@deslop/gateway 0.1.1233 → 0.1.1235

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,11 +14,11 @@
14
14
  <link rel="manifest" href="/manifest.webmanifest" />
15
15
 
16
16
  <title>Gateway</title>
17
- <script type="module" crossorigin src="/assets/index-GPYSTNwq.js"></script>
17
+ <script type="module" crossorigin src="/assets/index-kdeYQ-s9.js"></script>
18
18
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-WkwZ5CU-.js">
19
19
  <link rel="modulepreload" crossorigin href="/assets/react-BUjtWCUj.js">
20
20
  <link rel="modulepreload" crossorigin href="/assets/effect-DJFrJOhz.js">
21
- <link rel="stylesheet" crossorigin href="/assets/index-I1PNwXTF.css">
21
+ <link rel="stylesheet" crossorigin href="/assets/index-CsajmayO.css">
22
22
  </head>
23
23
  <body>
24
24
  <div id="root"></div>
package/dist/server.js CHANGED
@@ -88279,68 +88279,8 @@ function runApp(app) {
88279
88279
  });
88280
88280
  runMain(pipe$1(program, scoped, provide(layerPlatform), provideService(LogToStderr, true)));
88281
88281
  }
88282
- // src/services/connections/lib/utils.ts
88283
- const gatewayUrl = String$5("APP_URL");
88284
- function clientMetadata(url) {
88285
- return {
88286
- client_id: `${url}/oauth/client.json`,
88287
- client_name: "Deslop MCP gateway",
88288
- grant_types: ["authorization_code", "refresh_token"],
88289
- redirect_uris: [`${url}/oauth/callback`],
88290
- response_types: ["code"],
88291
- token_endpoint_auth_method: "none"
88292
- };
88293
- }
88294
- function connectionStatus(connection, now) {
88295
- return valueTags(connection.link, {
88296
- Authorized: (link) => match$1(link.expiresAt <= now && link.token.refresh_token === void 0, {
88297
- onFalse: () => "Connected",
88298
- onTrue: () => "Expired"
88299
- }),
88300
- Connected: () => "Connected",
88301
- Disconnected: () => "Not connected"
88302
- });
88303
- }
88304
- function connectionInfo(connection, now) {
88305
- return {
88306
- ...match$8(fromUndefinedOr(connection.error), {
88307
- onNone: () => ({}),
88308
- onSome: (error) => ({ error })
88309
- }),
88310
- ...pick$1(connection, [
88311
- "id",
88312
- "name",
88313
- "tools",
88314
- "url"
88315
- ]),
88316
- icons: connection.icons ?? [],
88317
- status: connectionStatus(connection, now)
88318
- };
88319
- }
88320
- function serverIcons(implementation) {
88321
- return pipe$1(implementation?.icons ?? [], filter$5((icon) => isSome(match$3(/^(?:https:|data:image\/)/u)(icon.src)) && icon.src.length <= 32768), take$3(2), map$8((icon) => ({
88322
- src: icon.src,
88323
- ...match$8(fromUndefinedOr(icon.theme), {
88324
- onNone: () => ({}),
88325
- onSome: (theme) => ({ theme })
88326
- })
88327
- })));
88328
- }
88329
- function summary(connection) {
88330
- return pipe$1(fromUndefinedOr(connection.instructions), flatMap$7((text) => fromUndefinedOr(split$1(text, /(?<=\.)\s/u)[0])), map$11(slice(0, 160)), getOrElse(() => connection.name));
88331
- }
88332
- function describe(cause) {
88333
- if (is$2(AuthError)(cause)) return cause.message;
88334
- if (isTagged(cause, "TimeoutError")) return "It did not answer in time";
88335
- if (isHttpClientError(cause) && cause.reason._tag === "StatusCodeError") return `It answered HTTP ${cause.reason.response.status}`;
88336
- if (hasProperty(cause, "cause") && isNotUndefined(cause.cause) && isTagged(cause, "UnknownError")) return describe(cause.cause);
88337
- if (hasProperty(cause, "message") && isString$1(cause.message)) return slice(0, 300)(cause.message);
88338
- return "It failed for an unknown reason";
88339
- }
88340
- function serverName(url) {
88341
- return pipe$1(new URL(url).hostname, replace(/^(?:api|app|mcp)\./u, ""), split$1("."), headNonEmpty, replaceAll(/[^a-z0-9_-]/giu, "-"), replaceAll(/^[^a-z0-9]+|[^a-z0-9]+$/giu, ""), slice(0, 16), toLowerCase);
88342
- }
88343
88282
  // src/services/connections/schema.ts
88283
+ var UpstreamError = class extends TaggedError()("UpstreamError", { cause: Defect() }) {};
88344
88284
  const ServerId = String$6.check(isPattern(/^[a-z0-9][a-z0-9_-]{0,23}$/u));
88345
88285
  const ServerUrl = NonEmptyString.check(isMaxLength(2048), makeFilter((value) => {
88346
88286
  if (!URL.canParse(value)) return false;
@@ -88424,6 +88364,67 @@ const Callback = Struct({
88424
88364
  iss: optionalKey(NonEmptyString),
88425
88365
  state: NonEmptyString
88426
88366
  });
88367
+ // src/services/connections/lib/utils.ts
88368
+ const gatewayUrl = String$5("APP_URL");
88369
+ function clientMetadata(url) {
88370
+ return {
88371
+ client_id: `${url}/oauth/client.json`,
88372
+ client_name: "Deslop MCP gateway",
88373
+ grant_types: ["authorization_code", "refresh_token"],
88374
+ redirect_uris: [`${url}/oauth/callback`],
88375
+ response_types: ["code"],
88376
+ token_endpoint_auth_method: "none"
88377
+ };
88378
+ }
88379
+ function connectionStatus(connection, now) {
88380
+ return valueTags(connection.link, {
88381
+ Authorized: (link) => match$1(link.expiresAt <= now && link.token.refresh_token === void 0, {
88382
+ onFalse: () => "Connected",
88383
+ onTrue: () => "Expired"
88384
+ }),
88385
+ Connected: () => "Connected",
88386
+ Disconnected: () => "Not connected"
88387
+ });
88388
+ }
88389
+ function connectionInfo(connection, now) {
88390
+ return {
88391
+ ...match$8(fromUndefinedOr(connection.error), {
88392
+ onNone: () => ({}),
88393
+ onSome: (error) => ({ error })
88394
+ }),
88395
+ ...pick$1(connection, [
88396
+ "id",
88397
+ "name",
88398
+ "tools",
88399
+ "url"
88400
+ ]),
88401
+ icons: connection.icons ?? [],
88402
+ status: connectionStatus(connection, now)
88403
+ };
88404
+ }
88405
+ function serverIcons(implementation) {
88406
+ return pipe$1(implementation?.icons ?? [], filter$5((icon) => isSome(match$3(/^(?:https:|data:image\/)/u)(icon.src)) && icon.src.length <= 32768), take$3(2), map$8((icon) => ({
88407
+ src: icon.src,
88408
+ ...match$8(fromUndefinedOr(icon.theme), {
88409
+ onNone: () => ({}),
88410
+ onSome: (theme) => ({ theme })
88411
+ })
88412
+ })));
88413
+ }
88414
+ function summary(connection) {
88415
+ return pipe$1(fromUndefinedOr(connection.instructions), flatMap$7((text) => fromUndefinedOr(split$1(text, /(?<=\.)\s/u)[0])), map$11(slice(0, 160)), getOrElse(() => connection.name));
88416
+ }
88417
+ function describe(cause) {
88418
+ if (is$2(AuthError)(cause)) return cause.message;
88419
+ if (isTagged(cause, "TimeoutError")) return "It did not answer in time";
88420
+ if (isHttpClientError(cause) && cause.reason._tag === "StatusCodeError") return `It answered HTTP ${cause.reason.response.status}`;
88421
+ if (is$2(UpstreamError)(cause)) return describe(cause.cause);
88422
+ if (hasProperty(cause, "message") && isString$1(cause.message)) return slice(0, 300)(cause.message);
88423
+ return "It failed for an unknown reason";
88424
+ }
88425
+ function serverName(url) {
88426
+ return pipe$1(new URL(url).hostname, replace(/^(?:api|app|mcp)\./u, ""), split$1("."), headNonEmpty, replaceAll(/[^a-z0-9_-]/giu, "-"), replaceAll(/^[^a-z0-9]+|[^a-z0-9]+$/giu, ""), slice(0, 16), toLowerCase);
88427
+ }
88427
88428
  // ../../node_modules/.pnpm/@modelcontextprotocol+client@2.4.0/node_modules/@modelcontextprotocol/client/dist/chunk-DYPzFuB5.mjs
88428
88429
  var __create = Object.create;
88429
88430
  var __defProp = Object.defineProperty;
@@ -115150,30 +115151,39 @@ var Connections = class Connections extends Service$1()("@deslop/gateway/service
115150
115151
  method: "tools/list",
115151
115152
  params: {}
115152
115153
  });
115153
- const response = yield* tryPromise((signal) => fetch(initial.url, {
115154
- body: probe,
115155
- headers: {
115156
- accept: "application/json, text/event-stream",
115157
- "content-type": "application/json",
115158
- "mcp-protocol-version": "2025-06-18"
115159
- },
115160
- method: "POST",
115161
- signal
115162
- }));
115154
+ const response = yield* tryPromise({
115155
+ catch: (cause) => UpstreamError.make({ cause }),
115156
+ try: (signal) => fetch(initial.url, {
115157
+ body: probe,
115158
+ headers: {
115159
+ accept: "application/json, text/event-stream",
115160
+ "content-type": "application/json",
115161
+ "mcp-protocol-version": "2025-06-18"
115162
+ },
115163
+ method: "POST",
115164
+ signal
115165
+ })
115166
+ });
115163
115167
  const challenge = extractWWWAuthenticateParams(response);
115164
115168
  yield* match$8(fromNullishOr(response.body), {
115165
115169
  onNone: () => void_$1,
115166
115170
  onSome: fnUntraced(function* (body) {
115167
- yield* tryPromise(() => body.cancel());
115171
+ yield* tryPromise({
115172
+ catch: (cause) => UpstreamError.make({ cause }),
115173
+ try: () => body.cancel()
115174
+ });
115175
+ })
115176
+ });
115177
+ const discovery = yield* tryPromise({
115178
+ catch: (cause) => UpstreamError.make({ cause }),
115179
+ try: (signal) => discoverOAuthServerInfo(initial.url, {
115180
+ fetchFn: (target, init) => fetch(target, {
115181
+ ...init,
115182
+ signal: AbortSignal.any([signal, ...toArray$1(fromNullishOr(init?.signal))])
115183
+ }),
115184
+ resourceMetadataUrl: challenge.resourceMetadataUrl
115168
115185
  })
115169
115186
  });
115170
- const discovery = yield* tryPromise((signal) => discoverOAuthServerInfo(initial.url, {
115171
- fetchFn: (target, init) => fetch(target, {
115172
- ...init,
115173
- signal: AbortSignal.any([signal, ...toArray$1(fromNullishOr(init?.signal))])
115174
- }),
115175
- resourceMetadataUrl: challenge.resourceMetadataUrl
115176
- }));
115177
115187
  if (discovery.resourceMetadata !== void 0 && discovery.resourceMetadata.resource !== initial.url) return yield* AuthError.make({ message: "The MCP metadata names a different resource URL." });
115178
115188
  if (discovery.authorizationServerMetadata === void 0) {
115179
115189
  const transport = new StreamableHTTPClientTransport(new URL(initial.url), {
@@ -115183,12 +115193,21 @@ var Connections = class Connections extends Service$1()("@deslop/gateway/service
115183
115193
  const anonymous = yield* acquireRelease(sync(() => new Client({
115184
115194
  name: "Deslop MCP gateway",
115185
115195
  version: "0.1.0"
115186
- }, { versionNegotiation: { mode: "auto" } })), (acquired) => pipe$1(tryPromise(() => transport.terminateSession()), timeout("3 seconds"), ignore$1({
115196
+ }, { versionNegotiation: { mode: "auto" } })), (acquired) => pipe$1(tryPromise({
115197
+ catch: (cause) => UpstreamError.make({ cause }),
115198
+ try: () => transport.terminateSession()
115199
+ }), timeout("3 seconds"), ignore$1({
115187
115200
  log: "Warn",
115188
115201
  message: "Cannot terminate the anonymous MCP session"
115189
115202
  }), andThen(promise(() => acquired.close()))));
115190
- yield* tryPromise((signal) => anonymous.connect(transport, { signal }));
115191
- const tools = yield* tryPromise((signal) => anonymous.listTools(void 0, { signal }));
115203
+ yield* tryPromise({
115204
+ catch: (cause) => UpstreamError.make({ cause }),
115205
+ try: (signal) => anonymous.connect(transport, { signal })
115206
+ });
115207
+ const tools = yield* tryPromise({
115208
+ catch: (cause) => UpstreamError.make({ cause }),
115209
+ try: (signal) => anonymous.listTools(void 0, { signal })
115210
+ });
115192
115211
  return {
115193
115212
  ...initial,
115194
115213
  ...match$8(fromUndefinedOr(anonymous.getInstructions()), {
@@ -115541,10 +115560,16 @@ var Gateway = class Gateway extends Service$1()("@deslop/gateway/services/gatewa
115541
115560
  const client = yield* acquireRelease(sync(() => new Client({
115542
115561
  name: "Deslop MCP gateway",
115543
115562
  version: "0.1.0"
115544
- }, { versionNegotiation: { mode: "auto" } })), (acquired) => pipe$1(tryPromise(() => transport.terminateSession()), timeout("3 seconds"), ignore$1({
115563
+ }, { versionNegotiation: { mode: "auto" } })), (acquired) => pipe$1(tryPromise({
115564
+ catch: rejected(server),
115565
+ try: () => transport.terminateSession()
115566
+ }), timeout("3 seconds"), ignore$1({
115545
115567
  log: "Warn",
115546
115568
  message: "Cannot terminate the upstream MCP session"
115547
- }), andThen(tryPromise(() => acquired.close())), ignore$1({
115569
+ }), andThen(tryPromise({
115570
+ catch: rejected(server),
115571
+ try: () => acquired.close()
115572
+ })), ignore$1({
115548
115573
  log: "Warn",
115549
115574
  message: "Cannot close the upstream MCP client"
115550
115575
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/gateway",
3
- "version": "0.1.1233",
3
+ "version": "0.1.1235",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/MP281X/deslop.git",
@@ -32,5 +32,5 @@
32
32
  "engines": {
33
33
  "node": ">=26"
34
34
  },
35
- "fingerprint": "e88c3bfa5c0dd63a1e02b41780a1decbdb09a3d57b6a62e3f3421d5baf9e913c"
35
+ "fingerprint": "db6a86a7c68347b9ff507f6dfce470b3c8b34f1998d668762c03dcdf523dc972"
36
36
  }