modality-ai 0.5.4 → 0.6.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/index.js +239 -30
- package/dist/types/ModalityClient.d.ts +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -126326,10 +126326,13 @@ function validateDownloadUrl(url2) {
|
|
|
126326
126326
|
message: `Invalid URL: ${url2}`
|
|
126327
126327
|
});
|
|
126328
126328
|
}
|
|
126329
|
+
if (parsed.protocol === "data:") {
|
|
126330
|
+
return;
|
|
126331
|
+
}
|
|
126329
126332
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
126330
126333
|
throw new DownloadError({
|
|
126331
126334
|
url: url2,
|
|
126332
|
-
message: `URL scheme must be http or
|
|
126335
|
+
message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
|
|
126333
126336
|
});
|
|
126334
126337
|
}
|
|
126335
126338
|
const hostname3 = parsed.hostname;
|
|
@@ -126556,7 +126559,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
126556
126559
|
normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
|
|
126557
126560
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
126558
126561
|
}
|
|
126559
|
-
var VERSION = "4.0.
|
|
126562
|
+
var VERSION = "4.0.22";
|
|
126560
126563
|
var getOriginalFetch = () => globalThis.fetch;
|
|
126561
126564
|
var getFromApi = async ({
|
|
126562
126565
|
url: url2,
|
|
@@ -128216,7 +128219,7 @@ async function* executeTool({
|
|
|
128216
128219
|
}
|
|
128217
128220
|
|
|
128218
128221
|
// node_modules/@ai-sdk/google/dist/index.mjs
|
|
128219
|
-
var VERSION2 = "3.0.
|
|
128222
|
+
var VERSION2 = "3.0.58";
|
|
128220
128223
|
var googleErrorDataSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
128221
128224
|
error: exports_external.object({
|
|
128222
128225
|
code: exports_external.number().nullable(),
|
|
@@ -128595,7 +128598,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue) {
|
|
|
128595
128598
|
}
|
|
128596
128599
|
}
|
|
128597
128600
|
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
128598
|
-
var _a16, _b16, _c, _d;
|
|
128601
|
+
var _a16, _b16, _c, _d, _e, _f, _g, _h;
|
|
128599
128602
|
const systemInstructionParts = [];
|
|
128600
128603
|
const contents = [];
|
|
128601
128604
|
let systemMessagesAllowed = true;
|
|
@@ -128680,6 +128683,18 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
128680
128683
|
};
|
|
128681
128684
|
}
|
|
128682
128685
|
case "tool-call": {
|
|
128686
|
+
const serverToolCallId = (providerOpts == null ? undefined : providerOpts.serverToolCallId) != null ? String(providerOpts.serverToolCallId) : undefined;
|
|
128687
|
+
const serverToolType = (providerOpts == null ? undefined : providerOpts.serverToolType) != null ? String(providerOpts.serverToolType) : undefined;
|
|
128688
|
+
if (serverToolCallId && serverToolType) {
|
|
128689
|
+
return {
|
|
128690
|
+
toolCall: {
|
|
128691
|
+
toolType: serverToolType,
|
|
128692
|
+
args: typeof part.input === "string" ? JSON.parse(part.input) : part.input,
|
|
128693
|
+
id: serverToolCallId
|
|
128694
|
+
},
|
|
128695
|
+
thoughtSignature
|
|
128696
|
+
};
|
|
128697
|
+
}
|
|
128683
128698
|
return {
|
|
128684
128699
|
functionCall: {
|
|
128685
128700
|
name: part.toolName,
|
|
@@ -128688,6 +128703,21 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
128688
128703
|
thoughtSignature
|
|
128689
128704
|
};
|
|
128690
128705
|
}
|
|
128706
|
+
case "tool-result": {
|
|
128707
|
+
const serverToolCallId = (providerOpts == null ? undefined : providerOpts.serverToolCallId) != null ? String(providerOpts.serverToolCallId) : undefined;
|
|
128708
|
+
const serverToolType = (providerOpts == null ? undefined : providerOpts.serverToolType) != null ? String(providerOpts.serverToolType) : undefined;
|
|
128709
|
+
if (serverToolCallId && serverToolType) {
|
|
128710
|
+
return {
|
|
128711
|
+
toolResponse: {
|
|
128712
|
+
toolType: serverToolType,
|
|
128713
|
+
response: part.output.type === "json" ? part.output.value : {},
|
|
128714
|
+
id: serverToolCallId
|
|
128715
|
+
},
|
|
128716
|
+
thoughtSignature
|
|
128717
|
+
};
|
|
128718
|
+
}
|
|
128719
|
+
return;
|
|
128720
|
+
}
|
|
128691
128721
|
}
|
|
128692
128722
|
}).filter((part) => part !== undefined)
|
|
128693
128723
|
});
|
|
@@ -128700,6 +128730,26 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
128700
128730
|
if (part.type === "tool-approval-response") {
|
|
128701
128731
|
continue;
|
|
128702
128732
|
}
|
|
128733
|
+
const partProviderOpts = (_g = (_d = part.providerOptions) == null ? undefined : _d[providerOptionsName]) != null ? _g : providerOptionsName !== "google" ? (_e = part.providerOptions) == null ? undefined : _e.google : (_f = part.providerOptions) == null ? undefined : _f.vertex;
|
|
128734
|
+
const serverToolCallId = (partProviderOpts == null ? undefined : partProviderOpts.serverToolCallId) != null ? String(partProviderOpts.serverToolCallId) : undefined;
|
|
128735
|
+
const serverToolType = (partProviderOpts == null ? undefined : partProviderOpts.serverToolType) != null ? String(partProviderOpts.serverToolType) : undefined;
|
|
128736
|
+
if (serverToolCallId && serverToolType) {
|
|
128737
|
+
const serverThoughtSignature = (partProviderOpts == null ? undefined : partProviderOpts.thoughtSignature) != null ? String(partProviderOpts.thoughtSignature) : undefined;
|
|
128738
|
+
if (contents.length > 0) {
|
|
128739
|
+
const lastContent = contents[contents.length - 1];
|
|
128740
|
+
if (lastContent.role === "model") {
|
|
128741
|
+
lastContent.parts.push({
|
|
128742
|
+
toolResponse: {
|
|
128743
|
+
toolType: serverToolType,
|
|
128744
|
+
response: part.output.type === "json" ? part.output.value : {},
|
|
128745
|
+
id: serverToolCallId
|
|
128746
|
+
},
|
|
128747
|
+
thoughtSignature: serverThoughtSignature
|
|
128748
|
+
});
|
|
128749
|
+
continue;
|
|
128750
|
+
}
|
|
128751
|
+
}
|
|
128752
|
+
}
|
|
128703
128753
|
const output = part.output;
|
|
128704
128754
|
if (output.type === "content") {
|
|
128705
128755
|
if (supportsFunctionResponseParts) {
|
|
@@ -128713,7 +128763,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
128713
128763
|
name: part.toolName,
|
|
128714
128764
|
response: {
|
|
128715
128765
|
name: part.toolName,
|
|
128716
|
-
content: output.type === "execution-denied" ? (
|
|
128766
|
+
content: output.type === "execution-denied" ? (_h = output.reason) != null ? _h : "Tool execution denied." : output.value
|
|
128717
128767
|
}
|
|
128718
128768
|
}
|
|
128719
128769
|
});
|
|
@@ -128810,14 +128860,15 @@ var googleLanguageModelOptions = lazySchema(() => zodSchema(exports_external.obj
|
|
|
128810
128860
|
latitude: exports_external.number(),
|
|
128811
128861
|
longitude: exports_external.number()
|
|
128812
128862
|
}).optional()
|
|
128813
|
-
}).optional()
|
|
128863
|
+
}).optional(),
|
|
128864
|
+
serviceTier: exports_external.enum(["standard", "flex", "priority"]).optional()
|
|
128814
128865
|
})));
|
|
128815
128866
|
function prepareTools({
|
|
128816
128867
|
tools,
|
|
128817
128868
|
toolChoice,
|
|
128818
128869
|
modelId
|
|
128819
128870
|
}) {
|
|
128820
|
-
var _a16;
|
|
128871
|
+
var _a16, _b16;
|
|
128821
128872
|
tools = (tools == null ? undefined : tools.length) ? tools : undefined;
|
|
128822
128873
|
const toolWarnings = [];
|
|
128823
128874
|
const isLatest = [
|
|
@@ -128826,13 +128877,14 @@ function prepareTools({
|
|
|
128826
128877
|
"gemini-pro-latest"
|
|
128827
128878
|
].some((id) => id === modelId);
|
|
128828
128879
|
const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
|
|
128880
|
+
const isGemini3orNewer = modelId.includes("gemini-3");
|
|
128829
128881
|
const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
|
|
128830
128882
|
if (tools == null) {
|
|
128831
128883
|
return { tools: undefined, toolConfig: undefined, toolWarnings };
|
|
128832
128884
|
}
|
|
128833
128885
|
const hasFunctionTools = tools.some((tool2) => tool2.type === "function");
|
|
128834
128886
|
const hasProviderTools = tools.some((tool2) => tool2.type === "provider");
|
|
128835
|
-
if (hasFunctionTools && hasProviderTools) {
|
|
128887
|
+
if (hasFunctionTools && hasProviderTools && !isGemini3orNewer) {
|
|
128836
128888
|
toolWarnings.push({
|
|
128837
128889
|
type: "unsupported",
|
|
128838
128890
|
feature: `combination of function and provider-defined tools`
|
|
@@ -128937,6 +128989,45 @@ function prepareTools({
|
|
|
128937
128989
|
break;
|
|
128938
128990
|
}
|
|
128939
128991
|
});
|
|
128992
|
+
if (hasFunctionTools && isGemini3orNewer && googleTools2.length > 0) {
|
|
128993
|
+
const functionDeclarations2 = [];
|
|
128994
|
+
for (const tool2 of tools) {
|
|
128995
|
+
if (tool2.type === "function") {
|
|
128996
|
+
functionDeclarations2.push({
|
|
128997
|
+
name: tool2.name,
|
|
128998
|
+
description: (_a16 = tool2.description) != null ? _a16 : "",
|
|
128999
|
+
parameters: convertJSONSchemaToOpenAPISchema(tool2.inputSchema)
|
|
129000
|
+
});
|
|
129001
|
+
}
|
|
129002
|
+
}
|
|
129003
|
+
const combinedToolConfig = {
|
|
129004
|
+
functionCallingConfig: { mode: "VALIDATED" },
|
|
129005
|
+
includeServerSideToolInvocations: true
|
|
129006
|
+
};
|
|
129007
|
+
if (toolChoice != null) {
|
|
129008
|
+
switch (toolChoice.type) {
|
|
129009
|
+
case "auto":
|
|
129010
|
+
break;
|
|
129011
|
+
case "none":
|
|
129012
|
+
combinedToolConfig.functionCallingConfig = { mode: "NONE" };
|
|
129013
|
+
break;
|
|
129014
|
+
case "required":
|
|
129015
|
+
combinedToolConfig.functionCallingConfig = { mode: "ANY" };
|
|
129016
|
+
break;
|
|
129017
|
+
case "tool":
|
|
129018
|
+
combinedToolConfig.functionCallingConfig = {
|
|
129019
|
+
mode: "ANY",
|
|
129020
|
+
allowedFunctionNames: [toolChoice.toolName]
|
|
129021
|
+
};
|
|
129022
|
+
break;
|
|
129023
|
+
}
|
|
129024
|
+
}
|
|
129025
|
+
return {
|
|
129026
|
+
tools: [...googleTools2, { functionDeclarations: functionDeclarations2 }],
|
|
129027
|
+
toolConfig: combinedToolConfig,
|
|
129028
|
+
toolWarnings
|
|
129029
|
+
};
|
|
129030
|
+
}
|
|
128940
129031
|
return {
|
|
128941
129032
|
tools: googleTools2.length > 0 ? googleTools2 : undefined,
|
|
128942
129033
|
toolConfig: undefined,
|
|
@@ -128950,7 +129041,7 @@ function prepareTools({
|
|
|
128950
129041
|
case "function":
|
|
128951
129042
|
functionDeclarations.push({
|
|
128952
129043
|
name: tool2.name,
|
|
128953
|
-
description: (
|
|
129044
|
+
description: (_b16 = tool2.description) != null ? _b16 : "",
|
|
128954
129045
|
parameters: convertJSONSchemaToOpenAPISchema(tool2.inputSchema)
|
|
128955
129046
|
});
|
|
128956
129047
|
if (tool2.strict === true) {
|
|
@@ -129144,14 +129235,15 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
129144
129235
|
retrievalConfig: googleOptions.retrievalConfig
|
|
129145
129236
|
} : googleToolConfig,
|
|
129146
129237
|
cachedContent: googleOptions == null ? undefined : googleOptions.cachedContent,
|
|
129147
|
-
labels: googleOptions == null ? undefined : googleOptions.labels
|
|
129238
|
+
labels: googleOptions == null ? undefined : googleOptions.labels,
|
|
129239
|
+
serviceTier: googleOptions == null ? undefined : googleOptions.serviceTier
|
|
129148
129240
|
},
|
|
129149
129241
|
warnings: [...warnings, ...toolWarnings],
|
|
129150
129242
|
providerOptionsName
|
|
129151
129243
|
};
|
|
129152
129244
|
}
|
|
129153
129245
|
async doGenerate(options) {
|
|
129154
|
-
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
129246
|
+
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
129155
129247
|
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
129156
129248
|
const mergedHeaders = combineHeaders(await resolve(this.config.headers), options.headers);
|
|
129157
129249
|
const {
|
|
@@ -129172,6 +129264,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
129172
129264
|
const parts = (_b16 = (_a16 = candidate.content) == null ? undefined : _a16.parts) != null ? _b16 : [];
|
|
129173
129265
|
const usageMetadata = response.usageMetadata;
|
|
129174
129266
|
let lastCodeExecutionToolCallId;
|
|
129267
|
+
let lastServerToolCallId;
|
|
129175
129268
|
for (const part of parts) {
|
|
129176
129269
|
if ("executableCode" in part && ((_c = part.executableCode) == null ? undefined : _c.code)) {
|
|
129177
129270
|
const toolCallId = this.config.generateId();
|
|
@@ -129238,12 +129331,56 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
129238
129331
|
}
|
|
129239
129332
|
} : undefined
|
|
129240
129333
|
});
|
|
129334
|
+
} else if ("toolCall" in part && part.toolCall) {
|
|
129335
|
+
const toolCallId = (_e = part.toolCall.id) != null ? _e : this.config.generateId();
|
|
129336
|
+
lastServerToolCallId = toolCallId;
|
|
129337
|
+
content.push({
|
|
129338
|
+
type: "tool-call",
|
|
129339
|
+
toolCallId,
|
|
129340
|
+
toolName: `server:${part.toolCall.toolType}`,
|
|
129341
|
+
input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
|
|
129342
|
+
providerExecuted: true,
|
|
129343
|
+
dynamic: true,
|
|
129344
|
+
providerMetadata: part.thoughtSignature ? {
|
|
129345
|
+
[providerOptionsName]: {
|
|
129346
|
+
thoughtSignature: part.thoughtSignature,
|
|
129347
|
+
serverToolCallId: toolCallId,
|
|
129348
|
+
serverToolType: part.toolCall.toolType
|
|
129349
|
+
}
|
|
129350
|
+
} : {
|
|
129351
|
+
[providerOptionsName]: {
|
|
129352
|
+
serverToolCallId: toolCallId,
|
|
129353
|
+
serverToolType: part.toolCall.toolType
|
|
129354
|
+
}
|
|
129355
|
+
}
|
|
129356
|
+
});
|
|
129357
|
+
} else if ("toolResponse" in part && part.toolResponse) {
|
|
129358
|
+
const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : this.config.generateId();
|
|
129359
|
+
content.push({
|
|
129360
|
+
type: "tool-result",
|
|
129361
|
+
toolCallId: responseToolCallId,
|
|
129362
|
+
toolName: `server:${part.toolResponse.toolType}`,
|
|
129363
|
+
result: (_h = part.toolResponse.response) != null ? _h : {},
|
|
129364
|
+
providerMetadata: part.thoughtSignature ? {
|
|
129365
|
+
[providerOptionsName]: {
|
|
129366
|
+
thoughtSignature: part.thoughtSignature,
|
|
129367
|
+
serverToolCallId: responseToolCallId,
|
|
129368
|
+
serverToolType: part.toolResponse.toolType
|
|
129369
|
+
}
|
|
129370
|
+
} : {
|
|
129371
|
+
[providerOptionsName]: {
|
|
129372
|
+
serverToolCallId: responseToolCallId,
|
|
129373
|
+
serverToolType: part.toolResponse.toolType
|
|
129374
|
+
}
|
|
129375
|
+
}
|
|
129376
|
+
});
|
|
129377
|
+
lastServerToolCallId = undefined;
|
|
129241
129378
|
}
|
|
129242
129379
|
}
|
|
129243
|
-
const sources = (
|
|
129380
|
+
const sources = (_i = extractSources({
|
|
129244
129381
|
groundingMetadata: candidate.groundingMetadata,
|
|
129245
129382
|
generateId: this.config.generateId
|
|
129246
|
-
})) != null ?
|
|
129383
|
+
})) != null ? _i : [];
|
|
129247
129384
|
for (const source of sources) {
|
|
129248
129385
|
content.push(source);
|
|
129249
129386
|
}
|
|
@@ -129254,18 +129391,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
129254
129391
|
finishReason: candidate.finishReason,
|
|
129255
129392
|
hasToolCalls: content.some((part) => part.type === "tool-call" && !part.providerExecuted)
|
|
129256
129393
|
}),
|
|
129257
|
-
raw: (
|
|
129394
|
+
raw: (_j = candidate.finishReason) != null ? _j : undefined
|
|
129258
129395
|
},
|
|
129259
129396
|
usage: convertGoogleGenerativeAIUsage(usageMetadata),
|
|
129260
129397
|
warnings,
|
|
129261
129398
|
providerMetadata: {
|
|
129262
129399
|
[providerOptionsName]: {
|
|
129263
|
-
promptFeedback: (
|
|
129264
|
-
groundingMetadata: (
|
|
129265
|
-
urlContextMetadata: (
|
|
129266
|
-
safetyRatings: (
|
|
129400
|
+
promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
|
|
129401
|
+
groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
|
|
129402
|
+
urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
|
|
129403
|
+
safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
|
|
129267
129404
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
129268
|
-
finishMessage: (
|
|
129405
|
+
finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
|
|
129406
|
+
serviceTier: (_p = response.serviceTier) != null ? _p : null
|
|
129269
129407
|
}
|
|
129270
129408
|
},
|
|
129271
129409
|
request: { body: args },
|
|
@@ -129295,6 +129433,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
129295
129433
|
let providerMetadata = undefined;
|
|
129296
129434
|
let lastGroundingMetadata = null;
|
|
129297
129435
|
let lastUrlContextMetadata = null;
|
|
129436
|
+
let serviceTier = null;
|
|
129298
129437
|
const generateId3 = this.config.generateId;
|
|
129299
129438
|
let hasToolCalls = false;
|
|
129300
129439
|
let currentTextBlockId = null;
|
|
@@ -129302,13 +129441,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
129302
129441
|
let blockCounter = 0;
|
|
129303
129442
|
const emittedSourceUrls = /* @__PURE__ */ new Set;
|
|
129304
129443
|
let lastCodeExecutionToolCallId;
|
|
129444
|
+
let lastServerToolCallId;
|
|
129305
129445
|
return {
|
|
129306
129446
|
stream: response.pipeThrough(new TransformStream({
|
|
129307
129447
|
start(controller) {
|
|
129308
129448
|
controller.enqueue({ type: "stream-start", warnings });
|
|
129309
129449
|
},
|
|
129310
129450
|
transform(chunk, controller) {
|
|
129311
|
-
var _a16, _b16, _c, _d, _e, _f, _g;
|
|
129451
|
+
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
129312
129452
|
if (options.includeRawChunks) {
|
|
129313
129453
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
129314
129454
|
}
|
|
@@ -129321,6 +129461,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
129321
129461
|
if (usageMetadata != null) {
|
|
129322
129462
|
usage = usageMetadata;
|
|
129323
129463
|
}
|
|
129464
|
+
if (value.serviceTier != null) {
|
|
129465
|
+
serviceTier = value.serviceTier;
|
|
129466
|
+
}
|
|
129324
129467
|
const candidate = (_a16 = value.candidates) == null ? undefined : _a16[0];
|
|
129325
129468
|
if (candidate == null) {
|
|
129326
129469
|
return;
|
|
@@ -129460,6 +129603,42 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
129460
129603
|
data: part.inlineData.data,
|
|
129461
129604
|
providerMetadata: fileMeta
|
|
129462
129605
|
});
|
|
129606
|
+
} else if ("toolCall" in part && part.toolCall) {
|
|
129607
|
+
const toolCallId = (_e = part.toolCall.id) != null ? _e : generateId3();
|
|
129608
|
+
lastServerToolCallId = toolCallId;
|
|
129609
|
+
const serverMeta = {
|
|
129610
|
+
[providerOptionsName]: {
|
|
129611
|
+
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
129612
|
+
serverToolCallId: toolCallId,
|
|
129613
|
+
serverToolType: part.toolCall.toolType
|
|
129614
|
+
}
|
|
129615
|
+
};
|
|
129616
|
+
controller.enqueue({
|
|
129617
|
+
type: "tool-call",
|
|
129618
|
+
toolCallId,
|
|
129619
|
+
toolName: `server:${part.toolCall.toolType}`,
|
|
129620
|
+
input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
|
|
129621
|
+
providerExecuted: true,
|
|
129622
|
+
dynamic: true,
|
|
129623
|
+
providerMetadata: serverMeta
|
|
129624
|
+
});
|
|
129625
|
+
} else if ("toolResponse" in part && part.toolResponse) {
|
|
129626
|
+
const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : generateId3();
|
|
129627
|
+
const serverMeta = {
|
|
129628
|
+
[providerOptionsName]: {
|
|
129629
|
+
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
129630
|
+
serverToolCallId: responseToolCallId,
|
|
129631
|
+
serverToolType: part.toolResponse.toolType
|
|
129632
|
+
}
|
|
129633
|
+
};
|
|
129634
|
+
controller.enqueue({
|
|
129635
|
+
type: "tool-result",
|
|
129636
|
+
toolCallId: responseToolCallId,
|
|
129637
|
+
toolName: `server:${part.toolResponse.toolType}`,
|
|
129638
|
+
result: (_h = part.toolResponse.response) != null ? _h : {},
|
|
129639
|
+
providerMetadata: serverMeta
|
|
129640
|
+
});
|
|
129641
|
+
lastServerToolCallId = undefined;
|
|
129463
129642
|
}
|
|
129464
129643
|
}
|
|
129465
129644
|
const toolCallDeltas = getToolCallsFromParts({
|
|
@@ -129507,12 +129686,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
129507
129686
|
};
|
|
129508
129687
|
providerMetadata = {
|
|
129509
129688
|
[providerOptionsName]: {
|
|
129510
|
-
promptFeedback: (
|
|
129689
|
+
promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
|
|
129511
129690
|
groundingMetadata: lastGroundingMetadata,
|
|
129512
129691
|
urlContextMetadata: lastUrlContextMetadata,
|
|
129513
|
-
safetyRatings: (
|
|
129692
|
+
safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
|
|
129514
129693
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
129515
|
-
finishMessage: (
|
|
129694
|
+
finishMessage: (_k = candidate.finishMessage) != null ? _k : null,
|
|
129695
|
+
serviceTier
|
|
129516
129696
|
}
|
|
129517
129697
|
};
|
|
129518
129698
|
}
|
|
@@ -129715,6 +129895,22 @@ var getContentSchema = () => exports_external.object({
|
|
|
129715
129895
|
thought: exports_external.boolean().nullish(),
|
|
129716
129896
|
thoughtSignature: exports_external.string().nullish()
|
|
129717
129897
|
}),
|
|
129898
|
+
exports_external.object({
|
|
129899
|
+
toolCall: exports_external.object({
|
|
129900
|
+
toolType: exports_external.string(),
|
|
129901
|
+
args: exports_external.unknown().nullish(),
|
|
129902
|
+
id: exports_external.string()
|
|
129903
|
+
}),
|
|
129904
|
+
thoughtSignature: exports_external.string().nullish()
|
|
129905
|
+
}),
|
|
129906
|
+
exports_external.object({
|
|
129907
|
+
toolResponse: exports_external.object({
|
|
129908
|
+
toolType: exports_external.string(),
|
|
129909
|
+
response: exports_external.unknown().nullish(),
|
|
129910
|
+
id: exports_external.string()
|
|
129911
|
+
}),
|
|
129912
|
+
thoughtSignature: exports_external.string().nullish()
|
|
129913
|
+
}),
|
|
129718
129914
|
exports_external.object({
|
|
129719
129915
|
executableCode: exports_external.object({
|
|
129720
129916
|
language: exports_external.string(),
|
|
@@ -129738,13 +129934,19 @@ var getSafetyRatingSchema = () => exports_external.object({
|
|
|
129738
129934
|
severityScore: exports_external.number().nullish(),
|
|
129739
129935
|
blocked: exports_external.boolean().nullish()
|
|
129740
129936
|
});
|
|
129937
|
+
var tokenDetailsSchema = exports_external.array(exports_external.object({
|
|
129938
|
+
modality: exports_external.string(),
|
|
129939
|
+
tokenCount: exports_external.number()
|
|
129940
|
+
})).nullish();
|
|
129741
129941
|
var usageSchema = exports_external.object({
|
|
129742
129942
|
cachedContentTokenCount: exports_external.number().nullish(),
|
|
129743
129943
|
thoughtsTokenCount: exports_external.number().nullish(),
|
|
129744
129944
|
promptTokenCount: exports_external.number().nullish(),
|
|
129745
129945
|
candidatesTokenCount: exports_external.number().nullish(),
|
|
129746
129946
|
totalTokenCount: exports_external.number().nullish(),
|
|
129747
|
-
trafficType: exports_external.string().nullish()
|
|
129947
|
+
trafficType: exports_external.string().nullish(),
|
|
129948
|
+
promptTokensDetails: tokenDetailsSchema,
|
|
129949
|
+
candidatesTokensDetails: tokenDetailsSchema
|
|
129748
129950
|
});
|
|
129749
129951
|
var getUrlContextMetadataSchema = () => exports_external.object({
|
|
129750
129952
|
urlMetadata: exports_external.array(exports_external.object({
|
|
@@ -129765,7 +129967,8 @@ var responseSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
|
129765
129967
|
promptFeedback: exports_external.object({
|
|
129766
129968
|
blockReason: exports_external.string().nullish(),
|
|
129767
129969
|
safetyRatings: exports_external.array(getSafetyRatingSchema()).nullish()
|
|
129768
|
-
}).nullish()
|
|
129970
|
+
}).nullish(),
|
|
129971
|
+
serviceTier: exports_external.string().nullish()
|
|
129769
129972
|
})));
|
|
129770
129973
|
var chunkSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
129771
129974
|
candidates: exports_external.array(exports_external.object({
|
|
@@ -129780,7 +129983,8 @@ var chunkSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
|
129780
129983
|
promptFeedback: exports_external.object({
|
|
129781
129984
|
blockReason: exports_external.string().nullish(),
|
|
129782
129985
|
safetyRatings: exports_external.array(getSafetyRatingSchema()).nullish()
|
|
129783
|
-
}).nullish()
|
|
129986
|
+
}).nullish(),
|
|
129987
|
+
serviceTier: exports_external.string().nullish()
|
|
129784
129988
|
})));
|
|
129785
129989
|
var codeExecution = createProviderToolFactoryWithOutputSchema({
|
|
129786
129990
|
id: "google.code_execution",
|
|
@@ -131592,7 +131796,7 @@ async function getVercelRequestId() {
|
|
|
131592
131796
|
var _a92;
|
|
131593
131797
|
return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
|
|
131594
131798
|
}
|
|
131595
|
-
var VERSION3 = "3.0.
|
|
131799
|
+
var VERSION3 = "3.0.88";
|
|
131596
131800
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
131597
131801
|
function createGatewayProvider(options = {}) {
|
|
131598
131802
|
var _a92, _b92;
|
|
@@ -132369,7 +132573,7 @@ function detectMediaType({
|
|
|
132369
132573
|
}
|
|
132370
132574
|
return;
|
|
132371
132575
|
}
|
|
132372
|
-
var VERSION4 = "6.0.
|
|
132576
|
+
var VERSION4 = "6.0.146";
|
|
132373
132577
|
var download = async ({
|
|
132374
132578
|
url: url2,
|
|
132375
132579
|
maxBytes,
|
|
@@ -136560,7 +136764,7 @@ class ModalityClientImpl {
|
|
|
136560
136764
|
await this.closeTransportAndKillProcess(this.transport);
|
|
136561
136765
|
} catch {}
|
|
136562
136766
|
}
|
|
136563
|
-
this.close();
|
|
136767
|
+
await this.close();
|
|
136564
136768
|
}
|
|
136565
136769
|
}
|
|
136566
136770
|
async callOnce(method, params, autoParse = true) {
|
|
@@ -136595,7 +136799,12 @@ class ModalityClientImpl {
|
|
|
136595
136799
|
}
|
|
136596
136800
|
});
|
|
136597
136801
|
}
|
|
136598
|
-
close() {
|
|
136802
|
+
async close() {
|
|
136803
|
+
if (this.transport) {
|
|
136804
|
+
try {
|
|
136805
|
+
await this.transport.close();
|
|
136806
|
+
} catch {}
|
|
136807
|
+
}
|
|
136599
136808
|
this.client.close();
|
|
136600
136809
|
this.connected = false;
|
|
136601
136810
|
this.transport = null;
|
|
@@ -45,7 +45,7 @@ declare class ModalityClientImpl {
|
|
|
45
45
|
*/
|
|
46
46
|
callOnceAndKill(method: string, params?: any, autoParse?: boolean): Promise<any>;
|
|
47
47
|
callStream(method: string, params?: any, callback?: (p: any) => void): ReadableStream;
|
|
48
|
-
close(): void
|
|
48
|
+
close(): Promise<void>;
|
|
49
49
|
listTools(): Promise<ListToolsResult>;
|
|
50
50
|
parseContent(toolResult: any): unknown;
|
|
51
51
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.6.0",
|
|
3
3
|
"name": "modality-ai",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
"author": "Hill <hill@kimo.com>",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
15
|
-
"modality-mcp-kit": "^1.
|
|
14
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
15
|
+
"modality-mcp-kit": "^1.6.2"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@ai-sdk/google": "^3.0.
|
|
19
|
-
"ai": "^6.0.
|
|
18
|
+
"@ai-sdk/google": "^3.0.58",
|
|
19
|
+
"ai": "^6.0.146",
|
|
20
20
|
"ollama-ai-provider": "^1.2.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/bun": "^1.3.11",
|
|
24
|
-
"modality-bun-kit": "^0.0.
|
|
24
|
+
"modality-bun-kit": "^0.0.4",
|
|
25
25
|
"typescript": "^6.0.2"
|
|
26
26
|
},
|
|
27
27
|
"exports": {
|