Initial commit: Complete Hive distributed AI orchestration platform
This comprehensive implementation includes: - FastAPI backend with MCP server integration - React/TypeScript frontend with Vite - PostgreSQL database with Redis caching - Grafana/Prometheus monitoring stack - Docker Compose orchestration - Full MCP protocol support for Claude Code integration Features: - Agent discovery and management across network - Visual workflow editor and execution engine - Real-time task coordination and monitoring - Multi-model support with specialized agents - Distributed development task allocation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
22
mcp-server/node_modules/eventsource/LICENSE
generated
vendored
Normal file
22
mcp-server/node_modules/eventsource/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) EventSource GitHub organisation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
167
mcp-server/node_modules/eventsource/README.md
generated
vendored
Normal file
167
mcp-server/node_modules/eventsource/README.md
generated
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
# eventsource
|
||||
|
||||
[](https://www.npmjs.com/package/eventsource)[](https://bundlephobia.com/result?p=eventsource)[](https://www.npmjs.com/package/eventsource)
|
||||
|
||||
WhatWG/W3C-compatible [server-sent events/eventsource](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) client. The module attempts to implement an absolute minimal amount of features/changes beyond the specification.
|
||||
|
||||
If you're looking for a modern alternative with a less constrained API, check out the [`eventsource-client` package](https://www.npmjs.com/package/eventsource-client).
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install --save eventsource
|
||||
```
|
||||
|
||||
## Supported engines
|
||||
|
||||
- Node.js >= 18
|
||||
- Chrome >= 63
|
||||
- Safari >= 11.3
|
||||
- Firefox >= 65
|
||||
- Edge >= 79
|
||||
- Deno >= 1.30
|
||||
- Bun >= 1.1.23
|
||||
|
||||
Basically, any environment that supports:
|
||||
|
||||
- [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch)
|
||||
- [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
|
||||
- [TextDecoderStream](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoderStream)
|
||||
- [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL)
|
||||
- [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event), [MessageEvent](https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent), [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)
|
||||
|
||||
If you need to support older runtimes, try the `2.x` branch/version range (note: 2.x branch is primarily targetted at Node.js, not browsers).
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import {EventSource} from 'eventsource'
|
||||
|
||||
const es = new EventSource('https://my-server.com/sse')
|
||||
|
||||
/*
|
||||
* This will listen for events with the field `event: notice`.
|
||||
*/
|
||||
es.addEventListener('notice', (event) => {
|
||||
console.log(event.data)
|
||||
})
|
||||
|
||||
/*
|
||||
* This will listen for events with the field `event: update`.
|
||||
*/
|
||||
es.addEventListener('update', (event) => {
|
||||
console.log(event.data)
|
||||
})
|
||||
|
||||
/*
|
||||
* The event "message" is a special case, as it will capture events _without_ an
|
||||
* event field, as well as events that have the specific type `event: message`.
|
||||
* It will not trigger on any other event type.
|
||||
*/
|
||||
es.addEventListener('message', (event) => {
|
||||
console.log(event.data)
|
||||
})
|
||||
|
||||
/**
|
||||
* To explicitly close the connection, call the `close` method.
|
||||
* This will prevent any reconnection from happening.
|
||||
*/
|
||||
setTimeout(() => {
|
||||
es.close()
|
||||
}, 10_000)
|
||||
```
|
||||
|
||||
### TypeScript
|
||||
|
||||
Make sure you have configured your TSConfig so it matches the environment you are targetting. If you are targetting browsers, this would be `dom`:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["dom"],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
If you're using Node.js, ensure you have `@types/node` installed (and it is version 18 or higher). Cloudflare workers have `@cloudflare/workers-types` etc.
|
||||
|
||||
The following errors are caused by targetting an environment that does not have the necessary types available:
|
||||
|
||||
```
|
||||
error TS2304: Cannot find name 'Event'.
|
||||
error TS2304: Cannot find name 'EventTarget'.
|
||||
error TS2304: Cannot find name 'MessageEvent'.
|
||||
```
|
||||
|
||||
## Migrating from v1 / v2
|
||||
|
||||
See [MIGRATION.md](MIGRATION.md#v2-to-v3) for a detailed migration guide.
|
||||
|
||||
## Extensions to the WhatWG/W3C API
|
||||
|
||||
### Message and code properties on errors
|
||||
|
||||
The `error` event has a `message` and `code` property that can be used to get more information about the error. In the specification, the Event
|
||||
|
||||
```ts
|
||||
es.addEventListener('error', (err) => {
|
||||
if (err.code === 401 || err.code === 403) {
|
||||
console.log('not authorized')
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Specify `fetch` implementation
|
||||
|
||||
The `EventSource` constructor accepts an optional `fetch` property in the second argument that can be used to specify the `fetch` implementation to use.
|
||||
|
||||
This can be useful in environments where the global `fetch` function is not available - but it can also be used to alter the request/response behaviour.
|
||||
|
||||
#### Setting HTTP request headers
|
||||
|
||||
```ts
|
||||
const es = new EventSource('https://my-server.com/sse', {
|
||||
fetch: (input, init) =>
|
||||
fetch(input, {
|
||||
...init,
|
||||
headers: {
|
||||
...init.headers,
|
||||
Authorization: 'Bearer myToken',
|
||||
},
|
||||
}),
|
||||
})
|
||||
```
|
||||
|
||||
#### HTTP/HTTPS proxy
|
||||
|
||||
Use a package like [`node-fetch-native`](https://github.com/unjs/node-fetch-native) to add proxy support, either through environment variables or explicit configuration.
|
||||
|
||||
```ts
|
||||
// npm install node-fetch-native --save
|
||||
import {fetch} from 'node-fetch-native/proxy'
|
||||
|
||||
const es = new EventSource('https://my-server.com/sse', {
|
||||
fetch: (input, init) => fetch(input, init),
|
||||
})
|
||||
```
|
||||
|
||||
#### Allow unauthorized HTTPS requests
|
||||
|
||||
Use a package like [`undici`](https://github.com/nodejs/undici) for more control of fetch options through the use of an [`Agent`](https://undici.nodejs.org/#/docs/api/Agent.md).
|
||||
|
||||
```ts
|
||||
// npm install undici --save
|
||||
import {fetch, Agent} from 'undici'
|
||||
|
||||
await fetch('https://my-server.com/sse', {
|
||||
dispatcher: new Agent({
|
||||
connect: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
}),
|
||||
})
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT-licensed. See [LICENSE](LICENSE).
|
||||
273
mcp-server/node_modules/eventsource/dist/index.cjs
generated
vendored
Normal file
273
mcp-server/node_modules/eventsource/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: !0 });
|
||||
var eventsourceParser = require("eventsource-parser");
|
||||
class ErrorEvent extends Event {
|
||||
/**
|
||||
* Constructs a new `ErrorEvent` instance. This is typically not called directly,
|
||||
* but rather emitted by the `EventSource` object when an error occurs.
|
||||
*
|
||||
* @param type - The type of the event (should be "error")
|
||||
* @param errorEventInitDict - Optional properties to include in the error event
|
||||
*/
|
||||
constructor(type, errorEventInitDict) {
|
||||
var _a, _b;
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
||||
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
||||
* we explicitly include the properties in the `inspect` method.
|
||||
*
|
||||
* This is automatically called by Node.js when you `console.log` an instance of this class.
|
||||
*
|
||||
* @param _depth - The current depth
|
||||
* @param options - The options passed to `util.inspect`
|
||||
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
||||
* @returns A string representation of the error
|
||||
*/
|
||||
[Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
|
||||
return inspect(inspectableError(this), options);
|
||||
}
|
||||
/**
|
||||
* Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
||||
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
||||
* we explicitly include the properties in the `inspect` method.
|
||||
*
|
||||
* This is automatically called by Deno when you `console.log` an instance of this class.
|
||||
*
|
||||
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
||||
* @param options - The options passed to `Deno.inspect`
|
||||
* @returns A string representation of the error
|
||||
*/
|
||||
[Symbol.for("Deno.customInspect")](inspect, options) {
|
||||
return inspect(inspectableError(this), options);
|
||||
}
|
||||
}
|
||||
function syntaxError(message) {
|
||||
const DomException = globalThis.DOMException;
|
||||
return typeof DomException == "function" ? new DomException(message, "SyntaxError") : new SyntaxError(message);
|
||||
}
|
||||
function flattenError(err) {
|
||||
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}`;
|
||||
}
|
||||
function inspectableError(err) {
|
||||
return {
|
||||
type: err.type,
|
||||
message: err.message,
|
||||
code: err.code,
|
||||
defaultPrevented: err.defaultPrevented,
|
||||
cancelable: err.cancelable,
|
||||
timeStamp: err.timeStamp
|
||||
};
|
||||
}
|
||||
var __typeError = (msg) => {
|
||||
throw TypeError(msg);
|
||||
}, __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;
|
||||
class EventSource extends EventTarget {
|
||||
constructor(url, eventSourceInitDict) {
|
||||
var _a, _b;
|
||||
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) => {
|
||||
var _a2;
|
||||
__privateGet(this, _parser).reset();
|
||||
const { body, redirected, status, headers } = response;
|
||||
if (status === 204) {
|
||||
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
||||
return;
|
||||
}
|
||||
if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {
|
||||
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);
|
||||
return;
|
||||
}
|
||||
if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {
|
||||
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, 'Invalid content type, expected "text/event-stream"', status);
|
||||
return;
|
||||
}
|
||||
if (__privateGet(this, _readyState) === this.CLOSED)
|
||||
return;
|
||||
__privateSet(this, _readyState, this.OPEN);
|
||||
const openEvent = new Event("open");
|
||||
if ((_a2 = __privateGet(this, _onOpen)) == null || _a2.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {
|
||||
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
|
||||
return;
|
||||
}
|
||||
const decoder = new TextDecoder(), reader = body.getReader();
|
||||
let open = !0;
|
||||
do {
|
||||
const { done, value } = await reader.read();
|
||||
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));
|
||||
} while (open);
|
||||
}), __privateAdd(this, _onFetchError, (err) => {
|
||||
__privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError(err));
|
||||
}), __privateAdd(this, _onEvent, (event) => {
|
||||
typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);
|
||||
const messageEvent = new MessageEvent(event.event || "message", {
|
||||
data: event.data,
|
||||
origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url).origin,
|
||||
lastEventId: event.id || ""
|
||||
});
|
||||
__privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);
|
||||
}), __privateAdd(this, _onRetryChange, (value) => {
|
||||
__privateSet(this, _reconnectInterval, value);
|
||||
}), __privateAdd(this, _reconnect, () => {
|
||||
__privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
||||
});
|
||||
try {
|
||||
if (url instanceof URL)
|
||||
__privateSet(this, _url, url);
|
||||
else if (typeof url == "string")
|
||||
__privateSet(this, _url, new URL(url, getBaseURL()));
|
||||
else
|
||||
throw new Error("Invalid URL");
|
||||
} catch {
|
||||
throw syntaxError("An invalid or illegal string was specified");
|
||||
}
|
||||
__privateSet(this, _parser, eventsourceParser.createParser({
|
||||
onEvent: __privateGet(this, _onEvent),
|
||||
onRetry: __privateGet(this, _onRetryChange)
|
||||
})), __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);
|
||||
}
|
||||
/**
|
||||
* Returns the state of this EventSource object's connection. It can have the values described below.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
||||
*
|
||||
* Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
|
||||
* defined in the TypeScript `dom` library.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
get readyState() {
|
||||
return __privateGet(this, _readyState);
|
||||
}
|
||||
/**
|
||||
* Returns the URL providing the event stream.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
get url() {
|
||||
return __privateGet(this, _url).href;
|
||||
}
|
||||
/**
|
||||
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
||||
*/
|
||||
get withCredentials() {
|
||||
return __privateGet(this, _withCredentials);
|
||||
}
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
||||
get onerror() {
|
||||
return __privateGet(this, _onError);
|
||||
}
|
||||
set onerror(value) {
|
||||
__privateSet(this, _onError, value);
|
||||
}
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
||||
get onmessage() {
|
||||
return __privateGet(this, _onMessage);
|
||||
}
|
||||
set onmessage(value) {
|
||||
__privateSet(this, _onMessage, value);
|
||||
}
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
||||
get onopen() {
|
||||
return __privateGet(this, _onOpen);
|
||||
}
|
||||
set onopen(value) {
|
||||
__privateSet(this, _onOpen, value);
|
||||
}
|
||||
addEventListener(type, listener, options) {
|
||||
const listen = listener;
|
||||
super.addEventListener(type, listen, options);
|
||||
}
|
||||
removeEventListener(type, listener, options) {
|
||||
const listen = listener;
|
||||
super.removeEventListener(type, listen, options);
|
||||
}
|
||||
/**
|
||||
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
close() {
|
||||
__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));
|
||||
}
|
||||
}
|
||||
_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 to the given URL and start receiving events
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
connect_fn = function() {
|
||||
__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));
|
||||
}, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), /**
|
||||
* Get request options for the `fetch()` request
|
||||
*
|
||||
* @returns The request options
|
||||
* @internal
|
||||
*/
|
||||
getRequestOptions_fn = function() {
|
||||
var _a;
|
||||
const init = {
|
||||
// [spec] Let `corsAttributeState` be `Anonymous`…
|
||||
// [spec] …will have their mode set to "cors"…
|
||||
mode: "cors",
|
||||
redirect: "follow",
|
||||
headers: { Accept: "text/event-stream", ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0 },
|
||||
cache: "no-store",
|
||||
signal: (_a = __privateGet(this, _controller)) == null ? void 0 : _a.signal
|
||||
};
|
||||
return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;
|
||||
}, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), /**
|
||||
* Handles the process referred to in the EventSource specification as "failing a connection".
|
||||
*
|
||||
* @param error - The error causing the connection to fail
|
||||
* @param code - The HTTP status code, if available
|
||||
* @internal
|
||||
*/
|
||||
failConnection_fn = function(message, code) {
|
||||
var _a;
|
||||
__privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
|
||||
const errorEvent = new ErrorEvent("error", { code, message });
|
||||
(_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent);
|
||||
}, /**
|
||||
* Schedules a reconnection attempt against the EventSource endpoint.
|
||||
*
|
||||
* @param message - The error causing the connection to fail
|
||||
* @param code - The HTTP status code, if available
|
||||
* @internal
|
||||
*/
|
||||
scheduleReconnect_fn = function(message, code) {
|
||||
var _a;
|
||||
if (__privateGet(this, _readyState) === this.CLOSED)
|
||||
return;
|
||||
__privateSet(this, _readyState, this.CONNECTING);
|
||||
const errorEvent = new ErrorEvent("error", { code, message });
|
||||
(_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
|
||||
}, _reconnect = /* @__PURE__ */ new WeakMap(), /**
|
||||
* ReadyState representing an EventSource currently trying to connect
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
EventSource.CONNECTING = 0, /**
|
||||
* ReadyState representing an EventSource connection that is open (eg connected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
EventSource.OPEN = 1, /**
|
||||
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
EventSource.CLOSED = 2;
|
||||
function getBaseURL() {
|
||||
const doc = "document" in globalThis ? globalThis.document : void 0;
|
||||
return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
|
||||
}
|
||||
exports.ErrorEvent = ErrorEvent;
|
||||
exports.EventSource = EventSource;
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
1
mcp-server/node_modules/eventsource/dist/index.cjs.map
generated
vendored
Normal file
1
mcp-server/node_modules/eventsource/dist/index.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
332
mcp-server/node_modules/eventsource/dist/index.d.cts
generated
vendored
Normal file
332
mcp-server/node_modules/eventsource/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,332 @@
|
||||
/**
|
||||
* Mirrors the official DOM typings (sorta).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface AddEventListenerOptions extends EventListenerOptions {
|
||||
/** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
|
||||
once?: boolean
|
||||
/** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
|
||||
passive?: boolean
|
||||
/** The listener will be removed when the given AbortSignal object's `abort()` method is called. */
|
||||
signal?: AbortSignal
|
||||
}
|
||||
|
||||
/**
|
||||
* An extended version of the `Event` emitted by the `EventSource` object when an error occurs.
|
||||
* While the spec does not include any additional properties, we intentionally go beyond the spec
|
||||
* and provide some (minimal) additional information to aid in debugging.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare class ErrorEvent extends Event {
|
||||
/**
|
||||
* HTTP status code, if this was triggered by an HTTP error
|
||||
* Note: this is not part of the spec, but is included for better error handling.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
code?: number | undefined
|
||||
/**
|
||||
* Optional message attached to the error.
|
||||
* Note: this is not part of the spec, but is included for better error handling.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
message?: string | undefined
|
||||
/**
|
||||
* Constructs a new `ErrorEvent` instance. This is typically not called directly,
|
||||
* but rather emitted by the `EventSource` object when an error occurs.
|
||||
*
|
||||
* @param type - The type of the event (should be "error")
|
||||
* @param errorEventInitDict - Optional properties to include in the error event
|
||||
*/
|
||||
constructor(
|
||||
type: string,
|
||||
errorEventInitDict?: {
|
||||
message?: string | undefined
|
||||
code?: number | undefined
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventListener {
|
||||
(evt: Event | MessageEvent): void
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventListenerObject {
|
||||
handleEvent(object: Event): void
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings (sorta).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventListenerOptions {
|
||||
/** Not directly used by Node.js. Added for API completeness. Default: `false`. */
|
||||
capture?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject
|
||||
|
||||
/**
|
||||
* An `EventSource` instance opens a persistent connection to an HTTP server, which sends events
|
||||
* in `text/event-stream` format. The connection remains open until closed by calling `.close()`.
|
||||
*
|
||||
* @public
|
||||
* @example
|
||||
* ```js
|
||||
* const eventSource = new EventSource('https://example.com/stream')
|
||||
* eventSource.addEventListener('error', (error) => {
|
||||
* console.error(error)
|
||||
* })
|
||||
* eventSource.addEventListener('message', (event) => {
|
||||
* console.log('Received message:', event.data)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
declare class EventSource_2 extends EventTarget {
|
||||
#private
|
||||
/**
|
||||
* ReadyState representing an EventSource currently trying to connect
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static CONNECTING: 0
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is open (eg connected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static OPEN: 1
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static CLOSED: 2
|
||||
/**
|
||||
* ReadyState representing an EventSource currently trying to connect
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
readonly CONNECTING: 0
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is open (eg connected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
readonly OPEN: 1
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
readonly CLOSED: 2
|
||||
/**
|
||||
* Returns the state of this EventSource object's connection. It can have the values described below.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
||||
*
|
||||
* Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
|
||||
* defined in the TypeScript `dom` library.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
get readyState(): number
|
||||
/**
|
||||
* Returns the URL providing the event stream.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
get url(): string
|
||||
/**
|
||||
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
||||
*/
|
||||
get withCredentials(): boolean
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
||||
get onerror(): ((ev: ErrorEvent) => unknown) | null
|
||||
set onerror(value: ((ev: ErrorEvent) => unknown) | null)
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
||||
get onmessage(): ((ev: MessageEvent) => unknown) | null
|
||||
set onmessage(value: ((ev: MessageEvent) => unknown) | null)
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
||||
get onopen(): ((ev: Event) => unknown) | null
|
||||
set onopen(value: ((ev: Event) => unknown) | null)
|
||||
addEventListener<K extends keyof EventSourceEventMap>(
|
||||
type: K,
|
||||
listener: (this: EventSource_2, ev: EventSourceEventMap[K]) => unknown,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: (this: EventSource_2, event: MessageEvent) => unknown,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void
|
||||
removeEventListener<K extends keyof EventSourceEventMap>(
|
||||
type: K,
|
||||
listener: (this: EventSource_2, ev: EventSourceEventMap[K]) => unknown,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: (this: EventSource_2, event: MessageEvent) => unknown,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void
|
||||
constructor(url: string | URL, eventSourceInitDict?: EventSourceInit)
|
||||
/**
|
||||
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
close(): void
|
||||
}
|
||||
export {EventSource_2 as EventSource}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings, with the exception of the extended ErrorEvent.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventSourceEventMap {
|
||||
error: ErrorEvent
|
||||
message: MessageEvent
|
||||
open: Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Subset of `RequestInit` used for `fetch()` calls made by the `EventSource` class.
|
||||
* As we know that we will be passing certain values, we can be more specific and have
|
||||
* users not have to do optional chaining and similar for things that will always be there.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventSourceFetchInit {
|
||||
/** An AbortSignal to set request's signal. Typed as `any` because of polyfill inconsistencies. */
|
||||
signal:
|
||||
| {
|
||||
aborted: boolean
|
||||
}
|
||||
| any
|
||||
/** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
|
||||
headers: {
|
||||
[key: string]: string
|
||||
Accept: 'text/event-stream'
|
||||
}
|
||||
/** A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. */
|
||||
mode: 'cors' | 'no-cors' | 'same-origin'
|
||||
/** A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. */
|
||||
credentials?: 'include' | 'omit' | 'same-origin'
|
||||
/** Controls how the request is cached. */
|
||||
cache: 'no-store'
|
||||
/** A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
|
||||
redirect: 'error' | 'follow' | 'manual'
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings (for the most part)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventSourceInit {
|
||||
/**
|
||||
* A boolean value, defaulting to `false`, indicating if CORS should be set to `include` credentials.
|
||||
*/
|
||||
withCredentials?: boolean
|
||||
/**
|
||||
* Optional fetch implementation to use. Defaults to `globalThis.fetch`.
|
||||
* Can also be used for advanced use cases like mocking, proxying, custom certs etc.
|
||||
*/
|
||||
fetch?: FetchLike
|
||||
}
|
||||
|
||||
/**
|
||||
* Stripped down version of `fetch()`, only defining the parts we care about.
|
||||
* This ensures it should work with "most" fetch implementations.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare type FetchLike = (
|
||||
url: string | URL,
|
||||
init: EventSourceFetchInit,
|
||||
) => Promise<FetchLikeResponse>
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @deprecated Use `EventSourceFetchInit` instead.
|
||||
* This type is only here for backwards compatibility and will be removed in a future version.
|
||||
*/
|
||||
export declare type FetchLikeInit = EventSourceFetchInit
|
||||
|
||||
/**
|
||||
* Minimal version of the `Response` type returned by `fetch()`.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface FetchLikeResponse {
|
||||
readonly body:
|
||||
| {
|
||||
getReader(): ReaderLike
|
||||
}
|
||||
| Response['body']
|
||||
| null
|
||||
readonly url: string
|
||||
readonly status: number
|
||||
readonly redirected: boolean
|
||||
readonly headers: {
|
||||
get(name: string): string | null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stripped down version of `ReadableStreamDefaultReader`, only defining the parts we care about.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface ReaderLike {
|
||||
read(): Promise<
|
||||
| {
|
||||
done: false
|
||||
value: unknown
|
||||
}
|
||||
| {
|
||||
done: true
|
||||
value?: undefined
|
||||
}
|
||||
>
|
||||
cancel(): Promise<void>
|
||||
}
|
||||
|
||||
export {}
|
||||
332
mcp-server/node_modules/eventsource/dist/index.d.ts
generated
vendored
Normal file
332
mcp-server/node_modules/eventsource/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,332 @@
|
||||
/**
|
||||
* Mirrors the official DOM typings (sorta).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface AddEventListenerOptions extends EventListenerOptions {
|
||||
/** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
|
||||
once?: boolean
|
||||
/** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
|
||||
passive?: boolean
|
||||
/** The listener will be removed when the given AbortSignal object's `abort()` method is called. */
|
||||
signal?: AbortSignal
|
||||
}
|
||||
|
||||
/**
|
||||
* An extended version of the `Event` emitted by the `EventSource` object when an error occurs.
|
||||
* While the spec does not include any additional properties, we intentionally go beyond the spec
|
||||
* and provide some (minimal) additional information to aid in debugging.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare class ErrorEvent extends Event {
|
||||
/**
|
||||
* HTTP status code, if this was triggered by an HTTP error
|
||||
* Note: this is not part of the spec, but is included for better error handling.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
code?: number | undefined
|
||||
/**
|
||||
* Optional message attached to the error.
|
||||
* Note: this is not part of the spec, but is included for better error handling.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
message?: string | undefined
|
||||
/**
|
||||
* Constructs a new `ErrorEvent` instance. This is typically not called directly,
|
||||
* but rather emitted by the `EventSource` object when an error occurs.
|
||||
*
|
||||
* @param type - The type of the event (should be "error")
|
||||
* @param errorEventInitDict - Optional properties to include in the error event
|
||||
*/
|
||||
constructor(
|
||||
type: string,
|
||||
errorEventInitDict?: {
|
||||
message?: string | undefined
|
||||
code?: number | undefined
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventListener {
|
||||
(evt: Event | MessageEvent): void
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventListenerObject {
|
||||
handleEvent(object: Event): void
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings (sorta).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventListenerOptions {
|
||||
/** Not directly used by Node.js. Added for API completeness. Default: `false`. */
|
||||
capture?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject
|
||||
|
||||
/**
|
||||
* An `EventSource` instance opens a persistent connection to an HTTP server, which sends events
|
||||
* in `text/event-stream` format. The connection remains open until closed by calling `.close()`.
|
||||
*
|
||||
* @public
|
||||
* @example
|
||||
* ```js
|
||||
* const eventSource = new EventSource('https://example.com/stream')
|
||||
* eventSource.addEventListener('error', (error) => {
|
||||
* console.error(error)
|
||||
* })
|
||||
* eventSource.addEventListener('message', (event) => {
|
||||
* console.log('Received message:', event.data)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
declare class EventSource_2 extends EventTarget {
|
||||
#private
|
||||
/**
|
||||
* ReadyState representing an EventSource currently trying to connect
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static CONNECTING: 0
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is open (eg connected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static OPEN: 1
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static CLOSED: 2
|
||||
/**
|
||||
* ReadyState representing an EventSource currently trying to connect
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
readonly CONNECTING: 0
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is open (eg connected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
readonly OPEN: 1
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
readonly CLOSED: 2
|
||||
/**
|
||||
* Returns the state of this EventSource object's connection. It can have the values described below.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
||||
*
|
||||
* Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
|
||||
* defined in the TypeScript `dom` library.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
get readyState(): number
|
||||
/**
|
||||
* Returns the URL providing the event stream.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
get url(): string
|
||||
/**
|
||||
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
||||
*/
|
||||
get withCredentials(): boolean
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
||||
get onerror(): ((ev: ErrorEvent) => unknown) | null
|
||||
set onerror(value: ((ev: ErrorEvent) => unknown) | null)
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
||||
get onmessage(): ((ev: MessageEvent) => unknown) | null
|
||||
set onmessage(value: ((ev: MessageEvent) => unknown) | null)
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
||||
get onopen(): ((ev: Event) => unknown) | null
|
||||
set onopen(value: ((ev: Event) => unknown) | null)
|
||||
addEventListener<K extends keyof EventSourceEventMap>(
|
||||
type: K,
|
||||
listener: (this: EventSource_2, ev: EventSourceEventMap[K]) => unknown,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: (this: EventSource_2, event: MessageEvent) => unknown,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void
|
||||
removeEventListener<K extends keyof EventSourceEventMap>(
|
||||
type: K,
|
||||
listener: (this: EventSource_2, ev: EventSourceEventMap[K]) => unknown,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: (this: EventSource_2, event: MessageEvent) => unknown,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void
|
||||
constructor(url: string | URL, eventSourceInitDict?: EventSourceInit)
|
||||
/**
|
||||
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
close(): void
|
||||
}
|
||||
export {EventSource_2 as EventSource}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings, with the exception of the extended ErrorEvent.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventSourceEventMap {
|
||||
error: ErrorEvent
|
||||
message: MessageEvent
|
||||
open: Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Subset of `RequestInit` used for `fetch()` calls made by the `EventSource` class.
|
||||
* As we know that we will be passing certain values, we can be more specific and have
|
||||
* users not have to do optional chaining and similar for things that will always be there.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventSourceFetchInit {
|
||||
/** An AbortSignal to set request's signal. Typed as `any` because of polyfill inconsistencies. */
|
||||
signal:
|
||||
| {
|
||||
aborted: boolean
|
||||
}
|
||||
| any
|
||||
/** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
|
||||
headers: {
|
||||
[key: string]: string
|
||||
Accept: 'text/event-stream'
|
||||
}
|
||||
/** A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. */
|
||||
mode: 'cors' | 'no-cors' | 'same-origin'
|
||||
/** A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. */
|
||||
credentials?: 'include' | 'omit' | 'same-origin'
|
||||
/** Controls how the request is cached. */
|
||||
cache: 'no-store'
|
||||
/** A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
|
||||
redirect: 'error' | 'follow' | 'manual'
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings (for the most part)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface EventSourceInit {
|
||||
/**
|
||||
* A boolean value, defaulting to `false`, indicating if CORS should be set to `include` credentials.
|
||||
*/
|
||||
withCredentials?: boolean
|
||||
/**
|
||||
* Optional fetch implementation to use. Defaults to `globalThis.fetch`.
|
||||
* Can also be used for advanced use cases like mocking, proxying, custom certs etc.
|
||||
*/
|
||||
fetch?: FetchLike
|
||||
}
|
||||
|
||||
/**
|
||||
* Stripped down version of `fetch()`, only defining the parts we care about.
|
||||
* This ensures it should work with "most" fetch implementations.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare type FetchLike = (
|
||||
url: string | URL,
|
||||
init: EventSourceFetchInit,
|
||||
) => Promise<FetchLikeResponse>
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @deprecated Use `EventSourceFetchInit` instead.
|
||||
* This type is only here for backwards compatibility and will be removed in a future version.
|
||||
*/
|
||||
export declare type FetchLikeInit = EventSourceFetchInit
|
||||
|
||||
/**
|
||||
* Minimal version of the `Response` type returned by `fetch()`.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface FetchLikeResponse {
|
||||
readonly body:
|
||||
| {
|
||||
getReader(): ReaderLike
|
||||
}
|
||||
| Response['body']
|
||||
| null
|
||||
readonly url: string
|
||||
readonly status: number
|
||||
readonly redirected: boolean
|
||||
readonly headers: {
|
||||
get(name: string): string | null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stripped down version of `ReadableStreamDefaultReader`, only defining the parts we care about.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare interface ReaderLike {
|
||||
read(): Promise<
|
||||
| {
|
||||
done: false
|
||||
value: unknown
|
||||
}
|
||||
| {
|
||||
done: true
|
||||
value?: undefined
|
||||
}
|
||||
>
|
||||
cancel(): Promise<void>
|
||||
}
|
||||
|
||||
export {}
|
||||
273
mcp-server/node_modules/eventsource/dist/index.js
generated
vendored
Normal file
273
mcp-server/node_modules/eventsource/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
import { createParser } from "eventsource-parser";
|
||||
class ErrorEvent extends Event {
|
||||
/**
|
||||
* Constructs a new `ErrorEvent` instance. This is typically not called directly,
|
||||
* but rather emitted by the `EventSource` object when an error occurs.
|
||||
*
|
||||
* @param type - The type of the event (should be "error")
|
||||
* @param errorEventInitDict - Optional properties to include in the error event
|
||||
*/
|
||||
constructor(type, errorEventInitDict) {
|
||||
var _a, _b;
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
||||
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
||||
* we explicitly include the properties in the `inspect` method.
|
||||
*
|
||||
* This is automatically called by Node.js when you `console.log` an instance of this class.
|
||||
*
|
||||
* @param _depth - The current depth
|
||||
* @param options - The options passed to `util.inspect`
|
||||
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
||||
* @returns A string representation of the error
|
||||
*/
|
||||
[Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
|
||||
return inspect(inspectableError(this), options);
|
||||
}
|
||||
/**
|
||||
* Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
||||
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
||||
* we explicitly include the properties in the `inspect` method.
|
||||
*
|
||||
* This is automatically called by Deno when you `console.log` an instance of this class.
|
||||
*
|
||||
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
||||
* @param options - The options passed to `Deno.inspect`
|
||||
* @returns A string representation of the error
|
||||
*/
|
||||
[Symbol.for("Deno.customInspect")](inspect, options) {
|
||||
return inspect(inspectableError(this), options);
|
||||
}
|
||||
}
|
||||
function syntaxError(message) {
|
||||
const DomException = globalThis.DOMException;
|
||||
return typeof DomException == "function" ? new DomException(message, "SyntaxError") : new SyntaxError(message);
|
||||
}
|
||||
function flattenError(err) {
|
||||
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}`;
|
||||
}
|
||||
function inspectableError(err) {
|
||||
return {
|
||||
type: err.type,
|
||||
message: err.message,
|
||||
code: err.code,
|
||||
defaultPrevented: err.defaultPrevented,
|
||||
cancelable: err.cancelable,
|
||||
timeStamp: err.timeStamp
|
||||
};
|
||||
}
|
||||
var __typeError = (msg) => {
|
||||
throw TypeError(msg);
|
||||
}, __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;
|
||||
class EventSource extends EventTarget {
|
||||
constructor(url, eventSourceInitDict) {
|
||||
var _a, _b;
|
||||
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) => {
|
||||
var _a2;
|
||||
__privateGet(this, _parser).reset();
|
||||
const { body, redirected, status, headers } = response;
|
||||
if (status === 204) {
|
||||
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
||||
return;
|
||||
}
|
||||
if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {
|
||||
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);
|
||||
return;
|
||||
}
|
||||
if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {
|
||||
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, 'Invalid content type, expected "text/event-stream"', status);
|
||||
return;
|
||||
}
|
||||
if (__privateGet(this, _readyState) === this.CLOSED)
|
||||
return;
|
||||
__privateSet(this, _readyState, this.OPEN);
|
||||
const openEvent = new Event("open");
|
||||
if ((_a2 = __privateGet(this, _onOpen)) == null || _a2.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {
|
||||
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
|
||||
return;
|
||||
}
|
||||
const decoder = new TextDecoder(), reader = body.getReader();
|
||||
let open = !0;
|
||||
do {
|
||||
const { done, value } = await reader.read();
|
||||
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));
|
||||
} while (open);
|
||||
}), __privateAdd(this, _onFetchError, (err) => {
|
||||
__privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError(err));
|
||||
}), __privateAdd(this, _onEvent, (event) => {
|
||||
typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);
|
||||
const messageEvent = new MessageEvent(event.event || "message", {
|
||||
data: event.data,
|
||||
origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url).origin,
|
||||
lastEventId: event.id || ""
|
||||
});
|
||||
__privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);
|
||||
}), __privateAdd(this, _onRetryChange, (value) => {
|
||||
__privateSet(this, _reconnectInterval, value);
|
||||
}), __privateAdd(this, _reconnect, () => {
|
||||
__privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
||||
});
|
||||
try {
|
||||
if (url instanceof URL)
|
||||
__privateSet(this, _url, url);
|
||||
else if (typeof url == "string")
|
||||
__privateSet(this, _url, new URL(url, getBaseURL()));
|
||||
else
|
||||
throw new Error("Invalid URL");
|
||||
} catch {
|
||||
throw syntaxError("An invalid or illegal string was specified");
|
||||
}
|
||||
__privateSet(this, _parser, createParser({
|
||||
onEvent: __privateGet(this, _onEvent),
|
||||
onRetry: __privateGet(this, _onRetryChange)
|
||||
})), __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);
|
||||
}
|
||||
/**
|
||||
* Returns the state of this EventSource object's connection. It can have the values described below.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
||||
*
|
||||
* Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
|
||||
* defined in the TypeScript `dom` library.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
get readyState() {
|
||||
return __privateGet(this, _readyState);
|
||||
}
|
||||
/**
|
||||
* Returns the URL providing the event stream.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
get url() {
|
||||
return __privateGet(this, _url).href;
|
||||
}
|
||||
/**
|
||||
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
||||
*/
|
||||
get withCredentials() {
|
||||
return __privateGet(this, _withCredentials);
|
||||
}
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
||||
get onerror() {
|
||||
return __privateGet(this, _onError);
|
||||
}
|
||||
set onerror(value) {
|
||||
__privateSet(this, _onError, value);
|
||||
}
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
||||
get onmessage() {
|
||||
return __privateGet(this, _onMessage);
|
||||
}
|
||||
set onmessage(value) {
|
||||
__privateSet(this, _onMessage, value);
|
||||
}
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
||||
get onopen() {
|
||||
return __privateGet(this, _onOpen);
|
||||
}
|
||||
set onopen(value) {
|
||||
__privateSet(this, _onOpen, value);
|
||||
}
|
||||
addEventListener(type, listener, options) {
|
||||
const listen = listener;
|
||||
super.addEventListener(type, listen, options);
|
||||
}
|
||||
removeEventListener(type, listener, options) {
|
||||
const listen = listener;
|
||||
super.removeEventListener(type, listen, options);
|
||||
}
|
||||
/**
|
||||
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
close() {
|
||||
__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));
|
||||
}
|
||||
}
|
||||
_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 to the given URL and start receiving events
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
connect_fn = function() {
|
||||
__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));
|
||||
}, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), /**
|
||||
* Get request options for the `fetch()` request
|
||||
*
|
||||
* @returns The request options
|
||||
* @internal
|
||||
*/
|
||||
getRequestOptions_fn = function() {
|
||||
var _a;
|
||||
const init = {
|
||||
// [spec] Let `corsAttributeState` be `Anonymous`…
|
||||
// [spec] …will have their mode set to "cors"…
|
||||
mode: "cors",
|
||||
redirect: "follow",
|
||||
headers: { Accept: "text/event-stream", ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0 },
|
||||
cache: "no-store",
|
||||
signal: (_a = __privateGet(this, _controller)) == null ? void 0 : _a.signal
|
||||
};
|
||||
return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;
|
||||
}, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), /**
|
||||
* Handles the process referred to in the EventSource specification as "failing a connection".
|
||||
*
|
||||
* @param error - The error causing the connection to fail
|
||||
* @param code - The HTTP status code, if available
|
||||
* @internal
|
||||
*/
|
||||
failConnection_fn = function(message, code) {
|
||||
var _a;
|
||||
__privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
|
||||
const errorEvent = new ErrorEvent("error", { code, message });
|
||||
(_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent);
|
||||
}, /**
|
||||
* Schedules a reconnection attempt against the EventSource endpoint.
|
||||
*
|
||||
* @param message - The error causing the connection to fail
|
||||
* @param code - The HTTP status code, if available
|
||||
* @internal
|
||||
*/
|
||||
scheduleReconnect_fn = function(message, code) {
|
||||
var _a;
|
||||
if (__privateGet(this, _readyState) === this.CLOSED)
|
||||
return;
|
||||
__privateSet(this, _readyState, this.CONNECTING);
|
||||
const errorEvent = new ErrorEvent("error", { code, message });
|
||||
(_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
|
||||
}, _reconnect = /* @__PURE__ */ new WeakMap(), /**
|
||||
* ReadyState representing an EventSource currently trying to connect
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
EventSource.CONNECTING = 0, /**
|
||||
* ReadyState representing an EventSource connection that is open (eg connected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
EventSource.OPEN = 1, /**
|
||||
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
EventSource.CLOSED = 2;
|
||||
function getBaseURL() {
|
||||
const doc = "document" in globalThis ? globalThis.document : void 0;
|
||||
return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
|
||||
}
|
||||
export {
|
||||
ErrorEvent,
|
||||
EventSource
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
mcp-server/node_modules/eventsource/dist/index.js.map
generated
vendored
Normal file
1
mcp-server/node_modules/eventsource/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
130
mcp-server/node_modules/eventsource/package.json
generated
vendored
Normal file
130
mcp-server/node_modules/eventsource/package.json
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
{
|
||||
"name": "eventsource",
|
||||
"version": "3.0.7",
|
||||
"description": "WhatWG/W3C compliant EventSource client for Node.js and browsers",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"deno": "./dist/index.js",
|
||||
"bun": "./dist/index.js",
|
||||
"source": "./src/index.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pkg-utils build && pkg-utils --strict",
|
||||
"build:watch": "pkg-utils watch",
|
||||
"clean": "rimraf dist coverage",
|
||||
"lint": "eslint . && tsc --noEmit",
|
||||
"posttest": "npm run lint",
|
||||
"prebuild": "npm run clean",
|
||||
"prepare": "npm run build",
|
||||
"test": "npm run test:node && npm run test:browser",
|
||||
"test:browser": "tsx test/browser/client.browser.test.ts",
|
||||
"test:bun": "bun run test/bun/client.bun.test.ts",
|
||||
"test:deno": "deno run --allow-net --allow-read --allow-env --unstable-sloppy-imports test/deno/client.deno.test.ts",
|
||||
"test:node": "tsx test/node/client.node.test.ts"
|
||||
},
|
||||
"files": [
|
||||
"!dist/stats.html",
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://git@github.com/EventSource/eventsource.git"
|
||||
},
|
||||
"keywords": [
|
||||
"sse",
|
||||
"eventsource",
|
||||
"server-sent-events"
|
||||
],
|
||||
"author": "Espen Hovlandsdal <espen@hovlandsdal.com>",
|
||||
"contributors": [
|
||||
"Aslak Hellesøy <aslak.hellesoy@gmail.com>",
|
||||
"Einar Otto Stangvik <einaro.s@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"browserslist": [
|
||||
"node >= 18",
|
||||
"chrome >= 71",
|
||||
"safari >= 14.1",
|
||||
"firefox >= 105",
|
||||
"edge >= 79"
|
||||
],
|
||||
"dependencies": {
|
||||
"eventsource-parser": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sanity/pkg-utils": "^7.1.0",
|
||||
"@sanity/semantic-release-preset": "^5.0.0",
|
||||
"@tsconfig/strictest": "^2.0.5",
|
||||
"@types/sinon": "^17.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^6.11.0",
|
||||
"@typescript-eslint/parser": "^6.11.0",
|
||||
"esbuild": "^0.25.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-config-sanity": "^7.1.3",
|
||||
"eventsource-encoder": "^1.0.0",
|
||||
"playwright": "^1.48.2",
|
||||
"prettier": "^3.5.3",
|
||||
"rimraf": "^5.0.5",
|
||||
"rollup-plugin-visualizer": "^5.12.0",
|
||||
"semantic-release": "^24.2.0",
|
||||
"sinon": "^17.0.1",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.8.2",
|
||||
"undici": "^6.20.1"
|
||||
},
|
||||
"overrides": {
|
||||
"cross-spawn": "7.0.6"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/EventSource/eventsource/issues"
|
||||
},
|
||||
"homepage": "https://github.com/EventSource/eventsource#readme",
|
||||
"prettier": {
|
||||
"semi": false,
|
||||
"printWidth": 100,
|
||||
"bracketSpacing": false,
|
||||
"singleQuote": true
|
||||
},
|
||||
"eslintConfig": {
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 9,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"modules": true
|
||||
}
|
||||
},
|
||||
"extends": [
|
||||
"sanity",
|
||||
"sanity/typescript",
|
||||
"prettier"
|
||||
],
|
||||
"ignorePatterns": [
|
||||
"lib/**/"
|
||||
],
|
||||
"globals": {
|
||||
"globalThis": false
|
||||
},
|
||||
"rules": {
|
||||
"no-undef": "off",
|
||||
"no-empty": "off"
|
||||
}
|
||||
},
|
||||
"publishConfig": {
|
||||
"provenance": true
|
||||
}
|
||||
}
|
||||
596
mcp-server/node_modules/eventsource/src/EventSource.ts
generated
vendored
Normal file
596
mcp-server/node_modules/eventsource/src/EventSource.ts
generated
vendored
Normal file
@@ -0,0 +1,596 @@
|
||||
import {createParser, type EventSourceMessage, type EventSourceParser} from 'eventsource-parser'
|
||||
|
||||
import {ErrorEvent, flattenError, syntaxError} from './errors.js'
|
||||
import type {
|
||||
AddEventListenerOptions,
|
||||
EventListenerOptions,
|
||||
EventListenerOrEventListenerObject,
|
||||
EventSourceEventMap,
|
||||
EventSourceFetchInit,
|
||||
EventSourceInit,
|
||||
FetchLike,
|
||||
FetchLikeResponse,
|
||||
} from './types.js'
|
||||
|
||||
/**
|
||||
* An `EventSource` instance opens a persistent connection to an HTTP server, which sends events
|
||||
* in `text/event-stream` format. The connection remains open until closed by calling `.close()`.
|
||||
*
|
||||
* @public
|
||||
* @example
|
||||
* ```js
|
||||
* const eventSource = new EventSource('https://example.com/stream')
|
||||
* eventSource.addEventListener('error', (error) => {
|
||||
* console.error(error)
|
||||
* })
|
||||
* eventSource.addEventListener('message', (event) => {
|
||||
* console.log('Received message:', event.data)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export class EventSource extends EventTarget {
|
||||
/**
|
||||
* ReadyState representing an EventSource currently trying to connect
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static CONNECTING = 0 as const
|
||||
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is open (eg connected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static OPEN = 1 as const
|
||||
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static CLOSED = 2 as const
|
||||
|
||||
/**
|
||||
* ReadyState representing an EventSource currently trying to connect
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
readonly CONNECTING = 0 as const
|
||||
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is open (eg connected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
readonly OPEN = 1 as const
|
||||
|
||||
/**
|
||||
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
readonly CLOSED = 2 as const
|
||||
|
||||
/**
|
||||
* Returns the state of this EventSource object's connection. It can have the values described below.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
||||
*
|
||||
* Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
|
||||
* defined in the TypeScript `dom` library.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
public get readyState(): number {
|
||||
return this.#readyState
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL providing the event stream.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
public get url(): string {
|
||||
return this.#url.href
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
||||
*/
|
||||
public get withCredentials(): boolean {
|
||||
return this.#withCredentials
|
||||
}
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
||||
public get onerror(): ((ev: ErrorEvent) => unknown) | null {
|
||||
return this.#onError
|
||||
}
|
||||
public set onerror(value: ((ev: ErrorEvent) => unknown) | null) {
|
||||
this.#onError = value
|
||||
}
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
||||
public get onmessage(): ((ev: MessageEvent) => unknown) | null {
|
||||
return this.#onMessage
|
||||
}
|
||||
public set onmessage(value: ((ev: MessageEvent) => unknown) | null) {
|
||||
this.#onMessage = value
|
||||
}
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
||||
public get onopen(): ((ev: Event) => unknown) | null {
|
||||
return this.#onOpen
|
||||
}
|
||||
public set onopen(value: ((ev: Event) => unknown) | null) {
|
||||
this.#onOpen = value
|
||||
}
|
||||
|
||||
override addEventListener<K extends keyof EventSourceEventMap>(
|
||||
type: K,
|
||||
listener: (this: EventSource, ev: EventSourceEventMap[K]) => unknown,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void
|
||||
override addEventListener(
|
||||
type: string,
|
||||
listener: (this: EventSource, event: MessageEvent) => unknown,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void
|
||||
override addEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void
|
||||
override addEventListener(
|
||||
type: string,
|
||||
listener:
|
||||
| ((this: EventSource, event: MessageEvent) => unknown)
|
||||
| EventListenerOrEventListenerObject,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void {
|
||||
const listen = listener as (this: EventSource, event: Event) => unknown
|
||||
super.addEventListener(type, listen, options)
|
||||
}
|
||||
|
||||
override removeEventListener<K extends keyof EventSourceEventMap>(
|
||||
type: K,
|
||||
listener: (this: EventSource, ev: EventSourceEventMap[K]) => unknown,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void
|
||||
override removeEventListener(
|
||||
type: string,
|
||||
listener: (this: EventSource, event: MessageEvent) => unknown,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void
|
||||
override removeEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void
|
||||
override removeEventListener(
|
||||
type: string,
|
||||
listener:
|
||||
| ((this: EventSource, event: MessageEvent) => unknown)
|
||||
| EventListenerOrEventListenerObject,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void {
|
||||
const listen = listener as (this: EventSource, event: Event) => unknown
|
||||
super.removeEventListener(type, listen, options)
|
||||
}
|
||||
|
||||
constructor(url: string | URL, eventSourceInitDict?: EventSourceInit) {
|
||||
super()
|
||||
|
||||
try {
|
||||
if (url instanceof URL) {
|
||||
this.#url = url
|
||||
} else if (typeof url === 'string') {
|
||||
this.#url = new URL(url, getBaseURL())
|
||||
} else {
|
||||
throw new Error('Invalid URL')
|
||||
}
|
||||
} catch (err) {
|
||||
throw syntaxError('An invalid or illegal string was specified')
|
||||
}
|
||||
|
||||
this.#parser = createParser({
|
||||
onEvent: this.#onEvent,
|
||||
onRetry: this.#onRetryChange,
|
||||
})
|
||||
|
||||
this.#readyState = this.CONNECTING
|
||||
this.#reconnectInterval = 3000
|
||||
this.#fetch = eventSourceInitDict?.fetch ?? globalThis.fetch
|
||||
this.#withCredentials = eventSourceInitDict?.withCredentials ?? false
|
||||
|
||||
this.#connect()
|
||||
}
|
||||
|
||||
/**
|
||||
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
close(): void {
|
||||
if (this.#reconnectTimer) clearTimeout(this.#reconnectTimer)
|
||||
if (this.#readyState === this.CLOSED) return
|
||||
if (this.#controller) this.#controller.abort()
|
||||
this.#readyState = this.CLOSED
|
||||
this.#controller = undefined
|
||||
}
|
||||
|
||||
// PRIVATES FOLLOW
|
||||
|
||||
/**
|
||||
* Current connection state
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#readyState: number
|
||||
|
||||
/**
|
||||
* Original URL used to connect.
|
||||
*
|
||||
* Note that this will stay the same even after a redirect.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#url: URL
|
||||
|
||||
/**
|
||||
* The destination URL after a redirect. Is reset on reconnection.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#redirectUrl: URL | undefined
|
||||
|
||||
/**
|
||||
* Whether to include credentials in the request
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#withCredentials: boolean
|
||||
|
||||
/**
|
||||
* The fetch implementation to use
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#fetch: FetchLike
|
||||
|
||||
/**
|
||||
* The reconnection time in milliseconds
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#reconnectInterval: number
|
||||
|
||||
/**
|
||||
* Reference to an ongoing reconnect attempt, if any
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#reconnectTimer: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
/**
|
||||
* The last event ID seen by the EventSource, which will be sent as `Last-Event-ID` in the
|
||||
* request headers on a reconnection attempt.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#lastEventId: string | null = null
|
||||
|
||||
/**
|
||||
* The AbortController instance used to abort the fetch request
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#controller: AbortController | undefined
|
||||
|
||||
/**
|
||||
* Instance of an EventSource parser (`eventsource-parser` npm module)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#parser: EventSourceParser
|
||||
|
||||
/**
|
||||
* Holds the current error handler, attached through `onerror` property directly.
|
||||
* Note that `addEventListener('error', …)` will not be stored here.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#onError: ((ev: ErrorEvent) => unknown) | null = null
|
||||
|
||||
/**
|
||||
* Holds the current message handler, attached through `onmessage` property directly.
|
||||
* Note that `addEventListener('message', …)` will not be stored here.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#onMessage: ((ev: MessageEvent) => unknown) | null = null
|
||||
|
||||
/**
|
||||
* Holds the current open handler, attached through `onopen` property directly.
|
||||
* Note that `addEventListener('open', …)` will not be stored here.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#onOpen: ((ev: Event) => unknown) | null = null
|
||||
|
||||
/**
|
||||
* Connect to the given URL and start receiving events
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#connect() {
|
||||
this.#readyState = this.CONNECTING
|
||||
this.#controller = new AbortController()
|
||||
|
||||
// Browser tests are failing if we directly call `this.#fetch()`, thus the indirection.
|
||||
const fetch = this.#fetch
|
||||
fetch(this.#url, this.#getRequestOptions())
|
||||
.then(this.#onFetchResponse)
|
||||
.catch(this.#onFetchError)
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the fetch response
|
||||
*
|
||||
* @param response - The Fetch(ish) response
|
||||
* @internal
|
||||
*/
|
||||
#onFetchResponse = async (response: FetchLikeResponse) => {
|
||||
this.#parser.reset()
|
||||
|
||||
const {body, redirected, status, headers} = response
|
||||
|
||||
// [spec] a client can be told to stop reconnecting using the HTTP 204 No Content response code.
|
||||
if (status === 204) {
|
||||
// We still need to emit an error event - this mirrors the browser behavior,
|
||||
// and without it there is no way to tell the user that the connection was closed.
|
||||
this.#failConnection('Server sent HTTP 204, not reconnecting', 204)
|
||||
this.close()
|
||||
return
|
||||
}
|
||||
|
||||
// [spec] …Event stream requests can be redirected using HTTP 301 and 307 redirects as with
|
||||
// [spec] normal HTTP requests.
|
||||
// Spec does not say anything about other redirect codes (302, 308), but this seems an
|
||||
// unintended omission, rather than a feature. Browsers will happily redirect on other 3xxs's.
|
||||
if (redirected) {
|
||||
this.#redirectUrl = new URL(response.url)
|
||||
} else {
|
||||
this.#redirectUrl = undefined
|
||||
}
|
||||
|
||||
// [spec] if res's status is not 200, …, then fail the connection.
|
||||
if (status !== 200) {
|
||||
this.#failConnection(`Non-200 status code (${status})`, status)
|
||||
return
|
||||
}
|
||||
|
||||
// [spec] …or if res's `Content-Type` is not `text/event-stream`, then fail the connection.
|
||||
const contentType = headers.get('content-type') || ''
|
||||
if (!contentType.startsWith('text/event-stream')) {
|
||||
this.#failConnection('Invalid content type, expected "text/event-stream"', status)
|
||||
return
|
||||
}
|
||||
|
||||
// [spec] …if the readyState attribute is set to a value other than CLOSED…
|
||||
if (this.#readyState === this.CLOSED) {
|
||||
return
|
||||
}
|
||||
|
||||
// [spec] …sets the readyState attribute to OPEN and fires an event
|
||||
// [spec] …named open at the EventSource object.
|
||||
this.#readyState = this.OPEN
|
||||
|
||||
const openEvent = new Event('open')
|
||||
this.#onOpen?.(openEvent)
|
||||
this.dispatchEvent(openEvent)
|
||||
|
||||
// Ensure that the response stream is a web stream
|
||||
if (typeof body !== 'object' || !body || !('getReader' in body)) {
|
||||
this.#failConnection('Invalid response body, expected a web ReadableStream', status)
|
||||
this.close() // This should only happen if `fetch` provided is "faulty" - don't reconnect
|
||||
return
|
||||
}
|
||||
|
||||
const decoder = new TextDecoder()
|
||||
|
||||
const reader = body.getReader()
|
||||
let open = true
|
||||
|
||||
do {
|
||||
const {done, value} = await reader.read()
|
||||
if (value) {
|
||||
this.#parser.feed(decoder.decode(value, {stream: !done}))
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
continue
|
||||
}
|
||||
|
||||
open = false
|
||||
this.#parser.reset()
|
||||
|
||||
this.#scheduleReconnect()
|
||||
} while (open)
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles rejected requests for the EventSource endpoint
|
||||
*
|
||||
* @param err - The error from `fetch()`
|
||||
* @internal
|
||||
*/
|
||||
#onFetchError = (err: Error & {type?: string}) => {
|
||||
this.#controller = undefined
|
||||
|
||||
// We expect abort errors when the user manually calls `close()` - ignore those
|
||||
if (err.name === 'AbortError' || err.type === 'aborted') {
|
||||
return
|
||||
}
|
||||
|
||||
this.#scheduleReconnect(flattenError(err))
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request options for the `fetch()` request
|
||||
*
|
||||
* @returns The request options
|
||||
* @internal
|
||||
*/
|
||||
#getRequestOptions(): EventSourceFetchInit {
|
||||
const lastEvent = this.#lastEventId ? {'Last-Event-ID': this.#lastEventId} : undefined
|
||||
|
||||
const init: EventSourceFetchInit = {
|
||||
// [spec] Let `corsAttributeState` be `Anonymous`…
|
||||
// [spec] …will have their mode set to "cors"…
|
||||
mode: 'cors',
|
||||
redirect: 'follow',
|
||||
headers: {Accept: 'text/event-stream', ...lastEvent},
|
||||
cache: 'no-store',
|
||||
signal: this.#controller?.signal,
|
||||
}
|
||||
|
||||
// Some environments crash if attempting to set `credentials` where it is not supported,
|
||||
// eg on Cloudflare Workers. To avoid this, we only set it in browser-like environments.
|
||||
if ('window' in globalThis) {
|
||||
// [spec] …and their credentials mode set to "same-origin"
|
||||
// [spec] …if the `withCredentials` attribute is `true`, set the credentials mode to "include"…
|
||||
init.credentials = this.withCredentials ? 'include' : 'same-origin'
|
||||
}
|
||||
|
||||
return init
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by EventSourceParser instance when an event has successfully been parsed
|
||||
* and is ready to be processed.
|
||||
*
|
||||
* @param event - The parsed event
|
||||
* @internal
|
||||
*/
|
||||
#onEvent = (event: EventSourceMessage) => {
|
||||
if (typeof event.id === 'string') {
|
||||
this.#lastEventId = event.id
|
||||
}
|
||||
|
||||
const messageEvent = new MessageEvent(event.event || 'message', {
|
||||
data: event.data,
|
||||
origin: this.#redirectUrl ? this.#redirectUrl.origin : this.#url.origin,
|
||||
lastEventId: event.id || '',
|
||||
})
|
||||
|
||||
// The `onmessage` property of the EventSource instance only triggers on messages without an
|
||||
// `event` field, or ones that explicitly set `message`.
|
||||
if (this.#onMessage && (!event.event || event.event === 'message')) {
|
||||
this.#onMessage(messageEvent)
|
||||
}
|
||||
|
||||
this.dispatchEvent(messageEvent)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by EventSourceParser instance when a new reconnection interval is received
|
||||
* from the EventSource endpoint.
|
||||
*
|
||||
* @param value - The new reconnection interval in milliseconds
|
||||
* @internal
|
||||
*/
|
||||
#onRetryChange = (value: number) => {
|
||||
this.#reconnectInterval = value
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the process referred to in the EventSource specification as "failing a connection".
|
||||
*
|
||||
* @param error - The error causing the connection to fail
|
||||
* @param code - The HTTP status code, if available
|
||||
* @internal
|
||||
*/
|
||||
#failConnection(message?: string, code?: number) {
|
||||
// [spec] …if the readyState attribute is set to a value other than CLOSED,
|
||||
// [spec] sets the readyState attribute to CLOSED…
|
||||
if (this.#readyState !== this.CLOSED) {
|
||||
this.#readyState = this.CLOSED
|
||||
}
|
||||
|
||||
// [spec] …and fires an event named `error` at the `EventSource` object.
|
||||
// [spec] Once the user agent has failed the connection, it does not attempt to reconnect.
|
||||
// [spec] > Implementations are especially encouraged to report detailed information
|
||||
// [spec] > to their development consoles whenever an error event is fired, since little
|
||||
// [spec] > to no information can be made available in the events themselves.
|
||||
// Printing to console is not very programatically helpful, though, so we emit a custom event.
|
||||
const errorEvent = new ErrorEvent('error', {code, message})
|
||||
|
||||
this.#onError?.(errorEvent)
|
||||
this.dispatchEvent(errorEvent)
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a reconnection attempt against the EventSource endpoint.
|
||||
*
|
||||
* @param message - The error causing the connection to fail
|
||||
* @param code - The HTTP status code, if available
|
||||
* @internal
|
||||
*/
|
||||
#scheduleReconnect(message?: string, code?: number) {
|
||||
// [spec] If the readyState attribute is set to CLOSED, abort the task.
|
||||
if (this.#readyState === this.CLOSED) {
|
||||
return
|
||||
}
|
||||
|
||||
// [spec] Set the readyState attribute to CONNECTING.
|
||||
this.#readyState = this.CONNECTING
|
||||
|
||||
// [spec] Fire an event named `error` at the EventSource object.
|
||||
const errorEvent = new ErrorEvent('error', {code, message})
|
||||
this.#onError?.(errorEvent)
|
||||
this.dispatchEvent(errorEvent)
|
||||
|
||||
// [spec] Wait a delay equal to the reconnection time of the event source.
|
||||
this.#reconnectTimer = setTimeout(this.#reconnect, this.#reconnectInterval)
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconnects to the EventSource endpoint after a disconnect/failure
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#reconnect = () => {
|
||||
this.#reconnectTimer = undefined
|
||||
|
||||
// [spec] If the EventSource's readyState attribute is not set to CONNECTING, then return.
|
||||
if (this.#readyState !== this.CONNECTING) {
|
||||
return
|
||||
}
|
||||
|
||||
this.#connect()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* According to spec, when constructing a URL:
|
||||
* > 1. Let baseURL be environment's base URL, if environment is a Document object
|
||||
* > 2. Return the result of applying the URL parser to url, with baseURL.
|
||||
*
|
||||
* Thus we should use `document.baseURI` if available, since it can be set through a base tag.
|
||||
*
|
||||
* @returns The base URL, if available - otherwise `undefined`
|
||||
* @internal
|
||||
*/
|
||||
function getBaseURL(): string | undefined {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const doc = 'document' in globalThis ? (globalThis as any).document : undefined
|
||||
return doc && typeof doc === 'object' && 'baseURI' in doc && typeof doc.baseURI === 'string'
|
||||
? doc.baseURI
|
||||
: undefined
|
||||
}
|
||||
141
mcp-server/node_modules/eventsource/src/errors.ts
generated
vendored
Normal file
141
mcp-server/node_modules/eventsource/src/errors.ts
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* An extended version of the `Event` emitted by the `EventSource` object when an error occurs.
|
||||
* While the spec does not include any additional properties, we intentionally go beyond the spec
|
||||
* and provide some (minimal) additional information to aid in debugging.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class ErrorEvent extends Event {
|
||||
/**
|
||||
* HTTP status code, if this was triggered by an HTTP error
|
||||
* Note: this is not part of the spec, but is included for better error handling.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
public code?: number | undefined
|
||||
|
||||
/**
|
||||
* Optional message attached to the error.
|
||||
* Note: this is not part of the spec, but is included for better error handling.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
public message?: string | undefined
|
||||
|
||||
/**
|
||||
* Constructs a new `ErrorEvent` instance. This is typically not called directly,
|
||||
* but rather emitted by the `EventSource` object when an error occurs.
|
||||
*
|
||||
* @param type - The type of the event (should be "error")
|
||||
* @param errorEventInitDict - Optional properties to include in the error event
|
||||
*/
|
||||
constructor(
|
||||
type: string,
|
||||
errorEventInitDict?: {message?: string | undefined; code?: number | undefined},
|
||||
) {
|
||||
super(type)
|
||||
this.code = errorEventInitDict?.code ?? undefined
|
||||
this.message = errorEventInitDict?.message ?? undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
||||
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
||||
* we explicitly include the properties in the `inspect` method.
|
||||
*
|
||||
* This is automatically called by Node.js when you `console.log` an instance of this class.
|
||||
*
|
||||
* @param _depth - The current depth
|
||||
* @param options - The options passed to `util.inspect`
|
||||
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
||||
* @returns A string representation of the error
|
||||
*/
|
||||
[Symbol.for('nodejs.util.inspect.custom')](
|
||||
_depth: number,
|
||||
options: {colors: boolean},
|
||||
inspect: (obj: unknown, inspectOptions: {colors: boolean}) => string,
|
||||
): string {
|
||||
return inspect(inspectableError(this), options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
||||
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
||||
* we explicitly include the properties in the `inspect` method.
|
||||
*
|
||||
* This is automatically called by Deno when you `console.log` an instance of this class.
|
||||
*
|
||||
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
||||
* @param options - The options passed to `Deno.inspect`
|
||||
* @returns A string representation of the error
|
||||
*/
|
||||
[Symbol.for('Deno.customInspect')](
|
||||
inspect: (obj: unknown, inspectOptions: {colors: boolean}) => string,
|
||||
options: {colors: boolean},
|
||||
): string {
|
||||
return inspect(inspectableError(this), options)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For environments where DOMException may not exist, we will use a SyntaxError instead.
|
||||
* While this isn't strictly according to spec, it is very close.
|
||||
*
|
||||
* @param message - The message to include in the error
|
||||
* @returns A `DOMException` or `SyntaxError` instance
|
||||
* @internal
|
||||
*/
|
||||
export function syntaxError(message: string): SyntaxError {
|
||||
// If someone can figure out a way to make this work without depending on DOM/Node.js typings,
|
||||
// and without casting to `any`, please send a PR 🙏
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const DomException = (globalThis as any).DOMException
|
||||
if (typeof DomException === 'function') {
|
||||
return new DomException(message, 'SyntaxError')
|
||||
}
|
||||
|
||||
return new SyntaxError(message)
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten an error into a single error message string.
|
||||
* Unwraps nested errors and joins them with a comma.
|
||||
*
|
||||
* @param err - The error to flatten
|
||||
* @returns A string representation of the error
|
||||
* @internal
|
||||
*/
|
||||
export function flattenError(err: unknown): string {
|
||||
if (!(err instanceof Error)) {
|
||||
return `${err}`
|
||||
}
|
||||
|
||||
if ('errors' in err && Array.isArray(err.errors)) {
|
||||
return err.errors.map(flattenError).join(', ')
|
||||
}
|
||||
|
||||
if ('cause' in err && err.cause instanceof Error) {
|
||||
return `${err}: ${flattenError(err.cause)}`
|
||||
}
|
||||
|
||||
return err.message
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an `ErrorEvent` instance into a plain object for inspection.
|
||||
*
|
||||
* @param err - The `ErrorEvent` instance to inspect
|
||||
* @returns A plain object representation of the error
|
||||
* @internal
|
||||
*/
|
||||
function inspectableError(err: ErrorEvent) {
|
||||
return {
|
||||
type: err.type,
|
||||
message: err.message,
|
||||
code: err.code,
|
||||
defaultPrevented: err.defaultPrevented,
|
||||
cancelable: err.cancelable,
|
||||
timeStamp: err.timeStamp,
|
||||
}
|
||||
}
|
||||
3
mcp-server/node_modules/eventsource/src/index.ts
generated
vendored
Normal file
3
mcp-server/node_modules/eventsource/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export {ErrorEvent} from './errors.js'
|
||||
export {EventSource} from './EventSource.js'
|
||||
export type * from './types.js'
|
||||
152
mcp-server/node_modules/eventsource/src/types.ts
generated
vendored
Normal file
152
mcp-server/node_modules/eventsource/src/types.ts
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
import type {ErrorEvent} from './errors.js'
|
||||
|
||||
/**
|
||||
* Stripped down version of `fetch()`, only defining the parts we care about.
|
||||
* This ensures it should work with "most" fetch implementations.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type FetchLike = (
|
||||
url: string | URL,
|
||||
init: EventSourceFetchInit,
|
||||
) => Promise<FetchLikeResponse>
|
||||
|
||||
/**
|
||||
* Subset of `RequestInit` used for `fetch()` calls made by the `EventSource` class.
|
||||
* As we know that we will be passing certain values, we can be more specific and have
|
||||
* users not have to do optional chaining and similar for things that will always be there.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface EventSourceFetchInit {
|
||||
/** An AbortSignal to set request's signal. Typed as `any` because of polyfill inconsistencies. */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
signal: {aborted: boolean} | any
|
||||
|
||||
/** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
|
||||
headers: {
|
||||
[key: string]: string
|
||||
Accept: 'text/event-stream'
|
||||
}
|
||||
|
||||
/** A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. */
|
||||
mode: 'cors' | 'no-cors' | 'same-origin'
|
||||
|
||||
/** A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. */
|
||||
credentials?: 'include' | 'omit' | 'same-origin'
|
||||
|
||||
/** Controls how the request is cached. */
|
||||
cache: 'no-store'
|
||||
|
||||
/** A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
|
||||
redirect: 'error' | 'follow' | 'manual'
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @deprecated Use `EventSourceFetchInit` instead.
|
||||
* This type is only here for backwards compatibility and will be removed in a future version.
|
||||
*/
|
||||
export type FetchLikeInit = EventSourceFetchInit
|
||||
|
||||
/**
|
||||
* Stripped down version of `ReadableStreamDefaultReader`, only defining the parts we care about.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ReaderLike {
|
||||
read(): Promise<{done: false; value: unknown} | {done: true; value?: undefined}>
|
||||
cancel(): Promise<void>
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimal version of the `Response` type returned by `fetch()`.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface FetchLikeResponse {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
readonly body: {getReader(): ReaderLike} | Response['body'] | null
|
||||
readonly url: string
|
||||
readonly status: number
|
||||
readonly redirected: boolean
|
||||
readonly headers: {get(name: string): string | null}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings, with the exception of the extended ErrorEvent.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface EventSourceEventMap {
|
||||
error: ErrorEvent
|
||||
message: MessageEvent
|
||||
open: Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings (for the most part)
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface EventSourceInit {
|
||||
/**
|
||||
* A boolean value, defaulting to `false`, indicating if CORS should be set to `include` credentials.
|
||||
*/
|
||||
withCredentials?: boolean
|
||||
|
||||
/**
|
||||
* Optional fetch implementation to use. Defaults to `globalThis.fetch`.
|
||||
* Can also be used for advanced use cases like mocking, proxying, custom certs etc.
|
||||
*/
|
||||
fetch?: FetchLike
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings (sorta).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface EventListenerOptions {
|
||||
/** Not directly used by Node.js. Added for API completeness. Default: `false`. */
|
||||
capture?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings (sorta).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface AddEventListenerOptions extends EventListenerOptions {
|
||||
/** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
|
||||
once?: boolean
|
||||
/** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
|
||||
passive?: boolean
|
||||
/** The listener will be removed when the given AbortSignal object's `abort()` method is called. */
|
||||
signal?: AbortSignal
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type EventListenerOrEventListenerObject = EventListener | EventListenerObject
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface EventListener {
|
||||
(evt: Event | MessageEvent): void
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the official DOM typings.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface EventListenerObject {
|
||||
handleEvent(object: Event): void
|
||||
}
|
||||
Reference in New Issue
Block a user