Skip to content

Commit 3402477

Browse files
committed
chore: remove unused infra helpers
1 parent 71b3bc8 commit 3402477

6 files changed

Lines changed: 2 additions & 80 deletions

File tree

scripts/check-kysely-guardrails.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ function collectImports(sourceFile) {
127127
const importedName = element.propertyName?.text ?? element.name.text;
128128
if (
129129
importedName === "executeSqliteQuerySync" ||
130-
importedName === "executeSqliteQueryTakeFirstSync" ||
131-
importedName === "executeSqliteQueryTakeFirstOrThrowSync"
130+
importedName === "executeSqliteQueryTakeFirstSync"
132131
) {
133132
syncHelperNames.add(element.name.text);
134133
}

src/agents/sessions/tools/bash.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ import { truncateToVisualLines } from "../../modes/interactive/components/visual
88
import { theme } from "../../modes/interactive/theme/theme.js";
99
import type { AgentTool } from "../../runtime/index.js";
1010
import { waitForChildProcess } from "../../utils/child-process.js";
11-
import {
12-
getShellConfig,
13-
getShellEnv,
14-
killProcessTree,
15-
trackDetachedChildPid,
16-
untrackDetachedChildPid,
17-
} from "../../utils/shell.js";
11+
import { getShellConfig, getShellEnv, killProcessTree } from "../../utils/shell.js";
1812
import type { ToolDefinition, ToolRenderResultOptions } from "../extensions/types.js";
1913
import type { BashOperations } from "./bash-operations.js";
2014
import { OutputAccumulator } from "./output-accumulator.js";
@@ -68,9 +62,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas
6862
stdio: ["ignore", "pipe", "pipe"],
6963
windowsHide: true,
7064
});
71-
if (child.pid) {
72-
trackDetachedChildPid(child.pid);
73-
}
7465
let timedOut = false;
7566
let timeoutHandle: NodeJS.Timeout | undefined;
7667
const timeoutMs = resolveBashTimeoutMs(timeout);
@@ -102,9 +93,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas
10293
// on inherited stdio handles held by detached descendants.
10394
waitForChildProcess(child)
10495
.then((code) => {
105-
if (child.pid) {
106-
untrackDetachedChildPid(child.pid);
107-
}
10896
if (timeoutHandle) {
10997
clearTimeout(timeoutHandle);
11098
}
@@ -122,9 +110,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas
122110
resolve({ exitCode: code });
123111
})
124112
.catch((err) => {
125-
if (child.pid) {
126-
untrackDetachedChildPid(child.pid);
127-
}
128113
if (timeoutHandle) {
129114
clearTimeout(timeoutHandle);
130115
}

src/agents/utils/paths.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { realpathSync } from "node:fs";
22
import { isAbsolute, relative, resolve as resolvePath, sep } from "node:path";
3-
import { spawnProcessSync } from "./child-process.js";
43

54
/**
65
* Resolve a path to its canonical (real) form, following symlinks.
@@ -56,23 +55,3 @@ export function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string)
5655
const absolutePath = resolveAgainstCwd(filePath, cwd);
5756
return (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep).join("/");
5857
}
59-
60-
export function markPathIgnoredByCloudSync(path: string): void {
61-
const attrs =
62-
process.platform === "darwin"
63-
? ["com.dropbox.ignored", "com.apple.fileprovider.ignore#P"]
64-
: process.platform === "linux"
65-
? ["user.com.dropbox.ignored"]
66-
: [];
67-
68-
for (const attr of attrs) {
69-
if (process.platform === "darwin") {
70-
spawnProcessSync("xattr", ["-w", attr, "1", path], { encoding: "utf-8", stdio: "ignore" });
71-
} else {
72-
spawnProcessSync("setfattr", ["-n", attr, "-v", "1", path], {
73-
encoding: "utf-8",
74-
stdio: "ignore",
75-
});
76-
}
77-
}
78-
}

src/agents/utils/shell.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -177,27 +177,6 @@ export function sanitizeBinaryOutput(str: string): string {
177177
.join("");
178178
}
179179

180-
/**
181-
* Detached child processes must be tracked so they can be killed on parent
182-
* shutdown signals (SIGHUP/SIGTERM).
183-
*/
184-
const trackedDetachedChildPids = new Set<number>();
185-
186-
export function trackDetachedChildPid(pid: number): void {
187-
trackedDetachedChildPids.add(pid);
188-
}
189-
190-
export function untrackDetachedChildPid(pid: number): void {
191-
trackedDetachedChildPids.delete(pid);
192-
}
193-
194-
export function killTrackedDetachedChildren(): void {
195-
for (const pid of trackedDetachedChildPids) {
196-
killProcessTree(pid);
197-
}
198-
trackedDetachedChildPids.clear();
199-
}
200-
201180
export function killProcessTree(pid: number, opts?: KillProcessTreeOptions): void {
202181
killProcessTreeGracefully(pid, { force: true, ...opts });
203182
}

src/infra/kysely-sync.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,6 @@ export function executeSqliteQueryTakeFirstSync<Row>(
6060
return executeSqliteQuerySync<Row>(db, query).rows[0];
6161
}
6262

63-
export function executeSqliteQueryTakeFirstOrThrowSync<Row>(
64-
db: DatabaseSync,
65-
query: CompilableQuery<Row>,
66-
): Row {
67-
const row = executeSqliteQueryTakeFirstSync<Row>(db, query);
68-
if (!row) {
69-
throw new Error("Kysely query returned no rows");
70-
}
71-
return row;
72-
}
73-
7463
export function clearNodeSqliteKyselyCacheForDatabase(db: DatabaseSync): void {
7564
kyselyByDatabase.delete(db);
7665
}

src/infra/restart-sentinel.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,6 @@ export async function readRestartSentinel(
193193
}
194194
}
195195

196-
export async function hasRestartSentinel(env: NodeJS.ProcessEnv = process.env): Promise<boolean> {
197-
try {
198-
await fs.access(resolveRestartSentinelPath(env));
199-
return true;
200-
} catch {
201-
return false;
202-
}
203-
}
204-
205196
export async function consumeRestartSentinel(
206197
env: NodeJS.ProcessEnv = process.env,
207198
): Promise<RestartSentinel | null> {

0 commit comments

Comments
 (0)