@kb-labs/mcp-app 2.118.0 → 2.118.2

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.
package/dist/bin.cjs CHANGED
@@ -27536,21 +27536,29 @@ function getHandlerPermissions(manifest, host, id) {
27536
27536
  let handlerPerms;
27537
27537
  switch (host) {
27538
27538
  case "cli":
27539
- handlerPerms = manifest.cli?.commands.find((cmd) => cmd.path === id)?.permissions;
27539
+ handlerPerms = manifest.cli?.commands.find(
27540
+ (cmd) => cmd.path === id
27541
+ )?.permissions;
27540
27542
  break;
27541
27543
  case "rest":
27542
27544
  handlerPerms = manifest.rest?.routes.find(
27543
27545
  (route) => `${route.method} ${route.path}` === id
27544
- )?.permissions;
27546
+ )?.permissions ?? manifest.sse?.streams.find((stream2) => stream2.path === id)?.permissions;
27545
27547
  break;
27546
27548
  case "ws":
27547
- handlerPerms = manifest.ws?.channels.find((ch) => ch.path === id)?.permissions;
27549
+ handlerPerms = manifest.ws?.channels.find(
27550
+ (ch) => ch.path === id
27551
+ )?.permissions;
27548
27552
  break;
27549
27553
  case "workflow":
27550
- handlerPerms = manifest.workflows?.handlers.find((h) => h.id === id)?.permissions;
27554
+ handlerPerms = manifest.workflows?.handlers.find(
27555
+ (h) => h.id === id
27556
+ )?.permissions;
27551
27557
  break;
27552
27558
  case "webhook":
27553
- handlerPerms = manifest.webhooks?.handlers.find((h) => h.event === id)?.permissions;
27559
+ handlerPerms = manifest.webhooks?.handlers.find(
27560
+ (h) => h.event === id
27561
+ )?.permissions;
27554
27562
  break;
27555
27563
  }
27556
27564
  return {
@@ -84108,6 +84116,47 @@ function interpolateConfig(value, required2 = true, env = process.env) {
84108
84116
  }
84109
84117
  return value;
84110
84118
  }
84119
+ function applyLocalNetworkOffset(value, env = process.env) {
84120
+ const offset = Number(env.KB_NET_OFFSET) || 0;
84121
+ if (offset === 0) {
84122
+ return value;
84123
+ }
84124
+ return shiftConfigUrls(value, offset);
84125
+ }
84126
+ function shiftConfigUrls(value, offset) {
84127
+ if (typeof value === "string") {
84128
+ return shiftLoopbackUrl(value, offset);
84129
+ }
84130
+ if (Array.isArray(value)) {
84131
+ return value.map((item) => shiftConfigUrls(item, offset));
84132
+ }
84133
+ if (value === null || typeof value !== "object") {
84134
+ return value;
84135
+ }
84136
+ const result = {};
84137
+ for (const [key, child] of Object.entries(value)) {
84138
+ result[key] = key === "serviceTransport" ? child : shiftConfigUrls(child, offset);
84139
+ }
84140
+ return result;
84141
+ }
84142
+ function shiftLoopbackUrl(value, offset) {
84143
+ let url2;
84144
+ try {
84145
+ url2 = new URL(value);
84146
+ } catch {
84147
+ return value;
84148
+ }
84149
+ if (!["localhost", "127.0.0.1", "::1", "[::1]"].includes(url2.hostname) || !url2.port) {
84150
+ return value;
84151
+ }
84152
+ const port = Number(url2.port);
84153
+ if (!Number.isInteger(port) || port <= 0) {
84154
+ return value;
84155
+ }
84156
+ url2.port = String(port + offset);
84157
+ const shifted = url2.toString();
84158
+ return /^[a-z][a-z0-9+.-]*:\/\/[^/?#]+$/i.test(value) ? shifted.replace(/\/$/, "") : shifted;
84159
+ }
84111
84160
  var PLATFORM_CONFIG_PRODUCT = "platform";
84112
84161
  var PLATFORM_CONFIG_SCHEMA = {
84113
84162
  type: "object",
@@ -84284,7 +84333,10 @@ async function loadPlatformConfig(options = {}) {
84284
84333
  );
84285
84334
  }
84286
84335
  const strictInterpolation = env.NODE_ENV === "production";
84287
- const effective = interpolateConfig(merged, strictInterpolation, env);
84336
+ const effective = applyLocalNetworkOffset(
84337
+ interpolateConfig(merged, strictInterpolation, env),
84338
+ env
84339
+ );
84288
84340
  return {
84289
84341
  platformConfig: effective,
84290
84342
  rawConfig: rawProjectConfig,