mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-23 07:51:33 +00:00
ACP: harden startup and move configured routing behind plugin seams (#48197)
* ACPX: keep plugin-local runtime installs out of dist * Gateway: harden ACP startup and service PATH * ACP: reinitialize error-state configured bindings * ACP: classify pre-turn runtime failures as session init failures * Plugins: move configured ACP routing behind channel seams * Telegram tests: align startup probe assertions after rebase * Discord: harden ACP configured binding recovery * ACP: recover Discord bindings after stale runtime exits * ACPX: replace dead sessions during ensure * Discord: harden ACP binding recovery * Discord: fix review follow-ups * ACP bindings: load channel snapshots across workspaces * ACP bindings: cache snapshot channel plugin resolution * Experiments: add ACP pluginification holy grail plan * Experiments: rename ACP pluginification plan doc * Experiments: drop old ACP pluginification doc path * ACP: move configured bindings behind plugin services * Experiments: update bindings capability architecture plan * Bindings: isolate configured binding routing and targets * Discord tests: fix runtime env helper path * Tests: fix channel binding CI regressions * Tests: normalize ACP workspace assertion on Windows * Bindings: isolate configured binding registry * Bindings: finish configured binding cleanup * Bindings: finish generic cleanup * Bindings: align runtime approval callbacks * ACP: delete residual bindings barrel * Bindings: restore legacy compatibility * Revert "Bindings: restore legacy compatibility" This reverts commit ac2ed68fa2426ecc874d68278c71c71ad363fcfe. * Tests: drop ACP route legacy helper names * Discord/ACP: fix binding regressions --------- Co-authored-by: Onur <2453968+osolmaz@users.noreply.github.com>
This commit is contained in:
@@ -257,6 +257,18 @@ describe("buildMinimalServicePath", () => {
|
||||
const unique = [...new Set(parts)];
|
||||
expect(parts.length).toBe(unique.length);
|
||||
});
|
||||
|
||||
it("prepends explicit runtime bin directories before guessed user paths", () => {
|
||||
const result = buildMinimalServicePath({
|
||||
platform: "linux",
|
||||
extraDirs: ["/home/alice/.nvm/versions/node/v22.22.0/bin"],
|
||||
env: { HOME: "/home/alice" },
|
||||
});
|
||||
const parts = splitPath(result, "linux");
|
||||
|
||||
expect(parts[0]).toBe("/home/alice/.nvm/versions/node/v22.22.0/bin");
|
||||
expect(parts).toContain("/home/alice/.nvm/current/bin");
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildServiceEnvironment", () => {
|
||||
@@ -344,6 +356,19 @@ describe("buildServiceEnvironment", () => {
|
||||
expect(env).not.toHaveProperty("PATH");
|
||||
expect(env.OPENCLAW_WINDOWS_TASK_NAME).toBe("OpenClaw Gateway");
|
||||
});
|
||||
|
||||
it("prepends extra runtime directories to the gateway service PATH", () => {
|
||||
const env = buildServiceEnvironment({
|
||||
env: { HOME: "/home/user" },
|
||||
port: 18789,
|
||||
platform: "linux",
|
||||
extraPathDirs: ["/home/user/.nvm/versions/node/v22.22.0/bin"],
|
||||
});
|
||||
|
||||
expect(env.PATH?.split(path.posix.delimiter)[0]).toBe(
|
||||
"/home/user/.nvm/versions/node/v22.22.0/bin",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildNodeServiceEnvironment", () => {
|
||||
@@ -416,6 +441,18 @@ describe("buildNodeServiceEnvironment", () => {
|
||||
});
|
||||
expect(env.TMPDIR).toBe(os.tmpdir());
|
||||
});
|
||||
|
||||
it("prepends extra runtime directories to the node service PATH", () => {
|
||||
const env = buildNodeServiceEnvironment({
|
||||
env: { HOME: "/home/user" },
|
||||
platform: "linux",
|
||||
extraPathDirs: ["/home/user/.nvm/versions/node/v22.22.0/bin"],
|
||||
});
|
||||
|
||||
expect(env.PATH?.split(path.posix.delimiter)[0]).toBe(
|
||||
"/home/user/.nvm/versions/node/v22.22.0/bin",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shared Node TLS env defaults", () => {
|
||||
|
||||
@@ -247,10 +247,11 @@ export function buildServiceEnvironment(params: {
|
||||
port: number;
|
||||
launchdLabel?: string;
|
||||
platform?: NodeJS.Platform;
|
||||
extraPathDirs?: string[];
|
||||
}): Record<string, string | undefined> {
|
||||
const { env, port, launchdLabel } = params;
|
||||
const { env, port, launchdLabel, extraPathDirs } = params;
|
||||
const platform = params.platform ?? process.platform;
|
||||
const sharedEnv = resolveSharedServiceEnvironmentFields(env, platform);
|
||||
const sharedEnv = resolveSharedServiceEnvironmentFields(env, platform, extraPathDirs);
|
||||
const profile = env.OPENCLAW_PROFILE;
|
||||
const resolvedLaunchdLabel =
|
||||
launchdLabel || (platform === "darwin" ? resolveGatewayLaunchAgentLabel(profile) : undefined);
|
||||
@@ -271,10 +272,11 @@ export function buildServiceEnvironment(params: {
|
||||
export function buildNodeServiceEnvironment(params: {
|
||||
env: Record<string, string | undefined>;
|
||||
platform?: NodeJS.Platform;
|
||||
extraPathDirs?: string[];
|
||||
}): Record<string, string | undefined> {
|
||||
const { env } = params;
|
||||
const { env, extraPathDirs } = params;
|
||||
const platform = params.platform ?? process.platform;
|
||||
const sharedEnv = resolveSharedServiceEnvironmentFields(env, platform);
|
||||
const sharedEnv = resolveSharedServiceEnvironmentFields(env, platform, extraPathDirs);
|
||||
const gatewayToken =
|
||||
env.OPENCLAW_GATEWAY_TOKEN?.trim() || env.CLAWDBOT_GATEWAY_TOKEN?.trim() || undefined;
|
||||
return {
|
||||
@@ -313,6 +315,7 @@ function buildCommonServiceEnvironment(
|
||||
function resolveSharedServiceEnvironmentFields(
|
||||
env: Record<string, string | undefined>,
|
||||
platform: NodeJS.Platform,
|
||||
extraPathDirs: string[] | undefined,
|
||||
): SharedServiceEnvironmentFields {
|
||||
const stateDir = env.OPENCLAW_STATE_DIR;
|
||||
const configPath = env.OPENCLAW_CONFIG_PATH;
|
||||
@@ -331,7 +334,10 @@ function resolveSharedServiceEnvironmentFields(
|
||||
tmpDir,
|
||||
// On Windows, Scheduled Tasks should inherit the current task PATH instead of
|
||||
// freezing the install-time snapshot into gateway.cmd/node-host.cmd.
|
||||
minimalPath: platform === "win32" ? undefined : buildMinimalServicePath({ env, platform }),
|
||||
minimalPath:
|
||||
platform === "win32"
|
||||
? undefined
|
||||
: buildMinimalServicePath({ env, platform, extraDirs: extraPathDirs }),
|
||||
proxyEnv,
|
||||
nodeCaCerts,
|
||||
nodeUseSystemCa,
|
||||
|
||||
Reference in New Issue
Block a user