@octocodeai/octocode-tools-core 16.5.1 → 16.6.2
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/README.md +200 -254
- package/dist/direct.js +37 -33
- package/dist/errors/localToolErrors.d.ts +1 -0
- package/dist/github/githubAPI.d.ts +22 -0
- package/dist/github/history.d.ts +3 -0
- package/dist/github/prTransformation.d.ts +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/index.js +44 -40
- package/dist/oql/adapters/compile.d.ts +25 -0
- package/dist/oql/adapters/github.d.ts +3 -0
- package/dist/oql/adapters/local.d.ts +8 -0
- package/dist/oql/adapters/materialize.d.ts +11 -0
- package/dist/oql/adapters/pagination.d.ts +21 -0
- package/dist/oql/adapters/researchTargets.d.ts +50 -0
- package/dist/oql/adapters/resultMap.d.ts +20 -0
- package/dist/oql/adapters/ruleYaml.d.ts +11 -0
- package/dist/oql/adapters/runner.d.ts +14 -0
- package/dist/oql/adapters/v2.d.ts +32 -0
- package/dist/oql/capabilities.d.ts +31 -0
- package/dist/oql/defaults.d.ts +26 -0
- package/dist/oql/diagnostics.d.ts +25 -0
- package/dist/oql/diffLanes.d.ts +29 -0
- package/dist/oql/envelope.d.ts +21 -0
- package/dist/oql/features.d.ts +7 -0
- package/dist/oql/index.d.ts +27 -0
- package/dist/oql/index.js +49 -0
- package/dist/oql/normalize.d.ts +5 -0
- package/dist/oql/planner.d.ts +7 -0
- package/dist/oql/research/analyze.d.ts +134 -0
- package/dist/oql/research/packets.d.ts +80 -0
- package/dist/oql/run.d.ts +32 -0
- package/dist/oql/schema.d.ts +1018 -0
- package/dist/oql/schemeText.d.ts +154 -0
- package/dist/oql/shorthand.d.ts +177 -0
- package/dist/oql/targetParams.d.ts +20 -0
- package/dist/oql/transformers/contract.d.ts +19 -0
- package/dist/oql/transformers/github/code.d.ts +17 -0
- package/dist/oql/transformers/github/common.d.ts +8 -0
- package/dist/oql/transformers/language.d.ts +1 -0
- package/dist/oql/transformers/registry.d.ts +16 -0
- package/dist/oql/transformers/types.d.ts +11 -0
- package/dist/oql/types.d.ts +640 -0
- package/dist/oql/v2params.d.ts +22 -0
- package/dist/providers/types.d.ts +1 -1
- package/dist/schema.d.ts +13 -0
- package/dist/schema.js +9 -0
- package/dist/serverConfig.d.ts +0 -1
- package/dist/session.d.ts +2 -24
- package/dist/shared/config/defaults.d.ts +1 -2
- package/dist/shared/config/index.d.ts +2 -3
- package/dist/shared/config/index.js +2 -3
- package/dist/shared/config/resolverSections.d.ts +1 -3
- package/dist/shared/config/runtimeSurface.d.ts +5 -4
- package/dist/shared/config/schemas.d.ts +0 -1
- package/dist/shared/config/types.d.ts +0 -8
- package/dist/shared/credentials/envTokens.d.ts +1 -1
- package/dist/shared/credentials/index.js +1 -2
- package/dist/shared/credentials/types.d.ts +1 -1
- package/dist/shared/index.d.ts +0 -1
- package/dist/shared/languageSelectors.d.ts +23 -0
- package/dist/shared/paths.d.ts +2 -3
- package/dist/shared/paths.js +1 -1
- package/dist/shared/session/index.js +1 -2
- package/dist/tools/directToolCatalog.d.ts +15 -56
- package/dist/tools/directToolCatalog.exec.d.ts +11 -0
- package/dist/tools/directToolCatalog.meta.d.ts +83 -0
- package/dist/tools/github_clone_repo/cache.d.ts +1 -1
- package/dist/tools/github_clone_repo/types.d.ts +2 -0
- package/dist/tools/github_fetch_content/scheme.d.ts +81 -59
- package/dist/tools/github_fetch_content/types.d.ts +27 -0
- package/dist/tools/local_binary_inspect/binaryInspector.d.ts +0 -4
- package/dist/tools/lsp/semantic_content/scheme.d.ts +164 -10
- package/dist/tools/lsp/shared/resolveSymbolAnchor.d.ts +2 -2
- package/dist/tools/lsp/shared/semanticTypes.d.ts +34 -5
- package/dist/tools/oql_search/execution.d.ts +7 -0
- package/dist/tools/package_search/execution.d.ts +33 -0
- package/dist/tools/package_search/scheme.d.ts +8 -0
- package/dist/tools/providerMappers.d.ts +7 -7
- package/dist/tools/toolConfig.d.ts +1 -0
- package/dist/tools/toolNames.d.ts +2 -0
- package/dist/types/server.d.ts +1 -2
- package/dist/types/session.d.ts +0 -19
- package/dist/utils/contextUtils.d.ts +15 -1
- package/dist/utils/core/types.d.ts +2 -1
- package/dist/utils/markdownOutline.d.ts +10 -0
- package/dist/utils/response/groupedFinalizer.d.ts +0 -23
- package/package.json +14 -3
- package/dist/commands/BaseCommandBuilder.d.ts +0 -14
- package/dist/commands/FindCommandBuilder.d.ts +0 -23
- package/dist/commands/LsCommandBuilder.d.ts +0 -15
- package/dist/shared/logger/index.d.ts +0 -2
- package/dist/shared/logger/logger.d.ts +0 -17
- package/dist/utils/pagination/outputSizeLimit.d.ts +0 -16
- package/dist/utils/ranking/evidenceRanker.d.ts +0 -86
- package/dist/utils/response/structuredPagination.d.ts +0 -9
|
@@ -5,5 +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 kt}from"node:crypto";import{existsSync as Z,readFileSync as Re,writeFileSync as lt,unlinkSync as ft,renameSync as dt}from"node:fs";var He=null;function Oe(e){let t=`[${e.module}]`,r=e.data&&Object.keys(e.data).length>0?` ${JSON.stringify(e.data)}`:"";process.stderr.write(`${t} ${e.level}: ${e.message}${r}
|
|
9
|
-
`)}function S(e){function t(r,s,n){let i={level:r,module:e,message:s,...n&&{data:n}};(He??Oe)(i)}return{debug:(r,s)=>t("debug",r,s),info:(r,s)=>t("info",r,s),warn:(r,s)=>t("warn",r,s),error:(r,s)=>t("error",r,s)}}function g(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function w(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 W(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var A=new Map,De=300*1e3;function _e(e){let t=g(e),r=A.get(t);return!r||Date.now()-r.cachedAt>=De?!1:r.credentials?!w(r.credentials):!0}function te(e){e?A.delete(g(e)):A.clear()}function re(e){let t=g(e);if(_e(t))return A.get(t).credentials}function se(e,t){let r=g(e);A.set(r,{credentials:t,cachedAt:Date.now()})}import{existsSync as ae,readFileSync as ce,writeFileSync as ue,unlinkSync as lr,statSync as We,chmodSync as $e}from"node:fs";import{createCipheriv as Ke,createDecipheriv as Ve,randomBytes as le}from"node:crypto";import{existsSync as Ne,mkdirSync as Ge}from"node:fs";import{join as a}from"node:path";import N from"node:os";import Fe from"node:path";var G=N.platform()==="win32",$=N.platform()==="darwin",Ie=N.platform()==="linux",y=N.homedir();function K(){return G?process.env.APPDATA||Fe.join(y,"AppData","Roaming"):y}var V=".octocode",Me=448;function je(e){let t=process.env[e];return t&&t.trim().length>0?t:void 0}function Ue(){return G?a(K(),V):$?a(y,V):a(je("XDG_CONFIG_HOME")??a(y,".config"),V)}var u=Ue(),f={home:u,config:a(u,".octocoderc"),credentials:a(u,"credentials.json"),key:a(u,".key"),session:a(u,"session.json"),stats:a(u,"stats.json"),tmp:a(u,"tmp"),clone:a(u,"tmp","clone"),tree:a(u,"tmp","tree"),binary:a(u,"tmp","binary"),repos:a(u,"tmp","clone"),logs:a(u,"logs"),unzip:a(u,"tmp","unzip"),cliConfig:a(u,"config.json"),lspConfig:a(u,"lsp-servers.json")};function ne(){Ne(f.home)||Ge(f.home,{recursive:!0,mode:Me})}import{z as c}from"zod";var Be=c.object({token:c.string(),tokenType:c.literal("oauth"),scopes:c.array(c.string()).optional(),refreshToken:c.string().optional(),expiresAt:c.string().optional(),refreshTokenExpiresAt:c.string().optional()}),ze=c.object({hostname:c.string(),username:c.string(),token:Be,gitProtocol:c.enum(["ssh","https"]),createdAt:c.string(),updatedAt:c.string()}),oe=c.object({version:c.number(),credentials:c.record(c.string(),ze)});var ie=S("token-storage");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***")}var Ze=f.home,R=f.credentials,v=f.key,fe="aes-256-gcm",qe=16;function b(){ne()}function de(){if(b(),ae(v))return We(v).mode&511&63&&$e(v,384),Buffer.from(ce(v,"utf8"),"hex");let e=le(32);return ue(v,e.toString("hex"),{mode:384}),e}function pe(e){let t=de(),r=le(qe),s=Ke(fe,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 me(e){let t=de(),[r,s,n]=e.split(":");if(!r||!s||!n)throw new Error("Invalid encrypted data format");let i=Buffer.from(r,"hex"),x=Buffer.from(s,"hex"),m=Ve(fe,t,i);m.setAuthTag(x);let ee=m.update(n,"hex","utf8");return ee+=m.final("utf8"),ee}function J(){if(b(),!ae(R))return{version:1,credentials:{}};try{let e=ce(R,"utf8"),t=me(e),r=JSON.parse(t),s=oe.safeParse(r);return s.success?s.data:(ie.warn("Credentials file has invalid format \u2014 starting fresh",{file:R}),{version:1,credentials:{}})}catch(e){let t=e instanceof Error&&e.message?Je(e.message):void 0;return ie.warn("Could not read credentials file \u2014 you may need to login again",{file:R,...t&&{reason:t}}),{version:1,credentials:{}}}}function ge(e){b();let t=pe(JSON.stringify(e,null,2));ue(R,t,{mode:384})}import{refreshToken as Ye}from"@octokit/oauth-methods";import{request as Xe}from"@octokit/request";var M="178c6fc778ccc68e1d6a",P="github.com";function Qe(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 et(e){return e==="github.com"||e===P?"https://api.github.com":`https://${e}/api/v3`}async function he(e,t=P,r=M){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(W(s))return{success:!1,error:"Refresh token has expired. Please login again."};try{let n=await Ye({clientType:"github-app",clientId:r,clientSecret:"",refreshToken:s.token.refreshToken,request:Xe.defaults({baseUrl:et(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?Qe(n.message):"Token refresh failed"}}}async function Se(e,t=P,r=M){let s=await e.getCredentials(t);if(!s||!s.token)return{token:null,source:"none"};if(!w(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 Rr}from"child_process";var tt=null;function Ce(e){tt=e}var rt=S("token-storage");async function st(e){let t=g(e.hostname),r={...e,hostname:t,updatedAt:new Date().toISOString()};try{let s=J();return s.credentials[t]=r,ge(s),te(t),{success:!0}}catch(s){let n=s instanceof Error?s.message:String(s);throw rt.error("CRITICAL: Storage failed",{error:n.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***")}),new Error("Failed to store credentials")}}async function ke(e="github.com",t){let r=g(e);if(!t?.bypassCache){let i=re(r);if(i!==void 0)return i}let n=J().credentials[r]||null;return se(r,n),n}async function nt(e,t){let r=await ke(e);return r?(r.token=t,r.updatedAt=new Date().toISOString(),await st(r),!0):!1}async function ot(e,t){return Se({getCredentials:ke,updateToken:nt},e,t)}Ce({getTokenWithRefresh:ot});import{z as o}from"zod";var it=o.object({rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),calls:o.number()}),at=o.object({hits:o.record(o.string(),o.number()).default({}),rateLimits:o.number().default(0)}),j=o.record(o.string(),o.number()).default({}),ct=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:j,rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),charSavingsCalls:o.number(),githubCacheHits:o.number(),githubCacheRateLimits:o.number(),packageRegistryFailures:o.number().default(0),packageRegistryFailuresByRegistry:j}),U=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:j,charsSavedByTool:o.record(o.string(),it).default({}),githubCacheHits:at.default({hits:{},rateLimits:0}),packageRegistryFailures:j,totalUsage:ct.optional()}),Te=o.object({version:o.literal(1),sessionId:o.string(),createdAt:o.string(),lastActiveAt:o.string(),stats:U.optional()}),xe=o.object({version:o.literal(1),stats:U});function ye(e){return Object.values(e).reduce((t,r)=>t+r,0)}function ut(e){let t=e.charsSavedByTool??{},r=e.githubCacheHits??{hits:{},rateLimits:0},s=e.rateLimitsByProvider??{},n=e.packageRegistryFailures??{},i=Object.values(t).reduce((x,m)=>({rawChars:x.rawChars+m.rawChars,responseChars:x.responseChars+m.responseChars,savedChars:x.savedChars+m.savedChars,charSavingsCalls:x.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:ye(r.hits),githubCacheRateLimits:r.rateLimits,packageRegistryFailures:ye(n),packageRegistryFailuresByRegistry:n}}function d(e){let t={...e,rateLimitsByProvider:e.rateLimitsByProvider??{},charsSavedByTool:e.charsSavedByTool??{},githubCacheHits:e.githubCacheHits??{hits:{},rateLimits:0},packageRegistryFailures:e.packageRegistryFailures??{}};return{...t,totalUsage:ut(t)}}function H(){return d({toolCalls:0,errors:0,rateLimits:0,rateLimitsByProvider:{},charsSavedByTool:{},githubCacheHits:{hits:{},rateLimits:0},packageRegistryFailures:{}})}var be=S("session"),C=f.session,k=f.stats;function ve(e,t){let r=`${e}.tmp`;lt(r,JSON.stringify(t,null,2),{mode:384}),dt(r,e)}function pt(e){let{stats:t,...r}=e;return r}function mt(e){let t=JSON.parse(e),r=xe.safeParse(t);if(r.success)return d(r.data.stats);let s=U.safeParse(t);return s.success?d(s.data):null}function gt(e){let t=e?d(e):H();if(!Z(k))return t;try{let r=Re(k,"utf8"),s=mt(r);return s||(be.warn("Stats file has invalid format",{file:k}),t)}catch{return t}}function B(e){b(),ve(k,{version:e.version,stats:d(e.stats)}),ve(C,pt(e))}function Ee(){if(!Z(C))return null;try{let e=Re(C,"utf8"),t=JSON.parse(e),r=Te.safeParse(t);return r.success?{...r.data,stats:gt(r.data.stats)}:(be.warn("Session file has invalid format",{file:C}),null)}catch{return null}}function Le(){let e=!1;for(let t of[C,k])if(Z(t))try{ft(t),e=!0}catch{return!1}return e}var ht=6e4,l=null,h=!1,E=null,q=!1,O=null,D=null,_=null,z=!1;function St(){q||(q=!0,O=()=>{F()},D=()=>{F()},_=()=>{F()},process.on("exit",O),process.on("SIGINT",D),process.on("SIGTERM",_))}function Y(){O&&(process.removeListener("exit",O),O=null),D&&(process.removeListener("SIGINT",D),D=null),_&&(process.removeListener("SIGTERM",_),_=null),q=!1}function Ct(){E||(E=setInterval(()=>{h&&l&&(B(l),h=!1)},ht),E.unref())}function X(){E&&(clearInterval(E),E=null)}function L(){if(l)return l;let e=Ee();return e&&(l=e),e}function T(e){l=e,h=!0,St(),Ct()}function I(){h&&l&&(B(l),h=!1)}function F(){if(!z&&h&&l){z=!0;try{B(l),h=!1}catch{}finally{z=!1}}}function Q(){l=null,h=!1,z=!1}function we(){Q(),X(),Y()}var Tt=1;function xt(e){return d(e)}function yt(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 Ae(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 vt(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 Pe(){let e=new Date().toISOString();return{version:Tt,sessionId:kt(),createdAt:e,lastActiveAt:e,stats:H()}}function Rt(){return L()}function bt(e){T(e)}function Et(){I()}function Lt(){F()}function wt(e){if(e?.forceNew){let s=Pe();return T(s),I(),s}let t=L();if(t){let s={...t,lastActiveAt:new Date().toISOString()};return T(s),I(),s}let r=Pe();return T(r),I(),r}function At(){return L()?.sessionId??null}function p(e){let t=L();if(!t)return{success:!1,session:null};let r=xt(t.stats),s=d({toolCalls:r.toolCalls+(e.toolCalls??0),errors:r.errors+(e.errors??0),rateLimits:r.rateLimits+(e.rateLimits??0),rateLimitsByProvider:Ae(r.rateLimitsByProvider,e.rateLimitsByProvider),charsSavedByTool:yt(r.charsSavedByTool,e.charsSavedByTool),githubCacheHits:vt(r.githubCacheHits,e.githubCacheHits),packageRegistryFailures:Ae(r.packageRegistryFailures,e.packageRegistryFailures)}),n={...t,lastActiveAt:new Date().toISOString(),stats:s};return T(n),{success:!0,session:n}}function Pt(e=1){return p({toolCalls:e})}function Ht(e=1){return p({errors:e})}function Ot(e=1){return p({rateLimits:e})}function Dt(e,t=1){return p({rateLimits:t,rateLimitsByProvider:{[e]:t}})}function _t(e,t,r){let s=Number.isFinite(t)?Math.max(0,t):0,n=Number.isFinite(r)?Math.max(0,r):0;return p({charsSavedByTool:{[e]:{rawChars:s,responseChars:n,savedChars:Math.max(0,s-n),calls:1}}})}function Ft(e,t=1){return p({githubCacheHits:{hits:{[e]:t},rateLimits:0}})}function It(e=1){return p({githubCacheHits:{hits:{},rateLimits:e}})}function Nt(e,t=1){return p({packageRegistryFailures:{[e]:t}})}function Gt(){let e=L();if(!e)return{success:!1,session:null};let t={...e,lastActiveAt:new Date().toISOString(),stats:H()};return T(t),{success:!0,session:t}}function Mt(){return Q(),X(),Y(),Le()}function jt(){we()}export{C as SESSION_FILE,k as STATS_FILE,jt as _resetSessionState,Mt as deleteSession,Et as flushSession,Lt as flushSessionSync,wt as getOrCreateSession,At as getSessionId,Ht as incrementErrors,Ft as incrementGitHubCacheHits,It as incrementGitHubCacheRateLimits,Nt as incrementPackageRegistryFailures,Dt as incrementRateLimitByProvider,Ot as incrementRateLimits,Pt as incrementToolCalls,_t as incrementToolCharSavings,Rt as readSession,Gt as resetSessionStats,p as updateSessionStats,bt as writeSession};
|
|
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};
|
|
@@ -1,56 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
type: string;
|
|
17
|
-
/** Numeric bounds and default, e.g. "1-100, default 30" — surfaced inline so
|
|
18
|
-
* agents see the full constraint without fetching the raw JSON schema. */
|
|
19
|
-
constraints?: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface DirectToolOutputField {
|
|
23
|
-
name: string;
|
|
24
|
-
type: string;
|
|
25
|
-
optional?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface DirectToolMetadata {
|
|
28
|
-
tools?: Record<string, {
|
|
29
|
-
description?: string;
|
|
30
|
-
schema?: Record<string, string>;
|
|
31
|
-
}>;
|
|
32
|
-
}
|
|
33
|
-
export interface PrepareDirectToolInputOptions {
|
|
34
|
-
sourceLabel?: string;
|
|
35
|
-
onUnknownFields?: (unknownFields: string[], queryIndex: number) => void;
|
|
36
|
-
}
|
|
37
|
-
export declare class DirectToolInputError extends Error {
|
|
38
|
-
readonly details: string[];
|
|
39
|
-
constructor(message: string, details?: string[]);
|
|
40
|
-
}
|
|
41
|
-
export declare const DIRECT_TOOL_DEFINITIONS: DirectToolDefinition[];
|
|
42
|
-
export declare function findDirectToolDefinition(name: string): DirectToolDefinition | undefined;
|
|
43
|
-
export declare function getDirectToolCategory(toolName: string): DirectToolCategory;
|
|
44
|
-
export declare function sortDirectToolNames(toolNames: string[]): string[];
|
|
45
|
-
export declare function formatDirectToolSchemaText(toolName: string): string;
|
|
46
|
-
export declare function formatDirectToolMetadataSchemaText(schema: Record<string, string> | undefined): string;
|
|
47
|
-
export declare function getDirectToolAutoFilledFields(toolName: string): string[];
|
|
48
|
-
export declare function getDirectToolOutputFields(): DirectToolOutputField[];
|
|
49
|
-
export declare function formatDirectToolOutputSchemaText(): string;
|
|
50
|
-
export declare function getDirectToolDescription(toolName: string, metadata?: DirectToolMetadata | null): string;
|
|
51
|
-
export declare function getDirectToolDisplayFields(toolName: string): DirectToolDisplayField[];
|
|
52
|
-
export declare function buildDirectToolExampleQuery(toolName: string): Record<string, unknown>;
|
|
53
|
-
export declare function prepareDirectToolInputFromJsonText(toolName: string, inputText: string | undefined, options?: PrepareDirectToolInputOptions): DirectToolInput | null;
|
|
54
|
-
export declare function prepareDirectToolInput(toolName: string, rawPayload: unknown, options?: PrepareDirectToolInputOptions): DirectToolInput;
|
|
55
|
-
export declare function formatDirectToolValidationIssues(error: z.ZodError): string[];
|
|
56
|
-
export declare function executeDirectTool(name: string, input: unknown): Promise<CallToolResult>;
|
|
1
|
+
/**
|
|
2
|
+
* Direct-tool catalog barrel (P3). The catalog is split so the schema/help path
|
|
3
|
+
* never loads the native engine:
|
|
4
|
+
* - `directToolCatalog.meta.ts` — engine-free definitions, schema text,
|
|
5
|
+
* display fields, input preparation (also exposed via the `/schema` subpath).
|
|
6
|
+
* - `directToolCatalog.exec.ts` — `executeDirectTool` + the engine/runtime.
|
|
7
|
+
*
|
|
8
|
+
* This barrel preserves the historical `@octocodeai/octocode-tools-core/direct`
|
|
9
|
+
* surface (meta + executeDirectTool). Importing it still eagerly loads the engine
|
|
10
|
+
* (via the exec module) — execution consumers want that. Pure schema/help/
|
|
11
|
+
* `--scheme`/`context` callers must import from `/schema` (meta only) instead, so
|
|
12
|
+
* they run on engine-less runtimes.
|
|
13
|
+
*/
|
|
14
|
+
export * from './directToolCatalog.meta.js';
|
|
15
|
+
export { executeDirectTool } from './directToolCatalog.exec.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Direct-tool EXECUTION path (P3). This module imports the engine (native LSP
|
|
3
|
+
* client pool) and every tool's execution function via `ALL_TOOLS`, so it is the
|
|
4
|
+
* one that loads the native `.node` addon at eval. It is reached only when a tool
|
|
5
|
+
* actually runs — schema/help/`--scheme`/`context` use `directToolCatalog.meta.ts`
|
|
6
|
+
* (and the `@octocodeai/octocode-tools-core/schema` subpath), which is engine-free.
|
|
7
|
+
*/
|
|
8
|
+
import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
+
import { DirectToolInputError } from './directToolCatalog.meta.js';
|
|
10
|
+
export declare function executeDirectTool(name: string, input: unknown): Promise<CallToolResult>;
|
|
11
|
+
export { DirectToolInputError };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine-free direct-tool catalog metadata (P3).
|
|
3
|
+
*
|
|
4
|
+
* This module holds EVERYTHING the schema/help/`--scheme`/`context` paths need
|
|
5
|
+
* — tool definitions (name + display/bulk zod schemas), schema-text formatters,
|
|
6
|
+
* display-field extraction, example builders, and input preparation — WITHOUT
|
|
7
|
+
* importing `@octocodeai/octocode-engine` (no native `.node` load at module
|
|
8
|
+
* eval). The schemas are sourced from each tool's engine-free `scheme.ts`, the
|
|
9
|
+
* same modules `toolConfig.ts` consumes, so the two cannot drift on shape (a
|
|
10
|
+
* drift test asserts name/schema parity against the runtime `ALL_TOOLS`).
|
|
11
|
+
*
|
|
12
|
+
* The execution path (`executeDirectTool`) lives in `directToolCatalog.exec.ts`,
|
|
13
|
+
* which DOES import the engine; it is only reached when a tool actually runs.
|
|
14
|
+
* The `@octocodeai/octocode-tools-core/schema` subpath re-exports only this
|
|
15
|
+
* module so engine-less runtimes (e.g. Codex.app Node) can read schemas.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
export type DirectToolInput = Record<string, unknown> & {
|
|
19
|
+
queries: unknown[];
|
|
20
|
+
};
|
|
21
|
+
export interface DirectToolDefinition {
|
|
22
|
+
name: string;
|
|
23
|
+
schema: z.ZodType;
|
|
24
|
+
inputSchema: z.ZodType;
|
|
25
|
+
}
|
|
26
|
+
export type DirectToolCategory = 'GitHub' | 'Local Code' | 'Package' | 'Other';
|
|
27
|
+
export declare const DIRECT_TOOL_CATEGORIES: readonly DirectToolCategory[];
|
|
28
|
+
export interface DirectToolDisplayField {
|
|
29
|
+
name: string;
|
|
30
|
+
required: boolean;
|
|
31
|
+
type: string;
|
|
32
|
+
/** Numeric bounds and default, e.g. "1-100, default 30" — surfaced inline so
|
|
33
|
+
* agents see the full constraint without fetching the raw JSON schema. */
|
|
34
|
+
constraints?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface DirectToolCommandPattern {
|
|
38
|
+
label: string;
|
|
39
|
+
query: Record<string, unknown>;
|
|
40
|
+
command: string;
|
|
41
|
+
}
|
|
42
|
+
export interface DirectToolOutputField {
|
|
43
|
+
name: string;
|
|
44
|
+
type: string;
|
|
45
|
+
optional?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface DirectToolMetadata {
|
|
48
|
+
tools?: Record<string, {
|
|
49
|
+
description?: string;
|
|
50
|
+
schema?: Record<string, string>;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
export interface PrepareDirectToolInputOptions {
|
|
54
|
+
sourceLabel?: string;
|
|
55
|
+
rejectUnknownFields?: boolean;
|
|
56
|
+
onUnknownFields?: (unknownFields: string[], queryIndex: number) => void;
|
|
57
|
+
}
|
|
58
|
+
export declare class DirectToolInputError extends Error {
|
|
59
|
+
readonly details: string[];
|
|
60
|
+
constructor(message: string, details?: string[]);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Engine-free tool definitions (name + display/bulk schema). Order mirrors
|
|
64
|
+
* `ALL_TOOLS` in `toolConfig.ts`; each schema is the SAME object that
|
|
65
|
+
* `toolConfig` attaches an executionFn to. Kept in lockstep by a drift test.
|
|
66
|
+
*/
|
|
67
|
+
export declare const DIRECT_TOOL_DEFINITIONS: DirectToolDefinition[];
|
|
68
|
+
export declare function findDirectToolDefinition(name: string): DirectToolDefinition | undefined;
|
|
69
|
+
export declare function getDirectToolCategory(toolName: string): DirectToolCategory;
|
|
70
|
+
export declare function sortDirectToolNames(toolNames: string[]): string[];
|
|
71
|
+
export declare function formatDirectToolSchemaText(toolName: string): string;
|
|
72
|
+
export declare function formatDirectToolMetadataSchemaText(schema: Record<string, string> | undefined): string;
|
|
73
|
+
export declare function getDirectToolAutoFilledFields(toolName: string): string[];
|
|
74
|
+
export declare function getDirectToolOutputFields(): DirectToolOutputField[];
|
|
75
|
+
export declare function formatDirectToolOutputSchemaText(): string;
|
|
76
|
+
export declare function getDirectToolDescription(toolName: string, metadata?: DirectToolMetadata | null): string;
|
|
77
|
+
export declare function getDirectToolDisplayFields(toolName: string): DirectToolDisplayField[];
|
|
78
|
+
export declare function formatDirectToolCommandPattern(toolName: string, query: Record<string, unknown>): string;
|
|
79
|
+
export declare function buildDirectToolCommandPatterns(toolName: string): DirectToolCommandPattern[];
|
|
80
|
+
export declare function buildDirectToolExampleQuery(toolName: string): Record<string, unknown>;
|
|
81
|
+
export declare function prepareDirectToolInputFromJsonText(toolName: string, inputText: string | undefined, options?: PrepareDirectToolInputOptions): DirectToolInput | null;
|
|
82
|
+
export declare function prepareDirectToolInput(toolName: string, rawPayload: unknown, options?: PrepareDirectToolInputOptions): DirectToolInput;
|
|
83
|
+
export declare function formatDirectToolValidationIssues(error: z.ZodError): string[];
|
|
@@ -16,7 +16,7 @@ export declare function isCacheHit(cloneDir: string): {
|
|
|
16
16
|
export declare function getCacheTTL(): number;
|
|
17
17
|
export declare function getMaxCacheSizeBytes(): number;
|
|
18
18
|
export declare function getMaxCloneCount(): number;
|
|
19
|
-
export declare function createCacheMeta(owner: string, repo: string, branch: string, source: CacheSource, sparsePath?: string, sizeBytes?: number): CloneCacheMeta;
|
|
19
|
+
export declare function createCacheMeta(owner: string, repo: string, branch: string, source: CacheSource, sparsePath?: string, sizeBytes?: number, commitSha?: string): CloneCacheMeta;
|
|
20
20
|
export declare function ensureCloneParentDir(cloneDir: string): void;
|
|
21
21
|
export declare function removeCloneDir(cloneDir: string): void;
|
|
22
22
|
export declare function evictExpiredClones(octocodeDir: string): number;
|
|
@@ -50,68 +50,90 @@ export declare const GitHubFetchContentOutputLocalSchema: z.ZodObject<{
|
|
|
50
50
|
}, z.core.$strip>>;
|
|
51
51
|
results: z.ZodArray<z.ZodObject<{
|
|
52
52
|
id: z.ZodString;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
path: z.ZodString;
|
|
57
|
-
content: z.ZodString;
|
|
58
|
-
localPath: z.ZodOptional<z.ZodString>;
|
|
59
|
-
repoRoot: z.ZodOptional<z.ZodString>;
|
|
60
|
-
contentView: z.ZodOptional<z.ZodEnum<{
|
|
61
|
-
none: "none";
|
|
62
|
-
standard: "standard";
|
|
63
|
-
symbols: "symbols";
|
|
64
|
-
}>>;
|
|
65
|
-
isSkeleton: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
-
totalLines: z.ZodOptional<z.ZodNumber>;
|
|
67
|
-
sourceChars: z.ZodOptional<z.ZodNumber>;
|
|
68
|
-
sourceBytes: z.ZodOptional<z.ZodNumber>;
|
|
69
|
-
resolvedBranch: z.ZodOptional<z.ZodString>;
|
|
70
|
-
pagination: z.ZodOptional<z.ZodObject<{
|
|
71
|
-
currentPage: z.ZodNumber;
|
|
72
|
-
totalPages: z.ZodNumber;
|
|
73
|
-
hasMore: z.ZodBoolean;
|
|
74
|
-
nextPage: z.ZodOptional<z.ZodNumber>;
|
|
75
|
-
nextMatchPage: z.ZodOptional<z.ZodNumber>;
|
|
76
|
-
charOffset: z.ZodOptional<z.ZodNumber>;
|
|
77
|
-
charLength: z.ZodOptional<z.ZodNumber>;
|
|
78
|
-
totalChars: z.ZodOptional<z.ZodNumber>;
|
|
79
|
-
nextCharOffset: z.ZodOptional<z.ZodNumber>;
|
|
80
|
-
filesPerPage: z.ZodOptional<z.ZodNumber>;
|
|
81
|
-
totalFiles: z.ZodOptional<z.ZodNumber>;
|
|
82
|
-
entriesPerPage: z.ZodOptional<z.ZodNumber>;
|
|
83
|
-
totalEntries: z.ZodOptional<z.ZodNumber>;
|
|
84
|
-
matchesPerPage: z.ZodOptional<z.ZodNumber>;
|
|
85
|
-
totalMatches: z.ZodOptional<z.ZodNumber>;
|
|
86
|
-
}, z.core.$strip>>;
|
|
87
|
-
isPartial: z.ZodOptional<z.ZodBoolean>;
|
|
88
|
-
startLine: z.ZodOptional<z.ZodNumber>;
|
|
89
|
-
endLine: z.ZodOptional<z.ZodNumber>;
|
|
90
|
-
matchRanges: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
91
|
-
start: z.ZodNumber;
|
|
92
|
-
end: z.ZodNumber;
|
|
93
|
-
}, z.core.$strip>>>;
|
|
94
|
-
lastModified: z.ZodOptional<z.ZodString>;
|
|
95
|
-
lastModifiedBy: z.ZodOptional<z.ZodString>;
|
|
96
|
-
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
97
|
-
matchNotFound: z.ZodOptional<z.ZodBoolean>;
|
|
98
|
-
searchedFor: z.ZodOptional<z.ZodString>;
|
|
99
|
-
cached: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
-
}, z.core.$strip>>>;
|
|
101
|
-
directories: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
102
|
-
path: z.ZodString;
|
|
103
|
-
localPath: z.ZodString;
|
|
104
|
-
repoRoot: z.ZodOptional<z.ZodString>;
|
|
105
|
-
fileCount: z.ZodNumber;
|
|
106
|
-
totalSize: z.ZodNumber;
|
|
53
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
54
|
+
owner: z.ZodString;
|
|
55
|
+
repo: z.ZodString;
|
|
107
56
|
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
108
57
|
path: z.ZodString;
|
|
109
|
-
|
|
110
|
-
|
|
58
|
+
content: z.ZodString;
|
|
59
|
+
localPath: z.ZodOptional<z.ZodString>;
|
|
60
|
+
repoRoot: z.ZodOptional<z.ZodString>;
|
|
61
|
+
contentView: z.ZodOptional<z.ZodEnum<{
|
|
62
|
+
none: "none";
|
|
63
|
+
standard: "standard";
|
|
64
|
+
symbols: "symbols";
|
|
65
|
+
}>>;
|
|
66
|
+
isSkeleton: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
+
totalLines: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
sourceChars: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
sourceBytes: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
resolvedBranch: z.ZodOptional<z.ZodString>;
|
|
71
|
+
pagination: z.ZodOptional<z.ZodObject<{
|
|
72
|
+
currentPage: z.ZodNumber;
|
|
73
|
+
totalPages: z.ZodNumber;
|
|
74
|
+
hasMore: z.ZodBoolean;
|
|
75
|
+
nextPage: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
nextMatchPage: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
charOffset: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
charLength: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
totalChars: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
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>;
|
|
87
|
+
}, z.core.$strip>>;
|
|
88
|
+
isPartial: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
startLine: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
91
|
+
matchRanges: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
92
|
+
start: z.ZodNumber;
|
|
93
|
+
end: z.ZodNumber;
|
|
94
|
+
}, z.core.$strip>>>;
|
|
95
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
96
|
+
lastModifiedBy: z.ZodOptional<z.ZodString>;
|
|
97
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
98
|
+
matchNotFound: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
+
searchedFor: z.ZodOptional<z.ZodString>;
|
|
100
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
+
}, z.core.$strip>>>;
|
|
102
|
+
directories: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
103
|
+
path: z.ZodString;
|
|
104
|
+
localPath: z.ZodString;
|
|
105
|
+
repoRoot: z.ZodOptional<z.ZodString>;
|
|
106
|
+
fileCount: z.ZodNumber;
|
|
107
|
+
totalSize: z.ZodNumber;
|
|
108
|
+
complete: z.ZodOptional<z.ZodBoolean>;
|
|
109
|
+
directoryEntryCount: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
eligibleFileCount: z.ZodOptional<z.ZodNumber>;
|
|
111
|
+
savedFileCount: z.ZodOptional<z.ZodNumber>;
|
|
112
|
+
skipped: z.ZodOptional<z.ZodObject<{
|
|
113
|
+
nonFile: z.ZodNumber;
|
|
114
|
+
missingDownloadUrl: z.ZodNumber;
|
|
115
|
+
oversized: z.ZodNumber;
|
|
116
|
+
binary: z.ZodNumber;
|
|
117
|
+
fileLimit: z.ZodNumber;
|
|
118
|
+
fetchFailed: z.ZodNumber;
|
|
119
|
+
totalSizeLimit: z.ZodNumber;
|
|
120
|
+
pathTraversal: z.ZodNumber;
|
|
121
|
+
}, z.core.$strip>>;
|
|
122
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
123
|
+
maxDirectoryFiles: z.ZodNumber;
|
|
124
|
+
maxTotalSize: z.ZodNumber;
|
|
125
|
+
maxFileSize: z.ZodNumber;
|
|
126
|
+
}, z.core.$strip>>;
|
|
127
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
128
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
129
|
+
path: z.ZodString;
|
|
130
|
+
size: z.ZodNumber;
|
|
131
|
+
type: z.ZodString;
|
|
132
|
+
}, z.core.$strip>>>;
|
|
133
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
134
|
+
resolvedBranch: z.ZodOptional<z.ZodString>;
|
|
111
135
|
}, z.core.$strip>>>;
|
|
112
|
-
|
|
113
|
-
resolvedBranch: z.ZodOptional<z.ZodString>;
|
|
114
|
-
}, z.core.$strip>>>;
|
|
136
|
+
}, z.core.$strip>>;
|
|
115
137
|
}, z.core.$strip>>;
|
|
116
138
|
errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
117
139
|
id: z.ZodString;
|
|
@@ -57,6 +57,33 @@ export interface DirectoryFetchResult {
|
|
|
57
57
|
}>;
|
|
58
58
|
fileCount: number;
|
|
59
59
|
totalSize: number;
|
|
60
|
+
/** true = no files were skipped by size/type/limit/error */
|
|
61
|
+
complete: boolean;
|
|
62
|
+
/** true = completeness was proven against the remote tree (fresh fetch + complete) */
|
|
63
|
+
verified: boolean;
|
|
64
|
+
/** HEAD commit SHA at the time of fetch; absent on cache hits from legacy entries */
|
|
65
|
+
commitSha?: string;
|
|
66
|
+
/** true when nonFile > 0 — subdirectory entries were present but not fetched; use ghCloneRepo for full coverage */
|
|
67
|
+
hasSubdirectories?: boolean;
|
|
68
|
+
directoryEntryCount: number;
|
|
69
|
+
eligibleFileCount: number;
|
|
70
|
+
savedFileCount: number;
|
|
71
|
+
skipped: {
|
|
72
|
+
nonFile: number;
|
|
73
|
+
missingDownloadUrl: number;
|
|
74
|
+
oversized: number;
|
|
75
|
+
binary: number;
|
|
76
|
+
fileLimit: number;
|
|
77
|
+
fetchFailed: number;
|
|
78
|
+
totalSizeLimit: number;
|
|
79
|
+
pathTraversal: number;
|
|
80
|
+
};
|
|
81
|
+
limits: {
|
|
82
|
+
maxDirectoryFiles: number;
|
|
83
|
+
maxTotalSize: number;
|
|
84
|
+
maxFileSize: number;
|
|
85
|
+
};
|
|
86
|
+
warnings?: string[];
|
|
60
87
|
cached: boolean;
|
|
61
88
|
expiresAt: string;
|
|
62
89
|
owner: string;
|
|
@@ -37,7 +37,6 @@ export declare function inspectBinary(query: BinaryInspectQuery): Promise<import
|
|
|
37
37
|
totalPages: number;
|
|
38
38
|
hasMore: boolean;
|
|
39
39
|
entriesPerPage: number;
|
|
40
|
-
totalEntries: number;
|
|
41
40
|
};
|
|
42
41
|
status: "success";
|
|
43
42
|
mode: "list";
|
|
@@ -54,7 +53,6 @@ export declare function inspectBinary(query: BinaryInspectQuery): Promise<import
|
|
|
54
53
|
backend: string;
|
|
55
54
|
localPath: string;
|
|
56
55
|
content: string;
|
|
57
|
-
contentLength: number;
|
|
58
56
|
isPartial: boolean;
|
|
59
57
|
} | {
|
|
60
58
|
pagination?: ContentCharPagination;
|
|
@@ -65,13 +63,11 @@ export declare function inspectBinary(query: BinaryInspectQuery): Promise<import
|
|
|
65
63
|
backend: string;
|
|
66
64
|
localPath: string;
|
|
67
65
|
content: string;
|
|
68
|
-
contentLength: number;
|
|
69
66
|
isPartial: boolean;
|
|
70
67
|
} | {
|
|
71
68
|
nextScanOffset?: number;
|
|
72
69
|
scanOffset: number;
|
|
73
70
|
pagination?: ContentCharPagination;
|
|
74
|
-
contentLength: number;
|
|
75
71
|
totalFound: number;
|
|
76
72
|
isPartial: boolean;
|
|
77
73
|
localPath?: string;
|