@alfe.ai/gateway 0.0.6 → 0.0.7

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 +15 -8
  2. package/package.json +1 -1
package/dist/health.js CHANGED
@@ -3326,7 +3326,7 @@ async function resolveAgentIdentity(apiKey, apiEndpoint) {
3326
3326
  if (!result.data.valid) throw new Error("API key invalid: validation failed. Run `alfe login` to reconfigure.");
3327
3327
  const orgId = result.data.tenantId;
3328
3328
  if (!orgId) throw new Error("Token validation returned no tenantId — cannot determine org.");
3329
- const agentId = result.data.tokenId ?? deriveAgentId(apiKey);
3329
+ const agentId = result.data.agentId ?? deriveAgentId(apiKey);
3330
3330
  const runtime = result.data.runtime ?? "openclaw";
3331
3331
  logger$1.debug({
3332
3332
  agentId,
@@ -3397,14 +3397,11 @@ function isManagedMode() {
3397
3397
  async function loadManagedConfig() {
3398
3398
  logger$1.debug("Loading managed config from environment...");
3399
3399
  const apiKey = process.env.ALFE_API_KEY;
3400
- const apiEndpoint = process.env.ALFE_API_ENDPOINT;
3401
- if (!apiKey || !apiEndpoint) throw new Error(`ALFE_API_KEY and ALFE_API_ENDPOINT required in managed mode (apiKey=${apiKey ? "set" : "missing"}, apiEndpoint=${apiEndpoint ? "set" : "missing"})`);
3402
- logger$1.debug({
3403
- apiEndpoint,
3404
- gatewayWsUrlEnv: process.env.ALFE_GATEWAY_WS_URL ?? "(not set)"
3405
- }, "Environment loaded, resolving identity...");
3400
+ if (!apiKey) throw new Error("ALFE_API_KEY required in managed mode");
3401
+ const apiEndpoint = process.env.ALFE_API_ENDPOINT ?? getEndpointFromToken(apiKey);
3402
+ logger$1.debug({ apiEndpoint }, "Environment loaded, resolving identity...");
3406
3403
  const identity = await resolveAgentIdentity(apiKey, apiEndpoint);
3407
- const gatewayWsUrl = process.env.ALFE_GATEWAY_WS_URL ?? deriveGatewayWsUrl(apiEndpoint);
3404
+ const gatewayWsUrl = deriveGatewayWsUrl(apiEndpoint);
3408
3405
  logger$1.debug({
3409
3406
  agentId: identity.agentId,
3410
3407
  orgId: identity.orgId,
@@ -4546,6 +4543,10 @@ function getGatewayBinPath() {
4546
4543
  if (globalBin) return globalBin;
4547
4544
  const builtBin = join(import.meta.dirname, "..", "bin", "gateway.js");
4548
4545
  if (existsSync(builtBin)) return builtBin;
4546
+ try {
4547
+ const resolved = execSync("node -e \"console.log(require.resolve('@alfe.ai/gateway/bin/gateway.js'))\"", { encoding: "utf-8" }).trim();
4548
+ if (existsSync(resolved)) return resolved;
4549
+ } catch {}
4549
4550
  return "alfe-gateway";
4550
4551
  }
4551
4552
  function getNodePath() {
@@ -4599,6 +4600,11 @@ function generateSystemdUnit() {
4599
4600
  const nodePath = getNodePath();
4600
4601
  const gatewayBin = getGatewayBinPath();
4601
4602
  const root = isRootUser();
4603
+ const envLines = [
4604
+ "ALFE_MANAGED",
4605
+ "ALFE_API_KEY",
4606
+ "LOG_LEVEL"
4607
+ ].filter((key) => process.env[key]).map((key) => `Environment=${key}=${process.env[key] ?? ""}`).join("\n");
4602
4608
  return `[Unit]
4603
4609
  Description=Alfe Gateway Daemon
4604
4610
  After=network-online.target
@@ -4610,6 +4616,7 @@ ExecStart=${nodePath} ${gatewayBin} daemon
4610
4616
  Restart=always
4611
4617
  RestartSec=10
4612
4618
  Environment=NODE_ENV=production${root ? "\nEnvironment=HOME=/root\nWorkingDirectory=/root" : ""}
4619
+ ${envLines}
4613
4620
 
4614
4621
  [Install]
4615
4622
  WantedBy=${root ? "multi-user.target" : "default.target"}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/gateway",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Alfe local gateway daemon — persistent control plane for agent integrations",
5
5
  "type": "module",
6
6
  "bin": {