ai 4.1.64 → 4.1.66
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +24 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -25
- package/dist/index.mjs.map +1 -1
- package/mcp-stdio/create-child-process.ts +56 -0
- package/mcp-stdio/dist/index.d.mts +169 -0
- package/mcp-stdio/dist/index.d.ts +169 -0
- package/mcp-stdio/dist/index.js +348 -0
- package/mcp-stdio/dist/index.js.map +1 -0
- package/mcp-stdio/dist/index.mjs +333 -0
- package/mcp-stdio/dist/index.mjs.map +1 -0
- package/mcp-stdio/index.ts +4 -0
- package/mcp-stdio/mcp-stdio-transport.test.ts +262 -0
- package/mcp-stdio/mcp-stdio-transport.ts +157 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
@@ -3832,10 +3832,14 @@ declare function experimental_createProviderRegistry(providers: Record<string, P
|
|
3832
3832
|
*
|
3833
3833
|
* @returns The cosine similarity between vector1 and vector2.
|
3834
3834
|
* @returns 0 if either vector is the zero vector.
|
3835
|
+
*
|
3835
3836
|
* @throws {InvalidArgumentError} If throwErrorForEmptyVectors is true and vectors are empty.
|
3836
|
-
* @throws {
|
3837
|
+
* @throws {InvalidArgumentError} If the vectors do not have the same length.
|
3837
3838
|
*/
|
3838
3839
|
declare function cosineSimilarity(vector1: number[], vector2: number[], options?: {
|
3840
|
+
/**
|
3841
|
+
* @deprecated will be removed in 5.0
|
3842
|
+
*/
|
3839
3843
|
throwErrorForEmptyVectors?: boolean;
|
3840
3844
|
}): number;
|
3841
3845
|
|
package/dist/index.d.ts
CHANGED
@@ -3832,10 +3832,14 @@ declare function experimental_createProviderRegistry(providers: Record<string, P
|
|
3832
3832
|
*
|
3833
3833
|
* @returns The cosine similarity between vector1 and vector2.
|
3834
3834
|
* @returns 0 if either vector is the zero vector.
|
3835
|
+
*
|
3835
3836
|
* @throws {InvalidArgumentError} If throwErrorForEmptyVectors is true and vectors are empty.
|
3836
|
-
* @throws {
|
3837
|
+
* @throws {InvalidArgumentError} If the vectors do not have the same length.
|
3837
3838
|
*/
|
3838
3839
|
declare function cosineSimilarity(vector1: number[], vector2: number[], options?: {
|
3840
|
+
/**
|
3841
|
+
* @deprecated will be removed in 5.0
|
3842
|
+
*/
|
3839
3843
|
throwErrorForEmptyVectors?: boolean;
|
3840
3844
|
}): number;
|
3841
3845
|
|
package/dist/index.js
CHANGED
@@ -7406,37 +7406,36 @@ var MCPClient = class {
|
|
7406
7406
|
};
|
7407
7407
|
|
7408
7408
|
// core/util/cosine-similarity.ts
|
7409
|
-
function cosineSimilarity(vector1, vector2, options
|
7410
|
-
throwErrorForEmptyVectors: false
|
7411
|
-
}) {
|
7412
|
-
const { throwErrorForEmptyVectors } = options;
|
7409
|
+
function cosineSimilarity(vector1, vector2, options) {
|
7413
7410
|
if (vector1.length !== vector2.length) {
|
7414
|
-
throw new Error(
|
7415
|
-
`Vectors must have the same length (vector1: ${vector1.length} elements, vector2: ${vector2.length} elements)`
|
7416
|
-
);
|
7417
|
-
}
|
7418
|
-
if (throwErrorForEmptyVectors && vector1.length === 0) {
|
7419
7411
|
throw new InvalidArgumentError({
|
7420
|
-
parameter: "vector1",
|
7421
|
-
value: vector1,
|
7422
|
-
message:
|
7412
|
+
parameter: "vector1,vector2",
|
7413
|
+
value: { vector1Length: vector1.length, vector2Length: vector2.length },
|
7414
|
+
message: `Vectors must have the same length`
|
7423
7415
|
});
|
7424
7416
|
}
|
7425
|
-
const
|
7426
|
-
|
7427
|
-
|
7417
|
+
const n = vector1.length;
|
7418
|
+
if (n === 0) {
|
7419
|
+
if (options == null ? void 0 : options.throwErrorForEmptyVectors) {
|
7420
|
+
throw new InvalidArgumentError({
|
7421
|
+
parameter: "vector1",
|
7422
|
+
value: vector1,
|
7423
|
+
message: "Vectors cannot be empty"
|
7424
|
+
});
|
7425
|
+
}
|
7428
7426
|
return 0;
|
7429
7427
|
}
|
7430
|
-
|
7431
|
-
|
7432
|
-
|
7433
|
-
|
7434
|
-
|
7435
|
-
|
7436
|
-
|
7437
|
-
|
7438
|
-
|
7439
|
-
|
7428
|
+
let magnitudeSquared1 = 0;
|
7429
|
+
let magnitudeSquared2 = 0;
|
7430
|
+
let dotProduct = 0;
|
7431
|
+
for (let i = 0; i < n; i++) {
|
7432
|
+
const value1 = vector1[i];
|
7433
|
+
const value2 = vector2[i];
|
7434
|
+
magnitudeSquared1 += value1 * value1;
|
7435
|
+
magnitudeSquared2 += value2 * value2;
|
7436
|
+
dotProduct += value1 * value2;
|
7437
|
+
}
|
7438
|
+
return magnitudeSquared1 === 0 || magnitudeSquared2 === 0 ? 0 : dotProduct / (Math.sqrt(magnitudeSquared1) * Math.sqrt(magnitudeSquared2));
|
7440
7439
|
}
|
7441
7440
|
|
7442
7441
|
// core/util/simulate-readable-stream.ts
|