ilml-plugin-linkedin 1.14.0 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.14.1
4
+ - **`ilml linkedin connect` sends without a note by default; notes are now opt-in.** LinkedIn caps personalised connection-request notes to a handful per month, and the "Add a note" dialog fails once you're out (which showed up as failed sends). So `connect run` now sends plain requests unless you add `--with-notes`, which sends the notes you saved with `connect note` — spend those few monthly notes deliberately. A saved note shows as 📝 in `connect list`.
5
+ - **connect stops itself after 3 failed sends in a row.** If sends keep failing — often LinkedIn's own (invisible) weekly invite limit — connect halts instead of hammering your account, and saves what LinkedIn showed on each failure to `<DATA_DIR>/collected-profiles/connect-diagnostics/` (the on-page message + a screenshot). That's so the exact limit wording can be recognised precisely in a later version, from real data rather than a guess.
6
+ - **Your connection quota is now configurable.** `CONNECT_MAX_DAILY` (default 20) and `CONNECT_MAX_WEEKLY` (default 100) in plugin config. Set them to match your account, or raise them deliberately to surface LinkedIn's real limit — the circuit-breaker keeps that safe. No schema change.
7
+
3
8
  ## 1.14.0
4
9
  - **New `ilml linkedin connect` command — a reviewable, prioritised connection queue.** Instead of blindly connecting recruiters found while applying, you now build a queue of people worth connecting to and send them under your daily/weekly quota:
5
10
  - `connect add <file.json> --tag=investors --priority=high` — drop a curated list (a JSON array of `{url, note?, name?}`, e.g. investors from a post or event speakers). Dedupes against the queue and skips anyone you're already connected to or have a pending request with.
package/README.md CHANGED
@@ -96,6 +96,8 @@ ilml plugin config linkedin reset # re-prompt on next run
96
96
  | | `FUNNEL_MAX_CONNECTIONS` | no | Cap connection requests per run. Default: `20`. |
97
97
  | | `FUNNEL_MESSAGE` | no | Note text. Use `{name}` placeholder, e.g. `Hi {name}, I just applied for a role at your company`. |
98
98
  | | `FUNNEL_EXCLUDE_LOCATIONS` | no | Comma-separated locations to skip. |
99
+ | Connection limits | `CONNECT_MAX_DAILY` | no | Max connection requests per day across every path (`connect`, `funnel`, `apply`). Default: `20`. LinkedIn's real limit is dynamic and unknown — keep this under it, or raise it deliberately to surface LinkedIn's own limit (`connect` stops itself after 3 failures in a row and saves what LinkedIn showed to `connect-diagnostics/`). |
100
+ | | `CONNECT_MAX_WEEKLY` | no | Rolling 7-day cap. Default: `100`. Free accounts are often limited around 100–200/week. Set e.g. `ilml plugin config linkedin set CONNECT_MAX_WEEKLY 250`. |
99
101
 
100
102
  ## Setting up your graph
101
103
 
@@ -172,7 +174,7 @@ Sessions live in your active ilml scope (`<scope>/.ilivemylife/plugins-state/lin
172
174
  | `ilml linkedin apply-queue` | Apply to the top-scored jobs from the latest `scout` run. |
173
175
  | `ilml linkedin messages` | Batch messaging — draft, review, then push. Nothing sends without your approval. Common forms: `messages --review-drafts` (review pending drafts) and `messages --push-drafts` (push approved). |
174
176
  | `ilml linkedin funnel` | Run the recruiter / founder / investor connection-request queue. |
175
- | `ilml linkedin connect` | Build a reviewable, prioritised queue of people to connect with, then send under your daily/weekly quota. `connect add <file.json>` drops a curated list; `connect fill --category=founder,investor,hiring_manager` (or `--valuable`) pulls from people already categorised in your contacts; `connect list` / `approve` / `note` / `priority` / `skip` manage the queue; `connect run` sends only the approved ones. Every send goes through the same quota gate. |
177
+ | `ilml linkedin connect` | Build a reviewable, prioritised queue of people to connect with, then send under your daily/weekly quota. `connect add <file.json>` drops a curated list; `connect fill --category=founder,investor,hiring_manager` (or `--valuable`) pulls from people already categorised in your contacts; `connect list` / `approve` / `note` / `priority` / `skip` manage the queue; `connect run` sends only the approved ones. Sends go **without a note** by default (LinkedIn caps custom notes to a few per month) — save notes on the deliberate few with `connect note` and send them with `connect run --with-notes`. Every send goes through the same quota gate; `run` stops itself after 3 failures in a row (often LinkedIn's own limit). |
176
178
  | `ilml linkedin quota` | No-browser report: how much of today's / this week's connection quota is left and how it was spent (by source), the acceptance rate per source (which outreach actually converts), and high-value contacts you haven't connected to yet. `--json` for machine output. |
177
179
  | `ilml linkedin visit` | Visit recruiter / target profiles so they see you in "who viewed your profile". |
178
180
  | `ilml linkedin viewers` | Pull the "who viewed your profile" list. |
@@ -1,58 +1,58 @@
1
- var Ce=Object.defineProperty;var G=(e,n)=>{for(var o in n)Ce(e,o,{get:n[o],enumerable:!0})};import"dotenv/config";import*as D from"fs";import*as L from"path";import{fileURLToPath as Zo}from"url";import{execFileSync as en}from"child_process";import{getPluginConfig as _e}from"@ilivemylife/graph-sdk";var xe=await _e();for(let[e,n]of Object.entries(xe))process.env[e]===void 0&&(process.env[e]=n);var an=process.env.LINKEDIN_NAME,N=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),un=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.NEEDS_REVIEW])),fn=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.REJECTED,N.NEEDS_REVIEW]));import"dotenv/config";import*as h from"fs";import*as g from"path";import{fileURLToPath as Fe}from"url";var Le=Fe(import.meta.url),Me=g.dirname(g.dirname(Le)),E=process.env.DATA_DIR?g.resolve(process.env.DATA_DIR,"collected-profiles"):g.join(Me,"collected-profiles"),Pe=g.join(E,"people.json"),gn=g.join(E,"jobs.json"),yn=g.join(E,"quota.json"),Sn=g.join(E,"conversations.json"),bn=g.join(E,"sync-state.json"),vn=g.join(E,"application-questions.json"),wn=g.join(E,"profile-history");var P=null,Je=null,Ue=null,Be=null,qe=null,Ve=null;function le(){P=null,Je=null,Ue=null,Be=null,qe=null,Ve=null}function We(){h.existsSync(E)||h.mkdirSync(E,{recursive:!0})}function Ge(e,n){if(!h.existsSync(e))return null;try{let o=JSON.parse(h.readFileSync(e,"utf-8"));try{h.copyFileSync(e,e+".backup")}catch{}return o}catch(o){console.error(`[!] ${n} is corrupted: ${o.message}`),console.error(` File: ${g.resolve(e)}`);let t=e+".backup";if(h.existsSync(t))try{let s=JSON.parse(h.readFileSync(t,"utf-8"));console.error(` Restored from ${t}`);try{h.copyFileSync(t,e)}catch{}return s}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{h.copyFileSync(e,e+".corrupted")}catch{}return null}}function ae(){return P||(We(),P=Ge(Pe,"people.json")||{},P)}import"dotenv/config";import*as v from"fs";import*as b from"path";import{fileURLToPath as Ye}from"url";var He=Ye(import.meta.url),Ke=b.dirname(b.dirname(He)),C=process.env.DATA_DIR?b.resolve(process.env.DATA_DIR,"market-research"):b.join(Ke,"market-research"),ue=b.join(C,"scouted-jobs.json"),jn=b.join(C,"discovered-people.json"),On=b.join(C,"visit-log.json"),En=b.join(C,"companies.json"),Qe=b.join(C,"job-decisions.json");function ze(){v.existsSync(C)||v.mkdirSync(C,{recursive:!0})}function Xe(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";v.writeFileSync(t,o);for(let s=0;s<3;s++)try{v.renameSync(t,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw r}}function fe(e){try{if(v.existsSync(e))return JSON.parse(v.readFileSync(e,"utf-8"))}catch{}return null}function pe(){J=null,U=null,Ze=null,eo=null,oo=null}var J=null;function Y(){return J||(J=fe(ue)||{},J)}function de(e,n){if(!e)return;ze();let o=Y(),t=new Date().toISOString().slice(0,10);if(o[e]){for(let[s,r]of Object.entries(n))r!=null&&(o[e][s]=r);o[e].lastSeen=t}else o[e]={...n,scoutedAt:t,lastSeen:t};try{Xe(ue,o)}catch(s){console.error(`[!] Failed to save scouted-jobs.json: ${s.message}`)}}var U=null;function me(){return U||(U=fe(Qe)||{},U)}var Ze=null;var eo=null;var oo=null;var no=new Set(["java","c#",".net","scala","python","typescript","javascript","react","node.js","aws","azure","docker","kubernetes","microservices","graphql","rest","sql","postgresql","mongodb","kafka","redis","ci/cd","terraform","spring"]),to=new Set(["iot","machine learning","ai","data engineering","spark","go","rust","kotlin","next.js","devops","sre"]),he=["vancouver","british columbia"],so=["canada","montreal","quebec","alberta","calgary","ottawa"],ro=["toronto","ontario"],io=["india","pakistan","nigeria","philippines"];function co(e,n={}){let o=0,t=(e.techStack||[]).map(a=>a.toLowerCase()),s=0,r=0;for(let a of t)no.has(a)&&s++,to.has(a)&&r++;if(o+=Math.min(s*6,24),o+=Math.min(r*3,6),e.salary){let a=lo(e.salary);a&&(a>=15e4?o+=20:a>=12e4?o+=15:a>=1e5?o+=10:a>=8e4?o+=5:a>=100&&a<1e3?o+=15:a>=70&&a<1e3&&(o+=10))}let i=(e.location||"").toLowerCase(),u=/remote/i.test(i)||e.workplaceType==="remote";io.some(a=>i.includes(a))?o-=30:u&&/united states|usa|\bus\b/i.test(i)?o+=25:u&&he.some(a=>i.includes(a))?o+=22:u?o+=20:he.some(a=>i.includes(a))?o+=18:so.some(a=>i.includes(a))?o+=10:ro.some(a=>i.includes(a))&&(o+=5),e.isEasyApply&&(o+=5);let c=(e.seniority||"").toLowerCase();c.includes("senior")||c.includes("lead")||c.includes("staff")?o+=10:c.includes("mid")?o+=5:(c.includes("entry")||c.includes("intern"))&&(o-=10),e.recruiterUrl&&(n.conversationRecruiters?.has(e.recruiterUrl)?o+=20:n.connectedRecruiters?.has(e.recruiterUrl)?o+=15:o+=3);let f=new Set(e.jobTags||[]);return f.has("managerial")?o+=8:f.has("senior-ic")&&(o+=5),f.has("junior")&&(o-=15),f.has("consultant")&&(o-=3),Math.max(0,Math.min(100,o))}function H(e=10,n={}){let{easyApplyOnly:o=!0}=n,t=Y(),s=ae(),r=new Set,i=new Set;for(let[m,p]of Object.entries(s))p.connectionStatus==="connected"&&r.add(m);let u={connectedRecruiters:r,conversationRecruiters:i},c=me(),f=new Set(["applied","skipped","expired","archived"]);return Object.entries(t).filter(([m,p])=>{if(typeof p!="object"||o&&!p.isEasyApply||p.applied)return!1;let y=c[m];return!(y&&f.has(y.status))}).map(([m,p])=>({jobId:m,score:co(p,u),job:p})).sort((m,p)=>{if(p.score!==m.score)return p.score-m.score;let y=m.job.scoutedAt||m.job.postedTime||"";return(p.job.scoutedAt||p.job.postedTime||"").localeCompare(y)}).slice(0,e)}function lo(e){if(!e)return null;let n=e.match(/[\$£€CAD\s]*([\d,]+(?:\.\d+)?)\s*[kK]?/g);if(!n||n.length===0)return null;let o=n.map(t=>{let s=parseFloat(t.replace(/[^\d.]/g,""));return t.toLowerCase().includes("k")&&(s*=1e3),s}).filter(t=>t>0);return o.length>=2?(o[0]+o[1])/2:o.length===1?o[0]:null}import"dotenv/config";import*as w from"fs";import*as I from"path";import{fileURLToPath as ho}from"url";import"dotenv/config";import{createGraphClient as ao,resolveToken as uo}from"@ilivemylife/graph-sdk";import{config as fo}from"dotenv";fo();var ge=uo()||process.env.TOKEN;ge||(console.error(`
1
+ var _e=Object.defineProperty;var G=(e,n)=>{for(var o in n)_e(e,o,{get:n[o],enumerable:!0})};import"dotenv/config";import*as D from"fs";import*as L from"path";import{fileURLToPath as en}from"url";import{execFileSync as on}from"child_process";import{getPluginConfig as xe}from"@ilivemylife/graph-sdk";var Fe=await xe();for(let[e,n]of Object.entries(Fe))process.env[e]===void 0&&(process.env[e]=n);var un=process.env.LINKEDIN_NAME,N=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),fn=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.NEEDS_REVIEW])),pn=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.REJECTED,N.NEEDS_REVIEW]));import"dotenv/config";import*as h from"fs";import*as g from"path";import{fileURLToPath as Le}from"url";var Me=Le(import.meta.url),Pe=g.dirname(g.dirname(Me)),O=process.env.DATA_DIR?g.resolve(process.env.DATA_DIR,"collected-profiles"):g.join(Pe,"collected-profiles"),Je=g.join(O,"people.json"),yn=g.join(O,"jobs.json"),Sn=g.join(O,"quota.json"),bn=g.join(O,"conversations.json"),vn=g.join(O,"sync-state.json"),wn=g.join(O,"application-questions.json"),$n=g.join(O,"profile-history"),le=(e,n)=>{let o=parseInt(e,10);return Number.isInteger(o)&&o>=0?o:n},kn=le(process.env.CONNECT_MAX_DAILY,20),An=le(process.env.CONNECT_MAX_WEEKLY,100),P=null,Ue=null,Be=null,qe=null,Ve=null,We=null;function ae(){P=null,Ue=null,Be=null,qe=null,Ve=null,We=null}function Ge(){h.existsSync(O)||h.mkdirSync(O,{recursive:!0})}function Ye(e,n){if(!h.existsSync(e))return null;try{let o=JSON.parse(h.readFileSync(e,"utf-8"));try{h.copyFileSync(e,e+".backup")}catch{}return o}catch(o){console.error(`[!] ${n} is corrupted: ${o.message}`),console.error(` File: ${g.resolve(e)}`);let t=e+".backup";if(h.existsSync(t))try{let s=JSON.parse(h.readFileSync(t,"utf-8"));console.error(` Restored from ${t}`);try{h.copyFileSync(t,e)}catch{}return s}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{h.copyFileSync(e,e+".corrupted")}catch{}return null}}function ue(){return P||(Ge(),P=Ye(Je,"people.json")||{},P)}import"dotenv/config";import*as v from"fs";import*as b from"path";import{fileURLToPath as He}from"url";var Ke=He(import.meta.url),Qe=b.dirname(b.dirname(Ke)),C=process.env.DATA_DIR?b.resolve(process.env.DATA_DIR,"market-research"):b.join(Qe,"market-research"),fe=b.join(C,"scouted-jobs.json"),Rn=b.join(C,"discovered-people.json"),In=b.join(C,"visit-log.json"),Tn=b.join(C,"companies.json"),ze=b.join(C,"job-decisions.json");function Xe(){v.existsSync(C)||v.mkdirSync(C,{recursive:!0})}function Ze(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";v.writeFileSync(t,o);for(let s=0;s<3;s++)try{v.renameSync(t,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw r}}function pe(e){try{if(v.existsSync(e))return JSON.parse(v.readFileSync(e,"utf-8"))}catch{}return null}function de(){J=null,U=null,eo=null,oo=null,no=null}var J=null;function Y(){return J||(J=pe(fe)||{},J)}function me(e,n){if(!e)return;Xe();let o=Y(),t=new Date().toISOString().slice(0,10);if(o[e]){for(let[s,r]of Object.entries(n))r!=null&&(o[e][s]=r);o[e].lastSeen=t}else o[e]={...n,scoutedAt:t,lastSeen:t};try{Ze(fe,o)}catch(s){console.error(`[!] Failed to save scouted-jobs.json: ${s.message}`)}}var U=null;function he(){return U||(U=pe(ze)||{},U)}var eo=null;var oo=null;var no=null;var to=new Set(["java","c#",".net","scala","python","typescript","javascript","react","node.js","aws","azure","docker","kubernetes","microservices","graphql","rest","sql","postgresql","mongodb","kafka","redis","ci/cd","terraform","spring"]),so=new Set(["iot","machine learning","ai","data engineering","spark","go","rust","kotlin","next.js","devops","sre"]),ge=["vancouver","british columbia"],ro=["canada","montreal","quebec","alberta","calgary","ottawa"],io=["toronto","ontario"],co=["india","pakistan","nigeria","philippines"];function lo(e,n={}){let o=0,t=(e.techStack||[]).map(a=>a.toLowerCase()),s=0,r=0;for(let a of t)to.has(a)&&s++,so.has(a)&&r++;if(o+=Math.min(s*6,24),o+=Math.min(r*3,6),e.salary){let a=ao(e.salary);a&&(a>=15e4?o+=20:a>=12e4?o+=15:a>=1e5?o+=10:a>=8e4?o+=5:a>=100&&a<1e3?o+=15:a>=70&&a<1e3&&(o+=10))}let i=(e.location||"").toLowerCase(),u=/remote/i.test(i)||e.workplaceType==="remote";co.some(a=>i.includes(a))?o-=30:u&&/united states|usa|\bus\b/i.test(i)?o+=25:u&&ge.some(a=>i.includes(a))?o+=22:u?o+=20:ge.some(a=>i.includes(a))?o+=18:ro.some(a=>i.includes(a))?o+=10:io.some(a=>i.includes(a))&&(o+=5),e.isEasyApply&&(o+=5);let c=(e.seniority||"").toLowerCase();c.includes("senior")||c.includes("lead")||c.includes("staff")?o+=10:c.includes("mid")?o+=5:(c.includes("entry")||c.includes("intern"))&&(o-=10),e.recruiterUrl&&(n.conversationRecruiters?.has(e.recruiterUrl)?o+=20:n.connectedRecruiters?.has(e.recruiterUrl)?o+=15:o+=3);let f=new Set(e.jobTags||[]);return f.has("managerial")?o+=8:f.has("senior-ic")&&(o+=5),f.has("junior")&&(o-=15),f.has("consultant")&&(o-=3),Math.max(0,Math.min(100,o))}function H(e=10,n={}){let{easyApplyOnly:o=!0}=n,t=Y(),s=ue(),r=new Set,i=new Set;for(let[m,p]of Object.entries(s))p.connectionStatus==="connected"&&r.add(m);let u={connectedRecruiters:r,conversationRecruiters:i},c=he(),f=new Set(["applied","skipped","expired","archived"]);return Object.entries(t).filter(([m,p])=>{if(typeof p!="object"||o&&!p.isEasyApply||p.applied)return!1;let y=c[m];return!(y&&f.has(y.status))}).map(([m,p])=>({jobId:m,score:lo(p,u),job:p})).sort((m,p)=>{if(p.score!==m.score)return p.score-m.score;let y=m.job.scoutedAt||m.job.postedTime||"";return(p.job.scoutedAt||p.job.postedTime||"").localeCompare(y)}).slice(0,e)}function ao(e){if(!e)return null;let n=e.match(/[\$£€CAD\s]*([\d,]+(?:\.\d+)?)\s*[kK]?/g);if(!n||n.length===0)return null;let o=n.map(t=>{let s=parseFloat(t.replace(/[^\d.]/g,""));return t.toLowerCase().includes("k")&&(s*=1e3),s}).filter(t=>t>0);return o.length>=2?(o[0]+o[1])/2:o.length===1?o[0]:null}import"dotenv/config";import*as w from"fs";import*as I from"path";import{fileURLToPath as go}from"url";import"dotenv/config";import{createGraphClient as uo,resolveToken as fo}from"@ilivemylife/graph-sdk";import{config as po}from"dotenv";po();var ye=fo()||process.env.TOKEN;ye||(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 ye=ao({token:ge});function po(e){if(!e||e<1e3)return`${e||0}ms`;let n=Math.round(e/1e3);if(n<60)return`${n}s`;let o=Math.floor(n/60),t=n%60;return t?`${o}m ${t}s`:`${o}m`}function mo({scriptName:e,mode:n,status:o,error:t,duration:s}){let r=o==="error"?"\u2717":o==="quota-reached"?"\u26A0":"\u2713",i=new Date().toISOString().slice(0,16).replace("T"," "),u=s?` ${po(s)}`:"",c=o==="error"?`error${t?`: ${String(t).slice(0,80)}`:""}`:o==="quota-reached"?"daily quota reached":"done",f=n&&n!=="default"?` (${n})`:"";return`${r} ${e}${f} \u2014 ${c} \u2014 ${i}${u}`}async function Se({scriptName:e,mode:n,status:o,summaryLines:t,error:s,duration:r}){let i=process.env.NODE_RUN_REPORTS;if(!i||!Array.isArray(t)||t.length===0)return;let c=`**${mo({scriptName:e,mode:n,status:o,error:s,duration:r})}**
5
+ `),process.exit(1));var Se=uo({token:ye});function mo(e){if(!e||e<1e3)return`${e||0}ms`;let n=Math.round(e/1e3);if(n<60)return`${n}s`;let o=Math.floor(n/60),t=n%60;return t?`${o}m ${t}s`:`${o}m`}function ho({scriptName:e,mode:n,status:o,error:t,duration:s}){let r=o==="error"?"\u2717":o==="quota-reached"?"\u26A0":"\u2713",i=new Date().toISOString().slice(0,16).replace("T"," "),u=s?` ${mo(s)}`:"",c=o==="error"?`error${t?`: ${String(t).slice(0,80)}`:""}`:o==="quota-reached"?"daily quota reached":"done",f=n&&n!=="default"?` (${n})`:"";return`${r} ${e}${f} \u2014 ${c} \u2014 ${i}${u}`}async function be({scriptName:e,mode:n,status:o,summaryLines:t,error:s,duration:r}){let i=process.env.NODE_RUN_REPORTS;if(!i||!Array.isArray(t)||t.length===0)return;let c=`**${ho({scriptName:e,mode:n,status:o,error:s,duration:r})}**
6
6
 
7
7
  ${t.join(`
8
- `)}`;try{await ye.addMessage(i,c)}catch(f){console.error(`[runReport] Failed to post end-of-session message: ${f.message}`)}}var go=ho(import.meta.url),yo=I.dirname(I.dirname(go)),K=process.env.DATA_DIR?I.resolve(process.env.DATA_DIR,"collected-profiles"):I.join(yo,"collected-profiles"),Q=I.join(K,"run-log.json");function So(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";w.writeFileSync(t,o);for(let s=0;s<3;s++)try{w.renameSync(t,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw r}}function be(){try{if(!w.existsSync(Q))return{runs:[]};let e=JSON.parse(w.readFileSync(Q,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function ve(e){w.existsSync(K)||w.mkdirSync(K,{recursive:!0});try{So(Q,e)}catch(n){console.error(`[!] Failed to save run-log.json: ${n.message}`)}}function we(e,n="default"){let o=be();for(let i of o.runs)i.status==="running"&&(i.status="interrupted",i.result="interrupted",i.timestamp&&(i.duration=Date.now()-new Date(i.timestamp).getTime()));let t=new Date,s={timestamp:t.toISOString(),script:e,mode:n,status:"running",result:null,duration:null,stats:null,error:null};o.runs.push(s);let r=Date.now()-30*24*60*60*1e3;return o.runs=o.runs.filter(i=>new Date(i.timestamp).getTime()>r),ve(o),{script:e,mode:n,startTime:t.getTime(),runIndex:o.runs.length-1}}function z(e,n,o=null,t=null){if(!e)return;let s=null;try{let i=be(),u=i.runs[e.runIndex];if(u&&u.status==="running"&&u.script===e.script)u.status=n,u.result=n,u.duration=Date.now()-e.startTime,u.stats=o,u.error=t,s=u.duration;else{let c=i.runs.find(f=>f.script===e.script&&f.status==="running"&&f.timestamp===new Date(e.startTime).toISOString());c&&(c.status=n,c.result=n,c.duration=Date.now()-e.startTime,c.stats=o,c.error=t,s=c.duration)}ve(i)}catch(i){console.error(`[runLog] Failed to end run: ${i.message}`)}let r=o&&Array.isArray(o.summaryLines)?o.summaryLines:null;if(r&&r.length>0&&process.env.NODE_RUN_REPORTS){let i=n==="error"?"error":o&&o.dailyLimitHit?"quota-reached":"done";Se({scriptName:e.script,mode:e.mode,status:i,summaryLines:r,error:t,duration:s??Date.now()-e.startTime}).catch(u=>console.error(`[runLog] postRunReport failed: ${u.message}`))}}import"dotenv/config";import*as l from"fs";import*as se from"os";import*as d from"path";import{fileURLToPath as Fo}from"url";var ee={};G(ee,{NAME:()=>vo,VERSION:()=>bo,up:()=>ko});import*as $ from"fs";import*as B from"path";var bo=1,vo="normalize-jobs-and-questions",wo=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],$o=50;function X(e){return $.existsSync(e)?JSON.parse($.readFileSync(e,"utf-8")):null}function Z(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{$.writeFileSync(t,o)}catch(s){try{$.unlinkSync(t)}catch{}throw s}try{$.renameSync(t,e)}catch(s){try{$.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function ko(e,n){let o=B.join(e,"jobs.json"),t=B.join(n,"scouted-jobs.json"),s=B.join(e,"application-questions.json"),r=X(o)||{},i=X(t)||{},u=0,c=[];for(let a of Object.keys(r)){if(!i[a])continue;let m=i[a],p=r[a];for(let y of wo)m[y]!=null&&p[y]==null&&(p[y]=m[y]);c.push(a),u++}u>0?(Z(o,r),console.log(` Phase 1: Merged ${u} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let f=X(s);if(f&&Array.isArray(f.applications)){let a={},m=0;for(let p of f.applications){let y=p.jobId||"unknown";a[y]||(a[y]={applications:[]});let W=(p.questions||[]).map(j=>{let M={type:j.type||"input",question:j.question||"",answer:j.answer||""};return j.options&&(j.options.length<=$o?M.options=j.options:(M.optionsOmitted=!0,m++)),j.page&&(M.page=j.page),j.wasPreFilled&&(M.wasPreFilled=!0),j.wasRetry&&(M.wasRetry=!0),M});a[y].applications.push({applicationId:p.applicationId,date:p.date,result:p.result||"submitted",formPages:p.formPages||null,duration:p.duration||null,retries:p.retries||0,failedField:p.failedField||null,questionCount:p.questionCount||W.length,questions:W})}Z(s,a),console.log(` Phase 2: Rekeyed ${f.applications.length} applications by jobId (${Object.keys(a).length} unique jobs)`),m>0&&console.log(` Phase 2: Stripped bloated options from ${m} questions`)}else f&&!f.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(c.length>0){for(let a of c)delete i[a];Z(t,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 oe={};G(oe,{NAME:()=>jo,VERSION:()=>Ao,up:()=>Ro});import*as k from"fs";import*as $e from"path";var Ao=2,jo="reset-unread-flags";function Oo(e){return k.existsSync(e)?JSON.parse(k.readFileSync(e,"utf-8")):null}function Eo(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{k.writeFileSync(t,o)}catch(s){try{k.unlinkSync(t)}catch{}throw s}try{k.renameSync(t,e)}catch(s){try{k.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Ro(e){let n=$e.join(e,"conversations.json"),o=Oo(n);if(!o){console.log(" conversations.json not found \u2014 nothing to reset.");return}let t=0;for(let s of Object.keys(o))o[s].unread===!0&&(o[s].unread=!1,t++);if(t===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}Eo(n,o),console.log(` Reset unread=false on ${t} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var ne={};G(ne,{NAME:()=>To,VERSION:()=>Io,up:()=>xo});import*as A from"fs";import*as ke from"path";var Io=3,To="recompute-last-message-by",Do=new Set(["draft","confirmed","rejected","needs_review"]);function No(e){return A.existsSync(e)?JSON.parse(A.readFileSync(e,"utf-8")):null}function Co(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{A.writeFileSync(t,o)}catch(s){try{A.unlinkSync(t)}catch{}throw s}try{A.renameSync(t,e)}catch(s){try{A.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}function _o(e,n){if(!e||e.length===0)return"them";let o=e.filter(r=>!Do.has(r.status));if(o.length===0)return"them";let t=o.map(r=>({m:r,t:Date.parse(r.time)})).filter(r=>Number.isFinite(r.t)).sort((r,i)=>i.t-r.t).map(r=>r.m),s=t.length>0?t:[...o].reverse();for(let r of s){let i=r.sender;if(i===n)return"me";if(i!=="Unknown"&&i!=="")return"them"}return"them"}async function xo(e){let n=ke.join(e,"conversations.json"),o=No(n);if(!o){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let t=process.env.LINKEDIN_NAME;if(!t||typeof t!="string"||!t.trim())throw new Error(`LINKEDIN_NAME env var is not set. Migration v003 needs your display name to determine which messages are yours vs theirs. Set LINKEDIN_NAME in your .env (or run "ilml plugin config linkedin set LINKEDIN_NAME 'Your Name'") and retry.`);let s=0,r=0,i=0;for(let u of Object.keys(o)){let c=o[u];if(!c||typeof c!="object")continue;Object.prototype.hasOwnProperty.call(c,"_cardSynced")&&(delete c._cardSynced,r++);let f=Array.isArray(c.messages)?c.messages:[],a=_o(f,t),m=a==="me"?"awaiting_reply":"unanswered_by_us";c.lastMessageBy!==a&&i++,c.lastMessageBy=a,c.conversationStatus=m,s++}if(s===0){console.log(" No conversations to recompute.");return}Co(n,o),console.log(` Recomputed lastMessageBy + conversationStatus on ${s} conversations.`),console.log(` ${i} had stale lastMessageBy (now corrected).`),r>0&&console.log(` Cleaned ${r} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var Lo=Fo(import.meta.url),Mo=d.dirname(Lo),Po=d.dirname(d.dirname(Mo));function Jo(e){return e&&(e==="~"?se.homedir():e.startsWith("~/")||e.startsWith("~\\")?d.join(se.homedir(),e.slice(2)):e)}var O=process.env.DATA_DIR?d.resolve(Jo(process.env.DATA_DIR)):Po,x=d.join(O,"collected-profiles"),F=d.join(O,"market-research"),S=d.join(O,".schema-version"),Ae=[d.join(x,".schema-version"),d.join(F,".schema-version")],T=3,R=[{version:1,module:ee},{version:2,module:oe},{version:3,module:ne}];(function(){R.sort((t,s)=>t.version-s.version);let n=new Set;for(let t of R){if(!Number.isInteger(t.version)||t.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(t.version)} (must be positive integer)`);if(n.has(t.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${t.version}`);n.add(t.version);let s=t.module;if(!s||typeof s.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(s.VERSION!==void 0&&s.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${s.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let o=R.length?R[R.length-1].version:0;if(o!==T)throw new Error(`MIGRATION_REGISTRY: highest version v${o} but CURRENT_SCHEMA_VERSION=${T}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<R.length;t++){let s=t+1;if(R[t].version!==s)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${s} at position ${t} but found v${R[t].version}`)}})();function Re(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
8
+ `)}`;try{await Se.addMessage(i,c)}catch(f){console.error(`[runReport] Failed to post end-of-session message: ${f.message}`)}}var yo=go(import.meta.url),So=I.dirname(I.dirname(yo)),K=process.env.DATA_DIR?I.resolve(process.env.DATA_DIR,"collected-profiles"):I.join(So,"collected-profiles"),Q=I.join(K,"run-log.json");function bo(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";w.writeFileSync(t,o);for(let s=0;s<3;s++)try{w.renameSync(t,e);return}catch(r){if(s<2&&(r.code==="EPERM"||r.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw r}}function ve(){try{if(!w.existsSync(Q))return{runs:[]};let e=JSON.parse(w.readFileSync(Q,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function we(e){w.existsSync(K)||w.mkdirSync(K,{recursive:!0});try{bo(Q,e)}catch(n){console.error(`[!] Failed to save run-log.json: ${n.message}`)}}function $e(e,n="default"){let o=ve();for(let i of o.runs)i.status==="running"&&(i.status="interrupted",i.result="interrupted",i.timestamp&&(i.duration=Date.now()-new Date(i.timestamp).getTime()));let t=new Date,s={timestamp:t.toISOString(),script:e,mode:n,status:"running",result:null,duration:null,stats:null,error:null};o.runs.push(s);let r=Date.now()-30*24*60*60*1e3;return o.runs=o.runs.filter(i=>new Date(i.timestamp).getTime()>r),we(o),{script:e,mode:n,startTime:t.getTime(),runIndex:o.runs.length-1}}function z(e,n,o=null,t=null){if(!e)return;let s=null;try{let i=ve(),u=i.runs[e.runIndex];if(u&&u.status==="running"&&u.script===e.script)u.status=n,u.result=n,u.duration=Date.now()-e.startTime,u.stats=o,u.error=t,s=u.duration;else{let c=i.runs.find(f=>f.script===e.script&&f.status==="running"&&f.timestamp===new Date(e.startTime).toISOString());c&&(c.status=n,c.result=n,c.duration=Date.now()-e.startTime,c.stats=o,c.error=t,s=c.duration)}we(i)}catch(i){console.error(`[runLog] Failed to end run: ${i.message}`)}let r=o&&Array.isArray(o.summaryLines)?o.summaryLines:null;if(r&&r.length>0&&process.env.NODE_RUN_REPORTS){let i=n==="error"?"error":o&&o.dailyLimitHit?"quota-reached":"done";be({scriptName:e.script,mode:e.mode,status:i,summaryLines:r,error:t,duration:s??Date.now()-e.startTime}).catch(u=>console.error(`[runLog] postRunReport failed: ${u.message}`))}}import"dotenv/config";import*as l from"fs";import*as se from"os";import*as d from"path";import{fileURLToPath as Lo}from"url";var ee={};G(ee,{NAME:()=>wo,VERSION:()=>vo,up:()=>Ao});import*as $ from"fs";import*as B from"path";var vo=1,wo="normalize-jobs-and-questions",$o=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],ko=50;function X(e){return $.existsSync(e)?JSON.parse($.readFileSync(e,"utf-8")):null}function Z(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{$.writeFileSync(t,o)}catch(s){try{$.unlinkSync(t)}catch{}throw s}try{$.renameSync(t,e)}catch(s){try{$.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Ao(e,n){let o=B.join(e,"jobs.json"),t=B.join(n,"scouted-jobs.json"),s=B.join(e,"application-questions.json"),r=X(o)||{},i=X(t)||{},u=0,c=[];for(let a of Object.keys(r)){if(!i[a])continue;let m=i[a],p=r[a];for(let y of $o)m[y]!=null&&p[y]==null&&(p[y]=m[y]);c.push(a),u++}u>0?(Z(o,r),console.log(` Phase 1: Merged ${u} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let f=X(s);if(f&&Array.isArray(f.applications)){let a={},m=0;for(let p of f.applications){let y=p.jobId||"unknown";a[y]||(a[y]={applications:[]});let W=(p.questions||[]).map(j=>{let M={type:j.type||"input",question:j.question||"",answer:j.answer||""};return j.options&&(j.options.length<=ko?M.options=j.options:(M.optionsOmitted=!0,m++)),j.page&&(M.page=j.page),j.wasPreFilled&&(M.wasPreFilled=!0),j.wasRetry&&(M.wasRetry=!0),M});a[y].applications.push({applicationId:p.applicationId,date:p.date,result:p.result||"submitted",formPages:p.formPages||null,duration:p.duration||null,retries:p.retries||0,failedField:p.failedField||null,questionCount:p.questionCount||W.length,questions:W})}Z(s,a),console.log(` Phase 2: Rekeyed ${f.applications.length} applications by jobId (${Object.keys(a).length} unique jobs)`),m>0&&console.log(` Phase 2: Stripped bloated options from ${m} questions`)}else f&&!f.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(c.length>0){for(let a of c)delete i[a];Z(t,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 oe={};G(oe,{NAME:()=>Eo,VERSION:()=>jo,up:()=>Io});import*as k from"fs";import*as ke from"path";var jo=2,Eo="reset-unread-flags";function Oo(e){return k.existsSync(e)?JSON.parse(k.readFileSync(e,"utf-8")):null}function Ro(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{k.writeFileSync(t,o)}catch(s){try{k.unlinkSync(t)}catch{}throw s}try{k.renameSync(t,e)}catch(s){try{k.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Io(e){let n=ke.join(e,"conversations.json"),o=Oo(n);if(!o){console.log(" conversations.json not found \u2014 nothing to reset.");return}let t=0;for(let s of Object.keys(o))o[s].unread===!0&&(o[s].unread=!1,t++);if(t===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}Ro(n,o),console.log(` Reset unread=false on ${t} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var ne={};G(ne,{NAME:()=>Do,VERSION:()=>To,up:()=>Fo});import*as A from"fs";import*as Ae from"path";var To=3,Do="recompute-last-message-by",No=new Set(["draft","confirmed","rejected","needs_review"]);function Co(e){return A.existsSync(e)?JSON.parse(A.readFileSync(e,"utf-8")):null}function _o(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{A.writeFileSync(t,o)}catch(s){try{A.unlinkSync(t)}catch{}throw s}try{A.renameSync(t,e)}catch(s){try{A.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}function xo(e,n){if(!e||e.length===0)return"them";let o=e.filter(r=>!No.has(r.status));if(o.length===0)return"them";let t=o.map(r=>({m:r,t:Date.parse(r.time)})).filter(r=>Number.isFinite(r.t)).sort((r,i)=>i.t-r.t).map(r=>r.m),s=t.length>0?t:[...o].reverse();for(let r of s){let i=r.sender;if(i===n)return"me";if(i!=="Unknown"&&i!=="")return"them"}return"them"}async function Fo(e){let n=Ae.join(e,"conversations.json"),o=Co(n);if(!o){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let t=process.env.LINKEDIN_NAME;if(!t||typeof t!="string"||!t.trim())throw new Error(`LINKEDIN_NAME env var is not set. Migration v003 needs your display name to determine which messages are yours vs theirs. Set LINKEDIN_NAME in your .env (or run "ilml plugin config linkedin set LINKEDIN_NAME 'Your Name'") and retry.`);let s=0,r=0,i=0;for(let u of Object.keys(o)){let c=o[u];if(!c||typeof c!="object")continue;Object.prototype.hasOwnProperty.call(c,"_cardSynced")&&(delete c._cardSynced,r++);let f=Array.isArray(c.messages)?c.messages:[],a=xo(f,t),m=a==="me"?"awaiting_reply":"unanswered_by_us";c.lastMessageBy!==a&&i++,c.lastMessageBy=a,c.conversationStatus=m,s++}if(s===0){console.log(" No conversations to recompute.");return}_o(n,o),console.log(` Recomputed lastMessageBy + conversationStatus on ${s} conversations.`),console.log(` ${i} had stale lastMessageBy (now corrected).`),r>0&&console.log(` Cleaned ${r} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var Mo=Lo(import.meta.url),Po=d.dirname(Mo),Jo=d.dirname(d.dirname(Po));function Uo(e){return e&&(e==="~"?se.homedir():e.startsWith("~/")||e.startsWith("~\\")?d.join(se.homedir(),e.slice(2)):e)}var E=process.env.DATA_DIR?d.resolve(Uo(process.env.DATA_DIR)):Jo,x=d.join(E,"collected-profiles"),F=d.join(E,"market-research"),S=d.join(E,".schema-version"),je=[d.join(x,".schema-version"),d.join(F,".schema-version")],T=3,R=[{version:1,module:ee},{version:2,module:oe},{version:3,module:ne}];(function(){R.sort((t,s)=>t.version-s.version);let n=new Set;for(let t of R){if(!Number.isInteger(t.version)||t.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(t.version)} (must be positive integer)`);if(n.has(t.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${t.version}`);n.add(t.version);let s=t.module;if(!s||typeof s.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(s.VERSION!==void 0&&s.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${s.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let o=R.length?R[R.length-1].version:0;if(o!==T)throw new Error(`MIGRATION_REGISTRY: highest version v${o} but CURRENT_SCHEMA_VERSION=${T}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<R.length;t++){let s=t+1;if(R[t].version!==s)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${s} at position ${t} but found v${R[t].version}`)}})();function Ie(){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{l.mkdirSync(O,{recursive:!0})}catch(n){n.code!=="EEXIST"&&(console.error(`
11
- [FATAL] Cannot create DATA_DIR (${O}): ${n.message}`),console.error(` Fix the path or permissions and try again.
12
- `),process.exit(1))}let e;try{e=l.statSync(O)}catch(n){console.error(`
13
- [FATAL] DATA_DIR (${O}) is not accessible: ${n.message}
10
+ `),process.exit(1));try{l.mkdirSync(E,{recursive:!0})}catch(n){n.code!=="EEXIST"&&(console.error(`
11
+ [FATAL] Cannot create DATA_DIR (${E}): ${n.message}`),console.error(` Fix the path or permissions and try again.
12
+ `),process.exit(1))}let e;try{e=l.statSync(E)}catch(n){console.error(`
13
+ [FATAL] DATA_DIR (${E}) is not accessible: ${n.message}
14
14
  `),process.exit(1)}e.isDirectory()||(console.error(`
15
- [FATAL] DATA_DIR (${O}) 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.
15
+ [FATAL] DATA_DIR (${E}) 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
16
  `),process.exit(1));for(let n of[x,F]){let o;try{o=l.lstatSync(n)}catch(t){if(t.code==="ENOENT")continue;throw t}o.isSymbolicLink()&&(console.error(`
17
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 _=d.join(O,".migration-lock");function Uo(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return l.writeFileSync(_,e,{flag:"wx"}),!0}catch(t){if(t.code!=="EEXIST")throw t}let n;try{n=JSON.parse(l.readFileSync(_,"utf-8"))}catch{n=null}if(n&&Number.isInteger(n.pid)){let t=!1;try{process.kill(n.pid,0),t=!0}catch(i){i.code==="EPERM"&&(t=!0)}let s=24*60*60*1e3,r=1/0;if(n.startedAt){let i=Date.parse(n.startedAt);Number.isNaN(i)||(r=Date.now()-i)}t&&r<s&&(console.error(`
18
+ `),process.exit(1))}}var _=d.join(E,".migration-lock");function Bo(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return l.writeFileSync(_,e,{flag:"wx"}),!0}catch(t){if(t.code!=="EEXIST")throw t}let n;try{n=JSON.parse(l.readFileSync(_,"utf-8"))}catch{n=null}if(n&&Number.isInteger(n.pid)){let t=!1;try{process.kill(n.pid,0),t=!0}catch(i){i.code==="EPERM"&&(t=!0)}let s=24*60*60*1e3,r=1/0;if(n.startedAt){let i=Date.parse(n.startedAt);Number.isNaN(i)||(r=Date.now()-i)}t&&r<s&&(console.error(`
19
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: ${_}
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)),t&&r>=s&&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 o=_+".tmp";try{return l.writeFileSync(o,e),l.renameSync(o,_),!0}catch(t){try{l.unlinkSync(o)}catch{}throw new Error(`Failed to take over stale migration lock: ${t.message}`)}}function re(){try{if(JSON.parse(l.readFileSync(_,"utf-8")).pid!==process.pid)return;l.unlinkSync(_)}catch{}}var je=!1;function Bo(){if(je)return;je=!0;let e=()=>{try{re()}catch{}process.exit(1)};for(let n of["SIGINT","SIGTERM","SIGHUP"])try{process.on(n,e)}catch{}}function qo(){if(l.existsSync(S))return;let e=[],n=[];for(let r of Ae)if(l.existsSync(r))try{e.push({file:r,schema:q(r)})}catch(i){n.push({file:r,err:i.message})}if(n.length>0){console.error(`
21
+ `),process.exit(1)),t&&r>=s&&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 o=_+".tmp";try{return l.writeFileSync(o,e),l.renameSync(o,_),!0}catch(t){try{l.unlinkSync(o)}catch{}throw new Error(`Failed to take over stale migration lock: ${t.message}`)}}function re(){try{if(JSON.parse(l.readFileSync(_,"utf-8")).pid!==process.pid)return;l.unlinkSync(_)}catch{}}var Ee=!1;function qo(){if(Ee)return;Ee=!0;let e=()=>{try{re()}catch{}process.exit(1)};for(let n of["SIGINT","SIGTERM","SIGHUP"])try{process.on(n,e)}catch{}}function Vo(){if(l.existsSync(S))return;let e=[],n=[];for(let r of je)if(l.existsSync(r))try{e.push({file:r,schema:q(r)})}catch(i){n.push({file:r,err:i.message})}if(n.length>0){console.error(`
22
22
  [FATAL] Legacy .schema-version file(s) corrupted \u2014 cannot determine current schema version:`);for(let r of n)console.error(` ${r.file}: ${r.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
24
  `),process.exit(1)}if(e.length===0)return;let o=e.map(r=>r.schema.version);if(new Set(o).size>1){console.error(`
25
25
  [FATAL] Legacy .schema-version files disagree:`);for(let r of e)console.error(` ${r.file}: v${r.schema.version}`);console.error(" This means a previous migration crashed between writing the two files."),console.error(` Reconcile manually (delete the wrong one, keep the right one), then re-run.
26
- `),process.exit(1)}let t=e[0].schema,s=S+".tmp";try{l.writeFileSync(s,JSON.stringify(t,null,2)),l.renameSync(s,S)}catch(r){try{l.unlinkSync(s)}catch{}throw r}for(let r of Ae)if(l.existsSync(r))try{l.unlinkSync(r)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${S}`)}function Vo(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=l.readFileSync(e,"utf-8");return n.charCodeAt(0)===65279&&(n=n.slice(1)),JSON.parse(n)}function Oe(){if(qo(),!l.existsSync(S))return{version:0,migrations:[]};let e;try{e=q(S)}catch(o){if(o.code==="ENOENT")return{version:0,migrations:[]};console.error(`
26
+ `),process.exit(1)}let t=e[0].schema,s=S+".tmp";try{l.writeFileSync(s,JSON.stringify(t,null,2)),l.renameSync(s,S)}catch(r){try{l.unlinkSync(s)}catch{}throw r}for(let r of je)if(l.existsSync(r))try{l.unlinkSync(r)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${S}`)}function Wo(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=l.readFileSync(e,"utf-8");return n.charCodeAt(0)===65279&&(n=n.slice(1)),JSON.parse(n)}function Oe(){if(Vo(),!l.existsSync(S))return{version:0,migrations:[]};let e;try{e=q(S)}catch(o){if(o.code==="ENOENT")return{version:0,migrations:[]};console.error(`
27
27
  [FATAL] ${S} is not valid JSON: ${o.message}`),console.error(" Refusing to proceed \u2014 silently treating it as 'fresh install' would re-apply"),console.error(" every migration on top of already-migrated data and corrupt it."),console.error(' Repair the file (set it to {"version":N,"migrations":[...]} matching your real state)'),console.error(` or restore from the *.pre-vNNN.backup files if you have them.
28
- `),process.exit(1)}let n=Vo(e);return n===null&&(console.error(`
28
+ `),process.exit(1)}let n=Wo(e);return n===null&&(console.error(`
29
29
  [FATAL] ${S} 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 Ie(e){try{l.chmodSync(e,384)}catch{}}function Wo(e){if(Re(),l.existsSync(S))try{if(l.lstatSync(S).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${S}. Refusing to write through it (potential symlink attack). Remove the link and re-run.`)}catch(o){if(o.message?.includes("symbolic link"))throw o}let n=S+".tmp";try{l.writeFileSync(n,JSON.stringify(e,null,2)),Ie(n),l.renameSync(n,S)}catch(o){try{l.unlinkSync(n)}catch{}throw o}}function Ee(e,n){if(!l.existsSync(e))return;let o=`.pre-v${String(n).padStart(3,"0")}.backup`,t=l.readdirSync(e).filter(u=>{let c=u.toLowerCase();if(c.includes(".backup")||c===".schema-version"||c.endsWith(".tmp"))return!1;try{return l.statSync(d.join(e,u)).isFile()}catch{return!1}}),s=0,r=0,i=[];for(let u of t){let c=d.join(e,u),f=d.join(e,u+o);if(l.existsSync(f)){r++;continue}try{De(c,f),s++}catch(a){i.push({file:u,err:a.message})}}if(i.length>0){let u=new Error(`Failed to back up ${i.length} file(s) in ${d.basename(e)}/: `+i.map(c=>`${c.file} (${c.err})`).join(", "));throw u.code="BACKUP_INCOMPLETE",u}if(s>0||r>0){let u=r>0?` (${r} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${s} files in ${d.basename(e)}/ (${o})${u}`)}}var te=!1;async function Te(){if(te)return;Re(),Qo();let n=Oe().version;if(n===T){te=!0;return}Bo(),Uo(),process.on("exit",re),n>T&&(console.error(`
30
+ `),process.exit(1)),n}function Te(e){try{l.chmodSync(e,384)}catch{}}function Go(e){if(Ie(),l.existsSync(S))try{if(l.lstatSync(S).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${S}. Refusing to write through it (potential symlink attack). Remove the link and re-run.`)}catch(o){if(o.message?.includes("symbolic link"))throw o}let n=S+".tmp";try{l.writeFileSync(n,JSON.stringify(e,null,2)),Te(n),l.renameSync(n,S)}catch(o){try{l.unlinkSync(n)}catch{}throw o}}function Re(e,n){if(!l.existsSync(e))return;let o=`.pre-v${String(n).padStart(3,"0")}.backup`,t=l.readdirSync(e).filter(u=>{let c=u.toLowerCase();if(c.includes(".backup")||c===".schema-version"||c.endsWith(".tmp"))return!1;try{return l.statSync(d.join(e,u)).isFile()}catch{return!1}}),s=0,r=0,i=[];for(let u of t){let c=d.join(e,u),f=d.join(e,u+o);if(l.existsSync(f)){r++;continue}try{Ne(c,f),s++}catch(a){i.push({file:u,err:a.message})}}if(i.length>0){let u=new Error(`Failed to back up ${i.length} file(s) in ${d.basename(e)}/: `+i.map(c=>`${c.file} (${c.err})`).join(", "));throw u.code="BACKUP_INCOMPLETE",u}if(s>0||r>0){let u=r>0?` (${r} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${s} files in ${d.basename(e)}/ (${o})${u}`)}}var te=!1;async function De(){if(te)return;Ie(),zo();let n=Oe().version;if(n===T){te=!0;return}qo(),Bo(),process.on("exit",re),n>T&&(console.error(`
31
31
  [FATAL] Your data schema is at v${n}, but this plugin build only understands up to v${T}.`),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${T}.
33
33
  `),process.exit(1)),console.log(`
34
- \u{1F4E6} Schema migration: v${n} \u2192 v${T}`);let o=zo();if(!o.ok){console.error(`
34
+ \u{1F4E6} Schema migration: v${n} \u2192 v${T}`);let o=Xo();if(!o.ok){console.error(`
35
35
  [FATAL] Cannot migrate \u2014 current data is corrupted:`);for(let s of o.broken)console.error(` ${s.dir}/${s.file}: ${s.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
37
  `),process.exit(1)}let t=R.filter(s=>s.version>n);for(let s of t){console.log(`
38
- Running migration v${String(s.version).padStart(3,"0")}...`);let r=`v${String(s.version).padStart(3,"0")}`,i=`.pre-${r}.backup`;try{Ee(x,s.version),Ee(F,s.version)}catch(c){console.error(`
38
+ Running migration v${String(s.version).padStart(3,"0")}...`);let r=`v${String(s.version).padStart(3,"0")}`,i=`.pre-${r}.backup`;try{Re(x,s.version),Re(F,s.version)}catch(c){console.error(`
39
39
  [FATAL] Pre-migration backup failed for ${r}: ${c.message}`),console.error(" Migration NOT applied. Repair the underlying issue (disk space, permissions, locked files)"),console.error(` and re-run the plugin command.
40
40
  `),process.exit(1)}let u=s.module;try{await u.up(x,F)}catch(c){console.error(`
41
- [FATAL] Migration ${r} failed: ${c.message}`),console.error(` Attempting auto-rollback from ${i} files...`);try{let f=Xo(i);f.ok?(console.error(` \u2713 Auto-rollback restored ${f.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 ${r} failed: ${c.message}`),console.error(` Attempting auto-rollback from ${i} files...`);try{let f=Zo(i);f.ok?(console.error(` \u2713 Auto-rollback restored ${f.restored} files. Schema stays at v${n}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
42
42
  `)):(console.error(` [!] Auto-rollback INCOMPLETE: ${f.error}`),console.error(` Manual recovery: copy *${i} files back over the originals.
43
43
  `))}catch(f){console.error(` [!] Auto-rollback CRASHED while restoring: ${f.message}`),console.error(` Manual recovery: copy *${i} files back over the originals.
44
- `)}process.exit(1)}try{let c=new Date().toISOString(),f={version:s.version,name:u.NAME||r,appliedAt:c},a=Oe();a.version=s.version,a.migratedAt=c,a.migrations=a.migrations||[],a.migrations.push(f),Wo(a)}catch(c){console.error(`
44
+ `)}process.exit(1)}try{let c=new Date().toISOString(),f={version:s.version,name:u.NAME||r,appliedAt:c},a=Oe();a.version=s.version,a.migratedAt=c,a.migrations=a.migrations||[],a.migrations.push(f),Go(a)}catch(c){console.error(`
45
45
  [FATAL] Migration ${r} applied successfully but schema version file could NOT be updated: ${c.message}`),console.error(` Your data is in the v${s.version} state but .schema-version still shows v${n}.`),console.error(` On next plugin command the runner will try to re-apply ${r}. If that migration is`),console.error(` idempotent (most are), it will succeed harmlessly. If you're unsure, run 'data-cleanup' and contact support.
46
- `),process.exit(1)}console.log(` \u2713 Migration ${r} complete`)}try{le()}catch{}try{pe()}catch{}te=!0,re(),console.log(`
46
+ `),process.exit(1)}console.log(` \u2713 Migration ${r} complete`)}try{ae()}catch{}try{de()}catch{}te=!0,re(),console.log(`
47
47
  \u2713 Schema is now at v${T}
48
- `)}var Go=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function Yo(e){let n=e.toLowerCase();return Go.some(o=>o.test(n))}var Ho=6e4;function Ko(){let e=Date.now(),n=[];for(let o of[O,x,F]){if(!l.existsSync(o))continue;let t;try{t=l.readdirSync(o)}catch{continue}for(let s of t){if(!Yo(s))continue;let r=d.join(o,s);try{let i=l.statSync(r);if(!i.isFile()||e-i.mtimeMs<Ho)continue;n.push({dir:o,file:s,fullPath:r})}catch{}}}return n}function Qo({verbose:e=!1}={}){let n=Ko();if(n.length===0)return e&&console.log(" No orphan .tmp files found."),0;let o=0;for(let t of n)try{l.unlinkSync(t.fullPath),o++,e&&console.log(` Removed orphan: ${d.basename(t.dir)}/${t.file}`)}catch(s){console.warn(` [!] Could not remove orphan ${t.fullPath}: ${s.message}`)}return!e&&o>0&&console.log(` Cleaned up ${o} orphan .tmp file(s) from previous run.`),o}function zo(){let e=[];for(let n of[x,F]){if(!l.existsSync(n))continue;let o=l.readdirSync(n).filter(t=>{let s=t.toLowerCase();return s.endsWith(".json")&&!s.includes(".backup")});for(let t of o){let s=d.join(n,t);try{q(s)}catch(r){e.push({dir:d.basename(n),file:t,err:r.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function Xo(e){let n=[],o=[];for(let r of[x,F]){if(!l.existsSync(r))continue;let i=l.readdirSync(r).filter(u=>u.endsWith(e));for(let u of i){let c=d.join(r,u),f=u.slice(0,-e.length),a=d.join(r,f);try{f.toLowerCase().endsWith(".json")?q(c):l.accessSync(c,l.constants.R_OK),n.push({backupPath:c,originalPath:a,fileName:u,dir:r})}catch(m){o.push(`${d.basename(r)}/${u}: ${m.message}`)}}}if(o.length>0)return{ok:!1,error:o.join("; "),restored:0};let t=0,s=[];for(let{backupPath:r,originalPath:i,fileName:u,dir:c}of n)try{De(r,i),t++}catch(f){s.push(`${d.basename(c)}/${u}: ${f.message}`)}return s.length>0?{ok:!1,error:s.join("; "),restored:t}:{ok:!0,restored:t}}function De(e,n){let o=n+".tmp";try{l.copyFileSync(e,o),Ie(o)}catch(t){try{l.unlinkSync(o)}catch{}throw t}try{l.renameSync(o,n)}catch(t){try{l.unlinkSync(o)}catch{}if(t.code==="EPERM"||t.code==="EBUSY"){let s=new Error(`File locked: ${n} (${t.code}). On Windows this is usually antivirus / Search Indexer / the file open in another app. Close anything that might be holding it and re-run.`);throw s.code=t.code,s}throw t}}var on=Zo(import.meta.url),nn=L.dirname(on),ie=process.env.DATA_DIR?L.resolve(process.env.DATA_DIR,"collected-profiles"):L.join(nn,"collected-profiles");await Te();var ce=process.argv.slice(2),Ne=parseInt(ce.find(e=>e.startsWith("--max="))?.split("=")[1]||"50"),V=parseInt(ce.find(e=>e.startsWith("--min-score="))?.split("=")[1]||"50"),tn=ce.includes("--list");function sn(){let n=H(20,{easyApplyOnly:!0}).filter(o=>o.score>=V);if(console.log(`
48
+ `)}var Yo=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function Ho(e){let n=e.toLowerCase();return Yo.some(o=>o.test(n))}var Ko=6e4;function Qo(){let e=Date.now(),n=[];for(let o of[E,x,F]){if(!l.existsSync(o))continue;let t;try{t=l.readdirSync(o)}catch{continue}for(let s of t){if(!Ho(s))continue;let r=d.join(o,s);try{let i=l.statSync(r);if(!i.isFile()||e-i.mtimeMs<Ko)continue;n.push({dir:o,file:s,fullPath:r})}catch{}}}return n}function zo({verbose:e=!1}={}){let n=Qo();if(n.length===0)return e&&console.log(" No orphan .tmp files found."),0;let o=0;for(let t of n)try{l.unlinkSync(t.fullPath),o++,e&&console.log(` Removed orphan: ${d.basename(t.dir)}/${t.file}`)}catch(s){console.warn(` [!] Could not remove orphan ${t.fullPath}: ${s.message}`)}return!e&&o>0&&console.log(` Cleaned up ${o} orphan .tmp file(s) from previous run.`),o}function Xo(){let e=[];for(let n of[x,F]){if(!l.existsSync(n))continue;let o=l.readdirSync(n).filter(t=>{let s=t.toLowerCase();return s.endsWith(".json")&&!s.includes(".backup")});for(let t of o){let s=d.join(n,t);try{q(s)}catch(r){e.push({dir:d.basename(n),file:t,err:r.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function Zo(e){let n=[],o=[];for(let r of[x,F]){if(!l.existsSync(r))continue;let i=l.readdirSync(r).filter(u=>u.endsWith(e));for(let u of i){let c=d.join(r,u),f=u.slice(0,-e.length),a=d.join(r,f);try{f.toLowerCase().endsWith(".json")?q(c):l.accessSync(c,l.constants.R_OK),n.push({backupPath:c,originalPath:a,fileName:u,dir:r})}catch(m){o.push(`${d.basename(r)}/${u}: ${m.message}`)}}}if(o.length>0)return{ok:!1,error:o.join("; "),restored:0};let t=0,s=[];for(let{backupPath:r,originalPath:i,fileName:u,dir:c}of n)try{Ne(r,i),t++}catch(f){s.push(`${d.basename(c)}/${u}: ${f.message}`)}return s.length>0?{ok:!1,error:s.join("; "),restored:t}:{ok:!0,restored:t}}function Ne(e,n){let o=n+".tmp";try{l.copyFileSync(e,o),Te(o)}catch(t){try{l.unlinkSync(o)}catch{}throw t}try{l.renameSync(o,n)}catch(t){try{l.unlinkSync(o)}catch{}if(t.code==="EPERM"||t.code==="EBUSY"){let s=new Error(`File locked: ${n} (${t.code}). On Windows this is usually antivirus / Search Indexer / the file open in another app. Close anything that might be holding it and re-run.`);throw s.code=t.code,s}throw t}}var nn=en(import.meta.url),tn=L.dirname(nn),ie=process.env.DATA_DIR?L.resolve(process.env.DATA_DIR,"collected-profiles"):L.join(tn,"collected-profiles");await De();var ce=process.argv.slice(2),Ce=parseInt(ce.find(e=>e.startsWith("--max="))?.split("=")[1]||"50"),V=parseInt(ce.find(e=>e.startsWith("--min-score="))?.split("=")[1]||"50"),sn=ce.includes("--list");function rn(){let n=H(20,{easyApplyOnly:!0}).filter(o=>o.score>=V);if(console.log(`
49
49
  \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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(` APPLY QUEUE (${n.length} jobs, min score ${V})`),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"),n.length===0)console.log(" No jobs in queue. Run: npm run scout");else for(let o=0;o<n.length;o++){let{score:t,job:s,jobId:r}=n[o],i=(s.techStack||[]).slice(0,4).join(", ");console.log(` ${String(o+1).padStart(2)}. [${t}] ${(s.title||"?").slice(0,35)} @ ${(s.company||"?").slice(0,20)}`),console.log(` ${s.salary||"no salary"} | ${s.location||"?"} | ${i||"no tech"}`),console.log(` ${s.url}`)}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
50
- `)}async function rn(){if(console.log(`
50
+ `)}async function cn(){if(console.log(`
51
51
  LinkedIn Apply Queue
52
- `),tn){sn();return}let n=H(Ne*3,{easyApplyOnly:!0}).filter(r=>r.score>=V).slice(0,Ne);if(n.length===0){console.log(` No jobs to apply. Run: npm run scout
52
+ `),sn){rn();return}let n=H(Ce*3,{easyApplyOnly:!0}).filter(r=>r.score>=V).slice(0,Ce);if(n.length===0){console.log(` No jobs to apply. Run: npm run scout
53
53
  `);return}console.log(` Applying to ${n.length} jobs (score >= ${V}):
54
54
  `);for(let{score:r,job:i}of n)console.log(` [${r}] ${(i.title||"?").slice(0,40)} @ ${(i.company||"?").slice(0,20)}`);D.existsSync(ie)||D.mkdirSync(ie,{recursive:!0});let o=L.join(ie,"apply-queue-urls.json"),t=n.map(({job:r,jobId:i})=>({url:r.url,title:r.title,company:r.company,location:r.location,salary:r.salary}));D.writeFileSync(o,JSON.stringify(t,null,2)),console.log(`
55
- Generated ${o} with ${t.length} jobs`);for(let{jobId:r}of n)de(r,{queued:!0,queuedAt:new Date().toISOString().slice(0,10)});let s=we("apply-queue",`${n.length} jobs`);console.log(`
55
+ Generated ${o} with ${t.length} jobs`);for(let{jobId:r}of n)me(r,{queued:!0,queuedAt:new Date().toISOString().slice(0,10)});let s=$e("apply-queue",`${n.length} jobs`);console.log(`
56
56
  Launching run.mjs --job-urls...
57
- `);try{en("node",["run.mjs",`--job-urls=${o}`],{stdio:"inherit",timeout:144e5}),z(s,"success",{applied:n.length})}catch(r){console.error(`
58
- Apply queue error: ${r.message?.slice(0,80)}`),z(s,"error",{applied:n.length},r.message)}try{D.unlinkSync(o)}catch{}}rn().catch(e=>{console.error("Apply queue failed:",e),process.exit(1)});
57
+ `);try{on("node",["run.mjs",`--job-urls=${o}`],{stdio:"inherit",timeout:144e5}),z(s,"success",{applied:n.length})}catch(r){console.error(`
58
+ Apply queue error: ${r.message?.slice(0,80)}`),z(s,"error",{applied:n.length},r.message)}try{D.unlinkSync(o)}catch{}}cn().catch(e=>{console.error("Apply queue failed:",e),process.exit(1)});