@lioneltay/claude-pilot 0.1.6 → 0.1.8

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/dist/cli.js CHANGED
@@ -375,7 +375,7 @@ Content-Type: ${u.type||"application/octet-stream"}\r
375
375
  Content-Length: ${r.length}\r
376
376
  Content-Type: application/json\r
377
377
  \r
378
- ${r}`),e.destroy(t)}function EA(t){if(typeof t!="function")throw new yA(typeof t);if(t.constructor.name==="AsyncFunction")throw new yA("AsyncFunction")}Co.exports=Xm;Co.exports.errorCodes=Mn;Co.exports.fastify=Xm;Co.exports.default=Xm});import{spawn as UJ}from"node:child_process";var _g=ig(yg(),1),{program:l8,createCommand:u8,createArgument:c8,createOption:f8,CommanderError:d8,InvalidArgumentError:h8,InvalidOptionArgumentError:p8,Command:Sg,Argument:m8,Option:g8,Help:y8}=_g.default;var yJ=ig(wA(),1);import{readFile as uJ,writeFile as cJ,mkdir as fJ}from"node:fs/promises";import{homedir as dJ}from"node:os";import{join as OA,dirname as hJ}from"node:path";var RA="Iv1.b507a08c87ecfe98";async function Qm(){let t=await fetch("https://github.com/login/device/code",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({client_id:RA,scope:"read:user"})});if(!t.ok)throw new Error(`Device flow initiation failed: ${t.statusText}`);return t.json()}async function Zm(t,e=5){let r=e;for(;;){await new Promise(i=>setTimeout(i,r*1e3));let s=await(await fetch("https://github.com/login/oauth/access_token",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({client_id:RA,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})})).json();if(s.access_token)return s.access_token;if(s.error!=="authorization_pending"){if(s.error==="slow_down"){r+=5;continue}throw new Error(`Authentication failed: ${s.error||"Unknown error"}`)}}}async function Us(t){let e=await fetch("https://api.github.com/copilot_internal/v2/token",{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});if(!e.ok){let n=await e.text();throw new Error(`Failed to get Copilot token: ${e.status} ${e.statusText} - ${n}`)}let r=await e.json();return{token:r.token,expiresAt:r.expires_at*1e3}}var pJ=OA(dJ(),".config","claude-pilot"),eg=OA(pJ,"auth.json");async function xr(t=eg){try{let e=await uJ(t,"utf-8");return JSON.parse(e)}catch{return null}}async function Pu(t,e=eg){await fJ(hJ(e),{recursive:!0}),await cJ(e,JSON.stringify(t,null,2))}async function Au(t,e=eg){let n=Date.now();if(t.copilotTokenExpiresAt-n>3e5)return t.copilotToken;console.log("Refreshing Copilot token...");let s=await Us(t.githubToken);return t.copilotToken=s.token,t.copilotTokenExpiresAt=s.expiresAt,await Pu(t,e),console.log("Copilot token refreshed"),s.token}var LQ=process.env.COPILOT_PATH||"copilot",qQ=parseInt(process.env.WEB_SEARCH_TIMEOUT||"60000",10),jQ=process.env.WEB_SEARCH_MODEL||"gpt-4.1";import{exec as mJ}from"child_process";import{promisify as gJ}from"util";var HQ=gJ(mJ);import{homedir as _J}from"node:os";import{join as Io}from"node:path";var yr=Io(_J(),".config","claude-pilot"),ft=Io(yr,"auth.json"),Cu=Io(yr,"daemon.json"),Iu=Io(yr,"server.log"),VZ=Io(yr,"requests.jsonl"),Nu=51080;async function TA(){console.log(`Claude Pilot - GitHub Copilot Authentication
378
+ ${r}`),e.destroy(t)}function EA(t){if(typeof t!="function")throw new yA(typeof t);if(t.constructor.name==="AsyncFunction")throw new yA("AsyncFunction")}Co.exports=Xm;Co.exports.errorCodes=Mn;Co.exports.fastify=Xm;Co.exports.default=Xm});import{spawn as UJ}from"node:child_process";var _g=ig(yg(),1),{program:l8,createCommand:u8,createArgument:c8,createOption:f8,CommanderError:d8,InvalidArgumentError:h8,InvalidOptionArgumentError:p8,Command:Sg,Argument:m8,Option:g8,Help:y8}=_g.default;var yJ=ig(wA(),1);import{readFile as uJ,writeFile as cJ,mkdir as fJ}from"node:fs/promises";import{homedir as dJ}from"node:os";import{join as OA,dirname as hJ}from"node:path";var RA="Iv1.b507a08c87ecfe98";async function Qm(){let t=await fetch("https://github.com/login/device/code",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({client_id:RA,scope:"read:user"})});if(!t.ok)throw new Error(`Device flow initiation failed: ${t.statusText}`);return t.json()}async function Zm(t,e=5){let r=e;for(;;){await new Promise(i=>setTimeout(i,r*1e3));let s=await(await fetch("https://github.com/login/oauth/access_token",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({client_id:RA,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})})).json();if(s.access_token)return s.access_token;if(s.error!=="authorization_pending"){if(s.error==="slow_down"){r+=5;continue}throw new Error(`Authentication failed: ${s.error||"Unknown error"}`)}}}async function Us(t){let e=await fetch("https://api.github.com/copilot_internal/v2/token",{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});if(!e.ok){let n=await e.text();throw new Error(`Failed to get Copilot token: ${e.status} ${e.statusText} - ${n}`)}let r=await e.json();return{token:r.token,expiresAt:r.expires_at*1e3}}var pJ=OA(dJ(),".config","claude-pilot"),eg=OA(pJ,"auth.json");async function xr(t=eg){try{let e=await uJ(t,"utf-8");return JSON.parse(e)}catch{return null}}async function Pu(t,e=eg){await fJ(hJ(e),{recursive:!0}),await cJ(e,JSON.stringify(t,null,2))}async function Au(t,e=eg){let n=Date.now();if(t.copilotTokenExpiresAt-n>3e5)return t.copilotToken;console.log("Refreshing Copilot token...");let s=await Us(t.githubToken);return t.copilotToken=s.token,t.copilotTokenExpiresAt=s.expiresAt,await Pu(t,e),console.log("Copilot token refreshed"),s.token}var LQ=process.env.COPILOT_PATH||"copilot",qQ=parseInt(process.env.WEB_SEARCH_TIMEOUT||"60000",10),jQ=process.env.WEB_SEARCH_MODEL||"gpt-4.1";import{exec as mJ}from"child_process";import{promisify as gJ}from"util";var HQ=gJ(mJ);import{homedir as _J}from"node:os";import{join as Io}from"node:path";var yr=Io(_J(),".config","claude-pilot"),ft=Io(yr,"auth.json"),Cu=Io(yr,"daemon.json"),Iu=Io(yr,"server.log"),zZ=Io(yr,"requests.jsonl"),Nu=51080;async function TA(){console.log(`Claude Pilot - GitHub Copilot Authentication
379
379
  `);let t=await xr(ft);if(t){console.log("Existing credentials found."),console.log(`To re-authenticate, delete ${ft}
380
380
  `);try{let s=await Us(t.githubToken);console.log("\u2713 Credentials are valid"),console.log(` Copilot token expires: ${new Date(s.expiresAt).toLocaleString()}`);return}catch{console.log(`\u2717 Credentials are invalid, re-authenticating...
381
381
  `)}}console.log(`Starting GitHub OAuth device flow...