fix: move Kernel connection IDs out of source into settings.json (gitignored)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user