Skip to content

Commit bcf3429

Browse files
authored
refactor: finish export shadow hazard renames (#121471)
* refactor(gateway): distinguish pending node handlers * refactor(approvals): distinguish button presentation builder * refactor(daemon): distinguish service home resolver
1 parent 5b478bb commit bcf3429

13 files changed

Lines changed: 37 additions & 47 deletions

‎docs/.generated/plugin-sdk-api-baseline.sha256‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ c0b60f2e239bc88e8dadbf7b9583c126822678f5d70c880f90f1d447b00e5170 module/agent-r
1111
8fecb210e22bce4532b6ab649b09465f0bd2c857a44abf40db7d683d6491e6da module/allow-from
1212
eba56a699695ffd3bcbf897da0aa93b51294abf1b9542907648b1c30db8c5763 module/allowlist-config-edit
1313
bcb0aa5ac50e9f0c3f72faf18765d36f6e4b5c27082049d8b8aa63c303d37ac7 module/approval-auth-runtime
14-
9624e365c80990675023b34bf46dd2dbc1e9ffc379d478ad800c9c0ef298ada2 module/approval-client-runtime
15-
a598be2363f3fd442c2084ea441ce82e9227ab7b4559d6d18f5f6f5151f6be3c module/approval-delivery-runtime
14+
b7c6bacd60272de8c45cb16c6c75e6acc7eb6580d55f2a3c7543e697b91470f7 module/approval-client-runtime
15+
4fb7f61d33a20570cc79896429b36a40e2c39062a7875e737ed68f262b0bcf38 module/approval-delivery-runtime
1616
0b11bcea0a4b248126d478b50111f922f888750f90a47eb7648d8f19cc36b0a3 module/approval-gateway-runtime
1717
eee50f080f9447135fe72dba2102cf0faf9194d37e5fb07e4a0dc78ac719f77d module/approval-handler-adapter-runtime
1818
2ee0442d19db08d563f61e7d71d5d45776d2a06c4d233317c5171e1a297dcef3 module/approval-handler-runtime
19-
92253e395bb70ec96cde68e7b9aff64316edd148a7eecfa9e7909774e35c9cd6 module/approval-native-runtime
20-
981a13f5c8445e558e17a4d6bb1f476ef0d9e03e0bc0d3c363b422636e6d3277 module/approval-reply-runtime
21-
8e12da9db8ce40d20449de6116c59f800f3f4a452eee2d35b3e8ca4399a5a0b7 module/approval-runtime
19+
886143c449b7d46046f6da65aedd636e8742853250524457464b7f6e8bab949c module/approval-native-runtime
20+
aee9ee8745eba7a1ff464920ecb1807c0b4cab603d0506b42a3647c301cc132d module/approval-reply-runtime
21+
22991b618ee3b322f2f6891b0a82853ff56362425b2bed0713723f6197d403f6 module/approval-runtime
2222
01ca912836b8dec672f705e294f72d346e778557e4c591317d67558ea7669c0b module/archive
2323
d7e53de63b0ac11a266e4abdc18ba6e9401b80309f5c8f5f6a72a00f65dfe3bd module/boolean-param
2424
0d9b23b23425e07595d7457b3b158197244b7ba8615d9fbc358bad13dddb417f module/channel-actions
@@ -76,7 +76,7 @@ dd9f6e0fd33cc88b22543c1ee30cc09cf4de4d8f30dff7b7f9cebef885c21543 module/gateway
7676
f5e190bbfe0c21e76b7281a73cf5e9db806a1ed6e724fac2fb83ade5ccb827a0 module/inbound-envelope
7777
4928af5d2509f696b896f53ac790303a0742202dbcdae3e44fe6d1b434a9c1ba module/inbound-event-delivery
7878
4b85419d23f930c761ad8a13f37fafba0f89a9b9e83ba98b9a3f58b19422f42d module/inbound-reply-dispatch
79-
5c223be031a4670052b7a2203f41eb75118d6331b6c6019a5a97714e256042b6 module/infra-runtime
79+
1e15f71b86e4af797fcbd4322833298a86eee95775970758cf02755b23afb4fd module/infra-runtime
8080
ce73721421f1b903dd04ead4df173582e59ea3e9990248102c448b419cc6d272 module/ingress-effect-once
8181
97742f0953ffc4270763b0d62f24875a0c3ed2ca6d90e96a18c52adc15a20cd0 module/interactive-runtime
8282
408d257ab5cc4b88a22b7e7595039cb8fc524b261c44141b294fbd0100ba62ee module/json-store

‎scripts/lib/export-name-collision-baseline.json‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@
4444
],
4545
"sdk": true
4646
},
47-
{
48-
"name": "buildApprovalPresentation",
49-
"files": [
50-
"src/infra/approval-presentation.ts",
51-
"src/infra/exec-approval-reply.ts"
52-
],
53-
"sdk": true
54-
},
5547
{
5648
"name": "buildBundleMcpToolsFromCatalog",
5749
"files": [
@@ -1320,14 +1312,6 @@
13201312
],
13211313
"sdk": true
13221314
},
1323-
{
1324-
"name": "resolveHomeDir",
1325-
"files": [
1326-
"src/daemon/paths.ts",
1327-
"src/utils.ts"
1328-
],
1329-
"sdk": true
1330-
},
13311315
{
13321316
"name": "resolveMarketplaceInstallShortcut",
13331317
"files": [

‎src/daemon/inspect.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { resolveLaunchAgentLabel } from "./launchd-label.js";
1313
import { parseLaunchdPlistLabel } from "./launchd-plist.js";
1414
import { readLaunchDaemonPlistLabel } from "./launchd-system.js";
15-
import { resolveHomeDir } from "./paths.js";
15+
import { resolveDaemonHomeDir } from "./paths.js";
1616
import { execSchtasks } from "./schtasks-exec.js";
1717
import { parseSystemdExecStart } from "./systemd-unit.js";
1818

@@ -495,7 +495,7 @@ export async function findExtraGatewayServices(
495495

496496
if (process.platform === "darwin") {
497497
try {
498-
const home = resolveHomeDir(env);
498+
const home = resolveDaemonHomeDir(env);
499499
const userDir = path.join(home, "Library", "LaunchAgents");
500500
for (const svc of await scanLaunchdDir({
501501
dir: userDir,
@@ -527,7 +527,7 @@ export async function findExtraGatewayServices(
527527

528528
if (process.platform === "linux") {
529529
try {
530-
const home = resolveHomeDir(env);
530+
const home = resolveDaemonHomeDir(env);
531531
const userDir = path.join(home, ".config", "systemd", "user");
532532
for (const svc of await scanSystemdDir({
533533
dir: userDir,

‎src/daemon/launchd.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import {
4545
isSystemLaunchDaemonOwnershipError,
4646
} from "./launchd-system.js";
4747
import { formatLine, toPosixPath, writeFormattedLines } from "./output.js";
48-
import { resolveGatewayStateDir, resolveHomeDir } from "./paths.js";
48+
import { resolveDaemonHomeDir, resolveGatewayStateDir } from "./paths.js";
4949
import { resolveGatewaySupervisorLogPaths } from "./restart-logs.js";
5050
import { parseKeyValueOutput } from "./runtime-parse.js";
5151
import { createGatewayLifecycleMutationReporter } from "./service-mutation.js";
@@ -167,7 +167,7 @@ function resolveLaunchAgentPlistPathForLabel(
167167
env: Record<string, string | undefined>,
168168
label: string,
169169
): string {
170-
const home = toPosixPath(resolveHomeDir(env));
170+
const home = toPosixPath(resolveDaemonHomeDir(env));
171171
return path.posix.join(home, "Library", "LaunchAgents", `${label}.plist`);
172172
}
173173

@@ -1025,7 +1025,7 @@ export async function uninstallLaunchAgent({
10251025
return;
10261026
}
10271027

1028-
const home = toPosixPath(resolveHomeDir(env));
1028+
const home = toPosixPath(resolveDaemonHomeDir(env));
10291029
const trashDir = path.posix.join(home, ".Trash");
10301030
const dest = path.join(trashDir, `${label}.plist`);
10311031
try {
@@ -1338,7 +1338,7 @@ async function writeLaunchAgentPlist({
13381338
await ensureSecureDirectory(logDir);
13391339

13401340
const plistPath = resolveLaunchAgentPlistPathForLabel(env, label);
1341-
const home = toPosixPath(resolveHomeDir(env));
1341+
const home = toPosixPath(resolveDaemonHomeDir(env));
13421342
const libraryDir = path.posix.join(home, "Library");
13431343
await ensureSecureDirectory(home);
13441344
await ensureSecureDirectory(libraryDir);

‎src/daemon/paths.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const windowsAbsolutePath = /^[a-zA-Z]:[\\/]/;
77
const windowsUncPath = /^\\\\/;
88

99
/** Resolves the home directory used for daemon state paths. */
10-
export function resolveHomeDir(env: Record<string, string | undefined>): string {
10+
// Daemon unit files must not use infra/home-dir because runtime overrides cannot leak into services.
11+
export function resolveDaemonHomeDir(env: Record<string, string | undefined>): string {
1112
const home = normalizeOptionalString(env.HOME) || normalizeOptionalString(env.USERPROFILE);
1213
if (!home) {
1314
throw new Error("Missing HOME");
@@ -38,10 +39,10 @@ function resolveUserPathWithHome(input: string, home?: string): string {
3839
export function resolveGatewayStateDir(env: Record<string, string | undefined>): string {
3940
const override = normalizeOptionalString(env.OPENCLAW_STATE_DIR);
4041
if (override) {
41-
const home = override.startsWith("~") ? resolveHomeDir(env) : undefined;
42+
const home = override.startsWith("~") ? resolveDaemonHomeDir(env) : undefined;
4243
return resolveUserPathWithHome(override, home);
4344
}
44-
const home = resolveHomeDir(env);
45+
const home = resolveDaemonHomeDir(env);
4546
const suffix = resolveGatewayProfileSuffix(env.OPENCLAW_PROFILE);
4647
// Profile suffixes isolate managed service files while preserving the default
4748
// historical ~/.openclaw state path.

‎src/daemon/restart-logs.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from "node:fs";
33
import path from "node:path";
44
import { quoteCmdScriptArg } from "./cmd-argv.js";
55
import { resolveGatewayProfileSuffix } from "./constants.js";
6-
import { resolveGatewayStateDir, resolveHomeDir } from "./paths.js";
6+
import { resolveDaemonHomeDir, resolveGatewayStateDir } from "./paths.js";
77
import type { GatewayLifecycleMutationMode, GatewayServiceEnv } from "./service-types.js";
88

99
const GATEWAY_RESTART_LOG_FILENAME = "gateway-restart.log";
@@ -47,7 +47,7 @@ export function resolveGatewayLogPaths(env: GatewayServiceEnv): GatewayLogPaths
4747
}
4848

4949
function resolveMacLaunchAgentLogPaths(env: GatewayServiceEnv): GatewayLogPaths {
50-
const home = resolveHomeDir(env).replaceAll("\\", "/");
50+
const home = resolveDaemonHomeDir(env).replaceAll("\\", "/");
5151
const logDir = path.posix.join(home, "Library", "Logs", "openclaw");
5252
const prefix = resolveMacLaunchAgentLogPrefix(env);
5353
return {

‎src/daemon/systemd.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
} from "./constants.js";
2727
import { execFileUtf8 } from "./exec-file.js";
2828
import { formatLine, toPosixPath, writeFormattedLines } from "./output.js";
29-
import { resolveHomeDir } from "./paths.js";
29+
import { resolveDaemonHomeDir } from "./paths.js";
3030
import { parseKeyValueOutput } from "./runtime-parse.js";
3131
import {
3232
hasEnvironmentFileSource,
@@ -68,7 +68,7 @@ const SYSTEMD_GATEWAY_DOTENV_FILENAME = "gateway.systemd.env";
6868
const SYSTEMD_NODE_DOTENV_FILENAME = "node.systemd.env";
6969

7070
function resolveSystemdUnitPathForName(env: GatewayServiceEnv, name: string): string {
71-
const home = toPosixPath(resolveHomeDir(env));
71+
const home = toPosixPath(resolveDaemonHomeDir(env));
7272
return path.posix.join(home, ".config", "systemd", "user", `${name}.service`);
7373
}
7474

@@ -523,7 +523,7 @@ async function assertNoSystemGatewayOwnership(env: GatewayServiceEnv): Promise<v
523523

524524
function expandSystemdSpecifier(input: string, env: GatewayServiceEnv): string {
525525
// Support the common unit-specifier used in user services.
526-
return input.replaceAll("%h", toPosixPath(resolveHomeDir(env)));
526+
return input.replaceAll("%h", toPosixPath(resolveDaemonHomeDir(env)));
527527
}
528528

529529
function parseEnvironmentFileSpecs(raw: string): string[] {

‎src/gateway/server-methods/nodes.pending-work.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ vi.mock("../node-wake-state.js", () => ({
3939
releaseNodeWakeLifecycle: mocks.releaseNodeWakeLifecycle,
4040
}));
4141

42-
vi.mock("./nodes.js", () => ({
42+
vi.mock("./nodes.wake.js", () => ({
4343
maybeWakeNodeWithApns: mocks.maybeWakeNodeWithApns,
4444
maybeSendNodeWakeNudge: mocks.maybeSendNodeWakeNudge,
4545
waitForNodeReconnect: mocks.waitForNodeReconnect,

‎src/gateway/server-methods/nodes.pending-work.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ import {
2626
releaseNodeWakeLifecycle,
2727
} from "../node-wake-state.js";
2828
import { respondInvalidParams, respondUnavailableOnThrow } from "./nodes.helpers.js";
29-
import { maybeSendNodeWakeNudge, maybeWakeNodeWithApns, waitForNodeReconnect } from "./nodes.js";
29+
import {
30+
maybeSendNodeWakeNudge,
31+
maybeWakeNodeWithApns,
32+
waitForNodeReconnect,
33+
} from "./nodes.wake.js";
3034
import type { RespondFn } from "./shared-types.js";
3135
import type { GatewayRequestHandlers } from "./types.js";
3236

‎src/infra/exec-approval-reply.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ vi.mock("./exec-approval-surface.js", () => ({
3838
}));
3939

4040
import {
41-
buildApprovalPresentation,
41+
buildApprovalButtonPresentation,
4242
buildApprovalPresentationFromActionDescriptors,
4343
buildExecApprovalActionDescriptors,
4444
buildExecApprovalCommandText,
@@ -508,7 +508,7 @@ describe("exec approval reply helpers", () => {
508508
]);
509509

510510
expect(
511-
buildApprovalPresentation({
511+
buildApprovalButtonPresentation({
512512
approvalId: "req-1",
513513
allowedDecisions: ["deny"],
514514
}),

0 commit comments

Comments
 (0)