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.
Files changed (90) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/README.md +7 -1
  3. package/dist/Credential-COZQnr1-.js +2055 -0
  4. package/dist/Mcp-CrCEqLqO.js +10 -0
  5. package/dist/Sse-ChldYgU7.js +9742 -0
  6. package/dist/Sse-kCB38G56.js +16482 -0
  7. package/dist/accounts-DsuvWwph.js +232 -0
  8. package/dist/accounts-DzvAlQRn.js +5 -0
  9. package/dist/accounts-IG-Cmrwy.js +229 -0
  10. package/dist/api-CUzmQvTQ.js +2802 -0
  11. package/dist/auth-DTzQmnZ_.js +1196 -0
  12. package/dist/bin/cli.js +585 -242
  13. package/dist/ccip-Bx-zoUCJ.js +240 -0
  14. package/dist/ccip-C2k1DD1T.js +153 -0
  15. package/dist/ccip-C6CQOJYv.js +152 -0
  16. package/dist/ccip-RZzsZ5Mv.js +156 -0
  17. package/dist/chain-CafcHffR.js +1997 -0
  18. package/dist/chain-DwfP5RGZ.js +1968 -0
  19. package/dist/chunk-DBEY4PJZ.js +16 -0
  20. package/dist/chunk-DjEMn6fM.js +36 -0
  21. package/dist/client-Blw2V7LF.js +657 -0
  22. package/dist/client-C37gWJOZ.js +102 -0
  23. package/dist/client-CEc4NYAA.js +6388 -0
  24. package/dist/client-CVDTUY0l.js +5152 -0
  25. package/dist/config-BUQsit4s.js +3 -0
  26. package/dist/config-DR1Fs_wL.js +6600 -0
  27. package/dist/{config-D9wIR3xc.js → config-rvKA3SYT.js} +10 -5
  28. package/dist/decodeFunctionData-DuFcwhC_.js +4510 -0
  29. package/dist/decodeFunctionData-JPOUdvil.js +4394 -0
  30. package/dist/derive-DNUl8LU9.js +9109 -0
  31. package/dist/dist-C2YO6HSQ.js +6581 -0
  32. package/dist/dist-DM5_F3r5.js +4 -0
  33. package/dist/dist-DxJCYyL5.js +1388 -0
  34. package/dist/hashTypedData-BHmP9dBd.js +859 -0
  35. package/dist/hashTypedData-CtEdfx4y.js +846 -0
  36. package/dist/helpers-CuUSw-tH.js +7125 -0
  37. package/dist/hmac-59IlS_by.js +648 -0
  38. package/dist/http-BAtucMbS.js +2060 -0
  39. package/dist/index.d.ts +1903 -9
  40. package/dist/index.js +18006 -50
  41. package/dist/index.node-CxkL0OFh.js +3592 -0
  42. package/dist/index.node-DvmeuZBj.js +3 -0
  43. package/dist/isAddressEqual-BLrd1Hg1.js +9 -0
  44. package/dist/isAddressEqual-DsAqfQOD.js +10 -0
  45. package/dist/localBatchGatewayRequest-C-RPJyDO.js +6260 -0
  46. package/dist/localBatchGatewayRequest-DOdQ9bR7.js +93 -0
  47. package/dist/localBatchGatewayRequest-DQkbZaSy.js +6261 -0
  48. package/dist/parseUnits-CApwcKSD.js +49 -0
  49. package/dist/parseUnits-cMO2udMe.js +48 -0
  50. package/dist/schemas-BxMFYNbH.js +1270 -0
  51. package/dist/secp256k1-BZpiyffY.js +2525 -0
  52. package/dist/secp256k1-BjenrLl5.js +1877 -0
  53. package/dist/secp256k1-CLPUX17u.js +3 -0
  54. package/dist/sendRawTransactionSync-DvSkhZtW.js +3612 -0
  55. package/dist/server-CSq0IuUq.js +565 -0
  56. package/dist/setup-BY4J49Lv.js +1110 -0
  57. package/dist/setup-wMOAgrsN.js +3 -0
  58. package/dist/sha256-FAs0qeni.js +17 -0
  59. package/dist/sha3-CYkWM8Xa.js +195 -0
  60. package/dist/sha3-DbMJRJ3C.js +194 -0
  61. package/dist/sse-B4LLqBQm.js +408 -0
  62. package/dist/status-Bu23RjW6.js +3 -0
  63. package/dist/{status-DihAcUSC.js → status-X21VnGUO.js} +16 -15
  64. package/dist/stdio-BADqxZdZ.js +85 -0
  65. package/dist/streamableHttp-BHkJypcI.js +358 -0
  66. package/dist/tempo-3nttrxgQ.js +17 -0
  67. package/dist/tempo-DER0P-ul.js +18 -0
  68. package/dist/types-BEKUz-Mf.js +1240 -0
  69. package/dist/types-DatK5vR5.js +3 -0
  70. package/dist/utils-BYjkXZDF.js +444 -0
  71. package/dist/utils-SeGHMW9O.js +445 -0
  72. package/dist/wallet-DKVlrR1S.js +3 -0
  73. package/dist/wallet-DSyht15_.js +17759 -0
  74. package/package.json +18 -71
  75. package/dist/config-B_upkJeK.js +0 -66
  76. package/dist/config-Be35NM5s.js +0 -3
  77. package/dist/config-J1m-CWXT.js +0 -27
  78. package/dist/derive-CL6e8K0Z.js +0 -81
  79. package/dist/openclaw/plugin.d.ts +0 -15
  80. package/dist/openclaw/plugin.js +0 -2067
  81. package/dist/openclaw.plugin.json +0 -93
  82. package/dist/setup-CNyMLnM-.js +0 -197
  83. package/dist/setup-DTIxPe58.js +0 -3
  84. package/dist/status-DZlJ4pS7.js +0 -3
  85. package/dist/wallet-B0S-rma9.js +0 -544
  86. package/dist/wallet-DBrVZJqe.js +0 -3
  87. package/openclaw.plugin.json +0 -93
  88. package/skills/SKILL.md +0 -183
  89. package/skills/references/library.md +0 -85
  90. package/skills/references/openclaw-plugin.md +0 -145
@@ -0,0 +1,408 @@
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 { Z as JSONRPCMessageSchema } from "./types-BEKUz-Mf.js";
4
+ //#region node_modules/.pnpm/eventsource@3.0.7/node_modules/eventsource/dist/index.js
5
+ var ErrorEvent = class extends Event {
6
+ /**
7
+ * Constructs a new `ErrorEvent` instance. This is typically not called directly,
8
+ * but rather emitted by the `EventSource` object when an error occurs.
9
+ *
10
+ * @param type - The type of the event (should be "error")
11
+ * @param errorEventInitDict - Optional properties to include in the error event
12
+ */
13
+ constructor(type, errorEventInitDict) {
14
+ var _a, _b;
15
+ super(type), this.code = (_a = errorEventInitDict == null ? void 0 : errorEventInitDict.code) != null ? _a : void 0, this.message = (_b = errorEventInitDict == null ? void 0 : errorEventInitDict.message) != null ? _b : void 0;
16
+ }
17
+ /**
18
+ * Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
19
+ * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
20
+ * we explicitly include the properties in the `inspect` method.
21
+ *
22
+ * This is automatically called by Node.js when you `console.log` an instance of this class.
23
+ *
24
+ * @param _depth - The current depth
25
+ * @param options - The options passed to `util.inspect`
26
+ * @param inspect - The inspect function to use (prevents having to import it from `util`)
27
+ * @returns A string representation of the error
28
+ */
29
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
30
+ return inspect(inspectableError(this), options);
31
+ }
32
+ /**
33
+ * Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
34
+ * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
35
+ * we explicitly include the properties in the `inspect` method.
36
+ *
37
+ * This is automatically called by Deno when you `console.log` an instance of this class.
38
+ *
39
+ * @param inspect - The inspect function to use (prevents having to import it from `util`)
40
+ * @param options - The options passed to `Deno.inspect`
41
+ * @returns A string representation of the error
42
+ */
43
+ [Symbol.for("Deno.customInspect")](inspect, options) {
44
+ return inspect(inspectableError(this), options);
45
+ }
46
+ };
47
+ function syntaxError(message) {
48
+ const DomException = globalThis.DOMException;
49
+ return typeof DomException == "function" ? new DomException(message, "SyntaxError") : new SyntaxError(message);
50
+ }
51
+ function flattenError(err) {
52
+ return err instanceof Error ? "errors" in err && Array.isArray(err.errors) ? err.errors.map(flattenError).join(", ") : "cause" in err && err.cause instanceof Error ? `${err}: ${flattenError(err.cause)}` : err.message : `${err}`;
53
+ }
54
+ function inspectableError(err) {
55
+ return {
56
+ type: err.type,
57
+ message: err.message,
58
+ code: err.code,
59
+ defaultPrevented: err.defaultPrevented,
60
+ cancelable: err.cancelable,
61
+ timeStamp: err.timeStamp
62
+ };
63
+ }
64
+ var __typeError = (msg) => {
65
+ throw TypeError(msg);
66
+ }, __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method), _readyState, _url, _redirectUrl, _withCredentials, _fetch, _reconnectInterval, _reconnectTimer, _lastEventId, _controller, _parser, _onError, _onMessage, _onOpen, _EventSource_instances, connect_fn, _onFetchResponse, _onFetchError, getRequestOptions_fn, _onEvent, _onRetryChange, failConnection_fn, scheduleReconnect_fn, _reconnect;
67
+ var EventSource = class extends EventTarget {
68
+ constructor(url, eventSourceInitDict) {
69
+ var _a, _b;
70
+ super(), __privateAdd(this, _EventSource_instances), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, __privateAdd(this, _readyState), __privateAdd(this, _url), __privateAdd(this, _redirectUrl), __privateAdd(this, _withCredentials), __privateAdd(this, _fetch), __privateAdd(this, _reconnectInterval), __privateAdd(this, _reconnectTimer), __privateAdd(this, _lastEventId, null), __privateAdd(this, _controller), __privateAdd(this, _parser), __privateAdd(this, _onError, null), __privateAdd(this, _onMessage, null), __privateAdd(this, _onOpen, null), __privateAdd(this, _onFetchResponse, async (response) => {
71
+ var _a2;
72
+ __privateGet(this, _parser).reset();
73
+ const { body, redirected, status, headers } = response;
74
+ if (status === 204) {
75
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
76
+ return;
77
+ }
78
+ if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {
79
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);
80
+ return;
81
+ }
82
+ if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {
83
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid content type, expected \"text/event-stream\"", status);
84
+ return;
85
+ }
86
+ if (__privateGet(this, _readyState) === this.CLOSED) return;
87
+ __privateSet(this, _readyState, this.OPEN);
88
+ const openEvent = new Event("open");
89
+ if ((_a2 = __privateGet(this, _onOpen)) == null || _a2.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {
90
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
91
+ return;
92
+ }
93
+ const decoder = new TextDecoder(), reader = body.getReader();
94
+ let open = !0;
95
+ do {
96
+ const { done, value } = await reader.read();
97
+ value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (open = !1, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
98
+ } while (open);
99
+ }), __privateAdd(this, _onFetchError, (err) => {
100
+ __privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError(err));
101
+ }), __privateAdd(this, _onEvent, (event) => {
102
+ typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);
103
+ const messageEvent = new MessageEvent(event.event || "message", {
104
+ data: event.data,
105
+ origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url).origin,
106
+ lastEventId: event.id || ""
107
+ });
108
+ __privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);
109
+ }), __privateAdd(this, _onRetryChange, (value) => {
110
+ __privateSet(this, _reconnectInterval, value);
111
+ }), __privateAdd(this, _reconnect, () => {
112
+ __privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
113
+ });
114
+ try {
115
+ if (url instanceof URL) __privateSet(this, _url, url);
116
+ else if (typeof url == "string") __privateSet(this, _url, new URL(url, getBaseURL()));
117
+ else throw new Error("Invalid URL");
118
+ } catch {
119
+ throw syntaxError("An invalid or illegal string was specified");
120
+ }
121
+ __privateSet(this, _parser, createParser({
122
+ onEvent: __privateGet(this, _onEvent),
123
+ onRetry: __privateGet(this, _onRetryChange)
124
+ })), __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _reconnectInterval, 3e3), __privateSet(this, _fetch, (_a = eventSourceInitDict == null ? void 0 : eventSourceInitDict.fetch) != null ? _a : globalThis.fetch), __privateSet(this, _withCredentials, (_b = eventSourceInitDict == null ? void 0 : eventSourceInitDict.withCredentials) != null ? _b : !1), __privateMethod(this, _EventSource_instances, connect_fn).call(this);
125
+ }
126
+ /**
127
+ * Returns the state of this EventSource object's connection. It can have the values described below.
128
+ *
129
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
130
+ *
131
+ * Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
132
+ * defined in the TypeScript `dom` library.
133
+ *
134
+ * @public
135
+ */
136
+ get readyState() {
137
+ return __privateGet(this, _readyState);
138
+ }
139
+ /**
140
+ * Returns the URL providing the event stream.
141
+ *
142
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
143
+ *
144
+ * @public
145
+ */
146
+ get url() {
147
+ return __privateGet(this, _url).href;
148
+ }
149
+ /**
150
+ * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
151
+ *
152
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
153
+ */
154
+ get withCredentials() {
155
+ return __privateGet(this, _withCredentials);
156
+ }
157
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
158
+ get onerror() {
159
+ return __privateGet(this, _onError);
160
+ }
161
+ set onerror(value) {
162
+ __privateSet(this, _onError, value);
163
+ }
164
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
165
+ get onmessage() {
166
+ return __privateGet(this, _onMessage);
167
+ }
168
+ set onmessage(value) {
169
+ __privateSet(this, _onMessage, value);
170
+ }
171
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
172
+ get onopen() {
173
+ return __privateGet(this, _onOpen);
174
+ }
175
+ set onopen(value) {
176
+ __privateSet(this, _onOpen, value);
177
+ }
178
+ addEventListener(type, listener, options) {
179
+ const listen = listener;
180
+ super.addEventListener(type, listen, options);
181
+ }
182
+ removeEventListener(type, listener, options) {
183
+ const listen = listener;
184
+ super.removeEventListener(type, listen, options);
185
+ }
186
+ /**
187
+ * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
188
+ *
189
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
190
+ *
191
+ * @public
192
+ */
193
+ close() {
194
+ __privateGet(this, _reconnectTimer) && clearTimeout(__privateGet(this, _reconnectTimer)), __privateGet(this, _readyState) !== this.CLOSED && (__privateGet(this, _controller) && __privateGet(this, _controller).abort(), __privateSet(this, _readyState, this.CLOSED), __privateSet(this, _controller, void 0));
195
+ }
196
+ };
197
+ _readyState = /* @__PURE__ */ new WeakMap(), _url = /* @__PURE__ */ new WeakMap(), _redirectUrl = /* @__PURE__ */ new WeakMap(), _withCredentials = /* @__PURE__ */ new WeakMap(), _fetch = /* @__PURE__ */ new WeakMap(), _reconnectInterval = /* @__PURE__ */ new WeakMap(), _reconnectTimer = /* @__PURE__ */ new WeakMap(), _lastEventId = /* @__PURE__ */ new WeakMap(), _controller = /* @__PURE__ */ new WeakMap(), _parser = /* @__PURE__ */ new WeakMap(), _onError = /* @__PURE__ */ new WeakMap(), _onMessage = /* @__PURE__ */ new WeakMap(), _onOpen = /* @__PURE__ */ new WeakMap(), _EventSource_instances = /* @__PURE__ */ new WeakSet(), connect_fn = function() {
198
+ __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _controller, new AbortController()), __privateGet(this, _fetch)(__privateGet(this, _url), __privateMethod(this, _EventSource_instances, getRequestOptions_fn).call(this)).then(__privateGet(this, _onFetchResponse)).catch(__privateGet(this, _onFetchError));
199
+ }, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), getRequestOptions_fn = function() {
200
+ var _a;
201
+ const init = {
202
+ mode: "cors",
203
+ redirect: "follow",
204
+ headers: {
205
+ Accept: "text/event-stream",
206
+ ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0
207
+ },
208
+ cache: "no-store",
209
+ signal: (_a = __privateGet(this, _controller)) == null ? void 0 : _a.signal
210
+ };
211
+ return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;
212
+ }, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), failConnection_fn = function(message, code) {
213
+ var _a;
214
+ __privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
215
+ const errorEvent = new ErrorEvent("error", {
216
+ code,
217
+ message
218
+ });
219
+ (_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent);
220
+ }, scheduleReconnect_fn = function(message, code) {
221
+ var _a;
222
+ if (__privateGet(this, _readyState) === this.CLOSED) return;
223
+ __privateSet(this, _readyState, this.CONNECTING);
224
+ const errorEvent = new ErrorEvent("error", {
225
+ code,
226
+ message
227
+ });
228
+ (_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
229
+ }, _reconnect = /* @__PURE__ */ new WeakMap(), EventSource.CONNECTING = 0, EventSource.OPEN = 1, EventSource.CLOSED = 2;
230
+ function getBaseURL() {
231
+ const doc = "document" in globalThis ? globalThis.document : void 0;
232
+ return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
233
+ }
234
+ //#endregion
235
+ //#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.28.0_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js
236
+ var SseError = class extends Error {
237
+ constructor(code, message, event) {
238
+ super(`SSE error: ${message}`);
239
+ this.code = code;
240
+ this.event = event;
241
+ }
242
+ };
243
+ /**
244
+ * Client transport for SSE: this will connect to a server using Server-Sent Events for receiving
245
+ * messages and make separate POST requests for sending messages.
246
+ * @deprecated SSEClientTransport is deprecated. Prefer to use StreamableHTTPClientTransport where possible instead. Note that because some servers are still using SSE, clients may need to support both transports during the migration period.
247
+ */
248
+ var SSEClientTransport = class {
249
+ constructor(url, opts) {
250
+ this._url = url;
251
+ this._resourceMetadataUrl = void 0;
252
+ this._scope = void 0;
253
+ this._eventSourceInit = opts?.eventSourceInit;
254
+ this._requestInit = opts?.requestInit;
255
+ this._authProvider = opts?.authProvider;
256
+ this._fetch = opts?.fetch;
257
+ this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
258
+ }
259
+ async _authThenStart() {
260
+ if (!this._authProvider) throw new UnauthorizedError("No auth provider");
261
+ let result;
262
+ try {
263
+ result = await auth(this._authProvider, {
264
+ serverUrl: this._url,
265
+ resourceMetadataUrl: this._resourceMetadataUrl,
266
+ scope: this._scope,
267
+ fetchFn: this._fetchWithInit
268
+ });
269
+ } catch (error) {
270
+ this.onerror?.(error);
271
+ throw error;
272
+ }
273
+ if (result !== "AUTHORIZED") throw new UnauthorizedError();
274
+ return await this._startOrAuth();
275
+ }
276
+ async _commonHeaders() {
277
+ const headers = {};
278
+ if (this._authProvider) {
279
+ const tokens = await this._authProvider.tokens();
280
+ if (tokens) headers["Authorization"] = `Bearer ${tokens.access_token}`;
281
+ }
282
+ if (this._protocolVersion) headers["mcp-protocol-version"] = this._protocolVersion;
283
+ const extraHeaders = normalizeHeaders(this._requestInit?.headers);
284
+ return new Headers({
285
+ ...headers,
286
+ ...extraHeaders
287
+ });
288
+ }
289
+ _startOrAuth() {
290
+ const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
291
+ return new Promise((resolve, reject) => {
292
+ this._eventSource = new EventSource(this._url.href, {
293
+ ...this._eventSourceInit,
294
+ fetch: async (url, init) => {
295
+ const headers = await this._commonHeaders();
296
+ headers.set("Accept", "text/event-stream");
297
+ const response = await fetchImpl(url, {
298
+ ...init,
299
+ headers
300
+ });
301
+ if (response.status === 401 && response.headers.has("www-authenticate")) {
302
+ const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
303
+ this._resourceMetadataUrl = resourceMetadataUrl;
304
+ this._scope = scope;
305
+ }
306
+ return response;
307
+ }
308
+ });
309
+ this._abortController = new AbortController();
310
+ this._eventSource.onerror = (event) => {
311
+ if (event.code === 401 && this._authProvider) {
312
+ this._authThenStart().then(resolve, reject);
313
+ return;
314
+ }
315
+ const error = new SseError(event.code, event.message, event);
316
+ reject(error);
317
+ this.onerror?.(error);
318
+ };
319
+ this._eventSource.onopen = () => {};
320
+ this._eventSource.addEventListener("endpoint", (event) => {
321
+ const messageEvent = event;
322
+ try {
323
+ this._endpoint = new URL(messageEvent.data, this._url);
324
+ if (this._endpoint.origin !== this._url.origin) throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`);
325
+ } catch (error) {
326
+ reject(error);
327
+ this.onerror?.(error);
328
+ this.close();
329
+ return;
330
+ }
331
+ resolve();
332
+ });
333
+ this._eventSource.onmessage = (event) => {
334
+ const messageEvent = event;
335
+ let message;
336
+ try {
337
+ message = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
338
+ } catch (error) {
339
+ this.onerror?.(error);
340
+ return;
341
+ }
342
+ this.onmessage?.(message);
343
+ };
344
+ });
345
+ }
346
+ async start() {
347
+ if (this._eventSource) throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");
348
+ return await this._startOrAuth();
349
+ }
350
+ /**
351
+ * 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.
352
+ */
353
+ async finishAuth(authorizationCode) {
354
+ if (!this._authProvider) throw new UnauthorizedError("No auth provider");
355
+ if (await auth(this._authProvider, {
356
+ serverUrl: this._url,
357
+ authorizationCode,
358
+ resourceMetadataUrl: this._resourceMetadataUrl,
359
+ scope: this._scope,
360
+ fetchFn: this._fetchWithInit
361
+ }) !== "AUTHORIZED") throw new UnauthorizedError("Failed to authorize");
362
+ }
363
+ async close() {
364
+ this._abortController?.abort();
365
+ this._eventSource?.close();
366
+ this.onclose?.();
367
+ }
368
+ async send(message) {
369
+ if (!this._endpoint) throw new Error("Not connected");
370
+ try {
371
+ const headers = await this._commonHeaders();
372
+ headers.set("content-type", "application/json");
373
+ const init = {
374
+ ...this._requestInit,
375
+ method: "POST",
376
+ headers,
377
+ body: JSON.stringify(message),
378
+ signal: this._abortController?.signal
379
+ };
380
+ const response = await (this._fetch ?? fetch)(this._endpoint, init);
381
+ if (!response.ok) {
382
+ const text = await response.text().catch(() => null);
383
+ if (response.status === 401 && this._authProvider) {
384
+ const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
385
+ this._resourceMetadataUrl = resourceMetadataUrl;
386
+ this._scope = scope;
387
+ if (await auth(this._authProvider, {
388
+ serverUrl: this._url,
389
+ resourceMetadataUrl: this._resourceMetadataUrl,
390
+ scope: this._scope,
391
+ fetchFn: this._fetchWithInit
392
+ }) !== "AUTHORIZED") throw new UnauthorizedError();
393
+ return this.send(message);
394
+ }
395
+ throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
396
+ }
397
+ await response.body?.cancel();
398
+ } catch (error) {
399
+ this.onerror?.(error);
400
+ throw error;
401
+ }
402
+ }
403
+ setProtocolVersion(version) {
404
+ this._protocolVersion = version;
405
+ }
406
+ };
407
+ //#endregion
408
+ export { SSEClientTransport };
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { t as displayStatus } from "./status-X21VnGUO.js";
3
+ export { displayStatus };
@@ -1,34 +1,35 @@
1
1
  #!/usr/bin/env node
2
- import { c as resolveWallet, f as formatAmount, g as dim, h as readHistory, m as formatUsdcValue, n as fetchAllBalances, p as formatTxLine, t as balanceLine, u as calcSpend } from "./wallet-B0S-rma9.js";
3
- import { a as getHistoryPath, i as getConfigDirShort, l as loadConfig } from "./config-D9wIR3xc.js";
4
- import { buildCommand } from "@stricli/core";
5
- import pc from "picocolors";
6
- //#region src/commands/status.ts
2
+ import { i as __toESM } from "./chunk-DjEMn6fM.js";
3
+ import { c as buildCommand, o as require_picocolors } from "./derive-DNUl8LU9.js";
4
+ import { c as resolveWallet, f as formatAmount, h as readHistory, m as formatUsdcValue, n as fetchAllBalances, p as formatTxLine, t as balanceLine, u as calcSpend, v as dim } from "./wallet-DSyht15_.js";
5
+ import { i as getConfigDirShort, o as getHistoryPath, u as loadConfig } from "./config-rvKA3SYT.js";
6
+ //#region packages/x402-proxy/src/commands/status.ts
7
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
7
8
  async function displayStatus() {
8
9
  const wallet = resolveWallet();
9
10
  const config = loadConfig();
10
11
  const records = readHistory(getHistoryPath());
11
12
  const spend = calcSpend(records);
12
13
  console.log();
13
- console.log(pc.cyan(pc.bold("x402-proxy")));
14
- console.log(pc.dim("curl for x402 paid APIs"));
14
+ console.log(import_picocolors.default.cyan(import_picocolors.default.bold("x402-proxy")));
15
+ console.log(import_picocolors.default.dim("curl for x402 paid APIs"));
15
16
  console.log();
16
17
  if (wallet.source === "none") {
17
- console.log(pc.yellow(" No wallet configured."));
18
- console.log(pc.dim(` Run ${pc.cyan("$ npx x402-proxy setup")} to create one.`));
18
+ console.log(import_picocolors.default.yellow(" No wallet configured."));
19
+ console.log(import_picocolors.default.dim(` Run ${import_picocolors.default.cyan("$ npx x402-proxy setup")} to create one.`));
19
20
  } else {
20
21
  const { evm, sol, tempo } = await fetchAllBalances(wallet.evmAddress, wallet.solanaAddress);
21
22
  if (wallet.evmAddress) {
22
- const bal = evm ? balanceLine(evm.usdc, evm.eth, "ETH") : pc.dim(" (network error)");
23
- console.log(` Base: ${pc.green(wallet.evmAddress)}${bal}`);
23
+ const bal = evm ? balanceLine(evm.usdc, evm.eth, "ETH") : import_picocolors.default.dim(" (network error)");
24
+ console.log(` Base: ${import_picocolors.default.green(wallet.evmAddress)}${bal}`);
24
25
  }
25
26
  if (wallet.evmAddress) {
26
- const bal = tempo ? pc.dim(` (${tempo.usdc} USDC)`) : pc.dim(" (network error)");
27
- console.log(` Tempo: ${pc.green(wallet.evmAddress)}${bal}`);
27
+ const bal = tempo ? import_picocolors.default.dim(` (${tempo.usdc} USDC)`) : import_picocolors.default.dim(" (network error)");
28
+ console.log(` Tempo: ${import_picocolors.default.green(wallet.evmAddress)}${bal}`);
28
29
  }
29
30
  if (wallet.solanaAddress) {
30
- const bal = sol ? balanceLine(sol.usdc, sol.sol, "SOL") : pc.dim(" (network error)");
31
- console.log(` Solana: ${pc.green(wallet.solanaAddress)}${bal}`);
31
+ const bal = sol ? balanceLine(sol.usdc, sol.sol, "SOL") : import_picocolors.default.dim(" (network error)");
32
+ console.log(` Solana: ${import_picocolors.default.green(wallet.solanaAddress)}${bal}`);
32
33
  }
33
34
  if (config?.spendLimitDaily || config?.spendLimitPerTx) {
34
35
  console.log();
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ import { Z as JSONRPCMessageSchema } from "./types-BEKUz-Mf.js";
3
+ import N from "node:process";
4
+ //#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.28.0_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
5
+ /**
6
+ * Buffers a continuous stdio stream into discrete JSON-RPC messages.
7
+ */
8
+ var ReadBuffer = class {
9
+ append(chunk) {
10
+ this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
11
+ }
12
+ readMessage() {
13
+ if (!this._buffer) return null;
14
+ const index = this._buffer.indexOf("\n");
15
+ if (index === -1) return null;
16
+ const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
17
+ this._buffer = this._buffer.subarray(index + 1);
18
+ return deserializeMessage(line);
19
+ }
20
+ clear() {
21
+ this._buffer = void 0;
22
+ }
23
+ };
24
+ function deserializeMessage(line) {
25
+ return JSONRPCMessageSchema.parse(JSON.parse(line));
26
+ }
27
+ function serializeMessage(message) {
28
+ return JSON.stringify(message) + "\n";
29
+ }
30
+ //#endregion
31
+ //#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.28.0_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
32
+ /**
33
+ * Server transport for stdio: this communicates with an MCP client by reading from the current process' stdin and writing to stdout.
34
+ *
35
+ * This transport is only available in Node.js environments.
36
+ */
37
+ var StdioServerTransport = class {
38
+ constructor(_stdin = N.stdin, _stdout = N.stdout) {
39
+ this._stdin = _stdin;
40
+ this._stdout = _stdout;
41
+ this._readBuffer = new ReadBuffer();
42
+ this._started = false;
43
+ this._ondata = (chunk) => {
44
+ this._readBuffer.append(chunk);
45
+ this.processReadBuffer();
46
+ };
47
+ this._onerror = (error) => {
48
+ this.onerror?.(error);
49
+ };
50
+ }
51
+ /**
52
+ * Starts listening for messages on stdin.
53
+ */
54
+ async start() {
55
+ if (this._started) throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
56
+ this._started = true;
57
+ this._stdin.on("data", this._ondata);
58
+ this._stdin.on("error", this._onerror);
59
+ }
60
+ processReadBuffer() {
61
+ while (true) try {
62
+ const message = this._readBuffer.readMessage();
63
+ if (message === null) break;
64
+ this.onmessage?.(message);
65
+ } catch (error) {
66
+ this.onerror?.(error);
67
+ }
68
+ }
69
+ async close() {
70
+ this._stdin.off("data", this._ondata);
71
+ this._stdin.off("error", this._onerror);
72
+ if (this._stdin.listenerCount("data") === 0) this._stdin.pause();
73
+ this._readBuffer.clear();
74
+ this.onclose?.();
75
+ }
76
+ send(message) {
77
+ return new Promise((resolve) => {
78
+ const json = serializeMessage(message);
79
+ if (this._stdout.write(json)) resolve();
80
+ else this._stdout.once("drain", resolve);
81
+ });
82
+ }
83
+ };
84
+ //#endregion
85
+ export { StdioServerTransport };