chore: Initial pass at cleanup of initializeAgent (#1888)

This commit is contained in:
Alex Hancock
2025-03-27 15:40:27 -04:00
committed by GitHub
parent ca41c6ba53
commit 9c290c569f
7 changed files with 23 additions and 243 deletions
@@ -1,6 +1,7 @@
import { ExtensionConfig } from '../../../api/types.gen';
import { getApiUrl, getSecretKey } from '../../../config';
import { toastService, ToastServiceOptions } from '../../../toasts';
import { replaceWithShims } from './utils';
/**
* Makes an API call to the extension endpoints
@@ -166,19 +167,3 @@ export async function removeFromAgent(
throw error;
}
}
// Update the path to the binary based on the command
async function replaceWithShims(cmd: string): Promise<string> {
const binaryPathMap: Record<string, string> = {
goosed: await window.electron.getBinaryPath('goosed'),
npx: await window.electron.getBinaryPath('npx'),
uvx: await window.electron.getBinaryPath('uvx'),
};
if (binaryPathMap[cmd]) {
console.log('--------> Replacing command with shim ------>', cmd, binaryPathMap[cmd]);
return binaryPathMap[cmd];
}
return cmd;
}
@@ -127,3 +127,19 @@ export function extractExtensionConfig(fixedEntry: FixedExtensionEntry): Extensi
const { enabled, ...extensionConfig } = fixedEntry;
return extensionConfig;
}
export async function replaceWithShims(cmd: string) {
const binaryPathMap: Record<string, string> = {
goosed: await window.electron.getBinaryPath('goosed'),
jbang: await window.electron.getBinaryPath('jbang'),
npx: await window.electron.getBinaryPath('npx'),
uvx: await window.electron.getBinaryPath('uvx'),
};
if (binaryPathMap[cmd]) {
console.log('--------> Replacing command with shim ------>', cmd, binaryPathMap[cmd]);
cmd = binaryPathMap[cmd];
}
return cmd;
}