@alfe.ai/gateway 0.0.42 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/health.js +34 -6
  2. package/package.json +3 -3
package/dist/health.js CHANGED
@@ -3415,6 +3415,7 @@ enumValues({
3415
3415
  enumValues({
3416
3416
  Dev: "dev",
3417
3417
  Test: "test",
3418
+ Demo: "demo",
3418
3419
  Live: "live"
3419
3420
  });
3420
3421
  //#endregion
@@ -3686,9 +3687,12 @@ function deriveAgentId(apiKey) {
3686
3687
  * The cloud gateway runs on Fly.io — its URL follows a convention.
3687
3688
  */
3688
3689
  function deriveGatewayWsUrl(apiEndpoint) {
3689
- if (apiEndpoint.includes("dev.alfe.ai")) return process.env.ALFE_GATEWAY_WS_URL ?? "wss://gateway.dev.alfe.ai/ws";
3690
- if (apiEndpoint.includes("test.alfe.ai")) return process.env.ALFE_GATEWAY_WS_URL ?? "wss://gateway.test.alfe.ai/ws";
3691
- return process.env.ALFE_GATEWAY_WS_URL ?? "wss://gateway.alfe.ai/ws";
3690
+ if (process.env.ALFE_GATEWAY_WS_URL) return process.env.ALFE_GATEWAY_WS_URL;
3691
+ try {
3692
+ return `wss://${new URL(apiEndpoint).hostname.replace(/^api\./, "gateway.")}/ws`;
3693
+ } catch {
3694
+ return "wss://gateway.alfe.ai/ws";
3695
+ }
3692
3696
  }
3693
3697
  /**
3694
3698
  * Parse [runtimes.*] sections from config.toml.
@@ -4824,6 +4828,17 @@ var IPCServer = class {
4824
4828
  this.sendResponse(conn, createIPCError(request.id, "PROTOCOL_MISMATCH", `Unsupported protocol version ${String(protocolVersion)}. Server supports v${String(1)}.`));
4825
4829
  return;
4826
4830
  }
4831
+ const staleIds = [];
4832
+ for (const [existingId, existing] of this.connections) if (existingId !== conn.id && existing.info?.name === name) {
4833
+ logger$1.info({
4834
+ staleConnId: existingId,
4835
+ newConnId: conn.id,
4836
+ plugin: name
4837
+ }, "IPC: closing stale duplicate connection");
4838
+ existing.socket.destroy();
4839
+ staleIds.push(existingId);
4840
+ }
4841
+ for (const id of staleIds) this.connections.delete(id);
4827
4842
  conn.info = {
4828
4843
  name,
4829
4844
  version,
@@ -17122,7 +17137,7 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17122
17137
  else module.exports = require_node();
17123
17138
  }));
17124
17139
  //#endregion
17125
- //#region ../../node_modules/.pnpm/follow-redirects@1.15.11/node_modules/follow-redirects/debug.js
17140
+ //#region ../../node_modules/.pnpm/follow-redirects@1.16.0/node_modules/follow-redirects/debug.js
17126
17141
  var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17127
17142
  var debug;
17128
17143
  module.exports = function() {
@@ -17136,7 +17151,7 @@ var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17136
17151
  };
17137
17152
  }));
17138
17153
  //#endregion
17139
- //#region ../../node_modules/.pnpm/follow-redirects@1.15.11/node_modules/follow-redirects/index.js
17154
+ //#region ../../node_modules/.pnpm/follow-redirects@1.16.0/node_modules/follow-redirects/index.js
17140
17155
  var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17141
17156
  var url$1 = __require("url");
17142
17157
  var URL = url$1.URL;
@@ -17158,6 +17173,11 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
17158
17173
  } catch (error) {
17159
17174
  useNativeURL = error.code === "ERR_INVALID_URL";
17160
17175
  }
17176
+ var sensitiveHeaders = [
17177
+ "Authorization",
17178
+ "Proxy-Authorization",
17179
+ "Cookie"
17180
+ ];
17161
17181
  var preservedUrlFields = [
17162
17182
  "auth",
17163
17183
  "host",
@@ -17211,6 +17231,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
17211
17231
  self.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause }));
17212
17232
  }
17213
17233
  };
17234
+ this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i");
17214
17235
  this._performRequest();
17215
17236
  }
17216
17237
  RedirectableRequest.prototype = Object.create(Writable.prototype);
@@ -17334,6 +17355,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
17334
17355
  });
17335
17356
  RedirectableRequest.prototype._sanitizeOptions = function(options) {
17336
17357
  if (!options.headers) options.headers = {};
17358
+ if (!isArray(options.sensitiveHeaders)) options.sensitiveHeaders = [];
17337
17359
  if (options.host) {
17338
17360
  if (!options.hostname) options.hostname = options.host;
17339
17361
  delete options.host;
@@ -17412,7 +17434,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
17412
17434
  debug("redirecting to", redirectUrl.href);
17413
17435
  this._isRedirect = true;
17414
17436
  spreadUrlObject(redirectUrl, this._options);
17415
- if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
17437
+ if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) removeMatchingHeaders(this._headerFilter, this._options.headers);
17416
17438
  if (isFunction(beforeRedirect)) {
17417
17439
  var responseDetails = {
17418
17440
  headers: response.headers,
@@ -17549,6 +17571,9 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
17549
17571
  var dot = subdomain.length - domain.length - 1;
17550
17572
  return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
17551
17573
  }
17574
+ function isArray(value) {
17575
+ return value instanceof Array;
17576
+ }
17552
17577
  function isString(value) {
17553
17578
  return typeof value === "string" || value instanceof String;
17554
17579
  }
@@ -17561,6 +17586,9 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
17561
17586
  function isURL(value) {
17562
17587
  return URL && value instanceof URL;
17563
17588
  }
17589
+ function escapeRegex(regex) {
17590
+ return regex.replace(/[\]\\/()*+?.$]/g, "\\$&");
17591
+ }
17564
17592
  module.exports = wrap({
17565
17593
  http: http$1,
17566
17594
  https: https$1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/gateway",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "description": "Alfe local gateway daemon — persistent control plane for agent integrations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,8 +22,8 @@
22
22
  "pino-roll": "^1.2.0",
23
23
  "smol-toml": ">=1.6.1",
24
24
  "ws": "^8.18.0",
25
- "@alfe.ai/ai-proxy-local": "^0.0.7",
26
- "@alfe.ai/config": "^0.0.7",
25
+ "@alfe.ai/ai-proxy-local": "^0.0.8",
26
+ "@alfe.ai/config": "^0.0.8",
27
27
  "@alfe.ai/integration-manifest": "^0.0.10",
28
28
  "@alfe.ai/integrations": "^0.0.28"
29
29
  },