Dynamic profile lookup from auth connection
Profile name is returned by ensureAuth() from the auth connection (looked up by domain). No more storing profile names in settings.json for the applier flow. createBrowser() still supports legacy platform keys as fallback for searcher/setup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@ async function getChromium(playwrightPath) {
|
||||
throw new Error('Playwright not found — install with: npm install -g playwright');
|
||||
}
|
||||
|
||||
export async function createBrowser(settings, profileKey) {
|
||||
export async function createBrowser(settings, profileNameOrKey) {
|
||||
const kernelConfig = settings.kernel || {};
|
||||
const playwrightPath = settings.browser?.playwright_path;
|
||||
const apiKey = process.env.KERNEL_API_KEY || settings.kernel_api_key;
|
||||
@@ -31,8 +31,11 @@ export async function createBrowser(settings, profileKey) {
|
||||
|
||||
const kernel = new Kernel({ apiKey });
|
||||
|
||||
const profileName = profileKey ? kernelConfig.profiles?.[profileKey] : null;
|
||||
if (profileKey && !profileName) throw new Error(`No Kernel profile configured for "${profileKey}"`);
|
||||
// Accept either a profile name directly or a platform key (legacy fallback)
|
||||
let profileName = profileNameOrKey;
|
||||
if (profileName && kernelConfig.profiles?.[profileName]) {
|
||||
profileName = kernelConfig.profiles[profileName];
|
||||
}
|
||||
|
||||
const opts = { stealth: true };
|
||||
if (profileName) opts.profile = { name: profileName };
|
||||
|
||||
@@ -59,7 +59,7 @@ export async function ensureAuth(platform, apiKey) {
|
||||
}
|
||||
|
||||
if (conn.status === 'AUTHENTICATED') {
|
||||
return { ok: true };
|
||||
return { ok: true, profileName: conn.profile_name };
|
||||
}
|
||||
|
||||
// NEEDS_AUTH — can we auto re-auth?
|
||||
@@ -88,7 +88,7 @@ export async function ensureAuth(platform, apiKey) {
|
||||
|
||||
if (updated.status === 'AUTHENTICATED') {
|
||||
console.log(` ✅ ${platform} re-authenticated`);
|
||||
return { ok: true };
|
||||
return { ok: true, profileName: updated.profile_name };
|
||||
}
|
||||
|
||||
if (updated.flow_status === 'FAILED') {
|
||||
|
||||
Reference in New Issue
Block a user