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/dist/index.mjs
CHANGED
@@ -7357,37 +7357,36 @@ var MCPClient = class {
|
|
7357
7357
|
};
|
7358
7358
|
|
7359
7359
|
// core/util/cosine-similarity.ts
|
7360
|
-
function cosineSimilarity(vector1, vector2, options
|
7361
|
-
throwErrorForEmptyVectors: false
|
7362
|
-
}) {
|
7363
|
-
const { throwErrorForEmptyVectors } = options;
|
7360
|
+
function cosineSimilarity(vector1, vector2, options) {
|
7364
7361
|
if (vector1.length !== vector2.length) {
|
7365
|
-
throw new Error(
|
7366
|
-
`Vectors must have the same length (vector1: ${vector1.length} elements, vector2: ${vector2.length} elements)`
|
7367
|
-
);
|
7368
|
-
}
|
7369
|
-
if (throwErrorForEmptyVectors && vector1.length === 0) {
|
7370
7362
|
throw new InvalidArgumentError({
|
7371
|
-
parameter: "vector1",
|
7372
|
-
value: vector1,
|
7373
|
-
message:
|
7363
|
+
parameter: "vector1,vector2",
|
7364
|
+
value: { vector1Length: vector1.length, vector2Length: vector2.length },
|
7365
|
+
message: `Vectors must have the same length`
|
7374
7366
|
});
|
7375
7367
|
}
|
7376
|
-
const
|
7377
|
-
|
7378
|
-
|
7368
|
+
const n = vector1.length;
|
7369
|
+
if (n === 0) {
|
7370
|
+
if (options == null ? void 0 : options.throwErrorForEmptyVectors) {
|
7371
|
+
throw new InvalidArgumentError({
|
7372
|
+
parameter: "vector1",
|
7373
|
+
value: vector1,
|
7374
|
+
message: "Vectors cannot be empty"
|
7375
|
+
});
|
7376
|
+
}
|
7379
7377
|
return 0;
|
7380
7378
|
}
|
7381
|
-
|
7382
|
-
|
7383
|
-
|
7384
|
-
|
7385
|
-
|
7386
|
-
|
7387
|
-
|
7388
|
-
|
7389
|
-
|
7390
|
-
|
7379
|
+
let magnitudeSquared1 = 0;
|
7380
|
+
let magnitudeSquared2 = 0;
|
7381
|
+
let dotProduct = 0;
|
7382
|
+
for (let i = 0; i < n; i++) {
|
7383
|
+
const value1 = vector1[i];
|
7384
|
+
const value2 = vector2[i];
|
7385
|
+
magnitudeSquared1 += value1 * value1;
|
7386
|
+
magnitudeSquared2 += value2 * value2;
|
7387
|
+
dotProduct += value1 * value2;
|
7388
|
+
}
|
7389
|
+
return magnitudeSquared1 === 0 || magnitudeSquared2 === 0 ? 0 : dotProduct / (Math.sqrt(magnitudeSquared1) * Math.sqrt(magnitudeSquared2));
|
7391
7390
|
}
|
7392
7391
|
|
7393
7392
|
// core/util/simulate-readable-stream.ts
|