@alfe.ai/gateway 0.0.6 → 0.0.8

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 -10
  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,
@@ -4544,8 +4541,10 @@ function getSystemdServicePath() {
4544
4541
  function getGatewayBinPath() {
4545
4542
  const globalBin = process.env.ALFE_GATEWAY_BIN;
4546
4543
  if (globalBin) return globalBin;
4547
- const builtBin = join(import.meta.dirname, "..", "bin", "gateway.js");
4548
- if (existsSync(builtBin)) return builtBin;
4544
+ for (const rel of ["../bin/gateway.js", "bin/gateway.js"]) {
4545
+ const candidate = join(import.meta.dirname, rel);
4546
+ if (existsSync(candidate)) return candidate;
4547
+ }
4549
4548
  return "alfe-gateway";
4550
4549
  }
4551
4550
  function getNodePath() {
@@ -4599,6 +4598,11 @@ function generateSystemdUnit() {
4599
4598
  const nodePath = getNodePath();
4600
4599
  const gatewayBin = getGatewayBinPath();
4601
4600
  const root = isRootUser();
4601
+ const envLines = [
4602
+ "ALFE_MANAGED",
4603
+ "ALFE_API_KEY",
4604
+ "LOG_LEVEL"
4605
+ ].filter((key) => process.env[key]).map((key) => `Environment=${key}=${process.env[key] ?? ""}`).join("\n");
4602
4606
  return `[Unit]
4603
4607
  Description=Alfe Gateway Daemon
4604
4608
  After=network-online.target
@@ -4610,6 +4614,7 @@ ExecStart=${nodePath} ${gatewayBin} daemon
4610
4614
  Restart=always
4611
4615
  RestartSec=10
4612
4616
  Environment=NODE_ENV=production${root ? "\nEnvironment=HOME=/root\nWorkingDirectory=/root" : ""}
4617
+ ${envLines}
4613
4618
 
4614
4619
  [Install]
4615
4620
  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.8",
4
4
  "description": "Alfe local gateway daemon — persistent control plane for agent integrations",
5
5
  "type": "module",
6
6
  "bin": {