ilml-plugin-linkedin 1.20.5 → 1.20.7

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,8 +1,8 @@
1
- var Tn=Object.defineProperty;var ce=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{for(var n in t)Tn(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 De(e,t,{timeout:n=45e3,poll:o=1e3,label:r="page"}={}){let s=Date.now();for(;Date.now()-s<n;){try{if(await e.evaluate(l=>!!document.querySelector(l),t)){let l=Date.now()-s;return l>6e3&&console.log(` (waited ${Math.round(l/1e3)}s for LinkedIn to finish loading ${r})`),!0}}catch{}await new Promise(i=>setTimeout(i,o))}return!1}async function bt(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"),i=r.includes("Try for")||r.includes("free trial")||r.includes("/month")||r.includes("per month")||r.includes("Start my")||r.includes("Subscribe"),l=r.includes("Get hired faster")||r.includes("Get hired 2x");if(s||i||l){let c=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(c)return c.click(),{dismissed:!0,matched:r.substring(0,80)};let d=o.querySelectorAll("button");for(let a of d){let m=a.innerText?.trim().toLowerCase()||"",f=a.getAttribute("aria-label")?.toLowerCase()||"";if(m==="not now"||m==="no thanks"||m==="dismiss"||f.includes("dismiss"))return a.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 he=ce(()=>{});import{getPluginConfig as Rn}from"@ilivemylife/graph-sdk";var Dn,On,X,Nr,jn,Oe=ce(async()=>{Dn=await Rn();for(let[e,t]of Object.entries(Dn))process.env[e]===void 0&&(process.env[e]=t);On=process.env.LINKEDIN_NAME,X=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Nr=Object.freeze(new Set([X.DRAFT,X.CONFIRMED,X.NEEDS_REVIEW])),jn=Object.freeze(new Set([X.DRAFT,X.CONFIRMED,X.REJECTED,X.NEEDS_REVIEW]))});import"dotenv/config";import*as x from"fs";import*as A from"path";import{fileURLToPath as Gn}from"url";function Ht(){ue=null,zn=null,Qn=null,ae=null,Zn=null,Xn=null}function Me(){x.existsSync(q)||x.mkdirSync(q,{recursive:!0})}function Pe(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";x.writeFileSync(o,n);for(let r=0;r<3;r++)try{x.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function qe(e,t){if(!x.existsSync(e))return null;try{let n=JSON.parse(x.readFileSync(e,"utf-8"));try{x.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${A.resolve(e)}`);let o=e+".backup";if(x.existsSync(o))try{let r=JSON.parse(x.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{x.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{x.copyFileSync(e,e+".corrupted")}catch{}return null}}function eo(){return new Date().toISOString().split("T")[0]}function ee(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function Pt(e){return typeof e=="string"?e.replace(/\s+/g," ").trim().toLowerCase():""}function Jt(e,t,n=null){if(!t||e[t])return t;let o=ee(t);if(!o)return t;let r=null;for(let[s,i]of Object.entries(e)){if(ee(i.profileUrl||s)===o)return s;!r&&Array.isArray(i.aliases)&&i.aliases.includes(o)&&(r=s)}if(r){let s=Pt(n),i=Pt(e[r].name);if(s&&i&&s===i)return r}return t}function oo(){x.existsSync(Fe)||x.mkdirSync(Fe,{recursive:!0})}function Wt(e){let t=ee(e);return t?A.join(Fe,`${t}.json`):null}function ro(e){let t=Wt(e);return t?qe(t,`profile-history/${ee(e)}.json`)||[]:[]}function so(e,t){let n=Wt(e);if(!n)return;oo();let o=ro(e);o.unshift(t);try{Pe(n,o)}catch(r){console.error(`[!] Failed to append profile-history for ${ee(e)}: ${r.message}`)}}function qt(e){return!!(e==null||Array.isArray(e)&&e.length===0||typeof e=="string"&&!e.trim())}function Ut(e){return Array.isArray(e)?[...e].map(t=>String(t).trim()).sort().join("||"):typeof e=="string"?e.replace(/\s+/g," ").trim():e}function io(e,t){if(!e)return[];let n=[];for(let o of no){let r=e[o],s=t[o];qt(r)||qt(s)||Ut(r)!==Ut(s)&&n.push(o)}return n}function lo(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 J(){return ue||(Me(),ue=qe(Le,"people.json")||{},ue)}function Gt(e){Me(),ue=e;try{Pe(Le,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${A.resolve(Le)}`)}}function Ue(){return ae||(Me(),ae=qe(Bt,"conversations.json")||{},co(ae),ae)}function co(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{Pe(Bt,e)}catch{}}}function Be(e,t={}){if(!e)return null;let n=J(),o=eo(),r=new Date().toISOString(),s=Jt(n,e,t.name),i=n[s];if(i){let l=io(i,t);l.length>0&&(so(s,{capturedAt:r,previousLastUpdated:i.lastUpdated||null,changedFields:l,snapshot:lo(i)}),i.lastSnapshotAt=r),i.seenCount=(i.seenCount||1)+1,i.lastSeen=o,i.lastUpdated=r,t.source&&!i.sources?.includes(t.source)&&(i.sources=i.sources||[],i.sources.push(t.source));for(let c of to)if(t[c]!=null){if(Array.isArray(t[c])&&t[c].length===0&&Array.isArray(i[c])&&i[c].length>0)continue;i[c]=t[c]}Array.isArray(t.availableSections)&&(i.lastFullVisitAt=r)}else n[s]={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,requestedConnectionAt:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:r,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(t.availableSections)?r:null};return Gt(n),n[s]}function Ve(e,t,n={}){if(n.dryRun||!e||!t)return;let o=ee(t);if(!o)return;let r=J(),s=Jt(r,e),i=r[s];if(!i)return;let l=ee(i.profileUrl||s);o!==l&&(Array.isArray(i.aliases)||(i.aliases=[]),i.aliases.includes(o)||(i.aliases.push(o),i.lastUpdated=new Date().toISOString(),Gt(r)))}var Yn,Kn,q,Le,ss,is,Bt,ls,cs,Fe,Vt,as,us,ue,zn,Qn,ae,Zn,Xn,to,no,we=ce(async()=>{await Oe();Yn=Gn(import.meta.url),Kn=A.dirname(A.dirname(Yn)),q=process.env.DATA_DIR?A.resolve(process.env.DATA_DIR,"collected-profiles"):A.join(Kn,"collected-profiles"),Le=A.join(q,"people.json"),ss=A.join(q,"jobs.json"),is=A.join(q,"quota.json"),Bt=A.join(q,"conversations.json"),ls=A.join(q,"sync-state.json"),cs=A.join(q,"application-questions.json"),Fe=A.join(q,"profile-history"),Vt=(e,t)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:t},as=Vt(process.env.CONNECT_MAX_DAILY,20),us=Vt(process.env.CONNECT_MAX_WEEKLY,100),ue=null,zn=null,Qn=null,ae=null,Zn=null,Xn=null;to=["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"],no=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"]});var Yt={};pe(Yt,{extractCertificationsFromDetails:()=>po,extractEducationFromDetails:()=>fo,extractExperienceFromDetails:()=>ao,extractFeaturedFromDetails:()=>uo,extractRecommendationsFromDetails:()=>ho,extractSkillsFromDetails:()=>mo});async function ao(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 i of document.querySelectorAll("button"))if(/^Load more$/i.test((i.textContent||"").trim()))return i.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 i(a){let m=[];for(let f of a.querySelectorAll("div")){let p=Array.from(f.children).filter(b=>b.tagName==="DIV");if(p.length<3)continue;let v=p.filter(b=>(b.textContent||"").trim().length>50);v.length<3||(f.textContent||"").length<500||m.push({el:f,count:v.length,totalText:(f.textContent||"").length})}return m.sort((f,p)=>p.count-f.count||f.totalText-p.totalText),m[0]?.el}let l=i(s);if(!l)return[];let c=Array.from(l.children).filter(a=>a.tagName==="DIV").filter(a=>(a.textContent||"").trim().length>50);function d(a){let m=a[0]||null,f=null,p=null;if(a[1]){let g=a[1].split("\xB7").map(T=>T.trim());f=g[0]||null,g[1]&&(p=g[1])}let v=a.findIndex(g=>/(\d{4}|present)/i.test(g)&&/(-|–|—)/i.test(g)&&g.length<80),b=null,E=null;if(v>=0){let g=a[v].split("\xB7").map(T=>T.trim());b=g[0]||null,g[1]&&(E=g[1])}let K=null,z=-1;if(v>=0&&a[v+1]){let g=a[v+1],T=/^[>*\-•]|^&gt;/.test(g),de=/https?:\/\//.test(g),ie=/\d{4}/.test(g),le=/,/.test(g)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(g);!T&&!de&&!ie&&g.length<100&&le&&(K=g,z=v+1)}let Q=null,Ie=-1,C=a[a.length-1];if(C&&/and\s+\+\d+\s+skills?$/i.test(C)){Ie=a.length-1;let g=C.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);g&&(Q={listed:g[1].split(",").map(T=>T.trim()),additional:parseInt(g[2],10)})}let fe=new Set([0,1,v,z,Ie].filter(g=>g>=0)),B=a.filter((g,T)=>!fe.has(T)),Z=B.length>0?B.join(`
1
+ var Tn=Object.defineProperty;var le=(e,t)=>()=>(e&&(t=e(e=0)),t);var me=(e,t)=>{for(var n in t)Tn(e,n,{get:t[n],enumerable:!0})};async function v(e){let t=Math.floor(Math.random()*2001),n=e+t;return new Promise(o=>setTimeout(o,n))}async function Rn(e,t,{timeout:n=45e3,poll:o=1e3,label:r="page"}={}){let s=Date.now();for(;Date.now()-s<n;){try{if(await e.evaluate(l=>!!document.querySelector(l),t)){let l=Date.now()-s;return l>6e3&&console.log(` (waited ${Math.round(l/1e3)}s for LinkedIn to finish loading ${r})`),!0}}catch{}await new Promise(i=>setTimeout(i,o))}return!1}function On(e){return Dn.test(e||"")}async function Re(e,{readySelector:t,label:n="page",timeout:o=45e3}={}){let r=await Rn(e,t,{timeout:o,label:n});if(!r&&On(e.url())){let s=new Error(`Session expired (${n}) \u2014 redirected to login. Run: ilml linkedin login`);throw s.code="SESSION_EXPIRED",s}return r}async function De(e,t,{readySelector:n,label:o="page",timeout:r=45e3,gotoTimeout:s=6e4}={}){return await e.goto(t,{waitUntil:"domcontentloaded",timeout:s}),Re(e,{readySelector:n,label:o,timeout:r})}async function bt(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"),i=r.includes("Try for")||r.includes("free trial")||r.includes("/month")||r.includes("per month")||r.includes("Start my")||r.includes("Subscribe"),l=r.includes("Get hired faster")||r.includes("Get hired 2x");if(s||i||l){let c=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(c)return c.click(),{dismissed:!0,matched:r.substring(0,80)};let a=o.querySelectorAll("button");for(let u of a){let m=u.innerText?.trim().toLowerCase()||"",d=u.getAttribute("aria-label")?.toLowerCase()||"";if(m==="not now"||m==="no thanks"||m==="dismiss"||d.includes("dismiss"))return u.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 Dn,pe=le(()=>{Dn=/\/authwall|\/login|\/checkpoint|\/uas\/login/});import{getPluginConfig as jn}from"@ilivemylife/graph-sdk";var Nn,Ln,X,Pr,Fn,Oe=le(async()=>{Nn=await jn();for(let[e,t]of Object.entries(Nn))process.env[e]===void 0&&(process.env[e]=t);Ln=process.env.LINKEDIN_NAME,X=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Pr=Object.freeze(new Set([X.DRAFT,X.CONFIRMED,X.NEEDS_REVIEW])),Fn=Object.freeze(new Set([X.DRAFT,X.CONFIRMED,X.REJECTED,X.NEEDS_REVIEW]))});import"dotenv/config";import*as C from"fs";import*as A from"path";import{fileURLToPath as zn}from"url";function Ht(){ae=null,Zn=null,eo=null,ce=null,to=null,no=null}function Pe(){C.existsSync(q)||C.mkdirSync(q,{recursive:!0})}function Me(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 i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function qe(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: ${A.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 oo(){return new Date().toISOString().split("T")[0]}function Z(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function Mt(e){return typeof e=="string"?e.replace(/\s+/g," ").trim().toLowerCase():""}function Wt(e,t,n=null){if(!t||e[t])return t;let o=Z(t);if(!o)return t;let r=null;for(let[s,i]of Object.entries(e)){if(Z(i.profileUrl||s)===o)return s;!r&&Array.isArray(i.aliases)&&i.aliases.includes(o)&&(r=s)}if(r){let s=Mt(n),i=Mt(e[r].name);if(s&&i&&s===i)return r}return t}function io(){C.existsSync(Fe)||C.mkdirSync(Fe,{recursive:!0})}function Jt(e){let t=Z(e);return t?A.join(Fe,`${t}.json`):null}function lo(e){let t=Jt(e);return t?qe(t,`profile-history/${Z(e)}.json`)||[]:[]}function co(e,t){let n=Jt(e);if(!n)return;io();let o=lo(e);o.unshift(t);try{Me(n,o)}catch(r){console.error(`[!] Failed to append profile-history for ${Z(e)}: ${r.message}`)}}function qt(e){return!!(e==null||Array.isArray(e)&&e.length===0||typeof e=="string"&&!e.trim())}function Ut(e){return Array.isArray(e)?[...e].map(t=>String(t).trim()).sort().join("||"):typeof e=="string"?e.replace(/\s+/g," ").trim():e}function ao(e,t){if(!e)return[];let n=[];for(let o of so){let r=e[o],s=t[o];qt(r)||qt(s)||Ut(r)!==Ut(s)&&n.push(o)}return n}function uo(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 W(){return ae||(Pe(),ae=qe(Le,"people.json")||{},ae)}function Gt(e){Pe(),ae=e;try{Me(Le,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${A.resolve(Le)}`)}}function Ue(){return ce||(Pe(),ce=qe(Bt,"conversations.json")||{},fo(ce),ce)}function fo(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{Me(Bt,e)}catch{}}}function Be(e,t={}){if(!e)return null;let n=W(),o=oo(),r=new Date().toISOString(),s=Wt(n,e,t.name),i=n[s];if(i){let l=ao(i,t);l.length>0&&(co(s,{capturedAt:r,previousLastUpdated:i.lastUpdated||null,changedFields:l,snapshot:uo(i)}),i.lastSnapshotAt=r),i.seenCount=(i.seenCount||1)+1,i.lastSeen=o,i.lastUpdated=r,t.source&&!i.sources?.includes(t.source)&&(i.sources=i.sources||[],i.sources.push(t.source));for(let c of ro)if(t[c]!=null){if(Array.isArray(t[c])&&t[c].length===0&&Array.isArray(i[c])&&i[c].length>0)continue;i[c]=t[c]}Array.isArray(t.availableSections)&&(i.lastFullVisitAt=r)}else n[s]={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,requestedConnectionAt:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:r,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(t.availableSections)?r:null};return Gt(n),n[s]}function Ve(e,t,n={}){if(n.dryRun||!e||!t)return;let o=Z(t);if(!o)return;let r=W(),s=Wt(r,e),i=r[s];if(!i)return;let l=Z(i.profileUrl||s);o!==l&&(Array.isArray(i.aliases)||(i.aliases=[]),i.aliases.includes(o)||(i.aliases.push(o),i.lastUpdated=new Date().toISOString(),Gt(r)))}var Qn,Xn,q,Le,cs,as,Bt,us,fs,Fe,Vt,ds,ms,ae,Zn,eo,ce,to,no,ro,so,ye=le(async()=>{await Oe();Qn=zn(import.meta.url),Xn=A.dirname(A.dirname(Qn)),q=process.env.DATA_DIR?A.resolve(process.env.DATA_DIR,"collected-profiles"):A.join(Xn,"collected-profiles"),Le=A.join(q,"people.json"),cs=A.join(q,"jobs.json"),as=A.join(q,"quota.json"),Bt=A.join(q,"conversations.json"),us=A.join(q,"sync-state.json"),fs=A.join(q,"application-questions.json"),Fe=A.join(q,"profile-history"),Vt=(e,t)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:t},ds=Vt(process.env.CONNECT_MAX_DAILY,20),ms=Vt(process.env.CONNECT_MAX_WEEKLY,100),ae=null,Zn=null,eo=null,ce=null,to=null,no=null;ro=["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"],so=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"]});var Yt={};me(Yt,{extractCertificationsFromDetails:()=>yo,extractEducationFromDetails:()=>ho,extractExperienceFromDetails:()=>mo,extractFeaturedFromDetails:()=>po,extractRecommendationsFromDetails:()=>wo,extractSkillsFromDetails:()=>go});async function mo(e,t){let n=t.replace(/\/+$/,"")+"/details/experience/";try{await e.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await Re(e,{readySelector:"main .pvs-list, .scaffold-layout__main, main.scaffold-layout__main, section.artdeco-card",label:"experience details"}),await v(1e3);for(let r=0;r<5;r++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await v(900);await v(1e3);let o=0;for(;o<5&&await e.evaluate(()=>{for(let s of document.querySelectorAll("button"))if(/^Load more$/i.test((s.textContent||"").trim()))return s.click(),!0;return!1});)o++,await v(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await v(700);return await e.evaluate(()=>{let r=document.querySelector("main");if(!r)return[];function s(a){let u=[];for(let m of a.querySelectorAll("div")){let d=Array.from(m.children).filter(x=>x.tagName==="DIV");if(d.length<3)continue;let h=d.filter(x=>(x.textContent||"").trim().length>50);h.length<3||(m.textContent||"").length<500||u.push({el:m,count:h.length,totalText:(m.textContent||"").length})}return u.sort((m,d)=>d.count-m.count||m.totalText-d.totalText),u[0]?.el}let i=s(r);if(!i)return[];let l=Array.from(i.children).filter(a=>a.tagName==="DIV").filter(a=>(a.textContent||"").trim().length>50);function c(a){let u=a[0]||null,m=null,d=null;if(a[1]){let g=a[1].split("\xB7").map(T=>T.trim());m=g[0]||null,g[1]&&(d=g[1])}let h=a.findIndex(g=>/(\d{4}|present)/i.test(g)&&/(-|–|—)/i.test(g)&&g.length<80),x=null,S=null;if(h>=0){let g=a[h].split("\xB7").map(T=>T.trim());x=g[0]||null,g[1]&&(S=g[1])}let E=null,K=-1;if(h>=0&&a[h+1]){let g=a[h+1],T=/^[>*\-•]|^&gt;/.test(g),fe=/https?:\/\//.test(g),se=/\d{4}/.test(g),ie=/,/.test(g)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(g);!T&&!fe&&!se&&g.length<100&&ie&&(E=g,K=h+1)}let z=null,_e=-1,k=a[a.length-1];if(k&&/and\s+\+\d+\s+skills?$/i.test(k)){_e=a.length-1;let g=k.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);g&&(z={listed:g[1].split(",").map(T=>T.trim()),additional:parseInt(g[2],10)})}let ue=new Set([0,1,h,K,_e].filter(g=>g>=0)),B=a.filter((g,T)=>!ue.has(T)),Q=B.length>0?B.join(`
2
2
 
3
- `):null;return{title:m,company:f,employmentType:p,dates:b,duration:E,location:K,description:Z,skills:Q,_raw:a}}return c.map(a=>{let f=(a.innerText||"").trim().split(`
4
- `).map(p=>p.trim()).filter(p=>p&&p.length<5e3);return d(f)}).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 ${t}: ${o.message?.slice(0,120)}`),[]}}async function be(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 i=0;i<4;i++)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 l of document.querySelectorAll("button"))if(/^Load more$/i.test((l.textContent||"").trim()))return l.click(),!0;return!1});)s++,await k(1300),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await k(600)}async function ve(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 uo(e,t){return ve(t,"featured","extractFeaturedFromDetails",async()=>(await be(e,t,"featured"),await e.evaluate(`(() => {
5
- ${Se}
3
+ `):null;return{title:u,company:m,employmentType:d,dates:x,duration:S,location:E,description:Q,skills:z,_raw:a}}return l.map(a=>{let m=(a.innerText||"").trim().split(`
4
+ `).map(d=>d.trim()).filter(d=>d&&d.length<5e3);return c(m)}).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 ${t}: ${o.message?.slice(0,120)}`),[]}}async function we(e,t,n){let o=t.replace(/\/+$/,"")+`/details/${n}/`;await e.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await v(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 i=0;i<4;i++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await v(700);await v(800);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 v(1300),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await v(600)}async function Se(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 po(e,t){return Se(t,"featured","extractFeaturedFromDetails",async()=>(await we(e,t,"featured"),await e.evaluate(`(() => {
5
+ ${be}
6
6
 
7
7
  const main = document.querySelector('main');
8
8
  if (!main) return [];
@@ -42,8 +42,8 @@ var Tn=Object.defineProperty;var ce=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{
42
42
  if (e.caption && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.caption.trim())) return false;
43
43
  return true;
44
44
  });
45
- })()`)))}async function fo(e,t){return ve(t,"education","extractEducationFromDetails",async()=>(await be(e,t,"education"),await e.evaluate(`(() => {
46
- ${Se}
45
+ })()`)))}async function ho(e,t){return Se(t,"education","extractEducationFromDetails",async()=>(await we(e,t,"education"),await e.evaluate(`(() => {
46
+ ${be}
47
47
 
48
48
  const main = document.querySelector('main');
49
49
  if (!main) return [];
@@ -79,8 +79,8 @@ var Tn=Object.defineProperty;var ce=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{
79
79
  if (e.degree && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.degree.trim())) return false;
80
80
  return true;
81
81
  });
82
- })()`)))}async function mo(e,t){return ve(t,"skills","extractSkillsFromDetails",async()=>(await be(e,t,"skills"),await e.evaluate(`(() => {
83
- ${Se}
82
+ })()`)))}async function go(e,t){return Se(t,"skills","extractSkillsFromDetails",async()=>(await we(e,t,"skills"),await e.evaluate(`(() => {
83
+ ${be}
84
84
 
85
85
  const main = document.querySelector('main');
86
86
  if (!main) return [];
@@ -111,8 +111,8 @@ var Tn=Object.defineProperty;var ce=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{
111
111
  skills.push({ name, endorsements, _raw: lines });
112
112
  }
113
113
  return skills;
114
- })()`)))}async function po(e,t){return ve(t,"certifications","extractCertificationsFromDetails",async()=>(await be(e,t,"certifications"),await e.evaluate(`(() => {
115
- ${Se}
114
+ })()`)))}async function yo(e,t){return Se(t,"certifications","extractCertificationsFromDetails",async()=>(await we(e,t,"certifications"),await e.evaluate(`(() => {
115
+ ${be}
116
116
 
117
117
  const main = document.querySelector('main');
118
118
  if (!main) return [];
@@ -136,8 +136,8 @@ var Tn=Object.defineProperty;var ce=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{
136
136
 
137
137
  return { name, issuer, issueDate, expiryDate, credentialId, _raw: lines };
138
138
  }).filter(e => e.name);
139
- })()`)))}async function ho(e,t){return ve(t,"recommendations","extractRecommendationsFromDetails",async()=>(await be(e,t,"recommendations"),await e.evaluate(`(() => {
140
- ${Se}
139
+ })()`)))}async function wo(e,t){return Se(t,"recommendations","extractRecommendationsFromDetails",async()=>(await we(e,t,"recommendations"),await e.evaluate(`(() => {
140
+ ${be}
141
141
 
142
142
  const main = document.querySelector('main');
143
143
  if (!main) return [];
@@ -172,7 +172,7 @@ var Tn=Object.defineProperty;var ce=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{
172
172
  if (e.recommenderTitle && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.recommenderTitle.trim())) return false;
173
173
  return true;
174
174
  });
175
- })()`)))}var Se,Kt=ce(()=>{he();Se=`
175
+ })()`)))}var be,Kt=le(()=>{pe();be=`
176
176
  function findEntryContainer(root) {
177
177
  const candidates = [];
178
178
  for (const div of root.querySelectorAll('div')) {
@@ -235,54 +235,54 @@ 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
- `});var Qt=ce(()=>{});import"dotenv/config";import*as D from"fs";import*as I from"path";import{fileURLToPath as yo}from"url";function So(){D.existsSync(ne)||D.mkdirSync(ne,{recursive:!0})}function vo(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";D.writeFileSync(o,n);for(let r=0;r<3;r++)try{D.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function ko(e){try{if(D.existsSync(e))return JSON.parse(D.readFileSync(e,"utf-8"))}catch{}return null}function Xt(){Co=null,xo=null,Ao=null,Eo=null,te=null}function He(){return te||(te=ko(Zt)||{visits:[]},Array.isArray(te.visits)||(te.visits=[]),te)}function en(e,t={}){if(!e)return;So();let n=He();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{vo(Zt,n)}catch(r){console.error(`[!] Failed to save visit-log.json: ${r.message}`)}}function tn(e){let t=He();for(let n=t.visits.length-1;n>=0;n--)if(t.visits[n].profileUrl===e)return t.visits[n].date;return null}var wo,bo,ne,_s,Is,Zt,Ts,Rs,Co,xo,Ao,Eo,te,Je=ce(()=>{Qt();wo=yo(import.meta.url),bo=I.dirname(I.dirname(wo)),ne=process.env.DATA_DIR?I.resolve(process.env.DATA_DIR,"market-research"):I.join(bo,"market-research"),_s=I.join(ne,"scouted-jobs.json"),Is=I.join(ne,"discovered-people.json"),Zt=I.join(ne,"visit-log.json"),Ts=I.join(ne,"companies.json"),Rs=I.join(ne,"job-decisions.json");Co=null,xo=null,Ao=null,Eo=null,te=null});import Hn from"puppeteer";import{addExtra as Jn}from"puppeteer-extra";import Wn from"puppeteer-extra-plugin-stealth";he();await Oe();import M from"fs";import H from"path";var Nn="cookies.json";function St(){let e=process.env.ILML_SCOPE_DIR;return e?H.join(e,"plugins-state","linkedin","cookies.json"):Nn}function vt(){let e=St();if(!M.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=M.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}function kt(){return M.existsSync(St())}function Ln(){let e=process.env.ILML_SCOPE_DIR;return e?H.join(e,"plugins-state","linkedin"):"."}function Ct(e){let t=String(e||"").replace(/[^a-zA-Z0-9_.-]/g,"_").slice(0,80);return/[a-zA-Z0-9]/.test(t)?t:"default"}function Fn(){let e=process.env.MY_LINKEDIN_URL,t=e&&e.match(/\/in\/([^/?#]+)/);return t&&t[1]?Ct(t[1]):"default"}function xt(e){let t=process.env.LINKEDIN_CHROME_PROFILE_DIR;if(t)return M.existsSync(t)||M.mkdirSync(t,{recursive:!0}),H.resolve(t);let n=Ct(e||Fn()),o=H.join(Ln(),"chrome-profile",n);return M.existsSync(o)||M.mkdirSync(o,{recursive:!0}),H.resolve(o)}var At=".ilml-seeded";function Et(e){return!M.existsSync(H.join(e,At))}function $t(e){try{M.writeFileSync(H.join(e,At),new Date().toISOString())}catch{}}function _t(e){let t=0;for(let n of["SingletonLock","SingletonCookie","SingletonSocket"])try{M.rmSync(H.join(e,n),{force:!0}),t++}catch{}return t}import je from"fs";import Mn from"path";var Pn={headless:!1,defaultViewport:null,protocolTimeout:3e5},ye=new Set,It=!1;async function Ae(){let e=[...ye].map(t=>{try{return Promise.resolve(t.close()).catch(()=>{})}catch{return Promise.resolve()}});ye.clear(),await Promise.race([Promise.all(e),new Promise(t=>setTimeout(t,5e3))])}function qn(){if(It)return;It=!0;let e=t=>async()=>{await Ae(),process.exit(t)};process.once("SIGINT",e(130)),process.once("SIGTERM",e(143)),process.once("SIGHUP",e(129)),process.once("uncaughtException",async t=>{await Ae(),console.error(t&&t.stack||t),process.exit(1)}),process.once("unhandledRejection",async t=>{await Ae(),console.error(t),process.exit(1)}),process.stdout.on("error",async t=>{t&&t.code==="EPIPE"&&(await Ae(),process.exit(0))}),process.on("exit",()=>{for(let t of ye)try{let n=t.process&&t.process();n&&n.kill("SIGKILL")}catch{}})}function Ne(e){return Mn.join(e,".ilml-browser-session.json")}function Ot(e,t={}){try{je.writeFileSync(Ne(e),JSON.stringify({ownerPid:process.pid,startedAt:Date.now(),...t}))}catch{}}function Un(e,t){try{let n=t.wsEndpoint&&t.wsEndpoint();Ot(e,n?{wsEndpoint:n}:{})}catch{}}function Bn(e){let t=jt(e);t&&t.ownerPid===process.pid&&ge(e)}function ge(e){try{je.rmSync(Ne(e),{force:!0})}catch{}}function jt(e){try{return JSON.parse(je.readFileSync(Ne(e),"utf-8"))}catch{return null}}function Tt(e){if(!e||e===process.pid)return!0;try{return process.kill(e,0),!0}catch(t){return!t||t.code!=="ESRCH"}}function Rt(e,t,n){let o,r=new Promise(i=>{o=setTimeout(()=>i(n),t)}),s=Promise.resolve(e).then(i=>(clearTimeout(o),i),i=>{throw clearTimeout(o),i});return Promise.race([s,r])}async function Dt(e,t,{probeTimeoutMs:n=4e3}={}){let o=jt(t);if(!o)return"free";if(!o.wsEndpoint)return o.ownerPid&&o.ownerPid!==process.pid&&Tt(o.ownerPid)?"live":(ge(t),"free");let r=Symbol("timeout"),s=e.connect({browserWSEndpoint:o.wsEndpoint,defaultViewport:null}).catch(()=>null),i=await Rt(s,n,r);if(i===r)return s.then(c=>{if(c)try{c.disconnect()}catch{}}),"live";if(!i)return ge(t),"free";if(Tt(o.ownerPid)){try{i.disconnect()}catch{}return"live"}if(console.log(" (recovered an orphaned automation browser from a previous run \u2014 closing it)"),await Rt(i.close().then(()=>!0).catch(()=>!1),n,!1))return ge(t),"free";try{i.disconnect()}catch{}return"live"}function Vn(e,t){e&&(qn(),ye.add(e),e.on("disconnected",()=>{ye.delete(e),t&&ge(t)}))}async function Nt(e,t={}){let n=xt(),o={...Pn,...t,userDataDir:n},r=`Could not open the LinkedIn automation Chrome profile at ${n}. Another LinkedIn automation command is already running (or its window is still open) \u2014 wait for it to finish or close that window, then retry.`;if(await Dt(e,n)==="live")throw new Error(r);Ot(n);let s;try{s=await e.launch(o)}catch{if(await Dt(e,n)==="live")throw new Error(r);_t(n);try{s=await e.launch(o)}catch(l){throw Bn(n),new Error(`Could not open the LinkedIn automation Chrome profile at ${n}. If a LinkedIn automation window is already open, close it and retry. (Chrome: ${l.message})`)}}return Vn(s,n),Un(n,s),{browser:s,profileDir:n,needsSeed:Et(n)}}async function Lt(e,t){if(!t||!t.needsSeed)return!1;if(!kt())return console.warn(" \u26A0 No saved LinkedIn session found. If this command comes back empty or redirects to login, run: ilml linkedin login"),!1;try{return await e.setCookie(...vt()),$t(t.profileDir),console.log(" (seeded persistent profile from saved cookies \u2014 one-time)"),!0}catch{return!1}}var Ft=Jn(Hn);Ft.use(Wn());async function Mt(){let{browser:e,profileDir:t,needsSeed:n}=await Nt(Ft),o=await e.newPage();return await o.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})}),await Lt(o,{profileDir:t,needsSeed:n}),console.log(" Browser launched (persistent profile)."),{browser:e,page:o}}he();await we();async function go(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: ilml linkedin 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 zt(e,t,n={}){let{extractExperience:o=!1,extractFeatured:r=!1,extractEducation:s=!1,extractSkills:i=!1,extractRecommendations:l=!1,extractCertifications:c=!1}=n;try{if(await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),!await De(e,".scaffold-layout__main, main.scaffold-layout__main, .pv-top-card, section.pv-top-card",{timeout:45e3,label:"profile"})&&/\/authwall|\/login|\/checkpoint|\/uas\/login/.test(e.url()))throw new Error("Session expired \u2014 redirected to login. Run: ilml linkedin login");await k(1500),await bt(e)&&(console.log(" Dismissed Premium overlay"),await k(1500),await go(e,t));let m=0;for(let C=0;C<2;C++){let fe=await e.evaluate(()=>document.body.scrollHeight);for(let Z=1;Z<=6;Z++)await e.evaluate(g=>window.scrollTo(0,g),fe*Z/6),await k(900);let B=await e.evaluate(()=>document.body.scrollHeight);if(B===m)break;m=B}await k(800);let f=null;try{let C=e.url();C&&/\/in\/[^/?#]/.test(C)&&(f=C.split("?")[0].replace(/\/+$/,""))}catch{}let p=await e.evaluate(()=>{let C=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"]),fe=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"]),B=h=>{let y=(h||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(y)},Z={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:[]},g=document.querySelector("main");if(!g)return Z;let T=[...Array.from(g.querySelectorAll("h1")),...Array.from(g.querySelectorAll("h2"))],de=Array.from(g.querySelectorAll("h2")),ie=T.find(h=>{let y=h.textContent&&h.textContent.trim(),w=(y||"").replace(/\s*\(\d+\)$/,"").trim();return y&&y.length>1&&y.length<100&&!C.has(w)&&!fe.has(w)}),le=ie?ie.textContent.trim():null,R=ie?ie.parentElement:null;for(;R&&R!==g&&!Array.from(R.children).filter(y=>y.tagName==="P").some(y=>{let w=y.textContent&&y.textContent.trim();return w&&w.length>5&&!B(w)});)R=R.parentElement;let st=null,it=null,lt=null,Te=null;if(R&&R!==g){let h=Array.from(R.children).filter(w=>w.tagName==="P").filter(w=>{let V=w.textContent&&w.textContent.trim();return V&&V.length>5&&!B(V)});if(h[0]&&(st=h[0].textContent.trim()),h[1]){let w=h[1].textContent.trim().split(/\s*[·•]\s*/);it=w[0]||null,w.length>1&&(lt=w.slice(1).join(" \xB7 "))}let y=Array.from(R.children).filter(w=>w.tagName==="DIV");for(let w=y.length-1;w>=0;w--){let V=y[w].textContent&&y[w].textContent.trim();if(V&&!(le&&V.startsWith(le))&&(Te=V.split(/[·•]/)[0].trim(),Te))break}}let ct=null;if(R){let h=R.querySelectorAll("p, span, div");for(let y of h){let w=(y.textContent||"").trim().replace(/^[·•]\s*/,"");if(w==="1st"||w==="2nd"||w==="3rd"){ct=w;break}}}let Cn=!!g.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),at=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),xn=at&&at.src||null,Ce=g.textContent||"",ut=null,ft=Ce.match(/(\d+\+?)\s+connections\b/i);ft&&(ut=ft[1]+" connections");let xe=null,dt=Ce.match(/(\d+)\s+mutual connection/i),mt=Ce.match(/and\s+(\d+)\s+other mutual/i),An=Ce.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);dt?xe=parseInt(dt[1],10):mt?xe=2+parseInt(mt[1],10):An&&(xe=2);let pt=null,ht=null,gt=de.find(h=>h.textContent&&h.textContent.trim()==="About");if(gt){let h=gt.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let y=(h.textContent||"").trim();y=y.replace(/^About\s*/,"").trim();let w=y.match(/Top skills\s*(.+?)$/i);if(w){let Re=w[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(In=>In.trim()).filter(Boolean);Re.length>0&&Re.length<10&&(ht=Re)}y=y.split(/\n?…\s*more/i)[0].trim(),y=y.split(/\n?\.\.\.\s*more/i)[0].trim(),y=y.split(/\bTop skills\b/i)[0].trim(),y=y.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),pt=y||null}}let yt=null,wt=de.find(h=>h.textContent&&h.textContent.trim()==="Activity");if(wt){let h=wt.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let y=(h.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);y&&(yt=parseInt(y[1].replace(/,/g,""),10))}}let En=[...new Set(de.map(h=>(h.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(h=>h&&h.length>1&&h.length<60&&h!==le).filter(h=>C.has(h)))],me=document.body.textContent||"",$n=/#OpenToWork\b/i.test(me)||/\bOpen to work\b/.test(me),_n=/#Hiring\b/i.test(me)||/\bI'?m hiring\b/i.test(me)||/\bWe are hiring\b/i.test(me);return{name:le,title:st,location:Te,currentCompany:it,currentSchool:lt,connectionDegree:ct,hasVerifiedBadge:Cn,photoUrl:xn,connectionsLevel:ut,mutualConnectionsCount:xe,followers:yt,openToWork:$n,hiring:_n,about:pt,topSkills:ht,availableSections:En}});console.log(`Viewed: ${p.name} - ${p.title}`);let v=null,b=null,E=null,K=null,z=null,Q=null;if(o||r||s||i||l||c){let C=await Promise.resolve().then(()=>(Kt(),Yt));o&&(v=await C.extractExperienceFromDetails(e,t),console.log(` + Experience: ${v.length} entries`)),r&&(b=await C.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${b.length} entries`)),s&&(E=await C.extractEducationFromDetails(e,t),console.log(` + Education: ${E.length} entries`)),i&&(K=await C.extractSkillsFromDetails(e,t),console.log(` + Skills: ${K.length} entries`)),l&&(z=await C.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${z.length} entries`)),c&&(Q=await C.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${Q.length} entries`))}return{...p,profileUrl:t,resolvedUrl:f,...v!==null&&{experience:v},...b!==null&&{featured:b},...E!==null&&{education:E},...K!==null&&{skillsFull:K},...z!==null&&{recommendations:z},...Q!==null&&{certifications:Q}}}catch(d){console.error(`Error viewing profile ${t}:`,d.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(d.message||""))throw d;return null}}Je();await we();he();async function nn(e,t,n={}){let{maxVisits:o=50,delayBetween:r=4e3,skipRecentDays:s=7,verbose:i=!1,extractExperience:l=!1}=n,c={visited:0,skipped:0,errors:0},d=Date.now()-s*24*60*60*1e3;for(let a of t){if(c.visited>=o)break;if(!a.profileUrl)continue;let m=tn(a.profileUrl);if(m&&new Date(m).getTime()>d){c.skipped++;continue}try{let f=await zt(e,a.profileUrl,{extractExperience:l}),p=a.source||"visit";if(f){let b={...f,source:p};l&&Array.isArray(f.experience)&&f.experience.length>0&&(b._lastEnrichedAt=new Date().toISOString()),Be(a.profileUrl,b),f.resolvedUrl&&Ve(a.profileUrl,f.resolvedUrl)}en(a.profileUrl,{name:f?.name||a.name||null,source:p}),c.visited++,i?console.log(` [${c.visited}] ${f?.name||a.profileUrl} \u2014 ${f?.title?.slice(0,40)||"?"}`):c.visited%10===0&&console.log(` Visited: ${c.visited}`);let v=Math.random()*4e3;await k(r+v)}catch(f){c.errors++,i&&console.error(` Error visiting ${a.name||a.profileUrl}: ${f.message?.slice(0,60)}`);let p=(f.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 c}await we();import"dotenv/config";import*as O from"fs";import*as W from"path";import{fileURLToPath as Do}from"url";import"dotenv/config";import{createGraphClient as $o,resolveToken as _o}from"@ilivemylife/graph-sdk";import{config as Io}from"dotenv";Io();var on=_o()||process.env.TOKEN;on||(console.error(`
238
+ `});var Qt=le(()=>{});import"dotenv/config";import*as D from"fs";import*as I from"path";import{fileURLToPath as So}from"url";function Co(){D.existsSync(te)||D.mkdirSync(te,{recursive:!0})}function xo(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";D.writeFileSync(o,n);for(let r=0;r<3;r++)try{D.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function Ao(e){try{if(D.existsSync(e))return JSON.parse(D.readFileSync(e,"utf-8"))}catch{}return null}function Zt(){Eo=null,$o=null,_o=null,Io=null,ee=null}function He(){return ee||(ee=Ao(Xt)||{visits:[]},Array.isArray(ee.visits)||(ee.visits=[]),ee)}function en(e,t={}){if(!e)return;Co();let n=He();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{xo(Xt,n)}catch(r){console.error(`[!] Failed to save visit-log.json: ${r.message}`)}}function tn(e){let t=He();for(let n=t.visits.length-1;n>=0;n--)if(t.visits[n].profileUrl===e)return t.visits[n].date;return null}var vo,ko,te,Rs,Ds,Xt,Os,js,Eo,$o,_o,Io,ee,We=le(()=>{Qt();vo=So(import.meta.url),ko=I.dirname(I.dirname(vo)),te=process.env.DATA_DIR?I.resolve(process.env.DATA_DIR,"market-research"):I.join(ko,"market-research"),Rs=I.join(te,"scouted-jobs.json"),Ds=I.join(te,"discovered-people.json"),Xt=I.join(te,"visit-log.json"),Os=I.join(te,"companies.json"),js=I.join(te,"job-decisions.json");Eo=null,$o=null,_o=null,Io=null,ee=null});import Gn from"puppeteer";import{addExtra as Yn}from"puppeteer-extra";import Kn from"puppeteer-extra-plugin-stealth";pe();await Oe();import P from"fs";import H from"path";var Pn="cookies.json";function St(){let e=process.env.ILML_SCOPE_DIR;return e?H.join(e,"plugins-state","linkedin","cookies.json"):Pn}function vt(){let e=St();if(!P.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=P.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}function kt(){return P.existsSync(St())}function Mn(){let e=process.env.ILML_SCOPE_DIR;return e?H.join(e,"plugins-state","linkedin"):"."}function Ct(e){let t=String(e||"").replace(/[^a-zA-Z0-9_.-]/g,"_").slice(0,80);return/[a-zA-Z0-9]/.test(t)?t:"default"}function qn(){let e=process.env.MY_LINKEDIN_URL,t=e&&e.match(/\/in\/([^/?#]+)/);return t&&t[1]?Ct(t[1]):"default"}function xt(e){let t=process.env.LINKEDIN_CHROME_PROFILE_DIR;if(t)return P.existsSync(t)||P.mkdirSync(t,{recursive:!0}),H.resolve(t);let n=Ct(e||qn()),o=H.join(Mn(),"chrome-profile",n);return P.existsSync(o)||P.mkdirSync(o,{recursive:!0}),H.resolve(o)}var At=".ilml-seeded";function Et(e){return!P.existsSync(H.join(e,At))}function $t(e){try{P.writeFileSync(H.join(e,At),new Date().toISOString())}catch{}}function _t(e){let t=0;for(let n of["SingletonLock","SingletonCookie","SingletonSocket"])try{P.rmSync(H.join(e,n),{force:!0}),t++}catch{}return t}import je from"fs";import Un from"path";var Bn={headless:!1,defaultViewport:null,protocolTimeout:3e5},ge=new Set,It=!1;async function xe(){let e=[...ge].map(t=>{try{return Promise.resolve(t.close()).catch(()=>{})}catch{return Promise.resolve()}});ge.clear(),await Promise.race([Promise.all(e),new Promise(t=>setTimeout(t,5e3))])}function Vn(){if(It)return;It=!0;let e=t=>async()=>{await xe(),process.exit(t)};process.once("SIGINT",e(130)),process.once("SIGTERM",e(143)),process.once("SIGHUP",e(129)),process.once("uncaughtException",async t=>{await xe(),console.error(t&&t.stack||t),process.exit(1)}),process.once("unhandledRejection",async t=>{await xe(),console.error(t),process.exit(1)}),process.stdout.on("error",async t=>{t&&t.code==="EPIPE"&&(await xe(),process.exit(0))}),process.on("exit",()=>{for(let t of ge)try{let n=t.process&&t.process();n&&n.kill("SIGKILL")}catch{}})}function Ne(e){return Un.join(e,".ilml-browser-session.json")}function Ot(e,t={}){try{je.writeFileSync(Ne(e),JSON.stringify({ownerPid:process.pid,startedAt:Date.now(),...t}))}catch{}}function Hn(e,t){try{let n=t.wsEndpoint&&t.wsEndpoint();Ot(e,n?{wsEndpoint:n}:{})}catch{}}function Wn(e){let t=jt(e);t&&t.ownerPid===process.pid&&he(e)}function he(e){try{je.rmSync(Ne(e),{force:!0})}catch{}}function jt(e){try{return JSON.parse(je.readFileSync(Ne(e),"utf-8"))}catch{return null}}function Tt(e){if(!e||e===process.pid)return!0;try{return process.kill(e,0),!0}catch(t){return!t||t.code!=="ESRCH"}}function Rt(e,t,n){let o,r=new Promise(i=>{o=setTimeout(()=>i(n),t)}),s=Promise.resolve(e).then(i=>(clearTimeout(o),i),i=>{throw clearTimeout(o),i});return Promise.race([s,r])}async function Dt(e,t,{probeTimeoutMs:n=4e3}={}){let o=jt(t);if(!o)return"free";if(!o.wsEndpoint)return o.ownerPid&&o.ownerPid!==process.pid&&Tt(o.ownerPid)?"live":(he(t),"free");let r=Symbol("timeout"),s=e.connect({browserWSEndpoint:o.wsEndpoint,defaultViewport:null}).catch(()=>null),i=await Rt(s,n,r);if(i===r)return s.then(c=>{if(c)try{c.disconnect()}catch{}}),"live";if(!i)return he(t),"free";if(Tt(o.ownerPid)){try{i.disconnect()}catch{}return"live"}if(console.log(" (recovered an orphaned automation browser from a previous run \u2014 closing it)"),await Rt(i.close().then(()=>!0).catch(()=>!1),n,!1))return he(t),"free";try{i.disconnect()}catch{}return"live"}function Jn(e,t){e&&(Vn(),ge.add(e),e.on("disconnected",()=>{ge.delete(e),t&&he(t)}))}async function Nt(e,t={}){let n=xt(),o={...Bn,...t,userDataDir:n},r=`Could not open the LinkedIn automation Chrome profile at ${n}. Another LinkedIn automation command is already running (or its window is still open) \u2014 wait for it to finish or close that window, then retry.`;if(await Dt(e,n)==="live")throw new Error(r);Ot(n);let s;try{s=await e.launch(o)}catch{if(await Dt(e,n)==="live")throw new Error(r);_t(n);try{s=await e.launch(o)}catch(l){throw Wn(n),new Error(`Could not open the LinkedIn automation Chrome profile at ${n}. If a LinkedIn automation window is already open, close it and retry. (Chrome: ${l.message})`)}}return Jn(s,n),Hn(n,s),{browser:s,profileDir:n,needsSeed:Et(n)}}async function Lt(e,t){if(!t||!t.needsSeed)return!1;if(!kt())return console.warn(" \u26A0 No saved LinkedIn session found. If this command comes back empty or redirects to login, run: ilml linkedin login"),!1;try{return await e.setCookie(...vt()),$t(t.profileDir),console.log(" (seeded persistent profile from saved cookies \u2014 one-time)"),!0}catch{return!1}}var Ft=Yn(Gn);Ft.use(Kn());async function Pt(){let{browser:e,profileDir:t,needsSeed:n}=await Nt(Ft),o=await e.newPage();return await o.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})}),await Lt(o,{profileDir:t,needsSeed:n}),console.log(" Browser launched (persistent profile)."),{browser:e,page:o}}pe();await ye();async function bo(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: ilml linkedin login");console.log(` Off-track: ${n.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await v(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function zt(e,t,n={}){let{extractExperience:o=!1,extractFeatured:r=!1,extractEducation:s=!1,extractSkills:i=!1,extractRecommendations:l=!1,extractCertifications:c=!1}=n;try{await De(e,t,{readySelector:".scaffold-layout__main, main.scaffold-layout__main, .pv-top-card, section.pv-top-card",label:"profile"}),await v(1500),await bt(e)&&(console.log(" Dismissed Premium overlay"),await v(1500),await bo(e,t));let u=0;for(let k=0;k<2;k++){let ue=await e.evaluate(()=>document.body.scrollHeight);for(let Q=1;Q<=6;Q++)await e.evaluate(g=>window.scrollTo(0,g),ue*Q/6),await v(900);let B=await e.evaluate(()=>document.body.scrollHeight);if(B===u)break;u=B}await v(800);let m=null;try{let k=e.url();k&&/\/in\/[^/?#]/.test(k)&&(m=k.split("?")[0].replace(/\/+$/,""))}catch{}let d=await e.evaluate(()=>{let k=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"]),ue=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"]),B=p=>{let y=(p||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(y)},Q={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:[]},g=document.querySelector("main");if(!g)return Q;let T=[...Array.from(g.querySelectorAll("h1")),...Array.from(g.querySelectorAll("h2"))],fe=Array.from(g.querySelectorAll("h2")),se=T.find(p=>{let y=p.textContent&&p.textContent.trim(),w=(y||"").replace(/\s*\(\d+\)$/,"").trim();return y&&y.length>1&&y.length<100&&!k.has(w)&&!ue.has(w)}),ie=se?se.textContent.trim():null,R=se?se.parentElement:null;for(;R&&R!==g&&!Array.from(R.children).filter(y=>y.tagName==="P").some(y=>{let w=y.textContent&&y.textContent.trim();return w&&w.length>5&&!B(w)});)R=R.parentElement;let st=null,it=null,lt=null,Ie=null;if(R&&R!==g){let p=Array.from(R.children).filter(w=>w.tagName==="P").filter(w=>{let V=w.textContent&&w.textContent.trim();return V&&V.length>5&&!B(V)});if(p[0]&&(st=p[0].textContent.trim()),p[1]){let w=p[1].textContent.trim().split(/\s*[·•]\s*/);it=w[0]||null,w.length>1&&(lt=w.slice(1).join(" \xB7 "))}let y=Array.from(R.children).filter(w=>w.tagName==="DIV");for(let w=y.length-1;w>=0;w--){let V=y[w].textContent&&y[w].textContent.trim();if(V&&!(ie&&V.startsWith(ie))&&(Ie=V.split(/[·•]/)[0].trim(),Ie))break}}let ct=null;if(R){let p=R.querySelectorAll("p, span, div");for(let y of p){let w=(y.textContent||"").trim().replace(/^[·•]\s*/,"");if(w==="1st"||w==="2nd"||w==="3rd"){ct=w;break}}}let Cn=!!g.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),at=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),xn=at&&at.src||null,ke=g.textContent||"",ut=null,ft=ke.match(/(\d+\+?)\s+connections\b/i);ft&&(ut=ft[1]+" connections");let Ce=null,dt=ke.match(/(\d+)\s+mutual connection/i),mt=ke.match(/and\s+(\d+)\s+other mutual/i),An=ke.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);dt?Ce=parseInt(dt[1],10):mt?Ce=2+parseInt(mt[1],10):An&&(Ce=2);let pt=null,ht=null,gt=fe.find(p=>p.textContent&&p.textContent.trim()==="About");if(gt){let p=gt.parentElement;for(;p&&p.tagName!=="SECTION";)p=p.parentElement;if(p){let y=(p.textContent||"").trim();y=y.replace(/^About\s*/,"").trim();let w=y.match(/Top skills\s*(.+?)$/i);if(w){let Te=w[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(In=>In.trim()).filter(Boolean);Te.length>0&&Te.length<10&&(ht=Te)}y=y.split(/\n?…\s*more/i)[0].trim(),y=y.split(/\n?\.\.\.\s*more/i)[0].trim(),y=y.split(/\bTop skills\b/i)[0].trim(),y=y.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),pt=y||null}}let yt=null,wt=fe.find(p=>p.textContent&&p.textContent.trim()==="Activity");if(wt){let p=wt.parentElement;for(;p&&p.tagName!=="SECTION";)p=p.parentElement;if(p){let y=(p.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);y&&(yt=parseInt(y[1].replace(/,/g,""),10))}}let En=[...new Set(fe.map(p=>(p.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(p=>p&&p.length>1&&p.length<60&&p!==ie).filter(p=>k.has(p)))],de=document.body.textContent||"",$n=/#OpenToWork\b/i.test(de)||/\bOpen to work\b/.test(de),_n=/#Hiring\b/i.test(de)||/\bI'?m hiring\b/i.test(de)||/\bWe are hiring\b/i.test(de);return{name:ie,title:st,location:Ie,currentCompany:it,currentSchool:lt,connectionDegree:ct,hasVerifiedBadge:Cn,photoUrl:xn,connectionsLevel:ut,mutualConnectionsCount:Ce,followers:yt,openToWork:$n,hiring:_n,about:pt,topSkills:ht,availableSections:En}});console.log(`Viewed: ${d.name} - ${d.title}`);let h=null,x=null,S=null,E=null,K=null,z=null;if(o||r||s||i||l||c){let k=await Promise.resolve().then(()=>(Kt(),Yt));o&&(h=await k.extractExperienceFromDetails(e,t),console.log(` + Experience: ${h.length} entries`)),r&&(x=await k.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${x.length} entries`)),s&&(S=await k.extractEducationFromDetails(e,t),console.log(` + Education: ${S.length} entries`)),i&&(E=await k.extractSkillsFromDetails(e,t),console.log(` + Skills: ${E.length} entries`)),l&&(K=await k.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${K.length} entries`)),c&&(z=await k.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${z.length} entries`))}return{...d,profileUrl:t,resolvedUrl:m,...h!==null&&{experience:h},...x!==null&&{featured:x},...S!==null&&{education:S},...E!==null&&{skillsFull:E},...K!==null&&{recommendations:K},...z!==null&&{certifications:z}}}catch(a){console.error(`Error viewing profile ${t}:`,a.message);try{await e.goto("about:blank",{timeout:1e4}),await v(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(a.message||""))throw a;return null}}We();await ye();pe();async function nn(e,t,n={}){let{maxVisits:o=50,delayBetween:r=4e3,skipRecentDays:s=7,verbose:i=!1,extractExperience:l=!1}=n,c={visited:0,skipped:0,errors:0},a=Date.now()-s*24*60*60*1e3;for(let u of t){if(c.visited>=o)break;if(!u.profileUrl)continue;let m=tn(u.profileUrl);if(m&&new Date(m).getTime()>a){c.skipped++;continue}try{let d=await zt(e,u.profileUrl,{extractExperience:l}),h=u.source||"visit";if(d){let S={...d,source:h};l&&Array.isArray(d.experience)&&d.experience.length>0&&(S._lastEnrichedAt=new Date().toISOString()),Be(u.profileUrl,S),d.resolvedUrl&&Ve(u.profileUrl,d.resolvedUrl)}en(u.profileUrl,{name:d?.name||u.name||null,source:h}),c.visited++,i?console.log(` [${c.visited}] ${d?.name||u.profileUrl} \u2014 ${d?.title?.slice(0,40)||"?"}`):c.visited%10===0&&console.log(` Visited: ${c.visited}`);let x=Math.random()*4e3;await v(r+x)}catch(d){c.errors++,i&&console.error(` Error visiting ${u.name||u.profileUrl}: ${d.message?.slice(0,60)}`);let h=(d.message||"").toLowerCase();if(h.includes("detached")||h.includes("session closed")||h.includes("target closed")||h.includes("session expired")||h.includes("bounced to")||h.includes("authwall")||h.includes("checkpoint")||h.includes("redirected to login")){console.log(" Fatal browser/session error \u2014 stopping visits");break}}}return c}await ye();import"dotenv/config";import*as O from"fs";import*as J from"path";import{fileURLToPath as No}from"url";import"dotenv/config";import{createGraphClient as To,resolveToken as Ro}from"@ilivemylife/graph-sdk";import{config as Do}from"dotenv";Do();var on=Ro()||process.env.TOKEN;on||(console.error(`
239
239
  [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.
240
240
  `),console.error(" Easiest way:"),console.error(" 1. npm install -g @ilivemylife/graph-sdk"),console.error(` 2. ilml login your@email.com yourpassword
241
241
  `),console.error(` Or add ILML_TOKEN=... to .env
242
- `),process.exit(1));var rn=$o({token:on});function To(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 Ro({scriptName:e,mode:t,status:n,error:o,duration:r}){let s=n==="error"?"\u2717":n==="quota-reached"?"\u26A0":"\u2713",i=new Date().toISOString().slice(0,16).replace("T"," "),l=r?` ${To(r)}`:"",c=n==="error"?`error${o?`: ${String(o).slice(0,80)}`:""}`:n==="quota-reached"?"daily quota reached":"done",d=t&&t!=="default"?` (${t})`:"";return`${s} ${e}${d} \u2014 ${c} \u2014 ${i}${l}`}async function sn({scriptName:e,mode:t,status:n,summaryLines:o,error:r,duration:s}){let i=process.env.NODE_RUN_REPORTS;if(!i||!Array.isArray(o)||o.length===0)return;let c=`**${Ro({scriptName:e,mode:t,status:n,error:r,duration:s})}**
242
+ `),process.exit(1));var rn=To({token:on});function Oo(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 jo({scriptName:e,mode:t,status:n,error:o,duration:r}){let s=n==="error"?"\u2717":n==="quota-reached"?"\u26A0":"\u2713",i=new Date().toISOString().slice(0,16).replace("T"," "),l=r?` ${Oo(r)}`:"",c=n==="error"?`error${o?`: ${String(o).slice(0,80)}`:""}`:n==="quota-reached"?"daily quota reached":"done",a=t&&t!=="default"?` (${t})`:"";return`${s} ${e}${a} \u2014 ${c} \u2014 ${i}${l}`}async function sn({scriptName:e,mode:t,status:n,summaryLines:o,error:r,duration:s}){let i=process.env.NODE_RUN_REPORTS;if(!i||!Array.isArray(o)||o.length===0)return;let c=`**${jo({scriptName:e,mode:t,status:n,error:r,duration:s})}**
243
243
 
244
244
  ${o.join(`
245
- `)}`;try{await rn.addMessage(i,c)}catch(d){console.error(`[runReport] Failed to post end-of-session message: ${d.message}`)}}var Oo=Do(import.meta.url),jo=W.dirname(W.dirname(Oo)),We=process.env.DATA_DIR?W.resolve(process.env.DATA_DIR,"collected-profiles"):W.join(jo,"collected-profiles"),Ge=W.join(We,"run-log.json");function No(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 i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function ln(){try{if(!O.existsSync(Ge))return{runs:[]};let e=JSON.parse(O.readFileSync(Ge,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function cn(e){O.existsSync(We)||O.mkdirSync(We,{recursive:!0});try{No(Ge,e)}catch(t){console.error(`[!] Failed to save run-log.json: ${t.message}`)}}function an(e,t="default"){let n=ln();for(let i of n.runs)i.status==="running"&&(i.status="interrupted",i.result="interrupted",i.timestamp&&(i.duration=Date.now()-new Date(i.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(i=>new Date(i.timestamp).getTime()>s),cn(n),{script:e,mode:t,startTime:o.getTime(),runIndex:n.runs.length-1}}function Ye(e,t,n=null,o=null){if(!e)return;let r=null;try{let i=ln(),l=i.runs[e.runIndex];if(l&&l.status==="running"&&l.script===e.script)l.status=t,l.result=t,l.duration=Date.now()-e.startTime,l.stats=n,l.error=o,r=l.duration;else{let c=i.runs.find(d=>d.script===e.script&&d.status==="running"&&d.timestamp===new Date(e.startTime).toISOString());c&&(c.status=t,c.result=t,c.duration=Date.now()-e.startTime,c.stats=n,c.error=o,r=c.duration)}cn(i)}catch(i){console.error(`[runLog] Failed to end run: ${i.message}`)}let s=n&&Array.isArray(n.summaryLines)?n.summaryLines:null;if(s&&s.length>0&&process.env.NODE_RUN_REPORTS){let i=t==="error"?"error":n&&n.dailyLimitHit?"quota-reached":"done";sn({scriptName:e.script,mode:e.mode,status:i,summaryLines:s,error:o,duration:r??Date.now()-e.startTime}).catch(l=>console.error(`[runLog] postRunReport failed: ${l.message}`))}}import"dotenv/config";import*as u from"fs";import*as nt from"os";import*as S from"path";import{fileURLToPath as sr}from"url";var Qe={};pe(Qe,{NAME:()=>Fo,VERSION:()=>Lo,up:()=>qo});import*as j from"fs";import*as Ee from"path";var Lo=1,Fo="normalize-jobs-and-questions",Mo=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Po=50;function Ke(e){return j.existsSync(e)?JSON.parse(j.readFileSync(e,"utf-8")):null}function ze(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{j.writeFileSync(o,n)}catch(r){try{j.unlinkSync(o)}catch{}throw r}try{j.renameSync(o,e)}catch(r){try{j.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 qo(e,t){let n=Ee.join(e,"jobs.json"),o=Ee.join(t,"scouted-jobs.json"),r=Ee.join(e,"application-questions.json"),s=Ke(n)||{},i=Ke(o)||{},l=0,c=[];for(let a of Object.keys(s)){if(!i[a])continue;let m=i[a],f=s[a];for(let p of Mo)m[p]!=null&&f[p]==null&&(f[p]=m[p]);c.push(a),l++}l>0?(ze(n,s),console.log(` Phase 1: Merged ${l} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let d=Ke(r);if(d&&Array.isArray(d.applications)){let a={},m=0;for(let f of d.applications){let p=f.jobId||"unknown";a[p]||(a[p]={applications:[]});let v=(f.questions||[]).map(b=>{let E={type:b.type||"input",question:b.question||"",answer:b.answer||""};return b.options&&(b.options.length<=Po?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});a[p].applications.push({applicationId:f.applicationId,date:f.date,result:f.result||"submitted",formPages:f.formPages||null,duration:f.duration||null,retries:f.retries||0,failedField:f.failedField||null,questionCount:f.questionCount||v.length,questions:v})}ze(r,a),console.log(` Phase 2: Rekeyed ${d.applications.length} applications by jobId (${Object.keys(a).length} unique jobs)`),m>0&&console.log(` Phase 2: Stripped bloated options from ${m} questions`)}else d&&!d.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(c.length>0){for(let a of c)delete i[a];ze(o,i),console.log(` Phase 3: Removed ${c.length} merged entries from scouted-jobs.json (${Object.keys(i).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var Ze={};pe(Ze,{NAME:()=>Bo,VERSION:()=>Uo,up:()=>Jo});import*as N from"fs";import*as un from"path";var Uo=2,Bo="reset-unread-flags";function Vo(e){return N.existsSync(e)?JSON.parse(N.readFileSync(e,"utf-8")):null}function Ho(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 Jo(e){let t=un.join(e,"conversations.json"),n=Vo(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}Ho(t,n),console.log(` Reset unread=false on ${o} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var Xe={};pe(Xe,{NAME:()=>Go,VERSION:()=>Wo,up:()=>Zo});import*as L from"fs";import*as fn from"path";var Wo=3,Go="recompute-last-message-by",Yo=new Set(["draft","confirmed","rejected","needs_review"]);function Ko(e){return L.existsSync(e)?JSON.parse(L.readFileSync(e,"utf-8")):null}function zo(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}}function Qo(e,t){if(!e||e.length===0)return"them";let n=e.filter(s=>!Yo.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,i)=>i.t-s.t).map(s=>s.m),r=o.length>0?o:[...n].reverse();for(let s of r){let i=s.sender;if(i===t)return"me";if(i!=="Unknown"&&i!=="")return"them"}return"them"}async function Zo(e){let t=fn.join(e,"conversations.json"),n=Ko(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,i=0;for(let l of Object.keys(n)){let c=n[l];if(!c||typeof c!="object")continue;Object.prototype.hasOwnProperty.call(c,"_cardSynced")&&(delete c._cardSynced,s++);let d=Array.isArray(c.messages)?c.messages:[],a=Qo(d,o),m=a==="me"?"awaiting_reply":"unanswered_by_us";c.lastMessageBy!==a&&i++,c.lastMessageBy=a,c.conversationStatus=m,r++}if(r===0){console.log(" No conversations to recompute.");return}zo(t,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${r} conversations.`),console.log(` ${i} 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 et={};pe(et,{NAME:()=>er,VERSION:()=>Xo,up:()=>rr});import*as F from"fs";import*as dn from"path";var Xo=4,er="split-connection-timestamps",tr=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function nr(e){if(!F.existsSync(e))return null;let t=F.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function or(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}}async function rr(e){let t=dn.join(e,"people.json"),n=nr(t);if(!n||typeof n!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let o=0,r=0;for(let s of Object.keys(n)){let i=n[s];!i||typeof i!="object"||(r++,tr.has(i.connectionStatus)&&i.connectionDate&&!i.requestedConnectionAt&&(i.requestedConnectionAt=i.connectionDate,i.connectionDate=null,o++))}if(o===0){console.log(` Scanned ${r} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}or(t,n),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${o} still-pending people (of ${r} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}await we();Je();var ir=sr(import.meta.url),lr=S.dirname(ir),cr=S.dirname(S.dirname(lr));function ar(e){return e&&(e==="~"?nt.homedir():e.startsWith("~/")||e.startsWith("~\\")?S.join(nt.homedir(),e.slice(2)):e)}var P=process.env.DATA_DIR?S.resolve(ar(process.env.DATA_DIR)):cr,re=S.join(P,"collected-profiles"),se=S.join(P,"market-research"),_=S.join(P,".schema-version"),mn=[S.join(re,".schema-version"),S.join(se,".schema-version")],G=4,U=[{version:1,module:Qe},{version:2,module:Ze},{version:3,module:Xe},{version:4,module:et}];(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!==G)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${G}. 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 yn(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
245
+ `)}`;try{await rn.addMessage(i,c)}catch(a){console.error(`[runReport] Failed to post end-of-session message: ${a.message}`)}}var Lo=No(import.meta.url),Fo=J.dirname(J.dirname(Lo)),Je=process.env.DATA_DIR?J.resolve(process.env.DATA_DIR,"collected-profiles"):J.join(Fo,"collected-profiles"),Ge=J.join(Je,"run-log.json");function Po(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 i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function ln(){try{if(!O.existsSync(Ge))return{runs:[]};let e=JSON.parse(O.readFileSync(Ge,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function cn(e){O.existsSync(Je)||O.mkdirSync(Je,{recursive:!0});try{Po(Ge,e)}catch(t){console.error(`[!] Failed to save run-log.json: ${t.message}`)}}function an(e,t="default"){let n=ln();for(let i of n.runs)i.status==="running"&&(i.status="interrupted",i.result="interrupted",i.timestamp&&(i.duration=Date.now()-new Date(i.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(i=>new Date(i.timestamp).getTime()>s),cn(n),{script:e,mode:t,startTime:o.getTime(),runIndex:n.runs.length-1}}function Ye(e,t,n=null,o=null){if(!e)return;let r=null;try{let i=ln(),l=i.runs[e.runIndex];if(l&&l.status==="running"&&l.script===e.script)l.status=t,l.result=t,l.duration=Date.now()-e.startTime,l.stats=n,l.error=o,r=l.duration;else{let c=i.runs.find(a=>a.script===e.script&&a.status==="running"&&a.timestamp===new Date(e.startTime).toISOString());c&&(c.status=t,c.result=t,c.duration=Date.now()-e.startTime,c.stats=n,c.error=o,r=c.duration)}cn(i)}catch(i){console.error(`[runLog] Failed to end run: ${i.message}`)}let s=n&&Array.isArray(n.summaryLines)?n.summaryLines:null;if(s&&s.length>0&&process.env.NODE_RUN_REPORTS){let i=t==="error"?"error":n&&n.dailyLimitHit?"quota-reached":"done";sn({scriptName:e.script,mode:e.mode,status:i,summaryLines:s,error:o,duration:r??Date.now()-e.startTime}).catch(l=>console.error(`[runLog] postRunReport failed: ${l.message}`))}}import"dotenv/config";import*as f from"fs";import*as nt from"os";import*as b from"path";import{fileURLToPath as cr}from"url";var Qe={};me(Qe,{NAME:()=>qo,VERSION:()=>Mo,up:()=>Vo});import*as j from"fs";import*as Ae from"path";var Mo=1,qo="normalize-jobs-and-questions",Uo=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Bo=50;function Ke(e){return j.existsSync(e)?JSON.parse(j.readFileSync(e,"utf-8")):null}function ze(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{j.writeFileSync(o,n)}catch(r){try{j.unlinkSync(o)}catch{}throw r}try{j.renameSync(o,e)}catch(r){try{j.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 Vo(e,t){let n=Ae.join(e,"jobs.json"),o=Ae.join(t,"scouted-jobs.json"),r=Ae.join(e,"application-questions.json"),s=Ke(n)||{},i=Ke(o)||{},l=0,c=[];for(let u of Object.keys(s)){if(!i[u])continue;let m=i[u],d=s[u];for(let h of Uo)m[h]!=null&&d[h]==null&&(d[h]=m[h]);c.push(u),l++}l>0?(ze(n,s),console.log(` Phase 1: Merged ${l} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let a=Ke(r);if(a&&Array.isArray(a.applications)){let u={},m=0;for(let d of a.applications){let h=d.jobId||"unknown";u[h]||(u[h]={applications:[]});let x=(d.questions||[]).map(S=>{let E={type:S.type||"input",question:S.question||"",answer:S.answer||""};return S.options&&(S.options.length<=Bo?E.options=S.options:(E.optionsOmitted=!0,m++)),S.page&&(E.page=S.page),S.wasPreFilled&&(E.wasPreFilled=!0),S.wasRetry&&(E.wasRetry=!0),E});u[h].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||x.length,questions:x})}ze(r,u),console.log(` Phase 2: Rekeyed ${a.applications.length} applications by jobId (${Object.keys(u).length} unique jobs)`),m>0&&console.log(` Phase 2: Stripped bloated options from ${m} questions`)}else a&&!a.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(c.length>0){for(let u of c)delete i[u];ze(o,i),console.log(` Phase 3: Removed ${c.length} merged entries from scouted-jobs.json (${Object.keys(i).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var Xe={};me(Xe,{NAME:()=>Wo,VERSION:()=>Ho,up:()=>Yo});import*as N from"fs";import*as un from"path";var Ho=2,Wo="reset-unread-flags";function Jo(e){return N.existsSync(e)?JSON.parse(N.readFileSync(e,"utf-8")):null}function Go(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 Yo(e){let t=un.join(e,"conversations.json"),n=Jo(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}Go(t,n),console.log(` Reset unread=false on ${o} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var Ze={};me(Ze,{NAME:()=>zo,VERSION:()=>Ko,up:()=>tr});import*as L from"fs";import*as fn from"path";var Ko=3,zo="recompute-last-message-by",Qo=new Set(["draft","confirmed","rejected","needs_review"]);function Xo(e){return L.existsSync(e)?JSON.parse(L.readFileSync(e,"utf-8")):null}function Zo(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}}function er(e,t){if(!e||e.length===0)return"them";let n=e.filter(s=>!Qo.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,i)=>i.t-s.t).map(s=>s.m),r=o.length>0?o:[...n].reverse();for(let s of r){let i=s.sender;if(i===t)return"me";if(i!=="Unknown"&&i!=="")return"them"}return"them"}async function tr(e){let t=fn.join(e,"conversations.json"),n=Xo(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,i=0;for(let l of Object.keys(n)){let c=n[l];if(!c||typeof c!="object")continue;Object.prototype.hasOwnProperty.call(c,"_cardSynced")&&(delete c._cardSynced,s++);let a=Array.isArray(c.messages)?c.messages:[],u=er(a,o),m=u==="me"?"awaiting_reply":"unanswered_by_us";c.lastMessageBy!==u&&i++,c.lastMessageBy=u,c.conversationStatus=m,r++}if(r===0){console.log(" No conversations to recompute.");return}Zo(t,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${r} conversations.`),console.log(` ${i} 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 et={};me(et,{NAME:()=>or,VERSION:()=>nr,up:()=>lr});import*as F from"fs";import*as dn from"path";var nr=4,or="split-connection-timestamps",rr=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function sr(e){if(!F.existsSync(e))return null;let t=F.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function ir(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}}async function lr(e){let t=dn.join(e,"people.json"),n=sr(t);if(!n||typeof n!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let o=0,r=0;for(let s of Object.keys(n)){let i=n[s];!i||typeof i!="object"||(r++,rr.has(i.connectionStatus)&&i.connectionDate&&!i.requestedConnectionAt&&(i.requestedConnectionAt=i.connectionDate,i.connectionDate=null,o++))}if(o===0){console.log(` Scanned ${r} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}ir(t,n),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${o} still-pending people (of ${r} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}await ye();We();var ar=cr(import.meta.url),ur=b.dirname(ar),fr=b.dirname(b.dirname(ur));function dr(e){return e&&(e==="~"?nt.homedir():e.startsWith("~/")||e.startsWith("~\\")?b.join(nt.homedir(),e.slice(2)):e)}var M=process.env.DATA_DIR?b.resolve(dr(process.env.DATA_DIR)):fr,oe=b.join(M,"collected-profiles"),re=b.join(M,"market-research"),_=b.join(M,".schema-version"),mn=[b.join(oe,".schema-version"),b.join(re,".schema-version")],G=4,U=[{version:1,module:Qe},{version:2,module:Xe},{version:3,module:Ze},{version:4,module:et}];(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!==G)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${G}. 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 yn(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
246
246
  [FATAL] DATA_DIR is set to whitespace ("${process.env.DATA_DIR}"). Either unset it or set a real path.
247
- `),process.exit(1));try{u.mkdirSync(P,{recursive:!0})}catch(t){t.code!=="EEXIST"&&(console.error(`
248
- [FATAL] Cannot create DATA_DIR (${P}): ${t.message}`),console.error(` Fix the path or permissions and try again.
249
- `),process.exit(1))}let e;try{e=u.statSync(P)}catch(t){console.error(`
250
- [FATAL] DATA_DIR (${P}) is not accessible: ${t.message}
247
+ `),process.exit(1));try{f.mkdirSync(M,{recursive:!0})}catch(t){t.code!=="EEXIST"&&(console.error(`
248
+ [FATAL] Cannot create DATA_DIR (${M}): ${t.message}`),console.error(` Fix the path or permissions and try again.
249
+ `),process.exit(1))}let e;try{e=f.statSync(M)}catch(t){console.error(`
250
+ [FATAL] DATA_DIR (${M}) is not accessible: ${t.message}
251
251
  `),process.exit(1)}e.isDirectory()||(console.error(`
252
- [FATAL] DATA_DIR (${P}) 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.
253
- `),process.exit(1));for(let t of[re,se]){let n;try{n=u.lstatSync(t)}catch(o){if(o.code==="ENOENT")continue;throw o}n.isSymbolicLink()&&(console.error(`
252
+ [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.
253
+ `),process.exit(1));for(let t of[oe,re]){let n;try{n=f.lstatSync(t)}catch(o){if(o.code==="ENOENT")continue;throw o}n.isSymbolicLink()&&(console.error(`
254
254
  [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.
255
- `),process.exit(1))}}var oe=S.join(P,".migration-lock");function ur(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return u.writeFileSync(oe,e,{flag:"wx"}),!0}catch(o){if(o.code!=="EEXIST")throw o}let t;try{t=JSON.parse(u.readFileSync(oe,"utf-8"))}catch{t=null}if(t&&Number.isInteger(t.pid)){let o=!1;try{process.kill(t.pid,0),o=!0}catch(i){i.code==="EPERM"&&(o=!0)}let r=24*60*60*1e3,s=1/0;if(t.startedAt){let i=Date.parse(t.startedAt);Number.isNaN(i)||(s=Date.now()-i)}o&&s<r&&(console.error(`
256
- [FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${t.pid}`),console.error(` Started at: ${t.startedAt||"(unknown)"}`),console.error(` Lock file: ${oe}
255
+ `),process.exit(1))}}var ne=b.join(M,".migration-lock");function mr(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return f.writeFileSync(ne,e,{flag:"wx"}),!0}catch(o){if(o.code!=="EEXIST")throw o}let t;try{t=JSON.parse(f.readFileSync(ne,"utf-8"))}catch{t=null}if(t&&Number.isInteger(t.pid)){let o=!1;try{process.kill(t.pid,0),o=!0}catch(i){i.code==="EPERM"&&(o=!0)}let r=24*60*60*1e3,s=1/0;if(t.startedAt){let i=Date.parse(t.startedAt);Number.isNaN(i)||(s=Date.now()-i)}o&&s<r&&(console.error(`
256
+ [FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${t.pid}`),console.error(` Started at: ${t.startedAt||"(unknown)"}`),console.error(` Lock file: ${ne}
257
257
  `),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.
258
- `),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=oe+".tmp";try{return u.writeFileSync(n,e),u.renameSync(n,oe),!0}catch(o){try{u.unlinkSync(n)}catch{}throw new Error(`Failed to take over stale migration lock: ${o.message}`)}}function ot(){try{if(JSON.parse(u.readFileSync(oe,"utf-8")).pid!==process.pid)return;u.unlinkSync(oe)}catch{}}var pn=!1;function fr(){if(pn)return;pn=!0;let e=()=>{try{ot()}catch{}process.exit(1)};for(let t of["SIGINT","SIGTERM","SIGHUP"])try{process.on(t,e)}catch{}}function dr(){if(u.existsSync(_))return;let e=[],t=[];for(let s of mn)if(u.existsSync(s))try{e.push({file:s,schema:$e(s)})}catch(i){t.push({file:s,err:i.message})}if(t.length>0){console.error(`
258
+ `),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=ne+".tmp";try{return f.writeFileSync(n,e),f.renameSync(n,ne),!0}catch(o){try{f.unlinkSync(n)}catch{}throw new Error(`Failed to take over stale migration lock: ${o.message}`)}}function ot(){try{if(JSON.parse(f.readFileSync(ne,"utf-8")).pid!==process.pid)return;f.unlinkSync(ne)}catch{}}var pn=!1;function pr(){if(pn)return;pn=!0;let e=()=>{try{ot()}catch{}process.exit(1)};for(let t of["SIGINT","SIGTERM","SIGHUP"])try{process.on(t,e)}catch{}}function hr(){if(f.existsSync(_))return;let e=[],t=[];for(let s of mn)if(f.existsSync(s))try{e.push({file:s,schema:Ee(s)})}catch(i){t.push({file:s,err:i.message})}if(t.length>0){console.error(`
259
259
  [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(`
260
260
  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.
261
261
  `),process.exit(1)}if(e.length===0)return;let n=e.map(s=>s.schema.version);if(new Set(n).size>1){console.error(`
262
262
  [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.
263
- `),process.exit(1)}let o=e[0].schema,r=_+".tmp";try{u.writeFileSync(r,JSON.stringify(o,null,2)),u.renameSync(r,_)}catch(s){try{u.unlinkSync(r)}catch{}throw s}for(let s of mn)if(u.existsSync(s))try{u.unlinkSync(s)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${_}`)}function mr(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 $e(e){let t=u.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function hn(){if(dr(),!u.existsSync(_))return{version:0,migrations:[]};let e;try{e=$e(_)}catch(n){if(n.code==="ENOENT")return{version:0,migrations:[]};console.error(`
263
+ `),process.exit(1)}let o=e[0].schema,r=_+".tmp";try{f.writeFileSync(r,JSON.stringify(o,null,2)),f.renameSync(r,_)}catch(s){try{f.unlinkSync(r)}catch{}throw s}for(let s of mn)if(f.existsSync(s))try{f.unlinkSync(s)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${_}`)}function gr(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 Ee(e){let t=f.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function hn(){if(hr(),!f.existsSync(_))return{version:0,migrations:[]};let e;try{e=Ee(_)}catch(n){if(n.code==="ENOENT")return{version:0,migrations:[]};console.error(`
264
264
  [FATAL] ${_} 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.
265
- `),process.exit(1)}let t=mr(e);return t===null&&(console.error(`
265
+ `),process.exit(1)}let t=gr(e);return t===null&&(console.error(`
266
266
  [FATAL] ${_} 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.
267
- `),process.exit(1)),t}function wn(e){try{u.chmodSync(e,384)}catch{}}function pr(e){if(yn(),u.existsSync(_))try{if(u.lstatSync(_).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${_}. 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=_+".tmp";try{u.writeFileSync(t,JSON.stringify(e,null,2)),wn(t),u.renameSync(t,_)}catch(n){try{u.unlinkSync(t)}catch{}throw n}}function gn(e,t){if(!u.existsSync(e))return;let n=`.pre-v${String(t).padStart(3,"0")}.backup`,o=u.readdirSync(e).filter(l=>{let c=l.toLowerCase();if(c.includes(".backup")||c===".schema-version"||c.endsWith(".tmp"))return!1;try{return u.statSync(S.join(e,l)).isFile()}catch{return!1}}),r=0,s=0,i=[];for(let l of o){let c=S.join(e,l),d=S.join(e,l+n);if(u.existsSync(d)){s++;continue}try{Sn(c,d),r++}catch(a){i.push({file:l,err:a.message})}}if(i.length>0){let l=new Error(`Failed to back up ${i.length} file(s) in ${S.basename(e)}/: `+i.map(c=>`${c.file} (${c.err})`).join(", "));throw l.code="BACKUP_INCOMPLETE",l}if(r>0||s>0){let l=s>0?` (${s} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${r} files in ${S.basename(e)}/ (${n})${l}`)}}var tt=!1;async function bn(){if(tt)return;yn(),br();let t=hn().version;if(t===G){tt=!0;return}fr(),ur(),process.on("exit",ot),t>G&&(console.error(`
267
+ `),process.exit(1)),t}function wn(e){try{f.chmodSync(e,384)}catch{}}function yr(e){if(yn(),f.existsSync(_))try{if(f.lstatSync(_).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${_}. 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=_+".tmp";try{f.writeFileSync(t,JSON.stringify(e,null,2)),wn(t),f.renameSync(t,_)}catch(n){try{f.unlinkSync(t)}catch{}throw n}}function gn(e,t){if(!f.existsSync(e))return;let n=`.pre-v${String(t).padStart(3,"0")}.backup`,o=f.readdirSync(e).filter(l=>{let c=l.toLowerCase();if(c.includes(".backup")||c===".schema-version"||c.endsWith(".tmp"))return!1;try{return f.statSync(b.join(e,l)).isFile()}catch{return!1}}),r=0,s=0,i=[];for(let l of o){let c=b.join(e,l),a=b.join(e,l+n);if(f.existsSync(a)){s++;continue}try{Sn(c,a),r++}catch(u){i.push({file:l,err:u.message})}}if(i.length>0){let l=new Error(`Failed to back up ${i.length} file(s) in ${b.basename(e)}/: `+i.map(c=>`${c.file} (${c.err})`).join(", "));throw l.code="BACKUP_INCOMPLETE",l}if(r>0||s>0){let l=s>0?` (${s} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${r} files in ${b.basename(e)}/ (${n})${l}`)}}var tt=!1;async function bn(){if(tt)return;yn(),kr();let t=hn().version;if(t===G){tt=!0;return}pr(),mr(),process.on("exit",ot),t>G&&(console.error(`
268
268
  [FATAL] Your data schema is at v${t}, but this plugin build only understands up to v${G}.`),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.
269
269
  `),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${G}.
270
270
  `),process.exit(1)),console.log(`
271
- \u{1F4E6} Schema migration: v${t} \u2192 v${G}`);let n=Sr();if(!n.ok){console.error(`
271
+ \u{1F4E6} Schema migration: v${t} \u2192 v${G}`);let n=Cr();if(!n.ok){console.error(`
272
272
  [FATAL] Cannot migrate \u2014 current data is corrupted:`);for(let r of n.broken)console.error(` ${r.dir}/${r.file}: ${r.err}`);console.error(`
273
273
  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'.
274
274
  `),process.exit(1)}let o=U.filter(r=>r.version>t);for(let r of o){console.log(`
275
- Running migration v${String(r.version).padStart(3,"0")}...`);let s=`v${String(r.version).padStart(3,"0")}`,i=`.pre-${s}.backup`;try{gn(re,r.version),gn(se,r.version)}catch(c){console.error(`
275
+ Running migration v${String(r.version).padStart(3,"0")}...`);let s=`v${String(r.version).padStart(3,"0")}`,i=`.pre-${s}.backup`;try{gn(oe,r.version),gn(re,r.version)}catch(c){console.error(`
276
276
  [FATAL] Pre-migration backup failed for ${s}: ${c.message}`),console.error(" Migration NOT applied. Repair the underlying issue (disk space, permissions, locked files)"),console.error(` and re-run the plugin command.
277
- `),process.exit(1)}let l=r.module;try{await l.up(re,se)}catch(c){console.error(`
278
- [FATAL] Migration ${s} failed: ${c.message}`),console.error(` Attempting auto-rollback from ${i} files...`);try{let d=vr(i);d.ok?(console.error(` \u2713 Auto-rollback restored ${d.restored} files. Schema stays at v${t}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
279
- `)):(console.error(` [!] Auto-rollback INCOMPLETE: ${d.error}`),console.error(` Manual recovery: copy *${i} files back over the originals.
280
- `))}catch(d){console.error(` [!] Auto-rollback CRASHED while restoring: ${d.message}`),console.error(` Manual recovery: copy *${i} files back over the originals.
281
- `)}process.exit(1)}try{let c=new Date().toISOString(),d={version:r.version,name:l.NAME||s,appliedAt:c},a=hn();a.version=r.version,a.migratedAt=c,a.migrations=a.migrations||[],a.migrations.push(d),pr(a)}catch(c){console.error(`
277
+ `),process.exit(1)}let l=r.module;try{await l.up(oe,re)}catch(c){console.error(`
278
+ [FATAL] Migration ${s} failed: ${c.message}`),console.error(` Attempting auto-rollback from ${i} files...`);try{let a=xr(i);a.ok?(console.error(` \u2713 Auto-rollback restored ${a.restored} files. Schema stays at v${t}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
279
+ `)):(console.error(` [!] Auto-rollback INCOMPLETE: ${a.error}`),console.error(` Manual recovery: copy *${i} files back over the originals.
280
+ `))}catch(a){console.error(` [!] Auto-rollback CRASHED while restoring: ${a.message}`),console.error(` Manual recovery: copy *${i} files back over the originals.
281
+ `)}process.exit(1)}try{let c=new Date().toISOString(),a={version:r.version,name:l.NAME||s,appliedAt:c},u=hn();u.version=r.version,u.migratedAt=c,u.migrations=u.migrations||[],u.migrations.push(a),yr(u)}catch(c){console.error(`
282
282
  [FATAL] Migration ${s} applied successfully but schema version file could NOT be updated: ${c.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.
283
- `),process.exit(1)}console.log(` \u2713 Migration ${s} complete`)}try{Ht()}catch{}try{Xt()}catch{}tt=!0,ot(),console.log(`
283
+ `),process.exit(1)}console.log(` \u2713 Migration ${s} complete`)}try{Ht()}catch{}try{Zt()}catch{}tt=!0,ot(),console.log(`
284
284
  \u2713 Schema is now at v${G}
285
- `)}var hr=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function gr(e){let t=e.toLowerCase();return hr.some(n=>n.test(t))}var yr=6e4;function wr(){let e=Date.now(),t=[];for(let n of[P,re,se]){if(!u.existsSync(n))continue;let o;try{o=u.readdirSync(n)}catch{continue}for(let r of o){if(!gr(r))continue;let s=S.join(n,r);try{let i=u.statSync(s);if(!i.isFile()||e-i.mtimeMs<yr)continue;t.push({dir:n,file:r,fullPath:s})}catch{}}}return t}function br({verbose:e=!1}={}){let t=wr();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 Sr(){let e=[];for(let t of[re,se]){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{$e(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 vr(e){let t=[],n=[];for(let s of[re,se]){if(!u.existsSync(s))continue;let i=u.readdirSync(s).filter(l=>l.endsWith(e));for(let l of i){let c=S.join(s,l),d=l.slice(0,-e.length),a=S.join(s,d);try{d.toLowerCase().endsWith(".json")?$e(c):u.accessSync(c,u.constants.R_OK),t.push({backupPath:c,originalPath:a,fileName:l,dir:s})}catch(m){n.push(`${S.basename(s)}/${l}: ${m.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let o=0,r=[];for(let{backupPath:s,originalPath:i,fileName:l,dir:c}of t)try{Sn(s,i),o++}catch(d){r.push(`${S.basename(c)}/${l}: ${d.message}`)}return r.length>0?{ok:!1,error:r.join("; "),restored:o}:{ok:!0,restored:o}}function Sn(e,t){let n=t+".tmp";try{u.copyFileSync(e,n),wn(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 bn();var Y=process.argv.slice(2),_e=parseInt(Y.find(e=>e.startsWith("--max="))?.split("=")[1]||"10"),ke=Y.includes("--connections"),vn=Y.find(e=>e.startsWith("--match-title="))?.split("=").slice(1).join("=")||null,$=vn?Ar(vn):null,kr=Y.includes("--list"),Cr=Y.includes("--verbose"),rt=Y.includes("--with-experience"),xr=Y.includes("--help")||Y.includes("-h");xr&&(console.log(`
285
+ `)}var wr=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function br(e){let t=e.toLowerCase();return wr.some(n=>n.test(t))}var Sr=6e4;function vr(){let e=Date.now(),t=[];for(let n of[M,oe,re]){if(!f.existsSync(n))continue;let o;try{o=f.readdirSync(n)}catch{continue}for(let r of o){if(!br(r))continue;let s=b.join(n,r);try{let i=f.statSync(s);if(!i.isFile()||e-i.mtimeMs<Sr)continue;t.push({dir:n,file:r,fullPath:s})}catch{}}}return t}function kr({verbose:e=!1}={}){let t=vr();if(t.length===0)return e&&console.log(" No orphan .tmp files found."),0;let n=0;for(let o of t)try{f.unlinkSync(o.fullPath),n++,e&&console.log(` Removed orphan: ${b.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 Cr(){let e=[];for(let t of[oe,re]){if(!f.existsSync(t))continue;let n=f.readdirSync(t).filter(o=>{let r=o.toLowerCase();return r.endsWith(".json")&&!r.includes(".backup")});for(let o of n){let r=b.join(t,o);try{Ee(r)}catch(s){e.push({dir:b.basename(t),file:o,err:s.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function xr(e){let t=[],n=[];for(let s of[oe,re]){if(!f.existsSync(s))continue;let i=f.readdirSync(s).filter(l=>l.endsWith(e));for(let l of i){let c=b.join(s,l),a=l.slice(0,-e.length),u=b.join(s,a);try{a.toLowerCase().endsWith(".json")?Ee(c):f.accessSync(c,f.constants.R_OK),t.push({backupPath:c,originalPath:u,fileName:l,dir:s})}catch(m){n.push(`${b.basename(s)}/${l}: ${m.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let o=0,r=[];for(let{backupPath:s,originalPath:i,fileName:l,dir:c}of t)try{Sn(s,i),o++}catch(a){r.push(`${b.basename(c)}/${l}: ${a.message}`)}return r.length>0?{ok:!1,error:r.join("; "),restored:o}:{ok:!0,restored:o}}function Sn(e,t){let n=t+".tmp";try{f.copyFileSync(e,n),wn(n)}catch(o){try{f.unlinkSync(n)}catch{}throw o}try{f.renameSync(n,t)}catch(o){try{f.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 bn();var Y=process.argv.slice(2),$e=parseInt(Y.find(e=>e.startsWith("--max="))?.split("=")[1]||"10"),ve=Y.includes("--connections"),vn=Y.find(e=>e.startsWith("--match-title="))?.split("=").slice(1).join("=")||null,$=vn?_r(vn):null,Ar=Y.includes("--list"),Er=Y.includes("--verbose"),rt=Y.includes("--with-experience"),$r=Y.includes("--help")||Y.includes("-h");$r&&(console.log(`
286
286
  enrich-profiles \u2014 batch-visit contacts in people.json missing About text
287
287
 
288
288
  USAGE
@@ -325,12 +325,12 @@ WHEN TO USE
325
325
  - You want to backfill in a controlled batch (\u2264 10 per day) before reaching
326
326
  out, so AI drafting has full context.
327
327
  - Use --connections to keep ban risk low.
328
- `),process.exit(0));function Ar(e){try{return new RegExp(e,"i")}catch(t){console.error(`Invalid regex for --match-title: ${t.message}`),process.exit(1)}}var Er=new Set(["pending","sent_with_note","sent_without_note"]);function $r(e){return!e.about||!e.about.trim()}function _r(e){return!Er.has(e.connectionStatus)}function kn(){let e=J(),t=Ue(),n=new Set,o=new Set;for(let l of Object.values(t))l.profileUrl&&n.add(l.profileUrl),(l.unread===!0||l.actionNeeded==="reply"||l.situation==="needs_our_reply"||l.conversationStatus==="unanswered_by_us")&&l.profileUrl&&o.add(l.profileUrl);let s=Object.entries(e).filter(([l,c])=>l&&l.startsWith("http")).filter(([,l])=>$r(l)).filter(([,l])=>_r(l)).filter(([l])=>!o.has(l)).map(([l,c])=>({profileUrl:l,name:c.name,person:c,hasConversation:n.has(l)}));ke&&(s=s.filter(l=>l.person.connectionStatus==="connected")),$&&(s=s.filter(l=>$.test(l.person.title||"")));function i(l){let c=l.person.connectionStatus==="connected";return c&&l.hasConversation?1:c?2:$&&$.test(l.person.title||"")?3:l.hasConversation?4:5}return s.sort((l,c)=>{let d=i(l),a=i(c);if(d!==a)return d-a;let m=l.person.lastFullVisitAt||"",f=c.person.lastFullVisitAt||"";return m.localeCompare(f)}),s.map(l=>({profileUrl:l.profileUrl,name:l.name,source:"enrich-profile"}))}function Ir(){let e=J(),t=Object.keys(e).length,n=Object.values(e).filter(m=>m.about&&m.about.trim()).length,o=t-n,r=kn(),s={connWithConv:0,conn:0,titleMatch:0,withConv:0,other:0},i=e,l=Ue(),c=new Set(Object.values(l).map(m=>m.profileUrl).filter(Boolean)),d=Object.values(l).filter(m=>m.profileUrl&&(m.unread===!0||m.actionNeeded==="reply"||m.situation==="needs_our_reply"||m.conversationStatus==="unanswered_by_us")).length,a=0;for(let m of r){let f=i[m.profileUrl],p=f.connectionStatus==="connected",v=$&&$.test(f.title||""),b=c.has(m.profileUrl);f.lastFullVisitAt||a++,p&&b?s.connWithConv++:p?s.conn++:v?s.titleMatch++:b?s.withConv++:s.other++}console.log(`
329
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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): ${d}`),console.log(` Visitable (queue): ${r.length}`),console.log(` Never fully visited: ${a} (gone first)`),$&&console.log(` Title-match filter: /${$.source}/i`),ke&&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 ${_e}/day \u2192 ~${Math.ceil(r.length/_e)} days to clear queue
330
- `)}function Tr(){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 Rr(){if(console.log(`
328
+ `),process.exit(0));function _r(e){try{return new RegExp(e,"i")}catch(t){console.error(`Invalid regex for --match-title: ${t.message}`),process.exit(1)}}var Ir=new Set(["pending","sent_with_note","sent_without_note"]);function Tr(e){return!e.about||!e.about.trim()}function Rr(e){return!Ir.has(e.connectionStatus)}function kn(){let e=W(),t=Ue(),n=new Set,o=new Set;for(let l of Object.values(t))l.profileUrl&&n.add(l.profileUrl),(l.unread===!0||l.actionNeeded==="reply"||l.situation==="needs_our_reply"||l.conversationStatus==="unanswered_by_us")&&l.profileUrl&&o.add(l.profileUrl);let s=Object.entries(e).filter(([l,c])=>l&&l.startsWith("http")).filter(([,l])=>Tr(l)).filter(([,l])=>Rr(l)).filter(([l])=>!o.has(l)).map(([l,c])=>({profileUrl:l,name:c.name,person:c,hasConversation:n.has(l)}));ve&&(s=s.filter(l=>l.person.connectionStatus==="connected")),$&&(s=s.filter(l=>$.test(l.person.title||"")));function i(l){let c=l.person.connectionStatus==="connected";return c&&l.hasConversation?1:c?2:$&&$.test(l.person.title||"")?3:l.hasConversation?4:5}return s.sort((l,c)=>{let a=i(l),u=i(c);if(a!==u)return a-u;let m=l.person.lastFullVisitAt||"",d=c.person.lastFullVisitAt||"";return m.localeCompare(d)}),s.map(l=>({profileUrl:l.profileUrl,name:l.name,source:"enrich-profile"}))}function Dr(){let e=W(),t=Object.keys(e).length,n=Object.values(e).filter(m=>m.about&&m.about.trim()).length,o=t-n,r=kn(),s={connWithConv:0,conn:0,titleMatch:0,withConv:0,other:0},i=e,l=Ue(),c=new Set(Object.values(l).map(m=>m.profileUrl).filter(Boolean)),a=Object.values(l).filter(m=>m.profileUrl&&(m.unread===!0||m.actionNeeded==="reply"||m.situation==="needs_our_reply"||m.conversationStatus==="unanswered_by_us")).length,u=0;for(let m of r){let d=i[m.profileUrl],h=d.connectionStatus==="connected",x=$&&$.test(d.title||""),S=c.has(m.profileUrl);d.lastFullVisitAt||u++,h&&S?s.connWithConv++:h?s.conn++:x?s.titleMatch++:S?s.withConv++:s.other++}console.log(`
329
+ \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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): ${a}`),console.log(` Visitable (queue): ${r.length}`),console.log(` Never fully visited: ${u} (gone first)`),$&&console.log(` Title-match filter: /${$.source}/i`),ve&&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 ${$e}/day \u2192 ~${Math.ceil(r.length/$e)} days to clear queue
330
+ `)}function Or(){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 jr(){if(console.log(`
331
331
  LinkedIn Profile Enricher
332
- `),kr){Ir();return}Tr(),rt&&(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=kn();if(console.log(` Queue size: ${e.length}`),console.log(` Max visits this session: ${_e}`),$&&console.log(` Title filter: /${$.source}/i`),ke&&console.log(" Connections only: yes"),rt&&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".
333
- `);return}let t=ke&&$?"connections+title":ke?"connections":$?`title=${$.source}`:"all",n=an("enrich-profiles",t),{browser:o,page:r}=await Mt();try{let s=await nn(r,e,{maxVisits:_e,verbose:Cr,skipRecentDays:7,extractExperience:rt}),i=J(),l=0;for(let c of e.slice(0,s.visited+s.skipped))i[c.profileUrl]?.about?.trim()&&l++;console.log(`
332
+ `),Ar){Dr();return}Or(),rt&&(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=kn();if(console.log(` Queue size: ${e.length}`),console.log(` Max visits this session: ${$e}`),$&&console.log(` Title filter: /${$.source}/i`),ve&&console.log(" Connections only: yes"),rt&&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".
333
+ `);return}let t=ve&&$?"connections+title":ve?"connections":$?`title=${$.source}`:"all",n=an("enrich-profiles",t),{browser:o,page:r}=await Pt();try{let s=await nn(r,e,{maxVisits:$e,verbose:Er,skipRecentDays:7,extractExperience:rt}),i=W(),l=0;for(let c of e.slice(0,s.visited+s.skipped))i[c.profileUrl]?.about?.trim()&&l++;console.log(`
334
334
  \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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: ${l} / ${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
335
335
  `),Ye(n,"success",s)}catch(s){console.error(`
336
- Error:`,s.message),Ye(n,"error",null,s.message)}finally{await o.close().catch(()=>{})}}Rr().catch(e=>{console.error("Enrich-profiles failed:",e),process.exit(1)});
336
+ Error:`,s.message),Ye(n,"error",null,s.message)}finally{await o.close().catch(()=>{})}}jr().catch(e=>{console.error("Enrich-profiles failed:",e),process.exit(1)});