ilml-plugin-linkedin 1.20.4 → 1.20.6

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