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:
anthonyrawlins
2025-07-07 21:44:31 +10:00
commit d7ad321176
2631 changed files with 870175 additions and 0 deletions

273
mcp-server/node_modules/eventsource/dist/index.cjs generated vendored Normal file
View 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

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
View 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
View 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
View 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

File diff suppressed because one or more lines are too long