mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 22:03:52 +00:00
merge: resolve conflicts with origin/main
Adopt main's refactored prepareMockAgentDataHome that returns platform-aware env vars via candidateInstallDirs, and use the returned agentEnv in integration tests. Remove duplicate installDirsForDataHome helper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
d8d0884d0a
3 changed files with 32 additions and 30 deletions
|
|
@ -1,7 +1,30 @@
|
|||
import { chmodSync, mkdirSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
export function prepareMockAgentDataHome(dataHome: string): void {
|
||||
function candidateInstallDirs(dataHome: string): string[] {
|
||||
const dirs = [join(dataHome, "sandbox-agent", "bin")];
|
||||
if (process.platform === "darwin") {
|
||||
dirs.push(join(dataHome, "Library", "Application Support", "sandbox-agent", "bin"));
|
||||
} else if (process.platform === "win32") {
|
||||
dirs.push(join(dataHome, "AppData", "Roaming", "sandbox-agent", "bin"));
|
||||
}
|
||||
return dirs;
|
||||
}
|
||||
|
||||
export function prepareMockAgentDataHome(dataHome: string): Record<string, string> {
|
||||
const runtimeEnv: Record<string, string> = {};
|
||||
if (process.platform === "darwin") {
|
||||
runtimeEnv.HOME = dataHome;
|
||||
runtimeEnv.XDG_DATA_HOME = join(dataHome, ".local", "share");
|
||||
} else if (process.platform === "win32") {
|
||||
runtimeEnv.USERPROFILE = dataHome;
|
||||
runtimeEnv.APPDATA = join(dataHome, "AppData", "Roaming");
|
||||
runtimeEnv.LOCALAPPDATA = join(dataHome, "AppData", "Local");
|
||||
} else {
|
||||
runtimeEnv.HOME = dataHome;
|
||||
runtimeEnv.XDG_DATA_HOME = dataHome;
|
||||
}
|
||||
|
||||
const nodeScript = String.raw`#!/usr/bin/env node
|
||||
const { createInterface } = require("node:readline");
|
||||
|
||||
|
|
@ -115,7 +138,7 @@ rl.on("line", (line) => {
|
|||
});
|
||||
`;
|
||||
|
||||
for (const installDir of installDirsForDataHome(dataHome)) {
|
||||
for (const installDir of candidateInstallDirs(dataHome)) {
|
||||
const processDir = join(installDir, "agent_processes");
|
||||
mkdirSync(processDir, { recursive: true });
|
||||
|
||||
|
|
@ -138,20 +161,6 @@ rl.on("line", (line) => {
|
|||
chmodSync(runner, 0o755);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function installDirsForDataHome(dataHome: string): string[] {
|
||||
const candidates = new Set<string>([
|
||||
join(dataHome, "sandbox-agent", "bin"),
|
||||
]);
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
candidates.add(join(dataHome, "Library", "Application Support", "sandbox-agent", "bin"));
|
||||
}
|
||||
|
||||
if (process.platform === "win32") {
|
||||
candidates.add(join(dataHome, "AppData", "Roaming", "sandbox-agent", "bin"));
|
||||
}
|
||||
|
||||
return [...candidates];
|
||||
|
||||
return runtimeEnv;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,19 +173,13 @@ describe("Integration: TypeScript SDK flat session API", () => {
|
|||
|
||||
beforeAll(async () => {
|
||||
dataHome = mkdtempSync(join(tmpdir(), "sdk-integration-"));
|
||||
prepareMockAgentDataHome(dataHome);
|
||||
const agentEnv = prepareMockAgentDataHome(dataHome);
|
||||
|
||||
handle = await spawnSandboxAgent({
|
||||
enabled: true,
|
||||
log: "silent",
|
||||
timeoutMs: 30000,
|
||||
env: {
|
||||
XDG_DATA_HOME: dataHome,
|
||||
HOME: dataHome,
|
||||
USERPROFILE: dataHome,
|
||||
APPDATA: join(dataHome, "AppData", "Roaming"),
|
||||
LOCALAPPDATA: join(dataHome, "AppData", "Local"),
|
||||
},
|
||||
env: agentEnv,
|
||||
});
|
||||
baseUrl = handle.baseUrl;
|
||||
token = handle.token;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue