ilml-plugin-linkedin 1.14.3 → 1.14.4

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,6 +1,6 @@
1
- var et=Object.defineProperty;var Ae=(t,e)=>()=>(t&&(e=t(t=0)),e);var tt=(t,e)=>{for(var n in e)et(t,n,{get:e[n],enumerable:!0})};async function w(t){let e=Math.floor(Math.random()*2001),n=t+e;return new Promise(o=>setTimeout(o,n))}async function $e(t){return await t.evaluate(()=>{let e=document.querySelectorAll("div.artdeco-modal--is-open");for(let o of e){let i=o.innerText||"",s=i.includes("Premium")||i.includes("premium")||i.includes("Upgrade")||i.includes("upgrade"),f=i.includes("Try for")||i.includes("free trial")||i.includes("/month")||i.includes("per month")||i.includes("Start my")||i.includes("Subscribe"),d=i.includes("Get hired faster")||i.includes("Get hired 2x");if(s||f||d){let D=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(D)return D.click(),{dismissed:!0,matched:i.substring(0,80)};let $=o.querySelectorAll("button");for(let a of $){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 n=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(n){let o=n.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||n.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(o)return o.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var re=Ae(()=>{});var je={};tt(je,{extractCertificationsFromDetails:()=>St,extractEducationFromDetails:()=>yt,extractExperienceFromDetails:()=>wt,extractFeaturedFromDetails:()=>gt,extractRecommendationsFromDetails:()=>kt,extractSkillsFromDetails:()=>bt});async function wt(t,e){let n=e.replace(/\/+$/,"")+"/details/experience/";try{await t.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let o=t.url();if(/\/(login|authwall|checkpoint)/i.test(o))throw new Error(`Session expired \u2014 bounced to ${o} when fetching /details/experience/`);for(let s=0;s<5;s++)await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(900);await w(1e3);let i=0;for(;i<5&&await t.evaluate(()=>{for(let f of document.querySelectorAll("button"))if(/^Load more$/i.test((f.textContent||"").trim()))return f.click(),!0;return!1});)i++,await w(1500),await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(700);return await t.evaluate(()=>{let s=document.querySelector("main");if(!s)return[];function f(a){let S=[];for(let p of a.querySelectorAll("div")){let h=Array.from(p.children).filter(v=>v.tagName==="DIV");if(h.length<3)continue;let y=h.filter(v=>(v.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 d=f(s);if(!d)return[];let D=Array.from(d.children).filter(a=>a.tagName==="DIV").filter(a=>(a.textContent||"").trim().length>50);function $(a){let S=a[0]||null,p=null,h=null;if(a[1]){let c=a[1].split("\xB7").map(k=>k.trim());p=c[0]||null,c[1]&&(h=c[1])}let y=a.findIndex(c=>/(\d{4}|present)/i.test(c)&&/(-|–|—)/i.test(c)&&c.length<80),v=null,L=null;if(y>=0){let c=a[y].split("\xB7").map(k=>k.trim());v=c[0]||null,c[1]&&(L=c[1])}let T=null,ne=-1;if(y>=0&&a[y+1]){let c=a[y+1],k=/^[>*\-•]|^&gt;/.test(c),P=/https?:\/\//.test(c),x=/\d{4}/.test(c),V=/,/.test(c)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(c);!k&&!P&&!x&&c.length<100&&V&&(T=c,ne=y+1)}let b=null,j=-1,I=a[a.length-1];if(I&&/and\s+\+\d+\s+skills?$/i.test(I)){j=a.length-1;let c=I.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);c&&(b={listed:c[1].split(",").map(k=>k.trim()),additional:parseInt(c[2],10)})}let M=new Set([0,1,y,ne,j].filter(c=>c>=0)),C=a.filter((c,k)=>!M.has(k)),oe=C.length>0?C.join(`
1
+ var et=Object.defineProperty;var Ae=(t,e)=>()=>(t&&(e=t(t=0)),e);var tt=(t,e)=>{for(var n in e)et(t,n,{get:e[n],enumerable:!0})};async function w(t){let e=Math.floor(Math.random()*2001),n=t+e;return new Promise(o=>setTimeout(o,n))}async function $e(t){return await t.evaluate(()=>{let e=document.querySelectorAll("div.artdeco-modal--is-open");for(let o of e){let i=o.innerText||"",s=i.includes("Premium")||i.includes("premium")||i.includes("Upgrade")||i.includes("upgrade"),f=i.includes("Try for")||i.includes("free trial")||i.includes("/month")||i.includes("per month")||i.includes("Start my")||i.includes("Subscribe"),d=i.includes("Get hired faster")||i.includes("Get hired 2x");if(s||f||d){let D=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(D)return D.click(),{dismissed:!0,matched:i.substring(0,80)};let $=o.querySelectorAll("button");for(let a of $){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 n=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(n){let o=n.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||n.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(o)return o.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var re=Ae(()=>{});var je={};tt(je,{extractCertificationsFromDetails:()=>St,extractEducationFromDetails:()=>yt,extractExperienceFromDetails:()=>wt,extractFeaturedFromDetails:()=>gt,extractRecommendationsFromDetails:()=>kt,extractSkillsFromDetails:()=>bt});async function wt(t,e){let n=e.replace(/\/+$/,"")+"/details/experience/";try{await t.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let o=t.url();if(/\/(login|authwall|checkpoint)/i.test(o))throw new Error(`Session expired \u2014 bounced to ${o} when fetching /details/experience/`);for(let s=0;s<5;s++)await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(900);await w(1e3);let i=0;for(;i<5&&await t.evaluate(()=>{for(let f of document.querySelectorAll("button"))if(/^Load more$/i.test((f.textContent||"").trim()))return f.click(),!0;return!1});)i++,await w(1500),await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(700);return await t.evaluate(()=>{let s=document.querySelector("main");if(!s)return[];function f(a){let S=[];for(let p of a.querySelectorAll("div")){let h=Array.from(p.children).filter(v=>v.tagName==="DIV");if(h.length<3)continue;let y=h.filter(v=>(v.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 d=f(s);if(!d)return[];let D=Array.from(d.children).filter(a=>a.tagName==="DIV").filter(a=>(a.textContent||"").trim().length>50);function $(a){let S=a[0]||null,p=null,h=null;if(a[1]){let c=a[1].split("\xB7").map(k=>k.trim());p=c[0]||null,c[1]&&(h=c[1])}let y=a.findIndex(c=>/(\d{4}|present)/i.test(c)&&/(-|–|—)/i.test(c)&&c.length<80),v=null,L=null;if(y>=0){let c=a[y].split("\xB7").map(k=>k.trim());v=c[0]||null,c[1]&&(L=c[1])}let M=null,ne=-1;if(y>=0&&a[y+1]){let c=a[y+1],k=/^[>*\-•]|^&gt;/.test(c),P=/https?:\/\//.test(c),x=/\d{4}/.test(c),V=/,/.test(c)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(c);!k&&!P&&!x&&c.length<100&&V&&(M=c,ne=y+1)}let b=null,j=-1,I=a[a.length-1];if(I&&/and\s+\+\d+\s+skills?$/i.test(I)){j=a.length-1;let c=I.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);c&&(b={listed:c[1].split(",").map(k=>k.trim()),additional:parseInt(c[2],10)})}let F=new Set([0,1,y,ne,j].filter(c=>c>=0)),C=a.filter((c,k)=>!F.has(k)),oe=C.length>0?C.join(`
2
2
 
3
- `):null;return{title:S,company:p,employmentType:h,dates:v,duration:L,location:T,description:oe,skills:b,_raw:a}}return D.map(a=>{let p=(a.innerText||"").trim().split(`
3
+ `):null;return{title:S,company:p,employmentType:h,dates:v,duration:L,location:M,description:oe,skills:b,_raw:a}}return D.map(a=>{let p=(a.innerText||"").trim().split(`
4
4
  `).map(h=>h.trim()).filter(h=>h&&h.length<5e3);return $(p)}).filter(a=>a.title)})}catch(o){if(/session expired|bounced to|authwall|checkpoint/i.test(o.message||""))throw o;return console.error(`extractExperienceFromDetails failed for ${e}: ${o.message?.slice(0,120)}`),[]}}async function B(t,e,n){let o=e.replace(/\/+$/,"")+`/details/${n}/`;await t.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let i=t.url();if(/\/(login|authwall|checkpoint)/i.test(i))throw new Error(`Session expired \u2014 bounced to ${i} when fetching /details/${n}/`);if(!i.toLowerCase().includes(`/details/${n.toLowerCase()}/`))throw new Error(`Section /details/${n}/ not available on profile (landed on ${i})`);for(let f=0;f<4;f++)await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(700);await w(800);let s=0;for(;s<5&&await t.evaluate(()=>{for(let d of document.querySelectorAll("button"))if(/^Load more$/i.test((d.textContent||"").trim()))return d.click(),!0;return!1});)s++,await w(1300),await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(600)}async function U(t,e,n,o){try{return await o()}catch(i){let s=i.message||"";if(/session expired|bounced to|authwall|checkpoint/i.test(s))throw i;return/not available on profile/i.test(s)?(console.log(` (${e}: section not on profile \u2014 skipped)`),[]):(console.error(`${n} failed for ${t}: ${s.slice(0,120)}`),[])}}async function gt(t,e){return U(e,"featured","extractFeaturedFromDetails",async()=>(await B(t,e,"featured"),await t.evaluate(`(() => {
5
5
  ${H}
6
6
 
@@ -235,7 +235,7 @@ 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"dotenv/config";import It from"puppeteer";re();import{getPluginConfig as nt}from"@ilivemylife/graph-sdk";var ot=await nt();for(let[t,e]of Object.entries(ot))process.env[t]===void 0&&(process.env[t]=e);var Lt=process.env.LINKEDIN_NAME,F=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Tt=Object.freeze(new Set([F.DRAFT,F.CONFIRMED,F.NEEDS_REVIEW])),Mt=Object.freeze(new Set([F.DRAFT,F.CONFIRMED,F.REJECTED,F.NEEDS_REVIEW]));import"dotenv/config";import*as m from"fs";import*as g from"path";import{fileURLToPath as it}from"url";var st=it(import.meta.url),rt=g.dirname(g.dirname(st)),A=process.env.DATA_DIR?g.resolve(process.env.DATA_DIR,"collected-profiles"):g.join(rt,"collected-profiles"),le=g.join(A,"people.json"),Pt=g.join(A,"jobs.json"),Ot=g.join(A,"quota.json"),qt=g.join(A,"conversations.json"),Bt=g.join(A,"sync-state.json"),Ht=g.join(A,"application-questions.json"),ae=g.join(A,"profile-history"),Le=(t,e)=>{let n=parseInt(t,10);return Number.isInteger(n)&&n>=0?n:e},Ut=Le(process.env.CONNECT_MAX_DAILY,20),Vt=Le(process.env.CONNECT_MAX_WEEKLY,100),q=null;function Te(){m.existsSync(A)||m.mkdirSync(A,{recursive:!0})}function Me(t,e){let n=JSON.stringify(e,null,2),o=t+".tmp";m.writeFileSync(o,n);for(let i=0;i<3;i++)try{m.renameSync(o,t);return}catch(s){if(i<2&&(s.code==="EPERM"||s.code==="EBUSY")){let f=Date.now();for(;Date.now()-f<200;);continue}throw s}}function Fe(t,e){if(!m.existsSync(t))return null;try{let n=JSON.parse(m.readFileSync(t,"utf-8"));try{m.copyFileSync(t,t+".backup")}catch{}return n}catch(n){console.error(`[!] ${e} is corrupted: ${n.message}`),console.error(` File: ${g.resolve(t)}`);let o=t+".backup";if(m.existsSync(o))try{let i=JSON.parse(m.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{m.copyFileSync(o,t)}catch{}return i}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${t}.corrupted`);try{m.copyFileSync(t,t+".corrupted")}catch{}return null}}function lt(){return new Date().toISOString().split("T")[0]}var at=["name","title","location","company","connectionDegree","connectionsCount","mutualConnections","photoUrl","hasVerifiedBadge","about","currentCompany","currentSchool","connectionsLevel","mutualConnectionsCount","followers","openToWork","hiring","topSkills","availableSections","experience","featuredLinks","_lastEnrichedAt","featured","education","skillsFull","recommendations","certifications"],ct=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"];function ce(t){if(!t)return null;let e=t.match(/\/in\/([^/?#]+)/);return e?e[1].toLowerCase():null}function ut(){m.existsSync(ae)||m.mkdirSync(ae,{recursive:!0})}function Ne(t){let e=ce(t);return e?g.join(ae,`${e}.json`):null}function dt(t){let e=Ne(t);return e?Fe(e,`profile-history/${ce(t)}.json`)||[]:[]}function ft(t,e){let n=Ne(t);if(!n)return;ut();let o=dt(t);o.unshift(e);try{Me(n,o)}catch(i){console.error(`[!] Failed to append profile-history for ${ce(t)}: ${i.message}`)}}function _e(t){return!!(t==null||Array.isArray(t)&&t.length===0||typeof t=="string"&&!t.trim())}function De(t){return Array.isArray(t)?[...t].map(e=>String(e).trim()).sort().join("||"):typeof t=="string"?t.replace(/\s+/g," ").trim():t}function mt(t,e){if(!t)return[];let n=[];for(let o of ct){let i=t[o],s=e[o];_e(i)||_e(s)||De(i)!==De(s)&&n.push(o)}return n}function pt(t){let e=new Set(["seenCount","sources","firstSeen","lastSeen","lastUpdated","encounters","jobIds","lastFullVisitAt","lastSnapshotAt","messageSent","connectionStatus","connectionDate","connectionMethod"]),n={};for(let[o,i]of Object.entries(t))e.has(o)||(n[o]=i);return n}function Re(){return q||(Te(),q=Fe(le,"people.json")||{},q)}function ht(t){Te(),q=t;try{Me(le,t)}catch(e){console.error(`[!] Failed to save people.json: ${e.message}`),console.error(` Path: ${g.resolve(le)}`)}}function ue(t,e={}){if(!t)return null;let n=Re(),o=lt(),i=new Date().toISOString(),s=n[t];if(s){let f=mt(s,e);f.length>0&&(ft(t,{capturedAt:i,previousLastUpdated:s.lastUpdated||null,changedFields:f,snapshot:pt(s)}),s.lastSnapshotAt=i),s.seenCount=(s.seenCount||1)+1,s.lastSeen=o,s.lastUpdated=i,e.source&&!s.sources?.includes(e.source)&&(s.sources=s.sources||[],s.sources.push(e.source));for(let d of at)if(e[d]!=null){if(Array.isArray(e[d])&&e[d].length===0&&Array.isArray(s[d])&&s[d].length>0)continue;s[d]=e[d]}Array.isArray(e.availableSections)&&(s.lastFullVisitAt=i)}else n[t]={name:e.name||null,title:e.title||null,location:e.location||null,company:e.company||null,about:e.about||null,connectionDegree:e.connectionDegree||null,connectionsCount:e.connectionsCount||null,mutualConnections:e.mutualConnections||null,photoUrl:e.photoUrl||null,hasVerifiedBadge:e.hasVerifiedBadge||!1,currentCompany:e.currentCompany||null,currentSchool:e.currentSchool||null,connectionsLevel:e.connectionsLevel||null,mutualConnectionsCount:e.mutualConnectionsCount||null,followers:e.followers||null,openToWork:e.openToWork||!1,hiring:e.hiring||!1,topSkills:e.topSkills||null,availableSections:e.availableSections||null,experience:e.experience||null,featuredLinks:e.featuredLinks||null,_lastEnrichedAt:e._lastEnrichedAt||null,featured:e.featured||null,education:e.education||null,skillsFull:e.skillsFull||null,recommendations:e.recommendations||null,certifications:e.certifications||null,firstSeen:o,lastSeen:o,seenCount:1,sources:e.source?[e.source]:[],connectionStatus:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:i,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(e.availableSections)?i:null};return ht(n),n[t]}async function Ct(t,e){let n=t.url();if(n.includes("/in/"))return!1;if(n.includes("/login")||n.includes("/authwall")||n.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${n.slice(0,80)}`),console.log(" Navigating back to profile..."),await t.goto(e,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let o=t.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function Oe(t,e,n={}){let{extractExperience:o=!1,extractFeatured:i=!1,extractEducation:s=!1,extractSkills:f=!1,extractRecommendations:d=!1,extractCertifications:D=!1}=n;try{await t.goto(e,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3),await $e(t)&&(console.log(" Dismissed Premium overlay"),await w(1500),await Ct(t,e));let a=0;for(let b=0;b<2;b++){let j=await t.evaluate(()=>document.body.scrollHeight);for(let M=1;M<=6;M++)await t.evaluate(C=>window.scrollTo(0,C),j*M/6),await w(900);let I=await t.evaluate(()=>document.body.scrollHeight);if(I===a)break;a=I}await w(800);let S=await t.evaluate(()=>{let b=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"]),j=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"]),I=r=>{let l=(r||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(l)},M={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:[]},C=document.querySelector("main");if(!C)return M;let oe=[...Array.from(C.querySelectorAll("h1")),...Array.from(C.querySelectorAll("h2"))],c=Array.from(C.querySelectorAll("h2")),k=oe.find(r=>{let l=r.textContent&&r.textContent.trim(),u=(l||"").replace(/\s*\(\d+\)$/,"").trim();return l&&l.length>1&&l.length<100&&!b.has(u)&&!j.has(u)}),P=k?k.textContent.trim():null,x=k?k.parentElement:null;for(;x&&x!==C&&!Array.from(x.children).filter(l=>l.tagName==="P").some(l=>{let u=l.textContent&&l.textContent.trim();return u&&u.length>5&&!I(u)});)x=x.parentElement;let V=null,pe=null,he=null,ie=null;if(x&&x!==C){let r=Array.from(x.children).filter(u=>u.tagName==="P").filter(u=>{let _=u.textContent&&u.textContent.trim();return _&&_.length>5&&!I(_)});if(r[0]&&(V=r[0].textContent.trim()),r[1]){let u=r[1].textContent.trim().split(/\s*[·•]\s*/);pe=u[0]||null,u.length>1&&(he=u.slice(1).join(" \xB7 "))}let l=Array.from(x.children).filter(u=>u.tagName==="DIV");for(let u=l.length-1;u>=0;u--){let _=l[u].textContent&&l[u].textContent.trim();if(_&&!(P&&_.startsWith(P))&&(ie=_.split(/[·•]/)[0].trim(),ie))break}}let we=null;if(x){let r=x.querySelectorAll("p, span, div");for(let l of r){let u=(l.textContent||"").trim().replace(/^[·•]\s*/,"");if(u==="1st"||u==="2nd"||u==="3rd"){we=u;break}}}let Ke=!!C.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),ge=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),Ye=ge&&ge.src||null,W=C.textContent||"",ye=null,be=W.match(/(\d+\+?)\s+connections\b/i);be&&(ye=be[1]+" connections");let J=null,Se=W.match(/(\d+)\s+mutual connection/i),ke=W.match(/and\s+(\d+)\s+other mutual/i),Ge=W.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Se?J=parseInt(Se[1],10):ke?J=2+parseInt(ke[1],10):Ge&&(J=2);let Ce=null,xe=null,ve=c.find(r=>r.textContent&&r.textContent.trim()==="About");if(ve){let r=ve.parentElement;for(;r&&r.tagName!=="SECTION";)r=r.parentElement;if(r){let l=(r.textContent||"").trim();l=l.replace(/^About\s*/,"").trim();let u=l.match(/Top skills\s*(.+?)$/i);if(u){let se=u[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Xe=>Xe.trim()).filter(Boolean);se.length>0&&se.length<10&&(xe=se)}l=l.split(/\n?…\s*more/i)[0].trim(),l=l.split(/\n?\.\.\.\s*more/i)[0].trim(),l=l.split(/\bTop skills\b/i)[0].trim(),l=l.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Ce=l||null}}let Ee=null,Ie=c.find(r=>r.textContent&&r.textContent.trim()==="Activity");if(Ie){let r=Ie.parentElement;for(;r&&r.tagName!=="SECTION";)r=r.parentElement;if(r){let l=(r.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);l&&(Ee=parseInt(l[1].replace(/,/g,""),10))}}let Qe=[...new Set(c.map(r=>(r.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(r=>r&&r.length>1&&r.length<60&&r!==P).filter(r=>b.has(r)))],O=document.body.textContent||"",ze=/#OpenToWork\b/i.test(O)||/\bOpen to work\b/.test(O),Ze=/#Hiring\b/i.test(O)||/\bI'?m hiring\b/i.test(O)||/\bWe are hiring\b/i.test(O);return{name:P,title:V,location:ie,currentCompany:pe,currentSchool:he,connectionDegree:we,hasVerifiedBadge:Ke,photoUrl:Ye,connectionsLevel:ye,mutualConnectionsCount:J,followers:Ee,openToWork:ze,hiring:Ze,about:Ce,topSkills:xe,availableSections:Qe}});console.log(`Viewed: ${S.name} - ${S.title}`);let p=null,h=null,y=null,v=null,L=null,T=null;if(o||i||s||f||d||D){let b=await Promise.resolve().then(()=>(Pe(),je));o&&(p=await b.extractExperienceFromDetails(t,e),console.log(` + Experience: ${p.length} entries`)),i&&(h=await b.extractFeaturedFromDetails(t,e),console.log(` + Featured: ${h.length} entries`)),s&&(y=await b.extractEducationFromDetails(t,e),console.log(` + Education: ${y.length} entries`)),f&&(v=await b.extractSkillsFromDetails(t,e),console.log(` + Skills: ${v.length} entries`)),d&&(L=await b.extractRecommendationsFromDetails(t,e),console.log(` + Recommendations: ${L.length} entries`)),D&&(T=await b.extractCertificationsFromDetails(t,e),console.log(` + Certifications: ${T.length} entries`))}return{...S,profileUrl:e,...p!==null&&{experience:p},...h!==null&&{featured:h},...y!==null&&{education:y},...v!==null&&{skillsFull:v},...L!==null&&{recommendations:L},...T!==null&&{certifications:T}}}catch($){console.error(`Error viewing profile ${e}:`,$.message);try{await t.goto("about:blank",{timeout:1e4}),await w(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test($.message||""))throw $;return null}}import qe from"fs";import xt from"path";var vt="cookies.json";function Et(){let t=process.env.ILML_SCOPE_DIR;return t?xt.join(t,"plugins-state","linkedin","cookies.json"):vt}function Be(){let t=Et();if(!qe.existsSync(t))throw new Error(`Cookies not found at ${t}. Run: ilml linkedin login`);let e;try{e=qe.readFileSync(t,"utf-8")}catch(o){throw new Error(`Failed to read cookies at ${t}: ${o.message}. Run: ilml linkedin login`)}let n;try{n=JSON.parse(e)}catch{throw new Error(`Cookies file at ${t} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(n)||n.length===0)throw new Error(`Cookies file at ${t} is empty or not an array. Run: ilml linkedin login`);return n}function He(t){return t?t.replace(/^https?:\/\/(www\.|m\.)?linkedin\.com/i,"https://linkedin.com").split("?")[0].split("#")[0].replace(/\/+$/,"").toLowerCase():""}function Ue(t){return(t||"").replace(/ /g," ").replace(/\s+/g," ").trim().toLowerCase()}var E=process.argv.slice(2),At=E.includes("--help")||E.includes("-h"),N=E.find(t=>t.startsWith("http")),R=E.includes("--full"),Y=R||E.includes("--with-experience"),G=R||E.includes("--with-featured"),Q=R||E.includes("--with-education"),z=R||E.includes("--with-skills"),Z=R||E.includes("--with-recommendations"),X=R||E.includes("--with-certifications"),Ve=[["experience",Y],["featured",G],["education",Q],["skills",z],["recommendations",Z],["certifications",X]],We=Ve.filter(([,t])=>t).length,fe=1+We;function Je(){console.log(`
238
+ `});import"dotenv/config";import It from"puppeteer";re();import{getPluginConfig as nt}from"@ilivemylife/graph-sdk";var ot=await nt();for(let[t,e]of Object.entries(ot))process.env[t]===void 0&&(process.env[t]=e);var Lt=process.env.LINKEDIN_NAME,T=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Mt=Object.freeze(new Set([T.DRAFT,T.CONFIRMED,T.NEEDS_REVIEW])),Ft=Object.freeze(new Set([T.DRAFT,T.CONFIRMED,T.REJECTED,T.NEEDS_REVIEW]));import"dotenv/config";import*as m from"fs";import*as g from"path";import{fileURLToPath as it}from"url";var st=it(import.meta.url),rt=g.dirname(g.dirname(st)),A=process.env.DATA_DIR?g.resolve(process.env.DATA_DIR,"collected-profiles"):g.join(rt,"collected-profiles"),le=g.join(A,"people.json"),Pt=g.join(A,"jobs.json"),Ot=g.join(A,"quota.json"),qt=g.join(A,"conversations.json"),Bt=g.join(A,"sync-state.json"),Ht=g.join(A,"application-questions.json"),ae=g.join(A,"profile-history"),Le=(t,e)=>{let n=parseInt(t,10);return Number.isInteger(n)&&n>=0?n:e},Ut=Le(process.env.CONNECT_MAX_DAILY,20),Vt=Le(process.env.CONNECT_MAX_WEEKLY,100),q=null;function Me(){m.existsSync(A)||m.mkdirSync(A,{recursive:!0})}function Fe(t,e){let n=JSON.stringify(e,null,2),o=t+".tmp";m.writeFileSync(o,n);for(let i=0;i<3;i++)try{m.renameSync(o,t);return}catch(s){if(i<2&&(s.code==="EPERM"||s.code==="EBUSY")){let f=Date.now();for(;Date.now()-f<200;);continue}throw s}}function Te(t,e){if(!m.existsSync(t))return null;try{let n=JSON.parse(m.readFileSync(t,"utf-8"));try{m.copyFileSync(t,t+".backup")}catch{}return n}catch(n){console.error(`[!] ${e} is corrupted: ${n.message}`),console.error(` File: ${g.resolve(t)}`);let o=t+".backup";if(m.existsSync(o))try{let i=JSON.parse(m.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{m.copyFileSync(o,t)}catch{}return i}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${t}.corrupted`);try{m.copyFileSync(t,t+".corrupted")}catch{}return null}}function lt(){return new Date().toISOString().split("T")[0]}var at=["name","title","location","company","connectionDegree","connectionsCount","mutualConnections","photoUrl","hasVerifiedBadge","about","currentCompany","currentSchool","connectionsLevel","mutualConnectionsCount","followers","openToWork","hiring","topSkills","availableSections","experience","featuredLinks","_lastEnrichedAt","featured","education","skillsFull","recommendations","certifications"],ct=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"];function ce(t){if(!t)return null;let e=t.match(/\/in\/([^/?#]+)/);return e?e[1].toLowerCase():null}function ut(){m.existsSync(ae)||m.mkdirSync(ae,{recursive:!0})}function Ne(t){let e=ce(t);return e?g.join(ae,`${e}.json`):null}function dt(t){let e=Ne(t);return e?Te(e,`profile-history/${ce(t)}.json`)||[]:[]}function ft(t,e){let n=Ne(t);if(!n)return;ut();let o=dt(t);o.unshift(e);try{Fe(n,o)}catch(i){console.error(`[!] Failed to append profile-history for ${ce(t)}: ${i.message}`)}}function _e(t){return!!(t==null||Array.isArray(t)&&t.length===0||typeof t=="string"&&!t.trim())}function De(t){return Array.isArray(t)?[...t].map(e=>String(e).trim()).sort().join("||"):typeof t=="string"?t.replace(/\s+/g," ").trim():t}function mt(t,e){if(!t)return[];let n=[];for(let o of ct){let i=t[o],s=e[o];_e(i)||_e(s)||De(i)!==De(s)&&n.push(o)}return n}function pt(t){let e=new Set(["seenCount","sources","firstSeen","lastSeen","lastUpdated","encounters","jobIds","lastFullVisitAt","lastSnapshotAt","messageSent","connectionStatus","connectionDate","connectionMethod"]),n={};for(let[o,i]of Object.entries(t))e.has(o)||(n[o]=i);return n}function Re(){return q||(Me(),q=Te(le,"people.json")||{},q)}function ht(t){Me(),q=t;try{Fe(le,t)}catch(e){console.error(`[!] Failed to save people.json: ${e.message}`),console.error(` Path: ${g.resolve(le)}`)}}function ue(t,e={}){if(!t)return null;let n=Re(),o=lt(),i=new Date().toISOString(),s=n[t];if(s){let f=mt(s,e);f.length>0&&(ft(t,{capturedAt:i,previousLastUpdated:s.lastUpdated||null,changedFields:f,snapshot:pt(s)}),s.lastSnapshotAt=i),s.seenCount=(s.seenCount||1)+1,s.lastSeen=o,s.lastUpdated=i,e.source&&!s.sources?.includes(e.source)&&(s.sources=s.sources||[],s.sources.push(e.source));for(let d of at)if(e[d]!=null){if(Array.isArray(e[d])&&e[d].length===0&&Array.isArray(s[d])&&s[d].length>0)continue;s[d]=e[d]}Array.isArray(e.availableSections)&&(s.lastFullVisitAt=i)}else n[t]={name:e.name||null,title:e.title||null,location:e.location||null,company:e.company||null,about:e.about||null,connectionDegree:e.connectionDegree||null,connectionsCount:e.connectionsCount||null,mutualConnections:e.mutualConnections||null,photoUrl:e.photoUrl||null,hasVerifiedBadge:e.hasVerifiedBadge||!1,currentCompany:e.currentCompany||null,currentSchool:e.currentSchool||null,connectionsLevel:e.connectionsLevel||null,mutualConnectionsCount:e.mutualConnectionsCount||null,followers:e.followers||null,openToWork:e.openToWork||!1,hiring:e.hiring||!1,topSkills:e.topSkills||null,availableSections:e.availableSections||null,experience:e.experience||null,featuredLinks:e.featuredLinks||null,_lastEnrichedAt:e._lastEnrichedAt||null,featured:e.featured||null,education:e.education||null,skillsFull:e.skillsFull||null,recommendations:e.recommendations||null,certifications:e.certifications||null,firstSeen:o,lastSeen:o,seenCount:1,sources:e.source?[e.source]:[],connectionStatus:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:i,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(e.availableSections)?i:null};return ht(n),n[t]}async function Ct(t,e){let n=t.url();if(n.includes("/in/"))return!1;if(n.includes("/login")||n.includes("/authwall")||n.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${n.slice(0,80)}`),console.log(" Navigating back to profile..."),await t.goto(e,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let o=t.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function Oe(t,e,n={}){let{extractExperience:o=!1,extractFeatured:i=!1,extractEducation:s=!1,extractSkills:f=!1,extractRecommendations:d=!1,extractCertifications:D=!1}=n;try{await t.goto(e,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3),await $e(t)&&(console.log(" Dismissed Premium overlay"),await w(1500),await Ct(t,e));let a=0;for(let b=0;b<2;b++){let j=await t.evaluate(()=>document.body.scrollHeight);for(let F=1;F<=6;F++)await t.evaluate(C=>window.scrollTo(0,C),j*F/6),await w(900);let I=await t.evaluate(()=>document.body.scrollHeight);if(I===a)break;a=I}await w(800);let S=await t.evaluate(()=>{let b=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"]),j=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"]),I=r=>{let l=(r||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(l)},F={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:[]},C=document.querySelector("main");if(!C)return F;let oe=[...Array.from(C.querySelectorAll("h1")),...Array.from(C.querySelectorAll("h2"))],c=Array.from(C.querySelectorAll("h2")),k=oe.find(r=>{let l=r.textContent&&r.textContent.trim(),u=(l||"").replace(/\s*\(\d+\)$/,"").trim();return l&&l.length>1&&l.length<100&&!b.has(u)&&!j.has(u)}),P=k?k.textContent.trim():null,x=k?k.parentElement:null;for(;x&&x!==C&&!Array.from(x.children).filter(l=>l.tagName==="P").some(l=>{let u=l.textContent&&l.textContent.trim();return u&&u.length>5&&!I(u)});)x=x.parentElement;let V=null,pe=null,he=null,ie=null;if(x&&x!==C){let r=Array.from(x.children).filter(u=>u.tagName==="P").filter(u=>{let _=u.textContent&&u.textContent.trim();return _&&_.length>5&&!I(_)});if(r[0]&&(V=r[0].textContent.trim()),r[1]){let u=r[1].textContent.trim().split(/\s*[·•]\s*/);pe=u[0]||null,u.length>1&&(he=u.slice(1).join(" \xB7 "))}let l=Array.from(x.children).filter(u=>u.tagName==="DIV");for(let u=l.length-1;u>=0;u--){let _=l[u].textContent&&l[u].textContent.trim();if(_&&!(P&&_.startsWith(P))&&(ie=_.split(/[·•]/)[0].trim(),ie))break}}let we=null;if(x){let r=x.querySelectorAll("p, span, div");for(let l of r){let u=(l.textContent||"").trim().replace(/^[·•]\s*/,"");if(u==="1st"||u==="2nd"||u==="3rd"){we=u;break}}}let Ke=!!C.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),ge=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),Ye=ge&&ge.src||null,W=C.textContent||"",ye=null,be=W.match(/(\d+\+?)\s+connections\b/i);be&&(ye=be[1]+" connections");let J=null,Se=W.match(/(\d+)\s+mutual connection/i),ke=W.match(/and\s+(\d+)\s+other mutual/i),Ge=W.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Se?J=parseInt(Se[1],10):ke?J=2+parseInt(ke[1],10):Ge&&(J=2);let Ce=null,xe=null,ve=c.find(r=>r.textContent&&r.textContent.trim()==="About");if(ve){let r=ve.parentElement;for(;r&&r.tagName!=="SECTION";)r=r.parentElement;if(r){let l=(r.textContent||"").trim();l=l.replace(/^About\s*/,"").trim();let u=l.match(/Top skills\s*(.+?)$/i);if(u){let se=u[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Xe=>Xe.trim()).filter(Boolean);se.length>0&&se.length<10&&(xe=se)}l=l.split(/\n?…\s*more/i)[0].trim(),l=l.split(/\n?\.\.\.\s*more/i)[0].trim(),l=l.split(/\bTop skills\b/i)[0].trim(),l=l.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Ce=l||null}}let Ee=null,Ie=c.find(r=>r.textContent&&r.textContent.trim()==="Activity");if(Ie){let r=Ie.parentElement;for(;r&&r.tagName!=="SECTION";)r=r.parentElement;if(r){let l=(r.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);l&&(Ee=parseInt(l[1].replace(/,/g,""),10))}}let Qe=[...new Set(c.map(r=>(r.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(r=>r&&r.length>1&&r.length<60&&r!==P).filter(r=>b.has(r)))],O=document.body.textContent||"",ze=/#OpenToWork\b/i.test(O)||/\bOpen to work\b/.test(O),Ze=/#Hiring\b/i.test(O)||/\bI'?m hiring\b/i.test(O)||/\bWe are hiring\b/i.test(O);return{name:P,title:V,location:ie,currentCompany:pe,currentSchool:he,connectionDegree:we,hasVerifiedBadge:Ke,photoUrl:Ye,connectionsLevel:ye,mutualConnectionsCount:J,followers:Ee,openToWork:ze,hiring:Ze,about:Ce,topSkills:xe,availableSections:Qe}});console.log(`Viewed: ${S.name} - ${S.title}`);let p=null,h=null,y=null,v=null,L=null,M=null;if(o||i||s||f||d||D){let b=await Promise.resolve().then(()=>(Pe(),je));o&&(p=await b.extractExperienceFromDetails(t,e),console.log(` + Experience: ${p.length} entries`)),i&&(h=await b.extractFeaturedFromDetails(t,e),console.log(` + Featured: ${h.length} entries`)),s&&(y=await b.extractEducationFromDetails(t,e),console.log(` + Education: ${y.length} entries`)),f&&(v=await b.extractSkillsFromDetails(t,e),console.log(` + Skills: ${v.length} entries`)),d&&(L=await b.extractRecommendationsFromDetails(t,e),console.log(` + Recommendations: ${L.length} entries`)),D&&(M=await b.extractCertificationsFromDetails(t,e),console.log(` + Certifications: ${M.length} entries`))}return{...S,profileUrl:e,...p!==null&&{experience:p},...h!==null&&{featured:h},...y!==null&&{education:y},...v!==null&&{skillsFull:v},...L!==null&&{recommendations:L},...M!==null&&{certifications:M}}}catch($){console.error(`Error viewing profile ${e}:`,$.message);try{await t.goto("about:blank",{timeout:1e4}),await w(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test($.message||""))throw $;return null}}import qe from"fs";import xt from"path";var vt="cookies.json";function Et(){let t=process.env.ILML_SCOPE_DIR;return t?xt.join(t,"plugins-state","linkedin","cookies.json"):vt}function Be(){let t=Et();if(!qe.existsSync(t))throw new Error(`Cookies not found at ${t}. Run: ilml linkedin login`);let e;try{e=qe.readFileSync(t,"utf-8")}catch(o){throw new Error(`Failed to read cookies at ${t}: ${o.message}. Run: ilml linkedin login`)}let n;try{n=JSON.parse(e)}catch{throw new Error(`Cookies file at ${t} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(n)||n.length===0)throw new Error(`Cookies file at ${t} is empty or not an array. Run: ilml linkedin login`);return n}function He(t){return t?t.replace(/^https?:\/\/(www\.|m\.)?linkedin\.com/i,"https://linkedin.com").split("?")[0].split("#")[0].replace(/\/+$/,"").toLowerCase():""}function Ue(t){return(t||"").replace(/ /g," ").replace(/\s+/g," ").trim().toLowerCase()}var E=process.argv.slice(2),At=E.includes("--help")||E.includes("-h"),N=E.find(t=>t.startsWith("http")),R=E.includes("--full"),Y=R||E.includes("--with-experience"),G=R||E.includes("--with-featured"),Q=R||E.includes("--with-education"),z=R||E.includes("--with-skills"),Z=R||E.includes("--with-recommendations"),X=R||E.includes("--with-certifications"),Ve=[["experience",Y],["featured",G],["education",Q],["skills",z],["recommendations",Z],["certifications",X]],We=Ve.filter(([,t])=>t).length,fe=1+We;function Je(){console.log(`
239
239
  enrich-profile \u2014 visit ONE LinkedIn profile and save what we learn
240
240
 
241
241
  USAGE
@@ -1,7 +1,7 @@
1
- var Gt=Object.defineProperty;var nt=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{for(var n in t)Gt(e,n,{get:t[n],enumerable:!0})};async function k(e){let t=Math.floor(Math.random()*2001),n=e+t;return new Promise(o=>setTimeout(o,n))}async function ot(e){return await e.evaluate(()=>{let t=document.querySelectorAll("div.artdeco-modal--is-open");for(let o of t){let r=o.innerText||"",s=r.includes("Premium")||r.includes("premium")||r.includes("Upgrade")||r.includes("upgrade"),l=r.includes("Try for")||r.includes("free trial")||r.includes("/month")||r.includes("per month")||r.includes("Start my")||r.includes("Subscribe"),i=r.includes("Get hired faster")||r.includes("Get hired 2x");if(s||l||i){let a=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(a)return a.click(),{dismissed:!0,matched:r.substring(0,80)};let f=o.querySelectorAll("button");for(let c of f){let m=c.innerText?.trim().toLowerCase()||"",d=c.getAttribute("aria-label")?.toLowerCase()||"";if(m==="not now"||m==="no thanks"||m==="dismiss"||d.includes("dismiss"))return c.click(),{dismissed:!0,matched:r.substring(0,80)}}}}let n=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(n){let o=n.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||n.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(o)return o.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var ie=nt(()=>{});var pt={};pe(pt,{extractCertificationsFromDetails:()=>En,extractEducationFromDetails:()=>xn,extractExperienceFromDetails:()=>kn,extractFeaturedFromDetails:()=>Cn,extractRecommendationsFromDetails:()=>An,extractSkillsFromDetails:()=>$n});async function kn(e,t){let n=t.replace(/\/+$/,"")+"/details/experience/";try{await e.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3);let o=e.url();if(/\/(login|authwall|checkpoint)/i.test(o))throw new Error(`Session expired \u2014 bounced to ${o} when fetching /details/experience/`);for(let s=0;s<5;s++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await k(900);await k(1e3);let r=0;for(;r<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});)r++,await k(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await k(700);return await e.evaluate(()=>{let s=document.querySelector("main");if(!s)return[];function l(c){let m=[];for(let d of c.querySelectorAll("div")){let p=Array.from(d.children).filter(b=>b.tagName==="DIV");if(p.length<3)continue;let v=p.filter(b=>(b.textContent||"").trim().length>50);v.length<3||(d.textContent||"").length<500||m.push({el:d,count:v.length,totalText:(d.textContent||"").length})}return m.sort((d,p)=>p.count-d.count||d.totalText-p.totalText),m[0]?.el}let i=l(s);if(!i)return[];let a=Array.from(i.children).filter(c=>c.tagName==="DIV").filter(c=>(c.textContent||"").trim().length>50);function f(c){let m=c[0]||null,d=null,p=null;if(c[1]){let y=c[1].split("\xB7").map(A=>A.trim());d=y[0]||null,y[1]&&(p=y[1])}let v=c.findIndex(y=>/(\d{4}|present)/i.test(y)&&/(-|–|—)/i.test(y)&&y.length<80),b=null,E=null;if(v>=0){let y=c[v].split("\xB7").map(A=>A.trim());b=y[0]||null,y[1]&&(E=y[1])}let J=null,we=-1;if(v>=0&&c[v+1]){let y=c[v+1],A=/^[>*\-•]|^&gt;/.test(y),ne=/https?:\/\//.test(y),T=/\d{4}/.test(y),de=/,/.test(y)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(y);!A&&!ne&&!T&&y.length<100&&de&&(J=y,we=v+1)}let $=null,te=-1,P=c[c.length-1];if(P&&/and\s+\+\d+\s+skills?$/i.test(P)){te=c.length-1;let y=P.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);y&&($={listed:y[1].split(",").map(A=>A.trim()),additional:parseInt(y[2],10)})}let G=new Set([0,1,v,we,te].filter(y=>y>=0)),I=c.filter((y,A)=>!G.has(A)),be=I.length>0?I.join(`
1
+ var Gt=Object.defineProperty;var nt=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{for(var n in t)Gt(e,n,{get:t[n],enumerable:!0})};async function k(e){let t=Math.floor(Math.random()*2001),n=e+t;return new Promise(o=>setTimeout(o,n))}async function ot(e){return await e.evaluate(()=>{let t=document.querySelectorAll("div.artdeco-modal--is-open");for(let o of t){let s=o.innerText||"",r=s.includes("Premium")||s.includes("premium")||s.includes("Upgrade")||s.includes("upgrade"),l=s.includes("Try for")||s.includes("free trial")||s.includes("/month")||s.includes("per month")||s.includes("Start my")||s.includes("Subscribe"),i=s.includes("Get hired faster")||s.includes("Get hired 2x");if(r||l||i){let a=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(a)return a.click(),{dismissed:!0,matched:s.substring(0,80)};let f=o.querySelectorAll("button");for(let c of f){let m=c.innerText?.trim().toLowerCase()||"",d=c.getAttribute("aria-label")?.toLowerCase()||"";if(m==="not now"||m==="no thanks"||m==="dismiss"||d.includes("dismiss"))return c.click(),{dismissed:!0,matched:s.substring(0,80)}}}}let n=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(n){let o=n.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||n.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(o)return o.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var ie=nt(()=>{});var pt={};pe(pt,{extractCertificationsFromDetails:()=>En,extractEducationFromDetails:()=>xn,extractExperienceFromDetails:()=>kn,extractFeaturedFromDetails:()=>Cn,extractRecommendationsFromDetails:()=>An,extractSkillsFromDetails:()=>$n});async function kn(e,t){let n=t.replace(/\/+$/,"")+"/details/experience/";try{await e.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3);let o=e.url();if(/\/(login|authwall|checkpoint)/i.test(o))throw new Error(`Session expired \u2014 bounced to ${o} when fetching /details/experience/`);for(let r=0;r<5;r++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await k(900);await k(1e3);let s=0;for(;s<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});)s++,await k(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await k(700);return await e.evaluate(()=>{let r=document.querySelector("main");if(!r)return[];function l(c){let m=[];for(let d of c.querySelectorAll("div")){let p=Array.from(d.children).filter(b=>b.tagName==="DIV");if(p.length<3)continue;let v=p.filter(b=>(b.textContent||"").trim().length>50);v.length<3||(d.textContent||"").length<500||m.push({el:d,count:v.length,totalText:(d.textContent||"").length})}return m.sort((d,p)=>p.count-d.count||d.totalText-p.totalText),m[0]?.el}let i=l(r);if(!i)return[];let a=Array.from(i.children).filter(c=>c.tagName==="DIV").filter(c=>(c.textContent||"").trim().length>50);function f(c){let m=c[0]||null,d=null,p=null;if(c[1]){let y=c[1].split("\xB7").map(A=>A.trim());d=y[0]||null,y[1]&&(p=y[1])}let v=c.findIndex(y=>/(\d{4}|present)/i.test(y)&&/(-|–|—)/i.test(y)&&y.length<80),b=null,E=null;if(v>=0){let y=c[v].split("\xB7").map(A=>A.trim());b=y[0]||null,y[1]&&(E=y[1])}let J=null,we=-1;if(v>=0&&c[v+1]){let y=c[v+1],A=/^[>*\-•]|^&gt;/.test(y),ne=/https?:\/\//.test(y),T=/\d{4}/.test(y),de=/,/.test(y)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(y);!A&&!ne&&!T&&y.length<100&&de&&(J=y,we=v+1)}let $=null,te=-1,P=c[c.length-1];if(P&&/and\s+\+\d+\s+skills?$/i.test(P)){te=c.length-1;let y=P.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);y&&($={listed:y[1].split(",").map(A=>A.trim()),additional:parseInt(y[2],10)})}let G=new Set([0,1,v,we,te].filter(y=>y>=0)),I=c.filter((y,A)=>!G.has(A)),be=I.length>0?I.join(`
2
2
 
3
3
  `):null;return{title:m,company:d,employmentType:p,dates:b,duration:E,location:J,description:be,skills:$,_raw:c}}return a.map(c=>{let d=(c.innerText||"").trim().split(`
4
- `).map(p=>p.trim()).filter(p=>p&&p.length<5e3);return f(d)}).filter(c=>c.title)})}catch(o){if(/session expired|bounced to|authwall|checkpoint/i.test(o.message||""))throw o;return console.error(`extractExperienceFromDetails failed for ${t}: ${o.message?.slice(0,120)}`),[]}}async function le(e,t,n){let o=t.replace(/\/+$/,"")+`/details/${n}/`;await e.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3);let r=e.url();if(/\/(login|authwall|checkpoint)/i.test(r))throw new Error(`Session expired \u2014 bounced to ${r} when fetching /details/${n}/`);if(!r.toLowerCase().includes(`/details/${n.toLowerCase()}/`))throw new Error(`Section /details/${n}/ not available on profile (landed on ${r})`);for(let l=0;l<4;l++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await k(700);await k(800);let s=0;for(;s<5&&await e.evaluate(()=>{for(let i of document.querySelectorAll("button"))if(/^Load more$/i.test((i.textContent||"").trim()))return i.click(),!0;return!1});)s++,await k(1300),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await k(600)}async function ce(e,t,n,o){try{return await o()}catch(r){let s=r.message||"";if(/session expired|bounced to|authwall|checkpoint/i.test(s))throw r;return/not available on profile/i.test(s)?(console.log(` (${t}: section not on profile \u2014 skipped)`),[]):(console.error(`${n} failed for ${e}: ${s.slice(0,120)}`),[])}}async function Cn(e,t){return ce(t,"featured","extractFeaturedFromDetails",async()=>(await le(e,t,"featured"),await e.evaluate(`(() => {
4
+ `).map(p=>p.trim()).filter(p=>p&&p.length<5e3);return f(d)}).filter(c=>c.title)})}catch(o){if(/session expired|bounced to|authwall|checkpoint/i.test(o.message||""))throw o;return console.error(`extractExperienceFromDetails failed for ${t}: ${o.message?.slice(0,120)}`),[]}}async function le(e,t,n){let o=t.replace(/\/+$/,"")+`/details/${n}/`;await e.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3);let s=e.url();if(/\/(login|authwall|checkpoint)/i.test(s))throw new Error(`Session expired \u2014 bounced to ${s} when fetching /details/${n}/`);if(!s.toLowerCase().includes(`/details/${n.toLowerCase()}/`))throw new Error(`Section /details/${n}/ not available on profile (landed on ${s})`);for(let l=0;l<4;l++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await k(700);await k(800);let r=0;for(;r<5&&await e.evaluate(()=>{for(let i of document.querySelectorAll("button"))if(/^Load more$/i.test((i.textContent||"").trim()))return i.click(),!0;return!1});)r++,await k(1300),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await k(600)}async function ce(e,t,n,o){try{return await o()}catch(s){let r=s.message||"";if(/session expired|bounced to|authwall|checkpoint/i.test(r))throw s;return/not available on profile/i.test(r)?(console.log(` (${t}: section not on profile \u2014 skipped)`),[]):(console.error(`${n} failed for ${e}: ${r.slice(0,120)}`),[])}}async function Cn(e,t){return ce(t,"featured","extractFeaturedFromDetails",async()=>(await le(e,t,"featured"),await e.evaluate(`(() => {
5
5
  ${ae}
6
6
 
7
7
  const main = document.querySelector('main');
@@ -235,17 +235,17 @@ 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 tn from"puppeteer";import{addExtra as nn}from"puppeteer-extra";import on from"puppeteer-extra-plugin-stealth";ie();import{getPluginConfig as Yt}from"@ilivemylife/graph-sdk";var Kt=await Yt();for(let[e,t]of Object.entries(Kt))process.env[e]===void 0&&(process.env[e]=t);var zt=process.env.LINKEDIN_NAME,Y=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Bo=Object.freeze(new Set([Y.DRAFT,Y.CONFIRMED,Y.NEEDS_REVIEW])),Qt=Object.freeze(new Set([Y.DRAFT,Y.CONFIRMED,Y.REJECTED,Y.NEEDS_REVIEW]));import rt from"fs";import Xt from"path";var Zt="cookies.json";function en(){let e=process.env.ILML_SCOPE_DIR;return e?Xt.join(e,"plugins-state","linkedin","cookies.json"):Zt}function st(){let e=en();if(!rt.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=rt.readFileSync(e,"utf-8")}catch(o){throw new Error(`Failed to read cookies at ${e}: ${o.message}. Run: ilml linkedin login`)}let n;try{n=JSON.parse(t)}catch{throw new Error(`Cookies file at ${e} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(n)||n.length===0)throw new Error(`Cookies file at ${e} is empty or not an array. Run: ilml linkedin login`);return n}var it=nn(tn);it.use(on());async function lt(){let e=await it.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 n=await e.newPage();await n.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})});try{let o=st();await n.setCookie(...o),console.log(" Browser launched, cookies loaded.")}catch(o){console.error(`
238
+ `});import tn from"puppeteer";import{addExtra as nn}from"puppeteer-extra";import on from"puppeteer-extra-plugin-stealth";ie();import{getPluginConfig as Yt}from"@ilivemylife/graph-sdk";var Kt=await Yt();for(let[e,t]of Object.entries(Kt))process.env[e]===void 0&&(process.env[e]=t);var zt=process.env.LINKEDIN_NAME,Y=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Bo=Object.freeze(new Set([Y.DRAFT,Y.CONFIRMED,Y.NEEDS_REVIEW])),Qt=Object.freeze(new Set([Y.DRAFT,Y.CONFIRMED,Y.REJECTED,Y.NEEDS_REVIEW]));import st from"fs";import Xt from"path";var Zt="cookies.json";function en(){let e=process.env.ILML_SCOPE_DIR;return e?Xt.join(e,"plugins-state","linkedin","cookies.json"):Zt}function rt(){let e=en();if(!st.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=st.readFileSync(e,"utf-8")}catch(o){throw new Error(`Failed to read cookies at ${e}: ${o.message}. Run: ilml linkedin login`)}let n;try{n=JSON.parse(t)}catch{throw new Error(`Cookies file at ${e} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(n)||n.length===0)throw new Error(`Cookies file at ${e} is empty or not an array. Run: ilml linkedin login`);return n}var it=nn(tn);it.use(on());async function lt(){let e=await it.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 n=await e.newPage();await n.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})});try{let o=rt();await n.setCookie(...o),console.log(" Browser launched, cookies loaded.")}catch(o){console.error(`
240
240
  [!] ${o.message}
241
- `),await e.close(),process.exit(1)}return{browser:e,page:n}}ie();import"dotenv/config";import*as C from"fs";import*as x from"path";import{fileURLToPath as rn}from"url";var sn=rn(import.meta.url),ln=x.dirname(x.dirname(sn)),q=process.env.DATA_DIR?x.resolve(process.env.DATA_DIR,"collected-profiles"):x.join(ln,"collected-profiles"),ke=x.join(q,"people.json"),ir=x.join(q,"jobs.json"),lr=x.join(q,"quota.json"),ut=x.join(q,"conversations.json"),ar=x.join(q,"sync-state.json"),cr=x.join(q,"application-questions.json"),Ce=x.join(q,"profile-history"),dt=(e,t)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:t},ur=dt(process.env.CONNECT_MAX_DAILY,20),dr=dt(process.env.CONNECT_MAX_WEEKLY,100),re=null,an=null,cn=null,oe=null,un=null,dn=null;function ft(){re=null,an=null,cn=null,oe=null,un=null,dn=null}function xe(){C.existsSync(q)||C.mkdirSync(q,{recursive:!0})}function $e(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";C.writeFileSync(o,n);for(let r=0;r<3;r++)try{C.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw s}}function Ee(e,t){if(!C.existsSync(e))return null;try{let n=JSON.parse(C.readFileSync(e,"utf-8"));try{C.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${x.resolve(e)}`);let o=e+".backup";if(C.existsSync(o))try{let r=JSON.parse(C.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{C.copyFileSync(o,e)}catch{}return r}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{C.copyFileSync(e,e+".corrupted")}catch{}return null}}function fn(){return new Date().toISOString().split("T")[0]}var mn=["name","title","location","company","connectionDegree","connectionsCount","mutualConnections","photoUrl","hasVerifiedBadge","about","currentCompany","currentSchool","connectionsLevel","mutualConnectionsCount","followers","openToWork","hiring","topSkills","availableSections","experience","featuredLinks","_lastEnrichedAt","featured","education","skillsFull","recommendations","certifications"],pn=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"];function Ae(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function hn(){C.existsSync(Ce)||C.mkdirSync(Ce,{recursive:!0})}function mt(e){let t=Ae(e);return t?x.join(Ce,`${t}.json`):null}function gn(e){let t=mt(e);return t?Ee(t,`profile-history/${Ae(e)}.json`)||[]:[]}function yn(e,t){let n=mt(e);if(!n)return;hn();let o=gn(e);o.unshift(t);try{$e(n,o)}catch(r){console.error(`[!] Failed to append profile-history for ${Ae(e)}: ${r.message}`)}}function at(e){return!!(e==null||Array.isArray(e)&&e.length===0||typeof e=="string"&&!e.trim())}function ct(e){return Array.isArray(e)?[...e].map(t=>String(t).trim()).sort().join("||"):typeof e=="string"?e.replace(/\s+/g," ").trim():e}function wn(e,t){if(!e)return[];let n=[];for(let o of pn){let r=e[o],s=t[o];at(r)||at(s)||ct(r)!==ct(s)&&n.push(o)}return n}function bn(e){let t=new Set(["seenCount","sources","firstSeen","lastSeen","lastUpdated","encounters","jobIds","lastFullVisitAt","lastSnapshotAt","messageSent","connectionStatus","connectionDate","connectionMethod"]),n={};for(let[o,r]of Object.entries(e))t.has(o)||(n[o]=r);return n}function K(){return re||(xe(),re=Ee(ke,"people.json")||{},re)}function Sn(e){xe(),re=e;try{$e(ke,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${x.resolve(ke)}`)}}function _e(){return oe||(xe(),oe=Ee(ut,"conversations.json")||{},vn(oe),oe)}function vn(e){let t=0;for(let n of Object.values(e)){if(!(n.draftStatus!==void 0||n.draftPreparedAt!==void 0))continue;let r=(n.messages||[]).find(s=>s.status==="draft");r&&n.draftStatus&&n.draftStatus!=="pending"&&(r.status=n.draftStatus),delete n.draftStatus,delete n.draftPreparedAt,t++}if(t>0){console.log(` [migration] Moved draft state from conv to msg.status for ${t} conversations`);try{$e(ut,e)}catch{}}}function Ie(e,t={}){if(!e)return null;let n=K(),o=fn(),r=new Date().toISOString(),s=n[e];if(s){let l=wn(s,t);l.length>0&&(yn(e,{capturedAt:r,previousLastUpdated:s.lastUpdated||null,changedFields:l,snapshot:bn(s)}),s.lastSnapshotAt=r),s.seenCount=(s.seenCount||1)+1,s.lastSeen=o,s.lastUpdated=r,t.source&&!s.sources?.includes(t.source)&&(s.sources=s.sources||[],s.sources.push(t.source));for(let i of mn)if(t[i]!=null){if(Array.isArray(t[i])&&t[i].length===0&&Array.isArray(s[i])&&s[i].length>0)continue;s[i]=t[i]}Array.isArray(t.availableSections)&&(s.lastFullVisitAt=r)}else n[e]={name:t.name||null,title:t.title||null,location:t.location||null,company:t.company||null,about:t.about||null,connectionDegree:t.connectionDegree||null,connectionsCount:t.connectionsCount||null,mutualConnections:t.mutualConnections||null,photoUrl:t.photoUrl||null,hasVerifiedBadge:t.hasVerifiedBadge||!1,currentCompany:t.currentCompany||null,currentSchool:t.currentSchool||null,connectionsLevel:t.connectionsLevel||null,mutualConnectionsCount:t.mutualConnectionsCount||null,followers:t.followers||null,openToWork:t.openToWork||!1,hiring:t.hiring||!1,topSkills:t.topSkills||null,availableSections:t.availableSections||null,experience:t.experience||null,featuredLinks:t.featuredLinks||null,_lastEnrichedAt:t._lastEnrichedAt||null,featured:t.featured||null,education:t.education||null,skillsFull:t.skillsFull||null,recommendations:t.recommendations||null,certifications:t.certifications||null,firstSeen:o,lastSeen:o,seenCount:1,sources:t.source?[t.source]:[],connectionStatus:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:r,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(t.availableSections)?r:null};return Sn(n),n[e]}async function _n(e,t){let n=e.url();if(n.includes("/in/"))return!1;if(n.includes("/login")||n.includes("/authwall")||n.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${n.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function gt(e,t,n={}){let{extractExperience:o=!1,extractFeatured:r=!1,extractEducation:s=!1,extractSkills:l=!1,extractRecommendations:i=!1,extractCertifications:a=!1}=n;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3),await ot(e)&&(console.log(" Dismissed Premium overlay"),await k(1500),await _n(e,t));let c=0;for(let $=0;$<2;$++){let te=await e.evaluate(()=>document.body.scrollHeight);for(let G=1;G<=6;G++)await e.evaluate(I=>window.scrollTo(0,I),te*G/6),await k(900);let P=await e.evaluate(()=>document.body.scrollHeight);if(P===c)break;c=P}await k(800);let m=await e.evaluate(()=>{let $=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"]),te=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"]),P=h=>{let g=(h||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(g)},G={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:[]},I=document.querySelector("main");if(!I)return G;let be=[...Array.from(I.querySelectorAll("h1")),...Array.from(I.querySelectorAll("h2"))],y=Array.from(I.querySelectorAll("h2")),A=be.find(h=>{let g=h.textContent&&h.textContent.trim(),w=(g||"").replace(/\s*\(\d+\)$/,"").trim();return g&&g.length>1&&g.length<100&&!$.has(w)&&!te.has(w)}),ne=A?A.textContent.trim():null,T=A?A.parentElement:null;for(;T&&T!==I&&!Array.from(T.children).filter(g=>g.tagName==="P").some(g=>{let w=g.textContent&&g.textContent.trim();return w&&w.length>5&&!P(w)});)T=T.parentElement;let de=null,Ve=null,He=null,Se=null;if(T&&T!==I){let h=Array.from(T.children).filter(w=>w.tagName==="P").filter(w=>{let B=w.textContent&&w.textContent.trim();return B&&B.length>5&&!P(B)});if(h[0]&&(de=h[0].textContent.trim()),h[1]){let w=h[1].textContent.trim().split(/\s*[·•]\s*/);Ve=w[0]||null,w.length>1&&(He=w.slice(1).join(" \xB7 "))}let g=Array.from(T.children).filter(w=>w.tagName==="DIV");for(let w=g.length-1;w>=0;w--){let B=g[w].textContent&&g[w].textContent.trim();if(B&&!(ne&&B.startsWith(ne))&&(Se=B.split(/[·•]/)[0].trim(),Se))break}}let We=null;if(T){let h=T.querySelectorAll("p, span, div");for(let g of h){let w=(g.textContent||"").trim().replace(/^[·•]\s*/,"");if(w==="1st"||w==="2nd"||w==="3rd"){We=w;break}}}let qt=!!I.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),Je=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),Ut=Je&&Je.src||null,fe=I.textContent||"",Ge=null,Ye=fe.match(/(\d+\+?)\s+connections\b/i);Ye&&(Ge=Ye[1]+" connections");let me=null,Ke=fe.match(/(\d+)\s+mutual connection/i),ze=fe.match(/and\s+(\d+)\s+other mutual/i),Bt=fe.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Ke?me=parseInt(Ke[1],10):ze?me=2+parseInt(ze[1],10):Bt&&(me=2);let Qe=null,Xe=null,Ze=y.find(h=>h.textContent&&h.textContent.trim()==="About");if(Ze){let h=Ze.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let g=(h.textContent||"").trim();g=g.replace(/^About\s*/,"").trim();let w=g.match(/Top skills\s*(.+?)$/i);if(w){let ve=w[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Jt=>Jt.trim()).filter(Boolean);ve.length>0&&ve.length<10&&(Xe=ve)}g=g.split(/\n?…\s*more/i)[0].trim(),g=g.split(/\n?\.\.\.\s*more/i)[0].trim(),g=g.split(/\bTop skills\b/i)[0].trim(),g=g.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Qe=g||null}}let et=null,tt=y.find(h=>h.textContent&&h.textContent.trim()==="Activity");if(tt){let h=tt.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let g=(h.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);g&&(et=parseInt(g[1].replace(/,/g,""),10))}}let Vt=[...new Set(y.map(h=>(h.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(h=>h&&h.length>1&&h.length<60&&h!==ne).filter(h=>$.has(h)))],se=document.body.textContent||"",Ht=/#OpenToWork\b/i.test(se)||/\bOpen to work\b/.test(se),Wt=/#Hiring\b/i.test(se)||/\bI'?m hiring\b/i.test(se)||/\bWe are hiring\b/i.test(se);return{name:ne,title:de,location:Se,currentCompany:Ve,currentSchool:He,connectionDegree:We,hasVerifiedBadge:qt,photoUrl:Ut,connectionsLevel:Ge,mutualConnectionsCount:me,followers:et,openToWork:Ht,hiring:Wt,about:Qe,topSkills:Xe,availableSections:Vt}});console.log(`Viewed: ${m.name} - ${m.title}`);let d=null,p=null,v=null,b=null,E=null,J=null;if(o||r||s||l||i||a){let $=await Promise.resolve().then(()=>(ht(),pt));o&&(d=await $.extractExperienceFromDetails(e,t),console.log(` + Experience: ${d.length} entries`)),r&&(p=await $.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${p.length} entries`)),s&&(v=await $.extractEducationFromDetails(e,t),console.log(` + Education: ${v.length} entries`)),l&&(b=await $.extractSkillsFromDetails(e,t),console.log(` + Skills: ${b.length} entries`)),i&&(E=await $.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${E.length} entries`)),a&&(J=await $.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${J.length} entries`))}return{...m,profileUrl:t,...d!==null&&{experience:d},...p!==null&&{featured:p},...v!==null&&{education:v},...b!==null&&{skillsFull:b},...E!==null&&{recommendations:E},...J!==null&&{certifications:J}}}catch(f){console.error(`Error viewing profile ${t}:`,f.message);try{await e.goto("about:blank",{timeout:1e4}),await k(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(f.message||""))throw f;return null}}import"dotenv/config";import*as O from"fs";import*as D from"path";import{fileURLToPath as In}from"url";var Tn=In(import.meta.url),Rn=D.dirname(D.dirname(Tn)),Q=process.env.DATA_DIR?D.resolve(process.env.DATA_DIR,"market-research"):D.join(Rn,"market-research"),$r=D.join(Q,"scouted-jobs.json"),Er=D.join(Q,"discovered-people.json"),yt=D.join(Q,"visit-log.json"),Ar=D.join(Q,"companies.json"),_r=D.join(Q,"job-decisions.json");function Dn(){O.existsSync(Q)||O.mkdirSync(Q,{recursive:!0})}function On(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";O.writeFileSync(o,n);for(let r=0;r<3;r++)try{O.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw s}}function jn(e){try{if(O.existsSync(e))return JSON.parse(O.readFileSync(e,"utf-8"))}catch{}return null}function wt(){Nn=null,Ln=null,Fn=null,Mn=null,z=null}var Nn=null;var Ln=null;var Fn=null;var Mn=null;var z=null;function Te(){return z||(z=jn(yt)||{visits:[]},Array.isArray(z.visits)||(z.visits=[]),z)}function bt(e,t={}){if(!e)return;Dn();let n=Te();n.visits.push({date:new Date().toISOString(),profileUrl:e,name:t.name||null,source:t.source||"manual"});let o=Date.now()-90*24*60*60*1e3;n.visits=n.visits.filter(r=>new Date(r.date).getTime()>o);try{On(yt,n)}catch(r){console.error(`[!] Failed to save visit-log.json: ${r.message}`)}}function St(e){let t=Te();for(let n=t.visits.length-1;n>=0;n--)if(t.visits[n].profileUrl===e)return t.visits[n].date;return null}ie();async function vt(e,t,n={}){let{maxVisits:o=50,delayBetween:r=4e3,skipRecentDays:s=7,verbose:l=!1,extractExperience:i=!1}=n,a={visited:0,skipped:0,errors:0},f=Date.now()-s*24*60*60*1e3;for(let c of t){if(a.visited>=o)break;if(!c.profileUrl)continue;let m=St(c.profileUrl);if(m&&new Date(m).getTime()>f){a.skipped++;continue}try{let d=await gt(e,c.profileUrl,{extractExperience:i}),p=c.source||"visit";if(d){let b={...d,source:p};i&&Array.isArray(d.experience)&&d.experience.length>0&&(b._lastEnrichedAt=new Date().toISOString()),Ie(c.profileUrl,b)}bt(c.profileUrl,{name:d?.name||c.name||null,source:p}),a.visited++,l?console.log(` [${a.visited}] ${d?.name||c.profileUrl} \u2014 ${d?.title?.slice(0,40)||"?"}`):a.visited%10===0&&console.log(` Visited: ${a.visited}`);let v=Math.random()*4e3;await k(r+v)}catch(d){a.errors++,l&&console.error(` Error visiting ${c.name||c.profileUrl}: ${d.message?.slice(0,60)}`);let p=(d.message||"").toLowerCase();if(p.includes("detached")||p.includes("session closed")||p.includes("target closed")||p.includes("session expired")||p.includes("bounced to")||p.includes("authwall")||p.includes("checkpoint")||p.includes("redirected to login")){console.log(" Fatal browser/session error \u2014 stopping visits");break}}}return a}import"dotenv/config";import*as j from"fs";import*as V from"path";import{fileURLToPath as Hn}from"url";import"dotenv/config";import{createGraphClient as Pn,resolveToken as qn}from"@ilivemylife/graph-sdk";import{config as Un}from"dotenv";Un();var kt=qn()||process.env.TOKEN;kt||(console.error(`
241
+ `),await e.close(),process.exit(1)}return{browser:e,page:n}}ie();import"dotenv/config";import*as C from"fs";import*as x from"path";import{fileURLToPath as sn}from"url";var rn=sn(import.meta.url),ln=x.dirname(x.dirname(rn)),q=process.env.DATA_DIR?x.resolve(process.env.DATA_DIR,"collected-profiles"):x.join(ln,"collected-profiles"),ke=x.join(q,"people.json"),is=x.join(q,"jobs.json"),ls=x.join(q,"quota.json"),ut=x.join(q,"conversations.json"),as=x.join(q,"sync-state.json"),cs=x.join(q,"application-questions.json"),Ce=x.join(q,"profile-history"),dt=(e,t)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:t},us=dt(process.env.CONNECT_MAX_DAILY,20),ds=dt(process.env.CONNECT_MAX_WEEKLY,100),se=null,an=null,cn=null,oe=null,un=null,dn=null;function ft(){se=null,an=null,cn=null,oe=null,un=null,dn=null}function xe(){C.existsSync(q)||C.mkdirSync(q,{recursive:!0})}function $e(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";C.writeFileSync(o,n);for(let s=0;s<3;s++)try{C.renameSync(o,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw r}}function Ee(e,t){if(!C.existsSync(e))return null;try{let n=JSON.parse(C.readFileSync(e,"utf-8"));try{C.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${x.resolve(e)}`);let o=e+".backup";if(C.existsSync(o))try{let s=JSON.parse(C.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{C.copyFileSync(o,e)}catch{}return s}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{C.copyFileSync(e,e+".corrupted")}catch{}return null}}function fn(){return new Date().toISOString().split("T")[0]}var mn=["name","title","location","company","connectionDegree","connectionsCount","mutualConnections","photoUrl","hasVerifiedBadge","about","currentCompany","currentSchool","connectionsLevel","mutualConnectionsCount","followers","openToWork","hiring","topSkills","availableSections","experience","featuredLinks","_lastEnrichedAt","featured","education","skillsFull","recommendations","certifications"],pn=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"];function Ae(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function hn(){C.existsSync(Ce)||C.mkdirSync(Ce,{recursive:!0})}function mt(e){let t=Ae(e);return t?x.join(Ce,`${t}.json`):null}function gn(e){let t=mt(e);return t?Ee(t,`profile-history/${Ae(e)}.json`)||[]:[]}function yn(e,t){let n=mt(e);if(!n)return;hn();let o=gn(e);o.unshift(t);try{$e(n,o)}catch(s){console.error(`[!] Failed to append profile-history for ${Ae(e)}: ${s.message}`)}}function at(e){return!!(e==null||Array.isArray(e)&&e.length===0||typeof e=="string"&&!e.trim())}function ct(e){return Array.isArray(e)?[...e].map(t=>String(t).trim()).sort().join("||"):typeof e=="string"?e.replace(/\s+/g," ").trim():e}function wn(e,t){if(!e)return[];let n=[];for(let o of pn){let s=e[o],r=t[o];at(s)||at(r)||ct(s)!==ct(r)&&n.push(o)}return n}function bn(e){let t=new Set(["seenCount","sources","firstSeen","lastSeen","lastUpdated","encounters","jobIds","lastFullVisitAt","lastSnapshotAt","messageSent","connectionStatus","connectionDate","connectionMethod"]),n={};for(let[o,s]of Object.entries(e))t.has(o)||(n[o]=s);return n}function K(){return se||(xe(),se=Ee(ke,"people.json")||{},se)}function Sn(e){xe(),se=e;try{$e(ke,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${x.resolve(ke)}`)}}function _e(){return oe||(xe(),oe=Ee(ut,"conversations.json")||{},vn(oe),oe)}function vn(e){let t=0;for(let n of Object.values(e)){if(!(n.draftStatus!==void 0||n.draftPreparedAt!==void 0))continue;let s=(n.messages||[]).find(r=>r.status==="draft");s&&n.draftStatus&&n.draftStatus!=="pending"&&(s.status=n.draftStatus),delete n.draftStatus,delete n.draftPreparedAt,t++}if(t>0){console.log(` [migration] Moved draft state from conv to msg.status for ${t} conversations`);try{$e(ut,e)}catch{}}}function Ie(e,t={}){if(!e)return null;let n=K(),o=fn(),s=new Date().toISOString(),r=n[e];if(r){let l=wn(r,t);l.length>0&&(yn(e,{capturedAt:s,previousLastUpdated:r.lastUpdated||null,changedFields:l,snapshot:bn(r)}),r.lastSnapshotAt=s),r.seenCount=(r.seenCount||1)+1,r.lastSeen=o,r.lastUpdated=s,t.source&&!r.sources?.includes(t.source)&&(r.sources=r.sources||[],r.sources.push(t.source));for(let i of mn)if(t[i]!=null){if(Array.isArray(t[i])&&t[i].length===0&&Array.isArray(r[i])&&r[i].length>0)continue;r[i]=t[i]}Array.isArray(t.availableSections)&&(r.lastFullVisitAt=s)}else n[e]={name:t.name||null,title:t.title||null,location:t.location||null,company:t.company||null,about:t.about||null,connectionDegree:t.connectionDegree||null,connectionsCount:t.connectionsCount||null,mutualConnections:t.mutualConnections||null,photoUrl:t.photoUrl||null,hasVerifiedBadge:t.hasVerifiedBadge||!1,currentCompany:t.currentCompany||null,currentSchool:t.currentSchool||null,connectionsLevel:t.connectionsLevel||null,mutualConnectionsCount:t.mutualConnectionsCount||null,followers:t.followers||null,openToWork:t.openToWork||!1,hiring:t.hiring||!1,topSkills:t.topSkills||null,availableSections:t.availableSections||null,experience:t.experience||null,featuredLinks:t.featuredLinks||null,_lastEnrichedAt:t._lastEnrichedAt||null,featured:t.featured||null,education:t.education||null,skillsFull:t.skillsFull||null,recommendations:t.recommendations||null,certifications:t.certifications||null,firstSeen:o,lastSeen:o,seenCount:1,sources:t.source?[t.source]:[],connectionStatus:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:s,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(t.availableSections)?s:null};return Sn(n),n[e]}async function _n(e,t){let n=e.url();if(n.includes("/in/"))return!1;if(n.includes("/login")||n.includes("/authwall")||n.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${n.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function gt(e,t,n={}){let{extractExperience:o=!1,extractFeatured:s=!1,extractEducation:r=!1,extractSkills:l=!1,extractRecommendations:i=!1,extractCertifications:a=!1}=n;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3),await ot(e)&&(console.log(" Dismissed Premium overlay"),await k(1500),await _n(e,t));let c=0;for(let $=0;$<2;$++){let te=await e.evaluate(()=>document.body.scrollHeight);for(let G=1;G<=6;G++)await e.evaluate(I=>window.scrollTo(0,I),te*G/6),await k(900);let P=await e.evaluate(()=>document.body.scrollHeight);if(P===c)break;c=P}await k(800);let m=await e.evaluate(()=>{let $=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"]),te=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"]),P=h=>{let g=(h||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(g)},G={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:[]},I=document.querySelector("main");if(!I)return G;let be=[...Array.from(I.querySelectorAll("h1")),...Array.from(I.querySelectorAll("h2"))],y=Array.from(I.querySelectorAll("h2")),A=be.find(h=>{let g=h.textContent&&h.textContent.trim(),w=(g||"").replace(/\s*\(\d+\)$/,"").trim();return g&&g.length>1&&g.length<100&&!$.has(w)&&!te.has(w)}),ne=A?A.textContent.trim():null,T=A?A.parentElement:null;for(;T&&T!==I&&!Array.from(T.children).filter(g=>g.tagName==="P").some(g=>{let w=g.textContent&&g.textContent.trim();return w&&w.length>5&&!P(w)});)T=T.parentElement;let de=null,Ve=null,He=null,Se=null;if(T&&T!==I){let h=Array.from(T.children).filter(w=>w.tagName==="P").filter(w=>{let B=w.textContent&&w.textContent.trim();return B&&B.length>5&&!P(B)});if(h[0]&&(de=h[0].textContent.trim()),h[1]){let w=h[1].textContent.trim().split(/\s*[·•]\s*/);Ve=w[0]||null,w.length>1&&(He=w.slice(1).join(" \xB7 "))}let g=Array.from(T.children).filter(w=>w.tagName==="DIV");for(let w=g.length-1;w>=0;w--){let B=g[w].textContent&&g[w].textContent.trim();if(B&&!(ne&&B.startsWith(ne))&&(Se=B.split(/[·•]/)[0].trim(),Se))break}}let We=null;if(T){let h=T.querySelectorAll("p, span, div");for(let g of h){let w=(g.textContent||"").trim().replace(/^[·•]\s*/,"");if(w==="1st"||w==="2nd"||w==="3rd"){We=w;break}}}let qt=!!I.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),Je=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),Ut=Je&&Je.src||null,fe=I.textContent||"",Ge=null,Ye=fe.match(/(\d+\+?)\s+connections\b/i);Ye&&(Ge=Ye[1]+" connections");let me=null,Ke=fe.match(/(\d+)\s+mutual connection/i),ze=fe.match(/and\s+(\d+)\s+other mutual/i),Bt=fe.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Ke?me=parseInt(Ke[1],10):ze?me=2+parseInt(ze[1],10):Bt&&(me=2);let Qe=null,Xe=null,Ze=y.find(h=>h.textContent&&h.textContent.trim()==="About");if(Ze){let h=Ze.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let g=(h.textContent||"").trim();g=g.replace(/^About\s*/,"").trim();let w=g.match(/Top skills\s*(.+?)$/i);if(w){let ve=w[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Jt=>Jt.trim()).filter(Boolean);ve.length>0&&ve.length<10&&(Xe=ve)}g=g.split(/\n?…\s*more/i)[0].trim(),g=g.split(/\n?\.\.\.\s*more/i)[0].trim(),g=g.split(/\bTop skills\b/i)[0].trim(),g=g.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Qe=g||null}}let et=null,tt=y.find(h=>h.textContent&&h.textContent.trim()==="Activity");if(tt){let h=tt.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let g=(h.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);g&&(et=parseInt(g[1].replace(/,/g,""),10))}}let Vt=[...new Set(y.map(h=>(h.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(h=>h&&h.length>1&&h.length<60&&h!==ne).filter(h=>$.has(h)))],re=document.body.textContent||"",Ht=/#OpenToWork\b/i.test(re)||/\bOpen to work\b/.test(re),Wt=/#Hiring\b/i.test(re)||/\bI'?m hiring\b/i.test(re)||/\bWe are hiring\b/i.test(re);return{name:ne,title:de,location:Se,currentCompany:Ve,currentSchool:He,connectionDegree:We,hasVerifiedBadge:qt,photoUrl:Ut,connectionsLevel:Ge,mutualConnectionsCount:me,followers:et,openToWork:Ht,hiring:Wt,about:Qe,topSkills:Xe,availableSections:Vt}});console.log(`Viewed: ${m.name} - ${m.title}`);let d=null,p=null,v=null,b=null,E=null,J=null;if(o||s||r||l||i||a){let $=await Promise.resolve().then(()=>(ht(),pt));o&&(d=await $.extractExperienceFromDetails(e,t),console.log(` + Experience: ${d.length} entries`)),s&&(p=await $.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${p.length} entries`)),r&&(v=await $.extractEducationFromDetails(e,t),console.log(` + Education: ${v.length} entries`)),l&&(b=await $.extractSkillsFromDetails(e,t),console.log(` + Skills: ${b.length} entries`)),i&&(E=await $.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${E.length} entries`)),a&&(J=await $.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${J.length} entries`))}return{...m,profileUrl:t,...d!==null&&{experience:d},...p!==null&&{featured:p},...v!==null&&{education:v},...b!==null&&{skillsFull:b},...E!==null&&{recommendations:E},...J!==null&&{certifications:J}}}catch(f){console.error(`Error viewing profile ${t}:`,f.message);try{await e.goto("about:blank",{timeout:1e4}),await k(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(f.message||""))throw f;return null}}import"dotenv/config";import*as O from"fs";import*as D from"path";import{fileURLToPath as In}from"url";var Tn=In(import.meta.url),Rn=D.dirname(D.dirname(Tn)),Q=process.env.DATA_DIR?D.resolve(process.env.DATA_DIR,"market-research"):D.join(Rn,"market-research"),$s=D.join(Q,"scouted-jobs.json"),Es=D.join(Q,"discovered-people.json"),yt=D.join(Q,"visit-log.json"),As=D.join(Q,"companies.json"),_s=D.join(Q,"job-decisions.json");function Dn(){O.existsSync(Q)||O.mkdirSync(Q,{recursive:!0})}function On(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";O.writeFileSync(o,n);for(let s=0;s<3;s++)try{O.renameSync(o,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw r}}function jn(e){try{if(O.existsSync(e))return JSON.parse(O.readFileSync(e,"utf-8"))}catch{}return null}function wt(){Nn=null,Ln=null,Fn=null,Mn=null,z=null}var Nn=null;var Ln=null;var Fn=null;var Mn=null;var z=null;function Te(){return z||(z=jn(yt)||{visits:[]},Array.isArray(z.visits)||(z.visits=[]),z)}function bt(e,t={}){if(!e)return;Dn();let n=Te();n.visits.push({date:new Date().toISOString(),profileUrl:e,name:t.name||null,source:t.source||"manual"});let o=Date.now()-90*24*60*60*1e3;n.visits=n.visits.filter(s=>new Date(s.date).getTime()>o);try{On(yt,n)}catch(s){console.error(`[!] Failed to save visit-log.json: ${s.message}`)}}function St(e){let t=Te();for(let n=t.visits.length-1;n>=0;n--)if(t.visits[n].profileUrl===e)return t.visits[n].date;return null}ie();async function vt(e,t,n={}){let{maxVisits:o=50,delayBetween:s=4e3,skipRecentDays:r=7,verbose:l=!1,extractExperience:i=!1}=n,a={visited:0,skipped:0,errors:0},f=Date.now()-r*24*60*60*1e3;for(let c of t){if(a.visited>=o)break;if(!c.profileUrl)continue;let m=St(c.profileUrl);if(m&&new Date(m).getTime()>f){a.skipped++;continue}try{let d=await gt(e,c.profileUrl,{extractExperience:i}),p=c.source||"visit";if(d){let b={...d,source:p};i&&Array.isArray(d.experience)&&d.experience.length>0&&(b._lastEnrichedAt=new Date().toISOString()),Ie(c.profileUrl,b)}bt(c.profileUrl,{name:d?.name||c.name||null,source:p}),a.visited++,l?console.log(` [${a.visited}] ${d?.name||c.profileUrl} \u2014 ${d?.title?.slice(0,40)||"?"}`):a.visited%10===0&&console.log(` Visited: ${a.visited}`);let v=Math.random()*4e3;await k(s+v)}catch(d){a.errors++,l&&console.error(` Error visiting ${c.name||c.profileUrl}: ${d.message?.slice(0,60)}`);let p=(d.message||"").toLowerCase();if(p.includes("detached")||p.includes("session closed")||p.includes("target closed")||p.includes("session expired")||p.includes("bounced to")||p.includes("authwall")||p.includes("checkpoint")||p.includes("redirected to login")){console.log(" Fatal browser/session error \u2014 stopping visits");break}}}return a}import"dotenv/config";import*as j from"fs";import*as V from"path";import{fileURLToPath as Hn}from"url";import"dotenv/config";import{createGraphClient as Pn,resolveToken as qn}from"@ilivemylife/graph-sdk";import{config as Un}from"dotenv";Un();var kt=qn()||process.env.TOKEN;kt||(console.error(`
242
242
  [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.
243
243
  `),console.error(" Easiest way:"),console.error(" 1. npm install -g @ilivemylife/graph-sdk"),console.error(` 2. ilml login your@email.com yourpassword
244
244
  `),console.error(` Or add ILML_TOKEN=... to .env
245
- `),process.exit(1));var Ct=Pn({token:kt});function Bn(e){if(!e||e<1e3)return`${e||0}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),o=t%60;return o?`${n}m ${o}s`:`${n}m`}function Vn({scriptName:e,mode:t,status:n,error:o,duration:r}){let s=n==="error"?"\u2717":n==="quota-reached"?"\u26A0":"\u2713",l=new Date().toISOString().slice(0,16).replace("T"," "),i=r?` ${Bn(r)}`:"",a=n==="error"?`error${o?`: ${String(o).slice(0,80)}`:""}`:n==="quota-reached"?"daily quota reached":"done",f=t&&t!=="default"?` (${t})`:"";return`${s} ${e}${f} \u2014 ${a} \u2014 ${l}${i}`}async function xt({scriptName:e,mode:t,status:n,summaryLines:o,error:r,duration:s}){let l=process.env.NODE_RUN_REPORTS;if(!l||!Array.isArray(o)||o.length===0)return;let a=`**${Vn({scriptName:e,mode:t,status:n,error:r,duration:s})}**
245
+ `),process.exit(1));var Ct=Pn({token:kt});function Bn(e){if(!e||e<1e3)return`${e||0}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),o=t%60;return o?`${n}m ${o}s`:`${n}m`}function Vn({scriptName:e,mode:t,status:n,error:o,duration:s}){let r=n==="error"?"\u2717":n==="quota-reached"?"\u26A0":"\u2713",l=new Date().toISOString().slice(0,16).replace("T"," "),i=s?` ${Bn(s)}`:"",a=n==="error"?`error${o?`: ${String(o).slice(0,80)}`:""}`:n==="quota-reached"?"daily quota reached":"done",f=t&&t!=="default"?` (${t})`:"";return`${r} ${e}${f} \u2014 ${a} \u2014 ${l}${i}`}async function xt({scriptName:e,mode:t,status:n,summaryLines:o,error:s,duration:r}){let l=process.env.NODE_RUN_REPORTS;if(!l||!Array.isArray(o)||o.length===0)return;let a=`**${Vn({scriptName:e,mode:t,status:n,error:s,duration:r})}**
246
246
 
247
247
  ${o.join(`
248
- `)}`;try{await Ct.addMessage(l,a)}catch(f){console.error(`[runReport] Failed to post end-of-session message: ${f.message}`)}}var Wn=Hn(import.meta.url),Jn=V.dirname(V.dirname(Wn)),Re=process.env.DATA_DIR?V.resolve(process.env.DATA_DIR,"collected-profiles"):V.join(Jn,"collected-profiles"),De=V.join(Re,"run-log.json");function Gn(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";j.writeFileSync(o,n);for(let r=0;r<3;r++)try{j.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw s}}function $t(){try{if(!j.existsSync(De))return{runs:[]};let e=JSON.parse(j.readFileSync(De,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function Et(e){j.existsSync(Re)||j.mkdirSync(Re,{recursive:!0});try{Gn(De,e)}catch(t){console.error(`[!] Failed to save run-log.json: ${t.message}`)}}function At(e,t="default"){let n=$t();for(let l of n.runs)l.status==="running"&&(l.status="interrupted",l.result="interrupted",l.timestamp&&(l.duration=Date.now()-new Date(l.timestamp).getTime()));let o=new Date,r={timestamp:o.toISOString(),script:e,mode:t,status:"running",result:null,duration:null,stats:null,error:null};n.runs.push(r);let s=Date.now()-30*24*60*60*1e3;return n.runs=n.runs.filter(l=>new Date(l.timestamp).getTime()>s),Et(n),{script:e,mode:t,startTime:o.getTime(),runIndex:n.runs.length-1}}function Oe(e,t,n=null,o=null){if(!e)return;let r=null;try{let l=$t(),i=l.runs[e.runIndex];if(i&&i.status==="running"&&i.script===e.script)i.status=t,i.result=t,i.duration=Date.now()-e.startTime,i.stats=n,i.error=o,r=i.duration;else{let a=l.runs.find(f=>f.script===e.script&&f.status==="running"&&f.timestamp===new Date(e.startTime).toISOString());a&&(a.status=t,a.result=t,a.duration=Date.now()-e.startTime,a.stats=n,a.error=o,r=a.duration)}Et(l)}catch(l){console.error(`[runLog] Failed to end run: ${l.message}`)}let s=n&&Array.isArray(n.summaryLines)?n.summaryLines:null;if(s&&s.length>0&&process.env.NODE_RUN_REPORTS){let l=t==="error"?"error":n&&n.dailyLimitHit?"quota-reached":"done";xt({scriptName:e.script,mode:e.mode,status:l,summaryLines:s,error:o,duration:r??Date.now()-e.startTime}).catch(i=>console.error(`[runLog] postRunReport failed: ${i.message}`))}}import"dotenv/config";import*as u from"fs";import*as qe from"os";import*as S from"path";import{fileURLToPath as fo}from"url";var Le={};pe(Le,{NAME:()=>Kn,VERSION:()=>Yn,up:()=>Xn});import*as N from"fs";import*as he from"path";var Yn=1,Kn="normalize-jobs-and-questions",zn=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Qn=50;function je(e){return N.existsSync(e)?JSON.parse(N.readFileSync(e,"utf-8")):null}function Ne(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{N.writeFileSync(o,n)}catch(r){try{N.unlinkSync(o)}catch{}throw r}try{N.renameSync(o,e)}catch(r){try{N.unlinkSync(o)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function Xn(e,t){let n=he.join(e,"jobs.json"),o=he.join(t,"scouted-jobs.json"),r=he.join(e,"application-questions.json"),s=je(n)||{},l=je(o)||{},i=0,a=[];for(let c of Object.keys(s)){if(!l[c])continue;let m=l[c],d=s[c];for(let p of zn)m[p]!=null&&d[p]==null&&(d[p]=m[p]);a.push(c),i++}i>0?(Ne(n,s),console.log(` Phase 1: Merged ${i} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let f=je(r);if(f&&Array.isArray(f.applications)){let c={},m=0;for(let d of f.applications){let p=d.jobId||"unknown";c[p]||(c[p]={applications:[]});let v=(d.questions||[]).map(b=>{let E={type:b.type||"input",question:b.question||"",answer:b.answer||""};return b.options&&(b.options.length<=Qn?E.options=b.options:(E.optionsOmitted=!0,m++)),b.page&&(E.page=b.page),b.wasPreFilled&&(E.wasPreFilled=!0),b.wasRetry&&(E.wasRetry=!0),E});c[p].applications.push({applicationId:d.applicationId,date:d.date,result:d.result||"submitted",formPages:d.formPages||null,duration:d.duration||null,retries:d.retries||0,failedField:d.failedField||null,questionCount:d.questionCount||v.length,questions:v})}Ne(r,c),console.log(` Phase 2: Rekeyed ${f.applications.length} applications by jobId (${Object.keys(c).length} unique jobs)`),m>0&&console.log(` Phase 2: Stripped bloated options from ${m} questions`)}else f&&!f.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(a.length>0){for(let c of a)delete l[c];Ne(o,l),console.log(` Phase 3: Removed ${a.length} merged entries from scouted-jobs.json (${Object.keys(l).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var Fe={};pe(Fe,{NAME:()=>eo,VERSION:()=>Zn,up:()=>oo});import*as L from"fs";import*as _t from"path";var Zn=2,eo="reset-unread-flags";function to(e){return L.existsSync(e)?JSON.parse(L.readFileSync(e,"utf-8")):null}function no(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{L.writeFileSync(o,n)}catch(r){try{L.unlinkSync(o)}catch{}throw r}try{L.renameSync(o,e)}catch(r){try{L.unlinkSync(o)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function oo(e){let t=_t.join(e,"conversations.json"),n=to(t);if(!n){console.log(" conversations.json not found \u2014 nothing to reset.");return}let o=0;for(let r of Object.keys(n))n[r].unread===!0&&(n[r].unread=!1,o++);if(o===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}no(t,n),console.log(` Reset unread=false on ${o} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var Me={};pe(Me,{NAME:()=>so,VERSION:()=>ro,up:()=>uo});import*as F from"fs";import*as It from"path";var ro=3,so="recompute-last-message-by",io=new Set(["draft","confirmed","rejected","needs_review"]);function lo(e){return F.existsSync(e)?JSON.parse(F.readFileSync(e,"utf-8")):null}function ao(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{F.writeFileSync(o,n)}catch(r){try{F.unlinkSync(o)}catch{}throw r}try{F.renameSync(o,e)}catch(r){try{F.unlinkSync(o)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}function co(e,t){if(!e||e.length===0)return"them";let n=e.filter(s=>!io.has(s.status));if(n.length===0)return"them";let o=n.map(s=>({m:s,t:Date.parse(s.time)})).filter(s=>Number.isFinite(s.t)).sort((s,l)=>l.t-s.t).map(s=>s.m),r=o.length>0?o:[...n].reverse();for(let s of r){let l=s.sender;if(l===t)return"me";if(l!=="Unknown"&&l!=="")return"them"}return"them"}async function uo(e){let t=It.join(e,"conversations.json"),n=lo(t);if(!n){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let o=process.env.LINKEDIN_NAME;if(!o||typeof o!="string"||!o.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 r=0,s=0,l=0;for(let i of Object.keys(n)){let a=n[i];if(!a||typeof a!="object")continue;Object.prototype.hasOwnProperty.call(a,"_cardSynced")&&(delete a._cardSynced,s++);let f=Array.isArray(a.messages)?a.messages:[],c=co(f,o),m=c==="me"?"awaiting_reply":"unanswered_by_us";a.lastMessageBy!==c&&l++,a.lastMessageBy=c,a.conversationStatus=m,r++}if(r===0){console.log(" No conversations to recompute.");return}ao(t,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${r} conversations.`),console.log(` ${l} had stale lastMessageBy (now corrected).`),s>0&&console.log(` Cleaned ${s} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var mo=fo(import.meta.url),po=S.dirname(mo),ho=S.dirname(S.dirname(po));function go(e){return e&&(e==="~"?qe.homedir():e.startsWith("~/")||e.startsWith("~\\")?S.join(qe.homedir(),e.slice(2)):e)}var M=process.env.DATA_DIR?S.resolve(go(process.env.DATA_DIR)):ho,Z=S.join(M,"collected-profiles"),ee=S.join(M,"market-research"),R=S.join(M,".schema-version"),Tt=[S.join(Z,".schema-version"),S.join(ee,".schema-version")],H=3,U=[{version:1,module:Le},{version:2,module:Fe},{version:3,module:Me}];(function(){U.sort((o,r)=>o.version-r.version);let t=new Set;for(let o of U){if(!Number.isInteger(o.version)||o.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(o.version)} (must be positive integer)`);if(t.has(o.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${o.version}`);t.add(o.version);let r=o.module;if(!r||typeof r.up!="function")throw new Error(`MIGRATION_REGISTRY: v${o.version} module is missing up()`);if(r.VERSION!==void 0&&r.VERSION!==o.version)throw new Error(`MIGRATION_REGISTRY: v${o.version} entry does not match module VERSION (${r.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=U.length?U[U.length-1].version:0;if(n!==H)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${H}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let o=0;o<U.length;o++){let r=o+1;if(U[o].version!==r)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${r} at position ${o} but found v${U[o].version}`)}})();function jt(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
248
+ `)}`;try{await Ct.addMessage(l,a)}catch(f){console.error(`[runReport] Failed to post end-of-session message: ${f.message}`)}}var Wn=Hn(import.meta.url),Jn=V.dirname(V.dirname(Wn)),Re=process.env.DATA_DIR?V.resolve(process.env.DATA_DIR,"collected-profiles"):V.join(Jn,"collected-profiles"),De=V.join(Re,"run-log.json");function Gn(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";j.writeFileSync(o,n);for(let s=0;s<3;s++)try{j.renameSync(o,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw r}}function $t(){try{if(!j.existsSync(De))return{runs:[]};let e=JSON.parse(j.readFileSync(De,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function Et(e){j.existsSync(Re)||j.mkdirSync(Re,{recursive:!0});try{Gn(De,e)}catch(t){console.error(`[!] Failed to save run-log.json: ${t.message}`)}}function At(e,t="default"){let n=$t();for(let l of n.runs)l.status==="running"&&(l.status="interrupted",l.result="interrupted",l.timestamp&&(l.duration=Date.now()-new Date(l.timestamp).getTime()));let o=new Date,s={timestamp:o.toISOString(),script:e,mode:t,status:"running",result:null,duration:null,stats:null,error:null};n.runs.push(s);let r=Date.now()-30*24*60*60*1e3;return n.runs=n.runs.filter(l=>new Date(l.timestamp).getTime()>r),Et(n),{script:e,mode:t,startTime:o.getTime(),runIndex:n.runs.length-1}}function Oe(e,t,n=null,o=null){if(!e)return;let s=null;try{let l=$t(),i=l.runs[e.runIndex];if(i&&i.status==="running"&&i.script===e.script)i.status=t,i.result=t,i.duration=Date.now()-e.startTime,i.stats=n,i.error=o,s=i.duration;else{let a=l.runs.find(f=>f.script===e.script&&f.status==="running"&&f.timestamp===new Date(e.startTime).toISOString());a&&(a.status=t,a.result=t,a.duration=Date.now()-e.startTime,a.stats=n,a.error=o,s=a.duration)}Et(l)}catch(l){console.error(`[runLog] Failed to end run: ${l.message}`)}let r=n&&Array.isArray(n.summaryLines)?n.summaryLines:null;if(r&&r.length>0&&process.env.NODE_RUN_REPORTS){let l=t==="error"?"error":n&&n.dailyLimitHit?"quota-reached":"done";xt({scriptName:e.script,mode:e.mode,status:l,summaryLines:r,error:o,duration:s??Date.now()-e.startTime}).catch(i=>console.error(`[runLog] postRunReport failed: ${i.message}`))}}import"dotenv/config";import*as u from"fs";import*as qe from"os";import*as S from"path";import{fileURLToPath as fo}from"url";var Le={};pe(Le,{NAME:()=>Kn,VERSION:()=>Yn,up:()=>Xn});import*as N from"fs";import*as he from"path";var Yn=1,Kn="normalize-jobs-and-questions",zn=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Qn=50;function je(e){return N.existsSync(e)?JSON.parse(N.readFileSync(e,"utf-8")):null}function Ne(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{N.writeFileSync(o,n)}catch(s){try{N.unlinkSync(o)}catch{}throw s}try{N.renameSync(o,e)}catch(s){try{N.unlinkSync(o)}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 Xn(e,t){let n=he.join(e,"jobs.json"),o=he.join(t,"scouted-jobs.json"),s=he.join(e,"application-questions.json"),r=je(n)||{},l=je(o)||{},i=0,a=[];for(let c of Object.keys(r)){if(!l[c])continue;let m=l[c],d=r[c];for(let p of zn)m[p]!=null&&d[p]==null&&(d[p]=m[p]);a.push(c),i++}i>0?(Ne(n,r),console.log(` Phase 1: Merged ${i} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let f=je(s);if(f&&Array.isArray(f.applications)){let c={},m=0;for(let d of f.applications){let p=d.jobId||"unknown";c[p]||(c[p]={applications:[]});let v=(d.questions||[]).map(b=>{let E={type:b.type||"input",question:b.question||"",answer:b.answer||""};return b.options&&(b.options.length<=Qn?E.options=b.options:(E.optionsOmitted=!0,m++)),b.page&&(E.page=b.page),b.wasPreFilled&&(E.wasPreFilled=!0),b.wasRetry&&(E.wasRetry=!0),E});c[p].applications.push({applicationId:d.applicationId,date:d.date,result:d.result||"submitted",formPages:d.formPages||null,duration:d.duration||null,retries:d.retries||0,failedField:d.failedField||null,questionCount:d.questionCount||v.length,questions:v})}Ne(s,c),console.log(` Phase 2: Rekeyed ${f.applications.length} applications by jobId (${Object.keys(c).length} unique jobs)`),m>0&&console.log(` Phase 2: Stripped bloated options from ${m} questions`)}else f&&!f.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(a.length>0){for(let c of a)delete l[c];Ne(o,l),console.log(` Phase 3: Removed ${a.length} merged entries from scouted-jobs.json (${Object.keys(l).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var Fe={};pe(Fe,{NAME:()=>eo,VERSION:()=>Zn,up:()=>oo});import*as L from"fs";import*as _t from"path";var Zn=2,eo="reset-unread-flags";function to(e){return L.existsSync(e)?JSON.parse(L.readFileSync(e,"utf-8")):null}function no(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{L.writeFileSync(o,n)}catch(s){try{L.unlinkSync(o)}catch{}throw s}try{L.renameSync(o,e)}catch(s){try{L.unlinkSync(o)}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 oo(e){let t=_t.join(e,"conversations.json"),n=to(t);if(!n){console.log(" conversations.json not found \u2014 nothing to reset.");return}let o=0;for(let s of Object.keys(n))n[s].unread===!0&&(n[s].unread=!1,o++);if(o===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}no(t,n),console.log(` Reset unread=false on ${o} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var Me={};pe(Me,{NAME:()=>ro,VERSION:()=>so,up:()=>uo});import*as F from"fs";import*as It from"path";var so=3,ro="recompute-last-message-by",io=new Set(["draft","confirmed","rejected","needs_review"]);function lo(e){return F.existsSync(e)?JSON.parse(F.readFileSync(e,"utf-8")):null}function ao(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{F.writeFileSync(o,n)}catch(s){try{F.unlinkSync(o)}catch{}throw s}try{F.renameSync(o,e)}catch(s){try{F.unlinkSync(o)}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 co(e,t){if(!e||e.length===0)return"them";let n=e.filter(r=>!io.has(r.status));if(n.length===0)return"them";let o=n.map(r=>({m:r,t:Date.parse(r.time)})).filter(r=>Number.isFinite(r.t)).sort((r,l)=>l.t-r.t).map(r=>r.m),s=o.length>0?o:[...n].reverse();for(let r of s){let l=r.sender;if(l===t)return"me";if(l!=="Unknown"&&l!=="")return"them"}return"them"}async function uo(e){let t=It.join(e,"conversations.json"),n=lo(t);if(!n){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let o=process.env.LINKEDIN_NAME;if(!o||typeof o!="string"||!o.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,l=0;for(let i of Object.keys(n)){let a=n[i];if(!a||typeof a!="object")continue;Object.prototype.hasOwnProperty.call(a,"_cardSynced")&&(delete a._cardSynced,r++);let f=Array.isArray(a.messages)?a.messages:[],c=co(f,o),m=c==="me"?"awaiting_reply":"unanswered_by_us";a.lastMessageBy!==c&&l++,a.lastMessageBy=c,a.conversationStatus=m,s++}if(s===0){console.log(" No conversations to recompute.");return}ao(t,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${s} conversations.`),console.log(` ${l} 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 mo=fo(import.meta.url),po=S.dirname(mo),ho=S.dirname(S.dirname(po));function go(e){return e&&(e==="~"?qe.homedir():e.startsWith("~/")||e.startsWith("~\\")?S.join(qe.homedir(),e.slice(2)):e)}var M=process.env.DATA_DIR?S.resolve(go(process.env.DATA_DIR)):ho,Z=S.join(M,"collected-profiles"),ee=S.join(M,"market-research"),R=S.join(M,".schema-version"),Tt=[S.join(Z,".schema-version"),S.join(ee,".schema-version")],H=3,U=[{version:1,module:Le},{version:2,module:Fe},{version:3,module:Me}];(function(){U.sort((o,s)=>o.version-s.version);let t=new Set;for(let o of U){if(!Number.isInteger(o.version)||o.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(o.version)} (must be positive integer)`);if(t.has(o.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${o.version}`);t.add(o.version);let s=o.module;if(!s||typeof s.up!="function")throw new Error(`MIGRATION_REGISTRY: v${o.version} module is missing up()`);if(s.VERSION!==void 0&&s.VERSION!==o.version)throw new Error(`MIGRATION_REGISTRY: v${o.version} entry does not match module VERSION (${s.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=U.length?U[U.length-1].version:0;if(n!==H)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${H}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let o=0;o<U.length;o++){let s=o+1;if(U[o].version!==s)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${s} at position ${o} but found v${U[o].version}`)}})();function jt(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
249
249
  [FATAL] DATA_DIR is set to whitespace ("${process.env.DATA_DIR}"). Either unset it or set a real path.
250
250
  `),process.exit(1));try{u.mkdirSync(M,{recursive:!0})}catch(t){t.code!=="EEXIST"&&(console.error(`
251
251
  [FATAL] Cannot create DATA_DIR (${M}): ${t.message}`),console.error(` Fix the path or permissions and try again.
@@ -255,37 +255,37 @@ ${o.join(`
255
255
  [FATAL] DATA_DIR (${M}) 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.
256
256
  `),process.exit(1));for(let t of[Z,ee]){let n;try{n=u.lstatSync(t)}catch(o){if(o.code==="ENOENT")continue;throw o}n.isSymbolicLink()&&(console.error(`
257
257
  [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.
258
- `),process.exit(1))}}var X=S.join(M,".migration-lock");function yo(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return u.writeFileSync(X,e,{flag:"wx"}),!0}catch(o){if(o.code!=="EEXIST")throw o}let t;try{t=JSON.parse(u.readFileSync(X,"utf-8"))}catch{t=null}if(t&&Number.isInteger(t.pid)){let o=!1;try{process.kill(t.pid,0),o=!0}catch(l){l.code==="EPERM"&&(o=!0)}let r=24*60*60*1e3,s=1/0;if(t.startedAt){let l=Date.parse(t.startedAt);Number.isNaN(l)||(s=Date.now()-l)}o&&s<r&&(console.error(`
258
+ `),process.exit(1))}}var X=S.join(M,".migration-lock");function yo(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return u.writeFileSync(X,e,{flag:"wx"}),!0}catch(o){if(o.code!=="EEXIST")throw o}let t;try{t=JSON.parse(u.readFileSync(X,"utf-8"))}catch{t=null}if(t&&Number.isInteger(t.pid)){let o=!1;try{process.kill(t.pid,0),o=!0}catch(l){l.code==="EPERM"&&(o=!0)}let s=24*60*60*1e3,r=1/0;if(t.startedAt){let l=Date.parse(t.startedAt);Number.isNaN(l)||(r=Date.now()-l)}o&&r<s&&(console.error(`
259
259
  [FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${t.pid}`),console.error(` Started at: ${t.startedAt||"(unknown)"}`),console.error(` Lock file: ${X}
260
260
  `),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.
261
- `),process.exit(1)),o&&s>=r&&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 n=X+".tmp";try{return u.writeFileSync(n,e),u.renameSync(n,X),!0}catch(o){try{u.unlinkSync(n)}catch{}throw new Error(`Failed to take over stale migration lock: ${o.message}`)}}function Ue(){try{if(JSON.parse(u.readFileSync(X,"utf-8")).pid!==process.pid)return;u.unlinkSync(X)}catch{}}var Rt=!1;function wo(){if(Rt)return;Rt=!0;let e=()=>{try{Ue()}catch{}process.exit(1)};for(let t of["SIGINT","SIGTERM","SIGHUP"])try{process.on(t,e)}catch{}}function bo(){if(u.existsSync(R))return;let e=[],t=[];for(let s of Tt)if(u.existsSync(s))try{e.push({file:s,schema:ge(s)})}catch(l){t.push({file:s,err:l.message})}if(t.length>0){console.error(`
262
- [FATAL] Legacy .schema-version file(s) corrupted \u2014 cannot determine current schema version:`);for(let s of t)console.error(` ${s.file}: ${s.err}`);console.error(`
261
+ `),process.exit(1)),o&&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 n=X+".tmp";try{return u.writeFileSync(n,e),u.renameSync(n,X),!0}catch(o){try{u.unlinkSync(n)}catch{}throw new Error(`Failed to take over stale migration lock: ${o.message}`)}}function Ue(){try{if(JSON.parse(u.readFileSync(X,"utf-8")).pid!==process.pid)return;u.unlinkSync(X)}catch{}}var Rt=!1;function wo(){if(Rt)return;Rt=!0;let e=()=>{try{Ue()}catch{}process.exit(1)};for(let t of["SIGINT","SIGTERM","SIGHUP"])try{process.on(t,e)}catch{}}function bo(){if(u.existsSync(R))return;let e=[],t=[];for(let r of Tt)if(u.existsSync(r))try{e.push({file:r,schema:ge(r)})}catch(l){t.push({file:r,err:l.message})}if(t.length>0){console.error(`
262
+ [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(`
263
263
  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.
264
- `),process.exit(1)}if(e.length===0)return;let n=e.map(s=>s.schema.version);if(new Set(n).size>1){console.error(`
265
- [FATAL] Legacy .schema-version files disagree:`);for(let s of e)console.error(` ${s.file}: v${s.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.
266
- `),process.exit(1)}let o=e[0].schema,r=R+".tmp";try{u.writeFileSync(r,JSON.stringify(o,null,2)),u.renameSync(r,R)}catch(s){try{u.unlinkSync(r)}catch{}throw s}for(let s of Tt)if(u.existsSync(s))try{u.unlinkSync(s)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${R}`)}function So(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 ge(e){let t=u.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function Dt(){if(bo(),!u.existsSync(R))return{version:0,migrations:[]};let e;try{e=ge(R)}catch(n){if(n.code==="ENOENT")return{version:0,migrations:[]};console.error(`
264
+ `),process.exit(1)}if(e.length===0)return;let n=e.map(r=>r.schema.version);if(new Set(n).size>1){console.error(`
265
+ [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.
266
+ `),process.exit(1)}let o=e[0].schema,s=R+".tmp";try{u.writeFileSync(s,JSON.stringify(o,null,2)),u.renameSync(s,R)}catch(r){try{u.unlinkSync(s)}catch{}throw r}for(let r of Tt)if(u.existsSync(r))try{u.unlinkSync(r)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${R}`)}function So(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 ge(e){let t=u.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function Dt(){if(bo(),!u.existsSync(R))return{version:0,migrations:[]};let e;try{e=ge(R)}catch(n){if(n.code==="ENOENT")return{version:0,migrations:[]};console.error(`
267
267
  [FATAL] ${R} is not valid JSON: ${n.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.
268
268
  `),process.exit(1)}let t=So(e);return t===null&&(console.error(`
269
269
  [FATAL] ${R} 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.
270
- `),process.exit(1)),t}function Nt(e){try{u.chmodSync(e,384)}catch{}}function vo(e){if(jt(),u.existsSync(R))try{if(u.lstatSync(R).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${R}. Refusing to write through it (potential symlink attack). Remove the link and re-run.`)}catch(n){if(n.message?.includes("symbolic link"))throw n}let t=R+".tmp";try{u.writeFileSync(t,JSON.stringify(e,null,2)),Nt(t),u.renameSync(t,R)}catch(n){try{u.unlinkSync(t)}catch{}throw n}}function Ot(e,t){if(!u.existsSync(e))return;let n=`.pre-v${String(t).padStart(3,"0")}.backup`,o=u.readdirSync(e).filter(i=>{let a=i.toLowerCase();if(a.includes(".backup")||a===".schema-version"||a.endsWith(".tmp"))return!1;try{return u.statSync(S.join(e,i)).isFile()}catch{return!1}}),r=0,s=0,l=[];for(let i of o){let a=S.join(e,i),f=S.join(e,i+n);if(u.existsSync(f)){s++;continue}try{Ft(a,f),r++}catch(c){l.push({file:i,err:c.message})}}if(l.length>0){let i=new Error(`Failed to back up ${l.length} file(s) in ${S.basename(e)}/: `+l.map(a=>`${a.file} (${a.err})`).join(", "));throw i.code="BACKUP_INCOMPLETE",i}if(r>0||s>0){let i=s>0?` (${s} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${r} files in ${S.basename(e)}/ (${n})${i}`)}}var Pe=!1;async function Lt(){if(Pe)return;jt(),Eo();let t=Dt().version;if(t===H){Pe=!0;return}wo(),yo(),process.on("exit",Ue),t>H&&(console.error(`
270
+ `),process.exit(1)),t}function Nt(e){try{u.chmodSync(e,384)}catch{}}function vo(e){if(jt(),u.existsSync(R))try{if(u.lstatSync(R).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${R}. Refusing to write through it (potential symlink attack). Remove the link and re-run.`)}catch(n){if(n.message?.includes("symbolic link"))throw n}let t=R+".tmp";try{u.writeFileSync(t,JSON.stringify(e,null,2)),Nt(t),u.renameSync(t,R)}catch(n){try{u.unlinkSync(t)}catch{}throw n}}function Ot(e,t){if(!u.existsSync(e))return;let n=`.pre-v${String(t).padStart(3,"0")}.backup`,o=u.readdirSync(e).filter(i=>{let a=i.toLowerCase();if(a.includes(".backup")||a===".schema-version"||a.endsWith(".tmp"))return!1;try{return u.statSync(S.join(e,i)).isFile()}catch{return!1}}),s=0,r=0,l=[];for(let i of o){let a=S.join(e,i),f=S.join(e,i+n);if(u.existsSync(f)){r++;continue}try{Ft(a,f),s++}catch(c){l.push({file:i,err:c.message})}}if(l.length>0){let i=new Error(`Failed to back up ${l.length} file(s) in ${S.basename(e)}/: `+l.map(a=>`${a.file} (${a.err})`).join(", "));throw i.code="BACKUP_INCOMPLETE",i}if(s>0||r>0){let i=r>0?` (${r} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${s} files in ${S.basename(e)}/ (${n})${i}`)}}var Pe=!1;async function Lt(){if(Pe)return;jt(),Eo();let t=Dt().version;if(t===H){Pe=!0;return}wo(),yo(),process.on("exit",Ue),t>H&&(console.error(`
271
271
  [FATAL] Your data schema is at v${t}, but this plugin build only understands up to v${H}.`),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.
272
272
  `),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${H}.
273
273
  `),process.exit(1)),console.log(`
274
274
  \u{1F4E6} Schema migration: v${t} \u2192 v${H}`);let n=Ao();if(!n.ok){console.error(`
275
- [FATAL] Cannot migrate \u2014 current data is corrupted:`);for(let r of n.broken)console.error(` ${r.dir}/${r.file}: ${r.err}`);console.error(`
275
+ [FATAL] Cannot migrate \u2014 current data is corrupted:`);for(let s of n.broken)console.error(` ${s.dir}/${s.file}: ${s.err}`);console.error(`
276
276
  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'.
277
- `),process.exit(1)}let o=U.filter(r=>r.version>t);for(let r of o){console.log(`
278
- Running migration v${String(r.version).padStart(3,"0")}...`);let s=`v${String(r.version).padStart(3,"0")}`,l=`.pre-${s}.backup`;try{Ot(Z,r.version),Ot(ee,r.version)}catch(a){console.error(`
279
- [FATAL] Pre-migration backup failed for ${s}: ${a.message}`),console.error(" Migration NOT applied. Repair the underlying issue (disk space, permissions, locked files)"),console.error(` and re-run the plugin command.
280
- `),process.exit(1)}let i=r.module;try{await i.up(Z,ee)}catch(a){console.error(`
281
- [FATAL] Migration ${s} failed: ${a.message}`),console.error(` Attempting auto-rollback from ${l} files...`);try{let f=_o(l);f.ok?(console.error(` \u2713 Auto-rollback restored ${f.restored} files. Schema stays at v${t}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
277
+ `),process.exit(1)}let o=U.filter(s=>s.version>t);for(let s of o){console.log(`
278
+ Running migration v${String(s.version).padStart(3,"0")}...`);let r=`v${String(s.version).padStart(3,"0")}`,l=`.pre-${r}.backup`;try{Ot(Z,s.version),Ot(ee,s.version)}catch(a){console.error(`
279
+ [FATAL] Pre-migration backup failed for ${r}: ${a.message}`),console.error(" Migration NOT applied. Repair the underlying issue (disk space, permissions, locked files)"),console.error(` and re-run the plugin command.
280
+ `),process.exit(1)}let i=s.module;try{await i.up(Z,ee)}catch(a){console.error(`
281
+ [FATAL] Migration ${r} failed: ${a.message}`),console.error(` Attempting auto-rollback from ${l} files...`);try{let f=_o(l);f.ok?(console.error(` \u2713 Auto-rollback restored ${f.restored} files. Schema stays at v${t}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
282
282
  `)):(console.error(` [!] Auto-rollback INCOMPLETE: ${f.error}`),console.error(` Manual recovery: copy *${l} files back over the originals.
283
283
  `))}catch(f){console.error(` [!] Auto-rollback CRASHED while restoring: ${f.message}`),console.error(` Manual recovery: copy *${l} files back over the originals.
284
- `)}process.exit(1)}try{let a=new Date().toISOString(),f={version:r.version,name:i.NAME||s,appliedAt:a},c=Dt();c.version=r.version,c.migratedAt=a,c.migrations=c.migrations||[],c.migrations.push(f),vo(c)}catch(a){console.error(`
285
- [FATAL] Migration ${s} applied successfully but schema version file could NOT be updated: ${a.message}`),console.error(` Your data is in the v${r.version} state but .schema-version still shows v${t}.`),console.error(` On next plugin command the runner will try to re-apply ${s}. If that migration is`),console.error(` idempotent (most are), it will succeed harmlessly. If you're unsure, run 'data-cleanup' and contact support.
286
- `),process.exit(1)}console.log(` \u2713 Migration ${s} complete`)}try{ft()}catch{}try{wt()}catch{}Pe=!0,Ue(),console.log(`
284
+ `)}process.exit(1)}try{let a=new Date().toISOString(),f={version:s.version,name:i.NAME||r,appliedAt:a},c=Dt();c.version=s.version,c.migratedAt=a,c.migrations=c.migrations||[],c.migrations.push(f),vo(c)}catch(a){console.error(`
285
+ [FATAL] Migration ${r} applied successfully but schema version file could NOT be updated: ${a.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.
286
+ `),process.exit(1)}console.log(` \u2713 Migration ${r} complete`)}try{ft()}catch{}try{wt()}catch{}Pe=!0,Ue(),console.log(`
287
287
  \u2713 Schema is now at v${H}
288
- `)}var ko=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function Co(e){let t=e.toLowerCase();return ko.some(n=>n.test(t))}var xo=6e4;function $o(){let e=Date.now(),t=[];for(let n of[M,Z,ee]){if(!u.existsSync(n))continue;let o;try{o=u.readdirSync(n)}catch{continue}for(let r of o){if(!Co(r))continue;let s=S.join(n,r);try{let l=u.statSync(s);if(!l.isFile()||e-l.mtimeMs<xo)continue;t.push({dir:n,file:r,fullPath:s})}catch{}}}return t}function Eo({verbose:e=!1}={}){let t=$o();if(t.length===0)return e&&console.log(" No orphan .tmp files found."),0;let n=0;for(let o of t)try{u.unlinkSync(o.fullPath),n++,e&&console.log(` Removed orphan: ${S.basename(o.dir)}/${o.file}`)}catch(r){console.warn(` [!] Could not remove orphan ${o.fullPath}: ${r.message}`)}return!e&&n>0&&console.log(` Cleaned up ${n} orphan .tmp file(s) from previous run.`),n}function Ao(){let e=[];for(let t of[Z,ee]){if(!u.existsSync(t))continue;let n=u.readdirSync(t).filter(o=>{let r=o.toLowerCase();return r.endsWith(".json")&&!r.includes(".backup")});for(let o of n){let r=S.join(t,o);try{ge(r)}catch(s){e.push({dir:S.basename(t),file:o,err:s.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function _o(e){let t=[],n=[];for(let s of[Z,ee]){if(!u.existsSync(s))continue;let l=u.readdirSync(s).filter(i=>i.endsWith(e));for(let i of l){let a=S.join(s,i),f=i.slice(0,-e.length),c=S.join(s,f);try{f.toLowerCase().endsWith(".json")?ge(a):u.accessSync(a,u.constants.R_OK),t.push({backupPath:a,originalPath:c,fileName:i,dir:s})}catch(m){n.push(`${S.basename(s)}/${i}: ${m.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let o=0,r=[];for(let{backupPath:s,originalPath:l,fileName:i,dir:a}of t)try{Ft(s,l),o++}catch(f){r.push(`${S.basename(a)}/${i}: ${f.message}`)}return r.length>0?{ok:!1,error:r.join("; "),restored:o}:{ok:!0,restored:o}}function Ft(e,t){let n=t+".tmp";try{u.copyFileSync(e,n),Nt(n)}catch(o){try{u.unlinkSync(n)}catch{}throw o}try{u.renameSync(n,t)}catch(o){try{u.unlinkSync(n)}catch{}if(o.code==="EPERM"||o.code==="EBUSY"){let r=new Error(`File locked: ${t} (${o.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 r.code=o.code,r}throw o}}await Lt();var W=process.argv.slice(2),ye=parseInt(W.find(e=>e.startsWith("--max="))?.split("=")[1]||"10"),ue=W.includes("--connections"),Mt=W.find(e=>e.startsWith("--match-title="))?.split("=").slice(1).join("=")||null,_=Mt?Do(Mt):null,Io=W.includes("--list"),To=W.includes("--verbose"),Be=W.includes("--with-experience"),Ro=W.includes("--help")||W.includes("-h");Ro&&(console.log(`
288
+ `)}var ko=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function Co(e){let t=e.toLowerCase();return ko.some(n=>n.test(t))}var xo=6e4;function $o(){let e=Date.now(),t=[];for(let n of[M,Z,ee]){if(!u.existsSync(n))continue;let o;try{o=u.readdirSync(n)}catch{continue}for(let s of o){if(!Co(s))continue;let r=S.join(n,s);try{let l=u.statSync(r);if(!l.isFile()||e-l.mtimeMs<xo)continue;t.push({dir:n,file:s,fullPath:r})}catch{}}}return t}function Eo({verbose:e=!1}={}){let t=$o();if(t.length===0)return e&&console.log(" No orphan .tmp files found."),0;let n=0;for(let o of t)try{u.unlinkSync(o.fullPath),n++,e&&console.log(` Removed orphan: ${S.basename(o.dir)}/${o.file}`)}catch(s){console.warn(` [!] Could not remove orphan ${o.fullPath}: ${s.message}`)}return!e&&n>0&&console.log(` Cleaned up ${n} orphan .tmp file(s) from previous run.`),n}function Ao(){let e=[];for(let t of[Z,ee]){if(!u.existsSync(t))continue;let n=u.readdirSync(t).filter(o=>{let s=o.toLowerCase();return s.endsWith(".json")&&!s.includes(".backup")});for(let o of n){let s=S.join(t,o);try{ge(s)}catch(r){e.push({dir:S.basename(t),file:o,err:r.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function _o(e){let t=[],n=[];for(let r of[Z,ee]){if(!u.existsSync(r))continue;let l=u.readdirSync(r).filter(i=>i.endsWith(e));for(let i of l){let a=S.join(r,i),f=i.slice(0,-e.length),c=S.join(r,f);try{f.toLowerCase().endsWith(".json")?ge(a):u.accessSync(a,u.constants.R_OK),t.push({backupPath:a,originalPath:c,fileName:i,dir:r})}catch(m){n.push(`${S.basename(r)}/${i}: ${m.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let o=0,s=[];for(let{backupPath:r,originalPath:l,fileName:i,dir:a}of t)try{Ft(r,l),o++}catch(f){s.push(`${S.basename(a)}/${i}: ${f.message}`)}return s.length>0?{ok:!1,error:s.join("; "),restored:o}:{ok:!0,restored:o}}function Ft(e,t){let n=t+".tmp";try{u.copyFileSync(e,n),Nt(n)}catch(o){try{u.unlinkSync(n)}catch{}throw o}try{u.renameSync(n,t)}catch(o){try{u.unlinkSync(n)}catch{}if(o.code==="EPERM"||o.code==="EBUSY"){let s=new Error(`File locked: ${t} (${o.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=o.code,s}throw o}}await Lt();var W=process.argv.slice(2),ye=parseInt(W.find(e=>e.startsWith("--max="))?.split("=")[1]||"10"),ue=W.includes("--connections"),Mt=W.find(e=>e.startsWith("--match-title="))?.split("=").slice(1).join("=")||null,_=Mt?Do(Mt):null,Io=W.includes("--list"),To=W.includes("--verbose"),Be=W.includes("--with-experience"),Ro=W.includes("--help")||W.includes("-h");Ro&&(console.log(`
289
289
  enrich-profiles \u2014 batch-visit contacts in people.json missing About text
290
290
 
291
291
  USAGE
@@ -328,12 +328,12 @@ WHEN TO USE
328
328
  - You want to backfill in a controlled batch (\u2264 10 per day) before reaching
329
329
  out, so AI drafting has full context.
330
330
  - Use --connections to keep ban risk low.
331
- `),process.exit(0));function Do(e){try{return new RegExp(e,"i")}catch(t){console.error(`Invalid regex for --match-title: ${t.message}`),process.exit(1)}}var Oo=new Set(["pending","sent_with_note","sent_without_note"]);function jo(e){return!e.about||!e.about.trim()}function No(e){return!Oo.has(e.connectionStatus)}function Pt(){let e=K(),t=_e(),n=new Set,o=new Set;for(let i of Object.values(t))i.profileUrl&&n.add(i.profileUrl),(i.unread===!0||i.actionNeeded==="reply"||i.situation==="needs_our_reply"||i.conversationStatus==="unanswered_by_us")&&i.profileUrl&&o.add(i.profileUrl);let s=Object.entries(e).filter(([i,a])=>i&&i.startsWith("http")).filter(([,i])=>jo(i)).filter(([,i])=>No(i)).filter(([i])=>!o.has(i)).map(([i,a])=>({profileUrl:i,name:a.name,person:a,hasConversation:n.has(i)}));ue&&(s=s.filter(i=>i.person.connectionStatus==="connected")),_&&(s=s.filter(i=>_.test(i.person.title||"")));function l(i){let a=i.person.connectionStatus==="connected";return a&&i.hasConversation?1:a?2:_&&_.test(i.person.title||"")?3:i.hasConversation?4:5}return s.sort((i,a)=>{let f=l(i),c=l(a);if(f!==c)return f-c;let m=i.person.lastFullVisitAt||"",d=a.person.lastFullVisitAt||"";return m.localeCompare(d)}),s.map(i=>({profileUrl:i.profileUrl,name:i.name,source:"enrich-profile"}))}function Lo(){let e=K(),t=Object.keys(e).length,n=Object.values(e).filter(m=>m.about&&m.about.trim()).length,o=t-n,r=Pt(),s={connWithConv:0,conn:0,titleMatch:0,withConv:0,other:0},l=e,i=_e(),a=new Set(Object.values(i).map(m=>m.profileUrl).filter(Boolean)),f=Object.values(i).filter(m=>m.profileUrl&&(m.unread===!0||m.actionNeeded==="reply"||m.situation==="needs_our_reply"||m.conversationStatus==="unanswered_by_us")).length,c=0;for(let m of r){let d=l[m.profileUrl],p=d.connectionStatus==="connected",v=_&&_.test(d.title||""),b=a.has(m.profileUrl);d.lastFullVisitAt||c++,p&&b?s.connWithConv++:p?s.conn++:v?s.titleMatch++:b?s.withConv++:s.other++}console.log(`
332
- \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(" PROFILE ENRICHMENT QUEUE"),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(` Total people: ${t}`),console.log(` With "about": ${n} (${(n/t*100).toFixed(1)}%)`),console.log(` Missing "about": ${o}`),console.log(` Skipped (needs reply): ${f}`),console.log(` Visitable (queue): ${r.length}`),console.log(` Never fully visited: ${c} (gone first)`),_&&console.log(` Title-match filter: /${_.source}/i`),ue&&console.log(" Connections-only: yes"),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(` Tier 1 (conn+conv): ${s.connWithConv}`),console.log(` Tier 2 (connection): ${s.conn}`),console.log(` Tier 3 (title match): ${s.titleMatch}${_?"":" (no --match-title set)"}`),console.log(` Tier 4 (conversation): ${s.withConv}`),console.log(` Tier 5 (other): ${s.other}`),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(` At ${ye}/day \u2192 ~${Math.ceil(r.length/ye)} days to clear queue
331
+ `),process.exit(0));function Do(e){try{return new RegExp(e,"i")}catch(t){console.error(`Invalid regex for --match-title: ${t.message}`),process.exit(1)}}var Oo=new Set(["pending","sent_with_note","sent_without_note"]);function jo(e){return!e.about||!e.about.trim()}function No(e){return!Oo.has(e.connectionStatus)}function Pt(){let e=K(),t=_e(),n=new Set,o=new Set;for(let i of Object.values(t))i.profileUrl&&n.add(i.profileUrl),(i.unread===!0||i.actionNeeded==="reply"||i.situation==="needs_our_reply"||i.conversationStatus==="unanswered_by_us")&&i.profileUrl&&o.add(i.profileUrl);let r=Object.entries(e).filter(([i,a])=>i&&i.startsWith("http")).filter(([,i])=>jo(i)).filter(([,i])=>No(i)).filter(([i])=>!o.has(i)).map(([i,a])=>({profileUrl:i,name:a.name,person:a,hasConversation:n.has(i)}));ue&&(r=r.filter(i=>i.person.connectionStatus==="connected")),_&&(r=r.filter(i=>_.test(i.person.title||"")));function l(i){let a=i.person.connectionStatus==="connected";return a&&i.hasConversation?1:a?2:_&&_.test(i.person.title||"")?3:i.hasConversation?4:5}return r.sort((i,a)=>{let f=l(i),c=l(a);if(f!==c)return f-c;let m=i.person.lastFullVisitAt||"",d=a.person.lastFullVisitAt||"";return m.localeCompare(d)}),r.map(i=>({profileUrl:i.profileUrl,name:i.name,source:"enrich-profile"}))}function Lo(){let e=K(),t=Object.keys(e).length,n=Object.values(e).filter(m=>m.about&&m.about.trim()).length,o=t-n,s=Pt(),r={connWithConv:0,conn:0,titleMatch:0,withConv:0,other:0},l=e,i=_e(),a=new Set(Object.values(i).map(m=>m.profileUrl).filter(Boolean)),f=Object.values(i).filter(m=>m.profileUrl&&(m.unread===!0||m.actionNeeded==="reply"||m.situation==="needs_our_reply"||m.conversationStatus==="unanswered_by_us")).length,c=0;for(let m of s){let d=l[m.profileUrl],p=d.connectionStatus==="connected",v=_&&_.test(d.title||""),b=a.has(m.profileUrl);d.lastFullVisitAt||c++,p&&b?r.connWithConv++:p?r.conn++:v?r.titleMatch++:b?r.withConv++:r.other++}console.log(`
332
+ \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(" PROFILE ENRICHMENT QUEUE"),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(` Total people: ${t}`),console.log(` With "about": ${n} (${(n/t*100).toFixed(1)}%)`),console.log(` Missing "about": ${o}`),console.log(` Skipped (needs reply): ${f}`),console.log(` Visitable (queue): ${s.length}`),console.log(` Never fully visited: ${c} (gone first)`),_&&console.log(` Title-match filter: /${_.source}/i`),ue&&console.log(" Connections-only: yes"),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(` Tier 1 (conn+conv): ${r.connWithConv}`),console.log(` Tier 2 (connection): ${r.conn}`),console.log(` Tier 3 (title match): ${r.titleMatch}${_?"":" (no --match-title set)"}`),console.log(` Tier 4 (conversation): ${r.withConv}`),console.log(` Tier 5 (other): ${r.other}`),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(` At ${ye}/day \u2192 ~${Math.ceil(s.length/ye)} days to clear queue
333
333
  `)}function Fo(){console.log(""),console.log(" \u2554\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\u2550\u2550\u2550\u2550\u2557"),console.log(" \u2551 \u26A0 BAN-RISK WARNING \u2014 please read \u2551"),console.log(" \u2560\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\u2550\u2550\u2550\u2550\u2563"),console.log(" \u2551 This script visits LinkedIn profiles WITHOUT performing any \u2551"),console.log(" \u2551 follow-up action (no message, no connect request, no like). \u2551"),console.log(" \u2551 LinkedIn has previously flagged accounts for exactly this \u2551"),console.log(' \u2551 pattern with a "we noticed unusual activity" warning. \u2551'),console.log(" \u2551 \u2551"),console.log(" \u2551 Safer alternative: let data accumulate organically through \u2551"),console.log(" \u2551 apply / outreach / funnel / visit \u2014 those visits HAVE a \u2551"),console.log(" \u2551 purpose and don't trip the same heuristic. \u2551"),console.log(" \u2551 \u2551"),console.log(" \u2551 If you proceed, keep --max small (\u226410) and run at most once \u2551"),console.log(" \u2551 per day. Your account, your call. \u2551"),console.log(" \u255A\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\u2550\u2550\u2550\u2550\u255D"),console.log("")}async function Mo(){if(console.log(`
334
334
  LinkedIn Profile Enricher
335
335
  `),Io){Lo();return}Fo(),Be&&(console.log(""),console.log(" \u2554\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\u2550\u2550\u2550\u2550\u2557"),console.log(" \u2551 \u26A0 --with-experience: extra ban-risk warning \u2551"),console.log(" \u2560\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\u2550\u2550\u2550\u2550\u2563"),console.log(" \u2551 Each visit now does TWO page loads (main + /details/ \u2551"),console.log(" \u2551 experience/). That doubles LinkedIn's view-counter signal \u2551"),console.log(" \u2551 per profile. Keep --max low (\u226410) and run rarely. \u2551"),console.log(" \u255A\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\u2550\u2550\u2550\u2550\u255D"),console.log(""));let e=Pt();if(console.log(` Queue size: ${e.length}`),console.log(` Max visits this session: ${ye}`),_&&console.log(` Title filter: /${_.source}/i`),ue&&console.log(" Connections only: yes"),Be&&console.log(" With experience: yes (2\xD7 page loads per profile)"),console.log(""),e.length===0){console.log(` Nothing to enrich \u2014 every visitable profile already has "about".
336
- `);return}let t=ue&&_?"connections+title":ue?"connections":_?`title=${_.source}`:"all",n=At("enrich-profiles",t),{browser:o,page:r}=await lt();try{let s=await vt(r,e,{maxVisits:ye,verbose:To,skipRecentDays:7,extractExperience:Be}),l=K(),i=0;for(let a of e.slice(0,s.visited+s.skipped))l[a.profileUrl]?.about?.trim()&&i++;console.log(`
337
- \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(" Enrichment Complete"),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(` Visited: ${s.visited}`),console.log(` Skipped (recent): ${s.skipped}`),console.log(` Errors: ${s.errors}`),console.log(` Have "about" now: ${i} / ${s.visited+s.skipped}`),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
338
- `),Oe(n,"success",s)}catch(s){console.error(`
339
- Error:`,s.message),Oe(n,"error",null,s.message)}finally{await o.close().catch(()=>{})}}Mo().catch(e=>{console.error("Enrich-profiles failed:",e),process.exit(1)});
336
+ `);return}let t=ue&&_?"connections+title":ue?"connections":_?`title=${_.source}`:"all",n=At("enrich-profiles",t),{browser:o,page:s}=await lt();try{let r=await vt(s,e,{maxVisits:ye,verbose:To,skipRecentDays:7,extractExperience:Be}),l=K(),i=0;for(let a of e.slice(0,r.visited+r.skipped))l[a.profileUrl]?.about?.trim()&&i++;console.log(`
337
+ \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(" Enrichment Complete"),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(` Visited: ${r.visited}`),console.log(` Skipped (recent): ${r.skipped}`),console.log(` Errors: ${r.errors}`),console.log(` Have "about" now: ${i} / ${r.visited+r.skipped}`),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
338
+ `),Oe(n,"success",r)}catch(r){console.error(`
339
+ Error:`,r.message),Oe(n,"error",null,r.message)}finally{await o.close().catch(()=>{})}}Mo().catch(e=>{console.error("Enrich-profiles failed:",e),process.exit(1)});