module.exports=[14747,(e,t,n)=>{t.exports=e.x("path",()=>require("path"))},12714,(e,t,n)=>{t.exports=e.x("node:fs/promises",()=>require("node:fs/promises"))},2157,(e,t,n)=>{t.exports=e.x("node:fs",()=>require("node:fs"))},60526,(e,t,n)=>{t.exports=e.x("node:os",()=>require("node:os"))},50227,(e,t,n)=>{t.exports=e.x("node:path",()=>require("node:path"))},22734,(e,t,n)=>{t.exports=e.x("fs",()=>require("fs"))},85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",()=>require("better-sqlite3-90e2652d1716b047"))},43793,77930,e=>{"use strict";var t=e.i(85148),n=e.i(14747),s=e.i(22734);function a(){return process.env.VIBEMETER_DATA_DIR??n.default.join(process.cwd(),".data")}e.s(["dataDir",0,a],77930);let i=null;e.s(["getDb",0,function(){var e;let r;if(i)return i;let o=a();return s.default.mkdirSync(o,{recursive:!0}),(i=new t.default(n.default.join(o,"continuity.sqlite"))).pragma("journal_mode = WAL"),(e=i).exec(`
    CREATE TABLE IF NOT EXISTS sessions (
      id TEXT PRIMARY KEY,
      tool TEXT NOT NULL,
      started_at INTEGER NOT NULL,
      ended_at INTEGER,
      exit_code INTEGER,
      cwd TEXT,
      cli_args TEXT,
      summary TEXT,
      confidence TEXT NOT NULL DEFAULT 'medium'
    );

    CREATE TABLE IF NOT EXISTS usage_snapshots (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      captured_at INTEGER NOT NULL,
      source TEXT NOT NULL,
      account_id TEXT,
      window_5h_used_pct REAL,
      window_weekly_used_pct REAL,
      reset_at_5h INTEGER,
      reset_at_weekly INTEGER,
      raw_output TEXT,
      confidence TEXT NOT NULL
    );

    CREATE TABLE IF NOT EXISTS file_changes (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      session_id TEXT NOT NULL,
      path TEXT NOT NULL,
      change_type TEXT NOT NULL,
      detected_at INTEGER NOT NULL,
      FOREIGN KEY (session_id) REFERENCES sessions(id)
    );
  `),(r=(t,n,s)=>{try{e.exec(`ALTER TABLE ${t} ADD COLUMN ${n} ${s}`)}catch{}})("sessions","ai_title","TEXT"),r("sessions","tags",'TEXT DEFAULT "[]"'),r("sessions","codex_category","TEXT"),r("sessions","tokens_used","INTEGER"),r("usage_snapshots","account_id","TEXT"),e.exec(`
    CREATE INDEX IF NOT EXISTS idx_sessions_started ON sessions(started_at DESC);
    CREATE INDEX IF NOT EXISTS idx_usage_captured ON usage_snapshots(captured_at DESC);
    CREATE INDEX IF NOT EXISTS idx_usage_source_account_captured ON usage_snapshots(source, account_id, captured_at DESC);
  `),i}],43793)},81149,e=>{"use strict";e.s(["getLatestUsageSnapshot",0,function(e,t,n){return(null!=n?e.prepare(`
        SELECT id, captured_at, source, account_id, window_5h_used_pct, window_weekly_used_pct,
               reset_at_5h, reset_at_weekly, raw_output, confidence
        FROM usage_snapshots
        WHERE source = ? AND account_id = ?
        ORDER BY captured_at DESC
        LIMIT 1
      `).get(t,n):e.prepare(`
        SELECT id, captured_at, source, account_id, window_5h_used_pct, window_weekly_used_pct,
               reset_at_5h, reset_at_weekly, raw_output, confidence
        FROM usage_snapshots
        WHERE source = ?
        ORDER BY captured_at DESC
        LIMIT 1
      `).get(t))??null},"insertUsageSnapshot",0,function(e,t){e.prepare(`
    INSERT INTO usage_snapshots
      (captured_at, source, account_id, window_5h_used_pct, window_weekly_used_pct,
       reset_at_5h, reset_at_weekly, raw_output, confidence)
    VALUES
      (@captured_at, @source, @account_id, @window_5h_used_pct, @window_weekly_used_pct,
       @reset_at_5h, @reset_at_weekly, @raw_output, @confidence)
  `).run({captured_at:t.capturedAt,source:t.source,account_id:t.accountId,window_5h_used_pct:t.window5hUsedPct,window_weekly_used_pct:t.windowWeeklyUsedPct,reset_at_5h:t.resetAt5h,reset_at_weekly:t.resetAtWeekly,raw_output:t.rawOutput,confidence:t.confidence})}])},46023,e=>{"use strict";var t=e.i(12714),n=e.i(2157),s=e.i(60526),a=e.i(50227);let i="https://api.openai.com/auth";function r(e={}){return{authPath:e.authPath??a.default.join((0,s.homedir)(),".codex","auth.json"),storeDir:e.storeDir??a.default.join((0,s.homedir)(),".codex","auth-accounts")}}function o(e,t){return a.default.join(t,`${e.replace(/[^a-zA-Z0-9_-]/g,"_")}.json`)}async function d(e){let n=JSON.parse(await (0,t.readFile)(e,"utf8"));if(!n.tokens||"string"!=typeof n.tokens.account_id)throw Error("Codex auth file is missing tokens.account_id");return n}async function l(e,n){await (0,t.mkdir)(a.default.dirname(e),{recursive:!0});let s=`${e}.${process.pid}.${Date.now()}.tmp`;await (0,t.writeFile)(s,`${JSON.stringify(n,null,2)}
`,{encoding:"utf8",mode:384}),await (0,t.rename)(s,e)}function c(e){if("string"!=typeof e)return null;let[,t]=e.split(".");if(!t)return null;try{return JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{return null}}function u(e){return"string"==typeof e&&e.length>0?e:null}function _(e){return"number"==typeof e?new Date(1e3*e).toISOString():null}function p(e,t,n){let s=u(e.tokens?.account_id);if(!s)throw Error("Codex auth file is missing tokens.account_id");let a=c(e.tokens?.id_token),r=c(e.tokens?.access_token),o=a?.[i],d=r?.[i],l=u(a?.email),p=u(a?.name),f=u(o?.chatgpt_plan_type)??u(d?.chatgpt_plan_type),w=u(o?.user_id)??u(d?.user_id),E=l??p??`${s.slice(0,8)}...${s.slice(-4)}`;return{accountId:s,label:E,email:l,name:p,planType:f,userId:w,lastRefresh:u(e.last_refresh),idTokenExpiresAt:_(a?.exp),accessTokenExpiresAt:_(r?.exp),storedAt:t,isCurrent:s===n}}async function f(e={}){let{authPath:n,storeDir:s}=r(e),i=null,o=null;try{o=await d(n),i=u(o.tokens?.account_id)}catch{o=null}let l=new Map;try{for(let e of(await (0,t.readdir)(s))){if(!e.endsWith(".json"))continue;let n=a.default.join(s,e);try{let e=await d(n),s=await (0,t.stat)(n),a=p(e,s.mtime.toISOString(),i);l.set(a.accountId,a)}catch{}}}catch{}return o&&i&&!l.has(i)&&l.set(i,p(o,null,i)),[...l.values()].sort((e,t)=>e.isCurrent!==t.isCurrent?e.isCurrent?-1:1:e.label.localeCompare(t.label))}async function w(e={}){let{authPath:n,storeDir:s}=r(e),a=await d(n),i=a.tokens?.account_id,c=o(i,s);return await l(c,a),p(a,(await (0,t.stat)(c)).mtime.toISOString(),i)}async function E(e,n={}){let{authPath:s,storeDir:a}=r(n),i=o(e,a),c=await d(i);if(c.tokens?.account_id!==e)throw Error("Stored account id does not match requested account");let u=null;try{let e=await (0,t.readFile)(s,"utf8");u=`${s}.${new Date().toISOString().replace(/[:.]/g,"-")}.bak`,await (0,t.writeFile)(u,e,{encoding:"utf8",mode:384})}catch{u=null}return await l(s,c),{...p(c,null,e),backupPath:u}}async function h(e,n={}){let{authPath:s,storeDir:a}=r(n),i=await d(s).catch(()=>null);if(i?.tokens?.account_id===e)throw Error("Cannot delete the currently active Codex account");await (0,t.unlink)(o(e,a))}e.s(["deleteCodexAccount",0,h,"getCodexAccounts",0,f,"getCurrentCodexAccount",0,function(e={}){let{authPath:t}=r(e);try{let e=JSON.parse((0,n.readFileSync)(t,"utf8")),s=u(e.tokens?.account_id);if(!s)return null;return{accountId:s,authMtimeMs:(0,n.statSync)(t).mtimeMs}}catch{return null}},"importCurrentCodexAuth",0,w,"switchCodexAccount",0,E])},46786,(e,t,n)=>{t.exports=e.x("os",()=>require("os"))},80909,e=>{"use strict";var t=e.i(22734),n=e.i(14747),s=e.i(46786),a=e.i(43793),i=e.i(69719);let r=i.z.object({timestamp:i.z.string().optional(),sessionId:i.z.string().optional(),cwd:i.z.string().optional(),gitBranch:i.z.string().optional(),version:i.z.string().optional(),type:i.z.string()}).passthrough(),o=i.z.object({type:i.z.literal("ai-title"),aiTitle:i.z.string(),sessionId:i.z.string()});var d=e.i(77930);let l=n.default.join((0,d.dataDir)(),"statusline-latest.json"),c=i.z.object({session_id:i.z.string().optional(),session_name:i.z.string().optional(),transcript_path:i.z.string().optional(),cwd:i.z.string().optional(),model:i.z.object({id:i.z.string(),display_name:i.z.string()}).optional(),cost:i.z.object({total_cost_usd:i.z.number()}).optional(),context_window:i.z.object({total_input_tokens:i.z.number(),total_output_tokens:i.z.number(),used_percentage:i.z.number()}).optional(),rate_limits:i.z.object({five_hour:i.z.object({used_percentage:i.z.number(),resets_at:i.z.number().optional()}).optional(),seven_day:i.z.object({used_percentage:i.z.number(),resets_at:i.z.number().optional()}).optional()}).optional()}).passthrough(),u=n.default.join(s.default.homedir(),".codex","sessions"),_=n.default.join(s.default.homedir(),".codex"),p=n.default.join(_,"state_5.sqlite"),f=n.default.join(_,"history.jsonl"),w=n.default.join(s.default.homedir(),"Library/Application Support/Cursor/User"),E=n.default.join(w,"workspaceStorage"),h=n.default.join(w,"globalStorage/state.vscdb");var T=e.i(46023),m=e.i(81149);let y=n.default.join(s.default.homedir(),".claude"),S=n.default.join(y,"projects"),g=n.default.join(y,"sessions");e.s(["importSessions",0,function(){let s=(0,a.getDb)(),i=function(){let e=new Set;try{for(let s of t.default.readdirSync(g))if(s.endsWith(".json"))try{let a=t.default.readFileSync(n.default.join(g,s),"utf8"),i=JSON.parse(a);i.sessionId&&e.add(i.sessionId)}catch{}}catch{}return e}(),d=function(){let e=[];try{for(let s of t.default.readdirSync(S)){let a=n.default.join(S,s);try{if(!t.default.statSync(a).isDirectory())continue;for(let s of t.default.readdirSync(a))s.endsWith(".jsonl")&&e.push(n.default.join(a,s))}catch{}}}catch{}return e}(),_=s.prepare(`
    INSERT INTO sessions (id, tool, started_at, ended_at, exit_code, cwd, cli_args, summary, ai_title, confidence)
    VALUES (@id, @tool, @started_at, @ended_at, @exit_code, @cwd, @cli_args, @summary, @ai_title, @confidence)
    ON CONFLICT(id) DO UPDATE SET
      ended_at   = excluded.ended_at,
      exit_code  = excluded.exit_code,
      ai_title   = COALESCE(sessions.ai_title, excluded.ai_title),
      confidence = excluded.confidence
  `),w=0,y=0;s.transaction(()=>{for(let e of d){let n=function(e){let n;try{n=t.default.readFileSync(e,"utf8")}catch{return null}let s=n.split("\n").filter(Boolean);if(0===s.length)return null;let a=e.split("/").pop()?.replace(".jsonl","")??null;if(!a)return null;let i=null,d=null,l=null,c=null,u=null,_=null;for(let e of s){let t;try{t=JSON.parse(e)}catch{continue}let n=r.safeParse(t);if(!n.success)continue;let s=n.data;if(s.timestamp){let e=new Date(s.timestamp).getTime();!Number.isNaN(e)&&((null===c||e<c)&&(c=e),(null===u||e>u)&&(u=e))}if(!i&&s.cwd&&(i=s.cwd),!d&&s.gitBranch&&(d=s.gitBranch),!l&&s.version&&(l=s.version),"ai-title"===s.type){let e=o.safeParse(t);e.success&&(_=e.data.aiTitle)}}return{sessionId:a,cwd:i,gitBranch:d,version:l,startedAt:c,lastSeenAt:u,aiTitle:_}}(e);if(!n||!n.startedAt){y++;continue}let s=i.has(n.sessionId);_.run({id:n.sessionId,tool:"claude-code",started_at:n.startedAt,ended_at:s?null:n.lastSeenAt,exit_code:null,cwd:n.cwd,cli_args:null,summary:null,ai_title:n.aiTitle,confidence:"high"}),w++}})(),!function(){if(!t.default.existsSync(p))return!1;try{let t=new(e.r(85148))(p,{readonly:!0}),n=t.prepare(`
      SELECT id, created_at_ms, updated_at_ms, cwd, title, first_user_message,
             tokens_used, git_branch, model, archived
      FROM threads
      ORDER BY created_at_ms ASC
    `).all(),s=(0,a.getDb)(),i=s.prepare(`
      INSERT INTO sessions (id, tool, started_at, ended_at, cwd, ai_title, tokens_used, confidence)
      VALUES (@id, 'codex', @started_at, @ended_at, @cwd, @ai_title, @tokens_used, 'high')
      ON CONFLICT(id) DO UPDATE SET
        ended_at    = excluded.ended_at,
        cwd         = COALESCE(sessions.cwd, excluded.cwd),
        ai_title    = COALESCE(sessions.ai_title, excluded.ai_title),
        tokens_used = excluded.tokens_used,
        confidence  = 'high'
    `);return s.transaction(()=>{for(let e of n)i.run({id:e.id,started_at:e.created_at_ms,ended_at:e.updated_at_ms,cwd:e.cwd,ai_title:e.title??e.first_user_message?.slice(0,120)??null,tokens_used:e.tokens_used})})(),t.close(),!0}catch{return!1}}()&&function(){if(!t.default.existsSync(f))return;let e=new Map;try{for(let n of t.default.readFileSync(f,"utf8").split("\n").filter(Boolean))try{let t=JSON.parse(n);if(!t.session_id||!t.ts)continue;let s=e.get(t.session_id);s?(t.ts<s.minTs&&(s.minTs=t.ts),t.ts>s.maxTs&&(s.maxTs=t.ts)):e.set(t.session_id,{minTs:t.ts,maxTs:t.ts})}catch{}}catch{return}let n=(0,a.getDb)(),s=n.prepare(`
    INSERT INTO sessions (id, tool, started_at, ended_at, confidence)
    VALUES (@id, 'codex', @started_at, @ended_at, 'medium')
    ON CONFLICT(id) DO NOTHING
  `);n.transaction(()=>{for(let[t,{minTs:n,maxTs:a}]of e)s.run({id:t,started_at:1e3*n,ended_at:1e3*a})})()}(),function(){let s;if(!t.default.existsSync(E))return;let i=e.r(85148),r=(0,a.getDb)(),o=r.prepare(`
    INSERT INTO sessions (id, tool, started_at, ended_at, cwd, ai_title, confidence)
    VALUES (@id, 'cursor', @started_at, @ended_at, @cwd, @ai_title, 'high')
    ON CONFLICT(id) DO UPDATE SET
      ended_at = excluded.ended_at,
      cwd      = COALESCE(sessions.cwd, excluded.cwd),
      ai_title = COALESCE(sessions.ai_title, excluded.ai_title)
  `);try{s=t.default.readdirSync(E)}catch{return}if(r.transaction(()=>{for(let e of s){let s=n.default.join(E,e,"state.vscdb"),a=n.default.join(E,e,"workspace.json");if(!t.default.existsSync(s))continue;let r=null;try{let e=JSON.parse(t.default.readFileSync(a,"utf8"));r=e.folder?.replace("file://","")??null}catch{}try{let e=new i(s,{readonly:!0}),t=e.prepare("SELECT value FROM ItemTable WHERE key = 'composer.composerData'").get();if(e.close(),!t)continue;for(let e of JSON.parse(t.value).allComposers??[])e.composerId&&e.createdAt&&o.run({id:e.composerId,started_at:e.createdAt,ended_at:e.createdAt,cwd:r,ai_title:e.name??null})}catch{}}})(),t.default.existsSync(h))try{let e=new i(h,{readonly:!0});if(e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='cursorDiskKV'").get()){let t=e.prepare("SELECT key, value FROM cursorDiskKV WHERE key LIKE 'composerData:%'").all();r.transaction(()=>{for(let e of t){let t,n=e.key.slice(13);try{t=JSON.parse("string"==typeof e.value?e.value:e.value.toString("utf8"))}catch{continue}let s=t.composerId||n,a=t.createdAt;if(!s||!a)continue;let i=t.lastUpdatedAt??a,r=t.name||(t.text?t.text.slice(0,120):null);o.run({id:s,started_at:a,ended_at:i,cwd:null,ai_title:r})}})()}e.close()}catch{}}();let N=function(){let e;try{e=t.default.readFileSync(l,"utf8")}catch{return null}let n=c.safeParse(JSON.parse(e));if(!n.success)return null;let s=n.data,a=s.rate_limits;return{window_5h_used_pct:a?.five_hour?.used_percentage??null,window_weekly_used_pct:a?.seven_day?.used_percentage??null,reset_at_5h:a?.five_hour?.resets_at!=null?1e3*a.five_hour.resets_at:null,reset_at_weekly:a?.seven_day?.resets_at!=null?1e3*a.seven_day.resets_at:null,raw_output:e.slice(0,2e3),confidence:"high",session_id:s.session_id??null,session_name:s.session_name??null,cwd:s.cwd??null}}();N&&(0,m.insertUsageSnapshot)(s,{capturedAt:Date.now(),source:"statusline",accountId:null,window5hUsedPct:N.window_5h_used_pct,windowWeeklyUsedPct:N.window_weekly_used_pct,resetAt5h:N.reset_at_5h,resetAtWeekly:N.reset_at_weekly,rawOutput:N.raw_output,confidence:"high"});let O=(0,T.getCurrentCodexAccount)(),x=function(e={}){let s=e.sessionsDir??u,a=e.minMtimeMs??0;try{let e=null;if(!t.default.existsSync(s)||(!function s(i){for(let r of t.default.readdirSync(i)){let o=n.default.join(i,r);try{let n=t.default.statSync(o);if(n.isDirectory()){s(o);continue}r.endsWith(".jsonl")&&n.mtimeMs>=a&&n.mtimeMs>(e?.mtime??0)&&(e={path:o,mtime:n.mtimeMs})}catch{}}}(s),!e))return null;for(let n of t.default.readFileSync(e.path,"utf8").split("\n").filter(Boolean).reverse())try{let t=JSON.parse(n),s=t?.payload?.rate_limits;if(!s?.primary||!s?.secondary)continue;return{window_5h_used_pct:s.primary.used_percent,window_weekly_used_pct:s.secondary.used_percent,reset_at_5h:1e3*s.primary.resets_at,reset_at_weekly:1e3*s.secondary.resets_at,source_mtime_ms:e.mtime}}catch{}return null}catch{return null}}({minMtimeMs:O?.authMtimeMs});return x&&(0,m.insertUsageSnapshot)(s,{capturedAt:Date.now(),source:"codex",accountId:O?.accountId??null,window5hUsedPct:x.window_5h_used_pct,windowWeeklyUsedPct:x.window_weekly_used_pct,resetAt5h:x.reset_at_5h,resetAtWeekly:x.reset_at_weekly,rawOutput:null,confidence:"high"}),{scanned:d.length,inserted:w,skipped:y}}],80909)}];

//# sourceMappingURL=%5Broot-of-the-server%5D__0y68a5d._.js.map