ilml-plugin-linkedin 1.20.21 → 1.20.26
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.
- package/CHANGELOG.md +22 -0
- package/dist/applyQueue.mjs +35 -35
- package/dist/connect.mjs +78 -77
- package/dist/daily.mjs +37 -37
- package/dist/enrichProfiles.mjs +50 -50
- package/dist/funnelRunner.mjs +61 -60
- package/dist/messageBot.mjs +73 -73
- package/dist/migrationCli.mjs +44 -44
- package/dist/peopleSearchCli.mjs +13 -0
- package/dist/quota.mjs +34 -34
- package/dist/run.mjs +65 -64
- package/dist/scout.mjs +31 -31
- package/dist/syncAll.mjs +96 -95
- package/dist/syncConnections.mjs +50 -50
- package/dist/version.mjs +1 -1
- package/dist/viewers.mjs +43 -43
- package/dist/visit.mjs +48 -48
- package/ilml-plugin.json +19 -1
- package/package.json +2 -1
package/dist/visit.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Hn=Object.defineProperty;var K=(e,t)=>()=>(e&&(t=e(e=0)),t);var de=(e,t)=>{for(var n in t)Hn(e,n,{get:t[n],enumerable:!0})};import T from"fs";import H from"path";function Me(){let e=process.env.ILML_SCOPE_DIR;return e?H.join(e,"plugins-state","linkedin","cookies.json"):Jn}function Wn(){let e=Me(),t=H.dirname(e);return t&&t!=="."&&!T.existsSync(t)&&T.mkdirSync(t,{recursive:!0}),e}function xt(e){let t=Wn();return T.writeFileSync(t,JSON.stringify(e)),t}function At(){let e=Me();if(!T.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=T.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 Et(){return T.existsSync(Me())}function Gn(){let e=process.env.ILML_SCOPE_DIR;return e?H.join(e,"plugins-state","linkedin"):"."}function _t(e){let t=String(e||"").replace(/[^a-zA-Z0-9_.-]/g,"_").slice(0,80);return/[a-zA-Z0-9]/.test(t)?t:"default"}function Yn(){let e=process.env.MY_LINKEDIN_URL,t=e&&e.match(/\/in\/([^/?#]+)/);return t&&t[1]?_t(t[1]):"default"}function $t(e){let t=process.env.LINKEDIN_CHROME_PROFILE_DIR;if(t)return T.existsSync(t)||T.mkdirSync(t,{recursive:!0}),H.resolve(t);let n=_t(e||Yn()),o=H.join(Gn(),"chrome-profile",n);return T.existsSync(o)||T.mkdirSync(o,{recursive:!0}),H.resolve(o)}function Rt(e){return!T.existsSync(H.join(e,It))}function Tt(e){try{T.writeFileSync(H.join(e,It),new Date().toISOString())}catch{}}function Dt(e){let t=0;for(let n of["SingletonLock","SingletonCookie","SingletonSocket"])try{T.rmSync(H.join(e,n),{force:!0}),t++}catch{}return t}var Jn,It,Ie=K(()=>{Jn="cookies.json";It=".ilml-seeded"});async function x(e){let t=Math.floor(Math.random()*2001),n=e+t;return new Promise(o=>setTimeout(o,n))}async function Kn(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(a=>!!document.querySelector(a),t)){let a=Date.now()-s;return a>6e3&&console.log(` (waited ${Math.round(a/1e3)}s for LinkedIn to finish loading ${r})`),!0}}catch{}await new Promise(i=>setTimeout(i,o))}return!1}function zn(e){return jt.test(e||"")}async function Qn(e,{credentialWaitMs:t=36e4,label:n="page"}={}){console.log(` \u26A0 Auth wall on ${n} \u2014 attempting self-recovery (cookies may just need a refresh)...`);try{await e.goto("https://www.linkedin.com/feed/",{waitUntil:"domcontentloaded",timeout:6e4})}catch{}let o=!!(process.stdin&&process.stdin.isTTY),r=o?t:Math.min(t,45e3),s=Date.now(),i=!1;for(;Date.now()-s<r;){let l="wait";try{l=await e.evaluate(u=>!new RegExp(u).test(location.href)&&document.querySelector("#global-nav, nav.global-nav")?"in":document.querySelector('input#username, input[name="session_key"], input#password')?"creds":"wait",jt.source)}catch{}if(l==="in"){try{let u=await e.cookies();if(Array.isArray(u)&&u.some(p=>p.name==="li_at")){let p=xt(u);console.log(` \u2713 Session recovered \u2014 re-saved ${u.length} cookies (${p}).`)}else console.log(" \u2713 Session recovered (kept existing cookie snapshot \u2014 refreshed set had no li_at).")}catch(u){console.log(` \u2713 Session recovered (cookie re-save skipped: ${u.message}).`)}return!0}if(l==="creds"){if(!o){let u=new Error(`Session expired (${n}) \u2014 credentials required and no interactive terminal. Run: ilml linkedin login`);throw u.code="SESSION_EXPIRED",u}i||(i=!0,console.log(`
|
|
2
2
|
\u26A0 LinkedIn is asking for your login + password (cookies not enough this time).`),console.log(" \u2192 Sign in MANUALLY in the browser window that is already open."),console.log(` I will wait and resume automatically \u2014 do NOT close the window or re-run the command.
|
|
3
|
-
`))}await new Promise(d=>setTimeout(d,2500))}let a=new Error(`Session expired (${n}) \u2014 not signed in within the wait window. Run: ilml linkedin login`);throw a.code="SESSION_EXPIRED",a}async function It(e,{readySelector:t,label:n="page",timeout:o=45e3}={}){let r=await Hn(e,t,{timeout:o,label:n});if(!r&&Jn(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 ce(e,t,{readySelector:n,label:o="page",timeout:r=45e3,gotoTimeout:s=6e4,autoRecover:i=!0}={}){await e.goto(t,{waitUntil:"domcontentloaded",timeout:s});try{return await It(e,{readySelector:n,label:o,timeout:r})}catch(a){if(i&&a.code==="SESSION_EXPIRED"){await Wn(e,{label:o});try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:s})}catch{}return await It(e,{readySelector:n,label:o,timeout:r})}throw a}}async function Tt(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"),a=r.includes("Get hired faster")||r.includes("Get hired 2x");if(s||i||a){let l=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(l)return l.click(),{dismissed:!0,matched:r.substring(0,80)};let d=o.querySelectorAll("button");for(let c of d){let p=c.innerText?.trim().toLowerCase()||"",u=c.getAttribute("aria-label")?.toLowerCase()||"";if(p==="not now"||p==="no thanks"||p==="dismiss"||u.includes("dismiss"))return c.click(),{dismissed:!0,matched:r.substring(0,80)}}}}let n=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(n){let o=n.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||n.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(o)return o.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var Rt,he=Y(()=>{Ee();Rt=/\/authwall|\/login|\/checkpoint|\/uas\/login/});function Yn(e){return String(e??"").split(/[,\s|]+/).map(t=>t.trim()).filter(Boolean)}function Ot(e=process.env){let t=(e.JOB_SEARCH_KEYWORDS||"").trim();if(!t)return null;let n=new URLSearchParams;n.set("keywords",t);let o=(e.JOB_SEARCH_LOCATION||"").trim();o&&n.set("location",o);let r=(e.JOB_SEARCH_GEO_ID||"").trim();r&&n.set("geoId",r);let s=parseInt(e.JOB_SEARCH_RADIUS_MILES,10);Number.isFinite(s)&&s>0&&n.set("distance",String(s)),Dt(e.JOB_SEARCH_EASY_APPLY)&&n.set("f_AL","true"),Dt(e.JOB_SEARCH_IN_NETWORK)&&n.set("f_JIYN","true");let i=Yn(e.JOB_SEARCH_COMPANY_IDS);i.length&&n.set("f_C",i.join(","));let a=(e.JOB_SEARCH_DATE_POSTED||"").trim().toLowerCase();a&&n.set("f_TPR",Gn[a]||a),n.set("origin","JOB_SEARCH_PAGE_JOB_FILTER");let l="https://www.linkedin.com/jobs/search/?"+n.toString(),d=(e.JOB_SEARCH_EXTRA_PARAMS||"").trim().replace(/^[?&]+/,"");return d&&(l+="&"+d),l}var Gn,Dt,jt=Y(()=>{Gn={day:"r86400","24h":"r86400",today:"r86400",week:"r604800","7d":"r604800",month:"r2592000","30d":"r2592000"},Dt=e=>/^(1|true|yes|on)$/i.test(String(e??"").trim())});import{getPluginConfig as Kn}from"@ilivemylife/graph-sdk";var zn,Nt,Qn,Z,es,Xn,Pe=Y(async()=>{jt();zn=await Kn();for(let[e,t]of Object.entries(zn))process.env[e]===void 0&&(process.env[e]=t);Nt=Ot(process.env);Nt&&(process.env.LINKEDIN_SEARCH_URL=Nt);Qn=process.env.LINKEDIN_NAME,Z=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),es=Object.freeze(new Set([Z.DRAFT,Z.CONFIRMED,Z.NEEDS_REVIEW])),Xn=Object.freeze(new Set([Z.DRAFT,Z.CONFIRMED,Z.REJECTED,Z.NEEDS_REVIEW]))});import"dotenv/config";import*as A from"fs";import*as _ from"path";import{fileURLToPath as ao}from"url";function zt(){ue=null,fo=null,mo=null,po=null,ho=null,go=null}function Qt(){A.existsSync(H)||A.mkdirSync(H,{recursive:!0})}function Xt(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";A.writeFileSync(o,n);for(let r=0;r<3;r++)try{A.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 Zt(e,t){if(!A.existsSync(e))return null;try{let n=JSON.parse(A.readFileSync(e,"utf-8"));try{A.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${_.resolve(e)}`);let o=e+".backup";if(A.existsSync(o))try{let r=JSON.parse(A.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{A.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{A.copyFileSync(e,e+".corrupted")}catch{}return null}}function yo(){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 Wt(e){return typeof e=="string"?e.replace(/\s+/g," ").trim().toLowerCase():""}function en(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=Wt(n),i=Wt(e[r].name);if(s&&i&&s===i)return r}return t}function bo(){A.existsSync(Ue)||A.mkdirSync(Ue,{recursive:!0})}function tn(e){let t=ee(e);return t?_.join(Ue,`${t}.json`):null}function vo(e){let t=tn(e);return t?Zt(t,`profile-history/${ee(e)}.json`)||[]:[]}function ko(e,t){let n=tn(e);if(!n)return;bo();let o=vo(e);o.unshift(t);try{Xt(n,o)}catch(r){console.error(`[!] Failed to append profile-history for ${ee(e)}: ${r.message}`)}}function Gt(e){return!!(e==null||Array.isArray(e)&&e.length===0||typeof e=="string"&&!e.trim())}function Yt(e){return Array.isArray(e)?[...e].map(t=>String(t).trim()).sort().join("||"):typeof e=="string"?e.replace(/\s+/g," ").trim():e}function Co(e,t){if(!e)return[];let n=[];for(let o of So){let r=e[o],s=t[o];Gt(r)||Gt(s)||Yt(r)!==Yt(s)&&n.push(o)}return n}function xo(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 de(){return ue||(Qt(),ue=Zt(qe,"people.json")||{},ue)}function nn(e){Qt(),ue=e;try{Xt(qe,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${_.resolve(qe)}`)}}function Be(e,t={}){if(!e)return null;let n=de(),o=yo(),r=new Date().toISOString(),s=en(n,e,t.name),i=n[s];if(i){let a=Co(i,t);a.length>0&&(ko(s,{capturedAt:r,previousLastUpdated:i.lastUpdated||null,changedFields:a,snapshot:xo(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 l of wo)if(t[l]!=null){if(Array.isArray(t[l])&&t[l].length===0&&Array.isArray(i[l])&&i[l].length>0)continue;i[l]=t[l]}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 nn(n),n[s]}function Ve(e,t,n={}){if(n.dryRun||!e||!t)return;let o=ee(t);if(!o)return;let r=de(),s=en(r,e),i=r[s];if(!i)return;let a=ee(i.profileUrl||s);o!==a&&(Array.isArray(i.aliases)||(i.aliases=[]),i.aliases.includes(o)||(i.aliases.push(o),i.lastUpdated=new Date().toISOString(),nn(r)))}var co,uo,H,qe,vs,ks,Cs,xs,As,Ue,Kt,Es,_s,ue,fo,mo,po,ho,go,wo,So,$e=Y(async()=>{await Pe();co=ao(import.meta.url),uo=_.dirname(_.dirname(co)),H=process.env.DATA_DIR?_.resolve(process.env.DATA_DIR,"collected-profiles"):_.join(uo,"collected-profiles"),qe=_.join(H,"people.json"),vs=_.join(H,"jobs.json"),ks=_.join(H,"quota.json"),Cs=_.join(H,"conversations.json"),xs=_.join(H,"sync-state.json"),As=_.join(H,"application-questions.json"),Ue=_.join(H,"profile-history"),Kt=(e,t)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:t},Es=Kt(process.env.CONNECT_MAX_DAILY,20),_s=Kt(process.env.CONNECT_MAX_WEEKLY,100),ue=null,fo=null,mo=null,po=null,ho=null,go=null;wo=["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 on={};pe(on,{extractCertificationsFromDetails:()=>Io,extractEducationFromDetails:()=>_o,extractExperienceFromDetails:()=>Ao,extractFeaturedFromDetails:()=>Eo,extractRecommendationsFromDetails:()=>Ro,extractSkillsFromDetails:()=>$o});async function Ao(e,t){let n=t.replace(/\/+$/,"")+"/details/experience/";try{await ce(e,n,{readySelector:"main .pvs-list, .scaffold-layout__main, main.scaffold-layout__main, section.artdeco-card",label:"experience details"}),await x(1e3);let o=e.url();if(!o.toLowerCase().includes("/details/experience/"))throw new Error(`Section /details/experience/ not available on profile (landed on ${o})`);for(let s=0;s<5;s++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await x(900);await x(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 x(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await x(700);return await e.evaluate(()=>{let s=document.querySelector("main");if(!s)return[];function i(c){let p=[];for(let u of c.querySelectorAll("div")){let f=Array.from(u.children).filter(b=>b.tagName==="DIV");if(f.length<3)continue;let C=f.filter(b=>(b.textContent||"").trim().length>50);C.length<3||(u.textContent||"").length<500||p.push({el:u,count:C.length,totalText:(u.textContent||"").length})}return p.sort((u,f)=>f.count-u.count||u.totalText-f.totalText),p[0]?.el}let a=i(s);if(!a)return[];let l=Array.from(a.children).filter(c=>c.tagName==="DIV").filter(c=>(c.textContent||"").trim().length>50);function d(c){let p=c[0]||null,u=null,f=null;if(c[1]){let v=c[1].split("\xB7").map(I=>I.trim());u=v[0]||null,v[1]&&(f=v[1])}let C=c.findIndex(v=>/(\d{4}|present)/i.test(v)&&/(-|–|—)/i.test(v)&&v.length<80),b=null,$=null;if(C>=0){let v=c[C].split("\xB7").map(I=>I.trim());b=v[0]||null,v[1]&&($=v[1])}let y=null,g=-1;if(C>=0&&c[C+1]){let v=c[C+1],I=/^[>*\-•]|^>/.test(v),le=/https?:\/\//.test(v),ae=/\d{4}/.test(v),R=/,/.test(v)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(v);!I&&!le&&!ae&&v.length<100&&R&&(y=v,g=C+1)}let B=null,E=-1,Q=c[c.length-1];if(Q&&/and\s+\+\d+\s+skills?$/i.test(Q)){E=c.length-1;let v=Q.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);v&&(B={listed:v[1].split(",").map(I=>I.trim()),additional:parseInt(v[2],10)})}let X=new Set([0,1,C,g,E].filter(v=>v>=0)),W=c.filter((v,I)=>!X.has(I)),O=W.length>0?W.join(`
|
|
3
|
+
`))}await new Promise(u=>setTimeout(u,2500))}let a=new Error(`Session expired (${n}) \u2014 not signed in within the wait window. Run: ilml linkedin login`);throw a.code="SESSION_EXPIRED",a}async function Ot(e,{readySelector:t,label:n="page",timeout:o=45e3}={}){let r=await Kn(e,t,{timeout:o,label:n});if(!r&&zn(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 fe(e,t,{readySelector:n,label:o="page",timeout:r=45e3,gotoTimeout:s=6e4,autoRecover:i=!0}={}){await e.goto(t,{waitUntil:"domcontentloaded",timeout:s});try{return await Ot(e,{readySelector:n,label:o,timeout:r})}catch(a){if(i&&a.code==="SESSION_EXPIRED"){await Qn(e,{label:o});try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:s})}catch{}return await Ot(e,{readySelector:n,label:o,timeout:r})}throw a}}async function Nt(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"),a=r.includes("Get hired faster")||r.includes("Get hired 2x");if(s||i||a){let l=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(l)return l.click(),{dismissed:!0,matched:r.substring(0,80)};let u=o.querySelectorAll("button");for(let c of u){let p=c.innerText?.trim().toLowerCase()||"",d=c.getAttribute("aria-label")?.toLowerCase()||"";if(p==="not now"||p==="no thanks"||p==="dismiss"||d.includes("dismiss"))return c.click(),{dismissed:!0,matched:r.substring(0,80)}}}}let n=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(n){let o=n.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||n.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(o)return o.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var jt,ye=K(()=>{Ie();jt=/\/authwall|\/login|\/checkpoint|\/uas\/login/});function Zn(e){return String(e??"").split(/[,\s|]+/).map(t=>t.trim()).filter(Boolean)}function Pt(e=process.env){let t=(e.JOB_SEARCH_KEYWORDS||"").trim();if(!t)return null;let n=new URLSearchParams;n.set("keywords",t);let o=(e.JOB_SEARCH_LOCATION||"").trim();o&&n.set("location",o);let r=(e.JOB_SEARCH_GEO_ID||"").trim();r&&n.set("geoId",r);let s=parseInt(e.JOB_SEARCH_RADIUS_MILES,10);Number.isFinite(s)&&s>0&&n.set("distance",String(s)),Lt(e.JOB_SEARCH_EASY_APPLY)&&n.set("f_AL","true"),Lt(e.JOB_SEARCH_IN_NETWORK)&&n.set("f_JIYN","true");let i=Zn(e.JOB_SEARCH_COMPANY_IDS);i.length&&n.set("f_C",i.join(","));let a=(e.JOB_SEARCH_DATE_POSTED||"").trim().toLowerCase();a&&n.set("f_TPR",Xn[a]||a),n.set("origin","JOB_SEARCH_PAGE_JOB_FILTER");let l="https://www.linkedin.com/jobs/search/?"+n.toString(),u=(e.JOB_SEARCH_EXTRA_PARAMS||"").trim().replace(/^[?&]+/,"");return u&&(l+="&"+u),l}var Xn,Lt,Ft=K(()=>{Xn={day:"r86400","24h":"r86400",today:"r86400",week:"r604800","7d":"r604800",month:"r2592000","30d":"r2592000"},Lt=e=>/^(1|true|yes|on)$/i.test(String(e??"").trim())});import{getPluginConfig as eo}from"@ilivemylife/graph-sdk";var to,Mt,no,ee,ds,oo,qe=K(async()=>{Ft();to=await eo();for(let[e,t]of Object.entries(to))process.env[e]===void 0&&(process.env[e]=t);Mt=Pt(process.env);Mt&&(process.env.LINKEDIN_SEARCH_URL=Mt);no=process.env.LINKEDIN_NAME,ee=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),ds=Object.freeze(new Set([ee.DRAFT,ee.CONFIRMED,ee.NEEDS_REVIEW])),oo=Object.freeze(new Set([ee.DRAFT,ee.CONFIRMED,ee.REJECTED,ee.NEEDS_REVIEW]))});import"dotenv/config";import*as A from"fs";import*as _ from"path";import{fileURLToPath as po}from"url";function en(){me=null,yo=null,wo=null,So=null,bo=null,vo=null}function tn(){A.existsSync(J)||A.mkdirSync(J,{recursive:!0})}function nn(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";A.writeFileSync(o,n);for(let r=0;r<3;r++)try{A.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 on(e,t){if(!A.existsSync(e))return null;try{let n=JSON.parse(A.readFileSync(e,"utf-8"));try{A.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${_.resolve(e)}`);let o=e+".backup";if(A.existsSync(o))try{let r=JSON.parse(A.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{A.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{A.copyFileSync(e,e+".corrupted")}catch{}return null}}function ko(){return new Date().toISOString().split("T")[0]}function te(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function zt(e){return typeof e=="string"?e.replace(/\s+/g," ").trim().toLowerCase():""}function rn(e,t,n=null){if(!t||e[t])return t;let o=te(t);if(!o)return t;let r=null;for(let[s,i]of Object.entries(e)){if(te(i.profileUrl||s)===o)return s;!r&&Array.isArray(i.aliases)&&i.aliases.includes(o)&&(r=s)}if(r){let s=zt(n),i=zt(e[r].name);if(s&&i&&s===i)return r}return t}function Ao(){A.existsSync(He)||A.mkdirSync(He,{recursive:!0})}function sn(e){let t=te(e);return t?_.join(He,`${t}.json`):null}function Eo(e){let t=sn(e);return t?on(t,`profile-history/${te(e)}.json`)||[]:[]}function _o(e,t){let n=sn(e);if(!n)return;Ao();let o=Eo(e);o.unshift(t);try{nn(n,o)}catch(r){console.error(`[!] Failed to append profile-history for ${te(e)}: ${r.message}`)}}function Qt(e){return!!(e==null||Array.isArray(e)&&e.length===0||typeof e=="string"&&!e.trim())}function Xt(e){return Array.isArray(e)?[...e].map(t=>String(t).trim()).sort().join("||"):typeof e=="string"?e.replace(/\s+/g," ").trim():e}function $o(e,t){if(!e)return[];let n=[];for(let o of xo){let r=e[o],s=t[o];Qt(r)||Qt(s)||Xt(r)!==Xt(s)&&n.push(o)}return n}function Io(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 pe(){return me||(tn(),me=on(Ve,"people.json")||{},me)}function ln(e){tn(),me=e;try{nn(Ve,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${_.resolve(Ve)}`)}}function Je(e,t={}){if(!e)return null;let n=pe(),o=ko(),r=new Date().toISOString(),s=rn(n,e,t.name),i=n[s];if(i){let a=$o(i,t);a.length>0&&(_o(s,{capturedAt:r,previousLastUpdated:i.lastUpdated||null,changedFields:a,snapshot:Io(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 l of Co)if(t[l]!=null){if(Array.isArray(t[l])&&t[l].length===0&&Array.isArray(i[l])&&i[l].length>0)continue;i[l]=t[l]}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 ln(n),n[s]}function We(e,t,n={}){if(n.dryRun||!e||!t)return;let o=te(t);if(!o)return;let r=pe(),s=rn(r,e),i=r[s];if(!i)return;let a=te(i.profileUrl||s);o!==a&&(Array.isArray(i.aliases)||(i.aliases=[]),i.aliases.includes(o)||(i.aliases.push(o),i.lastUpdated=new Date().toISOString(),ln(r)))}var ho,go,J,Ve,Ds,Os,js,Ns,Ls,He,Zt,Ps,Fs,me,yo,wo,So,bo,vo,Co,xo,Te=K(async()=>{await qe();ho=po(import.meta.url),go=_.dirname(_.dirname(ho)),J=process.env.DATA_DIR?_.resolve(process.env.DATA_DIR,"collected-profiles"):_.join(go,"collected-profiles"),Ve=_.join(J,"people.json"),Ds=_.join(J,"jobs.json"),Os=_.join(J,"quota.json"),js=_.join(J,"conversations.json"),Ns=_.join(J,"sync-state.json"),Ls=_.join(J,"application-questions.json"),He=_.join(J,"profile-history"),Zt=(e,t)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:t},Ps=Zt(process.env.CONNECT_MAX_DAILY,20),Fs=Zt(process.env.CONNECT_MAX_WEEKLY,100),me=null,yo=null,wo=null,So=null,bo=null,vo=null;Co=["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"],xo=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"]});var an={};de(an,{extractCertificationsFromDetails:()=>jo,extractEducationFromDetails:()=>Do,extractExperienceFromDetails:()=>Ro,extractFeaturedFromDetails:()=>To,extractRecommendationsFromDetails:()=>No,extractSkillsFromDetails:()=>Oo});async function Ro(e,t){let n=t.replace(/\/+$/,"")+"/details/experience/";try{await fe(e,n,{readySelector:"main .pvs-list, .scaffold-layout__main, main.scaffold-layout__main, section.artdeco-card",label:"experience details"}),await x(1e3);let o=e.url();if(!o.toLowerCase().includes("/details/experience/"))throw new Error(`Section /details/experience/ not available on profile (landed on ${o})`);for(let s=0;s<5;s++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await x(900);await x(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 x(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await x(700);return await e.evaluate(()=>{let s=document.querySelector("main");if(!s)return[];function i(c){let p=[];for(let d of c.querySelectorAll("div")){let f=Array.from(d.children).filter(v=>v.tagName==="DIV");if(f.length<3)continue;let b=f.filter(v=>(v.textContent||"").trim().length>50);b.length<3||(d.textContent||"").length<500||p.push({el:d,count:b.length,totalText:(d.textContent||"").length})}return p.sort((d,f)=>f.count-d.count||d.totalText-f.totalText),p[0]?.el}let a=i(s);if(!a)return[];let l=Array.from(a.children).filter(c=>c.tagName==="DIV").filter(c=>(c.textContent||"").trim().length>50);function u(c){let p=c[0]||null,d=null,f=null;if(c[1]){let k=c[1].split("\xB7").map(I=>I.trim());d=k[0]||null,k[1]&&(f=k[1])}let b=c.findIndex(k=>/(\d{4}|present)/i.test(k)&&/(-|–|—)/i.test(k)&&k.length<80),v=null,$=null;if(b>=0){let k=c[b].split("\xB7").map(I=>I.trim());v=k[0]||null,k[1]&&($=k[1])}let y=null,g=-1;if(b>=0&&c[b+1]){let k=c[b+1],I=/^[>*\-•]|^>/.test(k),ce=/https?:\/\//.test(k),ue=/\d{4}/.test(k),R=/,/.test(k)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(k);!I&&!ce&&!ue&&k.length<100&&R&&(y=k,g=b+1)}let V=null,E=-1,X=c[c.length-1];if(X&&/and\s+\+\d+\s+skills?$/i.test(X)){E=c.length-1;let k=X.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);k&&(V={listed:k[1].split(",").map(I=>I.trim()),additional:parseInt(k[2],10)})}let Z=new Set([0,1,b,g,E].filter(k=>k>=0)),G=c.filter((k,I)=>!Z.has(I)),O=G.length>0?G.join(`
|
|
4
4
|
|
|
5
|
-
`):null;return{title:p,company:
|
|
6
|
-
`).map(f=>f.trim()).filter(f=>f&&f.length<5e3);return d
|
|
7
|
-
${
|
|
5
|
+
`):null;return{title:p,company:d,employmentType:f,dates:v,duration:$,location:y,description:O,skills:V,_raw:c}}return l.map(c=>{let d=(c.innerText||"").trim().split(`
|
|
6
|
+
`).map(f=>f.trim()).filter(f=>f&&f.length<5e3);return u(d)}).filter(c=>c.title)})}catch(o){if(o.code==="SESSION_EXPIRED"||/^session expired/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 fe(e,o,{readySelector:"main .pvs-list, .scaffold-layout__main, main.scaffold-layout__main, section.artdeco-card",label:`details/${n}`}),await x(1e3);let r=e.url();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 x(700);await x(800);let s=0;for(;s<5&&await e.evaluate(()=>{for(let a of document.querySelectorAll("button"))if(/^Load more$/i.test((a.textContent||"").trim()))return a.click(),!0;return!1});)s++,await x(1300),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await x(600)}async function ke(e,t,n,o){try{return await o()}catch(r){let s=r.message||"";if(r.code==="SESSION_EXPIRED"||/^session expired/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 To(e,t){return ke(t,"featured","extractFeaturedFromDetails",async()=>(await be(e,t,"featured"),await e.evaluate(`(() => {
|
|
7
|
+
${ve}
|
|
8
8
|
|
|
9
9
|
const main = document.querySelector('main');
|
|
10
10
|
if (!main) return [];
|
|
@@ -44,8 +44,8 @@ var Mn=Object.defineProperty;var Y=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{f
|
|
|
44
44
|
if (e.caption && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.caption.trim())) return false;
|
|
45
45
|
return true;
|
|
46
46
|
});
|
|
47
|
-
})()`)))}async function
|
|
48
|
-
${
|
|
47
|
+
})()`)))}async function Do(e,t){return ke(t,"education","extractEducationFromDetails",async()=>(await be(e,t,"education"),await e.evaluate(`(() => {
|
|
48
|
+
${ve}
|
|
49
49
|
|
|
50
50
|
const main = document.querySelector('main');
|
|
51
51
|
if (!main) return [];
|
|
@@ -81,8 +81,8 @@ var Mn=Object.defineProperty;var Y=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{f
|
|
|
81
81
|
if (e.degree && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.degree.trim())) return false;
|
|
82
82
|
return true;
|
|
83
83
|
});
|
|
84
|
-
})()`)))}async function
|
|
85
|
-
${
|
|
84
|
+
})()`)))}async function Oo(e,t){return ke(t,"skills","extractSkillsFromDetails",async()=>(await be(e,t,"skills"),await e.evaluate(`(() => {
|
|
85
|
+
${ve}
|
|
86
86
|
|
|
87
87
|
const main = document.querySelector('main');
|
|
88
88
|
if (!main) return [];
|
|
@@ -113,8 +113,8 @@ var Mn=Object.defineProperty;var Y=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{f
|
|
|
113
113
|
skills.push({ name, endorsements, _raw: lines });
|
|
114
114
|
}
|
|
115
115
|
return skills;
|
|
116
|
-
})()`)))}async function
|
|
117
|
-
${
|
|
116
|
+
})()`)))}async function jo(e,t){return ke(t,"certifications","extractCertificationsFromDetails",async()=>(await be(e,t,"certifications"),await e.evaluate(`(() => {
|
|
117
|
+
${ve}
|
|
118
118
|
|
|
119
119
|
const main = document.querySelector('main');
|
|
120
120
|
if (!main) return [];
|
|
@@ -138,8 +138,8 @@ var Mn=Object.defineProperty;var Y=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{f
|
|
|
138
138
|
|
|
139
139
|
return { name, issuer, issueDate, expiryDate, credentialId, _raw: lines };
|
|
140
140
|
}).filter(e => e.name);
|
|
141
|
-
})()`)))}async function
|
|
142
|
-
${
|
|
141
|
+
})()`)))}async function No(e,t){return ke(t,"recommendations","extractRecommendationsFromDetails",async()=>(await be(e,t,"recommendations"),await e.evaluate(`(() => {
|
|
142
|
+
${ve}
|
|
143
143
|
|
|
144
144
|
const main = document.querySelector('main');
|
|
145
145
|
if (!main) return [];
|
|
@@ -174,7 +174,7 @@ var Mn=Object.defineProperty;var Y=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{f
|
|
|
174
174
|
if (e.recommenderTitle && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.recommenderTitle.trim())) return false;
|
|
175
175
|
return true;
|
|
176
176
|
});
|
|
177
|
-
})()`)))}var
|
|
177
|
+
})()`)))}var ve,cn=K(()=>{ye();ve=`
|
|
178
178
|
function findEntryContainer(root) {
|
|
179
179
|
const candidates = [];
|
|
180
180
|
for (const div of root.querySelectorAll('div')) {
|
|
@@ -237,58 +237,58 @@ function findEntryContainer(root) {
|
|
|
237
237
|
candidates.sort((a, b) => b.count - a.count || b.totalText - a.totalText);
|
|
238
238
|
return candidates[0]?.el;
|
|
239
239
|
}
|
|
240
|
-
`});var ln=Y(()=>{});import"dotenv/config";import*as N from"fs";import*as j from"path";import{fileURLToPath as Do}from"url";function Po(){N.existsSync(ne)||N.mkdirSync(ne,{recursive:!0})}function Fo(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";N.writeFileSync(o,n);for(let r=0;r<3;r++)try{N.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 He(e){try{if(N.existsSync(e))return JSON.parse(N.readFileSync(e,"utf-8"))}catch{}return null}function cn(){ve=null,qo=null,ke=null,Uo=null,te=null}function Mo(){return ve||(ve=He(No)||{},ve)}function Ie(){return ke||(ke=He(Lo)||{},ke)}function fe(){return te||(te=He(an)||{visits:[]},Array.isArray(te.visits)||(te.visits=[]),te)}function un(e,t={}){if(!e)return;Po();let n=fe();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{Fo(an,n)}catch(r){console.error(`[!] Failed to save visit-log.json: ${r.message}`)}}function dn(e){let t=fe();for(let n=t.visits.length-1;n>=0;n--)if(t.visits[n].profileUrl===e)return t.visits[n].date;return null}function fn(){let e=Mo(),t=Ie(),n=Object.values(e),o=Object.values(t),r={};for(let u of n)u.company&&(r[u.company]=(r[u.company]||0)+1);let s=Object.entries(r).sort((u,f)=>f[1]-u[1]).slice(0,5).map(([u,f])=>`${u} (${f})`),i={};for(let u of n)for(let f of u.techStack||[])i[f]=(i[f]||0)+1;let a=Object.entries(i).sort((u,f)=>f[1]-u[1]).slice(0,8).map(([u,f])=>`${u} (${f})`),l=fe(),d=new Date().toISOString().slice(0,10),c=l.visits.filter(u=>u.date.startsWith(d)).length,p=new Set(l.visits.map(u=>u.profileUrl)).size;return{totalJobs:n.length,totalRecruiters:o.length,topCompanies:s,topTech:a,totalVisited:p,todayVisited:c,lastScoutDate:n.length>0?n.sort((u,f)=>(f.scoutedAt||"").localeCompare(u.scoutedAt||""))[0]?.scoutedAt:null}}var Oo,jo,ne,No,Lo,an,Js,Ws,ve,qo,ke,Uo,te,Re=Y(()=>{ln();Oo=Do(import.meta.url),jo=j.dirname(j.dirname(Oo)),ne=process.env.DATA_DIR?j.resolve(process.env.DATA_DIR,"market-research"):j.join(jo,"market-research"),No=j.join(ne,"scouted-jobs.json"),Lo=j.join(ne,"discovered-people.json"),an=j.join(ne,"visit-log.json"),Js=j.join(ne,"companies.json"),Ws=j.join(ne,"job-decisions.json");ve=null;qo=null,ke=null;Uo=null,te=null});import so from"puppeteer";import{addExtra as io}from"puppeteer-extra";import lo from"puppeteer-extra-plugin-stealth";he();await Pe();Ee();Ee();import Fe from"fs";import Zn from"path";var eo={headless:!1,defaultViewport:null,protocolTimeout:3e5},ye=new Set,Lt=!1;async function _e(){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 to(){if(Lt)return;Lt=!0;let e=t=>async()=>{await _e(),process.exit(t)};process.once("SIGINT",e(130)),process.once("SIGTERM",e(143)),process.once("SIGHUP",e(129)),process.once("uncaughtException",async t=>{await _e(),console.error(t&&t.stack||t),process.exit(1)}),process.once("unhandledRejection",async t=>{await _e(),console.error(t),process.exit(1)}),process.stdout.on("error",async t=>{t&&t.code==="EPIPE"&&(await _e(),process.exit(0))}),process.on("exit",()=>{for(let t of ye)try{let n=t.process&&t.process();n&&n.kill("SIGKILL")}catch{}})}function Me(e){return Zn.join(e,".ilml-browser-session.json")}function qt(e,t={}){try{Fe.writeFileSync(Me(e),JSON.stringify({ownerPid:process.pid,startedAt:Date.now(),...t}))}catch{}}function no(e,t){try{let n=t.wsEndpoint&&t.wsEndpoint();qt(e,n?{wsEndpoint:n}:{})}catch{}}function oo(e){let t=Ut(e);t&&t.ownerPid===process.pid&&ge(e)}function ge(e){try{Fe.rmSync(Me(e),{force:!0})}catch{}}function Ut(e){try{return JSON.parse(Fe.readFileSync(Me(e),"utf-8"))}catch{return null}}function Pt(e){if(!e||e===process.pid)return!0;try{return process.kill(e,0),!0}catch(t){return!t||t.code!=="ESRCH"}}function Ft(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 Mt(e,t,{probeTimeoutMs:n=4e3}={}){let o=Ut(t);if(!o)return"free";if(!o.wsEndpoint)return o.ownerPid&&o.ownerPid!==process.pid&&Pt(o.ownerPid)?"live":(ge(t),"free");let r=Symbol("timeout"),s=e.connect({browserWSEndpoint:o.wsEndpoint,defaultViewport:null}).catch(()=>null),i=await Ft(s,n,r);if(i===r)return s.then(l=>{if(l)try{l.disconnect()}catch{}}),"live";if(!i)return ge(t),"free";if(Pt(o.ownerPid)){try{i.disconnect()}catch{}return"live"}if(console.log(" (recovered an orphaned automation browser from a previous run \u2014 closing it)"),await Ft(i.close().then(()=>!0).catch(()=>!1),n,!1))return ge(t),"free";try{i.disconnect()}catch{}return"live"}function ro(e,t){e&&(to(),ye.add(e),e.on("disconnected",()=>{ye.delete(e),t&&ge(t)}))}async function Bt(e,t={}){let n=xt(),o={...eo,...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 Mt(e,n)==="live")throw new Error(r);qt(n);let s;try{s=await e.launch(o)}catch{if(await Mt(e,n)==="live")throw new Error(r);$t(n);try{s=await e.launch(o)}catch(a){throw oo(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: ${a.message})`)}}return ro(s,n),no(n,s),{browser:s,profileDir:n,needsSeed:Et(n)}}async function Vt(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 Ht=io(so);Ht.use(lo());async function Jt(){let{browser:e,profileDir:t,needsSeed:n}=await Bt(Ht),o=await e.newPage();return await o.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})}),await Vt(o,{profileDir:t,needsSeed:n}),console.log(" Browser launched (persistent profile)."),{browser:e,page:o}}he();await $e();async function To(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 x(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function sn(e,t,n={}){let{extractExperience:o=!1,extractFeatured:r=!1,extractEducation:s=!1,extractSkills:i=!1,extractRecommendations:a=!1,extractCertifications:l=!1}=n;try{await ce(e,t,{readySelector:".scaffold-layout__main, main.scaffold-layout__main, .pv-top-card, section.pv-top-card",label:"profile"}),await x(1500),await Tt(e)&&(console.log(" Dismissed Premium overlay"),await x(1500),await To(e,t));let c=0;for(let E=0;E<2;E++){let Q=await e.evaluate(()=>document.body.scrollHeight);for(let W=1;W<=6;W++)await e.evaluate(O=>window.scrollTo(0,O),Q*W/6),await x(900);let X=await e.evaluate(()=>document.body.scrollHeight);if(X===c)break;c=X}await x(800);let p=null;try{let E=e.url();E&&/\/in\/[^/?#]/.test(E)&&(p=E.split("?")[0].replace(/\/+$/,""))}catch{}let u=await e.evaluate(()=>{let E=new Set(["Highlights","About","Activity","Experience","Education","Skills","Recommendations","Languages","Interests","Volunteer experience","Featured","Honors & awards","Honors and awards","Projects","Publications","Patents","Certifications","Licenses & certifications","Courses","Test scores","Organizations"]),Q=new Set(["Ad Options","Don\u2019t want to see this","0 notifications","Explore Premium profiles","You might like","People you may know","Suggested for you","More profiles for you","Promoted"]),X=h=>{let w=(h||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(w)},W={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:[]},O=document.querySelector("main");if(!O)return W;let v=[...Array.from(O.querySelectorAll("h1")),...Array.from(O.querySelectorAll("h2"))],I=Array.from(O.querySelectorAll("h2")),le=v.find(h=>{let w=h.textContent&&h.textContent.trim(),S=(w||"").replace(/\s*\(\d+\)$/,"").trim();return w&&w.length>1&&w.length<100&&!E.has(S)&&!Q.has(S)}),ae=le?le.textContent.trim():null,R=le?le.parentElement:null;for(;R&&R!==O&&!Array.from(R.children).filter(w=>w.tagName==="P").some(w=>{let S=w.textContent&&w.textContent.trim();return S&&S.length>5&&!X(S)});)R=R.parentElement;let it=null,lt=null,at=null,je=null;if(R&&R!==O){let h=Array.from(R.children).filter(S=>S.tagName==="P").filter(S=>{let G=S.textContent&&S.textContent.trim();return G&&G.length>5&&!X(G)});if(h[0]&&(it=h[0].textContent.trim()),h[1]){let S=h[1].textContent.trim().split(/\s*[·•]\s*/);lt=S[0]||null,S.length>1&&(at=S.slice(1).join(" \xB7 "))}let w=Array.from(R.children).filter(S=>S.tagName==="DIV");for(let S=w.length-1;S>=0;S--){let G=w[S].textContent&&w[S].textContent.trim();if(G&&!(ae&&G.startsWith(ae))&&(je=G.split(/[·•]/)[0].trim(),je))break}}let ct=null;if(R){let h=R.querySelectorAll("p, span, div");for(let w of h){let S=(w.textContent||"").trim().replace(/^[·•]\s*/,"");if(S==="1st"||S==="2nd"||S==="3rd"){ct=S;break}}}let Dn=!!O.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),ut=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),On=ut&&ut.src||null,xe=O.textContent||"",dt=null,ft=xe.match(/(\d+\+?)\s+connections\b/i);ft&&(dt=ft[1]+" connections");let Ae=null,mt=xe.match(/(\d+)\s+mutual connection/i),pt=xe.match(/and\s+(\d+)\s+other mutual/i),jn=xe.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);mt?Ae=parseInt(mt[1],10):pt?Ae=2+parseInt(pt[1],10):jn&&(Ae=2);let ht=null,gt=null,yt=I.find(h=>h.textContent&&h.textContent.trim()==="About");if(yt){let h=yt.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let w=(h.textContent||"").trim();w=w.replace(/^About\s*/,"").trim();let S=w.match(/Top skills\s*(.+?)$/i);if(S){let Ne=S[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Fn=>Fn.trim()).filter(Boolean);Ne.length>0&&Ne.length<10&&(gt=Ne)}w=w.split(/\n?…\s*more/i)[0].trim(),w=w.split(/\n?\.\.\.\s*more/i)[0].trim(),w=w.split(/\bTop skills\b/i)[0].trim(),w=w.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),ht=w||null}}let wt=null,St=I.find(h=>h.textContent&&h.textContent.trim()==="Activity");if(St){let h=St.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let w=(h.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);w&&(wt=parseInt(w[1].replace(/,/g,""),10))}}let Nn=[...new Set(I.map(h=>(h.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(h=>h&&h.length>1&&h.length<60&&h!==ae).filter(h=>E.has(h)))],me=document.body.textContent||"",Ln=/#OpenToWork\b/i.test(me)||/\bOpen to work\b/.test(me),Pn=/#Hiring\b/i.test(me)||/\bI'?m hiring\b/i.test(me)||/\bWe are hiring\b/i.test(me);return{name:ae,title:it,location:je,currentCompany:lt,currentSchool:at,connectionDegree:ct,hasVerifiedBadge:Dn,photoUrl:On,connectionsLevel:dt,mutualConnectionsCount:Ae,followers:wt,openToWork:Ln,hiring:Pn,about:ht,topSkills:gt,availableSections:Nn}});console.log(`Viewed: ${u.name} - ${u.title}`);let f=null,C=null,b=null,$=null,y=null,g=null;if(o||r||s||i||a||l){let E=await Promise.resolve().then(()=>(rn(),on));o&&(f=await E.extractExperienceFromDetails(e,t),console.log(` + Experience: ${f.length} entries`)),r&&(C=await E.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${C.length} entries`)),s&&(b=await E.extractEducationFromDetails(e,t),console.log(` + Education: ${b.length} entries`)),i&&($=await E.extractSkillsFromDetails(e,t),console.log(` + Skills: ${$.length} entries`)),a&&(y=await E.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${y.length} entries`)),l&&(g=await E.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${g.length} entries`))}return{...u,profileUrl:t,resolvedUrl:p,...f!==null&&{experience:f},...C!==null&&{featured:C},...b!==null&&{education:b},...$!==null&&{skillsFull:$},...y!==null&&{recommendations:y},...g!==null&&{certifications:g}}}catch(d){console.error(`Error viewing profile ${t}:`,d.message);try{await e.goto("about:blank",{timeout:1e4}),await x(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(d.message||""))throw d;return null}}Re();await $e();he();async function mn(e,t,n={}){let{maxVisits:o=10,delayBetween:r=4e3,skipRecentDays:s=7,verbose:i=!1,extractExperience:a=!1}=n,l={visited:0,skipped:0,errors:0},d=Date.now()-s*24*60*60*1e3;for(let c of t){if(l.visited>=o)break;if(!c.profileUrl)continue;let p=dn(c.profileUrl);if(p&&new Date(p).getTime()>d){l.skipped++;continue}try{let u=await sn(e,c.profileUrl,{extractExperience:a}),f=c.source||"visit";if(u){let b={...u,source:f};a&&Array.isArray(u.experience)&&u.experience.length>0&&(b._lastEnrichedAt=new Date().toISOString()),Be(c.profileUrl,b),u.resolvedUrl&&Ve(c.profileUrl,u.resolvedUrl)}un(c.profileUrl,{name:u?.name||c.name||null,source:f}),l.visited++,i?console.log(` [${l.visited}] ${u?.name||c.profileUrl} \u2014 ${u?.title?.slice(0,40)||"?"}`):l.visited%10===0&&console.log(` Visited: ${l.visited}`);let C=Math.random()*4e3;await x(r+C)}catch(u){l.errors++,i&&console.error(` Error visiting ${c.name||c.profileUrl}: ${u.message?.slice(0,60)}`);let f=(u.message||"").toLowerCase();if(f.includes("detached")||f.includes("session closed")||f.includes("target closed")||f.includes("session expired")||f.includes("bounced to")||f.includes("authwall")||f.includes("checkpoint")||f.includes("redirected to login")){console.log(" Fatal browser/session error \u2014 stopping visits");break}}}return l}function pn(e={}){let{limit:t=150,revisitDays:n=14}=e,o=fe(),r=new Set(o.visits?.map(y=>y.profileUrl)||[]),s=new Map;for(let y of o.visits||[]){let g=s.get(y.profileUrl);(!g||y.date>g)&&s.set(y.profileUrl,y.date)}let i=Date.now()-7*24*60*60*1e3,a=Date.now()-n*24*60*60*1e3;function l(y){let g=s.get(y);return g&&new Date(g).getTime()>i}let d=Ie(),c=Object.entries(d).filter(([y])=>!r.has(y)).map(([y,g])=>({profileUrl:y,name:g.name,source:"new-discovered",priority:1,jobCount:g.jobIds?.length||0})),p=de(),u=Object.entries(p).filter(([y,g])=>g.connectionStatus==="connected"||l(y)?!1:(g.jobCount||g.jobIds?.length||0)>=2).map(([y,g])=>({profileUrl:y,name:g.name,source:"active-recruiter",priority:2,jobCount:g.jobCount||g.jobIds?.length||0})),f=Object.entries(p).filter(([y,g])=>{let B=g.connectionStatus;return!(!B||B==="connected"||B==="pending"||B==="sent_without_note"||B==="sent_with_note"||l(y)||(g.jobCount||g.jobIds?.length||0)>=2)}).map(([y,g])=>({profileUrl:y,name:g.name,source:"unconnected",priority:3,jobCount:g.jobCount||g.jobIds?.length||0})),C=[...s.entries()].filter(([y,g])=>new Date(g).getTime()<a).map(([y,g])=>({profileUrl:y,name:null,source:"revisit",priority:4,lastVisit:g})),b=y=>y.sort(()=>Math.random()-.5);return c.sort((y,g)=>g.jobCount-y.jobCount),u.sort((y,g)=>g.jobCount-y.jobCount),b(f),b(C),[...c,...u,...f,...C].slice(0,t)}function hn(){let e=Ie();return Object.entries(e).map(([t,n])=>({profileUrl:t,name:n.name,source:"discovered"}))}function Je(){let e=de();return Object.entries(e).filter(([,t])=>{let n=t.connectionStatus;return n&&n!=="connected"&&n!=="pending"&&n!=="sent_without_note"&&n!=="sent_with_note"}).map(([t,n])=>({profileUrl:t,name:n.name,source:"unconnected"}))}function We(e=14){let t=fe(),n=Date.now()-e*24*60*60*1e3,o=new Map;for(let r of t.visits){let s=o.get(r.profileUrl);(!s||r.date>s.date)&&o.set(r.profileUrl,r)}return[...o.entries()].filter(([,r])=>new Date(r.date).getTime()<n).map(([r,s])=>({profileUrl:r,name:s.name,source:"revisit"}))}Re();import"dotenv/config";import*as L from"fs";import*as K from"path";import{fileURLToPath as Ko}from"url";import"dotenv/config";import{createGraphClient as Bo,resolveToken as Vo}from"@ilivemylife/graph-sdk";import{config as Ho}from"dotenv";Ho();var gn=Vo()||process.env.TOKEN;gn||(console.error(`
|
|
240
|
+
`});var dn=K(()=>{});import"dotenv/config";import*as N from"fs";import*as j from"path";import{fileURLToPath as Po}from"url";function Bo(){N.existsSync(oe)||N.mkdirSync(oe,{recursive:!0})}function Vo(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";N.writeFileSync(o,n);for(let r=0;r<3;r++)try{N.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 Ge(e){try{if(N.existsSync(e))return JSON.parse(N.readFileSync(e,"utf-8"))}catch{}return null}function mn(){Ce=null,Jo=null,xe=null,Wo=null,ne=null}function Ho(){return Ce||(Ce=Ge(qo)||{},Ce)}function De(){return xe||(xe=Ge(Uo)||{},xe)}function he(){return ne||(ne=Ge(fn)||{visits:[]},Array.isArray(ne.visits)||(ne.visits=[]),ne)}function pn(e,t={}){if(!e)return;Bo();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(fn,n)}catch(r){console.error(`[!] Failed to save visit-log.json: ${r.message}`)}}function hn(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}function gn(){let e=Ho(),t=De(),n=Object.values(e),o=Object.values(t),r={};for(let d of n)d.company&&(r[d.company]=(r[d.company]||0)+1);let s=Object.entries(r).sort((d,f)=>f[1]-d[1]).slice(0,5).map(([d,f])=>`${d} (${f})`),i={};for(let d of n)for(let f of d.techStack||[])i[f]=(i[f]||0)+1;let a=Object.entries(i).sort((d,f)=>f[1]-d[1]).slice(0,8).map(([d,f])=>`${d} (${f})`),l=he(),u=new Date().toISOString().slice(0,10),c=l.visits.filter(d=>d.date.startsWith(u)).length,p=new Set(l.visits.map(d=>d.profileUrl)).size;return{totalJobs:n.length,totalRecruiters:o.length,topCompanies:s,topTech:a,totalVisited:p,todayVisited:c,lastScoutDate:n.length>0?n.sort((d,f)=>(f.scoutedAt||"").localeCompare(d.scoutedAt||""))[0]?.scoutedAt:null}}var Fo,Mo,oe,qo,Uo,fn,ni,oi,Ce,Jo,xe,Wo,ne,Oe=K(()=>{dn();Fo=Po(import.meta.url),Mo=j.dirname(j.dirname(Fo)),oe=process.env.DATA_DIR?j.resolve(process.env.DATA_DIR,"market-research"):j.join(Mo,"market-research"),qo=j.join(oe,"scouted-jobs.json"),Uo=j.join(oe,"discovered-people.json"),fn=j.join(oe,"visit-log.json"),ni=j.join(oe,"companies.json"),oi=j.join(oe,"job-decisions.json");Ce=null;Jo=null,xe=null;Wo=null,ne=null});import uo from"puppeteer";import{addExtra as fo}from"puppeteer-extra";import mo from"puppeteer-extra-plugin-stealth";ye();await qe();Ie();Ie();import Ue from"fs";import ro from"path";var so={headless:!1,defaultViewport:null,protocolTimeout:3e5},Se=new Set,qt=!1;async function Re(){let e=[...Se].map(t=>{try{return Promise.resolve(t.close()).catch(()=>{})}catch{return Promise.resolve()}});Se.clear(),await Promise.race([Promise.all(e),new Promise(t=>setTimeout(t,5e3))])}function io(){if(qt)return;qt=!0;let e=t=>async()=>{await Re(),process.exit(t)};process.once("SIGINT",e(130)),process.once("SIGTERM",e(143)),process.once("SIGHUP",e(129)),process.once("uncaughtException",async t=>{await Re(),console.error(t&&t.stack||t),process.exit(1)}),process.once("unhandledRejection",async t=>{await Re(),console.error(t),process.exit(1)}),process.stdout.on("error",async t=>{t&&t.code==="EPIPE"&&(await Re(),process.exit(0))}),process.on("exit",()=>{for(let t of Se)try{let n=t.process&&t.process();n&&n.kill("SIGKILL")}catch{}})}function Be(e){return ro.join(e,".ilml-browser-session.json")}function Ht(e,t={}){try{Ue.writeFileSync(Be(e),JSON.stringify({ownerPid:process.pid,startedAt:Date.now(),...t}))}catch{}}function lo(e,t){try{let n=t.wsEndpoint&&t.wsEndpoint();Ht(e,n?{wsEndpoint:n}:{})}catch{}}function ao(e){let t=Jt(e);t&&t.ownerPid===process.pid&&we(e)}function we(e){try{Ue.rmSync(Be(e),{force:!0})}catch{}}function Jt(e){try{return JSON.parse(Ue.readFileSync(Be(e),"utf-8"))}catch{return null}}function Ut(e){if(!e||e===process.pid)return!0;try{return process.kill(e,0),!0}catch(t){return!t||t.code!=="ESRCH"}}function Bt(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 Vt(e,t,{probeTimeoutMs:n=4e3}={}){let o=Jt(t);if(!o)return"free";if(!o.wsEndpoint)return o.ownerPid&&o.ownerPid!==process.pid&&Ut(o.ownerPid)?"live":(we(t),"free");let r=Symbol("timeout"),s=e.connect({browserWSEndpoint:o.wsEndpoint,defaultViewport:null}).catch(()=>null),i=await Bt(s,n,r);if(i===r)return s.then(l=>{if(l)try{l.disconnect()}catch{}}),"live";if(!i)return we(t),"free";if(Ut(o.ownerPid)){try{i.disconnect()}catch{}return"live"}if(console.log(" (recovered an orphaned automation browser from a previous run \u2014 closing it)"),await Bt(i.close().then(()=>!0).catch(()=>!1),n,!1))return we(t),"free";try{i.disconnect()}catch{}return"live"}function co(e,t){e&&(io(),Se.add(e),e.on("disconnected",()=>{Se.delete(e),t&&we(t)}))}async function Wt(e,t={}){let n=$t(),o={...so,...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 Vt(e,n)==="live")throw new Error(r);Ht(n);let s;try{s=await e.launch(o)}catch{if(await Vt(e,n)==="live")throw new Error(r);Dt(n);try{s=await e.launch(o)}catch(a){throw ao(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: ${a.message})`)}}return co(s,n),lo(n,s),{browser:s,profileDir:n,needsSeed:Rt(n)}}async function Gt(e,t){if(!t||!t.needsSeed)return!1;if(!Et())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(...At()),Tt(t.profileDir),console.log(" (seeded persistent profile from saved cookies \u2014 one-time)"),!0}catch{return!1}}var Yt=fo(uo);Yt.use(mo());async function Kt(){let{browser:e,profileDir:t,needsSeed:n}=await Wt(Yt),o=await e.newPage();return await o.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})}),await Gt(o,{profileDir:t,needsSeed:n}),console.log(" Browser launched (persistent profile)."),{browser:e,page:o}}ye();await Te();async function Lo(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 x(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function un(e,t,n={}){let{extractExperience:o=!1,extractFeatured:r=!1,extractEducation:s=!1,extractSkills:i=!1,extractRecommendations:a=!1,extractCertifications:l=!1}=n;try{await fe(e,t,{readySelector:".scaffold-layout__main, main.scaffold-layout__main, .pv-top-card, section.pv-top-card",label:"profile"}),await x(1500),await Nt(e)&&(console.log(" Dismissed Premium overlay"),await x(1500),await Lo(e,t));let c=0;for(let E=0;E<2;E++){let X=await e.evaluate(()=>document.body.scrollHeight);for(let G=1;G<=6;G++)await e.evaluate(O=>window.scrollTo(0,O),X*G/6),await x(900);let Z=await e.evaluate(()=>document.body.scrollHeight);if(Z===c)break;c=Z}await x(800);let p=null;try{let E=e.url();E&&/\/in\/[^/?#]/.test(E)&&(p=E.split("?")[0].replace(/\/+$/,""))}catch{}let d=await e.evaluate(()=>{let E=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"]),X=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"]),Z=h=>{let w=(h||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(w)},G={name:null,title:null,location:null,currentCompany:null,currentSchool:null,connectionDegree:null,hasVerifiedBadge:!1,photoUrl:null,connectionsLevel:null,mutualConnectionsCount:null,followers:null,openToWork:!1,hiring:!1,about:null,topSkills:null,availableSections:[]},O=document.querySelector("main");if(!O)return G;let k=[...Array.from(O.querySelectorAll("h1")),...Array.from(O.querySelectorAll("h2"))],I=Array.from(O.querySelectorAll("h2")),ce=k.find(h=>{let w=h.textContent&&h.textContent.trim(),S=(w||"").replace(/\s*\(\d+\)$/,"").trim();return w&&w.length>1&&w.length<100&&!E.has(S)&&!X.has(S)}),ue=ce?ce.textContent.trim():null,R=ce?ce.parentElement:null;for(;R&&R!==O&&!Array.from(R.children).filter(w=>w.tagName==="P").some(w=>{let S=w.textContent&&w.textContent.trim();return S&&S.length>5&&!Z(S)});)R=R.parentElement;let ut=null,dt=null,ft=null,Pe=null;if(R&&R!==O){let h=Array.from(R.children).filter(S=>S.tagName==="P").filter(S=>{let Y=S.textContent&&S.textContent.trim();return Y&&Y.length>5&&!Z(Y)});if(h[0]&&(ut=h[0].textContent.trim()),h[1]){let S=h[1].textContent.trim().split(/\s*[·•]\s*/);dt=S[0]||null,S.length>1&&(ft=S.slice(1).join(" \xB7 "))}let w=Array.from(R.children).filter(S=>S.tagName==="DIV");for(let S=w.length-1;S>=0;S--){let Y=w[S].textContent&&w[S].textContent.trim();if(Y&&!(ue&&Y.startsWith(ue))&&(Pe=Y.split(/[·•]/)[0].trim(),Pe))break}}let mt=null;if(R){let h=R.querySelectorAll("p, span, div");for(let w of h){let S=(w.textContent||"").trim().replace(/^[·•]\s*/,"");if(S==="1st"||S==="2nd"||S==="3rd"){mt=S;break}}}let Pn=!!O.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),pt=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),Fn=pt&&pt.src||null,_e=O.textContent||"",ht=null,gt=_e.match(/(\d+\+?)\s+connections\b/i);gt&&(ht=gt[1]+" connections");let $e=null,yt=_e.match(/(\d+)\s+mutual connection/i),wt=_e.match(/and\s+(\d+)\s+other mutual/i),Mn=_e.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);yt?$e=parseInt(yt[1],10):wt?$e=2+parseInt(wt[1],10):Mn&&($e=2);let St=null,bt=null,vt=I.find(h=>h.textContent&&h.textContent.trim()==="About");if(vt){let h=vt.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let w=(h.textContent||"").trim();w=w.replace(/^About\s*/,"").trim();let S=w.match(/Top skills\s*(.+?)$/i);if(S){let Fe=S[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Vn=>Vn.trim()).filter(Boolean);Fe.length>0&&Fe.length<10&&(bt=Fe)}w=w.split(/\n?…\s*more/i)[0].trim(),w=w.split(/\n?\.\.\.\s*more/i)[0].trim(),w=w.split(/\bTop skills\b/i)[0].trim(),w=w.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),St=w||null}}let kt=null,Ct=I.find(h=>h.textContent&&h.textContent.trim()==="Activity");if(Ct){let h=Ct.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let w=(h.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);w&&(kt=parseInt(w[1].replace(/,/g,""),10))}}let qn=[...new Set(I.map(h=>(h.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(h=>h&&h.length>1&&h.length<60&&h!==ue).filter(h=>E.has(h)))],ge=document.body.textContent||"",Un=/#OpenToWork\b/i.test(ge)||/\bOpen to work\b/.test(ge),Bn=/#Hiring\b/i.test(ge)||/\bI'?m hiring\b/i.test(ge)||/\bWe are hiring\b/i.test(ge);return{name:ue,title:ut,location:Pe,currentCompany:dt,currentSchool:ft,connectionDegree:mt,hasVerifiedBadge:Pn,photoUrl:Fn,connectionsLevel:ht,mutualConnectionsCount:$e,followers:kt,openToWork:Un,hiring:Bn,about:St,topSkills:bt,availableSections:qn}});console.log(`Viewed: ${d.name} - ${d.title}`);let f=null,b=null,v=null,$=null,y=null,g=null;if(o||r||s||i||a||l){let E=await Promise.resolve().then(()=>(cn(),an));o&&(f=await E.extractExperienceFromDetails(e,t),console.log(` + Experience: ${f.length} entries`)),r&&(b=await E.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${b.length} entries`)),s&&(v=await E.extractEducationFromDetails(e,t),console.log(` + Education: ${v.length} entries`)),i&&($=await E.extractSkillsFromDetails(e,t),console.log(` + Skills: ${$.length} entries`)),a&&(y=await E.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${y.length} entries`)),l&&(g=await E.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${g.length} entries`))}return{...d,profileUrl:t,resolvedUrl:p,...f!==null&&{experience:f},...b!==null&&{featured:b},...v!==null&&{education:v},...$!==null&&{skillsFull:$},...y!==null&&{recommendations:y},...g!==null&&{certifications:g}}}catch(u){console.error(`Error viewing profile ${t}:`,u.message);try{await e.goto("about:blank",{timeout:1e4}),await x(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(u.message||""))throw u;return null}}Oe();await Te();ye();async function yn(e,t,n={}){let{maxVisits:o=10,delayBetween:r=4e3,skipRecentDays:s=7,verbose:i=!1,extractExperience:a=!1}=n,l={visited:0,skipped:0,errors:0},u=Date.now()-s*24*60*60*1e3;for(let c of t){if(l.visited>=o)break;if(!c.profileUrl)continue;let p=hn(c.profileUrl);if(p&&new Date(p).getTime()>u){l.skipped++;continue}try{let d=await un(e,c.profileUrl,{extractExperience:a}),f=c.source||"visit";if(d){let v={...d,source:f};a&&Array.isArray(d.experience)&&d.experience.length>0&&(v._lastEnrichedAt=new Date().toISOString()),Je(c.profileUrl,v),d.resolvedUrl&&We(c.profileUrl,d.resolvedUrl)}pn(c.profileUrl,{name:d?.name||c.name||null,source:f}),l.visited++,i?console.log(` [${l.visited}] ${d?.name||c.profileUrl} \u2014 ${d?.title?.slice(0,40)||"?"}`):l.visited%10===0&&console.log(` Visited: ${l.visited}`);let b=Math.random()*4e3;await x(r+b)}catch(d){l.errors++,i&&console.error(` Error visiting ${c.name||c.profileUrl}: ${d.message?.slice(0,60)}`);let f=(d.message||"").toLowerCase();if(f.includes("detached")||f.includes("session closed")||f.includes("target closed")||f.includes("session expired")||f.includes("bounced to")||f.includes("authwall")||f.includes("checkpoint")||f.includes("redirected to login")){console.log(" Fatal browser/session error \u2014 stopping visits");break}}}return l}function wn(e={}){let{limit:t=150,revisitDays:n=14}=e,o=he(),r=new Set(o.visits?.map(y=>y.profileUrl)||[]),s=new Map;for(let y of o.visits||[]){let g=s.get(y.profileUrl);(!g||y.date>g)&&s.set(y.profileUrl,y.date)}let i=Date.now()-7*24*60*60*1e3,a=Date.now()-n*24*60*60*1e3;function l(y){let g=s.get(y);return g&&new Date(g).getTime()>i}let u=De(),c=Object.entries(u).filter(([y])=>!r.has(y)).map(([y,g])=>({profileUrl:y,name:g.name,source:"new-discovered",priority:1,jobCount:g.jobIds?.length||0})),p=pe(),d=Object.entries(p).filter(([y,g])=>g.connectionStatus==="connected"||l(y)?!1:(g.jobCount||g.jobIds?.length||0)>=2).map(([y,g])=>({profileUrl:y,name:g.name,source:"active-recruiter",priority:2,jobCount:g.jobCount||g.jobIds?.length||0})),f=Object.entries(p).filter(([y,g])=>{let V=g.connectionStatus;return!(!V||V==="connected"||V==="pending"||V==="sent_without_note"||V==="sent_with_note"||l(y)||(g.jobCount||g.jobIds?.length||0)>=2)}).map(([y,g])=>({profileUrl:y,name:g.name,source:"unconnected",priority:3,jobCount:g.jobCount||g.jobIds?.length||0})),b=[...s.entries()].filter(([y,g])=>new Date(g).getTime()<a).map(([y,g])=>({profileUrl:y,name:null,source:"revisit",priority:4,lastVisit:g})),v=y=>y.sort(()=>Math.random()-.5);return c.sort((y,g)=>g.jobCount-y.jobCount),d.sort((y,g)=>g.jobCount-y.jobCount),v(f),v(b),[...c,...d,...f,...b].slice(0,t)}function Sn(){let e=De();return Object.entries(e).map(([t,n])=>({profileUrl:t,name:n.name,source:"discovered"}))}function Ye(){let e=pe();return Object.entries(e).filter(([,t])=>{let n=t.connectionStatus;return n&&n!=="connected"&&n!=="pending"&&n!=="sent_without_note"&&n!=="sent_with_note"}).map(([t,n])=>({profileUrl:t,name:n.name,source:"unconnected"}))}function Ke(e=14){let t=he(),n=Date.now()-e*24*60*60*1e3,o=new Map;for(let r of t.visits){let s=o.get(r.profileUrl);(!s||r.date>s.date)&&o.set(r.profileUrl,r)}return[...o.entries()].filter(([,r])=>new Date(r.date).getTime()<n).map(([r,s])=>({profileUrl:r,name:s.name,source:"revisit"}))}Oe();import"dotenv/config";import*as L from"fs";import*as z from"path";import{fileURLToPath as er}from"url";import"dotenv/config";import{createGraphClient as Go,resolveToken as Yo}from"@ilivemylife/graph-sdk";import{config as Ko}from"dotenv";Ko();var bn=Yo()||process.env.TOKEN;bn||(console.error(`
|
|
241
241
|
[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.
|
|
242
242
|
`),console.error(" Easiest way:"),console.error(" 1. npm install -g @ilivemylife/graph-sdk"),console.error(` 2. ilml login your@email.com yourpassword
|
|
243
243
|
`),console.error(` Or add ILML_TOKEN=... to .env
|
|
244
|
-
`),process.exit(1));var
|
|
245
|
-
`)}async function
|
|
246
|
-
\u2717 ${e}${p} failed: ${l.message||l}`)}let c=Date.now()-i.startTime;try{er(i,l?"error":"success",{...a,summaryLines:d,__deferReport:!0},l?l.message||String(l):null)}catch(p){console.error(`[runLog] endRun failed: ${p.message}`)}if(d.length>0&&process.env.NODE_RUN_REPORTS){let p=l?"error":a.dailyLimitHit?"quota-reached":"done";try{await Ge({scriptName:i.script,mode:i.mode,status:p,summaryLines:d,error:l?l.message||String(l):null,duration:c})}catch(u){console.error(`[runLog] report post failed: ${u.message}`)}}if(l&&s)throw l;return a}import"dotenv/config";import*as m from"fs";import*as ot from"os";import*as k from"path";import{fileURLToPath as xr}from"url";var Xe={};pe(Xe,{NAME:()=>nr,VERSION:()=>tr,up:()=>sr});import*as P from"fs";import*as Te from"path";var tr=1,nr="normalize-jobs-and-questions",or=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],rr=50;function ze(e){return P.existsSync(e)?JSON.parse(P.readFileSync(e,"utf-8")):null}function Qe(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{P.writeFileSync(o,n)}catch(r){try{P.unlinkSync(o)}catch{}throw r}try{P.renameSync(o,e)}catch(r){try{P.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 sr(e,t){let n=Te.join(e,"jobs.json"),o=Te.join(t,"scouted-jobs.json"),r=Te.join(e,"application-questions.json"),s=ze(n)||{},i=ze(o)||{},a=0,l=[];for(let c of Object.keys(s)){if(!i[c])continue;let p=i[c],u=s[c];for(let f of or)p[f]!=null&&u[f]==null&&(u[f]=p[f]);l.push(c),a++}a>0?(Qe(n,s),console.log(` Phase 1: Merged ${a} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let d=ze(r);if(d&&Array.isArray(d.applications)){let c={},p=0;for(let u of d.applications){let f=u.jobId||"unknown";c[f]||(c[f]={applications:[]});let C=(u.questions||[]).map(b=>{let $={type:b.type||"input",question:b.question||"",answer:b.answer||""};return b.options&&(b.options.length<=rr?$.options=b.options:($.optionsOmitted=!0,p++)),b.page&&($.page=b.page),b.wasPreFilled&&($.wasPreFilled=!0),b.wasRetry&&($.wasRetry=!0),$});c[f].applications.push({applicationId:u.applicationId,date:u.date,result:u.result||"submitted",formPages:u.formPages||null,duration:u.duration||null,retries:u.retries||0,failedField:u.failedField||null,questionCount:u.questionCount||C.length,questions:C})}Qe(r,c),console.log(` Phase 2: Rekeyed ${d.applications.length} applications by jobId (${Object.keys(c).length} unique jobs)`),p>0&&console.log(` Phase 2: Stripped bloated options from ${p} 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(l.length>0){for(let c of l)delete i[c];Qe(o,i),console.log(` Phase 3: Removed ${l.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:()=>lr,VERSION:()=>ir,up:()=>ur});import*as F from"fs";import*as vn from"path";var ir=2,lr="reset-unread-flags";function ar(e){return F.existsSync(e)?JSON.parse(F.readFileSync(e,"utf-8")):null}function cr(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 ur(e){let t=vn.join(e,"conversations.json"),n=ar(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}cr(t,n),console.log(` Reset unread=false on ${o} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var et={};pe(et,{NAME:()=>fr,VERSION:()=>dr,up:()=>yr});import*as M from"fs";import*as kn from"path";var dr=3,fr="recompute-last-message-by",mr=new Set(["draft","confirmed","rejected","needs_review"]);function pr(e){return M.existsSync(e)?JSON.parse(M.readFileSync(e,"utf-8")):null}function hr(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{M.writeFileSync(o,n)}catch(r){try{M.unlinkSync(o)}catch{}throw r}try{M.renameSync(o,e)}catch(r){try{M.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 gr(e,t){if(!e||e.length===0)return"them";let n=e.filter(s=>!mr.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 yr(e){let t=kn.join(e,"conversations.json"),n=pr(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 a of Object.keys(n)){let l=n[a];if(!l||typeof l!="object")continue;Object.prototype.hasOwnProperty.call(l,"_cardSynced")&&(delete l._cardSynced,s++);let d=Array.isArray(l.messages)?l.messages:[],c=gr(d,o),p=c==="me"?"awaiting_reply":"unanswered_by_us";l.lastMessageBy!==c&&i++,l.lastMessageBy=c,l.conversationStatus=p,r++}if(r===0){console.log(" No conversations to recompute.");return}hr(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 tt={};pe(tt,{NAME:()=>Sr,VERSION:()=>wr,up:()=>Cr});import*as q from"fs";import*as Cn from"path";var wr=4,Sr="split-connection-timestamps",br=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function vr(e){if(!q.existsSync(e))return null;let t=q.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function kr(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{q.writeFileSync(o,n)}catch(r){try{q.unlinkSync(o)}catch{}throw r}try{q.renameSync(o,e)}catch(r){try{q.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 Cr(e){let t=Cn.join(e,"people.json"),n=vr(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++,br.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}kr(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 $e();Re();var Ar=xr(import.meta.url),Er=k.dirname(Ar),_r=k.dirname(k.dirname(Er));function $r(e){return e&&(e==="~"?ot.homedir():e.startsWith("~/")||e.startsWith("~\\")?k.join(ot.homedir(),e.slice(2)):e)}var U=process.env.DATA_DIR?k.resolve($r(process.env.DATA_DIR)):_r,re=k.join(U,"collected-profiles"),se=k.join(U,"market-research"),D=k.join(U,".schema-version"),xn=[k.join(re,".schema-version"),k.join(se,".schema-version")],z=4,J=[{version:1,module:Xe},{version:2,module:Ze},{version:3,module:et},{version:4,module:tt}];(function(){J.sort((o,r)=>o.version-r.version);let t=new Set;for(let o of J){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=J.length?J[J.length-1].version:0;if(n!==z)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${z}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let o=0;o<J.length;o++){let r=o+1;if(J[o].version!==r)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${r} at position ${o} but found v${J[o].version}`)}})();function $n(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
244
|
+
`),process.exit(1));var vn=Go({token:bn});function zo(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`}var Qo={apply:"Job apply","apply-queue":"Job apply (queue)",scout:"Job scout",connect:"Connect run",funnel:"Recruiter funnel",messages:"Messages",sync:"Connections sync","sync-all":"Inbox sync",visit:"Profile visits",viewers:"Profile viewers",daily:"Daily run"};function Xo(e){let t=String(e||"").toLowerCase();return/authwall|session expired|not logged in|re-?auth|logged out|sign ?in/.test(t)?"LinkedIn asked to sign in again. Run `ilml linkedin login`, then run this again.":/protocoltimeout|callfunctionon|target closed|session closed|detached|execution context|browser.*disconnected|connection closed/.test(t)?"The browser stopped responding partway through. This is usually temporary \u2014 just run it again.":/err_aborted|err_network|err_connection|err_name_not_resolved|net::/.test(t)?"A page failed to load (network hiccup). Try running it again in a moment.":/navigation timeout|timeout.*exceeded|waiting for selector|waiting for/.test(t)?"A page took too long to load. Try again in a moment.":/invite limit|weekly.*limit|too many|rate.?limit|quota/.test(t)?"You've reached a LinkedIn sending limit for now. Wait a while, then try again.":"Something went wrong partway through. It is safe to run the command again."}function Zo({scriptName:e,mode:t,status:n,summaryLines:o,error:r,stoppedReason:s,duration:i}){let a=n==="error"||n==="stopped"?n==="error"?"\u2717":"\u26A0":n==="quota-reached"?"\u26A0":"\u2713",l=n==="error"?"stopped early":n==="stopped"?`stopped \u2014 ${s||"did not finish"}`:n==="quota-reached"?"daily limit reached":"done",u=Qo[e]||e,c=t&&t!=="default"?` \xB7 ${t}`:"",p=new Date().toISOString().slice(0,16).replace("T"," "),d=i?` \xB7 ${zo(i)}`:"",f=[];f.push(`## ${a} ${u} \u2014 ${l}`),f.push(`_${p}${c}${d}_`),f.push("");for(let b of o)f.push(`- ${b}`);if(n==="error"){f.push(""),f.push(`**What happened:** ${Xo(r)}`);let b=String(r||"").replace(/\s+/g," ").trim();b&&f.push(`_Technical detail: ${b.slice(0,140)}_`)}return f.join(`
|
|
245
|
+
`)}async function ze({scriptName:e,mode:t,status:n,summaryLines:o,error:r,stoppedReason:s,duration:i}){let a=process.env.NODE_RUN_REPORTS;if(!a||!Array.isArray(o)||o.length===0)return;let l=Zo({scriptName:e,mode:t,status:n,summaryLines:o,error:r,stoppedReason:s,duration:i});try{await vn.addMessage(a,l)}catch(u){console.error(`[runReport] Failed to post end-of-session message: ${u.message}`)}}var tr=er(import.meta.url),nr=z.dirname(z.dirname(tr)),Qe=process.env.DATA_DIR?z.resolve(process.env.DATA_DIR,"collected-profiles"):z.join(nr,"collected-profiles"),Xe=z.join(Qe,"run-log.json");function or(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";L.writeFileSync(o,n);for(let r=0;r<3;r++)try{L.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 kn(){try{if(!L.existsSync(Xe))return{runs:[]};let e=JSON.parse(L.readFileSync(Xe,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function Cn(e){L.existsSync(Qe)||L.mkdirSync(Qe,{recursive:!0});try{or(Xe,e)}catch(t){console.error(`[!] Failed to save run-log.json: ${t.message}`)}}function rr(e,t="default"){let n=kn();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 sr(e,t,n=null,o=null){if(!e)return;let r=null;try{let a=kn(),l=a.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 u=a.runs.find(c=>c.script===e.script&&c.status==="running"&&c.timestamp===new Date(e.startTime).toISOString());u&&(u.status=t,u.result=t,u.duration=Date.now()-e.startTime,u.stats=n,u.error=o,r=u.duration)}Cn(a)}catch(a){console.error(`[runLog] Failed to end run: ${a.message}`)}let s=n&&Array.isArray(n.summaryLines)?n.summaryLines:null,i=n&&n.__deferReport===!0;if(s&&s.length>0&&process.env.NODE_RUN_REPORTS&&!i){let a=t==="error"?"error":n&&n.dailyLimitHit?"quota-reached":"done";ze({scriptName:e.script,mode:e.mode,status:a,summaryLines:s,error:o,duration:r??Date.now()-e.startTime}).catch(l=>console.error(`[runLog] postRunReport failed: ${l.message}`))}}async function xn(e,t,n,o,r={}){let{rethrow:s=!0}=r,i=rr(e,t),a={},l=null;try{await n(a)}catch(d){l=d}let u=[];try{let d=o?o(a):[];u=(Array.isArray(d)?d:[]).filter(f=>typeof f=="string"&&f.trim())}catch(d){console.error(`[runLog] summarize threw (report still sent): ${d.message}`)}if(u.length===0&&l&&(u=["(crashed before any progress was recorded)"]),l){let d=t&&t!=="default"?` (${t})`:"";console.error(`
|
|
246
|
+
\u2717 ${e}${d} failed: ${l.message||l}`)}let c=Date.now()-i.startTime,p=!l&&a.stoppedReason?String(a.stoppedReason):null;try{sr(i,l?"error":p?"partial":"success",{...a,summaryLines:u,__deferReport:!0},l?l.message||String(l):null)}catch(d){console.error(`[runLog] endRun failed: ${d.message}`)}if(u.length>0&&process.env.NODE_RUN_REPORTS){let d=l?"error":p?"stopped":a.dailyLimitHit?"quota-reached":"done";try{await ze({scriptName:i.script,mode:i.mode,status:d,summaryLines:u,error:l?l.message||String(l):null,stoppedReason:p,duration:c})}catch(f){console.error(`[runLog] report post failed: ${f.message}`)}}if(l&&s)throw l;return a}import"dotenv/config";import*as m from"fs";import*as lt from"os";import*as C from"path";import{fileURLToPath as Nr}from"url";var tt={};de(tt,{NAME:()=>lr,VERSION:()=>ir,up:()=>ur});import*as P from"fs";import*as je from"path";var ir=1,lr="normalize-jobs-and-questions",ar=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],cr=50;function Ze(e){return P.existsSync(e)?JSON.parse(P.readFileSync(e,"utf-8")):null}function et(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{P.writeFileSync(o,n)}catch(r){try{P.unlinkSync(o)}catch{}throw r}try{P.renameSync(o,e)}catch(r){try{P.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 ur(e,t){let n=je.join(e,"jobs.json"),o=je.join(t,"scouted-jobs.json"),r=je.join(e,"application-questions.json"),s=Ze(n)||{},i=Ze(o)||{},a=0,l=[];for(let c of Object.keys(s)){if(!i[c])continue;let p=i[c],d=s[c];for(let f of ar)p[f]!=null&&d[f]==null&&(d[f]=p[f]);l.push(c),a++}a>0?(et(n,s),console.log(` Phase 1: Merged ${a} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let u=Ze(r);if(u&&Array.isArray(u.applications)){let c={},p=0;for(let d of u.applications){let f=d.jobId||"unknown";c[f]||(c[f]={applications:[]});let b=(d.questions||[]).map(v=>{let $={type:v.type||"input",question:v.question||"",answer:v.answer||""};return v.options&&(v.options.length<=cr?$.options=v.options:($.optionsOmitted=!0,p++)),v.page&&($.page=v.page),v.wasPreFilled&&($.wasPreFilled=!0),v.wasRetry&&($.wasRetry=!0),$});c[f].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||b.length,questions:b})}et(r,c),console.log(` Phase 2: Rekeyed ${u.applications.length} applications by jobId (${Object.keys(c).length} unique jobs)`),p>0&&console.log(` Phase 2: Stripped bloated options from ${p} questions`)}else u&&!u.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(l.length>0){for(let c of l)delete i[c];et(o,i),console.log(` Phase 3: Removed ${l.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 nt={};de(nt,{NAME:()=>fr,VERSION:()=>dr,up:()=>hr});import*as F from"fs";import*as An from"path";var dr=2,fr="reset-unread-flags";function mr(e){return F.existsSync(e)?JSON.parse(F.readFileSync(e,"utf-8")):null}function pr(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 hr(e){let t=An.join(e,"conversations.json"),n=mr(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}pr(t,n),console.log(` Reset unread=false on ${o} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var ot={};de(ot,{NAME:()=>yr,VERSION:()=>gr,up:()=>kr});import*as M from"fs";import*as En from"path";var gr=3,yr="recompute-last-message-by",wr=new Set(["draft","confirmed","rejected","needs_review"]);function Sr(e){return M.existsSync(e)?JSON.parse(M.readFileSync(e,"utf-8")):null}function br(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{M.writeFileSync(o,n)}catch(r){try{M.unlinkSync(o)}catch{}throw r}try{M.renameSync(o,e)}catch(r){try{M.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 vr(e,t){if(!e||e.length===0)return"them";let n=e.filter(s=>!wr.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 kr(e){let t=En.join(e,"conversations.json"),n=Sr(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 a of Object.keys(n)){let l=n[a];if(!l||typeof l!="object")continue;Object.prototype.hasOwnProperty.call(l,"_cardSynced")&&(delete l._cardSynced,s++);let u=Array.isArray(l.messages)?l.messages:[],c=vr(u,o),p=c==="me"?"awaiting_reply":"unanswered_by_us";l.lastMessageBy!==c&&i++,l.lastMessageBy=c,l.conversationStatus=p,r++}if(r===0){console.log(" No conversations to recompute.");return}br(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 rt={};de(rt,{NAME:()=>xr,VERSION:()=>Cr,up:()=>$r});import*as q from"fs";import*as _n from"path";var Cr=4,xr="split-connection-timestamps",Ar=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function Er(e){if(!q.existsSync(e))return null;let t=q.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function _r(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{q.writeFileSync(o,n)}catch(r){try{q.unlinkSync(o)}catch{}throw r}try{q.renameSync(o,e)}catch(r){try{q.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 $r(e){let t=_n.join(e,"people.json"),n=Er(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++,Ar.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}_r(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".')}var st={};de(st,{NAME:()=>Rr,VERSION:()=>Ir,up:()=>jr});import*as U from"fs";import*as $n from"path";var Ir=5,Rr="rename-headline-to-title",re=/[·•]\s*(1st|2nd|3rd)\+?/i,Tr=e=>(e||"").replace(/\s+/g," ").trim(),Ae=e=>Tr(e).replace(/^[+·•\s]+/,"").replace(/[·•\s]+$/,"");function Dr(e){if(!U.existsSync(e))return null;let t=U.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),o=e+".tmp";try{U.writeFileSync(o,n)}catch(r){try{U.unlinkSync(o)}catch{}throw r}try{U.renameSync(o,e)}catch(r){try{U.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 jr(e,t){let n=$n.join(t,"discovered-people.json"),o=Dr(n);if(!o||typeof o!="object"){console.log(" discovered-people.json not found \u2014 nothing to migrate.");return}let r=Array.isArray(o)?o:Object.values(o),s=0,i=0,a=0;for(let l of r)if(!(!l||typeof l!="object")){if(s++,l.name&&re.test(l.name)){let u=Ae(String(l.name).split(re)[0]),c=String(l.name).match(/[·•]\s*(?:1st|2nd|3rd)\+?\s*(.+)$/i),p=c?Ae(c[1]):"";u&&(l.name=u,i++),p&&(!l.headline||re.test(String(l.headline))||!Ae(l.headline))&&(l.headline=p)}if(Object.prototype.hasOwnProperty.call(l,"headline")){let u=Ae(l.headline||"");re.test(u)&&(u=""),(!l.title||re.test(String(l.title)))&&(l.title=u||(l.title&&!re.test(String(l.title))?l.title:null)||null),delete l.headline,a++}else if(typeof l.title=="string"){let u=Ae(l.title);u&&!re.test(u)&&u!==l.title&&(l.title=u)}}if(a===0&&i===0){console.log(` Scanned ${s} discovered people \u2014 already unified (no headline field, clean names).`);return}Or(n,o),console.log(` discovered-people.json: scanned ${s}, de-glued ${i} names, moved ${a} headline\u2192title.`),console.log(" Every record now carries a single `title` field (matches people.json).")}await Te();Oe();var Lr=Nr(import.meta.url),Pr=C.dirname(Lr),Fr=C.dirname(C.dirname(Pr));function Mr(e){return e&&(e==="~"?lt.homedir():e.startsWith("~/")||e.startsWith("~\\")?C.join(lt.homedir(),e.slice(2)):e)}var B=process.env.DATA_DIR?C.resolve(Mr(process.env.DATA_DIR)):Fr,ie=C.join(B,"collected-profiles"),le=C.join(B,"market-research"),D=C.join(B,".schema-version"),In=[C.join(ie,".schema-version"),C.join(le,".schema-version")],Q=5,W=[{version:1,module:tt},{version:2,module:nt},{version:3,module:ot},{version:4,module:rt},{version:5,module:st}];(function(){W.sort((o,r)=>o.version-r.version);let t=new Set;for(let o of W){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=W.length?W[W.length-1].version:0;if(n!==Q)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${Q}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let o=0;o<W.length;o++){let r=o+1;if(W[o].version!==r)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${r} at position ${o} but found v${W[o].version}`)}})();function On(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
247
247
|
[FATAL] DATA_DIR is set to whitespace ("${process.env.DATA_DIR}"). Either unset it or set a real path.
|
|
248
|
-
`),process.exit(1));try{m.mkdirSync(
|
|
249
|
-
[FATAL] Cannot create DATA_DIR (${
|
|
250
|
-
`),process.exit(1))}let e;try{e=m.statSync(
|
|
251
|
-
[FATAL] DATA_DIR (${
|
|
248
|
+
`),process.exit(1));try{m.mkdirSync(B,{recursive:!0})}catch(t){t.code!=="EEXIST"&&(console.error(`
|
|
249
|
+
[FATAL] Cannot create DATA_DIR (${B}): ${t.message}`),console.error(` Fix the path or permissions and try again.
|
|
250
|
+
`),process.exit(1))}let e;try{e=m.statSync(B)}catch(t){console.error(`
|
|
251
|
+
[FATAL] DATA_DIR (${B}) is not accessible: ${t.message}
|
|
252
252
|
`),process.exit(1)}e.isDirectory()||(console.error(`
|
|
253
|
-
[FATAL] DATA_DIR (${
|
|
254
|
-
`),process.exit(1));for(let t of[
|
|
253
|
+
[FATAL] DATA_DIR (${B}) 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.
|
|
254
|
+
`),process.exit(1));for(let t of[ie,le]){let n;try{n=m.lstatSync(t)}catch(o){if(o.code==="ENOENT")continue;throw o}n.isSymbolicLink()&&(console.error(`
|
|
255
255
|
[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.
|
|
256
|
-
`),process.exit(1))}}var
|
|
257
|
-
[FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${t.pid}`),console.error(` Started at: ${t.startedAt||"(unknown)"}`),console.error(` Lock file: ${
|
|
256
|
+
`),process.exit(1))}}var se=C.join(B,".migration-lock");function qr(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return m.writeFileSync(se,e,{flag:"wx"}),!0}catch(o){if(o.code!=="EEXIST")throw o}let t;try{t=JSON.parse(m.readFileSync(se,"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(`
|
|
257
|
+
[FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${t.pid}`),console.error(` Started at: ${t.startedAt||"(unknown)"}`),console.error(` Lock file: ${se}
|
|
258
258
|
`),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.
|
|
259
|
-
`),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=
|
|
259
|
+
`),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=se+".tmp";try{return m.writeFileSync(n,e),m.renameSync(n,se),!0}catch(o){try{m.unlinkSync(n)}catch{}throw new Error(`Failed to take over stale migration lock: ${o.message}`)}}function at(){try{if(JSON.parse(m.readFileSync(se,"utf-8")).pid!==process.pid)return;m.unlinkSync(se)}catch{}}var Rn=!1;function Ur(){if(Rn)return;Rn=!0;let e=()=>{try{at()}catch{}process.exit(1)};for(let t of["SIGINT","SIGTERM","SIGHUP"])try{process.on(t,e)}catch{}}function Br(){if(m.existsSync(D))return;let e=[],t=[];for(let s of In)if(m.existsSync(s))try{e.push({file:s,schema:Ne(s)})}catch(i){t.push({file:s,err:i.message})}if(t.length>0){console.error(`
|
|
260
260
|
[FATAL] Legacy .schema-version file(s) corrupted \u2014 cannot determine current schema version:`);for(let s of t)console.error(` ${s.file}: ${s.err}`);console.error(`
|
|
261
261
|
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.
|
|
262
262
|
`),process.exit(1)}if(e.length===0)return;let n=e.map(s=>s.schema.version);if(new Set(n).size>1){console.error(`
|
|
263
263
|
[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.
|
|
264
|
-
`),process.exit(1)}let o=e[0].schema,r=D+".tmp";try{m.writeFileSync(r,JSON.stringify(o,null,2)),m.renameSync(r,D)}catch(s){try{m.unlinkSync(r)}catch{}throw s}for(let s of
|
|
264
|
+
`),process.exit(1)}let o=e[0].schema,r=D+".tmp";try{m.writeFileSync(r,JSON.stringify(o,null,2)),m.renameSync(r,D)}catch(s){try{m.unlinkSync(r)}catch{}throw s}for(let s of In)if(m.existsSync(s))try{m.unlinkSync(s)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${D}`)}function Vr(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 Ne(e){let t=m.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function Tn(){if(Br(),!m.existsSync(D))return{version:0,migrations:[]};let e;try{e=Ne(D)}catch(n){if(n.code==="ENOENT")return{version:0,migrations:[]};console.error(`
|
|
265
265
|
[FATAL] ${D} 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.
|
|
266
|
-
`),process.exit(1)}let t=
|
|
266
|
+
`),process.exit(1)}let t=Vr(e);return t===null&&(console.error(`
|
|
267
267
|
[FATAL] ${D} 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.
|
|
268
|
-
`),process.exit(1)),t}function
|
|
269
|
-
[FATAL] Your data schema is at v${t}, but this plugin build only understands up to v${
|
|
270
|
-
`),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${
|
|
268
|
+
`),process.exit(1)),t}function jn(e){try{m.chmodSync(e,384)}catch{}}function Hr(e){if(On(),m.existsSync(D))try{if(m.lstatSync(D).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${D}. 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=D+".tmp";try{m.writeFileSync(t,JSON.stringify(e,null,2)),jn(t),m.renameSync(t,D)}catch(n){try{m.unlinkSync(t)}catch{}throw n}}function Dn(e,t){if(!m.existsSync(e))return;let n=`.pre-v${String(t).padStart(3,"0")}.backup`,o=m.readdirSync(e).filter(a=>{let l=a.toLowerCase();if(l.includes(".backup")||l===".schema-version"||l.endsWith(".tmp"))return!1;try{return m.statSync(C.join(e,a)).isFile()}catch{return!1}}),r=0,s=0,i=[];for(let a of o){let l=C.join(e,a),u=C.join(e,a+n);if(m.existsSync(u)){s++;continue}try{Ln(l,u),r++}catch(c){i.push({file:a,err:c.message})}}if(i.length>0){let a=new Error(`Failed to back up ${i.length} file(s) in ${C.basename(e)}/: `+i.map(l=>`${l.file} (${l.err})`).join(", "));throw a.code="BACKUP_INCOMPLETE",a}if(r>0||s>0){let a=s>0?` (${s} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${r} files in ${C.basename(e)}/ (${n})${a}`)}}var it=!1;async function Nn(){if(it)return;On(),Kr();let t=Tn().version;if(t===Q){it=!0;return}Ur(),qr(),process.on("exit",at),t>Q&&(console.error(`
|
|
269
|
+
[FATAL] Your data schema is at v${t}, but this plugin build only understands up to v${Q}.`),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.
|
|
270
|
+
`),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${Q}.
|
|
271
271
|
`),process.exit(1)),console.log(`
|
|
272
|
-
\u{1F4E6} Schema migration: v${t} \u2192 v${
|
|
272
|
+
\u{1F4E6} Schema migration: v${t} \u2192 v${Q}`);let n=zr();if(!n.ok){console.error(`
|
|
273
273
|
[FATAL] Cannot migrate \u2014 current data is corrupted:`);for(let r of n.broken)console.error(` ${r.dir}/${r.file}: ${r.err}`);console.error(`
|
|
274
274
|
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'.
|
|
275
|
-
`),process.exit(1)}let o=
|
|
276
|
-
Running migration v${String(r.version).padStart(3,"0")}...`);let s=`v${String(r.version).padStart(3,"0")}`,i=`.pre-${s}.backup`;try{
|
|
275
|
+
`),process.exit(1)}let o=W.filter(r=>r.version>t);for(let r of o){console.log(`
|
|
276
|
+
Running migration v${String(r.version).padStart(3,"0")}...`);let s=`v${String(r.version).padStart(3,"0")}`,i=`.pre-${s}.backup`;try{Dn(ie,r.version),Dn(le,r.version)}catch(l){console.error(`
|
|
277
277
|
[FATAL] Pre-migration backup failed for ${s}: ${l.message}`),console.error(" Migration NOT applied. Repair the underlying issue (disk space, permissions, locked files)"),console.error(` and re-run the plugin command.
|
|
278
|
-
`),process.exit(1)}let a=r.module;try{await a.up(
|
|
279
|
-
[FATAL] Migration ${s} failed: ${l.message}`),console.error(` Attempting auto-rollback from ${i} files...`);try{let
|
|
280
|
-
`)):(console.error(` [!] Auto-rollback INCOMPLETE: ${
|
|
281
|
-
`))}catch(
|
|
282
|
-
`)}process.exit(1)}try{let l=new Date().toISOString(),
|
|
278
|
+
`),process.exit(1)}let a=r.module;try{await a.up(ie,le)}catch(l){console.error(`
|
|
279
|
+
[FATAL] Migration ${s} failed: ${l.message}`),console.error(` Attempting auto-rollback from ${i} files...`);try{let u=Qr(i);u.ok?(console.error(` \u2713 Auto-rollback restored ${u.restored} files. Schema stays at v${t}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
|
|
280
|
+
`)):(console.error(` [!] Auto-rollback INCOMPLETE: ${u.error}`),console.error(` Manual recovery: copy *${i} files back over the originals.
|
|
281
|
+
`))}catch(u){console.error(` [!] Auto-rollback CRASHED while restoring: ${u.message}`),console.error(` Manual recovery: copy *${i} files back over the originals.
|
|
282
|
+
`)}process.exit(1)}try{let l=new Date().toISOString(),u={version:r.version,name:a.NAME||s,appliedAt:l},c=Tn();c.version=r.version,c.migratedAt=l,c.migrations=c.migrations||[],c.migrations.push(u),Hr(c)}catch(l){console.error(`
|
|
283
283
|
[FATAL] Migration ${s} applied successfully but schema version file could NOT be updated: ${l.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.
|
|
284
|
-
`),process.exit(1)}console.log(` \u2713 Migration ${s} complete`)}try{
|
|
285
|
-
\u2713 Schema is now at v${
|
|
286
|
-
`)}var
|
|
287
|
-
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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 VISIT STATS"),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(` Unique profiles visited: ${e.totalVisited}`),console.log(` Today: ${e.todayVisited}`),console.log(` Discovered recruiters: ${e.totalRecruiters} (potential visits)`);let t=
|
|
288
|
-
`)}async function
|
|
284
|
+
`),process.exit(1)}console.log(` \u2713 Migration ${s} complete`)}try{en()}catch{}try{mn()}catch{}it=!0,at(),console.log(`
|
|
285
|
+
\u2713 Schema is now at v${Q}
|
|
286
|
+
`)}var Jr=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function Wr(e){let t=e.toLowerCase();return Jr.some(n=>n.test(t))}var Gr=6e4;function Yr(){let e=Date.now(),t=[];for(let n of[B,ie,le]){if(!m.existsSync(n))continue;let o;try{o=m.readdirSync(n)}catch{continue}for(let r of o){if(!Wr(r))continue;let s=C.join(n,r);try{let i=m.statSync(s);if(!i.isFile()||e-i.mtimeMs<Gr)continue;t.push({dir:n,file:r,fullPath:s})}catch{}}}return t}function Kr({verbose:e=!1}={}){let t=Yr();if(t.length===0)return e&&console.log(" No orphan .tmp files found."),0;let n=0;for(let o of t)try{m.unlinkSync(o.fullPath),n++,e&&console.log(` Removed orphan: ${C.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 zr(){let e=[];for(let t of[ie,le]){if(!m.existsSync(t))continue;let n=m.readdirSync(t).filter(o=>{let r=o.toLowerCase();return r.endsWith(".json")&&!r.includes(".backup")});for(let o of n){let r=C.join(t,o);try{Ne(r)}catch(s){e.push({dir:C.basename(t),file:o,err:s.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function Qr(e){let t=[],n=[];for(let s of[ie,le]){if(!m.existsSync(s))continue;let i=m.readdirSync(s).filter(a=>a.endsWith(e));for(let a of i){let l=C.join(s,a),u=a.slice(0,-e.length),c=C.join(s,u);try{u.toLowerCase().endsWith(".json")?Ne(l):m.accessSync(l,m.constants.R_OK),t.push({backupPath:l,originalPath:c,fileName:a,dir:s})}catch(p){n.push(`${C.basename(s)}/${a}: ${p.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let o=0,r=[];for(let{backupPath:s,originalPath:i,fileName:a,dir:l}of t)try{Ln(s,i),o++}catch(u){r.push(`${C.basename(l)}/${a}: ${u.message}`)}return r.length>0?{ok:!1,error:r.join("; "),restored:o}:{ok:!0,restored:o}}function Ln(e,t){let n=t+".tmp";try{m.copyFileSync(e,n),jn(n)}catch(o){try{m.unlinkSync(n)}catch{}throw o}try{m.renameSync(n,t)}catch(o){try{m.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 Nn();var Ee=process.argv.slice(2),Le=Ee.find(e=>e.startsWith("--source="))?.split("=")[1]||"scouted",ct=parseInt(Ee.find(e=>e.startsWith("--max="))?.split("=")[1]||"10"),ae=parseInt(Ee.find(e=>e.startsWith("--revisit="))?.split("=")[1]||"0"),Xr=Ee.includes("--list"),Zr=Ee.includes("--verbose");function es(){let e=gn();console.log(`
|
|
287
|
+
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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 VISIT STATS"),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(` Unique profiles visited: ${e.totalVisited}`),console.log(` Today: ${e.todayVisited}`),console.log(` Discovered recruiters: ${e.totalRecruiters} (potential visits)`);let t=Ye();if(console.log(` Unconnected recruiters: ${t.length}`),ae>0){let n=Ke(ae);console.log(` Revisit (>${ae}d ago): ${n.length}`)}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
|
|
288
|
+
`)}async function ts(){if(console.log(`
|
|
289
289
|
LinkedIn Profile Visitor
|
|
290
|
-
`),
|
|
290
|
+
`),Xr){es();return}let e=[],t="";if(ae>0?(e=Ke(ae),t=`revisit (>${ae} days)`):Le==="people"?(e=Ye(),t="unconnected recruiters (people.json)"):Le==="scouted"||Le==="discovered"?(e=Sn(),t="discovered recruiters (market-research)"):(e=wn({limit:ct}),t="smart (new \u2192 active \u2192 unconnected \u2192 revisit)"),console.log(` Source: ${t}`),console.log(` Candidates: ${e.length}`),console.log(` Max visits: ${ct}
|
|
291
291
|
`),e.length===0){console.log(` No profiles to visit. Run npm run scout first.
|
|
292
|
-
`);return}await
|
|
292
|
+
`);return}await xn("visit",Le,async n=>{let{browser:o,page:r}=await Kt();try{let s=await yn(r,e,{maxVisits:ct,verbose:Zr,skipRecentDays:ae>0?0:7});Object.assign(n,s),console.log(`
|
|
293
293
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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(" Visit 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: ${s.skipped} (visited recently)`),console.log(` Errors: ${s.errors}`),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
|
|
294
|
-
`)}finally{await o.close().catch(()=>{})}},n=>[`${n.visited??0} visited, ${n.skipped??0} skipped (recent), ${n.errors??0} errors`],{rethrow:!1})}
|
|
294
|
+
`)}finally{await o.close().catch(()=>{})}},n=>[`${n.visited??0} visited, ${n.skipped??0} skipped (recent), ${n.errors??0} errors`],{rethrow:!1})}ts().catch(e=>{console.error("Visit failed:",e),process.exit(1)});
|
package/ilml-plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linkedin",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.26",
|
|
4
4
|
"description": "Reference ilml plugin: keep a local mirror of your LinkedIn data with AI-assisted workflows",
|
|
5
5
|
"commands": {
|
|
6
6
|
"help": { "run": "node dist/help.mjs", "description": "List all commands with descriptions; or `help <cmd>` for detailed info on one command (usage, flags, ban-risk, when-to-use). Reads ilml-plugin.json directly.", "usage": "ilml linkedin help [<cmd>]", "useWhen": "You forgot what a command does, or you're an AI agent picking the right tool." },
|
|
@@ -89,6 +89,24 @@
|
|
|
89
89
|
"banRisk": "Medium for `run` (sends real connection requests, browser) — but every send goes through the same daily/weekly quota gate as the funnel, so you can't exceed the limit. All other subcommands are local, no browser, no risk.",
|
|
90
90
|
"useWhen": "You have a curated list of people worth connecting to (investors from a post, event speakers, company leaders) and want to review, prioritise, and send requests under quota instead of blindly connecting recruiters."
|
|
91
91
|
},
|
|
92
|
+
"search": {
|
|
93
|
+
"run": "node dist/peopleSearchCli.mjs",
|
|
94
|
+
"description": "Search LinkedIn PEOPLE by any query and harvest whole result cards — name, title, location, connection degree — across pages. By default it just SHOWS the results, marking who you already know (✓connected / …pending / ⋯in-queue / ·known / +new). With --harvest it also saves each person into your contacts DB (with their title, so they're no longer 'unknown who') and drops the NEW ones (not already connected/pending) into the connect queue as `queued` for your review. Ideal for building a targeted pipeline (e.g. investors) instead of relying on the recruiter-heavy discovery pool. No sends — approving and sending stay with `connect approve` + `connect run`.",
|
|
95
|
+
"usage": "ilml linkedin search --url=\"<people-search URL>\" | --keywords=\"...\" [--2nd] [--pages=N] [--harvest] [--dry-run]",
|
|
96
|
+
"flags": {
|
|
97
|
+
"--url=\"...\"": "A LinkedIn people-search URL you copied from your browser (any filters you set are honoured). Use this OR --keywords.",
|
|
98
|
+
"--keywords=\"...\"": "Build the search from keywords instead of a URL. Combine with --2nd to restrict to 2nd-degree (excludes your existing connections).",
|
|
99
|
+
"--2nd": "With --keywords: only 2nd-degree people (not already connected).",
|
|
100
|
+
"--pages=N": "How many result pages to page through (default 5, ~10 people per page).",
|
|
101
|
+
"--harvest": "Also WRITE: upsert each person into your contacts DB (name, title, location, category, source=people-search:<query>) and queue the new non-connections for connect approval. Without this flag the command only prints results.",
|
|
102
|
+
"--tag=X": "Queue tag for the harvested batch (default people-search:<query>). Shows up in `ilml linkedin quota`.",
|
|
103
|
+
"--category=CAT": "Category to store when the title doesn't self-identify one (default investor).",
|
|
104
|
+
"--priority=LEVEL": "Priority for the queued entries: high|normal|low (default normal).",
|
|
105
|
+
"--dry-run": "With --harvest: show exactly what WOULD be written/queued without saving anything."
|
|
106
|
+
},
|
|
107
|
+
"banRisk": "Low. Reads public search-result pages and scrolls to load them — the same footprint as browsing search yourself. No profile visits, no sends. Keep --pages sane (a handful) to look human.",
|
|
108
|
+
"useWhen": "You want to build a targeted list of people (investors, founders, a role in a city) from LinkedIn search, see who you already know among them, and feed the fresh ones into the connect queue with their real titles."
|
|
109
|
+
},
|
|
92
110
|
"scout": {
|
|
93
111
|
"run": "node dist/scout.mjs",
|
|
94
112
|
"description": "Scan jobs from LINKEDIN_SCOUT_URLS (multiple search URLs supported), score them, and save to market-research/ — WITHOUT applying. Builds a ranked queue for apply-queue to consume.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ilml-plugin-linkedin",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.26",
|
|
4
4
|
"description": "Reference ilml plugin: keep a local mirror of your LinkedIn data and run AI-assisted workflows under your direction.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"today": "node syncAll.mjs --today",
|
|
58
58
|
"quota": "node quota.mjs",
|
|
59
59
|
"connect": "node connect.mjs",
|
|
60
|
+
"people-search": "node peopleSearchCli.mjs",
|
|
60
61
|
"plugin-version": "node version.mjs",
|
|
61
62
|
"migrate:status": "node migrationCli.mjs status",
|
|
62
63
|
"rollback:data": "node migrationCli.mjs rollback-data",
|