ilml-plugin-linkedin 1.17.2 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,72 +1,70 @@
1
- var Pe=Object.defineProperty;var B=(e,t)=>{for(var o in t)Pe(e,o,{get:t[o],enumerable:!0})};import{pathToFileURL as uo}from"url";var Y={jan:0,feb:1,mar:2,apr:3,may:4,jun:5,jul:6,aug:7,sep:8,oct:9,nov:10,dec:11},Ue={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6};function M(e){let t=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!t)return null;let o=parseInt(t[1],10),n=parseInt(t[2],10),s=t[3].toUpperCase()==="PM";return s&&o!==12&&(o+=12),!s&&o===12&&(o=0),{hours:o,minutes:n}}function J(e,t){if(!e)return null;let o=e.trim();if(!o)return null;if(t=t||new Date,/^just\s*now$/i.test(o))return t.toISOString();if(/^today\b/i.test(o)||/^\d{1,2}:\d{2}\s*(AM|PM)$/i.test(o)){let l=M(o),c=new Date(t);return l?c.setHours(l.hours,l.minutes,0,0):c.setHours(0,0,0,0),c.toISOString()}let n=o.match(/^(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)\s*(.*)/i);if(n){let l=Ue[n[1].toLowerCase()],c=M(n[2]||""),a=new Date(t),u=a.getDay()-l;return u<=0&&(u+=7),a.setDate(a.getDate()-u),c?a.setHours(c.hours,c.minutes,0,0):a.setHours(0,0,0,0),a.toISOString()}let s=o.match(/^([A-Z][a-z]+)\s+(\d{1,2}),?\s+(\d{4})\s*(.*)/i);if(s){let l=Y[s[1].toLowerCase().slice(0,3)];if(l===void 0)return null;let c=parseInt(s[2],10),a=parseInt(s[3],10),f=M(s[4]||"");return new Date(a,l,c,f?.hours||0,f?.minutes||0,0,0).toISOString()}let r=o.match(/^([A-Z][a-z]+)\s+(\d{1,2}),\s*(.*)/i);if(r){let l=Y[r[1].toLowerCase().slice(0,3)];if(l===void 0)return null;let c=parseInt(r[2],10),a=M(r[3]||""),f=t.getFullYear(),u=new Date(f,l,c,a?.hours||0,a?.minutes||0,0,0);return u>t&&u.setFullYear(f-1),u.toISOString()}let i=o.match(/^([A-Z][a-z]+)\s+(\d{1,2})\s*(.*)/i);if(i){let l=Y[i[1].toLowerCase().slice(0,3)];if(l===void 0)return null;let c=parseInt(i[2],10),a=M(i[3]||""),f=t.getFullYear(),u=new Date(f,l,c,a?.hours||0,a?.minutes||0,0,0);return u>t&&u.setFullYear(f-1),u.toISOString()}return null}async function P(e){let t=Math.floor(Math.random()*2001),o=e+t;return new Promise(n=>setTimeout(n,o))}import{getPluginConfig as qe}from"@ilivemylife/graph-sdk";var Be=await qe();for(let[e,t]of Object.entries(Be))process.env[e]===void 0&&(process.env[e]=t);var Je=process.env.LINKEDIN_NAME,_=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),$o=Object.freeze(new Set([_.DRAFT,_.CONFIRMED,_.NEEDS_REVIEW])),He=Object.freeze(new Set([_.DRAFT,_.CONFIRMED,_.REJECTED,_.NEEDS_REVIEW]));import"dotenv/config";import*as y from"fs";import*as S from"path";import{fileURLToPath as We}from"url";var Ve=We(import.meta.url),Ye=S.dirname(S.dirname(Ve)),I=process.env.DATA_DIR?S.resolve(process.env.DATA_DIR,"collected-profiles"):S.join(Ye,"collected-profiles"),G=S.join(I,"people.json"),xo=S.join(I,"jobs.json"),Io=S.join(I,"quota.json"),Do=S.join(I,"conversations.json"),Ro=S.join(I,"sync-state.json"),Oo=S.join(I,"application-questions.json"),_o=S.join(I,"profile-history"),ce=(e,t)=>{let o=parseInt(e,10);return Number.isInteger(o)&&o>=0?o:t},jo=ce(process.env.CONNECT_MAX_DAILY,20),No=ce(process.env.CONNECT_MAX_WEEKLY,100),L=null,Ge=null,Ke=null,ze=null,Qe=null,Xe=null;function le(){L=null,Ge=null,Ke=null,ze=null,Qe=null,Xe=null}function ae(){y.existsSync(I)||y.mkdirSync(I,{recursive:!0})}function Ze(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";y.writeFileSync(n,o);for(let s=0;s<3;s++)try{y.renameSync(n,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw r}}function et(e,t){if(!y.existsSync(e))return null;try{let o=JSON.parse(y.readFileSync(e,"utf-8"));try{y.copyFileSync(e,e+".backup")}catch{}return o}catch(o){console.error(`[!] ${t} is corrupted: ${o.message}`),console.error(` File: ${S.resolve(e)}`);let n=e+".backup";if(y.existsSync(n))try{let s=JSON.parse(y.readFileSync(n,"utf-8"));console.error(` Restored from ${n}`);try{y.copyFileSync(n,e)}catch{}return s}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{y.copyFileSync(e,e+".corrupted")}catch{}return null}}function H(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function U(){return L||(ae(),L=et(G,"people.json")||{},L)}function ue(e){ae(),L=e;try{Ze(G,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${S.resolve(G)}`)}}import st from"puppeteer";import{addExtra as rt}from"puppeteer-extra";import it from"puppeteer-extra-plugin-stealth";import fe from"fs";import tt from"path";var ot="cookies.json";function nt(){let e=process.env.ILML_SCOPE_DIR;return e?tt.join(e,"plugins-state","linkedin","cookies.json"):ot}function pe(){let e=nt();if(!fe.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=fe.readFileSync(e,"utf-8")}catch(n){throw new Error(`Failed to read cookies at ${e}: ${n.message}. Run: ilml linkedin login`)}let o;try{o=JSON.parse(t)}catch{throw new Error(`Cookies file at ${e} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(o)||o.length===0)throw new Error(`Cookies file at ${e} is empty or not an array. Run: ilml linkedin login`);return o}var de=rt(st);de.use(it());async function me(){let e=await de.launch({headless:!1,defaultViewport:null,protocolTimeout:3e5}),t=async()=>{console.log(`
2
- Closing browser...`);try{await e.close()}catch{}process.exit(0)};process.on("SIGINT",t),process.on("SIGTERM",t);let o=await e.newPage();await o.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})});try{let n=pe();await o.setCookie(...n),console.log(" Browser launched, cookies loaded.")}catch(n){console.error(`
3
- [!] ${n.message}
4
- `),await e.close(),process.exit(1)}return{browser:e,page:o}}import"dotenv/config";import*as $ from"fs";import*as R from"path";import{fileURLToPath as pt}from"url";import"dotenv/config";import{createGraphClient as ct,resolveToken as lt}from"@ilivemylife/graph-sdk";import{config as at}from"dotenv";at();var he=lt()||process.env.TOKEN;he||(console.error(`
1
+ var ze=Object.defineProperty;var H=(e,t)=>{for(var o in t)ze(e,o,{get:t[o],enumerable:!0})};import{pathToFileURL as Ao}from"url";var K={jan:0,feb:1,mar:2,apr:3,may:4,jun:5,jul:6,aug:7,sep:8,oct:9,nov:10,dec:11},Qe={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6};function U(e){let t=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!t)return null;let o=parseInt(t[1],10),n=parseInt(t[2],10),s=t[3].toUpperCase()==="PM";return s&&o!==12&&(o+=12),!s&&o===12&&(o=0),{hours:o,minutes:n}}function W(e,t){if(!e)return null;let o=e.trim();if(!o)return null;if(t=t||new Date,/^just\s*now$/i.test(o))return t.toISOString();if(/^today\b/i.test(o)||/^\d{1,2}:\d{2}\s*(AM|PM)$/i.test(o)){let l=U(o),c=new Date(t);return l?c.setHours(l.hours,l.minutes,0,0):c.setHours(0,0,0,0),c.toISOString()}let n=o.match(/^(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)\s*(.*)/i);if(n){let l=Qe[n[1].toLowerCase()],c=U(n[2]||""),a=new Date(t),u=a.getDay()-l;return u<=0&&(u+=7),a.setDate(a.getDate()-u),c?a.setHours(c.hours,c.minutes,0,0):a.setHours(0,0,0,0),a.toISOString()}let s=o.match(/^([A-Z][a-z]+)\s+(\d{1,2}),?\s+(\d{4})\s*(.*)/i);if(s){let l=K[s[1].toLowerCase().slice(0,3)];if(l===void 0)return null;let c=parseInt(s[2],10),a=parseInt(s[3],10),f=U(s[4]||"");return new Date(a,l,c,f?.hours||0,f?.minutes||0,0,0).toISOString()}let r=o.match(/^([A-Z][a-z]+)\s+(\d{1,2}),\s*(.*)/i);if(r){let l=K[r[1].toLowerCase().slice(0,3)];if(l===void 0)return null;let c=parseInt(r[2],10),a=U(r[3]||""),f=t.getFullYear(),u=new Date(f,l,c,a?.hours||0,a?.minutes||0,0,0);return u>t&&u.setFullYear(f-1),u.toISOString()}let i=o.match(/^([A-Z][a-z]+)\s+(\d{1,2})\s*(.*)/i);if(i){let l=K[i[1].toLowerCase().slice(0,3)];if(l===void 0)return null;let c=parseInt(i[2],10),a=U(i[3]||""),f=t.getFullYear(),u=new Date(f,l,c,a?.hours||0,a?.minutes||0,0,0);return u>t&&u.setFullYear(f-1),u.toISOString()}return null}async function q(e){let t=Math.floor(Math.random()*2001),o=e+t;return new Promise(n=>setTimeout(n,o))}import{getPluginConfig as Xe}from"@ilivemylife/graph-sdk";var Ze=await Xe();for(let[e,t]of Object.entries(Ze))process.env[e]===void 0&&(process.env[e]=t);var et=process.env.LINKEDIN_NAME,N=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),No=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.NEEDS_REVIEW])),tt=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.REJECTED,N.NEEDS_REVIEW]));import"dotenv/config";import*as y from"fs";import*as S from"path";import{fileURLToPath as ot}from"url";var nt=ot(import.meta.url),st=S.dirname(S.dirname(nt)),T=process.env.DATA_DIR?S.resolve(process.env.DATA_DIR,"collected-profiles"):S.join(st,"collected-profiles"),z=S.join(T,"people.json"),Uo=S.join(T,"jobs.json"),qo=S.join(T,"quota.json"),Bo=S.join(T,"conversations.json"),Jo=S.join(T,"sync-state.json"),Ho=S.join(T,"application-questions.json"),Wo=S.join(T,"profile-history"),ae=(e,t)=>{let o=parseInt(e,10);return Number.isInteger(o)&&o>=0?o:t},Vo=ae(process.env.CONNECT_MAX_DAILY,20),Yo=ae(process.env.CONNECT_MAX_WEEKLY,100),P=null,rt=null,it=null,ct=null,lt=null,at=null;function ue(){P=null,rt=null,it=null,ct=null,lt=null,at=null}function fe(){y.existsSync(T)||y.mkdirSync(T,{recursive:!0})}function ut(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";y.writeFileSync(n,o);for(let s=0;s<3;s++)try{y.renameSync(n,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw r}}function ft(e,t){if(!y.existsSync(e))return null;try{let o=JSON.parse(y.readFileSync(e,"utf-8"));try{y.copyFileSync(e,e+".backup")}catch{}return o}catch(o){console.error(`[!] ${t} is corrupted: ${o.message}`),console.error(` File: ${S.resolve(e)}`);let n=e+".backup";if(y.existsSync(n))try{let s=JSON.parse(y.readFileSync(n,"utf-8"));console.error(` Restored from ${n}`);try{y.copyFileSync(n,e)}catch{}return s}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{y.copyFileSync(e,e+".corrupted")}catch{}return null}}function V(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function B(){return P||(fe(),P=ft(z,"people.json")||{},P)}function de(e){fe(),P=e;try{ut(z,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${S.resolve(z)}`)}}import gt from"puppeteer";import{addExtra as yt}from"puppeteer-extra";import St from"puppeteer-extra-plugin-stealth";import I from"fs";import _ from"path";var dt="cookies.json";function pe(){let e=process.env.ILML_SCOPE_DIR;return e?_.join(e,"plugins-state","linkedin","cookies.json"):dt}function me(){let e=pe();if(!I.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=I.readFileSync(e,"utf-8")}catch(n){throw new Error(`Failed to read cookies at ${e}: ${n.message}. Run: ilml linkedin login`)}let o;try{o=JSON.parse(t)}catch{throw new Error(`Cookies file at ${e} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(o)||o.length===0)throw new Error(`Cookies file at ${e} is empty or not an array. Run: ilml linkedin login`);return o}function he(){return I.existsSync(pe())}function pt(){let e=process.env.ILML_SCOPE_DIR;return e?_.join(e,"plugins-state","linkedin"):"."}function ge(e){let t=String(e||"").replace(/[^a-zA-Z0-9_.-]/g,"_").slice(0,80);return/[a-zA-Z0-9]/.test(t)?t:"default"}function mt(){let e=process.env.MY_LINKEDIN_URL,t=e&&e.match(/\/in\/([^/?#]+)/);return t&&t[1]?ge(t[1]):"default"}function ye(e){let t=process.env.LINKEDIN_CHROME_PROFILE_DIR;if(t)return I.existsSync(t)||I.mkdirSync(t,{recursive:!0}),_.resolve(t);let o=ge(e||mt()),n=_.join(pt(),"chrome-profile",o);return I.existsSync(n)||I.mkdirSync(n,{recursive:!0}),_.resolve(n)}var Se=".ilml-seeded";function we(e){return!I.existsSync(_.join(e,Se))}function be(e){try{I.writeFileSync(_.join(e,Se),new Date().toISOString())}catch{}}function ve(e){let t=0;for(let o of["SingletonLock","SingletonCookie","SingletonSocket"])try{I.rmSync(_.join(e,o),{force:!0}),t++}catch{}return t}var ht={headless:!1,defaultViewport:null,protocolTimeout:3e5};async function ke(e,t={}){let o=ye(),n={...ht,...t,userDataDir:o},s;try{s=await e.launch(n)}catch{ve(o);try{s=await e.launch(n)}catch(i){throw new Error(`Could not open the LinkedIn automation Chrome profile at ${o}. If a LinkedIn automation window is already open, close it and retry. (Chrome: ${i.message})`)}}return{browser:s,profileDir:o,needsSeed:we(o)}}async function Ae(e,t){if(!t||!t.needsSeed)return!1;if(!he())return console.warn(" \u26A0 No saved LinkedIn session found. If this command comes back empty or redirects to login, run: ilml linkedin login"),!1;try{return await e.setCookie(...me()),be(t.profileDir),console.log(" (seeded persistent profile from saved cookies \u2014 one-time)"),!0}catch{return!1}}var $e=yt(gt);$e.use(St());async function Ce(){let{browser:e,profileDir:t,needsSeed:o}=await ke($e),n=async()=>{console.log(`
2
+ Closing browser...`);try{await e.close()}catch{}process.exit(0)};process.on("SIGINT",n),process.on("SIGTERM",n);let s=await e.newPage();return await s.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})}),await Ae(s,{profileDir:t,needsSeed:o}),console.log(" Browser launched (persistent profile)."),{browser:e,page:s}}import"dotenv/config";import*as A from"fs";import*as O from"path";import{fileURLToPath as $t}from"url";import"dotenv/config";import{createGraphClient as wt,resolveToken as bt}from"@ilivemylife/graph-sdk";import{config as vt}from"dotenv";vt();var Ee=bt()||process.env.TOKEN;Ee||(console.error(`
5
3
  [FATAL] No iLiveMyLife token found.`),console.error(" The bot uses Lifebot AI to decide which jobs to apply for"),console.error(` and how to fill application forms. It cannot work without it.
6
4
  `),console.error(" Easiest way:"),console.error(" 1. npm install -g @ilivemylife/graph-sdk"),console.error(` 2. ilml login your@email.com yourpassword
7
5
  `),console.error(` Or add ILML_TOKEN=... to .env
8
- `),process.exit(1));var ge=ct({token:he});function ut(e){if(!e||e<1e3)return`${e||0}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let o=Math.floor(t/60),n=t%60;return n?`${o}m ${n}s`:`${o}m`}function ft({scriptName:e,mode:t,status:o,error:n,duration:s}){let r=o==="error"?"\u2717":o==="quota-reached"?"\u26A0":"\u2713",i=new Date().toISOString().slice(0,16).replace("T"," "),l=s?` ${ut(s)}`:"",c=o==="error"?`error${n?`: ${String(n).slice(0,80)}`:""}`:o==="quota-reached"?"daily quota reached":"done",a=t&&t!=="default"?` (${t})`:"";return`${r} ${e}${a} \u2014 ${c} \u2014 ${i}${l}`}async function ye({scriptName:e,mode:t,status:o,summaryLines:n,error:s,duration:r}){let i=process.env.NODE_RUN_REPORTS;if(!i||!Array.isArray(n)||n.length===0)return;let c=`**${ft({scriptName:e,mode:t,status:o,error:s,duration:r})}**
6
+ `),process.exit(1));var xe=wt({token:Ee});function kt(e){if(!e||e<1e3)return`${e||0}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let o=Math.floor(t/60),n=t%60;return n?`${o}m ${n}s`:`${o}m`}function At({scriptName:e,mode:t,status:o,error:n,duration:s}){let r=o==="error"?"\u2717":o==="quota-reached"?"\u26A0":"\u2713",i=new Date().toISOString().slice(0,16).replace("T"," "),l=s?` ${kt(s)}`:"",c=o==="error"?`error${n?`: ${String(n).slice(0,80)}`:""}`:o==="quota-reached"?"daily quota reached":"done",a=t&&t!=="default"?` (${t})`:"";return`${r} ${e}${a} \u2014 ${c} \u2014 ${i}${l}`}async function Ie({scriptName:e,mode:t,status:o,summaryLines:n,error:s,duration:r}){let i=process.env.NODE_RUN_REPORTS;if(!i||!Array.isArray(n)||n.length===0)return;let c=`**${At({scriptName:e,mode:t,status:o,error:s,duration:r})}**
9
7
 
10
8
  ${n.join(`
11
- `)}`;try{await ge.addMessage(i,c)}catch(a){console.error(`[runReport] Failed to post end-of-session message: ${a.message}`)}}var dt=pt(import.meta.url),mt=R.dirname(R.dirname(dt)),K=process.env.DATA_DIR?R.resolve(process.env.DATA_DIR,"collected-profiles"):R.join(mt,"collected-profiles"),z=R.join(K,"run-log.json");function ht(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";$.writeFileSync(n,o);for(let s=0;s<3;s++)try{$.renameSync(n,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw r}}function Se(){try{if(!$.existsSync(z))return{runs:[]};let e=JSON.parse($.readFileSync(z,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function we(e){$.existsSync(K)||$.mkdirSync(K,{recursive:!0});try{ht(z,e)}catch(t){console.error(`[!] Failed to save run-log.json: ${t.message}`)}}function be(e,t="default"){let o=Se();for(let i of o.runs)i.status==="running"&&(i.status="interrupted",i.result="interrupted",i.timestamp&&(i.duration=Date.now()-new Date(i.timestamp).getTime()));let n=new Date,s={timestamp:n.toISOString(),script:e,mode:t,status:"running",result:null,duration:null,stats:null,error:null};o.runs.push(s);let r=Date.now()-30*24*60*60*1e3;return o.runs=o.runs.filter(i=>new Date(i.timestamp).getTime()>r),we(o),{script:e,mode:t,startTime:n.getTime(),runIndex:o.runs.length-1}}function Q(e,t,o=null,n=null){if(!e)return;let s=null;try{let i=Se(),l=i.runs[e.runIndex];if(l&&l.status==="running"&&l.script===e.script)l.status=t,l.result=t,l.duration=Date.now()-e.startTime,l.stats=o,l.error=n,s=l.duration;else{let c=i.runs.find(a=>a.script===e.script&&a.status==="running"&&a.timestamp===new Date(e.startTime).toISOString());c&&(c.status=t,c.result=t,c.duration=Date.now()-e.startTime,c.stats=o,c.error=n,s=c.duration)}we(i)}catch(i){console.error(`[runLog] Failed to end run: ${i.message}`)}let r=o&&Array.isArray(o.summaryLines)?o.summaryLines:null;if(r&&r.length>0&&process.env.NODE_RUN_REPORTS){let i=t==="error"?"error":o&&o.dailyLimitHit?"quota-reached":"done";ye({scriptName:e.script,mode:e.mode,status:i,summaryLines:r,error:n,duration:s??Date.now()-e.startTime}).catch(l=>console.error(`[runLog] postRunReport failed: ${l.message}`))}}import"dotenv/config";import*as p from"fs";import*as re from"os";import*as h from"path";import{fileURLToPath as Yt}from"url";var ee={};B(ee,{NAME:()=>yt,VERSION:()=>gt,up:()=>bt});import*as A from"fs";import*as W from"path";var gt=1,yt="normalize-jobs-and-questions",St=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],wt=50;function X(e){return A.existsSync(e)?JSON.parse(A.readFileSync(e,"utf-8")):null}function Z(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";try{A.writeFileSync(n,o)}catch(s){try{A.unlinkSync(n)}catch{}throw s}try{A.renameSync(n,e)}catch(s){try{A.unlinkSync(n)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function bt(e,t){let o=W.join(e,"jobs.json"),n=W.join(t,"scouted-jobs.json"),s=W.join(e,"application-questions.json"),r=X(o)||{},i=X(n)||{},l=0,c=[];for(let f of Object.keys(r)){if(!i[f])continue;let u=i[f],m=r[f];for(let g of St)u[g]!=null&&m[g]==null&&(m[g]=u[g]);c.push(f),l++}l>0?(Z(o,r),console.log(` Phase 1: Merged ${l} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let a=X(s);if(a&&Array.isArray(a.applications)){let f={},u=0;for(let m of a.applications){let g=m.jobId||"unknown";f[g]||(f[g]={applications:[]});let v=(m.questions||[]).map(d=>{let w={type:d.type||"input",question:d.question||"",answer:d.answer||""};return d.options&&(d.options.length<=wt?w.options=d.options:(w.optionsOmitted=!0,u++)),d.page&&(w.page=d.page),d.wasPreFilled&&(w.wasPreFilled=!0),d.wasRetry&&(w.wasRetry=!0),w});f[g].applications.push({applicationId:m.applicationId,date:m.date,result:m.result||"submitted",formPages:m.formPages||null,duration:m.duration||null,retries:m.retries||0,failedField:m.failedField||null,questionCount:m.questionCount||v.length,questions:v})}Z(s,f),console.log(` Phase 2: Rekeyed ${a.applications.length} applications by jobId (${Object.keys(f).length} unique jobs)`),u>0&&console.log(` Phase 2: Stripped bloated options from ${u} questions`)}else a&&!a.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(c.length>0){for(let f of c)delete i[f];Z(n,i),console.log(` Phase 3: Removed ${c.length} merged entries from scouted-jobs.json (${Object.keys(i).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var te={};B(te,{NAME:()=>kt,VERSION:()=>vt,up:()=>Ct});import*as C from"fs";import*as ve from"path";var vt=2,kt="reset-unread-flags";function $t(e){return C.existsSync(e)?JSON.parse(C.readFileSync(e,"utf-8")):null}function At(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";try{C.writeFileSync(n,o)}catch(s){try{C.unlinkSync(n)}catch{}throw s}try{C.renameSync(n,e)}catch(s){try{C.unlinkSync(n)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Ct(e){let t=ve.join(e,"conversations.json"),o=$t(t);if(!o){console.log(" conversations.json not found \u2014 nothing to reset.");return}let n=0;for(let s of Object.keys(o))o[s].unread===!0&&(o[s].unread=!1,n++);if(n===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}At(t,o),console.log(` Reset unread=false on ${n} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var oe={};B(oe,{NAME:()=>Tt,VERSION:()=>Et,up:()=>Ot});import*as E from"fs";import*as ke from"path";var Et=3,Tt="recompute-last-message-by",xt=new Set(["draft","confirmed","rejected","needs_review"]);function It(e){return E.existsSync(e)?JSON.parse(E.readFileSync(e,"utf-8")):null}function Dt(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";try{E.writeFileSync(n,o)}catch(s){try{E.unlinkSync(n)}catch{}throw s}try{E.renameSync(n,e)}catch(s){try{E.unlinkSync(n)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}function Rt(e,t){if(!e||e.length===0)return"them";let o=e.filter(r=>!xt.has(r.status));if(o.length===0)return"them";let n=o.map(r=>({m:r,t:Date.parse(r.time)})).filter(r=>Number.isFinite(r.t)).sort((r,i)=>i.t-r.t).map(r=>r.m),s=n.length>0?n:[...o].reverse();for(let r of s){let i=r.sender;if(i===t)return"me";if(i!=="Unknown"&&i!=="")return"them"}return"them"}async function Ot(e){let t=ke.join(e,"conversations.json"),o=It(t);if(!o){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let n=process.env.LINKEDIN_NAME;if(!n||typeof n!="string"||!n.trim())throw new Error(`LINKEDIN_NAME env var is not set. Migration v003 needs your display name to determine which messages are yours vs theirs. Set LINKEDIN_NAME in your .env (or run "ilml plugin config linkedin set LINKEDIN_NAME 'Your Name'") and retry.`);let s=0,r=0,i=0;for(let l of Object.keys(o)){let c=o[l];if(!c||typeof c!="object")continue;Object.prototype.hasOwnProperty.call(c,"_cardSynced")&&(delete c._cardSynced,r++);let a=Array.isArray(c.messages)?c.messages:[],f=Rt(a,n),u=f==="me"?"awaiting_reply":"unanswered_by_us";c.lastMessageBy!==f&&i++,c.lastMessageBy=f,c.conversationStatus=u,s++}if(s===0){console.log(" No conversations to recompute.");return}Dt(t,o),console.log(` Recomputed lastMessageBy + conversationStatus on ${s} conversations.`),console.log(` ${i} had stale lastMessageBy (now corrected).`),r>0&&console.log(` Cleaned ${r} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var ne={};B(ne,{NAME:()=>jt,VERSION:()=>_t,up:()=>Mt});import*as T from"fs";import*as $e from"path";var _t=4,jt="split-connection-timestamps",Nt=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function Ft(e){if(!T.existsSync(e))return null;let t=T.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function Lt(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";try{T.writeFileSync(n,o)}catch(s){try{T.unlinkSync(n)}catch{}throw s}try{T.renameSync(n,e)}catch(s){try{T.unlinkSync(n)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Mt(e){let t=$e.join(e,"people.json"),o=Ft(t);if(!o||typeof o!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let n=0,s=0;for(let r of Object.keys(o)){let i=o[r];!i||typeof i!="object"||(s++,Nt.has(i.connectionStatus)&&i.connectionDate&&!i.requestedConnectionAt&&(i.requestedConnectionAt=i.connectionDate,i.connectionDate=null,n++))}if(n===0){console.log(` Scanned ${s} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}Lt(t,o),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${n} still-pending people (of ${s} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}import"dotenv/config";import*as k from"path";import{fileURLToPath as Pt}from"url";var Ut=Pt(import.meta.url),qt=k.dirname(k.dirname(Ut)),q=process.env.DATA_DIR?k.resolve(process.env.DATA_DIR,"market-research"):k.join(qt,"market-research"),ln=k.join(q,"scouted-jobs.json"),an=k.join(q,"discovered-people.json"),un=k.join(q,"visit-log.json"),fn=k.join(q,"companies.json"),pn=k.join(q,"job-decisions.json");function Ae(){Bt=null,Jt=null,Ht=null,Wt=null,Vt=null}var Bt=null;var Jt=null;var Ht=null;var Wt=null;var Vt=null;var Gt=Yt(import.meta.url),Kt=h.dirname(Gt),zt=h.dirname(h.dirname(Kt));function Qt(e){return e&&(e==="~"?re.homedir():e.startsWith("~/")||e.startsWith("~\\")?h.join(re.homedir(),e.slice(2)):e)}var x=process.env.DATA_DIR?h.resolve(Qt(process.env.DATA_DIR)):zt,N=h.join(x,"collected-profiles"),F=h.join(x,"market-research"),b=h.join(x,".schema-version"),Ce=[h.join(N,".schema-version"),h.join(F,".schema-version")],O=4,D=[{version:1,module:ee},{version:2,module:te},{version:3,module:oe},{version:4,module:ne}];(function(){D.sort((n,s)=>n.version-s.version);let t=new Set;for(let n of D){if(!Number.isInteger(n.version)||n.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(n.version)} (must be positive integer)`);if(t.has(n.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${n.version}`);t.add(n.version);let s=n.module;if(!s||typeof s.up!="function")throw new Error(`MIGRATION_REGISTRY: v${n.version} module is missing up()`);if(s.VERSION!==void 0&&s.VERSION!==n.version)throw new Error(`MIGRATION_REGISTRY: v${n.version} entry does not match module VERSION (${s.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let o=D.length?D[D.length-1].version:0;if(o!==O)throw new Error(`MIGRATION_REGISTRY: highest version v${o} but CURRENT_SCHEMA_VERSION=${O}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let n=0;n<D.length;n++){let s=n+1;if(D[n].version!==s)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${s} at position ${n} but found v${D[n].version}`)}})();function Ie(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
9
+ `)}`;try{await xe.addMessage(i,c)}catch(a){console.error(`[runReport] Failed to post end-of-session message: ${a.message}`)}}var Ct=$t(import.meta.url),Et=O.dirname(O.dirname(Ct)),Q=process.env.DATA_DIR?O.resolve(process.env.DATA_DIR,"collected-profiles"):O.join(Et,"collected-profiles"),X=O.join(Q,"run-log.json");function xt(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";A.writeFileSync(n,o);for(let s=0;s<3;s++)try{A.renameSync(n,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw r}}function De(){try{if(!A.existsSync(X))return{runs:[]};let e=JSON.parse(A.readFileSync(X,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function Te(e){A.existsSync(Q)||A.mkdirSync(Q,{recursive:!0});try{xt(X,e)}catch(t){console.error(`[!] Failed to save run-log.json: ${t.message}`)}}function Re(e,t="default"){let o=De();for(let i of o.runs)i.status==="running"&&(i.status="interrupted",i.result="interrupted",i.timestamp&&(i.duration=Date.now()-new Date(i.timestamp).getTime()));let n=new Date,s={timestamp:n.toISOString(),script:e,mode:t,status:"running",result:null,duration:null,stats:null,error:null};o.runs.push(s);let r=Date.now()-30*24*60*60*1e3;return o.runs=o.runs.filter(i=>new Date(i.timestamp).getTime()>r),Te(o),{script:e,mode:t,startTime:n.getTime(),runIndex:o.runs.length-1}}function Z(e,t,o=null,n=null){if(!e)return;let s=null;try{let i=De(),l=i.runs[e.runIndex];if(l&&l.status==="running"&&l.script===e.script)l.status=t,l.result=t,l.duration=Date.now()-e.startTime,l.stats=o,l.error=n,s=l.duration;else{let c=i.runs.find(a=>a.script===e.script&&a.status==="running"&&a.timestamp===new Date(e.startTime).toISOString());c&&(c.status=t,c.result=t,c.duration=Date.now()-e.startTime,c.stats=o,c.error=n,s=c.duration)}Te(i)}catch(i){console.error(`[runLog] Failed to end run: ${i.message}`)}let r=o&&Array.isArray(o.summaryLines)?o.summaryLines:null;if(r&&r.length>0&&process.env.NODE_RUN_REPORTS){let i=t==="error"?"error":o&&o.dailyLimitHit?"quota-reached":"done";Ie({scriptName:e.script,mode:e.mode,status:i,summaryLines:r,error:n,duration:s??Date.now()-e.startTime}).catch(l=>console.error(`[runLog] postRunReport failed: ${l.message}`))}}import"dotenv/config";import*as d from"fs";import*as ce from"os";import*as h from"path";import{fileURLToPath as ro}from"url";var oe={};H(oe,{NAME:()=>Dt,VERSION:()=>It,up:()=>_t});import*as $ from"fs";import*as Y from"path";var It=1,Dt="normalize-jobs-and-questions",Tt=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Rt=50;function ee(e){return $.existsSync(e)?JSON.parse($.readFileSync(e,"utf-8")):null}function te(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";try{$.writeFileSync(n,o)}catch(s){try{$.unlinkSync(n)}catch{}throw s}try{$.renameSync(n,e)}catch(s){try{$.unlinkSync(n)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function _t(e,t){let o=Y.join(e,"jobs.json"),n=Y.join(t,"scouted-jobs.json"),s=Y.join(e,"application-questions.json"),r=ee(o)||{},i=ee(n)||{},l=0,c=[];for(let f of Object.keys(r)){if(!i[f])continue;let u=i[f],m=r[f];for(let g of Tt)u[g]!=null&&m[g]==null&&(m[g]=u[g]);c.push(f),l++}l>0?(te(o,r),console.log(` Phase 1: Merged ${l} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let a=ee(s);if(a&&Array.isArray(a.applications)){let f={},u=0;for(let m of a.applications){let g=m.jobId||"unknown";f[g]||(f[g]={applications:[]});let v=(m.questions||[]).map(p=>{let w={type:p.type||"input",question:p.question||"",answer:p.answer||""};return p.options&&(p.options.length<=Rt?w.options=p.options:(w.optionsOmitted=!0,u++)),p.page&&(w.page=p.page),p.wasPreFilled&&(w.wasPreFilled=!0),p.wasRetry&&(w.wasRetry=!0),w});f[g].applications.push({applicationId:m.applicationId,date:m.date,result:m.result||"submitted",formPages:m.formPages||null,duration:m.duration||null,retries:m.retries||0,failedField:m.failedField||null,questionCount:m.questionCount||v.length,questions:v})}te(s,f),console.log(` Phase 2: Rekeyed ${a.applications.length} applications by jobId (${Object.keys(f).length} unique jobs)`),u>0&&console.log(` Phase 2: Stripped bloated options from ${u} questions`)}else a&&!a.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(c.length>0){for(let f of c)delete i[f];te(n,i),console.log(` Phase 3: Removed ${c.length} merged entries from scouted-jobs.json (${Object.keys(i).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var ne={};H(ne,{NAME:()=>jt,VERSION:()=>Ot,up:()=>Lt});import*as C from"fs";import*as _e from"path";var Ot=2,jt="reset-unread-flags";function Nt(e){return C.existsSync(e)?JSON.parse(C.readFileSync(e,"utf-8")):null}function Ft(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";try{C.writeFileSync(n,o)}catch(s){try{C.unlinkSync(n)}catch{}throw s}try{C.renameSync(n,e)}catch(s){try{C.unlinkSync(n)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Lt(e){let t=_e.join(e,"conversations.json"),o=Nt(t);if(!o){console.log(" conversations.json not found \u2014 nothing to reset.");return}let n=0;for(let s of Object.keys(o))o[s].unread===!0&&(o[s].unread=!1,n++);if(n===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}Ft(t,o),console.log(` Reset unread=false on ${n} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var se={};H(se,{NAME:()=>Pt,VERSION:()=>Mt,up:()=>Ht});import*as E from"fs";import*as Oe from"path";var Mt=3,Pt="recompute-last-message-by",Ut=new Set(["draft","confirmed","rejected","needs_review"]);function qt(e){return E.existsSync(e)?JSON.parse(E.readFileSync(e,"utf-8")):null}function Bt(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";try{E.writeFileSync(n,o)}catch(s){try{E.unlinkSync(n)}catch{}throw s}try{E.renameSync(n,e)}catch(s){try{E.unlinkSync(n)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}function Jt(e,t){if(!e||e.length===0)return"them";let o=e.filter(r=>!Ut.has(r.status));if(o.length===0)return"them";let n=o.map(r=>({m:r,t:Date.parse(r.time)})).filter(r=>Number.isFinite(r.t)).sort((r,i)=>i.t-r.t).map(r=>r.m),s=n.length>0?n:[...o].reverse();for(let r of s){let i=r.sender;if(i===t)return"me";if(i!=="Unknown"&&i!=="")return"them"}return"them"}async function Ht(e){let t=Oe.join(e,"conversations.json"),o=qt(t);if(!o){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let n=process.env.LINKEDIN_NAME;if(!n||typeof n!="string"||!n.trim())throw new Error(`LINKEDIN_NAME env var is not set. Migration v003 needs your display name to determine which messages are yours vs theirs. Set LINKEDIN_NAME in your .env (or run "ilml plugin config linkedin set LINKEDIN_NAME 'Your Name'") and retry.`);let s=0,r=0,i=0;for(let l of Object.keys(o)){let c=o[l];if(!c||typeof c!="object")continue;Object.prototype.hasOwnProperty.call(c,"_cardSynced")&&(delete c._cardSynced,r++);let a=Array.isArray(c.messages)?c.messages:[],f=Jt(a,n),u=f==="me"?"awaiting_reply":"unanswered_by_us";c.lastMessageBy!==f&&i++,c.lastMessageBy=f,c.conversationStatus=u,s++}if(s===0){console.log(" No conversations to recompute.");return}Bt(t,o),console.log(` Recomputed lastMessageBy + conversationStatus on ${s} conversations.`),console.log(` ${i} had stale lastMessageBy (now corrected).`),r>0&&console.log(` Cleaned ${r} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var re={};H(re,{NAME:()=>Vt,VERSION:()=>Wt,up:()=>zt});import*as x from"fs";import*as je from"path";var Wt=4,Vt="split-connection-timestamps",Yt=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function Gt(e){if(!x.existsSync(e))return null;let t=x.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function Kt(e,t){let o=JSON.stringify(t,null,2),n=e+".tmp";try{x.writeFileSync(n,o)}catch(s){try{x.unlinkSync(n)}catch{}throw s}try{x.renameSync(n,e)}catch(s){try{x.unlinkSync(n)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function zt(e){let t=je.join(e,"people.json"),o=Gt(t);if(!o||typeof o!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let n=0,s=0;for(let r of Object.keys(o)){let i=o[r];!i||typeof i!="object"||(s++,Yt.has(i.connectionStatus)&&i.connectionDate&&!i.requestedConnectionAt&&(i.requestedConnectionAt=i.connectionDate,i.connectionDate=null,n++))}if(n===0){console.log(` Scanned ${s} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}Kt(t,o),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${n} still-pending people (of ${s} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}import"dotenv/config";import*as k from"path";import{fileURLToPath as Qt}from"url";var Xt=Qt(import.meta.url),Zt=k.dirname(k.dirname(Xt)),J=process.env.DATA_DIR?k.resolve(process.env.DATA_DIR,"market-research"):k.join(Zt,"market-research"),$n=k.join(J,"scouted-jobs.json"),Cn=k.join(J,"discovered-people.json"),En=k.join(J,"visit-log.json"),xn=k.join(J,"companies.json"),In=k.join(J,"job-decisions.json");function Ne(){eo=null,to=null,oo=null,no=null,so=null}var eo=null;var to=null;var oo=null;var no=null;var so=null;var io=ro(import.meta.url),co=h.dirname(io),lo=h.dirname(h.dirname(co));function ao(e){return e&&(e==="~"?ce.homedir():e.startsWith("~/")||e.startsWith("~\\")?h.join(ce.homedir(),e.slice(2)):e)}var D=process.env.DATA_DIR?h.resolve(ao(process.env.DATA_DIR)):lo,L=h.join(D,"collected-profiles"),M=h.join(D,"market-research"),b=h.join(D,".schema-version"),Fe=[h.join(L,".schema-version"),h.join(M,".schema-version")],j=4,R=[{version:1,module:oe},{version:2,module:ne},{version:3,module:se},{version:4,module:re}];(function(){R.sort((n,s)=>n.version-s.version);let t=new Set;for(let n of R){if(!Number.isInteger(n.version)||n.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(n.version)} (must be positive integer)`);if(t.has(n.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${n.version}`);t.add(n.version);let s=n.module;if(!s||typeof s.up!="function")throw new Error(`MIGRATION_REGISTRY: v${n.version} module is missing up()`);if(s.VERSION!==void 0&&s.VERSION!==n.version)throw new Error(`MIGRATION_REGISTRY: v${n.version} entry does not match module VERSION (${s.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let o=R.length?R[R.length-1].version:0;if(o!==j)throw new Error(`MIGRATION_REGISTRY: highest version v${o} but CURRENT_SCHEMA_VERSION=${j}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let n=0;n<R.length;n++){let s=n+1;if(R[n].version!==s)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${s} at position ${n} but found v${R[n].version}`)}})();function Ue(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
12
10
  [FATAL] DATA_DIR is set to whitespace ("${process.env.DATA_DIR}"). Either unset it or set a real path.
13
- `),process.exit(1));try{p.mkdirSync(x,{recursive:!0})}catch(t){t.code!=="EEXIST"&&(console.error(`
14
- [FATAL] Cannot create DATA_DIR (${x}): ${t.message}`),console.error(` Fix the path or permissions and try again.
15
- `),process.exit(1))}let e;try{e=p.statSync(x)}catch(t){console.error(`
16
- [FATAL] DATA_DIR (${x}) is not accessible: ${t.message}
11
+ `),process.exit(1));try{d.mkdirSync(D,{recursive:!0})}catch(t){t.code!=="EEXIST"&&(console.error(`
12
+ [FATAL] Cannot create DATA_DIR (${D}): ${t.message}`),console.error(` Fix the path or permissions and try again.
13
+ `),process.exit(1))}let e;try{e=d.statSync(D)}catch(t){console.error(`
14
+ [FATAL] DATA_DIR (${D}) is not accessible: ${t.message}
17
15
  `),process.exit(1)}e.isDirectory()||(console.error(`
18
- [FATAL] DATA_DIR (${x}) exists but is NOT a directory.`),console.error(` Looks like a typo \u2014 your DATA_DIR points at a file. Fix the path and try again.
19
- `),process.exit(1));for(let t of[N,F]){let o;try{o=p.lstatSync(t)}catch(n){if(n.code==="ENOENT")continue;throw n}o.isSymbolicLink()&&(console.error(`
16
+ [FATAL] DATA_DIR (${D}) exists but is NOT a directory.`),console.error(` Looks like a typo \u2014 your DATA_DIR points at a file. Fix the path and try again.
17
+ `),process.exit(1));for(let t of[L,M]){let o;try{o=d.lstatSync(t)}catch(n){if(n.code==="ENOENT")continue;throw n}o.isSymbolicLink()&&(console.error(`
20
18
  [FATAL] Data subdirectory is a symbolic link: ${t}`),console.error(" Refusing to follow \u2014 backup code would copy whatever the link points at."),console.error(` If this is intentional, replace the symlink with the real directory.
21
- `),process.exit(1))}}var j=h.join(x,".migration-lock");function Xt(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return p.writeFileSync(j,e,{flag:"wx"}),!0}catch(n){if(n.code!=="EEXIST")throw n}let t;try{t=JSON.parse(p.readFileSync(j,"utf-8"))}catch{t=null}if(t&&Number.isInteger(t.pid)){let n=!1;try{process.kill(t.pid,0),n=!0}catch(i){i.code==="EPERM"&&(n=!0)}let s=24*60*60*1e3,r=1/0;if(t.startedAt){let i=Date.parse(t.startedAt);Number.isNaN(i)||(r=Date.now()-i)}n&&r<s&&(console.error(`
22
- [FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${t.pid}`),console.error(` Started at: ${t.startedAt||"(unknown)"}`),console.error(` Lock file: ${j}
19
+ `),process.exit(1))}}var F=h.join(D,".migration-lock");function uo(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return d.writeFileSync(F,e,{flag:"wx"}),!0}catch(n){if(n.code!=="EEXIST")throw n}let t;try{t=JSON.parse(d.readFileSync(F,"utf-8"))}catch{t=null}if(t&&Number.isInteger(t.pid)){let n=!1;try{process.kill(t.pid,0),n=!0}catch(i){i.code==="EPERM"&&(n=!0)}let s=24*60*60*1e3,r=1/0;if(t.startedAt){let i=Date.parse(t.startedAt);Number.isNaN(i)||(r=Date.now()-i)}n&&r<s&&(console.error(`
20
+ [FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${t.pid}`),console.error(` Started at: ${t.startedAt||"(unknown)"}`),console.error(` Lock file: ${F}
23
21
  `),console.error(" Wait for it to finish, or if you're sure it's not actually running,"),console.error(` delete the lock file manually and re-run.
24
- `),process.exit(1)),n&&r>=s&&console.log(` Lock holder PID ${t.pid} is alive but lock is older than 24h \u2014 assuming PID reuse, taking over.`)}console.log(` Stale migration lock from PID ${t?.pid??"?"} found \u2014 taking over.`);let o=j+".tmp";try{return p.writeFileSync(o,e),p.renameSync(o,j),!0}catch(n){try{p.unlinkSync(o)}catch{}throw new Error(`Failed to take over stale migration lock: ${n.message}`)}}function ie(){try{if(JSON.parse(p.readFileSync(j,"utf-8")).pid!==process.pid)return;p.unlinkSync(j)}catch{}}var Ee=!1;function Zt(){if(Ee)return;Ee=!0;let e=()=>{try{ie()}catch{}process.exit(1)};for(let t of["SIGINT","SIGTERM","SIGHUP"])try{process.on(t,e)}catch{}}function eo(){if(p.existsSync(b))return;let e=[],t=[];for(let r of Ce)if(p.existsSync(r))try{e.push({file:r,schema:V(r)})}catch(i){t.push({file:r,err:i.message})}if(t.length>0){console.error(`
22
+ `),process.exit(1)),n&&r>=s&&console.log(` Lock holder PID ${t.pid} is alive but lock is older than 24h \u2014 assuming PID reuse, taking over.`)}console.log(` Stale migration lock from PID ${t?.pid??"?"} found \u2014 taking over.`);let o=F+".tmp";try{return d.writeFileSync(o,e),d.renameSync(o,F),!0}catch(n){try{d.unlinkSync(o)}catch{}throw new Error(`Failed to take over stale migration lock: ${n.message}`)}}function le(){try{if(JSON.parse(d.readFileSync(F,"utf-8")).pid!==process.pid)return;d.unlinkSync(F)}catch{}}var Le=!1;function fo(){if(Le)return;Le=!0;let e=()=>{try{le()}catch{}process.exit(1)};for(let t of["SIGINT","SIGTERM","SIGHUP"])try{process.on(t,e)}catch{}}function po(){if(d.existsSync(b))return;let e=[],t=[];for(let r of Fe)if(d.existsSync(r))try{e.push({file:r,schema:G(r)})}catch(i){t.push({file:r,err:i.message})}if(t.length>0){console.error(`
25
23
  [FATAL] Legacy .schema-version file(s) corrupted \u2014 cannot determine current schema version:`);for(let r of t)console.error(` ${r.file}: ${r.err}`);console.error(`
26
24
  Repair the file(s) (likely just an integer 'version' field \u2014 see another working DATA_DIR`),console.error(` or default to {"version":1,"migrations":[]} if you're sure you're on schema v1) and try again.
27
25
  `),process.exit(1)}if(e.length===0)return;let o=e.map(r=>r.schema.version);if(new Set(o).size>1){console.error(`
28
26
  [FATAL] Legacy .schema-version files disagree:`);for(let r of e)console.error(` ${r.file}: v${r.schema.version}`);console.error(" This means a previous migration crashed between writing the two files."),console.error(` Reconcile manually (delete the wrong one, keep the right one), then re-run.
29
- `),process.exit(1)}let n=e[0].schema,s=b+".tmp";try{p.writeFileSync(s,JSON.stringify(n,null,2)),p.renameSync(s,b)}catch(r){try{p.unlinkSync(s)}catch{}throw r}for(let r of Ce)if(p.existsSync(r))try{p.unlinkSync(r)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${b}`)}function to(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=Number(e.version);return!Number.isFinite(t)||t<0||!Number.isInteger(t)?null:(e.version=t,Array.isArray(e.migrations)||(e.migrations=[]),e)}function V(e){let t=p.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function Te(){if(eo(),!p.existsSync(b))return{version:0,migrations:[]};let e;try{e=V(b)}catch(o){if(o.code==="ENOENT")return{version:0,migrations:[]};console.error(`
27
+ `),process.exit(1)}let n=e[0].schema,s=b+".tmp";try{d.writeFileSync(s,JSON.stringify(n,null,2)),d.renameSync(s,b)}catch(r){try{d.unlinkSync(s)}catch{}throw r}for(let r of Fe)if(d.existsSync(r))try{d.unlinkSync(r)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${b}`)}function mo(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=Number(e.version);return!Number.isFinite(t)||t<0||!Number.isInteger(t)?null:(e.version=t,Array.isArray(e.migrations)||(e.migrations=[]),e)}function G(e){let t=d.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function Me(){if(po(),!d.existsSync(b))return{version:0,migrations:[]};let e;try{e=G(b)}catch(o){if(o.code==="ENOENT")return{version:0,migrations:[]};console.error(`
30
28
  [FATAL] ${b} is not valid JSON: ${o.message}`),console.error(" Refusing to proceed \u2014 silently treating it as 'fresh install' would re-apply"),console.error(" every migration on top of already-migrated data and corrupt it."),console.error(' Repair the file (set it to {"version":N,"migrations":[...]} matching your real state)'),console.error(` or restore from the *.pre-vNNN.backup files if you have them.
31
- `),process.exit(1)}let t=to(e);return t===null&&(console.error(`
29
+ `),process.exit(1)}let t=mo(e);return t===null&&(console.error(`
32
30
  [FATAL] ${b} has invalid structure:`),console.error(` ${JSON.stringify(e)?.slice(0,200)||"(unparseable)"}`),console.error(' Expected shape: { "version": <integer>, "migrations": [...] }'),console.error(` Repair the file or restore from a backup.
33
- `),process.exit(1)),t}function De(e){try{p.chmodSync(e,384)}catch{}}function oo(e){if(Ie(),p.existsSync(b))try{if(p.lstatSync(b).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${b}. Refusing to write through it (potential symlink attack). Remove the link and re-run.`)}catch(o){if(o.message?.includes("symbolic link"))throw o}let t=b+".tmp";try{p.writeFileSync(t,JSON.stringify(e,null,2)),De(t),p.renameSync(t,b)}catch(o){try{p.unlinkSync(t)}catch{}throw o}}function xe(e,t){if(!p.existsSync(e))return;let o=`.pre-v${String(t).padStart(3,"0")}.backup`,n=p.readdirSync(e).filter(l=>{let c=l.toLowerCase();if(c.includes(".backup")||c===".schema-version"||c.endsWith(".tmp"))return!1;try{return p.statSync(h.join(e,l)).isFile()}catch{return!1}}),s=0,r=0,i=[];for(let l of n){let c=h.join(e,l),a=h.join(e,l+o);if(p.existsSync(a)){r++;continue}try{Oe(c,a),s++}catch(f){i.push({file:l,err:f.message})}}if(i.length>0){let l=new Error(`Failed to back up ${i.length} file(s) in ${h.basename(e)}/: `+i.map(c=>`${c.file} (${c.err})`).join(", "));throw l.code="BACKUP_INCOMPLETE",l}if(s>0||r>0){let l=r>0?` (${r} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${s} files in ${h.basename(e)}/ (${o})${l}`)}}var se=!1;async function Re(){if(se)return;Ie(),co();let t=Te().version;if(t===O){se=!0;return}Zt(),Xt(),process.on("exit",ie),t>O&&(console.error(`
34
- [FATAL] Your data schema is at v${t}, but this plugin build only understands up to v${O}.`),console.error(" This usually means you downgraded the plugin without rolling back data."),console.error(` Operating on the newer-format data with this build would risk corrupting it.
35
- `),console.error(" Options:"),console.error(" A) Re-install the newer plugin version that produced this schema, then"),console.error(" (if you really want to downgrade) run 'rollback-data --confirm' first,"),console.error(" then re-install the older plugin version."),console.error(` B) Manually restore your data from the *.pre-vNNN.backup files matching v${O}.
31
+ `),process.exit(1)),t}function qe(e){try{d.chmodSync(e,384)}catch{}}function ho(e){if(Ue(),d.existsSync(b))try{if(d.lstatSync(b).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${b}. Refusing to write through it (potential symlink attack). Remove the link and re-run.`)}catch(o){if(o.message?.includes("symbolic link"))throw o}let t=b+".tmp";try{d.writeFileSync(t,JSON.stringify(e,null,2)),qe(t),d.renameSync(t,b)}catch(o){try{d.unlinkSync(t)}catch{}throw o}}function Pe(e,t){if(!d.existsSync(e))return;let o=`.pre-v${String(t).padStart(3,"0")}.backup`,n=d.readdirSync(e).filter(l=>{let c=l.toLowerCase();if(c.includes(".backup")||c===".schema-version"||c.endsWith(".tmp"))return!1;try{return d.statSync(h.join(e,l)).isFile()}catch{return!1}}),s=0,r=0,i=[];for(let l of n){let c=h.join(e,l),a=h.join(e,l+o);if(d.existsSync(a)){r++;continue}try{Je(c,a),s++}catch(f){i.push({file:l,err:f.message})}}if(i.length>0){let l=new Error(`Failed to back up ${i.length} file(s) in ${h.basename(e)}/: `+i.map(c=>`${c.file} (${c.err})`).join(", "));throw l.code="BACKUP_INCOMPLETE",l}if(s>0||r>0){let l=r>0?` (${r} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${s} files in ${h.basename(e)}/ (${o})${l}`)}}var ie=!1;async function Be(){if(ie)return;Ue(),bo();let t=Me().version;if(t===j){ie=!0;return}fo(),uo(),process.on("exit",le),t>j&&(console.error(`
32
+ [FATAL] Your data schema is at v${t}, but this plugin build only understands up to v${j}.`),console.error(" This usually means you downgraded the plugin without rolling back data."),console.error(` Operating on the newer-format data with this build would risk corrupting it.
33
+ `),console.error(" Options:"),console.error(" A) Re-install the newer plugin version that produced this schema, then"),console.error(" (if you really want to downgrade) run 'rollback-data --confirm' first,"),console.error(" then re-install the older plugin version."),console.error(` B) Manually restore your data from the *.pre-vNNN.backup files matching v${j}.
36
34
  `),process.exit(1)),console.log(`
37
- \u{1F4E6} Schema migration: v${t} \u2192 v${O}`);let o=lo();if(!o.ok){console.error(`
35
+ \u{1F4E6} Schema migration: v${t} \u2192 v${j}`);let o=vo();if(!o.ok){console.error(`
38
36
  [FATAL] Cannot migrate \u2014 current data is corrupted:`);for(let s of o.broken)console.error(` ${s.dir}/${s.file}: ${s.err}`);console.error(`
39
37
  Migration ABORTED. No backups taken, no files modified.`),console.error(" Repair the file(s) above (restore from your own backup, or fix manually)"),console.error(` and try again. To inspect: 'ilml linkedin migrate-status'.
40
- `),process.exit(1)}let n=D.filter(s=>s.version>t);for(let s of n){console.log(`
41
- Running migration v${String(s.version).padStart(3,"0")}...`);let r=`v${String(s.version).padStart(3,"0")}`,i=`.pre-${r}.backup`;try{xe(N,s.version),xe(F,s.version)}catch(c){console.error(`
38
+ `),process.exit(1)}let n=R.filter(s=>s.version>t);for(let s of n){console.log(`
39
+ Running migration v${String(s.version).padStart(3,"0")}...`);let r=`v${String(s.version).padStart(3,"0")}`,i=`.pre-${r}.backup`;try{Pe(L,s.version),Pe(M,s.version)}catch(c){console.error(`
42
40
  [FATAL] Pre-migration backup failed for ${r}: ${c.message}`),console.error(" Migration NOT applied. Repair the underlying issue (disk space, permissions, locked files)"),console.error(` and re-run the plugin command.
43
- `),process.exit(1)}let l=s.module;try{await l.up(N,F)}catch(c){console.error(`
44
- [FATAL] Migration ${r} failed: ${c.message}`),console.error(` Attempting auto-rollback from ${i} files...`);try{let a=ao(i);a.ok?(console.error(` \u2713 Auto-rollback restored ${a.restored} files. Schema stays at v${t}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
41
+ `),process.exit(1)}let l=s.module;try{await l.up(L,M)}catch(c){console.error(`
42
+ [FATAL] Migration ${r} failed: ${c.message}`),console.error(` Attempting auto-rollback from ${i} files...`);try{let a=ko(i);a.ok?(console.error(` \u2713 Auto-rollback restored ${a.restored} files. Schema stays at v${t}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
45
43
  `)):(console.error(` [!] Auto-rollback INCOMPLETE: ${a.error}`),console.error(` Manual recovery: copy *${i} files back over the originals.
46
44
  `))}catch(a){console.error(` [!] Auto-rollback CRASHED while restoring: ${a.message}`),console.error(` Manual recovery: copy *${i} files back over the originals.
47
- `)}process.exit(1)}try{let c=new Date().toISOString(),a={version:s.version,name:l.NAME||r,appliedAt:c},f=Te();f.version=s.version,f.migratedAt=c,f.migrations=f.migrations||[],f.migrations.push(a),oo(f)}catch(c){console.error(`
45
+ `)}process.exit(1)}try{let c=new Date().toISOString(),a={version:s.version,name:l.NAME||r,appliedAt:c},f=Me();f.version=s.version,f.migratedAt=c,f.migrations=f.migrations||[],f.migrations.push(a),ho(f)}catch(c){console.error(`
48
46
  [FATAL] Migration ${r} applied successfully but schema version file could NOT be updated: ${c.message}`),console.error(` Your data is in the v${s.version} state but .schema-version still shows v${t}.`),console.error(` On next plugin command the runner will try to re-apply ${r}. If that migration is`),console.error(` idempotent (most are), it will succeed harmlessly. If you're unsure, run 'data-cleanup' and contact support.
49
- `),process.exit(1)}console.log(` \u2713 Migration ${r} complete`)}try{le()}catch{}try{Ae()}catch{}se=!0,ie(),console.log(`
50
- \u2713 Schema is now at v${O}
51
- `)}var no=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function so(e){let t=e.toLowerCase();return no.some(o=>o.test(t))}var ro=6e4;function io(){let e=Date.now(),t=[];for(let o of[x,N,F]){if(!p.existsSync(o))continue;let n;try{n=p.readdirSync(o)}catch{continue}for(let s of n){if(!so(s))continue;let r=h.join(o,s);try{let i=p.statSync(r);if(!i.isFile()||e-i.mtimeMs<ro)continue;t.push({dir:o,file:s,fullPath:r})}catch{}}}return t}function co({verbose:e=!1}={}){let t=io();if(t.length===0)return e&&console.log(" No orphan .tmp files found."),0;let o=0;for(let n of t)try{p.unlinkSync(n.fullPath),o++,e&&console.log(` Removed orphan: ${h.basename(n.dir)}/${n.file}`)}catch(s){console.warn(` [!] Could not remove orphan ${n.fullPath}: ${s.message}`)}return!e&&o>0&&console.log(` Cleaned up ${o} orphan .tmp file(s) from previous run.`),o}function lo(){let e=[];for(let t of[N,F]){if(!p.existsSync(t))continue;let o=p.readdirSync(t).filter(n=>{let s=n.toLowerCase();return s.endsWith(".json")&&!s.includes(".backup")});for(let n of o){let s=h.join(t,n);try{V(s)}catch(r){e.push({dir:h.basename(t),file:n,err:r.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function ao(e){let t=[],o=[];for(let r of[N,F]){if(!p.existsSync(r))continue;let i=p.readdirSync(r).filter(l=>l.endsWith(e));for(let l of i){let c=h.join(r,l),a=l.slice(0,-e.length),f=h.join(r,a);try{a.toLowerCase().endsWith(".json")?V(c):p.accessSync(c,p.constants.R_OK),t.push({backupPath:c,originalPath:f,fileName:l,dir:r})}catch(u){o.push(`${h.basename(r)}/${l}: ${u.message}`)}}}if(o.length>0)return{ok:!1,error:o.join("; "),restored:0};let n=0,s=[];for(let{backupPath:r,originalPath:i,fileName:l,dir:c}of t)try{Oe(r,i),n++}catch(a){s.push(`${h.basename(c)}/${l}: ${a.message}`)}return s.length>0?{ok:!1,error:s.join("; "),restored:n}:{ok:!0,restored:n}}function Oe(e,t){let o=t+".tmp";try{p.copyFileSync(e,o),De(o)}catch(n){try{p.unlinkSync(o)}catch{}throw n}try{p.renameSync(o,t)}catch(n){try{p.unlinkSync(o)}catch{}if(n.code==="EPERM"||n.code==="EBUSY"){let s=new Error(`File locked: ${t} (${n.code}). On Windows this is usually antivirus / Search Indexer / the file open in another app. Close anything that might be holding it and re-run.`);throw s.code=n.code,s}throw n}}function fo(){let e={list:!1,full:!1,max:1/0,dryRun:!1,verbose:!1};for(let t of process.argv.slice(2))t==="--list"?e.list=!0:t==="--full"?e.full=!0:t==="--dry-run"?e.dryRun=!0:t==="--verbose"?e.verbose=!0:t.startsWith("--max=")&&(e.max=parseInt(t.split("=")[1],10));return e}function po(){let e=U(),t=Object.values(e),o=t.length,n={};for(let r of t){let i=r.connectionStatus||"(none)";n[i]=(n[i]||0)+1}let s={};for(let r of t){for(let i of r.sources||[])s[i]=(s[i]||0)+1;(!r.sources||r.sources.length===0)&&(s["(no source)"]=(s["(no source)"]||0)+1)}console.log(`
47
+ `),process.exit(1)}console.log(` \u2713 Migration ${r} complete`)}try{ue()}catch{}try{Ne()}catch{}ie=!0,le(),console.log(`
48
+ \u2713 Schema is now at v${j}
49
+ `)}var go=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function yo(e){let t=e.toLowerCase();return go.some(o=>o.test(t))}var So=6e4;function wo(){let e=Date.now(),t=[];for(let o of[D,L,M]){if(!d.existsSync(o))continue;let n;try{n=d.readdirSync(o)}catch{continue}for(let s of n){if(!yo(s))continue;let r=h.join(o,s);try{let i=d.statSync(r);if(!i.isFile()||e-i.mtimeMs<So)continue;t.push({dir:o,file:s,fullPath:r})}catch{}}}return t}function bo({verbose:e=!1}={}){let t=wo();if(t.length===0)return e&&console.log(" No orphan .tmp files found."),0;let o=0;for(let n of t)try{d.unlinkSync(n.fullPath),o++,e&&console.log(` Removed orphan: ${h.basename(n.dir)}/${n.file}`)}catch(s){console.warn(` [!] Could not remove orphan ${n.fullPath}: ${s.message}`)}return!e&&o>0&&console.log(` Cleaned up ${o} orphan .tmp file(s) from previous run.`),o}function vo(){let e=[];for(let t of[L,M]){if(!d.existsSync(t))continue;let o=d.readdirSync(t).filter(n=>{let s=n.toLowerCase();return s.endsWith(".json")&&!s.includes(".backup")});for(let n of o){let s=h.join(t,n);try{G(s)}catch(r){e.push({dir:h.basename(t),file:n,err:r.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function ko(e){let t=[],o=[];for(let r of[L,M]){if(!d.existsSync(r))continue;let i=d.readdirSync(r).filter(l=>l.endsWith(e));for(let l of i){let c=h.join(r,l),a=l.slice(0,-e.length),f=h.join(r,a);try{a.toLowerCase().endsWith(".json")?G(c):d.accessSync(c,d.constants.R_OK),t.push({backupPath:c,originalPath:f,fileName:l,dir:r})}catch(u){o.push(`${h.basename(r)}/${l}: ${u.message}`)}}}if(o.length>0)return{ok:!1,error:o.join("; "),restored:0};let n=0,s=[];for(let{backupPath:r,originalPath:i,fileName:l,dir:c}of t)try{Je(r,i),n++}catch(a){s.push(`${h.basename(c)}/${l}: ${a.message}`)}return s.length>0?{ok:!1,error:s.join("; "),restored:n}:{ok:!0,restored:n}}function Je(e,t){let o=t+".tmp";try{d.copyFileSync(e,o),qe(o)}catch(n){try{d.unlinkSync(o)}catch{}throw n}try{d.renameSync(o,t)}catch(n){try{d.unlinkSync(o)}catch{}if(n.code==="EPERM"||n.code==="EBUSY"){let s=new Error(`File locked: ${t} (${n.code}). On Windows this is usually antivirus / Search Indexer / the file open in another app. Close anything that might be holding it and re-run.`);throw s.code=n.code,s}throw n}}function $o(){let e={list:!1,full:!1,max:1/0,dryRun:!1,verbose:!1};for(let t of process.argv.slice(2))t==="--list"?e.list=!0:t==="--full"?e.full=!0:t==="--dry-run"?e.dryRun=!0:t==="--verbose"?e.verbose=!0:t.startsWith("--max=")&&(e.max=parseInt(t.split("=")[1],10));return e}function Co(){let e=B(),t=Object.values(e),o=t.length,n={};for(let r of t){let i=r.connectionStatus||"(none)";n[i]=(n[i]||0)+1}let s={};for(let r of t){for(let i of r.sources||[])s[i]=(s[i]||0)+1;(!r.sources||r.sources.length===0)&&(s["(no source)"]=(s["(no source)"]||0)+1)}console.log(`
52
50
  === People Database: ${o} entries ===
53
51
  `),console.log("By connection status:");for(let[r,i]of Object.entries(n).sort((l,c)=>c[1]-l[1]))console.log(` ${r.padEnd(30)} ${i}`);console.log(`
54
- By source:`);for(let[r,i]of Object.entries(s).sort((l,c)=>c[1]-l[1]))console.log(` ${r.padEnd(30)} ${i}`);console.log()}async function mo(e){let t="https://www.linkedin.com/mynetwork/invite-connect/connections/";console.log(`Navigating to ${t}`),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await P(3e3);let o=e.url();if(o.includes("/login")||o.includes("/authwall"))throw new Error("Redirected to login \u2014 cookies expired. Run: npm run login");try{await e.waitForSelector('main a[href*="/in/"]',{timeout:15e3})}catch{console.warn("\u26A0 No connection cards found after 15s. Page may have changed layout.")}let n=await e.evaluate(()=>{let i=((document.querySelector("main")||document.body).innerText||"").match(/([\d,]+)\s+connections?/i);return i?parseInt(i[1].replace(/,/g,""),10):null});return n&&console.log(` LinkedIn reports: ${n.toLocaleString()} connections`),n}async function je(e){return e.evaluate(()=>{let o=(document.querySelector("main")||document.body).querySelectorAll('a[href*="/in/"]'),n={};for(let i of o){let l=i.getAttribute("href");if(!l)continue;let c;try{let a=new URL(l,location.origin);c=a.origin+a.pathname.replace(/\/+$/,"")}catch{continue}n[c]||(n[c]=[]),n[c].push(i)}let s=[],r=i=>((i&&(i.innerText||i.textContent)||"").trim().split(`
55
- `)[0]||"").trim();for(let[i,l]of Object.entries(n)){let c=null;for(let d of l){let w=r(d);!w||d.querySelector("img")||(!c||w.length<r(c).length)&&(c=d)}let a=r(c)||null,f=c||l[0];for(let d=0;d<10&&f?.parentElement;d++){f=f.parentElement;let w=f.innerText||"";if((w.includes("Connected on")||w.includes("Message"))&&(w.match(/Connected on/g)||[]).length<=1)break}let u=(f?.innerText||"").split(`
56
- `).map(d=>d.trim()).filter(Boolean),m=null,g=null,v=u.indexOf(a);if(v>=0&&v+1<u.length){let d=u[v+1];!d.startsWith("Connected on")&&d!=="Message"&&(m=d)}for(let d of u)if(d.startsWith("Connected on")){g=d;break}s.push({profileUrl:i,name:a,title:m,time:g})}return s})}async function Ne(e){return e.evaluate(()=>{let t=document.querySelector("main")||document.body,o=null,n=[t,...t.querySelectorAll("div, section")];for(let r of n){let i=getComputedStyle(r);if((i.overflowY==="auto"||i.overflowY==="scroll")&&r.scrollHeight>r.clientHeight+10){o=r;break}}o&&o.scrollBy(0,800),window.scrollBy(0,800);let s=document.querySelectorAll("button");for(let r of s){let i=r.textContent?.trim().toLowerCase()||"";if((i.includes("load more")||i.includes("show more"))&&r.getBoundingClientRect().height>0)return r.click(),"clicked"}return o?"scrolled":"window-scroll"})}async function ho(e,t){let{max:o,verbose:n,dryRun:s}=t,r=new Map,i=0,l=0,c=3,a=10;for(;;){i++;let f=await je(e),u=0;for(let g of f)g.profileUrl&&(r.has(g.profileUrl)||(r.set(g.profileUrl,g),u++));if(n?console.log(` Round #${i}: ${u} new | Total: ${r.size}`):process.stdout.write(`\r Connections found: ${r.size} (page #${i})`),!s&&i%a===0&&(Me(Array.from(r.values()),!1),n&&console.log(` \u{1F4BE} Saved progress (${r.size} connections)`)),r.size>=o){console.log(`
52
+ By source:`);for(let[r,i]of Object.entries(s).sort((l,c)=>c[1]-l[1]))console.log(` ${r.padEnd(30)} ${i}`);console.log()}async function Eo(e){let t="https://www.linkedin.com/mynetwork/invite-connect/connections/";console.log(`Navigating to ${t}`),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await q(3e3);let o=e.url();if(o.includes("/login")||o.includes("/authwall"))throw new Error("Redirected to login (not logged in, or session expired). Run: ilml linkedin login");try{await e.waitForSelector('main a[href*="/in/"]',{timeout:15e3})}catch{console.warn("\u26A0 No connection cards found after 15s. Page may have changed layout.")}let n=await e.evaluate(()=>{let i=((document.querySelector("main")||document.body).innerText||"").match(/([\d,]+)\s+connections?/i);return i?parseInt(i[1].replace(/,/g,""),10):null});return n&&console.log(` LinkedIn reports: ${n.toLocaleString()} connections`),n}async function We(e){return e.evaluate(()=>{let o=(document.querySelector("main")||document.body).querySelectorAll('a[href*="/in/"]'),n={};for(let i of o){let l=i.getAttribute("href");if(!l)continue;let c;try{let a=new URL(l,location.origin);c=a.origin+a.pathname.replace(/\/+$/,"")}catch{continue}n[c]||(n[c]=[]),n[c].push(i)}let s=[],r=i=>((i&&(i.innerText||i.textContent)||"").trim().split(`
53
+ `)[0]||"").trim();for(let[i,l]of Object.entries(n)){let c=null;for(let p of l){let w=r(p);!w||p.querySelector("img")||(!c||w.length<r(c).length)&&(c=p)}let a=r(c)||null,f=c||l[0];for(let p=0;p<10&&f?.parentElement;p++){f=f.parentElement;let w=f.innerText||"";if((w.includes("Connected on")||w.includes("Message"))&&(w.match(/Connected on/g)||[]).length<=1)break}let u=(f?.innerText||"").split(`
54
+ `).map(p=>p.trim()).filter(Boolean),m=null,g=null,v=u.indexOf(a);if(v>=0&&v+1<u.length){let p=u[v+1];!p.startsWith("Connected on")&&p!=="Message"&&(m=p)}for(let p of u)if(p.startsWith("Connected on")){g=p;break}s.push({profileUrl:i,name:a,title:m,time:g})}return s})}async function Ve(e){return e.evaluate(()=>{let t=document.querySelector("main")||document.body,o=null,n=[t,...t.querySelectorAll("div, section")];for(let r of n){let i=getComputedStyle(r);if((i.overflowY==="auto"||i.overflowY==="scroll")&&r.scrollHeight>r.clientHeight+10){o=r;break}}o&&o.scrollBy(0,800),window.scrollBy(0,800);let s=document.querySelectorAll("button");for(let r of s){let i=r.textContent?.trim().toLowerCase()||"";if((i.includes("load more")||i.includes("show more"))&&r.getBoundingClientRect().height>0)return r.click(),"clicked"}return o?"scrolled":"window-scroll"})}async function xo(e,t){let{max:o,verbose:n,dryRun:s}=t,r=new Map,i=0,l=0,c=3,a=10;for(;;){i++;let f=await We(e),u=0;for(let g of f)g.profileUrl&&(r.has(g.profileUrl)||(r.set(g.profileUrl,g),u++));if(n?console.log(` Round #${i}: ${u} new | Total: ${r.size}`):process.stdout.write(`\r Connections found: ${r.size} (page #${i})`),!s&&i%a===0&&(Ke(Array.from(r.values()),!1),n&&console.log(` \u{1F4BE} Saved progress (${r.size} connections)`)),r.size>=o){console.log(`
57
55
  Reached --max=${o}, stopping.`);break}if(u===0){if(l++,l>=c){console.log(`
58
- ${c} rounds with no new cards \u2014 end of list.`);break}}else l=0;let m=await Ne(e);n&&m==="clicked"&&console.log(' \u2192 Clicked "Load more"'),await P(2e3)}return n||process.stdout.write(`
59
- `),Array.from(r.values())}async function go(e,t){let{max:o,verbose:n}=t,s=U(),r=new Set;for(let[f,u]of Object.entries(s))u.connectionStatus==="connected"&&u.sources?.includes("sync-connections")&&r.add(f);console.log(` Known synced connections in DB: ${r.size}`);let i=new Map,l=0,c=0,a=3;for(;;){l++;let f=await je(e),u=0,m=0;for(let d of f)d.profileUrl&&(i.has(d.profileUrl)||(i.set(d.profileUrl,d),r.has(d.profileUrl)?m++:u++));let g=Array.from(i.values()).filter(d=>!r.has(d.profileUrl)).length;if(n?console.log(` Round #${l}: ${u} new, ${m} known | New total: ${g}`):process.stdout.write(`\r New connections: ${g} (page #${l})`),g>=o){console.log(`
56
+ ${c} rounds with no new cards \u2014 end of list.`);break}}else l=0;let m=await Ve(e);n&&m==="clicked"&&console.log(' \u2192 Clicked "Load more"'),await q(2e3)}return n||process.stdout.write(`
57
+ `),Array.from(r.values())}async function Io(e,t){let{max:o,verbose:n}=t,s=B(),r=new Set;for(let[f,u]of Object.entries(s))u.connectionStatus==="connected"&&u.sources?.includes("sync-connections")&&r.add(f);console.log(` Known synced connections in DB: ${r.size}`);let i=new Map,l=0,c=0,a=3;for(;;){l++;let f=await We(e),u=0,m=0;for(let p of f)p.profileUrl&&(i.has(p.profileUrl)||(i.set(p.profileUrl,p),r.has(p.profileUrl)?m++:u++));let g=Array.from(i.values()).filter(p=>!r.has(p.profileUrl)).length;if(n?console.log(` Round #${l}: ${u} new, ${m} known | New total: ${g}`):process.stdout.write(`\r New connections: ${g} (page #${l})`),g>=o){console.log(`
60
58
  Reached --max=${o}, stopping.`);break}if(u===0&&m>0){if(c++,c>=a){console.log(`
61
59
  ${a} consecutive pages of known connections \u2014 caught up.`);break}}else if(u>0)c=0;else if(c++,c>=a){console.log(`
62
- ${a} empty rounds \u2014 end of list.`);break}let v=await Ne(e);n&&v==="clicked"&&console.log(' \u2192 Clicked "Load more"'),await P(2e3)}return n||process.stdout.write(`
63
- `),Array.from(i.values())}var Fe=new Set(["pending","sent_with_note","sent_without_note","sent_without_note_upsell"]);function _e(e){return typeof e=="string"?e.replace(/\s+/g," ").trim().toLowerCase():""}function Le(e){let t=new Map;for(let[o,n]of Object.entries(e)){let s=H(n.profileUrl||o);s&&!t.has(s)&&t.set(s,o)}for(let[o,n]of Object.entries(e))for(let s of n.aliases||[])s&&!t.has(s)&&t.set(s,o);return t}function yo(e,t){let o=[],n=Le(t);for(let s of e){if(!s.profileUrl)continue;let r=n.get(H(s.profileUrl)),i=r?t[r]:void 0;i&&Fe.has(i.connectionStatus)&&o.push({...s,previousStatus:i.connectionStatus})}return o}function Me(e,t){let o=U(),n=new Date().toISOString(),s=n.slice(0,10),r={newPeople:0,updatedToConnected:0,alreadyConnected:0,flaggedDuplicates:0,flagged:[]},i=Le(o),l=new Map;for(let[c,a]of Object.entries(o)){if(!Fe.has(a.connectionStatus))continue;let f=_e(a.name);f&&(l.has(f)||l.set(f,[]),l.get(f).push(c))}for(let c of e){if(!c.profileUrl)continue;let a=H(c.profileUrl),f=a?i.get(a):null,u=f?o[f]:void 0;if(u){if(u.connectionStatus!=="connected"){u.connectionStatus="connected";let m=c.time?J(c.time.replace(/^Connected\s+on\s+/i,"")):null;u.connectedAt=m||n,u.connectionDate=(m||n).slice(0,10),u.lastUpdated=n,r.updatedToConnected++}else if(r.alreadyConnected++,c.time&&(!u.connectedAt||!u.connectionDate)){let m=J(c.time.replace(/^Connected\s+on\s+/i,""));m&&(u.connectedAt||(u.connectedAt=m),u.connectionDate||(u.connectionDate=m.slice(0,10)),u.lastUpdated=n)}c.name&&!u.name&&(u.name=c.name),c.title&&(u.title=c.title),u.sources||(u.sources=[]),u.sources.includes("sync-connections")||u.sources.push("sync-connections"),u.lastSeen=s,u.seenCount=(u.seenCount||1)+1,u.lastUpdated=n}else{let m={name:c.name,title:c.title,location:null,company:null,connectionDegree:"1st",connectionsCount:null,mutualConnections:null,photoUrl:null,hasVerifiedBadge:!1,firstSeen:s,lastSeen:s,seenCount:1,sources:["sync-connections"],connectionStatus:"connected",connectionDate:s,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:n},g=_e(c.name),v=g?l.get(g)||[]:[];v.length&&(m.possibleDuplicateOf=[...v],r.flaggedDuplicates++,r.flagged.push({name:c.name,candidates:v.length})),o[c.profileUrl]=m,a&&i.set(a,c.profileUrl),r.newPeople++}}return t||ue(o),r}function So(e,t,o,n,s,r){if(console.log(`
60
+ ${a} empty rounds \u2014 end of list.`);break}let v=await Ve(e);n&&v==="clicked"&&console.log(' \u2192 Clicked "Load more"'),await q(2e3)}return n||process.stdout.write(`
61
+ `),Array.from(i.values())}var Ye=new Set(["pending","sent_with_note","sent_without_note","sent_without_note_upsell"]);function He(e){return typeof e=="string"?e.replace(/\s+/g," ").trim().toLowerCase():""}function Ge(e){let t=new Map;for(let[o,n]of Object.entries(e)){let s=V(n.profileUrl||o);s&&!t.has(s)&&t.set(s,o)}for(let[o,n]of Object.entries(e))for(let s of n.aliases||[])s&&!t.has(s)&&t.set(s,o);return t}function Do(e,t){let o=[],n=Ge(t);for(let s of e){if(!s.profileUrl)continue;let r=n.get(V(s.profileUrl)),i=r?t[r]:void 0;i&&Ye.has(i.connectionStatus)&&o.push({...s,previousStatus:i.connectionStatus})}return o}function Ke(e,t){let o=B(),n=new Date().toISOString(),s=n.slice(0,10),r={newPeople:0,updatedToConnected:0,alreadyConnected:0,flaggedDuplicates:0,flagged:[]},i=Ge(o),l=new Map;for(let[c,a]of Object.entries(o)){if(!Ye.has(a.connectionStatus))continue;let f=He(a.name);f&&(l.has(f)||l.set(f,[]),l.get(f).push(c))}for(let c of e){if(!c.profileUrl)continue;let a=V(c.profileUrl),f=a?i.get(a):null,u=f?o[f]:void 0;if(u){if(u.connectionStatus!=="connected"){u.connectionStatus="connected";let m=c.time?W(c.time.replace(/^Connected\s+on\s+/i,"")):null;u.connectedAt=m||n,u.connectionDate=(m||n).slice(0,10),u.lastUpdated=n,r.updatedToConnected++}else if(r.alreadyConnected++,c.time&&(!u.connectedAt||!u.connectionDate)){let m=W(c.time.replace(/^Connected\s+on\s+/i,""));m&&(u.connectedAt||(u.connectedAt=m),u.connectionDate||(u.connectionDate=m.slice(0,10)),u.lastUpdated=n)}c.name&&!u.name&&(u.name=c.name),c.title&&(u.title=c.title),u.sources||(u.sources=[]),u.sources.includes("sync-connections")||u.sources.push("sync-connections"),u.lastSeen=s,u.seenCount=(u.seenCount||1)+1,u.lastUpdated=n}else{let m={name:c.name,title:c.title,location:null,company:null,connectionDegree:"1st",connectionsCount:null,mutualConnections:null,photoUrl:null,hasVerifiedBadge:!1,firstSeen:s,lastSeen:s,seenCount:1,sources:["sync-connections"],connectionStatus:"connected",connectionDate:s,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:n},g=He(c.name),v=g?l.get(g)||[]:[];v.length&&(m.possibleDuplicateOf=[...v],r.flaggedDuplicates++,r.flagged.push({name:c.name,candidates:v.length})),o[c.profileUrl]=m,a&&i.set(a,c.profileUrl),r.newPeople++}}return t||de(o),r}function To(e,t,o,n,s,r){if(console.log(`
64
62
  \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`),console.log(` Sync Connections Summary (${r})`),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),s&&console.log(` LinkedIn header: ${s.toLocaleString()}`),console.log(` Connections scraped: ${e.length}`),console.log(` New people added: ${o.newPeople}`),console.log(` Updated to connected: ${o.updatedToConnected}`),console.log(` Already connected: ${o.alreadyConnected}`),t.length>0){console.log(`
65
63
  Newly accepted (${t.length}):`);for(let i of t)console.log(` \u2713 ${i.name||"Unknown"} (was: ${i.previousStatus})`)}if(o.flaggedDuplicates>0){console.log(`
66
64
  \u26A0 Possible duplicates (${o.flaggedDuplicates}) \u2014 new connection shares a name with a still-pending person (likely the same person accepting under a vanity url we couldn't match by slug). Flagged for review, NOT merged:`);for(let i of o.flagged||[])console.log(` ? ${i.name||"Unknown"}${i.candidates>1?` (${i.candidates} candidates)`:""}`)}n&&console.log(`
67
65
  [DRY RUN \u2014 nothing written to DB]`),console.log(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
68
- `)}async function wo(){let e=fo();if(await Re(),e.list){po();return}let t=e.full?"full":"incremental",o=be("sync",t);console.log(`
66
+ `)}async function Ro(){let e=$o();if(await Be(),e.list){Co();return}let t=e.full?"full":"incremental",o=Re("sync",t);console.log(`
69
67
  \u{1F504} Sync LinkedIn Connections (${t})
70
- `),e.dryRun&&console.log(" [DRY RUN mode]"),e.max!==1/0&&console.log(` Max: ${e.max}`);let{browser:n,page:s}=await me();try{let r=await mo(s),i=e.full?await ho(s,{max:e.max,verbose:e.verbose,dryRun:e.dryRun}):await go(s,{max:e.max,verbose:e.verbose});console.log(`
71
- Extracted ${i.length} connections.`);let l=U(),c=yo(i,l),a=Me(i,e.dryRun);So(i,c,a,e.dryRun,r,t),Q(o,"success",{scraped:i.length,newPeople:a.newPeople,updatedToConnected:a.updatedToConnected})}catch(r){console.error(`
72
- \u2717 Error:`,r.message),e.verbose&&console.error(r.stack),Q(o,"error",null,r.message)}finally{await n.close().catch(()=>{})}}process.argv[1]&&import.meta.url===uo(process.argv[1]).href&&wo();export{Le as buildSlugIndex,yo as detectNewlyAccepted,_e as normName,Me as syncToDatabaseBatch};
68
+ `),e.dryRun&&console.log(" [DRY RUN mode]"),e.max!==1/0&&console.log(` Max: ${e.max}`);let{browser:n,page:s}=await Ce();try{let r=await Eo(s),i=e.full?await xo(s,{max:e.max,verbose:e.verbose,dryRun:e.dryRun}):await Io(s,{max:e.max,verbose:e.verbose});console.log(`
69
+ Extracted ${i.length} connections.`);let l=B(),c=Do(i,l),a=Ke(i,e.dryRun);To(i,c,a,e.dryRun,r,t),Z(o,"success",{scraped:i.length,newPeople:a.newPeople,updatedToConnected:a.updatedToConnected})}catch(r){console.error(`
70
+ \u2717 Error:`,r.message),e.verbose&&console.error(r.stack),Z(o,"error",null,r.message)}finally{await n.close().catch(()=>{})}}process.argv[1]&&import.meta.url===Ao(process.argv[1]).href&&Ro();export{Ge as buildSlugIndex,Do as detectNewlyAccepted,He as normName,Ke as syncToDatabaseBatch};
@@ -1,8 +1,8 @@
1
- var Te=Object.defineProperty;var fe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Le=(e,t)=>{for(var o in t)Te(e,o,{get:t[o],enumerable:!0})};async function d(e){let t=Math.floor(Math.random()*2001),o=e+t;return new Promise(n=>setTimeout(n,o))}async function me(e){return await e.evaluate(()=>{let t=document.querySelectorAll("div.artdeco-modal--is-open");for(let n of t){let s=n.innerText||"",f=s.includes("Premium")||s.includes("premium")||s.includes("Upgrade")||s.includes("upgrade"),c=s.includes("Try for")||s.includes("free trial")||s.includes("/month")||s.includes("per month")||s.includes("Start my")||s.includes("Subscribe"),g=s.includes("Get hired faster")||s.includes("Get hired 2x");if(f||c||g){let D=n.querySelector('button[aria-label="Dismiss"]')||n.querySelector("button.artdeco-modal__dismiss")||n.querySelector("button[data-test-modal-close-btn]");if(D)return D.click(),{dismissed:!0,matched:s.substring(0,80)};let A=n.querySelectorAll("button");for(let l of A){let S=l.innerText?.trim().toLowerCase()||"",p=l.getAttribute("aria-label")?.toLowerCase()||"";if(S==="not now"||S==="no thanks"||S==="dismiss"||p.includes("dismiss"))return l.click(),{dismissed:!0,matched:s.substring(0,80)}}}}let o=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(o){let n=o.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||o.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(n)return n.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var N=fe(()=>{});var be={};Le(be,{extractCertificationsFromDetails:()=>Xe,extractEducationFromDetails:()=>ze,extractExperienceFromDetails:()=>Ge,extractFeaturedFromDetails:()=>Qe,extractRecommendationsFromDetails:()=>et,extractSkillsFromDetails:()=>Ze});async function Ge(e,t){let o=t.replace(/\/+$/,"")+"/details/experience/";try{await e.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await d(3e3);let n=e.url();if(/\/(login|authwall|checkpoint)/i.test(n))throw new Error(`Session expired \u2014 bounced to ${n} when fetching /details/experience/`);for(let f=0;f<5;f++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(900);await d(1e3);let s=0;for(;s<5&&await e.evaluate(()=>{for(let c of document.querySelectorAll("button"))if(/^Load more$/i.test((c.textContent||"").trim()))return c.click(),!0;return!1});)s++,await d(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(700);return await e.evaluate(()=>{let f=document.querySelector("main");if(!f)return[];function c(l){let S=[];for(let p of l.querySelectorAll("div")){let h=Array.from(p.children).filter(x=>x.tagName==="DIV");if(h.length<3)continue;let y=h.filter(x=>(x.textContent||"").trim().length>50);y.length<3||(p.textContent||"").length<500||S.push({el:p,count:y.length,totalText:(p.textContent||"").length})}return S.sort((p,h)=>h.count-p.count||p.totalText-h.totalText),S[0]?.el}let g=c(f);if(!g)return[];let D=Array.from(g.children).filter(l=>l.tagName==="DIV").filter(l=>(l.textContent||"").trim().length>50);function A(l){let S=l[0]||null,p=null,h=null;if(l[1]){let u=l[1].split("\xB7").map(C=>C.trim());p=u[0]||null,u[1]&&(h=u[1])}let y=l.findIndex(u=>/(\d{4}|present)/i.test(u)&&/(-|–|—)/i.test(u)&&u.length<80),x=null,T=null;if(y>=0){let u=l[y].split("\xB7").map(C=>C.trim());x=u[0]||null,u[1]&&(T=u[1])}let L=null,M=-1;if(y>=0&&l[y+1]){let u=l[y+1],C=/^[>*\-•]|^&gt;/.test(u),P=/https?:\/\//.test(u),j=/\d{4}/.test(u),v=/,/.test(u)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(u);!C&&!P&&!j&&u.length<100&&v&&(L=u,M=y+1)}let Y=null,m=-1,F=l[l.length-1];if(F&&/and\s+\+\d+\s+skills?$/i.test(F)){m=l.length-1;let u=F.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);u&&(Y={listed:u[1].split(",").map(C=>C.trim()),additional:parseInt(u[2],10)})}let q=new Set([0,1,y,M,m].filter(u=>u>=0)),$=l.filter((u,C)=>!q.has(C)),k=$.length>0?$.join(`
1
+ var He=Object.defineProperty;var pe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ue=(e,t)=>{for(var o in t)He(e,o,{get:t[o],enumerable:!0})};async function f(e){let t=Math.floor(Math.random()*2001),o=e+t;return new Promise(n=>setTimeout(n,o))}async function he(e){return await e.evaluate(()=>{let t=document.querySelectorAll("div.artdeco-modal--is-open");for(let n of t){let i=n.innerText||"",d=i.includes("Premium")||i.includes("premium")||i.includes("Upgrade")||i.includes("upgrade"),l=i.includes("Try for")||i.includes("free trial")||i.includes("/month")||i.includes("per month")||i.includes("Start my")||i.includes("Subscribe"),g=i.includes("Get hired faster")||i.includes("Get hired 2x");if(d||l||g){let L=n.querySelector('button[aria-label="Dismiss"]')||n.querySelector("button.artdeco-modal__dismiss")||n.querySelector("button[data-test-modal-close-btn]");if(L)return L.click(),{dismissed:!0,matched:i.substring(0,80)};let I=n.querySelectorAll("button");for(let a of I){let S=a.innerText?.trim().toLowerCase()||"",p=a.getAttribute("aria-label")?.toLowerCase()||"";if(S==="not now"||S==="no thanks"||S==="dismiss"||p.includes("dismiss"))return a.click(),{dismissed:!0,matched:i.substring(0,80)}}}}let o=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(o){let n=o.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||o.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(n)return n.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var H=pe(()=>{});var De={};Ue(De,{extractCertificationsFromDetails:()=>dt,extractEducationFromDetails:()=>ct,extractExperienceFromDetails:()=>lt,extractFeaturedFromDetails:()=>at,extractRecommendationsFromDetails:()=>ft,extractSkillsFromDetails:()=>ut});async function lt(e,t){let o=t.replace(/\/+$/,"")+"/details/experience/";try{await e.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await f(3e3);let n=e.url();if(/\/(login|authwall|checkpoint)/i.test(n))throw new Error(`Session expired \u2014 bounced to ${n} when fetching /details/experience/`);for(let d=0;d<5;d++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await f(900);await f(1e3);let i=0;for(;i<5&&await e.evaluate(()=>{for(let l of document.querySelectorAll("button"))if(/^Load more$/i.test((l.textContent||"").trim()))return l.click(),!0;return!1});)i++,await f(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await f(700);return await e.evaluate(()=>{let d=document.querySelector("main");if(!d)return[];function l(a){let S=[];for(let p of a.querySelectorAll("div")){let h=Array.from(p.children).filter(x=>x.tagName==="DIV");if(h.length<3)continue;let y=h.filter(x=>(x.textContent||"").trim().length>50);y.length<3||(p.textContent||"").length<500||S.push({el:p,count:y.length,totalText:(p.textContent||"").length})}return S.sort((p,h)=>h.count-p.count||p.totalText-h.totalText),S[0]?.el}let g=l(d);if(!g)return[];let L=Array.from(g.children).filter(a=>a.tagName==="DIV").filter(a=>(a.textContent||"").trim().length>50);function I(a){let S=a[0]||null,p=null,h=null;if(a[1]){let u=a[1].split("\xB7").map(C=>C.trim());p=u[0]||null,u[1]&&(h=u[1])}let y=a.findIndex(u=>/(\d{4}|present)/i.test(u)&&/(-|–|—)/i.test(u)&&u.length<80),x=null,M=null;if(y>=0){let u=a[y].split("\xB7").map(C=>C.trim());x=u[0]||null,u[1]&&(M=u[1])}let F=null,P=-1;if(y>=0&&a[y+1]){let u=a[y+1],C=/^[>*\-•]|^&gt;/.test(u),N=/https?:\/\//.test(u),O=/\d{4}/.test(u),k=/,/.test(u)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(u);!C&&!N&&!O&&u.length<100&&k&&(F=u,P=y+1)}let G=null,m=-1,q=a[a.length-1];if(q&&/and\s+\+\d+\s+skills?$/i.test(q)){m=a.length-1;let u=q.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);u&&(G={listed:u[1].split(",").map(C=>C.trim()),additional:parseInt(u[2],10)})}let R=new Set([0,1,y,P,m].filter(u=>u>=0)),$=a.filter((u,C)=>!R.has(C)),v=$.length>0?$.join(`
2
2
 
3
- `):null;return{title:S,company:p,employmentType:h,dates:x,duration:T,location:L,description:k,skills:Y,_raw:l}}return D.map(l=>{let p=(l.innerText||"").trim().split(`
4
- `).map(h=>h.trim()).filter(h=>h&&h.length<5e3);return A(p)}).filter(l=>l.title)})}catch(n){if(/session expired|bounced to|authwall|checkpoint/i.test(n.message||""))throw n;return console.error(`extractExperienceFromDetails failed for ${t}: ${n.message?.slice(0,120)}`),[]}}async function B(e,t,o){let n=t.replace(/\/+$/,"")+`/details/${o}/`;await e.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await d(3e3);let s=e.url();if(/\/(login|authwall|checkpoint)/i.test(s))throw new Error(`Session expired \u2014 bounced to ${s} when fetching /details/${o}/`);if(!s.toLowerCase().includes(`/details/${o.toLowerCase()}/`))throw new Error(`Section /details/${o}/ not available on profile (landed on ${s})`);for(let c=0;c<4;c++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(700);await d(800);let f=0;for(;f<5&&await e.evaluate(()=>{for(let g of document.querySelectorAll("button"))if(/^Load more$/i.test((g.textContent||"").trim()))return g.click(),!0;return!1});)f++,await d(1300),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(600)}async function U(e,t,o,n){try{return await n()}catch(s){let f=s.message||"";if(/session expired|bounced to|authwall|checkpoint/i.test(f))throw s;return/not available on profile/i.test(f)?(console.log(` (${t}: section not on profile \u2014 skipped)`),[]):(console.error(`${o} failed for ${e}: ${f.slice(0,120)}`),[])}}async function Qe(e,t){return U(t,"featured","extractFeaturedFromDetails",async()=>(await B(e,t,"featured"),await e.evaluate(`(() => {
5
- ${H}
3
+ `):null;return{title:S,company:p,employmentType:h,dates:x,duration:M,location:F,description:v,skills:G,_raw:a}}return L.map(a=>{let p=(a.innerText||"").trim().split(`
4
+ `).map(h=>h.trim()).filter(h=>h&&h.length<5e3);return I(p)}).filter(a=>a.title)})}catch(n){if(/session expired|bounced to|authwall|checkpoint/i.test(n.message||""))throw n;return console.error(`extractExperienceFromDetails failed for ${t}: ${n.message?.slice(0,120)}`),[]}}async function U(e,t,o){let n=t.replace(/\/+$/,"")+`/details/${o}/`;await e.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await f(3e3);let i=e.url();if(/\/(login|authwall|checkpoint)/i.test(i))throw new Error(`Session expired \u2014 bounced to ${i} when fetching /details/${o}/`);if(!i.toLowerCase().includes(`/details/${o.toLowerCase()}/`))throw new Error(`Section /details/${o}/ not available on profile (landed on ${i})`);for(let l=0;l<4;l++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await f(700);await f(800);let d=0;for(;d<5&&await e.evaluate(()=>{for(let g of document.querySelectorAll("button"))if(/^Load more$/i.test((g.textContent||"").trim()))return g.click(),!0;return!1});)d++,await f(1300),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await f(600)}async function W(e,t,o,n){try{return await n()}catch(i){let d=i.message||"";if(/session expired|bounced to|authwall|checkpoint/i.test(d))throw i;return/not available on profile/i.test(d)?(console.log(` (${t}: section not on profile \u2014 skipped)`),[]):(console.error(`${o} failed for ${e}: ${d.slice(0,120)}`),[])}}async function at(e,t){return W(t,"featured","extractFeaturedFromDetails",async()=>(await U(e,t,"featured"),await e.evaluate(`(() => {
5
+ ${V}
6
6
 
7
7
  const main = document.querySelector('main');
8
8
  if (!main) return [];
@@ -42,8 +42,8 @@ var Te=Object.defineProperty;var fe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Le=(e,t)=>{
42
42
  if (e.caption && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.caption.trim())) return false;
43
43
  return true;
44
44
  });
45
- })()`)))}async function ze(e,t){return U(t,"education","extractEducationFromDetails",async()=>(await B(e,t,"education"),await e.evaluate(`(() => {
46
- ${H}
45
+ })()`)))}async function ct(e,t){return W(t,"education","extractEducationFromDetails",async()=>(await U(e,t,"education"),await e.evaluate(`(() => {
46
+ ${V}
47
47
 
48
48
  const main = document.querySelector('main');
49
49
  if (!main) return [];
@@ -79,8 +79,8 @@ var Te=Object.defineProperty;var fe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Le=(e,t)=>{
79
79
  if (e.degree && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.degree.trim())) return false;
80
80
  return true;
81
81
  });
82
- })()`)))}async function Ze(e,t){return U(t,"skills","extractSkillsFromDetails",async()=>(await B(e,t,"skills"),await e.evaluate(`(() => {
83
- ${H}
82
+ })()`)))}async function ut(e,t){return W(t,"skills","extractSkillsFromDetails",async()=>(await U(e,t,"skills"),await e.evaluate(`(() => {
83
+ ${V}
84
84
 
85
85
  const main = document.querySelector('main');
86
86
  if (!main) return [];
@@ -111,8 +111,8 @@ var Te=Object.defineProperty;var fe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Le=(e,t)=>{
111
111
  skills.push({ name, endorsements, _raw: lines });
112
112
  }
113
113
  return skills;
114
- })()`)))}async function Xe(e,t){return U(t,"certifications","extractCertificationsFromDetails",async()=>(await B(e,t,"certifications"),await e.evaluate(`(() => {
115
- ${H}
114
+ })()`)))}async function dt(e,t){return W(t,"certifications","extractCertificationsFromDetails",async()=>(await U(e,t,"certifications"),await e.evaluate(`(() => {
115
+ ${V}
116
116
 
117
117
  const main = document.querySelector('main');
118
118
  if (!main) return [];
@@ -136,8 +136,8 @@ var Te=Object.defineProperty;var fe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Le=(e,t)=>{
136
136
 
137
137
  return { name, issuer, issueDate, expiryDate, credentialId, _raw: lines };
138
138
  }).filter(e => e.name);
139
- })()`)))}async function et(e,t){return U(t,"recommendations","extractRecommendationsFromDetails",async()=>(await B(e,t,"recommendations"),await e.evaluate(`(() => {
140
- ${H}
139
+ })()`)))}async function ft(e,t){return W(t,"recommendations","extractRecommendationsFromDetails",async()=>(await U(e,t,"recommendations"),await e.evaluate(`(() => {
140
+ ${V}
141
141
 
142
142
  const main = document.querySelector('main');
143
143
  if (!main) return [];
@@ -172,7 +172,7 @@ var Te=Object.defineProperty;var fe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Le=(e,t)=>{
172
172
  if (e.recommenderTitle && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.recommenderTitle.trim())) return false;
173
173
  return true;
174
174
  });
175
- })()`)))}var H,Se=fe(()=>{N();H=`
175
+ })()`)))}var V,Te=pe(()=>{H();V=`
176
176
  function findEntryContainer(root) {
177
177
  const candidates = [];
178
178
  for (const div of root.querySelectorAll('div')) {
@@ -235,12 +235,10 @@ function findEntryContainer(root) {
235
235
  candidates.sort((a, b) => b.count - a.count || b.totalText - a.totalText);
236
236
  return candidates[0]?.el;
237
237
  }
238
- `});import Ne from"puppeteer";import{addExtra as Be}from"puppeteer-extra";import He from"puppeteer-extra-plugin-stealth";N();import{getPluginConfig as Me}from"@ilivemylife/graph-sdk";var Fe=await Me();for(let[e,t]of Object.entries(Fe))process.env[e]===void 0&&(process.env[e]=t);var qe=process.env.LINKEDIN_NAME,R=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),ct=Object.freeze(new Set([R.DRAFT,R.CONFIRMED,R.NEEDS_REVIEW])),Re=Object.freeze(new Set([R.DRAFT,R.CONFIRMED,R.REJECTED,R.NEEDS_REVIEW]));import pe from"fs";import Pe from"path";var je="cookies.json";function Oe(){let e=process.env.ILML_SCOPE_DIR;return e?Pe.join(e,"plugins-state","linkedin","cookies.json"):je}function he(){let e=Oe();if(!pe.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=pe.readFileSync(e,"utf-8")}catch(n){throw new Error(`Failed to read cookies at ${e}: ${n.message}. Run: ilml linkedin login`)}let o;try{o=JSON.parse(t)}catch{throw new Error(`Cookies file at ${e} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(o)||o.length===0)throw new Error(`Cookies file at ${e} is empty or not an array. Run: ilml linkedin login`);return o}var ge=Be(Ne);ge.use(He());async function we(){let e=await ge.launch({headless:!1,defaultViewport:null,protocolTimeout:3e5}),t=async()=>{console.log(`
239
- Closing browser...`);try{await e.close()}catch{}process.exit(0)};process.on("SIGINT",t),process.on("SIGTERM",t);let o=await e.newPage();await o.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})});try{let n=he();await o.setCookie(...n),console.log(" Browser launched, cookies loaded.")}catch(n){console.error(`
240
- [!] ${n.message}
241
- `),await e.close(),process.exit(1)}return{browser:e,page:o}}N();import"dotenv/config";import*as w from"fs";import*as b from"path";import{fileURLToPath as Ue}from"url";var Ve=Ue(import.meta.url),We=b.dirname(b.dirname(Ve)),E=process.env.DATA_DIR?b.resolve(process.env.DATA_DIR,"collected-profiles"):b.join(We,"collected-profiles"),Je=b.join(E,"people.json"),At=b.join(E,"jobs.json"),$t=b.join(E,"quota.json"),It=b.join(E,"conversations.json"),Dt=b.join(E,"sync-state.json"),Tt=b.join(E,"application-questions.json"),Lt=b.join(E,"profile-history"),ye=(e,t)=>{let o=parseInt(e,10);return Number.isInteger(o)&&o>=0?o:t},Mt=ye(process.env.CONNECT_MAX_DAILY,20),Ft=ye(process.env.CONNECT_MAX_WEEKLY,100),J=null;function Ye(){w.existsSync(E)||w.mkdirSync(E,{recursive:!0})}function Ke(e,t){if(!w.existsSync(e))return null;try{let o=JSON.parse(w.readFileSync(e,"utf-8"));try{w.copyFileSync(e,e+".backup")}catch{}return o}catch(o){console.error(`[!] ${t} is corrupted: ${o.message}`),console.error(` File: ${b.resolve(e)}`);let n=e+".backup";if(w.existsSync(n))try{let s=JSON.parse(w.readFileSync(n,"utf-8"));console.error(` Restored from ${n}`);try{w.copyFileSync(n,e)}catch{}return s}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{w.copyFileSync(e,e+".corrupted")}catch{}return null}}function Q(){return J||(Ye(),J=Ke(Je,"people.json")||{},J)}async function tt(e,t){let o=e.url();if(o.includes("/in/"))return!1;if(o.includes("/login")||o.includes("/authwall")||o.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${o.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await d(3e3);let n=e.url();return n.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${n.slice(0,80)}`),!0}async function Ce(e,t,o={}){let{extractExperience:n=!1,extractFeatured:s=!1,extractEducation:f=!1,extractSkills:c=!1,extractRecommendations:g=!1,extractCertifications:D=!1}=o;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await d(3e3),await me(e)&&(console.log(" Dismissed Premium overlay"),await d(1500),await tt(e,t));let l=0;for(let m=0;m<2;m++){let F=await e.evaluate(()=>document.body.scrollHeight);for(let $=1;$<=6;$++)await e.evaluate(k=>window.scrollTo(0,k),F*$/6),await d(900);let q=await e.evaluate(()=>document.body.scrollHeight);if(q===l)break;l=q}await d(800);let S=null;try{let m=e.url();m&&/\/in\/[^/?#]/.test(m)&&(S=m.split("?")[0].replace(/\/+$/,""))}catch{}let p=await e.evaluate(()=>{let m=new Set(["Highlights","About","Activity","Experience","Education","Skills","Recommendations","Languages","Interests","Volunteer experience","Featured","Honors & awards","Honors and awards","Projects","Publications","Patents","Certifications","Licenses & certifications","Courses","Test scores","Organizations"]),F=new Set(["Ad Options","Don\u2019t want to see this","0 notifications","Explore Premium profiles","You might like","People you may know","Suggested for you","More profiles for you","Promoted"]),q=i=>{let r=(i||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(r)},$={name:null,title:null,location:null,currentCompany:null,currentSchool:null,connectionDegree:null,hasVerifiedBadge:!1,photoUrl:null,connectionsLevel:null,mutualConnectionsCount:null,followers:null,openToWork:!1,hiring:!1,about:null,topSkills:null,availableSections:[]},k=document.querySelector("main");if(!k)return $;let u=[...Array.from(k.querySelectorAll("h1")),...Array.from(k.querySelectorAll("h2"))],C=Array.from(k.querySelectorAll("h2")),P=u.find(i=>{let r=i.textContent&&i.textContent.trim(),a=(r||"").replace(/\s*\(\d+\)$/,"").trim();return r&&r.length>1&&r.length<100&&!m.has(a)&&!F.has(a)}),j=P?P.textContent.trim():null,v=P?P.parentElement:null;for(;v&&v!==k&&!Array.from(v.children).filter(r=>r.tagName==="P").some(r=>{let a=r.textContent&&r.textContent.trim();return a&&a.length>5&&!q(a)});)v=v.parentElement;let Z=null,X=null,ee=null,K=null;if(v&&v!==k){let i=Array.from(v.children).filter(a=>a.tagName==="P").filter(a=>{let I=a.textContent&&a.textContent.trim();return I&&I.length>5&&!q(I)});if(i[0]&&(Z=i[0].textContent.trim()),i[1]){let a=i[1].textContent.trim().split(/\s*[·•]\s*/);X=a[0]||null,a.length>1&&(ee=a.slice(1).join(" \xB7 "))}let r=Array.from(v.children).filter(a=>a.tagName==="DIV");for(let a=r.length-1;a>=0;a--){let I=r[a].textContent&&r[a].textContent.trim();if(I&&!(j&&I.startsWith(j))&&(K=I.split(/[·•]/)[0].trim(),K))break}}let te=null;if(v){let i=v.querySelectorAll("p, span, div");for(let r of i){let a=(r.textContent||"").trim().replace(/^[·•]\s*/,"");if(a==="1st"||a==="2nd"||a==="3rd"){te=a;break}}}let xe=!!k.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),ne=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),_e=ne&&ne.src||null,V=k.textContent||"",oe=null,ie=V.match(/(\d+\+?)\s+connections\b/i);ie&&(oe=ie[1]+" connections");let W=null,se=V.match(/(\d+)\s+mutual connection/i),re=V.match(/and\s+(\d+)\s+other mutual/i),Ee=V.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);se?W=parseInt(se[1],10):re?W=2+parseInt(re[1],10):Ee&&(W=2);let le=null,ae=null,ce=C.find(i=>i.textContent&&i.textContent.trim()==="About");if(ce){let i=ce.parentElement;for(;i&&i.tagName!=="SECTION";)i=i.parentElement;if(i){let r=(i.textContent||"").trim();r=r.replace(/^About\s*/,"").trim();let a=r.match(/Top skills\s*(.+?)$/i);if(a){let G=a[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(De=>De.trim()).filter(Boolean);G.length>0&&G.length<10&&(ae=G)}r=r.split(/\n?…\s*more/i)[0].trim(),r=r.split(/\n?\.\.\.\s*more/i)[0].trim(),r=r.split(/\bTop skills\b/i)[0].trim(),r=r.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),le=r||null}}let ue=null,de=C.find(i=>i.textContent&&i.textContent.trim()==="Activity");if(de){let i=de.parentElement;for(;i&&i.tagName!=="SECTION";)i=i.parentElement;if(i){let r=(i.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);r&&(ue=parseInt(r[1].replace(/,/g,""),10))}}let Ae=[...new Set(C.map(i=>(i.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(i=>i&&i.length>1&&i.length<60&&i!==j).filter(i=>m.has(i)))],O=document.body.textContent||"",$e=/#OpenToWork\b/i.test(O)||/\bOpen to work\b/.test(O),Ie=/#Hiring\b/i.test(O)||/\bI'?m hiring\b/i.test(O)||/\bWe are hiring\b/i.test(O);return{name:j,title:Z,location:K,currentCompany:X,currentSchool:ee,connectionDegree:te,hasVerifiedBadge:xe,photoUrl:_e,connectionsLevel:oe,mutualConnectionsCount:W,followers:ue,openToWork:$e,hiring:Ie,about:le,topSkills:ae,availableSections:Ae}});console.log(`Viewed: ${p.name} - ${p.title}`);let h=null,y=null,x=null,T=null,L=null,M=null;if(n||s||f||c||g||D){let m=await Promise.resolve().then(()=>(Se(),be));n&&(h=await m.extractExperienceFromDetails(e,t),console.log(` + Experience: ${h.length} entries`)),s&&(y=await m.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${y.length} entries`)),f&&(x=await m.extractEducationFromDetails(e,t),console.log(` + Education: ${x.length} entries`)),c&&(T=await m.extractSkillsFromDetails(e,t),console.log(` + Skills: ${T.length} entries`)),g&&(L=await m.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${L.length} entries`)),D&&(M=await m.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${M.length} entries`))}return{...p,profileUrl:t,resolvedUrl:S,...h!==null&&{experience:h},...y!==null&&{featured:y},...x!==null&&{education:x},...T!==null&&{skillsFull:T},...L!==null&&{recommendations:L},...M!==null&&{certifications:M}}}catch(A){console.error(`Error viewing profile ${t}:`,A.message);try{await e.goto("about:blank",{timeout:1e4}),await d(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(A.message||""))throw A;return null}}N();var z=process.argv.slice(2),ve=z.filter(e=>e.startsWith("http")),ke=parseInt(z.find(e=>e.startsWith("--pick="))?.split("=")[1]||"0"),nt=z.includes("--has-about");function ot(e,t){return[...e].sort(()=>Math.random()-.5).slice(0,t)}function it(){if(ve.length>0)return ve.map(t=>({url:t,name:"(arg)"}));if(ke>0){let t=Q(),o=Object.entries(t).filter(([n])=>n.startsWith("http")).filter(([,n])=>nt?!!(n.about&&n.about.trim()):!n.about);return ot(o,ke).map(([n,s])=>({url:n,name:s.name}))}let e=process.env.MY_LINKEDIN_URL;return e||(console.error("Pass a URL, use --pick=N, or set MY_LINKEDIN_URL in .env"),process.exit(1)),[{url:e,name:"(self)"}]}function _(e,t,o=80){if(t==null){console.log(` ${e.padEnd(20)} (null)`);return}let n=String(t),s=n.length>o?n.slice(0,o)+`\u2026 (+${n.length-o} chars)`:n;console.log(` ${e.padEnd(20)} ${s} [len=${n.length}]`)}async function st(){let e=it();console.log(`
238
+ `});import Ze from"puppeteer";import{addExtra as Xe}from"puppeteer-extra";import et from"puppeteer-extra-plugin-stealth";H();import{getPluginConfig as Ve}from"@ilivemylife/graph-sdk";var We=await Ve();for(let[e,t]of Object.entries(We))process.env[e]===void 0&&(process.env[e]=t);var Je=process.env.LINKEDIN_NAME,j=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Ct=Object.freeze(new Set([j.DRAFT,j.CONFIRMED,j.NEEDS_REVIEW])),Ke=Object.freeze(new Set([j.DRAFT,j.CONFIRMED,j.REJECTED,j.NEEDS_REVIEW]));import _ from"fs";import T from"path";var Ye="cookies.json";function ge(){let e=process.env.ILML_SCOPE_DIR;return e?T.join(e,"plugins-state","linkedin","cookies.json"):Ye}function we(){let e=ge();if(!_.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=_.readFileSync(e,"utf-8")}catch(n){throw new Error(`Failed to read cookies at ${e}: ${n.message}. Run: ilml linkedin login`)}let o;try{o=JSON.parse(t)}catch{throw new Error(`Cookies file at ${e} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(o)||o.length===0)throw new Error(`Cookies file at ${e} is empty or not an array. Run: ilml linkedin login`);return o}function ye(){return _.existsSync(ge())}function Ge(){let e=process.env.ILML_SCOPE_DIR;return e?T.join(e,"plugins-state","linkedin"):"."}function be(e){let t=String(e||"").replace(/[^a-zA-Z0-9_.-]/g,"_").slice(0,80);return/[a-zA-Z0-9]/.test(t)?t:"default"}function ze(){let e=process.env.MY_LINKEDIN_URL,t=e&&e.match(/\/in\/([^/?#]+)/);return t&&t[1]?be(t[1]):"default"}function Se(e){let t=process.env.LINKEDIN_CHROME_PROFILE_DIR;if(t)return _.existsSync(t)||_.mkdirSync(t,{recursive:!0}),T.resolve(t);let o=be(e||ze()),n=T.join(Ge(),"chrome-profile",o);return _.existsSync(n)||_.mkdirSync(n,{recursive:!0}),T.resolve(n)}var Ce=".ilml-seeded";function ke(e){return!_.existsSync(T.join(e,Ce))}function ve(e){try{_.writeFileSync(T.join(e,Ce),new Date().toISOString())}catch{}}function xe(e){let t=0;for(let o of["SingletonLock","SingletonCookie","SingletonSocket"])try{_.rmSync(T.join(e,o),{force:!0}),t++}catch{}return t}var Qe={headless:!1,defaultViewport:null,protocolTimeout:3e5};async function _e(e,t={}){let o=Se(),n={...Qe,...t,userDataDir:o},i;try{i=await e.launch(n)}catch{xe(o);try{i=await e.launch(n)}catch(l){throw new Error(`Could not open the LinkedIn automation Chrome profile at ${o}. If a LinkedIn automation window is already open, close it and retry. (Chrome: ${l.message})`)}}return{browser:i,profileDir:o,needsSeed:ke(o)}}async function Ee(e,t){if(!t||!t.needsSeed)return!1;if(!ye())return console.warn(" \u26A0 No saved LinkedIn session found. If this command comes back empty or redirects to login, run: ilml linkedin login"),!1;try{return await e.setCookie(...we()),ve(t.profileDir),console.log(" (seeded persistent profile from saved cookies \u2014 one-time)"),!0}catch{return!1}}var Ae=Xe(Ze);Ae.use(et());async function Ie(){let{browser:e,profileDir:t,needsSeed:o}=await _e(Ae),n=async()=>{console.log(`
239
+ Closing browser...`);try{await e.close()}catch{}process.exit(0)};process.on("SIGINT",n),process.on("SIGTERM",n);let i=await e.newPage();return await i.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})}),await Ee(i,{profileDir:t,needsSeed:o}),console.log(" Browser launched (persistent profile)."),{browser:e,page:i}}H();import"dotenv/config";import*as w from"fs";import*as b from"path";import{fileURLToPath as tt}from"url";var nt=tt(import.meta.url),ot=b.dirname(b.dirname(nt)),A=process.env.DATA_DIR?b.resolve(process.env.DATA_DIR,"collected-profiles"):b.join(ot,"collected-profiles"),it=b.join(A,"people.json"),Ut=b.join(A,"jobs.json"),Vt=b.join(A,"quota.json"),Wt=b.join(A,"conversations.json"),Jt=b.join(A,"sync-state.json"),Kt=b.join(A,"application-questions.json"),Yt=b.join(A,"profile-history"),$e=(e,t)=>{let o=parseInt(e,10);return Number.isInteger(o)&&o>=0?o:t},Gt=$e(process.env.CONNECT_MAX_DAILY,20),zt=$e(process.env.CONNECT_MAX_WEEKLY,100),Y=null;function st(){w.existsSync(A)||w.mkdirSync(A,{recursive:!0})}function rt(e,t){if(!w.existsSync(e))return null;try{let o=JSON.parse(w.readFileSync(e,"utf-8"));try{w.copyFileSync(e,e+".backup")}catch{}return o}catch(o){console.error(`[!] ${t} is corrupted: ${o.message}`),console.error(` File: ${b.resolve(e)}`);let n=e+".backup";if(w.existsSync(n))try{let i=JSON.parse(w.readFileSync(n,"utf-8"));console.error(` Restored from ${n}`);try{w.copyFileSync(n,e)}catch{}return i}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{w.copyFileSync(e,e+".corrupted")}catch{}return null}}function Z(){return Y||(st(),Y=rt(it,"people.json")||{},Y)}async function mt(e,t){let o=e.url();if(o.includes("/in/"))return!1;if(o.includes("/login")||o.includes("/authwall")||o.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: ilml linkedin login");console.log(` Off-track: ${o.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await f(3e3);let n=e.url();return n.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${n.slice(0,80)}`),!0}async function Le(e,t,o={}){let{extractExperience:n=!1,extractFeatured:i=!1,extractEducation:d=!1,extractSkills:l=!1,extractRecommendations:g=!1,extractCertifications:L=!1}=o;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await f(3e3),await he(e)&&(console.log(" Dismissed Premium overlay"),await f(1500),await mt(e,t));let a=0;for(let m=0;m<2;m++){let q=await e.evaluate(()=>document.body.scrollHeight);for(let $=1;$<=6;$++)await e.evaluate(v=>window.scrollTo(0,v),q*$/6),await f(900);let R=await e.evaluate(()=>document.body.scrollHeight);if(R===a)break;a=R}await f(800);let S=null;try{let m=e.url();m&&/\/in\/[^/?#]/.test(m)&&(S=m.split("?")[0].replace(/\/+$/,""))}catch{}let p=await e.evaluate(()=>{let m=new Set(["Highlights","About","Activity","Experience","Education","Skills","Recommendations","Languages","Interests","Volunteer experience","Featured","Honors & awards","Honors and awards","Projects","Publications","Patents","Certifications","Licenses & certifications","Courses","Test scores","Organizations"]),q=new Set(["Ad Options","Don\u2019t want to see this","0 notifications","Explore Premium profiles","You might like","People you may know","Suggested for you","More profiles for you","Promoted"]),R=s=>{let r=(s||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(r)},$={name:null,title:null,location:null,currentCompany:null,currentSchool:null,connectionDegree:null,hasVerifiedBadge:!1,photoUrl:null,connectionsLevel:null,mutualConnectionsCount:null,followers:null,openToWork:!1,hiring:!1,about:null,topSkills:null,availableSections:[]},v=document.querySelector("main");if(!v)return $;let u=[...Array.from(v.querySelectorAll("h1")),...Array.from(v.querySelectorAll("h2"))],C=Array.from(v.querySelectorAll("h2")),N=u.find(s=>{let r=s.textContent&&s.textContent.trim(),c=(r||"").replace(/\s*\(\d+\)$/,"").trim();return r&&r.length>1&&r.length<100&&!m.has(c)&&!q.has(c)}),O=N?N.textContent.trim():null,k=N?N.parentElement:null;for(;k&&k!==v&&!Array.from(k.children).filter(r=>r.tagName==="P").some(r=>{let c=r.textContent&&r.textContent.trim();return c&&c.length>5&&!R(c)});)k=k.parentElement;let ee=null,te=null,ne=null,z=null;if(k&&k!==v){let s=Array.from(k.children).filter(c=>c.tagName==="P").filter(c=>{let D=c.textContent&&c.textContent.trim();return D&&D.length>5&&!R(D)});if(s[0]&&(ee=s[0].textContent.trim()),s[1]){let c=s[1].textContent.trim().split(/\s*[·•]\s*/);te=c[0]||null,c.length>1&&(ne=c.slice(1).join(" \xB7 "))}let r=Array.from(k.children).filter(c=>c.tagName==="DIV");for(let c=r.length-1;c>=0;c--){let D=r[c].textContent&&r[c].textContent.trim();if(D&&!(O&&D.startsWith(O))&&(z=D.split(/[·•]/)[0].trim(),z))break}}let oe=null;if(k){let s=k.querySelectorAll("p, span, div");for(let r of s){let c=(r.textContent||"").trim().replace(/^[·•]\s*/,"");if(c==="1st"||c==="2nd"||c==="3rd"){oe=c;break}}}let Pe=!!v.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),ie=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),qe=ie&&ie.src||null,J=v.textContent||"",se=null,re=J.match(/(\d+\+?)\s+connections\b/i);re&&(se=re[1]+" connections");let K=null,le=J.match(/(\d+)\s+mutual connection/i),ae=J.match(/and\s+(\d+)\s+other mutual/i),Re=J.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);le?K=parseInt(le[1],10):ae?K=2+parseInt(ae[1],10):Re&&(K=2);let ce=null,ue=null,de=C.find(s=>s.textContent&&s.textContent.trim()==="About");if(de){let s=de.parentElement;for(;s&&s.tagName!=="SECTION";)s=s.parentElement;if(s){let r=(s.textContent||"").trim();r=r.replace(/^About\s*/,"").trim();let c=r.match(/Top skills\s*(.+?)$/i);if(c){let Q=c[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Be=>Be.trim()).filter(Boolean);Q.length>0&&Q.length<10&&(ue=Q)}r=r.split(/\n?…\s*more/i)[0].trim(),r=r.split(/\n?\.\.\.\s*more/i)[0].trim(),r=r.split(/\bTop skills\b/i)[0].trim(),r=r.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),ce=r||null}}let fe=null,me=C.find(s=>s.textContent&&s.textContent.trim()==="Activity");if(me){let s=me.parentElement;for(;s&&s.tagName!=="SECTION";)s=s.parentElement;if(s){let r=(s.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);r&&(fe=parseInt(r[1].replace(/,/g,""),10))}}let je=[...new Set(C.map(s=>(s.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(s=>s&&s.length>1&&s.length<60&&s!==O).filter(s=>m.has(s)))],B=document.body.textContent||"",Ne=/#OpenToWork\b/i.test(B)||/\bOpen to work\b/.test(B),Oe=/#Hiring\b/i.test(B)||/\bI'?m hiring\b/i.test(B)||/\bWe are hiring\b/i.test(B);return{name:O,title:ee,location:z,currentCompany:te,currentSchool:ne,connectionDegree:oe,hasVerifiedBadge:Pe,photoUrl:qe,connectionsLevel:se,mutualConnectionsCount:K,followers:fe,openToWork:Ne,hiring:Oe,about:ce,topSkills:ue,availableSections:je}});console.log(`Viewed: ${p.name} - ${p.title}`);let h=null,y=null,x=null,M=null,F=null,P=null;if(n||i||d||l||g||L){let m=await Promise.resolve().then(()=>(Te(),De));n&&(h=await m.extractExperienceFromDetails(e,t),console.log(` + Experience: ${h.length} entries`)),i&&(y=await m.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${y.length} entries`)),d&&(x=await m.extractEducationFromDetails(e,t),console.log(` + Education: ${x.length} entries`)),l&&(M=await m.extractSkillsFromDetails(e,t),console.log(` + Skills: ${M.length} entries`)),g&&(F=await m.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${F.length} entries`)),L&&(P=await m.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${P.length} entries`))}return{...p,profileUrl:t,resolvedUrl:S,...h!==null&&{experience:h},...y!==null&&{featured:y},...x!==null&&{education:x},...M!==null&&{skillsFull:M},...F!==null&&{recommendations:F},...P!==null&&{certifications:P}}}catch(I){console.error(`Error viewing profile ${t}:`,I.message);try{await e.goto("about:blank",{timeout:1e4}),await f(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(I.message||""))throw I;return null}}H();var X=process.argv.slice(2),Me=X.filter(e=>e.startsWith("http")),Fe=parseInt(X.find(e=>e.startsWith("--pick="))?.split("=")[1]||"0"),pt=X.includes("--has-about");function ht(e,t){return[...e].sort(()=>Math.random()-.5).slice(0,t)}function gt(){if(Me.length>0)return Me.map(t=>({url:t,name:"(arg)"}));if(Fe>0){let t=Z(),o=Object.entries(t).filter(([n])=>n.startsWith("http")).filter(([,n])=>pt?!!(n.about&&n.about.trim()):!n.about);return ht(o,Fe).map(([n,i])=>({url:n,name:i.name}))}let e=process.env.MY_LINKEDIN_URL;return e||(console.error("Pass a URL, use --pick=N, or set MY_LINKEDIN_URL in .env"),process.exit(1)),[{url:e,name:"(self)"}]}function E(e,t,o=80){if(t==null){console.log(` ${e.padEnd(20)} (null)`);return}let n=String(t),i=n.length>o?n.slice(0,o)+`\u2026 (+${n.length-o} chars)`:n;console.log(` ${e.padEnd(20)} ${i} [len=${n.length}]`)}async function wt(){let e=gt();console.log(`
242
240
  About-selector verification \u2014 ${e.length} profile(s)
243
- `);let{browser:t,page:o}=await we();try{for(let n=0;n<e.length;n++){let{url:s,name:f}=e[n];console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.log(` [${n+1}/${e.length}] ${f}`),console.log(` ${s}`),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");let c=await Ce(o,s);if(!c){console.log(` \u26A0 viewProfile returned null \u2014 selector failed entirely
244
- `);continue}_("name",c.name),_("title",c.title),_("location",c.location),_("company",c.company),_("connectionDegree",c.connectionDegree),_("connectionsCount",c.connectionsCount),_("mutualConnections",c.mutualConnections),_("hasVerifiedBadge",c.hasVerifiedBadge),_("photoUrl",c.photoUrl,60),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 about \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),_("about",c.about,200);let g=[];c.name||g.push("NAME MISSING"),c.title||g.push("TITLE MISSING"),c.location||g.push("LOCATION MISSING"),c.about||g.push("ABOUT MISSING"),console.log(`
241
+ `);let{browser:t,page:o}=await Ie();try{for(let n=0;n<e.length;n++){let{url:i,name:d}=e[n];console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.log(` [${n+1}/${e.length}] ${d}`),console.log(` ${i}`),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");let l=await Le(o,i);if(!l){console.log(` \u26A0 viewProfile returned null \u2014 selector failed entirely
242
+ `);continue}E("name",l.name),E("title",l.title),E("location",l.location),E("company",l.company),E("connectionDegree",l.connectionDegree),E("connectionsCount",l.connectionsCount),E("mutualConnections",l.mutualConnections),E("hasVerifiedBadge",l.hasVerifiedBadge),E("photoUrl",l.photoUrl,60),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 about \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),E("about",l.about,200);let g=[];l.name||g.push("NAME MISSING"),l.title||g.push("TITLE MISSING"),l.location||g.push("LOCATION MISSING"),l.about||g.push("ABOUT MISSING"),console.log(`
245
243
  Verdict: ${g.length===0?"OK \u2014 all core fields present":g.join(", ")}
246
- `),n<e.length-1&&await d(3e3+Math.random()*2e3)}}finally{await t.close().catch(()=>{})}}st().catch(e=>{console.error("verify-about failed:",e),process.exit(1)});
244
+ `),n<e.length-1&&await f(3e3+Math.random()*2e3)}}finally{await t.close().catch(()=>{})}}wt().catch(e=>{console.error("verify-about failed:",e),process.exit(1)});
package/dist/version.mjs CHANGED
@@ -1 +1 @@
1
- import{readFileSync as e}from"fs";import{fileURLToPath as r}from"url";function i(){return"1.17.2";try{let n=new URL("./ilml-plugin.json",import.meta.url);return JSON.parse(e(r(n),"utf-8")).version}catch{return"unknown"}}console.log(`ilml-plugin-linkedin ${i()}`);
1
+ import{readFileSync as e}from"fs";import{fileURLToPath as r}from"url";function i(){return"1.18.0";try{let n=new URL("./ilml-plugin.json",import.meta.url);return JSON.parse(e(r(n),"utf-8")).version}catch{return"unknown"}}console.log(`ilml-plugin-linkedin ${i()}`);