惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
罗磊的独立博客
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
Jina AI
Jina AI
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Last Week in AI
Last Week in AI
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
C
Check Point Blog
GbyAI
GbyAI

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: filter launchd handoff environment · openclaw/opencl...
jesse-merhi · 2026-04-29 · via Recent Commits to openclaw:main

@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";

22

import os from "node:os";

33

import path from "node:path";

44

import { formatErrorMessage } from "../infra/errors.js";

5+

import { sanitizeHostExecEnv } from "../infra/host-env-security.js";

56

import { normalizeOptionalString } from "../shared/string-coerce.js";

67

import { sanitizeForLog } from "../terminal/ansi.js";

78

import { resolveGatewayLaunchAgentLabel } from "./constants.js";

@@ -25,6 +26,13 @@ export type LaunchdRestartTarget = {

2526

const START_AFTER_EXIT_PRINT_RETRY_COUNT = 15;

2627

const START_AFTER_EXIT_PRINT_RETRY_DELAY_SECONDS = 0.2;

272829+

type LaunchdRestartLogEnv = {

30+

HOME?: string;

31+

USERPROFILE?: string;

32+

OPENCLAW_STATE_DIR?: string;

33+

OPENCLAW_PROFILE?: string;

34+

};

35+2836

function assertValidLaunchAgentLabel(label: string): string {

2937

const trimmed = label.trim();

3038

if (!/^[A-Za-z0-9._-]+$/.test(trimmed)) {

@@ -40,6 +48,27 @@ function resolveGuiDomain(): string {

4048

return `gui/${process.getuid()}`;

4149

}

425051+

function collectStringEnvOverrides(

52+

env?: Record<string, string | undefined>,

53+

): Record<string, string> | undefined {

54+

const overrides = Object.fromEntries(

55+

Object.entries(env ?? {}).filter(

56+

(entry): entry is [string, string] => typeof entry[1] === "string",

57+

),

58+

);

59+

return Object.keys(overrides).length > 0 ? overrides : undefined;

60+

}

61+62+

function collectRestartLogEnv(env?: Record<string, string | undefined>): LaunchdRestartLogEnv {

63+

const source = { ...process.env, ...env };

64+

return {

65+

HOME: source.HOME,

66+

USERPROFILE: source.USERPROFILE,

67+

OPENCLAW_STATE_DIR: source.OPENCLAW_STATE_DIR,

68+

OPENCLAW_PROFILE: source.OPENCLAW_PROFILE,

69+

};

70+

}

71+4372

function resolveLaunchAgentLabel(env?: Record<string, string | undefined>): string {

4473

const envLabel = normalizeOptionalString(env?.OPENCLAW_LAUNCHD_LABEL);

4574

if (envLabel) {

@@ -80,11 +109,11 @@ export function isCurrentProcessLaunchdServiceLabel(

8010981110

function buildLaunchdRestartScript(

82111

mode: LaunchdRestartHandoffMode,

83-

env: Record<string, string | undefined>,

112+

restartLogEnv: LaunchdRestartLogEnv,

84113

): string {

85114

const waitForCallerPid = `wait_pid="$4"

86115

label="$5"

87-

${renderPosixRestartLogSetup(env)}

116+

${renderPosixRestartLogSetup(restartLogEnv)}

88117

printf '[%s] openclaw restart attempt source=launchd-handoff mode=${mode} target=%s waitPid=%s\\n' "$(date -u +%FT%TZ)" "$service_target" "$wait_pid" >&2

89118

if [ -n "$wait_pid" ] && [ "$wait_pid" -gt 1 ] 2>/dev/null; then

90119

while kill -0 "$wait_pid" >/dev/null 2>&1; do

@@ -169,13 +198,17 @@ export function scheduleDetachedLaunchdRestartHandoff(params: {

169198

typeof params.waitForPid === "number" && Number.isFinite(params.waitForPid)

170199

? Math.floor(params.waitForPid)

171200

: 0;

172-

const restartEnv = { ...process.env, ...params.env };

201+

const restartLogEnv = collectRestartLogEnv(params.env);

202+

const restartEnv = sanitizeHostExecEnv({

203+

baseEnv: process.env,

204+

overrides: collectStringEnvOverrides(params.env),

205+

});

173206

try {

174207

const child = spawn(

175208

"/bin/sh",

176209

[

177210

"-c",

178-

buildLaunchdRestartScript(params.mode, restartEnv),

211+

buildLaunchdRestartScript(params.mode, restartLogEnv),

179212

"openclaw-launchd-restart-handoff",

180213

target.serviceTarget,

181214

target.domain,