mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-18 04:51:36 +00:00
refactor: prune unsupported OPENCLAW env overrides (#105970)
* refactor: prune unsupported env overrides * refactor: prune unsupported env overrides * chore: keep dead export baseline current * fix: preserve packaged telemetry override
This commit is contained in:
committed by
GitHub
parent
17630226fc
commit
92962af779
@@ -62,7 +62,6 @@ if [[ "${OPENCLAW_KITCHEN_SINK_LIVE_CLAWHUB:-0}" = "1" ]]; then
|
||||
OPENCLAW_KITCHEN_SINK_LIVE_CLAWHUB \
|
||||
OPENCLAW_CLAWHUB_URL \
|
||||
CLAWHUB_URL \
|
||||
OPENCLAW_CLAWHUB_TOKEN \
|
||||
CLAWHUB_TOKEN \
|
||||
CLAWHUB_AUTH_TOKEN; do
|
||||
env_value="${!env_name:-}"
|
||||
|
||||
@@ -844,11 +844,7 @@ async function assertClawHubPreflight() {
|
||||
process.env.CLAWHUB_URL ||
|
||||
"https://clawhub.ai"
|
||||
).replace(/\/+$/, "");
|
||||
const token =
|
||||
process.env.OPENCLAW_CLAWHUB_TOKEN ||
|
||||
process.env.CLAWHUB_TOKEN ||
|
||||
process.env.CLAWHUB_AUTH_TOKEN ||
|
||||
"";
|
||||
const token = process.env.CLAWHUB_TOKEN || process.env.CLAWHUB_AUTH_TOKEN || "";
|
||||
const preflightUrl = `${baseUrl}/api/v1/packages/${encodeURIComponent(packageName)}`;
|
||||
const response = await withTimeout(
|
||||
`ClawHub package preflight for ${packageName}`,
|
||||
|
||||
@@ -40,7 +40,6 @@ if [[ "${OPENCLAW_PLUGINS_E2E_LIVE_CLAWHUB:-0}" = "1" ]]; then
|
||||
for env_name in \
|
||||
OPENCLAW_CLAWHUB_URL \
|
||||
CLAWHUB_URL \
|
||||
OPENCLAW_CLAWHUB_TOKEN \
|
||||
CLAWHUB_TOKEN \
|
||||
CLAWHUB_AUTH_TOKEN \
|
||||
OPENCLAW_PLUGINS_E2E_LIVE_NPM_REGISTRY; do
|
||||
|
||||
@@ -3,24 +3,13 @@
|
||||
*/
|
||||
import { Buffer } from "node:buffer";
|
||||
import fs from "node:fs/promises";
|
||||
import {
|
||||
createExpiringMapCache,
|
||||
isCacheEnabled,
|
||||
resolveCacheTtlMs,
|
||||
} from "../../config/cache-utils.js";
|
||||
import { createExpiringMapCache, isCacheEnabled } from "../../config/cache-utils.js";
|
||||
import { parseSqliteSessionFileMarker } from "../../config/sessions/sqlite-marker.js";
|
||||
|
||||
const DEFAULT_SESSION_MANAGER_TTL_MS = 45_000; // 45 seconds
|
||||
const MIN_SESSION_MANAGER_CACHE_PRUNE_INTERVAL_MS = 1_000;
|
||||
const MAX_SESSION_MANAGER_CACHE_PRUNE_INTERVAL_MS = 30_000;
|
||||
|
||||
function getSessionManagerTtl(): number {
|
||||
return resolveCacheTtlMs({
|
||||
envValue: process.env.OPENCLAW_SESSION_MANAGER_CACHE_TTL_MS,
|
||||
defaultTtlMs: DEFAULT_SESSION_MANAGER_TTL_MS,
|
||||
});
|
||||
}
|
||||
|
||||
function resolveSessionManagerCachePruneInterval(ttlMs: number): number {
|
||||
return Math.min(
|
||||
Math.max(ttlMs, MIN_SESSION_MANAGER_CACHE_PRUNE_INTERVAL_MS),
|
||||
@@ -44,7 +33,7 @@ export function createSessionManagerCache(options?: {
|
||||
const getTtlMs = () =>
|
||||
typeof options?.ttlMs === "function"
|
||||
? options.ttlMs()
|
||||
: (options?.ttlMs ?? getSessionManagerTtl());
|
||||
: (options?.ttlMs ?? DEFAULT_SESSION_MANAGER_TTL_MS);
|
||||
const cache = createExpiringMapCache<string, true>({
|
||||
ttlMs: getTtlMs,
|
||||
pruneIntervalMs: resolveSessionManagerCachePruneInterval,
|
||||
|
||||
@@ -319,7 +319,7 @@ function stopWatchdogTimer(): void {
|
||||
}
|
||||
|
||||
function shouldStartBackgroundWatchdog(): boolean {
|
||||
return process.env.VITEST !== "true" || process.env.OPENCLAW_TEST_SESSION_LOCK_WATCHDOG === "1";
|
||||
return process.env.VITEST !== "true";
|
||||
}
|
||||
|
||||
function ensureWatchdogStarted(intervalMs: number): void {
|
||||
|
||||
@@ -976,11 +976,7 @@ export class SettingsManager {
|
||||
}
|
||||
|
||||
getClearOnShrink(): boolean {
|
||||
// Settings takes precedence, then env var, then default false
|
||||
if (this.settings.terminal?.clearOnShrink !== undefined) {
|
||||
return this.settings.terminal.clearOnShrink;
|
||||
}
|
||||
return process.env.OPENCLAW_CLEAR_ON_SHRINK === "1";
|
||||
return this.settings.terminal?.clearOnShrink ?? false;
|
||||
}
|
||||
|
||||
setClearOnShrink(enabled: boolean): void {
|
||||
@@ -1064,7 +1060,7 @@ export class SettingsManager {
|
||||
}
|
||||
|
||||
getShowHardwareCursor(): boolean {
|
||||
return this.settings.showHardwareCursor ?? process.env.OPENCLAW_HARDWARE_CURSOR === "1";
|
||||
return this.settings.showHardwareCursor ?? false;
|
||||
}
|
||||
|
||||
setShowHardwareCursor(enabled: boolean): void {
|
||||
|
||||
@@ -117,8 +117,8 @@ describe("openclaw skills install ClawHub GitHub-backed E2E", () => {
|
||||
OPENCLAW_STATE_DIR: stateDir,
|
||||
OPENCLAW_CONFIG_PATH: path.join(stateDir, "openclaw.json"),
|
||||
OPENCLAW_CLAWHUB_URL: registry,
|
||||
OPENCLAW_CLAWHUB_TOKEN: "test-token",
|
||||
OPENCLAW_CLAWHUB_GITHUB_CODELOAD_BASE_URL: registry,
|
||||
CLAWHUB_TOKEN: "test-token",
|
||||
CLAWHUB_GITHUB_CODELOAD_BASE_URL: registry,
|
||||
CLAWHUB_DISABLE_TELEMETRY: "",
|
||||
CLAWDHUB_DISABLE_TELEMETRY: "",
|
||||
OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1",
|
||||
|
||||
@@ -161,10 +161,8 @@ describe("clawhub helpers", () => {
|
||||
|
||||
afterEach(() => {
|
||||
delete process.env.OPENCLAW_CLAWHUB_URL;
|
||||
delete process.env.OPENCLAW_CLAWHUB_TOKEN;
|
||||
delete process.env.CLAWHUB_TOKEN;
|
||||
delete process.env.CLAWHUB_AUTH_TOKEN;
|
||||
delete process.env.OPENCLAW_CLAWHUB_CONFIG_PATH;
|
||||
delete process.env.CLAWHUB_CONFIG_PATH;
|
||||
delete process.env.CLAWDHUB_CONFIG_PATH;
|
||||
originalEnv.restore();
|
||||
@@ -306,7 +304,7 @@ describe("clawhub helpers", () => {
|
||||
it("resolves ClawHub auth token from config.json", async () => {
|
||||
await withTempDir({ prefix: "openclaw-clawhub-config-" }, async (configRoot) => {
|
||||
const configPath = path.join(configRoot, "clawhub", "config.json");
|
||||
process.env.OPENCLAW_CLAWHUB_CONFIG_PATH = configPath;
|
||||
process.env.CLAWHUB_CONFIG_PATH = configPath;
|
||||
await fs.mkdir(path.dirname(configPath), { recursive: true });
|
||||
await fs.writeFile(configPath, JSON.stringify({ auth: { token: "cfg-token-123" } }), "utf8");
|
||||
|
||||
@@ -370,7 +368,7 @@ describe("clawhub helpers", () => {
|
||||
);
|
||||
|
||||
it("injects resolved auth token into ClawHub requests", async () => {
|
||||
process.env.OPENCLAW_CLAWHUB_TOKEN = "env-token-123";
|
||||
process.env.CLAWHUB_TOKEN = "env-token-123";
|
||||
const fetchImpl = async (input: string | URL | Request, init?: RequestInit) => {
|
||||
const url = input instanceof Request ? input.url : String(input);
|
||||
expect(url).toContain("/api/v1/search");
|
||||
@@ -590,7 +588,7 @@ describe("clawhub helpers", () => {
|
||||
});
|
||||
|
||||
it("can post bulk skill security verdict requests without resolved auth", async () => {
|
||||
process.env.OPENCLAW_CLAWHUB_TOKEN = "env-token-123";
|
||||
process.env.CLAWHUB_TOKEN = "env-token-123";
|
||||
let requestedInit: RequestInit | undefined;
|
||||
const envelope = {
|
||||
schema: "clawhub.skill.security-verdicts.v1",
|
||||
@@ -968,7 +966,7 @@ describe("clawhub helpers", () => {
|
||||
});
|
||||
|
||||
it("annotates 429 errors with the reset hint and a sign-in hint when unauthenticated", async () => {
|
||||
process.env.OPENCLAW_CLAWHUB_CONFIG_PATH = path.join(os.tmpdir(), "openclaw-no-clawhub-config");
|
||||
process.env.CLAWHUB_CONFIG_PATH = path.join(os.tmpdir(), "openclaw-no-clawhub-config");
|
||||
await expect(
|
||||
searchClawHubSkills({
|
||||
query: "calendar",
|
||||
@@ -986,7 +984,7 @@ describe("clawhub helpers", () => {
|
||||
});
|
||||
|
||||
it("degrades gracefully on 429 when the response carries no rate-limit headers", async () => {
|
||||
process.env.OPENCLAW_CLAWHUB_CONFIG_PATH = path.join(os.tmpdir(), "openclaw-no-clawhub-config");
|
||||
process.env.CLAWHUB_CONFIG_PATH = path.join(os.tmpdir(), "openclaw-no-clawhub-config");
|
||||
await expect(
|
||||
searchClawHubSkills({
|
||||
query: "calendar",
|
||||
@@ -1200,7 +1198,7 @@ describe("clawhub helpers", () => {
|
||||
});
|
||||
|
||||
it("annotates 429 errors with the reset hint but no sign-in hint when authenticated", async () => {
|
||||
process.env.OPENCLAW_CLAWHUB_TOKEN = "env-token-123";
|
||||
process.env.CLAWHUB_TOKEN = "env-token-123";
|
||||
await expect(
|
||||
searchClawHubSkills({
|
||||
query: "calendar",
|
||||
@@ -1218,7 +1216,7 @@ describe("clawhub helpers", () => {
|
||||
});
|
||||
|
||||
it("skips the reset suffix on 429 when Retry-After is an HTTP-date", async () => {
|
||||
process.env.OPENCLAW_CLAWHUB_TOKEN = "env-token-123";
|
||||
process.env.CLAWHUB_TOKEN = "env-token-123";
|
||||
await expect(
|
||||
searchClawHubSkills({
|
||||
query: "calendar",
|
||||
@@ -1336,7 +1334,7 @@ describe("clawhub helpers", () => {
|
||||
});
|
||||
|
||||
it("does not send ambient ClawHub auth tokens to off-registry resolver archive URLs", async () => {
|
||||
process.env.OPENCLAW_CLAWHUB_TOKEN = "env-token-123";
|
||||
process.env.CLAWHUB_TOKEN = "env-token-123";
|
||||
let requestedUrl = "";
|
||||
let requestedInit: RequestInit | undefined;
|
||||
|
||||
|
||||
@@ -469,7 +469,6 @@ function normalizeBaseUrl(baseUrl?: string): string {
|
||||
|
||||
function normalizeGitHubCodeloadBaseUrl(): string {
|
||||
const value =
|
||||
normalizeOptionalString(process.env.OPENCLAW_CLAWHUB_GITHUB_CODELOAD_BASE_URL) ||
|
||||
normalizeOptionalString(process.env.CLAWHUB_GITHUB_CODELOAD_BASE_URL) ||
|
||||
DEFAULT_GITHUB_CODELOAD_URL;
|
||||
return value.replace(/\/+$/, "") || DEFAULT_GITHUB_CODELOAD_URL;
|
||||
@@ -494,7 +493,6 @@ function extractTokenFromClawHubConfig(value: unknown): string | undefined {
|
||||
|
||||
function resolveClawHubConfigPaths(): string[] {
|
||||
const explicit =
|
||||
normalizeOptionalString(process.env.OPENCLAW_CLAWHUB_CONFIG_PATH) ||
|
||||
normalizeOptionalString(process.env.CLAWHUB_CONFIG_PATH) ||
|
||||
normalizeOptionalString(process.env.CLAWDHUB_CONFIG_PATH); // legacy misspelling from older clawhub CLI builds; keep for back-compat
|
||||
if (explicit) {
|
||||
@@ -518,7 +516,6 @@ function resolveClawHubConfigPaths(): string[] {
|
||||
|
||||
export async function resolveClawHubAuthToken(): Promise<string | undefined> {
|
||||
const envToken =
|
||||
normalizeOptionalString(process.env.OPENCLAW_CLAWHUB_TOKEN) ||
|
||||
normalizeOptionalString(process.env.CLAWHUB_TOKEN) ||
|
||||
normalizeOptionalString(process.env.CLAWHUB_AUTH_TOKEN);
|
||||
if (envToken) {
|
||||
|
||||
@@ -956,7 +956,6 @@ describe("workspace .env blocklist completeness", () => {
|
||||
"OPENCLAW_GATEWAY_URL",
|
||||
"OPENCLAW_CLAWHUB_URL",
|
||||
"CLAWHUB_URL",
|
||||
"OPENCLAW_CLAWHUB_TOKEN",
|
||||
"CLAWHUB_TOKEN",
|
||||
"CLAWHUB_AUTH_TOKEN",
|
||||
"CLAWHUB_CONFIG_PATH",
|
||||
|
||||
Reference in New Issue
Block a user