From fb7fc31fe115f8ce4ed73c7bca8f1928fe840078 Mon Sep 17 00:00:00 2001 From: Claw Date: Fri, 6 Mar 2026 01:17:52 +0000 Subject: [PATCH] fix: move Kernel connection IDs out of source into settings.json (gitignored) --- config/settings.example.json | 4 ++++ job_searcher.mjs | 4 ++-- lib/session.mjs | 15 +++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/config/settings.example.json b/config/settings.example.json index 10b3b87..cb9e727 100644 --- a/config/settings.example.json +++ b/config/settings.example.json @@ -16,6 +16,10 @@ "profiles": { "linkedin": "LinkedIn-YourName", "wellfound": "WellFound-YourName" + }, + "connection_ids": { + "linkedin": "your-linkedin-connection-id", + "wellfound": "your-wellfound-connection-id" } }, "browser": { diff --git a/job_searcher.mjs b/job_searcher.mjs index 3790b02..c4fb9b5 100644 --- a/job_searcher.mjs +++ b/job_searcher.mjs @@ -97,7 +97,7 @@ async function main() { let liBrowser; try { liBrowser = await createBrowser(settings, 'linkedin'); - const loggedIn = await ensureLoggedIn(liBrowser.page, liLogin, 'linkedin', settings.kernel_api_key || process.env.KERNEL_API_KEY); + const loggedIn = await ensureLoggedIn(liBrowser.page, liLogin, 'linkedin', settings.kernel_api_key || process.env.KERNEL_API_KEY, settings.kernel?.connection_ids || {}); if (!loggedIn) throw new Error('LinkedIn not logged in'); console.log(' ✅ Logged in'); @@ -136,7 +136,7 @@ async function main() { let wfBrowser; try { wfBrowser = await createBrowser(settings, 'wellfound'); - const loggedIn = await ensureLoggedIn(wfBrowser.page, wfLogin, 'wellfound', settings.kernel_api_key || process.env.KERNEL_API_KEY); + const loggedIn = await ensureLoggedIn(wfBrowser.page, wfLogin, 'wellfound', settings.kernel_api_key || process.env.KERNEL_API_KEY, settings.kernel?.connection_ids || {}); if (!loggedIn) console.warn(' ⚠️ Wellfound login unconfirmed, proceeding'); else console.log(' ✅ Logged in'); diff --git a/lib/session.mjs b/lib/session.mjs index 4cf4c30..08309e8 100644 --- a/lib/session.mjs +++ b/lib/session.mjs @@ -7,14 +7,9 @@ const require = createRequire(import.meta.url); const KERNEL_SDK_PATH = '/home/ubuntu/.openclaw/workspace/node_modules/@onkernel/sdk/index.js'; -const CONNECTION_IDS = { - linkedin: 'REDACTED_CONNECTION_ID_LINKEDIN', - wellfound: 'REDACTED_CONNECTION_ID_WELLFOUND', -}; - -export async function refreshSession(platform, apiKey) { - const connectionId = CONNECTION_IDS[platform]; - if (!connectionId) throw new Error(`No connection ID for platform: ${platform}`); +export async function refreshSession(platform, apiKey, connectionIds = {}) { + const connectionId = connectionIds[platform]; + if (!connectionId) throw new Error(`No Kernel connection ID configured for platform: ${platform} — add it to settings.json under kernel.connection_ids`); const Kernel = require(KERNEL_SDK_PATH); const kernel = new Kernel({ apiKey }); @@ -51,14 +46,14 @@ export async function refreshSession(platform, apiKey) { /** * Verify login after browser connects — if not logged in, trigger refresh and retry */ -export async function ensureLoggedIn(page, verifyFn, platform, apiKey, maxAttempts = 2) { +export async function ensureLoggedIn(page, verifyFn, platform, apiKey, connectionIds = {}, maxAttempts = 2) { for (let attempt = 1; attempt <= maxAttempts; attempt++) { const loggedIn = await verifyFn(page); if (loggedIn) return true; if (attempt < maxAttempts) { console.warn(` ⚠️ ${platform} not logged in (attempt ${attempt}), refreshing session...`); - await refreshSession(platform, apiKey); + await refreshSession(platform, apiKey, connectionIds); await page.reload({ waitUntil: 'domcontentloaded' }); await page.waitForTimeout(3000); }