@octocodeai/octocode-tools-core 16.6.2 → 16.6.3

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.
Files changed (58) hide show
  1. package/README.md +11 -9
  2. package/dist/direct.js +37 -34
  3. package/dist/github/pullRequestSearch.d.ts +1 -0
  4. package/dist/index.d.ts +6 -4
  5. package/dist/index.js +39 -43
  6. package/dist/oql/adapters/graphProof.d.ts +6 -0
  7. package/dist/oql/adapters/graphView.d.ts +28 -0
  8. package/dist/oql/adapters/resultMap.d.ts +7 -0
  9. package/dist/oql/adapters/runner.d.ts +7 -0
  10. package/dist/oql/index.js +37 -34
  11. package/dist/oql/schema.d.ts +24 -8
  12. package/dist/oql/schemeText.d.ts +12 -11
  13. package/dist/oql/transformers/github/common.d.ts +7 -1
  14. package/dist/oql/types.d.ts +12 -2
  15. package/dist/responses.d.ts +4 -35
  16. package/dist/schema.js +2 -2
  17. package/dist/scheme/pagination.d.ts +51 -0
  18. package/dist/scheme/responseEnvelope.d.ts +67 -1
  19. package/dist/shared/config/index.d.ts +1 -8
  20. package/dist/shared/config/index.js +1 -2
  21. package/dist/shared/credentials/index.d.ts +1 -1
  22. package/dist/shared/credentials/index.js +2 -1
  23. package/dist/shared/credentials/storage.d.ts +0 -2
  24. package/dist/shared/credentials/testing.js +1 -1
  25. package/dist/shared/paths.d.ts +4 -0
  26. package/dist/shared/paths.js +1 -1
  27. package/dist/shared/session/index.js +1 -1
  28. package/dist/tools/directToolCatalog.exec.d.ts +5 -0
  29. package/dist/tools/github_clone_repo/scheme.d.ts +0 -1
  30. package/dist/tools/github_fetch_content/scheme.d.ts +6 -7
  31. package/dist/tools/github_search_code/scheme.d.ts +4 -6
  32. package/dist/tools/github_search_pull_requests/scheme.d.ts +0 -1
  33. package/dist/tools/github_search_repos/execution.d.ts +58 -0
  34. package/dist/tools/github_search_repos/scheme.d.ts +3 -6
  35. package/dist/tools/github_view_repo_structure/scheme.d.ts +0 -1
  36. package/dist/tools/local_binary_inspect/scheme.d.ts +97 -0
  37. package/dist/tools/local_fetch_content/scheme.d.ts +66 -0
  38. package/dist/tools/local_find_files/scheme.d.ts +49 -0
  39. package/dist/tools/local_ripgrep/scheme.d.ts +75 -0
  40. package/dist/tools/local_view_structure/scheme.d.ts +52 -0
  41. package/dist/tools/lsp/semantic_content/scheme.d.ts +8 -8
  42. package/dist/tools/lsp/shared/readiness.d.ts +17 -0
  43. package/dist/tools/package_search/scheme.d.ts +2 -4
  44. package/dist/tools/toolNames.d.ts +1 -0
  45. package/dist/utils/response/bulk.d.ts +1 -0
  46. package/dist/utils/response/groupedFinalizer.d.ts +7 -2
  47. package/package.json +4 -3
  48. package/dist/oql/adapters/v2.d.ts +0 -32
  49. package/dist/oql/v2params.d.ts +0 -22
  50. package/dist/shared/config/defaults.d.ts +0 -14
  51. package/dist/shared/config/loader.d.ts +0 -7
  52. package/dist/shared/config/resolver.d.ts +0 -2
  53. package/dist/shared/config/resolverCache.d.ts +0 -12
  54. package/dist/shared/config/resolverSections.d.ts +0 -10
  55. package/dist/shared/config/runtimeSurface.d.ts +0 -22
  56. package/dist/shared/config/types.d.ts +0 -92
  57. package/dist/shared/config/validator.d.ts +0 -2
  58. package/dist/shared/credentials/envTokens.d.ts +0 -9
@@ -5,4 +5,5 @@ import { dirname as __dirname_fn } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __dirname_fn(__filename);
8
- function l(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function f(e){if(!e.token.expiresAt)return!1;let t=new Date(e.token.expiresAt);if(isNaN(t.getTime()))return!0;let r=new Date;return t.getTime()-r.getTime()<300*1e3}function E(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var S=new Map,pe=300*1e3;function de(e){let t=l(e),r=S.get(t);return!r||Date.now()-r.cachedAt>=pe?!1:r.credentials?!f(r.credentials):!0}function A(e){e?S.delete(l(e)):S.clear()}function K(e){let t=l(e);if(de(t))return S.get(t).credentials}function U(e,t){let r=l(e);S.set(r,{credentials:t,cachedAt:Date.now()})}import{existsSync as b,readFileSync as q,writeFileSync as J,unlinkSync as Y,statSync as Re,chmodSync as ve}from"node:fs";import{createCipheriv as Ee,createDecipheriv as Ae,randomBytes as Z}from"node:crypto";import{existsSync as ge,mkdirSync as ke}from"node:fs";import{join as a,resolve as Te}from"node:path";import O from"node:os";import he from"node:path";var _=O.platform()==="win32",P=O.platform()==="darwin",me=O.platform()==="linux",k=O.homedir();function H(){return _?process.env.APPDATA||he.join(k,"AppData","Roaming"):k}var N=".octocode",Ce=448;function B(e){let t=process.env[e];return t&&t.trim().length>0?t:void 0}function xe(){let e=B("OCTOCODE_HOME");return e?Te(e):_?a(H(),N):P?a(k,N):a(B("XDG_CONFIG_HOME")??a(k,".config"),N)}var c=xe(),T={home:c,config:a(c,".octocoderc"),credentials:a(c,"credentials.json"),key:a(c,".key"),session:a(c,"session.json"),stats:a(c,"stats.json"),tmp:a(c,"tmp"),clone:a(c,"tmp","clone"),tree:a(c,"tmp","tree"),binary:a(c,"tmp","binary"),repos:a(c,"tmp","clone"),unzip:a(c,"tmp","unzip"),cliConfig:a(c,"config.json"),lspConfig:a(c,"lsp-servers.json")};function V(){ge(T.home)||ke(T.home,{recursive:!0,mode:Ce})}import{z as i}from"zod";var ye=i.object({token:i.string(),tokenType:i.literal("oauth"),scopes:i.array(i.string()).optional(),refreshToken:i.string().optional(),expiresAt:i.string().optional(),refreshTokenExpiresAt:i.string().optional()}),Se=i.object({hostname:i.string(),username:i.string(),token:ye,gitProtocol:i.enum(["ssh","https"]),createdAt:i.string(),updatedAt:i.string()}),$=i.object({version:i.number(),credentials:i.record(i.string(),Se)});var X=T.home,p=T.credentials,u=T.key,Q="aes-256-gcm",Oe=16;function R(){V()}function ee(){if(R(),b(u))return Re(u).mode&511&63&&ve(u,384),Buffer.from(q(u,"utf8"),"hex");let e=Z(32);return J(u,e.toString("hex"),{mode:384}),e}function F(e){let t=ee(),r=Z(Oe),n=Ee(Q,t,r),o=n.update(e,"utf8","hex");o+=n.final("hex");let s=n.getAuthTag();return`${r.toString("hex")}:${s.toString("hex")}:${o}`}function G(e){let t=ee(),[r,n,o]=e.split(":");if(!r||!n||!o)throw new Error("Invalid encrypted data format");let s=Buffer.from(r,"hex"),g=Buffer.from(n,"hex"),m=Ae(Q,t,s);m.setAuthTag(g);let y=m.update(o,"hex","utf8");return y+=m.final("utf8"),y}function d(){if(R(),!b(p))return{version:1,credentials:{}};try{let e=q(p,"utf8"),t=G(e),r=JSON.parse(t),n=$.safeParse(r);return n.success?n.data:{version:1,credentials:{}}}catch{return{version:1,credentials:{}}}}function I(e){R();let t=F(JSON.stringify(e,null,2));J(p,t,{mode:384})}function te(){try{b(p)&&Y(p),b(u)&&Y(u)}catch{}}import{refreshToken as _e}from"@octokit/oauth-methods";import{request as be}from"@octokit/request";var C="178c6fc778ccc68e1d6a",h="github.com";function De(e){return e.replace(/\b(ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}\b/g,"***MASKED***").replace(/\b[a-zA-Z0-9]{40,}\b/g,"***MASKED***")}function we(e){return e==="github.com"||e===h?"https://api.github.com":`https://${e}/api/v3`}async function L(e,t=h,r=C){let n=await e.getCredentials(t);if(!n)return{success:!1,error:`Not logged in to ${t}`};if(!n.token.refreshToken)return{success:!1,error:"Token does not support refresh (OAuth App tokens do not expire)"};if(E(n))return{success:!1,error:"Refresh token has expired. Please login again."};try{let o=await _e({clientType:"github-app",clientId:r,clientSecret:"",refreshToken:n.token.refreshToken,request:be.defaults({baseUrl:we(t)})}),s={token:o.authentication.token,tokenType:"oauth",refreshToken:o.authentication.refreshToken,expiresAt:o.authentication.expiresAt,refreshTokenExpiresAt:o.authentication.refreshTokenExpiresAt};return await e.updateToken(t,s),{success:!0,username:n.username,hostname:t}}catch(o){return{success:!1,error:o instanceof Error?De(o.message):"Token refresh failed"}}}async function re(e,t=h,r=C){let n=await e.getCredentials(t);if(!n||!n.token)return{token:null,source:"none"};if(!f(n))return{token:n.token.token,source:"stored",username:n.username};if(n.token.refreshToken){let o=await L(e,t,r);if(o.success){let s=await e.getCredentials(t);if(s?.token.token)return{token:s.token.token,source:"refreshed",username:s.username}}return{token:null,source:"none",refreshError:o.error}}return{token:null,source:"none",refreshError:"Token expired and no refresh token available"}}var v=["OCTOCODE_TOKEN","GH_TOKEN","GITHUB_TOKEN","GITHUB_PERSONAL_ACCESS_TOKEN"];function W(){for(let e of v){let t=process.env[e];if(t&&t.trim())return t.trim()}return null}function ne(){for(let e of v){let t=process.env[e];if(t&&t.trim())return`env:${e}`}return null}function oe(){return W()!==null}function se(){for(let e of v){let t=process.env[e];if(t?.trim())return{token:t.trim(),source:`env:${e}`}}return null}import{execFile as Pe}from"child_process";var He=["/opt/homebrew/bin","/usr/local/bin","/home/linuxbrew/.linuxbrew/bin"];function j(e){return new Promise(t=>{let r=["auth","token"];e&&r.push("--hostname",e);let n=process.env.PATH??"",o=new Set(n.split(":")),s=He.filter(m=>!o.has(m)),g=s.length?`${s.join(":")}:${n}`:n;Pe("gh",r,{encoding:"utf8",timeout:5e3,env:{...process.env,PATH:g}},(m,y)=>{if(m||!y){t(null);return}t(y.trim()||null)})})}var D=null;function ie(e){D=e}function ae(){D=null}function Ne(){if(!D)throw new Error("Token resolution not initialized. Call initTokenResolution() first.");return D}async function w(e){let t=e?.hostname??h,r=e?.clientId??C,n=e?.getGhCliToken??j,o=se();if(o)return{token:o.token,source:o.source,wasRefreshed:!1};let s=await Ne().getTokenWithRefresh(t,r);if(s.token)return{token:s.token,source:"octocode-storage",wasRefreshed:s.source==="refreshed",username:s.username};try{let g=await Promise.resolve(n(t));if(g?.trim())return{token:g.trim(),source:"gh-cli",wasRefreshed:!1}}catch{}return null}async function ce(e=h){let t=await w({hostname:e,getGhCliToken:()=>null});return t?{token:t.token,source:t.source}:null}async function le(e=h,t=C){let r=await w({hostname:e,clientId:t,getGhCliToken:()=>null});return r?{token:r.token,source:r.source,wasRefreshed:r.wasRefreshed,username:r.username}:null}async function ue(e){let t=l(e.hostname),r={...e,hostname:t,updatedAt:new Date().toISOString()};try{let n=d();return n.credentials[t]=r,I(n),A(t),{success:!0}}catch{throw new Error("Failed to store credentials")}}async function x(e="github.com",t){let r=l(e);if(!t?.bypassCache){let s=K(r);if(s!==void 0)return s}let o=d().credentials[r]||null;return U(r,o),o}function M(e="github.com"){let t=l(e);return d().credentials[t]||null}async function Fe(e="github.com"){let t=l(e),r=!1,n=d();return n.credentials[t]&&(delete n.credentials[t],Object.keys(n.credentials).length===0?te():I(n),r=!0),A(t),{success:r,deletedFromFile:r}}async function Ge(){let e=d();return Object.keys(e.credentials)}function Ie(){let e=d();return Object.keys(e.credentials)}async function Le(e="github.com"){return await x(e)!==null}function We(e="github.com"){return M(e)!==null}async function z(e,t){let r=await x(e);return r?(r.token=t,r.updatedAt=new Date().toISOString(),await ue(r),!0):!1}function je(){return p}async function Me(e="github.com"){let t=await x(e);return!t||!t.token||f(t)?null:t.token.token}function ze(e="github.com"){let t=M(e);return!t||!t.token||f(t)?null:t.token.token}async function Ke(e,t){return L({getCredentials:x,updateToken:z},e,t)}async function fe(e,t){return re({getCredentials:x,updateToken:z},e,t)}ie({getTokenWithRefresh:fe});export{p as CREDENTIALS_FILE,v as ENV_TOKEN_VARS,u as KEY_FILE,X as OCTOCODE_DIR,G as decrypt,Fe as deleteCredentials,F as encrypt,R as ensureOctocodeDir,x as getCredentials,je as getCredentialsFilePath,M as getCredentialsSync,ne as getEnvTokenSource,j as getGhCliToken,Me as getToken,W as getTokenFromEnv,ze as getTokenSync,fe as getTokenWithRefresh,Le as hasCredentials,We as hasCredentialsSync,oe as hasEnvToken,A as invalidateCredentialsCache,E as isRefreshTokenExpired,f as isTokenExpired,Ge as listStoredHosts,Ie as listStoredHostsSync,d as readCredentialsStore,Ke as refreshAuthToken,ae as resetTokenResolution,ce as resolveToken,w as resolveTokenFull,le as resolveTokenWithRefresh,ue as storeCredentials,z as updateToken};
8
+ function u(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function d(e){if(!e.token.expiresAt)return!1;let t=new Date(e.token.expiresAt);if(isNaN(t.getTime()))return!0;let n=new Date;return t.getTime()-n.getTime()<300*1e3}function R(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var E=new Map,oe=300*1e3;function se(e){let t=u(e),n=E.get(t);return!n||Date.now()-n.cachedAt>=oe?!1:n.credentials?!d(n.credentials):!0}function b(e){e?E.delete(u(e)):E.clear()}function U(e){let t=u(e);if(se(t))return E.get(t).credentials}function F(e,t){let n=u(e);E.set(n,{credentials:t,cachedAt:Date.now()})}import{existsSync as A,readFileSync as B,writeFileSync as z,unlinkSync as $,statSync as pe,chmodSync as he}from"node:fs";import{createCipheriv as me,createDecipheriv as ge,randomBytes as K}from"node:crypto";import{existsSync as ae,mkdirSync as ce}from"node:fs";import{join as c}from"node:path";import He from"node:fs";import Ge from"node:path";import H from"node:os";import T from"node:path";import{existsSync as Be,readFileSync as ze}from"node:fs";import Ve from"node:path";function M(e=process.env){let t=e.OCTOCODE_HOME;if(t&&t.trim())return T.resolve(t.trim());let n=H.homedir(),r=H.platform();if(r==="win32"){let s=e.APPDATA??T.join(n,"AppData","Roaming");return T.join(s,".octocode")}if(r==="darwin")return T.join(n,".octocode");let o=e.XDG_CONFIG_HOME??T.join(n,".config");return T.join(o,".octocode")}var ie=["OCTOCODE_TOKEN","GH_TOKEN","GITHUB_TOKEN","GITHUB_PERSONAL_ACCESS_TOKEN"];function G(e=process.env){for(let t of ie){let n=e[t];if(n?.trim())return{token:n.trim(),source:`env:${t}`}}return null}var le=448;function ue(){return M(process.env)}var a=ue(),v={home:a,config:c(a,".octocoderc"),credentials:c(a,"credentials.json"),key:c(a,".key"),session:c(a,"session.json"),stats:c(a,"stats.json"),tmp:c(a,"tmp"),clone:c(a,"tmp","clone"),tree:c(a,"tmp","tree"),binary:c(a,"tmp","binary"),repos:c(a,"tmp","clone"),unzip:c(a,"tmp","unzip"),cliConfig:c(a,"config.json"),lspConfig:c(a,"lsp-servers.json")};function j(){ae(v.home)||ce(v.home,{recursive:!0,mode:le})}import{z as i}from"zod";var fe=i.object({token:i.string(),tokenType:i.literal("oauth"),scopes:i.array(i.string()).optional(),refreshToken:i.string().optional(),expiresAt:i.string().optional(),refreshTokenExpiresAt:i.string().optional()}),de=i.object({hostname:i.string(),username:i.string(),token:fe,gitProtocol:i.enum(["ssh","https"]),createdAt:i.string(),updatedAt:i.string()}),W=i.object({version:i.number(),credentials:i.record(i.string(),de)});var V=v.home,p=v.credentials,f=v.key,J="aes-256-gcm",Te=16;function O(){j()}function X(){if(O(),A(f))return pe(f).mode&511&63&&he(f,384),Buffer.from(B(f,"utf8"),"hex");let e=K(32);return z(f,e.toString("hex"),{mode:384}),e}function x(e){let t=X(),n=K(Te),r=me(J,t,n),o=r.update(e,"utf8","hex");o+=r.final("hex");let s=r.getAuthTag();return`${n.toString("hex")}:${s.toString("hex")}:${o}`}function w(e){let t=X(),[n,r,o]=e.split(":");if(!n||!r||!o)throw new Error("Invalid encrypted data format");let s=Buffer.from(n,"hex"),l=Buffer.from(r,"hex"),g=ge(J,t,s);g.setAuthTag(l);let y=g.update(o,"hex","utf8");return y+=g.final("utf8"),y}function h(){if(O(),!A(p))return{version:1,credentials:{}};try{let e=B(p,"utf8"),t=w(e),n=JSON.parse(t),r=W.safeParse(n);return r.success?r.data:{version:1,credentials:{}}}catch{return{version:1,credentials:{}}}}function L(e){O();let t=x(JSON.stringify(e,null,2));z(p,t,{mode:384})}function Y(){try{A(p)&&$(p),A(f)&&$(f)}catch{}}import{refreshToken as ve}from"@octokit/oauth-methods";import{request as ke}from"@octokit/request";var k="178c6fc778ccc68e1d6a",m="github.com";function Ce(e){return e.replace(/\b(ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}\b/g,"***MASKED***").replace(/\b[a-zA-Z0-9]{40,}\b/g,"***MASKED***")}function ye(e){return e==="github.com"||e===m?"https://api.github.com":`https://${e}/api/v3`}async function P(e,t=m,n=k){let r=await e.getCredentials(t);if(!r)return{success:!1,error:`Not logged in to ${t}`};if(!r.token.refreshToken)return{success:!1,error:"Token does not support refresh (OAuth App tokens do not expire)"};if(R(r))return{success:!1,error:"Refresh token has expired. Please login again."};try{let o=await ve({clientType:"github-app",clientId:n,clientSecret:"",refreshToken:r.token.refreshToken,request:ke.defaults({baseUrl:ye(t)})}),s={token:o.authentication.token,tokenType:"oauth",refreshToken:o.authentication.refreshToken,expiresAt:o.authentication.expiresAt,refreshTokenExpiresAt:o.authentication.refreshTokenExpiresAt};return await e.updateToken(t,s),{success:!0,username:r.username,hostname:t}}catch(o){return{success:!1,error:o instanceof Error?Ce(o.message):"Token refresh failed"}}}async function q(e,t=m,n=k){let r=await e.getCredentials(t);if(!r||!r.token)return{token:null,source:"none"};if(!d(r))return{token:r.token.token,source:"stored",username:r.username};if(r.token.refreshToken){let o=await P(e,t,n);if(o.success){let s=await e.getCredentials(t);if(s?.token.token)return{token:s.token.token,source:"refreshed",username:s.username}}return{token:null,source:"none",refreshError:o.error}}return{token:null,source:"none",refreshError:"Token expired and no refresh token available"}}import{execFile as Ee}from"child_process";var Oe=["/opt/homebrew/bin","/usr/local/bin","/home/linuxbrew/.linuxbrew/bin"];function D(e){return new Promise(t=>{let n=["auth","token"];e&&n.push("--hostname",e);let r=process.env.PATH??"",o=new Set(r.split(":")),s=Oe.filter(g=>!o.has(g)),l=s.length?`${s.join(":")}:${r}`:r;Ee("gh",n,{encoding:"utf8",timeout:5e3,env:{...process.env,PATH:l}},(g,y)=>{if(g||!y){t(null);return}t(y.trim()||null)})})}var S=null;function Q(e){S=e}function Z(){S=null}function Re(){if(!S)throw new Error("Token resolution not initialized. Call initTokenResolution() first.");return S}async function _(e){let t=e?.hostname??m,n=e?.clientId??k,r=e?.getGhCliToken??D,o=G();if(o)return{token:o.token,source:o.source,wasRefreshed:!1};let s=await Re().getTokenWithRefresh(t,n);if(s.token)return{token:s.token,source:"octocode-storage",wasRefreshed:s.source==="refreshed",username:s.username};try{let l=await Promise.resolve(r(t));if(l?.trim())return{token:l.trim(),source:"gh-cli",wasRefreshed:!1}}catch(l){process.stderr.write(`[octocode] gh auth token failed: ${l instanceof Error?l.message:String(l)}
9
+ `)}return null}async function ee(e=m){let t=await _({hostname:e,getGhCliToken:()=>null});return t?{token:t.token,source:t.source}:null}async function te(e=m,t=k){let n=await _({hostname:e,clientId:t,getGhCliToken:()=>null});return n?{token:n.token,source:n.source,wasRefreshed:n.wasRefreshed,username:n.username}:null}async function ne(e){let t=u(e.hostname),n={...e,hostname:t,updatedAt:new Date().toISOString()};try{let r=h();return r.credentials[t]=n,L(r),b(t),{success:!0}}catch{throw new Error("Failed to store credentials")}}async function C(e="github.com",t){let n=u(e);if(!t?.bypassCache){let s=U(n);if(s!==void 0)return s}let o=h().credentials[n]||null;return F(n,o),o}function N(e="github.com"){let t=u(e);return h().credentials[t]||null}async function be(e="github.com"){let t=u(e),n=!1,r=h();return r.credentials[t]&&(delete r.credentials[t],Object.keys(r.credentials).length===0?Y():L(r),n=!0),b(t),{success:n,deletedFromFile:n}}async function Ae(){let e=h();return Object.keys(e.credentials)}function Se(){let e=h();return Object.keys(e.credentials)}async function _e(e="github.com"){return await C(e)!==null}function xe(e="github.com"){return N(e)!==null}async function I(e,t){let n=await C(e);return n?(n.token=t,n.updatedAt=new Date().toISOString(),await ne(n),!0):!1}function we(){return p}async function Le(e="github.com"){let t=await C(e);return!t||!t.token||d(t)?null:t.token.token}function Pe(e="github.com"){let t=N(e);return!t||!t.token||d(t)?null:t.token.token}async function De(e,t){return P({getCredentials:C,updateToken:I},e,t)}async function re(e,t){return q({getCredentials:C,updateToken:I},e,t)}Q({getTokenWithRefresh:re});export{p as CREDENTIALS_FILE,f as KEY_FILE,V as OCTOCODE_DIR,w as decrypt,be as deleteCredentials,x as encrypt,O as ensureOctocodeDir,C as getCredentials,we as getCredentialsFilePath,N as getCredentialsSync,D as getGhCliToken,Le as getToken,Pe as getTokenSync,re as getTokenWithRefresh,_e as hasCredentials,xe as hasCredentialsSync,b as invalidateCredentialsCache,R as isRefreshTokenExpired,d as isTokenExpired,Ae as listStoredHosts,Se as listStoredHostsSync,h as readCredentialsStore,De as refreshAuthToken,Z as resetTokenResolution,ee as resolveToken,_ as resolveTokenFull,te as resolveTokenWithRefresh,ne as storeCredentials,I as updateToken};
@@ -3,9 +3,7 @@ import { invalidateCredentialsCache, _getCacheStats, _resetCredentialsCache } fr
3
3
  import { OCTOCODE_DIR, CREDENTIALS_FILE, KEY_FILE, encrypt, decrypt, ensureOctocodeDir, readCredentialsStore, writeCredentialsStore } from './credentialEncryption.js';
4
4
  import { type RefreshResult, type TokenWithRefreshResult } from './tokenRefresh.js';
5
5
  import { resolveToken, type ResolvedToken, resolveTokenWithRefresh, type ResolvedTokenWithRefresh, resolveTokenFull, type FullTokenResolution, type GhCliTokenGetter, resetTokenResolution } from './tokenResolution.js';
6
- import { getTokenFromEnv, getEnvTokenSource, hasEnvToken, ENV_TOKEN_VARS } from './envTokens.js';
7
6
  import { isTokenExpired, isRefreshTokenExpired } from './credentialUtils.js';
8
- export { getTokenFromEnv, getEnvTokenSource, hasEnvToken, ENV_TOKEN_VARS };
9
7
  export declare function storeCredentials(credentials: StoredCredentials): Promise<StoreResult>;
10
8
  export interface GetCredentialsOptions {
11
9
  bypassCache?: boolean;
@@ -5,4 +5,4 @@ import { dirname as __dirname_fn } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __dirname_fn(__filename);
8
- function o(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function s(e){if(!e.token.expiresAt)return!1;let n=new Date(e.token.expiresAt);if(isNaN(n.getTime()))return!0;let t=new Date;return n.getTime()-t.getTime()<300*1e3}var r=new Map,i=300*1e3;function l(e){let n=o(e),t=r.get(n);return!t||Date.now()-t.cachedAt>=i?!1:t.credentials?!s(t.credentials):!0}function a(){let e=Date.now();return{size:r.size,entries:Array.from(r.entries()).map(([n,t])=>({hostname:n,age:e-t.cachedAt,valid:l(n)}))}}function u(){r.clear()}import{execFile as g}from"child_process";var c=null;function f(){c=null}export{a as _getCacheStats,u as _resetCredentialsCache,f as resetTokenResolution};
8
+ function r(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function s(e){if(!e.token.expiresAt)return!1;let n=new Date(e.token.expiresAt);if(isNaN(n.getTime()))return!0;let t=new Date;return n.getTime()-t.getTime()<300*1e3}var o=new Map,i=300*1e3;function a(e){let n=r(e),t=o.get(n);return!t||Date.now()-t.cachedAt>=i?!1:t.credentials?!s(t.credentials):!0}function l(){let e=Date.now();return{size:o.size,entries:Array.from(o.entries()).map(([n,t])=>({hostname:n,age:e-t.cachedAt,valid:a(n)}))}}function c(){o.clear()}import m from"node:fs";import E from"node:path";import C from"node:os";import _ from"node:path";import{existsSync as k,readFileSync as R}from"node:fs";import y from"node:path";import{execFile as P}from"child_process";var u=null;function f(){u=null}export{l as _getCacheStats,c as _resetCredentialsCache,f as resetTokenResolution};
@@ -4,8 +4,12 @@
4
4
  * - macOS: `~/.octocode`
5
5
  * - Linux: `${XDG_CONFIG_HOME:-~/.config}/.octocode`
6
6
  * - Windows: `%APPDATA%\.octocode`
7
+ *
8
+ * Implementation delegated to @octocodeai/config — single source of truth.
7
9
  */
8
10
  export declare function getDefaultOctocodeHome(): string;
11
+ /** Octocode home directory — same as OCTOCODE_HOME, exposed for tool/cache use. */
12
+ export declare function getOctocodeDir(): string;
9
13
  export declare const OCTOCODE_HOME: string;
10
14
  export declare const paths: {
11
15
  readonly home: string;
@@ -5,4 +5,4 @@ import { dirname as __dirname_fn } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __dirname_fn(__filename);
8
- import{existsSync as n,mkdirSync as i}from"node:fs";import{join as e,resolve as A}from"node:path";import c from"node:os";import x from"node:path";var u=c.platform()==="win32",m=c.platform()==="darwin",v=c.platform()==="linux",r=c.homedir();function d(){return u?process.env.APPDATA||x.join(r,"AppData","Roaming"):r}var l=".octocode",s=448;function g(p){let f=process.env[p];return f&&f.trim().length>0?f:void 0}function O(){let p=g("OCTOCODE_HOME");return p?A(p):u?e(d(),l):m?e(r,l):e(g("XDG_CONFIG_HOME")??e(r,".config"),l)}var t=O(),o={home:t,config:e(t,".octocoderc"),credentials:e(t,"credentials.json"),key:e(t,".key"),session:e(t,"session.json"),stats:e(t,"stats.json"),tmp:e(t,"tmp"),clone:e(t,"tmp","clone"),tree:e(t,"tmp","tree"),binary:e(t,"tmp","binary"),repos:e(t,"tmp","clone"),unzip:e(t,"tmp","unzip"),cliConfig:e(t,"config.json"),lspConfig:e(t,"lsp-servers.json")};function D(){n(o.home)||i(o.home,{recursive:!0,mode:s})}function _(){h()}function a(){D(),n(o.tmp)||i(o.tmp,{recursive:!0,mode:s})}function h(){a(),n(o.clone)||i(o.clone,{recursive:!0,mode:s})}function z(){a(),n(o.tree)||i(o.tree,{recursive:!0,mode:s})}function N(){a(),n(o.binary)||i(o.binary,{recursive:!0,mode:s})}function R(){a(),n(o.unzip)||i(o.unzip,{recursive:!0,mode:s})}export{t as OCTOCODE_HOME,N as ensureBinary,h as ensureClone,D as ensureHome,_ as ensureRepos,a as ensureTmp,z as ensureTree,R as ensureUnzip,O as getDefaultOctocodeHome,o as paths};
8
+ import{existsSync as r,mkdirSync as i}from"node:fs";import{join as t}from"node:path";import T from"node:fs";import _ from"node:path";import p from"node:os";import n from"node:path";import{existsSync as L,readFileSync as R}from"node:fs";import S from"node:path";function d(c=process.env){let u=c.OCTOCODE_HOME;if(u&&u.trim())return n.resolve(u.trim());let l=p.homedir(),f=p.platform();if(f==="win32"){let h=c.APPDATA??n.join(l,"AppData","Roaming");return n.join(h,".octocode")}if(f==="darwin")return n.join(l,".octocode");let v=c.XDG_CONFIG_HOME??n.join(l,".config");return n.join(v,".octocode")}var s=448;function m(){return d(process.env)}function M(){return e}var e=m(),o={home:e,config:t(e,".octocoderc"),credentials:t(e,"credentials.json"),key:t(e,".key"),session:t(e,"session.json"),stats:t(e,"stats.json"),tmp:t(e,"tmp"),clone:t(e,"tmp","clone"),tree:t(e,"tmp","tree"),binary:t(e,"tmp","binary"),repos:t(e,"tmp","clone"),unzip:t(e,"tmp","unzip"),cliConfig:t(e,"config.json"),lspConfig:t(e,"lsp-servers.json")};function O(){r(o.home)||i(o.home,{recursive:!0,mode:s})}function I(){E()}function a(){O(),r(o.tmp)||i(o.tmp,{recursive:!0,mode:s})}function E(){a(),r(o.clone)||i(o.clone,{recursive:!0,mode:s})}function D(){a(),r(o.tree)||i(o.tree,{recursive:!0,mode:s})}function j(){a(),r(o.binary)||i(o.binary,{recursive:!0,mode:s})}function F(){a(),r(o.unzip)||i(o.unzip,{recursive:!0,mode:s})}export{e as OCTOCODE_HOME,j as ensureBinary,E as ensureClone,O as ensureHome,I as ensureRepos,a as ensureTmp,D as ensureTree,F as ensureUnzip,m as getDefaultOctocodeHome,M as getOctocodeDir,o as paths};
@@ -5,4 +5,4 @@ import { dirname as __dirname_fn } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __dirname_fn(__filename);
8
- import{randomUUID as dt}from"node:crypto";import{existsSync as J,readFileSync as ve,writeFileSync as nt,unlinkSync as ot,renameSync as it}from"node:fs";function h(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function E(e){if(!e.token.expiresAt)return!1;let t=new Date(e.token.expiresAt);if(isNaN(t.getTime()))return!0;let r=new Date;return t.getTime()-r.getTime()<300*1e3}function z(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var P=new Map,we=300*1e3;function Oe(e){let t=h(e),r=P.get(t);return!r||Date.now()-r.cachedAt>=we?!1:r.credentials?!E(r.credentials):!0}function ee(e){e?P.delete(h(e)):P.clear()}function te(e){let t=h(e);if(Oe(t))return P.get(t).credentials}function re(e,t){let r=h(e);P.set(r,{credentials:t,cachedAt:Date.now()})}import{existsSync as ie,readFileSync as ae,writeFileSync as ce,unlinkSync as Qt,statSync as je,chmodSync as Me}from"node:fs";import{createCipheriv as Be,createDecipheriv as ze,randomBytes as ue}from"node:crypto";import{existsSync as De,mkdirSync as Fe}from"node:fs";import{join as c,resolve as _e}from"node:path";import _ from"node:os";import Le from"node:path";var I=_.platform()==="win32",W=_.platform()==="darwin",He=_.platform()==="linux",T=_.homedir();function K(){return I?process.env.APPDATA||Le.join(T,"AppData","Roaming"):T}var V=".octocode",Ie=448;function se(e){let t=process.env[e];return t&&t.trim().length>0?t:void 0}function Ne(){let e=se("OCTOCODE_HOME");return e?_e(e):I?c(K(),V):W?c(T,V):c(se("XDG_CONFIG_HOME")??c(T,".config"),V)}var u=Ne(),f={home:u,config:c(u,".octocoderc"),credentials:c(u,"credentials.json"),key:c(u,".key"),session:c(u,"session.json"),stats:c(u,"stats.json"),tmp:c(u,"tmp"),clone:c(u,"tmp","clone"),tree:c(u,"tmp","tree"),binary:c(u,"tmp","binary"),repos:c(u,"tmp","clone"),unzip:c(u,"tmp","unzip"),cliConfig:c(u,"config.json"),lspConfig:c(u,"lsp-servers.json")};function ne(){De(f.home)||Fe(f.home,{recursive:!0,mode:Ie})}import{z as a}from"zod";var Ge=a.object({token:a.string(),tokenType:a.literal("oauth"),scopes:a.array(a.string()).optional(),refreshToken:a.string().optional(),expiresAt:a.string().optional(),refreshTokenExpiresAt:a.string().optional()}),Ue=a.object({hostname:a.string(),username:a.string(),token:Ge,gitProtocol:a.enum(["ssh","https"]),createdAt:a.string(),updatedAt:a.string()}),oe=a.object({version:a.number(),credentials:a.record(a.string(),Ue)});var We=f.home,N=f.credentials,k=f.key,le="aes-256-gcm",Ke=16;function x(){ne()}function fe(){if(x(),ie(k))return je(k).mode&511&63&&Me(k,384),Buffer.from(ae(k,"utf8"),"hex");let e=ue(32);return ce(k,e.toString("hex"),{mode:384}),e}function pe(e){let t=fe(),r=ue(Ke),s=Be(le,t,r),n=s.update(e,"utf8","hex");n+=s.final("hex");let i=s.getAuthTag();return`${r.toString("hex")}:${i.toString("hex")}:${n}`}function de(e){let t=fe(),[r,s,n]=e.split(":");if(!r||!s||!n)throw new Error("Invalid encrypted data format");let i=Buffer.from(r,"hex"),C=Buffer.from(s,"hex"),m=ze(le,t,i);m.setAuthTag(C);let Q=m.update(n,"hex","utf8");return Q+=m.final("utf8"),Q}function $(){if(x(),!ie(N))return{version:1,credentials:{}};try{let e=ae(N,"utf8"),t=de(e),r=JSON.parse(t),s=oe.safeParse(r);return s.success?s.data:{version:1,credentials:{}}}catch{return{version:1,credentials:{}}}}function me(e){x();let t=pe(JSON.stringify(e,null,2));ce(N,t,{mode:384})}import{refreshToken as Ve}from"@octokit/oauth-methods";import{request as $e}from"@octokit/request";var G="178c6fc778ccc68e1d6a",A="github.com";function Je(e){return e.replace(/\b(ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}\b/g,"***MASKED***").replace(/\b[a-zA-Z0-9]{40,}\b/g,"***MASKED***")}function qe(e){return e==="github.com"||e===A?"https://api.github.com":`https://${e}/api/v3`}async function he(e,t=A,r=G){let s=await e.getCredentials(t);if(!s)return{success:!1,error:`Not logged in to ${t}`};if(!s.token.refreshToken)return{success:!1,error:"Token does not support refresh (OAuth App tokens do not expire)"};if(z(s))return{success:!1,error:"Refresh token has expired. Please login again."};try{let n=await Ve({clientType:"github-app",clientId:r,clientSecret:"",refreshToken:s.token.refreshToken,request:$e.defaults({baseUrl:qe(t)})}),i={token:n.authentication.token,tokenType:"oauth",refreshToken:n.authentication.refreshToken,expiresAt:n.authentication.expiresAt,refreshTokenExpiresAt:n.authentication.refreshTokenExpiresAt};return await e.updateToken(t,i),{success:!0,username:s.username,hostname:t}}catch(n){return{success:!1,error:n instanceof Error?Je(n.message):"Token refresh failed"}}}async function Se(e,t=A,r=G){let s=await e.getCredentials(t);if(!s||!s.token)return{token:null,source:"none"};if(!E(s))return{token:s.token.token,source:"stored",username:s.username};if(s.token.refreshToken){let n=await he(e,t,r);if(n.success){let i=await e.getCredentials(t);if(i?.token.token)return{token:i.token.token,source:"refreshed",username:i.username}}return{token:null,source:"none",refreshError:n.error}}return{token:null,source:"none",refreshError:"Token expired and no refresh token available"}}import{execFile as pr}from"child_process";var Ye=null;function ge(e){Ye=e}async function Ze(e){let t=h(e.hostname),r={...e,hostname:t,updatedAt:new Date().toISOString()};try{let s=$();return s.credentials[t]=r,me(s),ee(t),{success:!0}}catch{throw new Error("Failed to store credentials")}}async function Ce(e="github.com",t){let r=h(e);if(!t?.bypassCache){let i=te(r);if(i!==void 0)return i}let n=$().credentials[r]||null;return re(r,n),n}async function Xe(e,t){let r=await Ce(e);return r?(r.token=t,r.updatedAt=new Date().toISOString(),await Ze(r),!0):!1}async function Qe(e,t){return Se({getCredentials:Ce,updateToken:Xe},e,t)}ge({getTokenWithRefresh:Qe});import{z as o}from"zod";var et=o.object({rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),calls:o.number()}),tt=o.object({hits:o.record(o.string(),o.number()).default({}),rateLimits:o.number().default(0)}),U=o.record(o.string(),o.number()).default({}),rt=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:U,rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),charSavingsCalls:o.number(),githubCacheHits:o.number(),githubCacheRateLimits:o.number(),packageRegistryFailures:o.number().default(0),packageRegistryFailuresByRegistry:U}),j=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:U,charsSavedByTool:o.record(o.string(),et).default({}),githubCacheHits:tt.default({hits:{},rateLimits:0}),packageRegistryFailures:U,totalUsage:rt.optional()}),Te=o.object({version:o.literal(1),sessionId:o.string(),createdAt:o.string(),lastActiveAt:o.string(),stats:j.optional()}),ke=o.object({version:o.literal(1),stats:j});function xe(e){return Object.values(e).reduce((t,r)=>t+r,0)}function st(e){let t=e.charsSavedByTool??{},r=e.githubCacheHits??{hits:{},rateLimits:0},s=e.rateLimitsByProvider??{},n=e.packageRegistryFailures??{},i=Object.values(t).reduce((C,m)=>({rawChars:C.rawChars+m.rawChars,responseChars:C.responseChars+m.responseChars,savedChars:C.savedChars+m.savedChars,charSavingsCalls:C.charSavingsCalls+m.calls}),{rawChars:0,responseChars:0,savedChars:0,charSavingsCalls:0});return{toolCalls:e.toolCalls,errors:e.errors,rateLimits:e.rateLimits,rateLimitsByProvider:s,...i,githubCacheHits:xe(r.hits),githubCacheRateLimits:r.rateLimits,packageRegistryFailures:xe(n),packageRegistryFailuresByRegistry:n}}function p(e){let t={...e,rateLimitsByProvider:e.rateLimitsByProvider??{},charsSavedByTool:e.charsSavedByTool??{},githubCacheHits:e.githubCacheHits??{hits:{},rateLimits:0},packageRegistryFailures:e.packageRegistryFailures??{}};return{...t,totalUsage:st(t)}}function w(){return p({toolCalls:0,errors:0,rateLimits:0,rateLimitsByProvider:{},charsSavedByTool:{},githubCacheHits:{hits:{},rateLimits:0},packageRegistryFailures:{}})}var y=f.session,v=f.stats;function ye(e,t){let r=`${e}.tmp`;nt(r,JSON.stringify(t,null,2),{mode:384}),it(r,e)}function at(e){let{stats:t,...r}=e;return r}function ct(e){let t=JSON.parse(e),r=ke.safeParse(t);if(r.success)return p(r.data.stats);let s=j.safeParse(t);return s.success?p(s.data):null}function ut(e){let t=e?p(e):w();if(!J(v))return t;try{let r=ve(v,"utf8"),s=ct(r);return s||t}catch{return t}}function M(e){x(),ye(v,{version:e.version,stats:p(e.stats)}),ye(y,at(e))}function Re(){if(!J(y))return null;try{let e=ve(y,"utf8"),t=JSON.parse(e),r=Te.safeParse(t);return r.success?{...r.data,stats:ut(r.data.stats)}:null}catch{return null}}function be(){let e=!1;for(let t of[y,v])if(J(t))try{ot(t),e=!0}catch{return!1}return e}var lt=6e4,l=null,S=!1,R=null,q=!1,O=null,L=null,H=null,B=!1;function ft(){q||(q=!0,O=()=>{D()},L=()=>{D()},H=()=>{D()},process.on("exit",O),process.on("SIGINT",L),process.on("SIGTERM",H))}function Y(){O&&(process.removeListener("exit",O),O=null),L&&(process.removeListener("SIGINT",L),L=null),H&&(process.removeListener("SIGTERM",H),H=null),q=!1}function pt(){R||(R=setInterval(()=>{S&&l&&(M(l),S=!1)},lt),R.unref())}function Z(){R&&(clearInterval(R),R=null)}function b(){if(l)return l;let e=Re();return e&&(l=e),e}function g(e){l=e,S=!0,ft(),pt()}function F(){S&&l&&(M(l),S=!1)}function D(){if(!B&&S&&l){B=!0;try{M(l),S=!1}catch{}finally{B=!1}}}function X(){l=null,S=!1,B=!1}function Ee(){X(),Z(),Y()}var mt=1;function ht(e){return p(e)}function St(e,t){if(!t)return e;let r={...e};for(let[s,n]of Object.entries(t)){let i=r[s]??{rawChars:0,responseChars:0,savedChars:0,calls:0};r[s]={rawChars:i.rawChars+n.rawChars,responseChars:i.responseChars+n.responseChars,savedChars:i.savedChars+n.savedChars,calls:i.calls+n.calls}}return r}function Pe(e,t){if(!t)return e;let r={...e};for(let[s,n]of Object.entries(t))r[s]=(r[s]??0)+n;return r}function gt(e,t){if(!t)return e;let r={...e.hits};for(let[s,n]of Object.entries(t.hits??{}))r[s]=(r[s]??0)+n;return{hits:r,rateLimits:e.rateLimits+(t.rateLimits??0)}}function Ae(){let e=new Date().toISOString();return{version:mt,sessionId:dt(),createdAt:e,lastActiveAt:e,stats:w()}}function Ct(){return b()}function Tt(e){g(e)}function kt(){F()}function xt(){D()}function yt(e){if(e?.forceNew){let s=Ae();return g(s),F(),s}let t=b();if(t){let s={...t,lastActiveAt:new Date().toISOString()};return g(s),F(),s}let r=Ae();return g(r),F(),r}function vt(){return b()?.sessionId??null}function d(e){let t=b();if(!t)return{success:!1,session:null};let r=ht(t.stats),s=p({toolCalls:r.toolCalls+(e.toolCalls??0),errors:r.errors+(e.errors??0),rateLimits:r.rateLimits+(e.rateLimits??0),rateLimitsByProvider:Pe(r.rateLimitsByProvider,e.rateLimitsByProvider),charsSavedByTool:St(r.charsSavedByTool,e.charsSavedByTool),githubCacheHits:gt(r.githubCacheHits,e.githubCacheHits),packageRegistryFailures:Pe(r.packageRegistryFailures,e.packageRegistryFailures)}),n={...t,lastActiveAt:new Date().toISOString(),stats:s};return g(n),{success:!0,session:n}}function Rt(e=1){return d({toolCalls:e})}function bt(e=1){return d({errors:e})}function Et(e=1){return d({rateLimits:e})}function Pt(e,t=1){return d({rateLimits:t,rateLimitsByProvider:{[e]:t}})}function At(e,t,r){let s=Number.isFinite(t)?Math.max(0,t):0,n=Number.isFinite(r)?Math.max(0,r):0;return d({charsSavedByTool:{[e]:{rawChars:s,responseChars:n,savedChars:Math.max(0,s-n),calls:1}}})}function wt(e,t=1){return d({githubCacheHits:{hits:{[e]:t},rateLimits:0}})}function Ot(e=1){return d({githubCacheHits:{hits:{},rateLimits:e}})}function Lt(e,t=1){return d({packageRegistryFailures:{[e]:t}})}function Ht(){let e=b();if(!e)return{success:!1,session:null};let t={...e,lastActiveAt:new Date().toISOString(),stats:w()};return g(t),{success:!0,session:t}}function Dt(){return X(),Z(),Y(),be()}function Ft(){Ee()}export{y as SESSION_FILE,v as STATS_FILE,Ft as _resetSessionState,Dt as deleteSession,kt as flushSession,xt as flushSessionSync,yt as getOrCreateSession,vt as getSessionId,bt as incrementErrors,wt as incrementGitHubCacheHits,Ot as incrementGitHubCacheRateLimits,Lt as incrementPackageRegistryFailures,Pt as incrementRateLimitByProvider,Et as incrementRateLimits,Rt as incrementToolCalls,At as incrementToolCharSavings,Ct as readSession,Ht as resetSessionStats,d as updateSessionStats,Tt as writeSession};
8
+ import{randomUUID as it}from"node:crypto";import{existsSync as $,readFileSync as Te,writeFileSync as Ye,unlinkSync as Qe,renameSync as Ze}from"node:fs";function m(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function O(e){if(!e.token.expiresAt)return!1;let t=new Date(e.token.expiresAt);if(isNaN(t.getTime()))return!0;let r=new Date;return t.getTime()-r.getTime()<300*1e3}function G(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var x=new Map,Ee=300*1e3;function Oe(e){let t=m(e),r=x.get(t);return!r||Date.now()-r.cachedAt>=Ee?!1:r.credentials?!O(r.credentials):!0}function X(e){e?x.delete(m(e)):x.clear()}function q(e){let t=m(e);if(Oe(t))return x.get(t).credentials}function Y(e,t){let r=m(e);x.set(r,{credentials:t,cachedAt:Date.now()})}import{existsSync as re,readFileSync as ne,writeFileSync as se,unlinkSync as qt,statSync as Fe,chmodSync as Ie}from"node:fs";import{createCipheriv as De,createDecipheriv as He,randomBytes as oe}from"node:crypto";import{existsSync as xe,mkdirSync as Ae}from"node:fs";import{join as u}from"node:path";import Pt from"node:fs";import It from"node:path";import Q from"node:os";import T from"node:path";import{existsSync as Nt,readFileSync as Mt}from"node:fs";import Gt from"node:path";function Z(e=process.env){let t=e.OCTOCODE_HOME;if(t&&t.trim())return T.resolve(t.trim());let r=Q.homedir(),n=Q.platform();if(n==="win32"){let i=e.APPDATA??T.join(r,"AppData","Roaming");return T.join(i,".octocode")}if(n==="darwin")return T.join(r,".octocode");let s=e.XDG_CONFIG_HOME??T.join(r,".config");return T.join(s,".octocode")}var _e=448;function we(){return Z(process.env)}var c=we(),f={home:c,config:u(c,".octocoderc"),credentials:u(c,"credentials.json"),key:u(c,".key"),session:u(c,"session.json"),stats:u(c,"stats.json"),tmp:u(c,"tmp"),clone:u(c,"tmp","clone"),tree:u(c,"tmp","tree"),binary:u(c,"tmp","binary"),repos:u(c,"tmp","clone"),unzip:u(c,"tmp","unzip"),cliConfig:u(c,"config.json"),lspConfig:u(c,"lsp-servers.json")};function ee(){xe(f.home)||Ae(f.home,{recursive:!0,mode:_e})}import{z as a}from"zod";var Le=a.object({token:a.string(),tokenType:a.literal("oauth"),scopes:a.array(a.string()).optional(),refreshToken:a.string().optional(),expiresAt:a.string().optional(),refreshTokenExpiresAt:a.string().optional()}),Pe=a.object({hostname:a.string(),username:a.string(),token:Le,gitProtocol:a.enum(["ssh","https"]),createdAt:a.string(),updatedAt:a.string()}),te=a.object({version:a.number(),credentials:a.record(a.string(),Pe)});var Ue=f.home,D=f.credentials,C=f.key,ie="aes-256-gcm",Ne=16;function y(){ee()}function ae(){if(y(),re(C))return Fe(C).mode&511&63&&Ie(C,384),Buffer.from(ne(C,"utf8"),"hex");let e=oe(32);return se(C,e.toString("hex"),{mode:384}),e}function ce(e){let t=ae(),r=oe(Ne),n=De(ie,t,r),s=n.update(e,"utf8","hex");s+=n.final("hex");let i=n.getAuthTag();return`${r.toString("hex")}:${i.toString("hex")}:${s}`}function ue(e){let t=ae(),[r,n,s]=e.split(":");if(!r||!n||!s)throw new Error("Invalid encrypted data format");let i=Buffer.from(r,"hex"),v=Buffer.from(n,"hex"),h=He(ie,t,i);h.setAuthTag(v);let J=h.update(s,"hex","utf8");return J+=h.final("utf8"),J}function B(){if(y(),!re(D))return{version:1,credentials:{}};try{let e=ne(D,"utf8"),t=ue(e),r=JSON.parse(t),n=te.safeParse(r);return n.success?n.data:{version:1,credentials:{}}}catch{return{version:1,credentials:{}}}}function le(e){y();let t=ce(JSON.stringify(e,null,2));se(D,t,{mode:384})}import{refreshToken as Me}from"@octokit/oauth-methods";import{request as je}from"@octokit/request";var H="178c6fc778ccc68e1d6a",A="github.com";function Ge(e){return e.replace(/\b(ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}\b/g,"***MASKED***").replace(/\b[a-zA-Z0-9]{40,}\b/g,"***MASKED***")}function Be(e){return e==="github.com"||e===A?"https://api.github.com":`https://${e}/api/v3`}async function fe(e,t=A,r=H){let n=await e.getCredentials(t);if(!n)return{success:!1,error:`Not logged in to ${t}`};if(!n.token.refreshToken)return{success:!1,error:"Token does not support refresh (OAuth App tokens do not expire)"};if(G(n))return{success:!1,error:"Refresh token has expired. Please login again."};try{let s=await Me({clientType:"github-app",clientId:r,clientSecret:"",refreshToken:n.token.refreshToken,request:je.defaults({baseUrl:Be(t)})}),i={token:s.authentication.token,tokenType:"oauth",refreshToken:s.authentication.refreshToken,expiresAt:s.authentication.expiresAt,refreshTokenExpiresAt:s.authentication.refreshTokenExpiresAt};return await e.updateToken(t,i),{success:!0,username:n.username,hostname:t}}catch(s){return{success:!1,error:s instanceof Error?Ge(s.message):"Token refresh failed"}}}async function de(e,t=A,r=H){let n=await e.getCredentials(t);if(!n||!n.token)return{token:null,source:"none"};if(!O(n))return{token:n.token.token,source:"stored",username:n.username};if(n.token.refreshToken){let s=await fe(e,t,r);if(s.success){let i=await e.getCredentials(t);if(i?.token.token)return{token:i.token.token,source:"refreshed",username:i.username}}return{token:null,source:"none",refreshError:s.error}}return{token:null,source:"none",refreshError:"Token expired and no refresh token available"}}import{execFile as cr}from"child_process";var $e=null;function pe(e){$e=e}async function We(e){let t=m(e.hostname),r={...e,hostname:t,updatedAt:new Date().toISOString()};try{let n=B();return n.credentials[t]=r,le(n),X(t),{success:!0}}catch{throw new Error("Failed to store credentials")}}async function he(e="github.com",t){let r=m(e);if(!t?.bypassCache){let i=q(r);if(i!==void 0)return i}let s=B().credentials[r]||null;return Y(r,s),s}async function ze(e,t){let r=await he(e);return r?(r.token=t,r.updatedAt=new Date().toISOString(),await We(r),!0):!1}async function Ke(e,t){return de({getCredentials:he,updateToken:ze},e,t)}pe({getTokenWithRefresh:Ke});import{z as o}from"zod";var Ve=o.object({rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),calls:o.number()}),Je=o.object({hits:o.record(o.string(),o.number()).default({}),rateLimits:o.number().default(0)}),U=o.record(o.string(),o.number()).default({}),Xe=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:U,rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),charSavingsCalls:o.number(),githubCacheHits:o.number(),githubCacheRateLimits:o.number(),packageRegistryFailures:o.number().default(0),packageRegistryFailuresByRegistry:U}),N=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:U,charsSavedByTool:o.record(o.string(),Ve).default({}),githubCacheHits:Je.default({hits:{},rateLimits:0}),packageRegistryFailures:U,totalUsage:Xe.optional()}),me=o.object({version:o.literal(1),sessionId:o.string(),createdAt:o.string(),lastActiveAt:o.string(),stats:N.optional()}),ge=o.object({version:o.literal(1),stats:N});function Se(e){return Object.values(e).reduce((t,r)=>t+r,0)}function qe(e){let t=e.charsSavedByTool??{},r=e.githubCacheHits??{hits:{},rateLimits:0},n=e.rateLimitsByProvider??{},s=e.packageRegistryFailures??{},i=Object.values(t).reduce((v,h)=>({rawChars:v.rawChars+h.rawChars,responseChars:v.responseChars+h.responseChars,savedChars:v.savedChars+h.savedChars,charSavingsCalls:v.charSavingsCalls+h.calls}),{rawChars:0,responseChars:0,savedChars:0,charSavingsCalls:0});return{toolCalls:e.toolCalls,errors:e.errors,rateLimits:e.rateLimits,rateLimitsByProvider:n,...i,githubCacheHits:Se(r.hits),githubCacheRateLimits:r.rateLimits,packageRegistryFailures:Se(s),packageRegistryFailuresByRegistry:s}}function d(e){let t={...e,rateLimitsByProvider:e.rateLimitsByProvider??{},charsSavedByTool:e.charsSavedByTool??{},githubCacheHits:e.githubCacheHits??{hits:{},rateLimits:0},packageRegistryFailures:e.packageRegistryFailures??{}};return{...t,totalUsage:qe(t)}}function _(){return d({toolCalls:0,errors:0,rateLimits:0,rateLimitsByProvider:{},charsSavedByTool:{},githubCacheHits:{hits:{},rateLimits:0},packageRegistryFailures:{}})}var k=f.session,b=f.stats;function ve(e,t){let r=`${e}.tmp`;Ye(r,JSON.stringify(t,null,2),{mode:384}),Ze(r,e)}function et(e){let{stats:t,...r}=e;return r}function tt(e){let t=JSON.parse(e),r=ge.safeParse(t);if(r.success)return d(r.data.stats);let n=N.safeParse(t);return n.success?d(n.data):null}function rt(e){let t=e?d(e):_();if(!$(b))return t;try{let r=Te(b,"utf8"),n=tt(r);return n||t}catch{return t}}function M(e){y(),ve(b,{version:e.version,stats:d(e.stats)}),ve(k,et(e))}function Ce(){if(!$(k))return null;try{let e=Te(k,"utf8"),t=JSON.parse(e),r=me.safeParse(t);return r.success?{...r.data,stats:rt(r.data.stats)}:null}catch{return null}}function ye(){let e=!1;for(let t of[k,b])if($(t))try{Qe(t),e=!0}catch{return!1}return e}var nt=6e4,l=null,g=!1,R=null,W=!1,w=null,L=null,P=null,j=!1;function st(){W||(W=!0,w=()=>{F()},L=()=>{F()},P=()=>{F()},process.on("exit",w),process.on("SIGINT",L),process.on("SIGTERM",P))}function z(){w&&(process.removeListener("exit",w),w=null),L&&(process.removeListener("SIGINT",L),L=null),P&&(process.removeListener("SIGTERM",P),P=null),W=!1}function ot(){R||(R=setInterval(()=>{g&&l&&(M(l),g=!1)},nt),R.unref())}function K(){R&&(clearInterval(R),R=null)}function E(){if(l)return l;let e=Ce();return e&&(l=e),e}function S(e){l=e,g=!0,st(),ot()}function I(){g&&l&&(M(l),g=!1)}function F(){if(!j&&g&&l){j=!0;try{M(l),g=!1}catch{}finally{j=!1}}}function V(){l=null,g=!1,j=!1}function ke(){V(),K(),z()}var at=1;function ct(e){return d(e)}function ut(e,t){if(!t)return e;let r={...e};for(let[n,s]of Object.entries(t)){let i=r[n]??{rawChars:0,responseChars:0,savedChars:0,calls:0};r[n]={rawChars:i.rawChars+s.rawChars,responseChars:i.responseChars+s.responseChars,savedChars:i.savedChars+s.savedChars,calls:i.calls+s.calls}}return r}function be(e,t){if(!t)return e;let r={...e};for(let[n,s]of Object.entries(t))r[n]=(r[n]??0)+s;return r}function lt(e,t){if(!t)return e;let r={...e.hits};for(let[n,s]of Object.entries(t.hits??{}))r[n]=(r[n]??0)+s;return{hits:r,rateLimits:e.rateLimits+(t.rateLimits??0)}}function Re(){let e=new Date().toISOString();return{version:at,sessionId:it(),createdAt:e,lastActiveAt:e,stats:_()}}function ft(){return E()}function dt(e){S(e)}function pt(){I()}function ht(){F()}function mt(e){if(e?.forceNew){let n=Re();return S(n),I(),n}let t=E();if(t){let n={...t,lastActiveAt:new Date().toISOString()};return S(n),I(),n}let r=Re();return S(r),I(),r}function gt(){return E()?.sessionId??null}function p(e){let t=E();if(!t)return{success:!1,session:null};let r=ct(t.stats),n=d({toolCalls:r.toolCalls+(e.toolCalls??0),errors:r.errors+(e.errors??0),rateLimits:r.rateLimits+(e.rateLimits??0),rateLimitsByProvider:be(r.rateLimitsByProvider,e.rateLimitsByProvider),charsSavedByTool:ut(r.charsSavedByTool,e.charsSavedByTool),githubCacheHits:lt(r.githubCacheHits,e.githubCacheHits),packageRegistryFailures:be(r.packageRegistryFailures,e.packageRegistryFailures)}),s={...t,lastActiveAt:new Date().toISOString(),stats:n};return S(s),{success:!0,session:s}}function St(e=1){return p({toolCalls:e})}function vt(e=1){return p({errors:e})}function Tt(e=1){return p({rateLimits:e})}function Ct(e,t=1){return p({rateLimits:t,rateLimitsByProvider:{[e]:t}})}function yt(e,t,r){let n=Number.isFinite(t)?Math.max(0,t):0,s=Number.isFinite(r)?Math.max(0,r):0;return p({charsSavedByTool:{[e]:{rawChars:n,responseChars:s,savedChars:Math.max(0,n-s),calls:1}}})}function kt(e,t=1){return p({githubCacheHits:{hits:{[e]:t},rateLimits:0}})}function bt(e=1){return p({githubCacheHits:{hits:{},rateLimits:e}})}function Rt(e,t=1){return p({packageRegistryFailures:{[e]:t}})}function Et(){let e=E();if(!e)return{success:!1,session:null};let t={...e,lastActiveAt:new Date().toISOString(),stats:_()};return S(t),{success:!0,session:t}}function Ot(){return V(),K(),z(),ye()}function xt(){ke()}export{k as SESSION_FILE,b as STATS_FILE,xt as _resetSessionState,Ot as deleteSession,pt as flushSession,ht as flushSessionSync,mt as getOrCreateSession,gt as getSessionId,vt as incrementErrors,kt as incrementGitHubCacheHits,bt as incrementGitHubCacheRateLimits,Rt as incrementPackageRegistryFailures,Ct as incrementRateLimitByProvider,Tt as incrementRateLimits,St as incrementToolCalls,yt as incrementToolCharSavings,ft as readSession,Et as resetSessionStats,p as updateSessionStats,dt as writeSession};
@@ -7,5 +7,10 @@
7
7
  */
8
8
  import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
9
9
  import { DirectToolInputError } from './directToolCatalog.meta.js';
10
+ type InitializeFn = () => Promise<void>;
11
+ /** @internal — test use only; not part of the public API. */
12
+ export declare function _overrideInitialize(fn: InitializeFn): void;
13
+ /** @internal — test use only; not part of the public API. */
14
+ export declare function _resetInitialize(): void;
10
15
  export declare function executeDirectTool(name: string, input: unknown): Promise<CallToolResult>;
11
16
  export { DirectToolInputError };
@@ -82,7 +82,6 @@ export declare const GitHubCloneRepoOutputLocalSchema: import("zod").ZodObject<{
82
82
  kind: import("zod").ZodString;
83
83
  }, import("zod/v4/core").$loose>]>>>;
84
84
  error: import("zod").ZodOptional<import("zod").ZodString>;
85
- hints: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
86
85
  base: import("zod").ZodOptional<import("zod").ZodString>;
87
86
  shared: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean]>>>;
88
87
  responsePagination: import("zod").ZodOptional<import("zod").ZodObject<{
@@ -73,17 +73,16 @@ export declare const GitHubFetchContentOutputLocalSchema: z.ZodObject<{
73
73
  totalPages: z.ZodNumber;
74
74
  hasMore: z.ZodBoolean;
75
75
  nextPage: z.ZodOptional<z.ZodNumber>;
76
- nextMatchPage: z.ZodOptional<z.ZodNumber>;
77
76
  charOffset: z.ZodOptional<z.ZodNumber>;
78
77
  charLength: z.ZodOptional<z.ZodNumber>;
79
78
  totalChars: z.ZodOptional<z.ZodNumber>;
80
79
  nextCharOffset: z.ZodOptional<z.ZodNumber>;
81
- filesPerPage: z.ZodOptional<z.ZodNumber>;
82
- totalFiles: z.ZodOptional<z.ZodNumber>;
83
- entriesPerPage: z.ZodOptional<z.ZodNumber>;
84
- totalEntries: z.ZodOptional<z.ZodNumber>;
85
- matchesPerPage: z.ZodOptional<z.ZodNumber>;
86
- totalMatches: z.ZodOptional<z.ZodNumber>;
80
+ }, z.core.$strip>>;
81
+ next: z.ZodOptional<z.ZodObject<{
82
+ continueChars: z.ZodOptional<z.ZodObject<{
83
+ tool: z.ZodLiteral<"ghGetFileContent">;
84
+ query: z.ZodRecord<z.ZodString, z.ZodUnknown>;
85
+ }, z.core.$strip>>;
87
86
  }, z.core.$strip>>;
88
87
  isPartial: z.ZodOptional<z.ZodBoolean>;
89
88
  startLine: z.ZodOptional<z.ZodNumber>;
@@ -58,18 +58,16 @@ export declare const GitHubCodeSearchOutputLocalSchema: z.ZodObject<{
58
58
  pagination: z.ZodOptional<z.ZodObject<{
59
59
  currentPage: z.ZodNumber;
60
60
  totalPages: z.ZodNumber;
61
- perPage: z.ZodNumber;
62
- totalMatches: z.ZodNumber;
63
- reportedTotalMatches: z.ZodOptional<z.ZodNumber>;
64
- reachableTotalMatches: z.ZodOptional<z.ZodNumber>;
61
+ hasMore: z.ZodBoolean;
62
+ nextPage: z.ZodOptional<z.ZodNumber>;
63
+ pageSize: z.ZodOptional<z.ZodNumber>;
64
+ totalItems: z.ZodOptional<z.ZodNumber>;
65
65
  totalMatchesKind: z.ZodOptional<z.ZodEnum<{
66
66
  exact: "exact";
67
67
  reported: "reported";
68
68
  lowerBound: "lowerBound";
69
69
  }>>;
70
70
  totalMatchesCapped: z.ZodOptional<z.ZodBoolean>;
71
- hasMore: z.ZodBoolean;
72
- nextPage: z.ZodOptional<z.ZodNumber>;
73
71
  uniqueFileCount: z.ZodOptional<z.ZodNumber>;
74
72
  }, z.core.$strip>>;
75
73
  }, z.core.$strip>;
@@ -206,7 +206,6 @@ export declare const GitHubSearchPullRequestsOutputLocalSchema: z.ZodObject<{
206
206
  kind: z.ZodString;
207
207
  }, z.core.$loose>]>>>;
208
208
  error: z.ZodOptional<z.ZodString>;
209
- hints: z.ZodOptional<z.ZodArray<z.ZodString>>;
210
209
  base: z.ZodOptional<z.ZodString>;
211
210
  shared: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
212
211
  responsePagination: z.ZodOptional<z.ZodObject<{
@@ -13,5 +13,63 @@ type RepositorySearchExtraFields = {
13
13
  };
14
14
  type PartialReposSearchQuery = WithOptionalMeta<GitHubReposSearchSingleQuery> & RepositorySearchExtraFields;
15
15
  export declare function formatRepoLine(repo: GitHubRepositoryOutput): string;
16
+ import type { RepoSearchResult as ProviderRepoSearchResult } from '../../providers/types.js';
17
+ import { type ProviderOperationResult } from '../providerExecution.js';
18
+ type RepoSearchVariantLabel = 'combined' | 'topics' | 'keywords';
19
+ interface RepoSearchVariant {
20
+ label: RepoSearchVariantLabel;
21
+ query: PartialReposSearchQuery;
22
+ }
23
+ interface RepoSearchVariantExecution {
24
+ label: RepoSearchVariantLabel;
25
+ query: PartialReposSearchQuery;
26
+ response: ProviderOperationResult<RepoSearchVariant, ProviderRepoSearchResult>['response'];
27
+ }
28
+ type SuccessfulRepoSearchVariant = RepoSearchVariantExecution & {
29
+ response: Extract<ProviderOperationResult<RepoSearchVariant, ProviderRepoSearchResult>, {
30
+ response: {
31
+ data: ProviderRepoSearchResult;
32
+ };
33
+ }>['response'] & {
34
+ data: ProviderRepoSearchResult;
35
+ };
36
+ };
37
+ export declare function buildResultPagination(pagination: {
38
+ currentPage: number;
39
+ totalPages: number;
40
+ hasMore: boolean;
41
+ entriesPerPage?: number;
42
+ totalMatches?: number;
43
+ reportedTotalMatches?: number;
44
+ reachableTotalMatches?: number;
45
+ totalMatchesKind?: 'exact' | 'reported' | 'lowerBound';
46
+ totalMatchesCapped?: boolean;
47
+ }): {
48
+ nextPage?: number;
49
+ hasMore: boolean;
50
+ totalMatchesCapped?: boolean;
51
+ totalMatchesKind?: "exact" | "reported" | "lowerBound";
52
+ reachableTotalMatches?: number;
53
+ reportedTotalMatches?: number;
54
+ totalMatches?: number;
55
+ currentPage: number;
56
+ totalPages: number;
57
+ perPage: number;
58
+ };
59
+ type EffectivePagination = {
60
+ currentPage: number;
61
+ totalPages: number;
62
+ hasMore: boolean;
63
+ entriesPerPage?: number;
64
+ totalMatches?: number;
65
+ reportedTotalMatches?: number;
66
+ reachableTotalMatches?: number;
67
+ totalMatchesKind?: 'exact' | 'reported' | 'lowerBound';
68
+ totalMatchesCapped?: boolean;
69
+ };
70
+ export declare function buildPartialFailureWarnings(failedVariants: readonly {
71
+ label: RepoSearchVariantLabel;
72
+ }[]): string[] | undefined;
73
+ export declare function buildMergedPagination(variants: SuccessfulRepoSearchVariant[], dedupedCount: number): EffectivePagination | undefined;
16
74
  export declare function searchMultipleGitHubRepos(args: ToolExecutionArgs<PartialReposSearchQuery>): Promise<CallToolResult>;
17
75
  export {};
@@ -68,21 +68,18 @@ export declare const GitHubSearchRepositoriesOutputLocalSchema: z.ZodObject<{
68
68
  currentPage: z.ZodNumber;
69
69
  totalPages: z.ZodNumber;
70
70
  hasMore: z.ZodBoolean;
71
- perPage: z.ZodOptional<z.ZodNumber>;
72
- totalMatches: z.ZodOptional<z.ZodNumber>;
73
- reportedTotalMatches: z.ZodOptional<z.ZodNumber>;
74
- reachableTotalMatches: z.ZodOptional<z.ZodNumber>;
71
+ nextPage: z.ZodOptional<z.ZodNumber>;
72
+ pageSize: z.ZodOptional<z.ZodNumber>;
73
+ totalItems: z.ZodOptional<z.ZodNumber>;
75
74
  totalMatchesKind: z.ZodOptional<z.ZodEnum<{
76
75
  exact: "exact";
77
76
  reported: "reported";
78
77
  lowerBound: "lowerBound";
79
78
  }>>;
80
79
  totalMatchesCapped: z.ZodOptional<z.ZodBoolean>;
81
- nextPage: z.ZodOptional<z.ZodNumber>;
82
80
  }, z.core.$strip>>;
83
81
  }, z.core.$loose>>;
84
82
  }, z.core.$loose>>>;
85
- hints: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
83
  base: z.ZodOptional<z.ZodString>;
87
84
  shared: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
88
85
  responsePagination: z.ZodOptional<z.ZodObject<{
@@ -70,7 +70,6 @@ export declare const GitHubViewRepoStructureOutputLocalSchema: import("zod").Zod
70
70
  kind: import("zod").ZodString;
71
71
  }, import("zod/v4/core").$loose>]>>>;
72
72
  error: import("zod").ZodOptional<import("zod").ZodString>;
73
- hints: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
74
73
  base: import("zod").ZodOptional<import("zod").ZodString>;
75
74
  shared: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean]>>>;
76
75
  responsePagination: import("zod").ZodOptional<import("zod").ZodObject<{
@@ -45,3 +45,100 @@ export declare const LocalBinaryInspectBulkQuerySchema: z.ZodObject<{
45
45
  responseCharLength: z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>;
46
46
  queries: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
47
47
  }, z.core.$strip>;
48
+ export declare const LocalBinaryInspectOutputSchema: z.ZodObject<{
49
+ results: z.ZodArray<z.ZodObject<{
50
+ id: z.ZodString;
51
+ status: z.ZodOptional<z.ZodEnum<{
52
+ empty: "empty";
53
+ error: "error";
54
+ success: "success";
55
+ }>>;
56
+ data: z.ZodUnion<readonly [z.ZodObject<{
57
+ path: z.ZodString;
58
+ mode: z.ZodLiteral<"inspect">;
59
+ format: z.ZodOptional<z.ZodString>;
60
+ size: z.ZodOptional<z.ZodNumber>;
61
+ isText: z.ZodOptional<z.ZodBoolean>;
62
+ encoding: z.ZodOptional<z.ZodString>;
63
+ symbols: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
+ imports: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
+ exports: z.ZodOptional<z.ZodArray<z.ZodString>>;
66
+ sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
67
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
+ }, z.core.$strip>, z.ZodObject<{
69
+ path: z.ZodString;
70
+ mode: z.ZodLiteral<"list">;
71
+ entries: z.ZodOptional<z.ZodArray<z.ZodObject<{
72
+ name: z.ZodString;
73
+ size: z.ZodOptional<z.ZodNumber>;
74
+ compressedSize: z.ZodOptional<z.ZodNumber>;
75
+ isDir: z.ZodOptional<z.ZodBoolean>;
76
+ modified: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strip>>>;
78
+ pagination: z.ZodOptional<z.ZodObject<{
79
+ currentPage: z.ZodNumber;
80
+ totalPages: z.ZodNumber;
81
+ hasMore: z.ZodBoolean;
82
+ nextPage: z.ZodOptional<z.ZodNumber>;
83
+ pageSize: z.ZodOptional<z.ZodNumber>;
84
+ totalItems: z.ZodOptional<z.ZodNumber>;
85
+ }, z.core.$strip>>;
86
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
87
+ }, z.core.$strip>, z.ZodObject<{
88
+ path: z.ZodString;
89
+ mode: z.ZodEnum<{
90
+ extract: "extract";
91
+ decompress: "decompress";
92
+ }>;
93
+ archiveFile: z.ZodOptional<z.ZodString>;
94
+ content: z.ZodOptional<z.ZodString>;
95
+ isPartial: z.ZodOptional<z.ZodBoolean>;
96
+ pagination: z.ZodOptional<z.ZodObject<{
97
+ charOffset: z.ZodNumber;
98
+ charLength: z.ZodNumber;
99
+ totalChars: z.ZodNumber;
100
+ hasMore: z.ZodBoolean;
101
+ nextCharOffset: z.ZodOptional<z.ZodNumber>;
102
+ currentPage: z.ZodOptional<z.ZodNumber>;
103
+ totalPages: z.ZodOptional<z.ZodNumber>;
104
+ chunkMode: z.ZodOptional<z.ZodEnum<{
105
+ semantic: "semantic";
106
+ "char-limit": "char-limit";
107
+ }>>;
108
+ }, z.core.$strip>>;
109
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
110
+ }, z.core.$strip>, z.ZodObject<{
111
+ path: z.ZodString;
112
+ mode: z.ZodLiteral<"strings">;
113
+ strings: z.ZodOptional<z.ZodArray<z.ZodObject<{
114
+ value: z.ZodString;
115
+ offset: z.ZodOptional<z.ZodNumber>;
116
+ }, z.core.$strip>>>;
117
+ content: z.ZodOptional<z.ZodString>;
118
+ totalStrings: z.ZodOptional<z.ZodNumber>;
119
+ scanOffset: z.ZodOptional<z.ZodNumber>;
120
+ nextScanOffset: z.ZodOptional<z.ZodNumber>;
121
+ hasMore: z.ZodOptional<z.ZodBoolean>;
122
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
123
+ }, z.core.$strip>, z.ZodObject<{
124
+ path: z.ZodString;
125
+ mode: z.ZodLiteral<"unpack">;
126
+ localPath: z.ZodOptional<z.ZodString>;
127
+ fileCount: z.ZodOptional<z.ZodNumber>;
128
+ totalSize: z.ZodOptional<z.ZodNumber>;
129
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
130
+ }, z.core.$strip>]>;
131
+ }, z.core.$strip>>;
132
+ base: z.ZodOptional<z.ZodString>;
133
+ shared: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
134
+ responsePagination: z.ZodOptional<z.ZodObject<{
135
+ currentPage: z.ZodNumber;
136
+ totalPages: z.ZodNumber;
137
+ hasMore: z.ZodBoolean;
138
+ charOffset: z.ZodNumber;
139
+ charLength: z.ZodNumber;
140
+ totalChars: z.ZodNumber;
141
+ nextCharOffset: z.ZodOptional<z.ZodNumber>;
142
+ }, z.core.$strip>>;
143
+ }, z.core.$strip>;
144
+ export type LocalBinaryInspectOutput = z.infer<typeof LocalBinaryInspectOutputSchema>;
@@ -29,3 +29,69 @@ export declare const LocalFetchContentBulkQuerySchema: z.ZodObject<{
29
29
  responseCharLength: z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>;
30
30
  queries: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
31
31
  }, z.core.$strip>;
32
+ export declare const LocalGetFileContentOutputSchema: z.ZodObject<{
33
+ results: z.ZodArray<z.ZodObject<{
34
+ id: z.ZodString;
35
+ status: z.ZodOptional<z.ZodEnum<{
36
+ empty: "empty";
37
+ error: "error";
38
+ }>>;
39
+ data: z.ZodObject<{
40
+ path: z.ZodOptional<z.ZodString>;
41
+ content: z.ZodOptional<z.ZodString>;
42
+ contentView: z.ZodOptional<z.ZodEnum<{
43
+ none: "none";
44
+ standard: "standard";
45
+ symbols: "symbols";
46
+ }>>;
47
+ isSkeleton: z.ZodOptional<z.ZodBoolean>;
48
+ totalLines: z.ZodOptional<z.ZodNumber>;
49
+ sourceChars: z.ZodOptional<z.ZodNumber>;
50
+ startLine: z.ZodOptional<z.ZodNumber>;
51
+ endLine: z.ZodOptional<z.ZodNumber>;
52
+ isPartial: z.ZodOptional<z.ZodBoolean>;
53
+ matchRanges: z.ZodOptional<z.ZodArray<z.ZodObject<{
54
+ start: z.ZodNumber;
55
+ end: z.ZodNumber;
56
+ }, z.core.$strip>>>;
57
+ pagination: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
58
+ charOffset: z.ZodNumber;
59
+ charLength: z.ZodNumber;
60
+ totalChars: z.ZodNumber;
61
+ hasMore: z.ZodBoolean;
62
+ nextCharOffset: z.ZodOptional<z.ZodNumber>;
63
+ currentPage: z.ZodOptional<z.ZodNumber>;
64
+ totalPages: z.ZodOptional<z.ZodNumber>;
65
+ chunkMode: z.ZodOptional<z.ZodEnum<{
66
+ semantic: "semantic";
67
+ "char-limit": "char-limit";
68
+ }>>;
69
+ }, z.core.$strip>, z.ZodObject<{
70
+ currentPage: z.ZodNumber;
71
+ totalPages: z.ZodNumber;
72
+ hasMore: z.ZodBoolean;
73
+ nextPage: z.ZodOptional<z.ZodNumber>;
74
+ pageSize: z.ZodOptional<z.ZodNumber>;
75
+ totalItems: z.ZodOptional<z.ZodNumber>;
76
+ }, z.core.$strip>]>>;
77
+ modified: z.ZodOptional<z.ZodString>;
78
+ lastModified: z.ZodOptional<z.ZodString>;
79
+ lastModifiedBy: z.ZodOptional<z.ZodString>;
80
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
81
+ matchNotFound: z.ZodOptional<z.ZodBoolean>;
82
+ searchedFor: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strip>;
84
+ }, z.core.$strip>>;
85
+ base: z.ZodOptional<z.ZodString>;
86
+ shared: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
87
+ responsePagination: z.ZodOptional<z.ZodObject<{
88
+ currentPage: z.ZodNumber;
89
+ totalPages: z.ZodNumber;
90
+ hasMore: z.ZodBoolean;
91
+ charOffset: z.ZodNumber;
92
+ charLength: z.ZodNumber;
93
+ totalChars: z.ZodNumber;
94
+ nextCharOffset: z.ZodOptional<z.ZodNumber>;
95
+ }, z.core.$strip>>;
96
+ }, z.core.$strip>;
97
+ export type LocalGetFileContentOutput = z.infer<typeof LocalGetFileContentOutputSchema>;
@@ -7,3 +7,52 @@ export declare const LocalFindFilesBulkQuerySchema: z.ZodObject<{
7
7
  responseCharLength: z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>;
8
8
  queries: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
9
9
  }, z.core.$strip>;
10
+ export declare const LocalFindFilesOutputSchema: z.ZodObject<{
11
+ results: z.ZodArray<z.ZodObject<{
12
+ id: z.ZodString;
13
+ status: z.ZodOptional<z.ZodEnum<{
14
+ empty: "empty";
15
+ error: "error";
16
+ }>>;
17
+ data: z.ZodObject<{
18
+ files: z.ZodOptional<z.ZodArray<z.ZodObject<{
19
+ name: z.ZodOptional<z.ZodString>;
20
+ path: z.ZodOptional<z.ZodString>;
21
+ type: z.ZodOptional<z.ZodEnum<{
22
+ file: "file";
23
+ link: "link";
24
+ directory: "directory";
25
+ dir: "dir";
26
+ symlink: "symlink";
27
+ }>>;
28
+ size: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
29
+ modified: z.ZodOptional<z.ZodString>;
30
+ accessed: z.ZodOptional<z.ZodString>;
31
+ created: z.ZodOptional<z.ZodString>;
32
+ permissions: z.ZodOptional<z.ZodString>;
33
+ }, z.core.$strip>>>;
34
+ summary: z.ZodOptional<z.ZodString>;
35
+ pagination: z.ZodOptional<z.ZodObject<{
36
+ currentPage: z.ZodNumber;
37
+ totalPages: z.ZodNumber;
38
+ hasMore: z.ZodBoolean;
39
+ nextPage: z.ZodOptional<z.ZodNumber>;
40
+ pageSize: z.ZodOptional<z.ZodNumber>;
41
+ totalItems: z.ZodOptional<z.ZodNumber>;
42
+ }, z.core.$strip>>;
43
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
44
+ }, z.core.$strip>;
45
+ }, z.core.$strip>>;
46
+ base: z.ZodOptional<z.ZodString>;
47
+ shared: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
48
+ responsePagination: z.ZodOptional<z.ZodObject<{
49
+ currentPage: z.ZodNumber;
50
+ totalPages: z.ZodNumber;
51
+ hasMore: z.ZodBoolean;
52
+ charOffset: z.ZodNumber;
53
+ charLength: z.ZodNumber;
54
+ totalChars: z.ZodNumber;
55
+ nextCharOffset: z.ZodOptional<z.ZodNumber>;
56
+ }, z.core.$strip>>;
57
+ }, z.core.$strip>;
58
+ export type LocalFindFilesOutput = z.infer<typeof LocalFindFilesOutputSchema>;