@suveren/gateway 0.8.2 → 0.8.4

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.
@@ -26,8 +26,8 @@
26
26
  "label": "Artifact directory (optional)",
27
27
  "type": "text",
28
28
  "optional": true,
29
- "placeholder": "website/dist",
30
- "description": "Repository-relative directory the host serves as-is, if the built artifact is committed. Lets get_deployment report a digest of the served bytes and derive the source commit from git, so a private staged build can still be released."
29
+ "placeholder": "e.g. dist",
30
+ "description": "Repository-relative directory the host serves as-is, if the built artifact is committed (for the HAP website: website/dist). Lets get_deployment report a digest of the served bytes and derive the source commit from git, so a private staged build can still be released. Leave empty if the host builds from source."
31
31
  }
32
32
  ],
33
33
  "envMapping": {
@@ -3416,31 +3416,74 @@ var IntegrationRegistry = class {
3416
3416
 
3417
3417
  // src/lib/integration-manager.ts
3418
3418
  import { homedir as homedir8 } from "os";
3419
- import { join as join9, delimiter } from "path";
3420
- import { existsSync as existsSync9, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync9, rmSync } from "fs";
3419
+ import { join as join10, delimiter } from "path";
3420
+ import { existsSync as existsSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync10, rmSync } from "fs";
3421
3421
  import { execFile } from "child_process";
3422
3422
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3423
3423
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
3424
3424
  import { getProfile as getProfile5 } from "@hap/core";
3425
- var DEFAULT_DATA_DIR2 = process.env.SUVEREN_DATA_DIR ?? join9(homedir8(), ".suveren");
3426
- var INTEGRATIONS_DIR = process.env.SUVEREN_INTEGRATIONS_DIR ?? join9(DEFAULT_DATA_DIR2, "integrations");
3425
+
3426
+ // src/lib/manifest-loader.ts
3427
+ import { readFileSync as readFileSync9, existsSync as existsSync9 } from "fs";
3428
+ import { join as join9, resolve } from "path";
3429
+ var manifests = /* @__PURE__ */ new Map();
3430
+ function loadManifests(integrationsDir) {
3431
+ const dir = resolve(
3432
+ integrationsDir ?? process.env.SUVEREN_MANIFESTS_DIR ?? join9(import.meta.dirname ?? __dirname, "..", "..", "..", "..", "content", "integrations")
3433
+ );
3434
+ const indexPath = join9(dir, "index.json");
3435
+ if (!existsSync9(indexPath)) {
3436
+ console.error(`[ManifestLoader] No index.json found at ${indexPath}, skipping manifest loading`);
3437
+ return 0;
3438
+ }
3439
+ let index;
3440
+ try {
3441
+ index = JSON.parse(readFileSync9(indexPath, "utf-8"));
3442
+ } catch (err) {
3443
+ console.error(`[ManifestLoader] Failed to parse ${indexPath}:`, err);
3444
+ return 0;
3445
+ }
3446
+ let loaded = 0;
3447
+ for (const [id, relativePath] of Object.entries(index.integrations)) {
3448
+ const manifestPath = join9(dir, relativePath);
3449
+ try {
3450
+ const manifest = JSON.parse(readFileSync9(manifestPath, "utf-8"));
3451
+ manifests.set(id, manifest);
3452
+ loaded++;
3453
+ } catch (err) {
3454
+ console.error(`[ManifestLoader] Failed to load manifest ${id} from ${manifestPath}:`, err);
3455
+ }
3456
+ }
3457
+ console.error(`[ManifestLoader] Loaded ${loaded} integration manifest(s) from ${dir}`);
3458
+ return loaded;
3459
+ }
3460
+ function getManifest(id) {
3461
+ return manifests.get(id);
3462
+ }
3463
+ function getAllManifests() {
3464
+ return Array.from(manifests.values());
3465
+ }
3466
+
3467
+ // src/lib/integration-manager.ts
3468
+ var DEFAULT_DATA_DIR2 = process.env.SUVEREN_DATA_DIR ?? join10(homedir8(), ".suveren");
3469
+ var INTEGRATIONS_DIR = process.env.SUVEREN_INTEGRATIONS_DIR ?? join10(DEFAULT_DATA_DIR2, "integrations");
3427
3470
  var installLock = Promise.resolve();
3428
3471
  function withInstallLock(task) {
3429
3472
  const run = installLock.then(task, task);
3430
3473
  installLock = run.then(() => void 0, () => void 0);
3431
3474
  return run;
3432
3475
  }
3433
- var INTEGRATIONS_BIN = join9(INTEGRATIONS_DIR, "node_modules", ".bin");
3476
+ var INTEGRATIONS_BIN = join10(INTEGRATIONS_DIR, "node_modules", ".bin");
3434
3477
  function buildPath() {
3435
3478
  const base = process.env.PATH ?? "";
3436
3479
  return [INTEGRATIONS_BIN, base].join(delimiter);
3437
3480
  }
3438
3481
  function ensureIntegrationsDir() {
3439
- if (!existsSync9(INTEGRATIONS_DIR)) {
3482
+ if (!existsSync10(INTEGRATIONS_DIR)) {
3440
3483
  mkdirSync7(INTEGRATIONS_DIR, { recursive: true });
3441
3484
  }
3442
- const pkgPath = join9(INTEGRATIONS_DIR, "package.json");
3443
- if (!existsSync9(pkgPath)) {
3485
+ const pkgPath = join10(INTEGRATIONS_DIR, "package.json");
3486
+ if (!existsSync10(pkgPath)) {
3444
3487
  writeFileSync7(pkgPath, JSON.stringify({ name: "suveren-integrations", version: "1.0.0", private: true }, null, 2));
3445
3488
  }
3446
3489
  }
@@ -3507,19 +3550,19 @@ var IntegrationManager = class {
3507
3550
  * exist, and treat anything else as not-installed (and reinstallable).
3508
3551
  */
3509
3552
  isUsableInstall(npmPackage) {
3510
- const pkgDir = join9(INTEGRATIONS_DIR, "node_modules", ...npmPackage.split("/"));
3511
- const pkgJson = join9(pkgDir, "package.json");
3512
- if (!existsSync9(pkgDir) || !existsSync9(pkgJson)) return false;
3553
+ const pkgDir = join10(INTEGRATIONS_DIR, "node_modules", ...npmPackage.split("/"));
3554
+ const pkgJson = join10(pkgDir, "package.json");
3555
+ if (!existsSync10(pkgDir) || !existsSync10(pkgJson)) return false;
3513
3556
  try {
3514
- const pkg = JSON.parse(readFileSync9(pkgJson, "utf8"));
3557
+ const pkg = JSON.parse(readFileSync10(pkgJson, "utf8"));
3515
3558
  const defaultBinName = (pkg.name ?? npmPackage).split("/").pop() ?? "";
3516
3559
  const binMap = typeof pkg.bin === "string" ? { [defaultBinName]: pkg.bin } : pkg.bin ?? {};
3517
3560
  const binEntries = Object.entries(binMap);
3518
3561
  for (const [binName, target] of binEntries) {
3519
- if (!existsSync9(join9(pkgDir, target))) return false;
3562
+ if (!existsSync10(join10(pkgDir, target))) return false;
3520
3563
  if (!this.binShimExists(binName)) return false;
3521
3564
  }
3522
- if (binEntries.length === 0 && pkg.main && !existsSync9(join9(pkgDir, pkg.main))) return false;
3565
+ if (binEntries.length === 0 && pkg.main && !existsSync10(join10(pkgDir, pkg.main))) return false;
3523
3566
  return true;
3524
3567
  } catch {
3525
3568
  return false;
@@ -3533,7 +3576,7 @@ var IntegrationManager = class {
3533
3576
  binShimExists(binName) {
3534
3577
  if (!binName) return false;
3535
3578
  const candidates = process.platform === "win32" ? [binName, `${binName}.cmd`, `${binName}.CMD`, `${binName}.ps1`] : [binName];
3536
- return candidates.some((c) => existsSync9(join9(INTEGRATIONS_BIN, c)));
3579
+ return candidates.some((c) => existsSync10(join10(INTEGRATIONS_BIN, c)));
3537
3580
  }
3538
3581
  /**
3539
3582
  * Install an npm package into the managed integrations directory if not
@@ -3557,8 +3600,8 @@ var IntegrationManager = class {
3557
3600
  }
3558
3601
  /** The actual install. Callers MUST hold the install lock. */
3559
3602
  async installNow(npmPackage) {
3560
- const pkgDir = join9(INTEGRATIONS_DIR, "node_modules", ...npmPackage.split("/"));
3561
- if (existsSync9(pkgDir)) {
3603
+ const pkgDir = join10(INTEGRATIONS_DIR, "node_modules", ...npmPackage.split("/"));
3604
+ if (existsSync10(pkgDir)) {
3562
3605
  console.error(`[IntegrationManager] Removing unusable install of ${npmPackage}`);
3563
3606
  try {
3564
3607
  rmSync(pkgDir, { recursive: true, force: true });
@@ -3887,6 +3930,15 @@ var IntegrationManager = class {
3887
3930
  env[envVar] = creds[key];
3888
3931
  }
3889
3932
  }
3933
+ const manifest = getManifest(config.id);
3934
+ for (const [envVar, credKey] of Object.entries(manifest?.credentials?.envMapping ?? {})) {
3935
+ if (envVar in env) continue;
3936
+ if (envVar in config.envKeys || envVar in (config.optionalEnvKeys ?? {})) continue;
3937
+ const creds = this.serviceCredentials.get(config.id);
3938
+ if (creds && credKey in creds) {
3939
+ env[envVar] = creds[credKey];
3940
+ }
3941
+ }
3890
3942
  return env;
3891
3943
  }
3892
3944
  /**
@@ -3974,28 +4026,28 @@ var IntegrationManager = class {
3974
4026
  };
3975
4027
 
3976
4028
  // src/lib/profile-loader.ts
3977
- import { readFileSync as readFileSync10, existsSync as existsSync10 } from "fs";
3978
- import { join as join10, resolve } from "path";
4029
+ import { readFileSync as readFileSync11, existsSync as existsSync11 } from "fs";
4030
+ import { join as join11, resolve as resolve2 } from "path";
3979
4031
  import { registerProfile } from "@hap/core";
3980
4032
  function loadProfiles(profilesDir) {
3981
- const dir = resolve(profilesDir ?? process.env.SUVEREN_PROFILES_DIR ?? join10(import.meta.dirname ?? __dirname, "..", "..", "..", "..", "..", "hap-profiles"));
3982
- const indexPath = join10(dir, "index.json");
3983
- if (!existsSync10(indexPath)) {
4033
+ const dir = resolve2(profilesDir ?? process.env.SUVEREN_PROFILES_DIR ?? join11(import.meta.dirname ?? __dirname, "..", "..", "..", "..", "..", "hap-profiles"));
4034
+ const indexPath = join11(dir, "index.json");
4035
+ if (!existsSync11(indexPath)) {
3984
4036
  warnNoProfiles(`No index.json at ${indexPath}`);
3985
4037
  return 0;
3986
4038
  }
3987
4039
  let index;
3988
4040
  try {
3989
- index = JSON.parse(readFileSync10(indexPath, "utf-8"));
4041
+ index = JSON.parse(readFileSync11(indexPath, "utf-8"));
3990
4042
  } catch (err) {
3991
4043
  console.error(`[ProfileLoader] Failed to parse ${indexPath}:`, err);
3992
4044
  return 0;
3993
4045
  }
3994
4046
  let loaded = 0;
3995
4047
  for (const [profileId, relativePath] of Object.entries(index.profiles)) {
3996
- const profilePath = join10(dir, relativePath);
4048
+ const profilePath = join11(dir, relativePath);
3997
4049
  try {
3998
- const profile = JSON.parse(readFileSync10(profilePath, "utf-8"));
4050
+ const profile = JSON.parse(readFileSync11(profilePath, "utf-8"));
3999
4051
  registerProfile(profileId, profile);
4000
4052
  const shortName = profileId.split("/").pop()?.replace(/@.*$/, "");
4001
4053
  if (shortName && shortName !== profileId) {
@@ -4027,47 +4079,6 @@ function warnNoProfiles(reason) {
4027
4079
  );
4028
4080
  }
4029
4081
 
4030
- // src/lib/manifest-loader.ts
4031
- import { readFileSync as readFileSync11, existsSync as existsSync11 } from "fs";
4032
- import { join as join11, resolve as resolve2 } from "path";
4033
- var manifests = /* @__PURE__ */ new Map();
4034
- function loadManifests(integrationsDir) {
4035
- const dir = resolve2(
4036
- integrationsDir ?? process.env.SUVEREN_MANIFESTS_DIR ?? join11(import.meta.dirname ?? __dirname, "..", "..", "..", "..", "content", "integrations")
4037
- );
4038
- const indexPath = join11(dir, "index.json");
4039
- if (!existsSync11(indexPath)) {
4040
- console.error(`[ManifestLoader] No index.json found at ${indexPath}, skipping manifest loading`);
4041
- return 0;
4042
- }
4043
- let index;
4044
- try {
4045
- index = JSON.parse(readFileSync11(indexPath, "utf-8"));
4046
- } catch (err) {
4047
- console.error(`[ManifestLoader] Failed to parse ${indexPath}:`, err);
4048
- return 0;
4049
- }
4050
- let loaded = 0;
4051
- for (const [id, relativePath] of Object.entries(index.integrations)) {
4052
- const manifestPath = join11(dir, relativePath);
4053
- try {
4054
- const manifest = JSON.parse(readFileSync11(manifestPath, "utf-8"));
4055
- manifests.set(id, manifest);
4056
- loaded++;
4057
- } catch (err) {
4058
- console.error(`[ManifestLoader] Failed to load manifest ${id} from ${manifestPath}:`, err);
4059
- }
4060
- }
4061
- console.error(`[ManifestLoader] Loaded ${loaded} integration manifest(s) from ${dir}`);
4062
- return loaded;
4063
- }
4064
- function getManifest(id) {
4065
- return manifests.get(id);
4066
- }
4067
- function getAllManifests() {
4068
- return Array.from(manifests.values());
4069
- }
4070
-
4071
4082
  // bin/http.ts
4072
4083
  import { decodeAttestationBlob as decodeAttestationBlob3 } from "@hap/core";
4073
4084