ai 4.2.0 → 4.2.2
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 +17 -0
- package/dist/index.d.mts +125 -4
- package/dist/index.d.ts +125 -4
- package/dist/index.js +18 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -5
package/dist/index.mjs
CHANGED
@@ -6816,7 +6816,7 @@ function tool(tool2) {
|
|
6816
6816
|
}
|
6817
6817
|
|
6818
6818
|
// core/tool/mcp/mcp-sse-transport.ts
|
6819
|
-
import {
|
6819
|
+
import { createEventSourceParserStream } from "@ai-sdk/provider-utils";
|
6820
6820
|
|
6821
6821
|
// core/tool/mcp/json-rpc-message.ts
|
6822
6822
|
import { z as z9 } from "zod";
|
@@ -6957,9 +6957,13 @@ var JSONRPCMessageSchema = z9.union([
|
|
6957
6957
|
|
6958
6958
|
// core/tool/mcp/mcp-sse-transport.ts
|
6959
6959
|
var SseMCPTransport = class {
|
6960
|
-
constructor({
|
6960
|
+
constructor({
|
6961
|
+
url,
|
6962
|
+
headers
|
6963
|
+
}) {
|
6961
6964
|
this.connected = false;
|
6962
6965
|
this.url = new URL(url);
|
6966
|
+
this.headers = headers;
|
6963
6967
|
}
|
6964
6968
|
async start() {
|
6965
6969
|
return new Promise((resolve, reject) => {
|
@@ -6970,10 +6974,10 @@ var SseMCPTransport = class {
|
|
6970
6974
|
const establishConnection = async () => {
|
6971
6975
|
var _a17, _b, _c;
|
6972
6976
|
try {
|
6977
|
+
const headers = new Headers(this.headers);
|
6978
|
+
headers.set("Accept", "text/event-stream");
|
6973
6979
|
const response = await fetch(this.url.href, {
|
6974
|
-
headers
|
6975
|
-
Accept: "text/event-stream"
|
6976
|
-
},
|
6980
|
+
headers,
|
6977
6981
|
signal: (_a17 = this.abortController) == null ? void 0 : _a17.signal
|
6978
6982
|
});
|
6979
6983
|
if (!response.ok || !response.body) {
|
@@ -6983,7 +6987,7 @@ var SseMCPTransport = class {
|
|
6983
6987
|
(_b = this.onerror) == null ? void 0 : _b.call(this, error);
|
6984
6988
|
return reject(error);
|
6985
6989
|
}
|
6986
|
-
const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(
|
6990
|
+
const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(createEventSourceParserStream());
|
6987
6991
|
const reader = stream.getReader();
|
6988
6992
|
const processEvents = async () => {
|
6989
6993
|
var _a18, _b2, _c2;
|
@@ -7062,7 +7066,7 @@ var SseMCPTransport = class {
|
|
7062
7066
|
});
|
7063
7067
|
}
|
7064
7068
|
try {
|
7065
|
-
const headers = new Headers();
|
7069
|
+
const headers = new Headers(this.headers);
|
7066
7070
|
headers.set("Content-Type", "application/json");
|
7067
7071
|
const init = {
|
7068
7072
|
method: "POST",
|