mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 11:14:08 +00:00
chore: remove unused infra helpers
This commit is contained in:
@@ -127,8 +127,7 @@ function collectImports(sourceFile) {
|
||||
const importedName = element.propertyName?.text ?? element.name.text;
|
||||
if (
|
||||
importedName === "executeSqliteQuerySync" ||
|
||||
importedName === "executeSqliteQueryTakeFirstSync" ||
|
||||
importedName === "executeSqliteQueryTakeFirstOrThrowSync"
|
||||
importedName === "executeSqliteQueryTakeFirstSync"
|
||||
) {
|
||||
syncHelperNames.add(element.name.text);
|
||||
}
|
||||
|
||||
@@ -8,13 +8,7 @@ import { truncateToVisualLines } from "../../modes/interactive/components/visual
|
||||
import { theme } from "../../modes/interactive/theme/theme.js";
|
||||
import type { AgentTool } from "../../runtime/index.js";
|
||||
import { waitForChildProcess } from "../../utils/child-process.js";
|
||||
import {
|
||||
getShellConfig,
|
||||
getShellEnv,
|
||||
killProcessTree,
|
||||
trackDetachedChildPid,
|
||||
untrackDetachedChildPid,
|
||||
} from "../../utils/shell.js";
|
||||
import { getShellConfig, getShellEnv, killProcessTree } from "../../utils/shell.js";
|
||||
import type { ToolDefinition, ToolRenderResultOptions } from "../extensions/types.js";
|
||||
import type { BashOperations } from "./bash-operations.js";
|
||||
import { OutputAccumulator } from "./output-accumulator.js";
|
||||
@@ -68,9 +62,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
windowsHide: true,
|
||||
});
|
||||
if (child.pid) {
|
||||
trackDetachedChildPid(child.pid);
|
||||
}
|
||||
let timedOut = false;
|
||||
let timeoutHandle: NodeJS.Timeout | undefined;
|
||||
const timeoutMs = resolveBashTimeoutMs(timeout);
|
||||
@@ -102,9 +93,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas
|
||||
// on inherited stdio handles held by detached descendants.
|
||||
waitForChildProcess(child)
|
||||
.then((code) => {
|
||||
if (child.pid) {
|
||||
untrackDetachedChildPid(child.pid);
|
||||
}
|
||||
if (timeoutHandle) {
|
||||
clearTimeout(timeoutHandle);
|
||||
}
|
||||
@@ -122,9 +110,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas
|
||||
resolve({ exitCode: code });
|
||||
})
|
||||
.catch((err) => {
|
||||
if (child.pid) {
|
||||
untrackDetachedChildPid(child.pid);
|
||||
}
|
||||
if (timeoutHandle) {
|
||||
clearTimeout(timeoutHandle);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { realpathSync } from "node:fs";
|
||||
import { isAbsolute, relative, resolve as resolvePath, sep } from "node:path";
|
||||
import { spawnProcessSync } from "./child-process.js";
|
||||
|
||||
/**
|
||||
* Resolve a path to its canonical (real) form, following symlinks.
|
||||
@@ -56,23 +55,3 @@ export function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string)
|
||||
const absolutePath = resolveAgainstCwd(filePath, cwd);
|
||||
return (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep).join("/");
|
||||
}
|
||||
|
||||
export function markPathIgnoredByCloudSync(path: string): void {
|
||||
const attrs =
|
||||
process.platform === "darwin"
|
||||
? ["com.dropbox.ignored", "com.apple.fileprovider.ignore#P"]
|
||||
: process.platform === "linux"
|
||||
? ["user.com.dropbox.ignored"]
|
||||
: [];
|
||||
|
||||
for (const attr of attrs) {
|
||||
if (process.platform === "darwin") {
|
||||
spawnProcessSync("xattr", ["-w", attr, "1", path], { encoding: "utf-8", stdio: "ignore" });
|
||||
} else {
|
||||
spawnProcessSync("setfattr", ["-n", attr, "-v", "1", path], {
|
||||
encoding: "utf-8",
|
||||
stdio: "ignore",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,27 +177,6 @@ export function sanitizeBinaryOutput(str: string): string {
|
||||
.join("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Detached child processes must be tracked so they can be killed on parent
|
||||
* shutdown signals (SIGHUP/SIGTERM).
|
||||
*/
|
||||
const trackedDetachedChildPids = new Set<number>();
|
||||
|
||||
export function trackDetachedChildPid(pid: number): void {
|
||||
trackedDetachedChildPids.add(pid);
|
||||
}
|
||||
|
||||
export function untrackDetachedChildPid(pid: number): void {
|
||||
trackedDetachedChildPids.delete(pid);
|
||||
}
|
||||
|
||||
export function killTrackedDetachedChildren(): void {
|
||||
for (const pid of trackedDetachedChildPids) {
|
||||
killProcessTree(pid);
|
||||
}
|
||||
trackedDetachedChildPids.clear();
|
||||
}
|
||||
|
||||
export function killProcessTree(pid: number, opts?: KillProcessTreeOptions): void {
|
||||
killProcessTreeGracefully(pid, { force: true, ...opts });
|
||||
}
|
||||
|
||||
@@ -60,17 +60,6 @@ export function executeSqliteQueryTakeFirstSync<Row>(
|
||||
return executeSqliteQuerySync<Row>(db, query).rows[0];
|
||||
}
|
||||
|
||||
export function executeSqliteQueryTakeFirstOrThrowSync<Row>(
|
||||
db: DatabaseSync,
|
||||
query: CompilableQuery<Row>,
|
||||
): Row {
|
||||
const row = executeSqliteQueryTakeFirstSync<Row>(db, query);
|
||||
if (!row) {
|
||||
throw new Error("Kysely query returned no rows");
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
export function clearNodeSqliteKyselyCacheForDatabase(db: DatabaseSync): void {
|
||||
kyselyByDatabase.delete(db);
|
||||
}
|
||||
|
||||
@@ -193,15 +193,6 @@ export async function readRestartSentinel(
|
||||
}
|
||||
}
|
||||
|
||||
export async function hasRestartSentinel(env: NodeJS.ProcessEnv = process.env): Promise<boolean> {
|
||||
try {
|
||||
await fs.access(resolveRestartSentinelPath(env));
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function consumeRestartSentinel(
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
): Promise<RestartSentinel | null> {
|
||||
|
||||
Reference in New Issue
Block a user