x402-proxy 0.10.7 → 0.10.9
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 +23 -1
- package/README.md +7 -1
- package/dist/Credential-COZQnr1-.js +2055 -0
- package/dist/Mcp-CrCEqLqO.js +10 -0
- package/dist/Sse-ChldYgU7.js +9742 -0
- package/dist/Sse-kCB38G56.js +16482 -0
- package/dist/accounts-DsuvWwph.js +232 -0
- package/dist/accounts-DzvAlQRn.js +5 -0
- package/dist/accounts-IG-Cmrwy.js +229 -0
- package/dist/api-CUzmQvTQ.js +2802 -0
- package/dist/auth-DTzQmnZ_.js +1196 -0
- package/dist/bin/cli.js +585 -242
- package/dist/ccip-Bx-zoUCJ.js +240 -0
- package/dist/ccip-C2k1DD1T.js +153 -0
- package/dist/ccip-C6CQOJYv.js +152 -0
- package/dist/ccip-RZzsZ5Mv.js +156 -0
- package/dist/chain-CafcHffR.js +1997 -0
- package/dist/chain-DwfP5RGZ.js +1968 -0
- package/dist/chunk-DBEY4PJZ.js +16 -0
- package/dist/chunk-DjEMn6fM.js +36 -0
- package/dist/client-Blw2V7LF.js +657 -0
- package/dist/client-C37gWJOZ.js +102 -0
- package/dist/client-CEc4NYAA.js +6388 -0
- package/dist/client-CVDTUY0l.js +5152 -0
- package/dist/config-BUQsit4s.js +3 -0
- package/dist/config-DR1Fs_wL.js +6600 -0
- package/dist/{config-D9wIR3xc.js → config-rvKA3SYT.js} +10 -5
- package/dist/decodeFunctionData-DuFcwhC_.js +4510 -0
- package/dist/decodeFunctionData-JPOUdvil.js +4394 -0
- package/dist/derive-DNUl8LU9.js +9109 -0
- package/dist/dist-C2YO6HSQ.js +6581 -0
- package/dist/dist-DM5_F3r5.js +4 -0
- package/dist/dist-DxJCYyL5.js +1388 -0
- package/dist/hashTypedData-BHmP9dBd.js +859 -0
- package/dist/hashTypedData-CtEdfx4y.js +846 -0
- package/dist/helpers-CuUSw-tH.js +7125 -0
- package/dist/hmac-59IlS_by.js +648 -0
- package/dist/http-BAtucMbS.js +2060 -0
- package/dist/index.d.ts +1903 -9
- package/dist/index.js +18006 -50
- package/dist/index.node-CxkL0OFh.js +3592 -0
- package/dist/index.node-DvmeuZBj.js +3 -0
- package/dist/isAddressEqual-BLrd1Hg1.js +9 -0
- package/dist/isAddressEqual-DsAqfQOD.js +10 -0
- package/dist/localBatchGatewayRequest-C-RPJyDO.js +6260 -0
- package/dist/localBatchGatewayRequest-DOdQ9bR7.js +93 -0
- package/dist/localBatchGatewayRequest-DQkbZaSy.js +6261 -0
- package/dist/parseUnits-CApwcKSD.js +49 -0
- package/dist/parseUnits-cMO2udMe.js +48 -0
- package/dist/schemas-BxMFYNbH.js +1270 -0
- package/dist/secp256k1-BZpiyffY.js +2525 -0
- package/dist/secp256k1-BjenrLl5.js +1877 -0
- package/dist/secp256k1-CLPUX17u.js +3 -0
- package/dist/sendRawTransactionSync-DvSkhZtW.js +3612 -0
- package/dist/server-CSq0IuUq.js +565 -0
- package/dist/setup-BY4J49Lv.js +1110 -0
- package/dist/setup-wMOAgrsN.js +3 -0
- package/dist/sha256-FAs0qeni.js +17 -0
- package/dist/sha3-CYkWM8Xa.js +195 -0
- package/dist/sha3-DbMJRJ3C.js +194 -0
- package/dist/sse-B4LLqBQm.js +408 -0
- package/dist/status-Bu23RjW6.js +3 -0
- package/dist/{status-DihAcUSC.js → status-X21VnGUO.js} +16 -15
- package/dist/stdio-BADqxZdZ.js +85 -0
- package/dist/streamableHttp-BHkJypcI.js +358 -0
- package/dist/tempo-3nttrxgQ.js +17 -0
- package/dist/tempo-DER0P-ul.js +18 -0
- package/dist/types-BEKUz-Mf.js +1240 -0
- package/dist/types-DatK5vR5.js +3 -0
- package/dist/utils-BYjkXZDF.js +444 -0
- package/dist/utils-SeGHMW9O.js +445 -0
- package/dist/wallet-DKVlrR1S.js +3 -0
- package/dist/wallet-DSyht15_.js +17759 -0
- package/package.json +18 -71
- package/dist/config-B_upkJeK.js +0 -66
- package/dist/config-Be35NM5s.js +0 -3
- package/dist/config-J1m-CWXT.js +0 -27
- package/dist/derive-CL6e8K0Z.js +0 -81
- package/dist/openclaw/plugin.d.ts +0 -15
- package/dist/openclaw/plugin.js +0 -2067
- package/dist/openclaw.plugin.json +0 -93
- package/dist/setup-CNyMLnM-.js +0 -197
- package/dist/setup-DTIxPe58.js +0 -3
- package/dist/status-DZlJ4pS7.js +0 -3
- package/dist/wallet-B0S-rma9.js +0 -544
- package/dist/wallet-DBrVZJqe.js +0 -3
- package/openclaw.plugin.json +0 -93
- package/skills/SKILL.md +0 -183
- package/skills/references/library.md +0 -85
- package/skills/references/openclaw-plugin.md +0 -145
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { a as normalizeHeaders, i as createFetchWithInit, n as auth, o as createParser, r as extractWWWAuthenticateParams, t as UnauthorizedError } from "./auth-DTzQmnZ_.js";
|
|
3
|
+
import { Hn as isJSONRPCRequest, Un as isJSONRPCResultResponse, Z as JSONRPCMessageSchema, zn as isInitializedNotification } from "./types-BEKUz-Mf.js";
|
|
4
|
+
//#region node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/stream.js
|
|
5
|
+
var EventSourceParserStream = class extends TransformStream {
|
|
6
|
+
constructor({ onError, onRetry, onComment } = {}) {
|
|
7
|
+
let parser;
|
|
8
|
+
super({
|
|
9
|
+
start(controller) {
|
|
10
|
+
parser = createParser({
|
|
11
|
+
onEvent: (event) => {
|
|
12
|
+
controller.enqueue(event);
|
|
13
|
+
},
|
|
14
|
+
onError(error) {
|
|
15
|
+
onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
|
|
16
|
+
},
|
|
17
|
+
onRetry,
|
|
18
|
+
onComment
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
transform(chunk) {
|
|
22
|
+
parser.feed(chunk);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.28.0_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js
|
|
29
|
+
const DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {
|
|
30
|
+
initialReconnectionDelay: 1e3,
|
|
31
|
+
maxReconnectionDelay: 3e4,
|
|
32
|
+
reconnectionDelayGrowFactor: 1.5,
|
|
33
|
+
maxRetries: 2
|
|
34
|
+
};
|
|
35
|
+
var StreamableHTTPError = class extends Error {
|
|
36
|
+
constructor(code, message) {
|
|
37
|
+
super(`Streamable HTTP error: ${message}`);
|
|
38
|
+
this.code = code;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Client transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.
|
|
43
|
+
* It will connect to a server using HTTP POST for sending messages and HTTP GET with Server-Sent Events
|
|
44
|
+
* for receiving messages.
|
|
45
|
+
*/
|
|
46
|
+
var StreamableHTTPClientTransport = class {
|
|
47
|
+
constructor(url, opts) {
|
|
48
|
+
this._hasCompletedAuthFlow = false;
|
|
49
|
+
this._url = url;
|
|
50
|
+
this._resourceMetadataUrl = void 0;
|
|
51
|
+
this._scope = void 0;
|
|
52
|
+
this._requestInit = opts?.requestInit;
|
|
53
|
+
this._authProvider = opts?.authProvider;
|
|
54
|
+
this._fetch = opts?.fetch;
|
|
55
|
+
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
56
|
+
this._sessionId = opts?.sessionId;
|
|
57
|
+
this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
|
|
58
|
+
}
|
|
59
|
+
async _authThenStart() {
|
|
60
|
+
if (!this._authProvider) throw new UnauthorizedError("No auth provider");
|
|
61
|
+
let result;
|
|
62
|
+
try {
|
|
63
|
+
result = await auth(this._authProvider, {
|
|
64
|
+
serverUrl: this._url,
|
|
65
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
66
|
+
scope: this._scope,
|
|
67
|
+
fetchFn: this._fetchWithInit
|
|
68
|
+
});
|
|
69
|
+
} catch (error) {
|
|
70
|
+
this.onerror?.(error);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
if (result !== "AUTHORIZED") throw new UnauthorizedError();
|
|
74
|
+
return await this._startOrAuthSse({ resumptionToken: void 0 });
|
|
75
|
+
}
|
|
76
|
+
async _commonHeaders() {
|
|
77
|
+
const headers = {};
|
|
78
|
+
if (this._authProvider) {
|
|
79
|
+
const tokens = await this._authProvider.tokens();
|
|
80
|
+
if (tokens) headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
81
|
+
}
|
|
82
|
+
if (this._sessionId) headers["mcp-session-id"] = this._sessionId;
|
|
83
|
+
if (this._protocolVersion) headers["mcp-protocol-version"] = this._protocolVersion;
|
|
84
|
+
const extraHeaders = normalizeHeaders(this._requestInit?.headers);
|
|
85
|
+
return new Headers({
|
|
86
|
+
...headers,
|
|
87
|
+
...extraHeaders
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async _startOrAuthSse(options) {
|
|
91
|
+
const { resumptionToken } = options;
|
|
92
|
+
try {
|
|
93
|
+
const headers = await this._commonHeaders();
|
|
94
|
+
headers.set("Accept", "text/event-stream");
|
|
95
|
+
if (resumptionToken) headers.set("last-event-id", resumptionToken);
|
|
96
|
+
const response = await (this._fetch ?? fetch)(this._url, {
|
|
97
|
+
method: "GET",
|
|
98
|
+
headers,
|
|
99
|
+
signal: this._abortController?.signal
|
|
100
|
+
});
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
await response.body?.cancel();
|
|
103
|
+
if (response.status === 401 && this._authProvider) return await this._authThenStart();
|
|
104
|
+
if (response.status === 405) return;
|
|
105
|
+
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
|
|
106
|
+
}
|
|
107
|
+
this._handleSseStream(response.body, options, true);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
this.onerror?.(error);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Calculates the next reconnection delay using backoff algorithm
|
|
115
|
+
*
|
|
116
|
+
* @param attempt Current reconnection attempt count for the specific stream
|
|
117
|
+
* @returns Time to wait in milliseconds before next reconnection attempt
|
|
118
|
+
*/
|
|
119
|
+
_getNextReconnectionDelay(attempt) {
|
|
120
|
+
if (this._serverRetryMs !== void 0) return this._serverRetryMs;
|
|
121
|
+
const initialDelay = this._reconnectionOptions.initialReconnectionDelay;
|
|
122
|
+
const growFactor = this._reconnectionOptions.reconnectionDelayGrowFactor;
|
|
123
|
+
const maxDelay = this._reconnectionOptions.maxReconnectionDelay;
|
|
124
|
+
return Math.min(initialDelay * Math.pow(growFactor, attempt), maxDelay);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Schedule a reconnection attempt using server-provided retry interval or backoff
|
|
128
|
+
*
|
|
129
|
+
* @param lastEventId The ID of the last received event for resumability
|
|
130
|
+
* @param attemptCount Current reconnection attempt count for this specific stream
|
|
131
|
+
*/
|
|
132
|
+
_scheduleReconnection(options, attemptCount = 0) {
|
|
133
|
+
const maxRetries = this._reconnectionOptions.maxRetries;
|
|
134
|
+
if (attemptCount >= maxRetries) {
|
|
135
|
+
this.onerror?.(/* @__PURE__ */ new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const delay = this._getNextReconnectionDelay(attemptCount);
|
|
139
|
+
this._reconnectionTimeout = setTimeout(() => {
|
|
140
|
+
this._startOrAuthSse(options).catch((error) => {
|
|
141
|
+
this.onerror?.(/* @__PURE__ */ new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));
|
|
142
|
+
this._scheduleReconnection(options, attemptCount + 1);
|
|
143
|
+
});
|
|
144
|
+
}, delay);
|
|
145
|
+
}
|
|
146
|
+
_handleSseStream(stream, options, isReconnectable) {
|
|
147
|
+
if (!stream) return;
|
|
148
|
+
const { onresumptiontoken, replayMessageId } = options;
|
|
149
|
+
let lastEventId;
|
|
150
|
+
let hasPrimingEvent = false;
|
|
151
|
+
let receivedResponse = false;
|
|
152
|
+
const processStream = async () => {
|
|
153
|
+
try {
|
|
154
|
+
const reader = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream({ onRetry: (retryMs) => {
|
|
155
|
+
this._serverRetryMs = retryMs;
|
|
156
|
+
} })).getReader();
|
|
157
|
+
while (true) {
|
|
158
|
+
const { value: event, done } = await reader.read();
|
|
159
|
+
if (done) break;
|
|
160
|
+
if (event.id) {
|
|
161
|
+
lastEventId = event.id;
|
|
162
|
+
hasPrimingEvent = true;
|
|
163
|
+
onresumptiontoken?.(event.id);
|
|
164
|
+
}
|
|
165
|
+
if (!event.data) continue;
|
|
166
|
+
if (!event.event || event.event === "message") try {
|
|
167
|
+
const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
|
|
168
|
+
if (isJSONRPCResultResponse(message)) {
|
|
169
|
+
receivedResponse = true;
|
|
170
|
+
if (replayMessageId !== void 0) message.id = replayMessageId;
|
|
171
|
+
}
|
|
172
|
+
this.onmessage?.(message);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
this.onerror?.(error);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if ((isReconnectable || hasPrimingEvent) && !receivedResponse && this._abortController && !this._abortController.signal.aborted) this._scheduleReconnection({
|
|
178
|
+
resumptionToken: lastEventId,
|
|
179
|
+
onresumptiontoken,
|
|
180
|
+
replayMessageId
|
|
181
|
+
}, 0);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
this.onerror?.(/* @__PURE__ */ new Error(`SSE stream disconnected: ${error}`));
|
|
184
|
+
if ((isReconnectable || hasPrimingEvent) && !receivedResponse && this._abortController && !this._abortController.signal.aborted) try {
|
|
185
|
+
this._scheduleReconnection({
|
|
186
|
+
resumptionToken: lastEventId,
|
|
187
|
+
onresumptiontoken,
|
|
188
|
+
replayMessageId
|
|
189
|
+
}, 0);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
this.onerror?.(/* @__PURE__ */ new Error(`Failed to reconnect: ${error instanceof Error ? error.message : String(error)}`));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
processStream();
|
|
196
|
+
}
|
|
197
|
+
async start() {
|
|
198
|
+
if (this._abortController) throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
199
|
+
this._abortController = new AbortController();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
|
|
203
|
+
*/
|
|
204
|
+
async finishAuth(authorizationCode) {
|
|
205
|
+
if (!this._authProvider) throw new UnauthorizedError("No auth provider");
|
|
206
|
+
if (await auth(this._authProvider, {
|
|
207
|
+
serverUrl: this._url,
|
|
208
|
+
authorizationCode,
|
|
209
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
210
|
+
scope: this._scope,
|
|
211
|
+
fetchFn: this._fetchWithInit
|
|
212
|
+
}) !== "AUTHORIZED") throw new UnauthorizedError("Failed to authorize");
|
|
213
|
+
}
|
|
214
|
+
async close() {
|
|
215
|
+
if (this._reconnectionTimeout) {
|
|
216
|
+
clearTimeout(this._reconnectionTimeout);
|
|
217
|
+
this._reconnectionTimeout = void 0;
|
|
218
|
+
}
|
|
219
|
+
this._abortController?.abort();
|
|
220
|
+
this.onclose?.();
|
|
221
|
+
}
|
|
222
|
+
async send(message, options) {
|
|
223
|
+
try {
|
|
224
|
+
const { resumptionToken, onresumptiontoken } = options || {};
|
|
225
|
+
if (resumptionToken) {
|
|
226
|
+
this._startOrAuthSse({
|
|
227
|
+
resumptionToken,
|
|
228
|
+
replayMessageId: isJSONRPCRequest(message) ? message.id : void 0
|
|
229
|
+
}).catch((err) => this.onerror?.(err));
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const headers = await this._commonHeaders();
|
|
233
|
+
headers.set("content-type", "application/json");
|
|
234
|
+
headers.set("accept", "application/json, text/event-stream");
|
|
235
|
+
const init = {
|
|
236
|
+
...this._requestInit,
|
|
237
|
+
method: "POST",
|
|
238
|
+
headers,
|
|
239
|
+
body: JSON.stringify(message),
|
|
240
|
+
signal: this._abortController?.signal
|
|
241
|
+
};
|
|
242
|
+
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
243
|
+
const sessionId = response.headers.get("mcp-session-id");
|
|
244
|
+
if (sessionId) this._sessionId = sessionId;
|
|
245
|
+
if (!response.ok) {
|
|
246
|
+
const text = await response.text().catch(() => null);
|
|
247
|
+
if (response.status === 401 && this._authProvider) {
|
|
248
|
+
if (this._hasCompletedAuthFlow) throw new StreamableHTTPError(401, "Server returned 401 after successful authentication");
|
|
249
|
+
const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
|
|
250
|
+
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
251
|
+
this._scope = scope;
|
|
252
|
+
if (await auth(this._authProvider, {
|
|
253
|
+
serverUrl: this._url,
|
|
254
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
255
|
+
scope: this._scope,
|
|
256
|
+
fetchFn: this._fetchWithInit
|
|
257
|
+
}) !== "AUTHORIZED") throw new UnauthorizedError();
|
|
258
|
+
this._hasCompletedAuthFlow = true;
|
|
259
|
+
return this.send(message);
|
|
260
|
+
}
|
|
261
|
+
if (response.status === 403 && this._authProvider) {
|
|
262
|
+
const { resourceMetadataUrl, scope, error } = extractWWWAuthenticateParams(response);
|
|
263
|
+
if (error === "insufficient_scope") {
|
|
264
|
+
const wwwAuthHeader = response.headers.get("WWW-Authenticate");
|
|
265
|
+
if (this._lastUpscopingHeader === wwwAuthHeader) throw new StreamableHTTPError(403, "Server returned 403 after trying upscoping");
|
|
266
|
+
if (scope) this._scope = scope;
|
|
267
|
+
if (resourceMetadataUrl) this._resourceMetadataUrl = resourceMetadataUrl;
|
|
268
|
+
this._lastUpscopingHeader = wwwAuthHeader ?? void 0;
|
|
269
|
+
if (await auth(this._authProvider, {
|
|
270
|
+
serverUrl: this._url,
|
|
271
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
272
|
+
scope: this._scope,
|
|
273
|
+
fetchFn: this._fetch
|
|
274
|
+
}) !== "AUTHORIZED") throw new UnauthorizedError();
|
|
275
|
+
return this.send(message);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
|
|
279
|
+
}
|
|
280
|
+
this._hasCompletedAuthFlow = false;
|
|
281
|
+
this._lastUpscopingHeader = void 0;
|
|
282
|
+
if (response.status === 202) {
|
|
283
|
+
await response.body?.cancel();
|
|
284
|
+
if (isInitializedNotification(message)) this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => this.onerror?.(err));
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const hasRequests = (Array.isArray(message) ? message : [message]).filter((msg) => "method" in msg && "id" in msg && msg.id !== void 0).length > 0;
|
|
288
|
+
const contentType = response.headers.get("content-type");
|
|
289
|
+
if (hasRequests) if (contentType?.includes("text/event-stream")) this._handleSseStream(response.body, { onresumptiontoken }, false);
|
|
290
|
+
else if (contentType?.includes("application/json")) {
|
|
291
|
+
const data = await response.json();
|
|
292
|
+
const responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
|
|
293
|
+
for (const msg of responseMessages) this.onmessage?.(msg);
|
|
294
|
+
} else {
|
|
295
|
+
await response.body?.cancel();
|
|
296
|
+
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
|
|
297
|
+
}
|
|
298
|
+
else await response.body?.cancel();
|
|
299
|
+
} catch (error) {
|
|
300
|
+
this.onerror?.(error);
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
get sessionId() {
|
|
305
|
+
return this._sessionId;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Terminates the current session by sending a DELETE request to the server.
|
|
309
|
+
*
|
|
310
|
+
* Clients that no longer need a particular session
|
|
311
|
+
* (e.g., because the user is leaving the client application) SHOULD send an
|
|
312
|
+
* HTTP DELETE to the MCP endpoint with the Mcp-Session-Id header to explicitly
|
|
313
|
+
* terminate the session.
|
|
314
|
+
*
|
|
315
|
+
* The server MAY respond with HTTP 405 Method Not Allowed, indicating that
|
|
316
|
+
* the server does not allow clients to terminate sessions.
|
|
317
|
+
*/
|
|
318
|
+
async terminateSession() {
|
|
319
|
+
if (!this._sessionId) return;
|
|
320
|
+
try {
|
|
321
|
+
const headers = await this._commonHeaders();
|
|
322
|
+
const init = {
|
|
323
|
+
...this._requestInit,
|
|
324
|
+
method: "DELETE",
|
|
325
|
+
headers,
|
|
326
|
+
signal: this._abortController?.signal
|
|
327
|
+
};
|
|
328
|
+
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
329
|
+
await response.body?.cancel();
|
|
330
|
+
if (!response.ok && response.status !== 405) throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
|
|
331
|
+
this._sessionId = void 0;
|
|
332
|
+
} catch (error) {
|
|
333
|
+
this.onerror?.(error);
|
|
334
|
+
throw error;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
setProtocolVersion(version) {
|
|
338
|
+
this._protocolVersion = version;
|
|
339
|
+
}
|
|
340
|
+
get protocolVersion() {
|
|
341
|
+
return this._protocolVersion;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Resume an SSE stream from a previous event ID.
|
|
345
|
+
* Opens a GET SSE connection with Last-Event-ID header to replay missed events.
|
|
346
|
+
*
|
|
347
|
+
* @param lastEventId The event ID to resume from
|
|
348
|
+
* @param options Optional callback to receive new resumption tokens
|
|
349
|
+
*/
|
|
350
|
+
async resumeStream(lastEventId, options) {
|
|
351
|
+
await this._startOrAuthSse({
|
|
352
|
+
resumptionToken: lastEventId,
|
|
353
|
+
onresumptiontoken: options?.onresumptiontoken
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
//#endregion
|
|
358
|
+
export { StreamableHTTPClientTransport };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { n as __exportAll } from "./chunk-DBEY4PJZ.js";
|
|
2
|
+
import { d as Voucher_exports, i as Receipt_exports, l as Channel_exports, o as Chain_exports, r as ChannelStore_exports, t as Sse_exports } from "./Sse-kCB38G56.js";
|
|
3
|
+
//#region node_modules/.pnpm/mppx@0.5.1_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_openap_d8babfcabcc768186151f117bc0e35e5/node_modules/mppx/dist/tempo/session/Types.js
|
|
4
|
+
var Types_exports = /* @__PURE__ */ __exportAll({});
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region node_modules/.pnpm/mppx@0.5.1_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_openap_d8babfcabcc768186151f117bc0e35e5/node_modules/mppx/dist/tempo/session/index.js
|
|
7
|
+
var session_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
Chain: () => Chain_exports,
|
|
9
|
+
Channel: () => Channel_exports,
|
|
10
|
+
ChannelStore: () => ChannelStore_exports,
|
|
11
|
+
Receipt: () => Receipt_exports,
|
|
12
|
+
Sse: () => Sse_exports,
|
|
13
|
+
Types: () => Types_exports,
|
|
14
|
+
Voucher: () => Voucher_exports
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { session_exports as Session };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { n as __exportAll } from "./chunk-DjEMn6fM.js";
|
|
3
|
+
import { d as Voucher_exports, i as Receipt_exports, l as Channel_exports, o as Chain_exports, r as ChannelStore_exports, t as Sse_exports } from "./Sse-ChldYgU7.js";
|
|
4
|
+
//#region node_modules/.pnpm/mppx@0.5.1_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_openap_d8babfcabcc768186151f117bc0e35e5/node_modules/mppx/dist/tempo/session/Types.js
|
|
5
|
+
var Types_exports = /* @__PURE__ */ __exportAll({});
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region node_modules/.pnpm/mppx@0.5.1_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_openap_d8babfcabcc768186151f117bc0e35e5/node_modules/mppx/dist/tempo/session/index.js
|
|
8
|
+
var session_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
Chain: () => Chain_exports,
|
|
10
|
+
Channel: () => Channel_exports,
|
|
11
|
+
ChannelStore: () => ChannelStore_exports,
|
|
12
|
+
Receipt: () => Receipt_exports,
|
|
13
|
+
Sse: () => Sse_exports,
|
|
14
|
+
Types: () => Types_exports,
|
|
15
|
+
Voucher: () => Voucher_exports
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { session_exports as Session };
|