feat: update openclaw and polish desktop flows

This commit is contained in:
inman
2026-05-13 21:52:17 +08:00
parent 7c8781a6e3
commit 86795078f7
22 changed files with 1145 additions and 186 deletions

View File

@@ -306,6 +306,7 @@ const OPENCLAW_RUNTIME_DEPS_PACKAGES = [
'semver',
'sharp',
'silk-wasm',
'socks-proxy-agent',
'sqlite-vec',
'tar',
'tokenjuice',
@@ -904,6 +905,17 @@ function findFilesByName(rootDir, matcher) {
return matches;
}
function findFirstFileByNameContaining(rootDir, matcher, needle) {
for (const filePath of findFilesByName(rootDir, matcher)) {
try {
if (fs.readFileSync(filePath, 'utf8').includes(needle)) return filePath;
} catch {
continue;
}
}
return null;
}
function patchBundledRuntime(outputDir) {
const replacePatches = [
{
@@ -957,11 +969,17 @@ function patchBundledRuntime(outputDir) {
{
label: 'main session restart recovery mark boundary',
target: () => findFirstFileByName(path.join(outputDir, 'dist'), /^main-session-restart-recovery-.*\.js$/),
search: `\t\t\tif (!interruptedSessionIds.has(entry.sessionId)) continue;
search: `\t\t\tif (!resolveEntryTranscriptLockPaths({
\t\t\t\tentry,
\t\t\t\tsessionsDir
\t\t\t}).some((lockPath) => interruptedLockPaths.has(lockPath))) continue;
\t\t\tentry.abortedLastRun = true;
\t\t\tstore[sessionKey] = entry;
\t\t\tresult.marked++;`,
replace: `\t\t\tif (!interruptedSessionIds.has(entry.sessionId)) continue;
replace: `\t\t\tif (!resolveEntryTranscriptLockPaths({
\t\t\t\tentry,
\t\t\t\tsessionsDir
\t\t\t}).some((lockPath) => interruptedLockPaths.has(lockPath))) continue;
\t\t\tentry.abortedLastRun = true;
\t\t\tif (process.env.OPENCLAW_DISABLE_MAIN_SESSION_RESTART_RECOVERY === "1") {
\t\t\t\tentry.status = "failed";
@@ -987,14 +1005,18 @@ function patchBundledRuntime(outputDir) {
},
{
label: 'stuck session active-run recovery boundary',
target: () => findFirstFileByName(path.join(outputDir, 'dist'), /^diagnostic-.*\.js$/),
search: `\t\t\t\t(opts?.recoverStuckSession ?? recoverStuckSession)({
target: () => findFirstFileByNameContaining(
path.join(outputDir, 'dist'),
/^diagnostic-.*\.js$/,
'classification?.recoveryEligible',
),
search: `\t\t\t\tif (classification?.recoveryEligible) (opts?.recoverStuckSession ?? recoverStuckSession)({
\t\t\t\t\tsessionId: state.sessionId,
\t\t\t\t\tsessionKey: state.sessionKey,
\t\t\t\t\tageMs,
\t\t\t\t\tqueueDepth: state.queueDepth
\t\t\t\t});`,
replace: `\t\t\t\t(opts?.recoverStuckSession ?? recoverStuckSession)({
replace: `\t\t\t\tif (classification?.recoveryEligible) (opts?.recoverStuckSession ?? recoverStuckSession)({
\t\t\t\t\tsessionId: state.sessionId,
\t\t\t\t\tsessionKey: state.sessionKey,
\t\t\t\t\tageMs,
@@ -1019,6 +1041,9 @@ function patchBundledRuntime(outputDir) {
}
const current = fs.readFileSync(target, 'utf8');
if (current.includes(patch.replace)) {
continue;
}
if (!current.includes(patch.search)) {
echo` ⚠️ Skipped patch for ${patch.label}: expected source snippet not found`;
continue;
@@ -1075,6 +1100,10 @@ function patchBundledRuntime(outputDir) {
let matchedAny = false;
for (const target of ptyTargets) {
const current = fs.readFileSync(target, 'utf8');
if (current.includes(patch.replace)) {
matchedAny = true;
continue;
}
if (!current.includes(patch.search)) continue;
matchedAny = true;
const next = current.replaceAll(patch.search, patch.replace);
@@ -1173,6 +1202,10 @@ function patchBundledRuntime(outputDir) {
if (!file.endsWith('.js')) continue;
const filePath = path.join(distDir, file);
const content = fs.readFileSync(filePath, 'utf8');
if (content.includes(patch.replace)) {
matchedAny = true;
continue;
}
if (!content.includes(patch.search)) continue;
matchedAny = true;
const next = content.replace(patch.search, patch.replace);