Node install: persist gateway token in service env (#31122)

* Node daemon: persist gateway token env

* changelog: add credits for node gateway token fix

* changelog: credit byungsker for node token service fix

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
Mark L
2026-03-02 09:35:24 +08:00
committed by GitHub
parent ca770622b3
commit f1354869bd
3 changed files with 40 additions and 0 deletions

View File

@@ -364,6 +364,42 @@ describe("buildNodeServiceEnvironment", () => {
expect(env.HOME).toBe("/home/user");
});
it("passes through OPENCLAW_GATEWAY_TOKEN for node services", () => {
const env = buildNodeServiceEnvironment({
env: { HOME: "/home/user", OPENCLAW_GATEWAY_TOKEN: " node-token " },
});
expect(env.OPENCLAW_GATEWAY_TOKEN).toBe("node-token");
});
it("maps legacy CLAWDBOT_GATEWAY_TOKEN to OPENCLAW_GATEWAY_TOKEN for node services", () => {
const env = buildNodeServiceEnvironment({
env: { HOME: "/home/user", CLAWDBOT_GATEWAY_TOKEN: " legacy-token " },
});
expect(env.OPENCLAW_GATEWAY_TOKEN).toBe("legacy-token");
});
it("prefers OPENCLAW_GATEWAY_TOKEN over legacy CLAWDBOT_GATEWAY_TOKEN", () => {
const env = buildNodeServiceEnvironment({
env: {
HOME: "/home/user",
OPENCLAW_GATEWAY_TOKEN: "openclaw-token",
CLAWDBOT_GATEWAY_TOKEN: "legacy-token",
},
});
expect(env.OPENCLAW_GATEWAY_TOKEN).toBe("openclaw-token");
});
it("omits OPENCLAW_GATEWAY_TOKEN when both token env vars are empty", () => {
const env = buildNodeServiceEnvironment({
env: {
HOME: "/home/user",
OPENCLAW_GATEWAY_TOKEN: " ",
CLAWDBOT_GATEWAY_TOKEN: " ",
},
});
expect(env.OPENCLAW_GATEWAY_TOKEN).toBeUndefined();
});
it("forwards proxy environment variables for node services", () => {
const env = buildNodeServiceEnvironment({
env: {