@githits/mcp 0.40.2 → 0.41.0

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.
@@ -1,4 +1,4 @@
1
- import{parseHttpErrorDetail,DEFAULT_WAIT_TIMEOUT_MS,indexingRequestTimeoutMs,isFetchTimeoutError,SERVER_AUTHENTICATION_REJECTED_MESSAGE,AuthenticationError2,withServiceDiagnostics,isTokenRefreshableError,GitHitsServiceImpl2,executeWithTokenRefresh,ClientUpdateRequiredError,isClientUpdateRequiredGraphQLError,isGraphQLSchemaMismatchError,parseAvailableArtifacts,PkgseerTransportError,postPkgseerGraphql,INDEXING_DURATION_ESTIMATE_SELECTION,INDEXING_ESTIMATES_SELECTION,indexingEstimatesSchema,parseIndexingDurationEstimate,READ_TARGET_SELECTION,selectedReadTargetSchema,parseVersionRefRecovery,CodeNavigationAccessError,MalformedCodeNavigationResponseError,CodeNavigationNetworkError,CodeNavigationBackendError,TARGET_RESOLUTION_SELECTION,CODE_CONTEXT_AVAILABLE_VERSIONS_SELECTION,requiredTargetResolutionSchema,createCodeNavigationHttpError,createCodeNavigationGraphQLError,parseCodeContextResult,osvSourceMetadataSchema,osvSourceDetailsSchema,MalformedPackageIntelligenceResponseError,parsePackageDocResult,createPackageIntelligenceHttpError,createPackageIntelligenceTransportError,createPackageIntelligenceGraphQLError}from"./chunk-bzjgrtan.js";import{createHash,randomBytes}from"node:crypto";import{z as z2}from"zod";import{z}from"zod";var severitySchema=osvSourceDetailsSchema.shape.severity.element;var packageSchema=z.object({name:z.string(),ecosystem:z.string(),purl:z.string().nullable().optional()});var fullAdvisorySchema=osvSourceDetailsSchema.extend({affected:z.array(z.object({package:packageSchema.required({purl:true}).nullable(),severity:z.array(severitySchema),versions:z.array(z.string()),ranges:z.array(z.object({type:z.string(),repo:z.string().nullable(),events:z.array(z.object({introduced:z.string().nullable(),fixed:z.string().nullable(),lastAffected:z.string().nullable(),limit:z.string().nullable()}))}))}))});var strings=z.array(z.string());var safety=osvSourceDetailsSchema.shape.contentSafety;var display=z.object({ranges:strings,totalCount:z.number().int().nonnegative(),truncated:z.boolean()}).nullable();var source=z.object({osvId:z.string(),sourceUrl:z.string(),modifiedAt:z.string().optional(),withdrawnAt:z.string().nullable(),affectedVersionRanges:strings.nullable(),fixedInVersions:strings,affectedVersionDisplay:display,affected:fullAdvisorySchema.shape.affected.optional(),contentSafety:safety.optional()});var local=z.object({osvId:z.string().nullable(),sourceUrl:z.string(),summary:z.string().nullable(),severityScore:z.number().nullable(),severityType:z.string().nullable(),withdrawnAt:z.string().nullable(),affectedVersionRanges:strings.nullable(),fixedInVersions:strings.nullable(),affectedVersionDisplay:display,registry:z.string().nullable().optional(),packageName:z.string().nullable().optional(),publishedAt:z.string().nullable().optional(),modifiedAt:z.string().nullable().optional(),aliases:strings,isMalicious:z.boolean().nullable().optional(),contentSafety:safety.optional()});var compactAdvisory=osvSourceDetailsSchema.pick({osvId:true,aliases:true,summary:true,sourceUrl:true,withdrawnAt:true});var lookupUnknownSchema=z.object({section:z.string(),code:z.string(),message:z.string(),retryable:z.boolean(),candidateIds:strings.nullable(),candidateIdsTruncated:z.boolean().nullable(),path:z.array(z.union([z.string(),z.number().int()])).optional()});var group=z.object({package:z.object({name:z.string(),registry:z.string().nullable(),ecosystem:z.string().nullable()}),sourceEvidence:source.nullable(),advisories:z.array(local)});var connection=z.object({entries:z.array(group),pageInfo:z.object({totalCount:z.number().int().nonnegative(),hasNextPage:z.boolean(),endCursor:z.string().nullable()}),coverage:z.object({sourceStatus:z.string(),localStatus:z.string()})});var lookupSchema=z.object({requestedId:z.string(),advisory:compactAdvisory.extend(osvSourceMetadataSchema.partial().shape).extend({details:z.string().nullable().optional(),publishedAt:z.string().nullable().optional(),modifiedAt:z.string().optional(),severity:osvSourceDetailsSchema.shape.severity.optional(),references:osvSourceDetailsSchema.shape.references.optional(),affected:fullAdvisorySchema.shape.affected.optional(),contentSafety:safety.optional()}).nullable().optional(),affectedPackages:connection.nullable(),unknownDetails:z.array(lookupUnknownSchema)});var detailedLookupSchema=lookupSchema.extend({advisory:fullAdvisorySchema.nullable().optional(),affectedPackages:connection.extend({entries:z.array(group.extend({sourceEvidence:source.required({affected:true,contentSafety:true,modifiedAt:true}).nullable(),advisories:z.array(local.required({registry:true,packageName:true,publishedAt:true,modifiedAt:true,aliases:true,isMalicious:true,contentSafety:true}))}))}).nullable()});var graphQLErrorSchema=z2.object({message:z2.string(),path:z2.array(z2.union([z2.string(),z2.number().int()])).optional(),extensions:z2.record(z2.string(),z2.unknown()).optional()});var envelopeSchema=z2.object({data:z2.object({vulnerabilityLookup:z2.unknown()}).nullish(),errors:z2.array(graphQLErrorSchema).optional()});import{z as z3}from"zod";class GrepGraphQLError2 extends Error{extensions;constructor(message,extensions={}){super(message);this.extensions=extensions;this.name="GrepGraphQLError"}}class GrepBackendError2 extends Error{status;graphqlCode;retryable;constructor(message,status,graphqlCode,retryable){super(message);this.status=status;this.graphqlCode=graphqlCode;this.retryable=retryable;this.name="GrepBackendError"}}class GrepAccessError2 extends Error{constructor(message){super(message);this.name="GrepAccessError"}}class GrepNetworkError2 extends Error{constructor(message,options){super(message,options);this.name="GrepNetworkError"}}class MalformedGrepResponseError2 extends Error{constructor(){super("Malformed response from the grep service.");this.name="MalformedGrepResponseError"}}var traversal=z3.enum(["COMPLETE","RESUMABLE_LIMIT","NON_RESUMABLE_PARTIAL","FAILED","CURSOR_EXPIRED"]);var corpus=z3.enum(["SOURCE","DOCUMENTATION","ALL"]);var nonnegativeInt=z3.number().int().nonnegative();var nullableString=z3.string().nullable();var lineSlice=z3.object({content:z3.string(),startByte:nonnegativeInt,endByte:nonnegativeInt,originalLineBytes:nonnegativeInt});var readAction=z3.object({target:z3.string(),path:nullableString,startLine:z3.number().int().positive(),endLine:z3.number().int().positive()});var modifications=z3.array(z3.enum(["INVISIBLE_CONTROLS_STRIPPED","HTML_COMMENTS_STRIPPED","IMAGES_REPLACED","UNSAFE_LINKS_NEUTRALIZED"]));function resultSchema(detailed){const selected=(schema)=>detailed?schema:schema.optional();const safety=z3.object({filtered:z3.boolean(),modifications:selected(modifications)});const common={targetIndex:nonnegativeInt,line:z3.number().int().positive(),lineSlice,contextBeforeSlices:z3.array(lineSlice),contextAfterSlices:z3.array(lineSlice),read:readAction,contentSafety:safety,lineContent:selected(z3.string()),matchStartByte:nonnegativeInt,matchEndByte:nonnegativeInt,sourceMatchStartByte:selected(nonnegativeInt),sourceMatchEndByte:selected(nonnegativeInt)};return z3.object({pathWarnings:z3.array(z3.object({requestedInputIndices:z3.array(nonnegativeInt),target:z3.string(),path:z3.string(),repositorySubpath:z3.string(),message:z3.string(),suggestions:z3.array(z3.object({target:z3.string(),path:z3.string()}))})),targetResolutions:z3.array(z3.object({inputIndex:nonnegativeInt,target:z3.string(),targetResolution:requiredTargetResolutionSchema})),indexingEstimates:indexingEstimatesSchema,hits:z3.array(z3.discriminatedUnion("__typename",[z3.object({...common,__typename:z3.literal("GrepRepositoryHit"),read:readAction.extend({path:z3.string()}),filePath:z3.string(),repoUrl:selected(z3.string()),commitSha:selected(z3.string()),repositoryFilePath:selected(z3.string())}),z3.object({...common,__typename:z3.literal("GrepSiteHit"),read:readAction.extend({path:z3.null()}),pageUrl:z3.string()})])),targets:z3.array(z3.object({targetIndex:nonnegativeInt,requestedInputIndices:z3.array(nonnegativeInt),kind:z3.enum(["REPOSITORY","SITE"]),target:z3.string(),traversal,readiness:z3.enum(["UNSPECIFIED","CURRENT","STALE","NOT_AVAILABLE","MISSING_REF","READER_OPEN_FAILED","INCOMPLETE","RESOURCE_LIMIT","VERSION_UNSUPPORTED","READ_FAILED"]),errorCode:nullableString,retryable:z3.boolean(),publicMessage:nullableString,requestedRef:nullableString,commitSha:nullableString,corpus:corpus.nullable(),filesScanned:nonnegativeInt.nullable(),filesInScope:nonnegativeInt.nullable(),binaryFilesSkipped:nonnegativeInt.nullable(),filesTooLargeSkipped:nonnegativeInt.nullable(),fileIssuesOmitted:nonnegativeInt.nullable(),fileIssues:z3.array(z3.object({filePath:z3.string(),contentSafety:safety,code:z3.string(),line:nonnegativeInt,lineBytes:selected(nonnegativeInt),matchStartByte:selected(nonnegativeInt.nullable()),matchEndByte:selected(nonnegativeInt.nullable())})).nullable(),repoUrl:nullableString,canonicalSite:nullableString,urlPrefixes:selected(z3.array(z3.string()))})),unavailableTargets:z3.array(z3.object({inputIndex:nonnegativeInt,target:z3.string(),reason:z3.string(),retryable:z3.boolean(),progressRef:nullableString,suggestedSiteTargets:z3.array(z3.string()).nullable()})),traversal,nextCursor:nullableString,totalMatches:nonnegativeInt})}function parseGrepResult(value,detailed=false){const parsed=resultSchema(detailed).safeParse(value);if(!parsed.success)throw new MalformedGrepResponseError2;const result=parsed.data;const indices=new Set(result.targets.map((target)=>target.targetIndex));if(indices.size!==result.targets.length||result.hits.some((hit)=>!indices.has(hit.targetIndex)||!validMatchCoordinates(hit))||result.traversal==="RESUMABLE_LIMIT"&&!result.nextCursor)throw new MalformedGrepResponseError2;return result}function validMatchCoordinates(hit){const bytes=new TextEncoder().encode(hit.lineSlice.content);const{matchStartByte:start,matchEndByte:end}=hit;const boundary=(offset)=>offset===bytes.length||((bytes[offset]??0)&192)!==128;return start<=end&&end<=bytes.length&&boundary(start)&&boundary(end)}var GRAPHQL_QUERY=`query Grep(
1
+ import{parseHttpErrorDetail,DEFAULT_WAIT_TIMEOUT_MS,indexingRequestTimeoutMs,isFetchTimeoutError,SERVER_AUTHENTICATION_REJECTED_MESSAGE,AuthenticationError2,withServiceDiagnostics,isTokenRefreshableError,GitHitsServiceImpl2,executeWithTokenRefresh,ClientUpdateRequiredError,isClientUpdateRequiredGraphQLError,isGraphQLSchemaMismatchError,parseAvailableArtifacts,parsePkgseerErrorDetails,getPrimaryExtensions,httpRateLimitError,PkgseerTransportError,postPkgseerGraphql,INDEXING_DURATION_ESTIMATE_SELECTION,INDEXING_ESTIMATES_SELECTION,indexingEstimatesSchema,parseIndexingDurationEstimate,READ_TARGET_SELECTION,selectedReadTargetSchema,parseVersionRefRecovery,CodeNavigationAccessError,MalformedCodeNavigationResponseError,CodeNavigationNetworkError,CodeNavigationBackendError,TARGET_RESOLUTION_SELECTION,CODE_CONTEXT_AVAILABLE_VERSIONS_SELECTION,requiredTargetResolutionSchema,createCodeNavigationHttpError,createCodeNavigationGraphQLError,parseCodeContextResult,osvSourceMetadataSchema,osvSourceDetailsSchema,MalformedPackageIntelligenceResponseError,parsePackageDocResult,createPackageIntelligenceHttpError,createPackageIntelligenceTransportError,createPackageIntelligenceGraphQLError}from"./chunk-39naxvkd.js";import{createHash,randomBytes}from"node:crypto";import{z as z2}from"zod";import{z}from"zod";var severitySchema=osvSourceDetailsSchema.shape.severity.element;var packageSchema=z.object({name:z.string(),ecosystem:z.string(),purl:z.string().nullable().optional()});var fullAdvisorySchema=osvSourceDetailsSchema.extend({affected:z.array(z.object({package:packageSchema.required({purl:true}).nullable(),severity:z.array(severitySchema),versions:z.array(z.string()),ranges:z.array(z.object({type:z.string(),repo:z.string().nullable(),events:z.array(z.object({introduced:z.string().nullable(),fixed:z.string().nullable(),lastAffected:z.string().nullable(),limit:z.string().nullable()}))}))}))});var strings=z.array(z.string());var safety=osvSourceDetailsSchema.shape.contentSafety;var display=z.object({ranges:strings,totalCount:z.number().int().nonnegative(),truncated:z.boolean()}).nullable();var source=z.object({osvId:z.string(),sourceUrl:z.string(),modifiedAt:z.string().optional(),withdrawnAt:z.string().nullable(),affectedVersionRanges:strings.nullable(),fixedInVersions:strings,affectedVersionDisplay:display,affected:fullAdvisorySchema.shape.affected.optional(),contentSafety:safety.optional()});var local=z.object({osvId:z.string().nullable(),sourceUrl:z.string(),summary:z.string().nullable(),severityScore:z.number().nullable(),severityType:z.string().nullable(),withdrawnAt:z.string().nullable(),affectedVersionRanges:strings.nullable(),fixedInVersions:strings.nullable(),affectedVersionDisplay:display,registry:z.string().nullable().optional(),packageName:z.string().nullable().optional(),publishedAt:z.string().nullable().optional(),modifiedAt:z.string().nullable().optional(),aliases:strings,isMalicious:z.boolean().nullable().optional(),contentSafety:safety.optional()});var compactAdvisory=osvSourceDetailsSchema.pick({osvId:true,aliases:true,summary:true,sourceUrl:true,withdrawnAt:true});var lookupUnknownSchema=z.object({section:z.string(),code:z.string(),message:z.string(),retryable:z.boolean(),candidateIds:strings.nullable(),candidateIdsTruncated:z.boolean().nullable(),path:z.array(z.union([z.string(),z.number().int()])).optional()});var group=z.object({package:z.object({name:z.string(),registry:z.string().nullable(),ecosystem:z.string().nullable()}),sourceEvidence:source.nullable(),advisories:z.array(local)});var connection=z.object({entries:z.array(group),pageInfo:z.object({totalCount:z.number().int().nonnegative(),hasNextPage:z.boolean(),endCursor:z.string().nullable()}),coverage:z.object({sourceStatus:z.string(),localStatus:z.string()})});var lookupSchema=z.object({requestedId:z.string(),advisory:compactAdvisory.extend(osvSourceMetadataSchema.partial().shape).extend({details:z.string().nullable().optional(),publishedAt:z.string().nullable().optional(),modifiedAt:z.string().optional(),severity:osvSourceDetailsSchema.shape.severity.optional(),references:osvSourceDetailsSchema.shape.references.optional(),affected:fullAdvisorySchema.shape.affected.optional(),contentSafety:safety.optional()}).nullable().optional(),affectedPackages:connection.nullable(),unknownDetails:z.array(lookupUnknownSchema)});var detailedLookupSchema=lookupSchema.extend({advisory:fullAdvisorySchema.nullable().optional(),affectedPackages:connection.extend({entries:z.array(group.extend({sourceEvidence:source.required({affected:true,contentSafety:true,modifiedAt:true}).nullable(),advisories:z.array(local.required({registry:true,packageName:true,publishedAt:true,modifiedAt:true,aliases:true,isMalicious:true,contentSafety:true}))}))}).nullable()});var graphQLErrorSchema=z2.object({message:z2.string(),path:z2.array(z2.union([z2.string(),z2.number().int()])).optional(),extensions:z2.record(z2.string(),z2.unknown()).optional()});var envelopeSchema=z2.object({data:z2.object({vulnerabilityLookup:z2.unknown()}).nullish(),errors:z2.array(graphQLErrorSchema).optional()});import{z as z3}from"zod";class GrepGraphQLError2 extends Error{extensions;constructor(message,extensions={}){super(message);this.extensions=extensions;this.name="GrepGraphQLError"}}class GrepBackendError2 extends Error{status;graphqlCode;retryable;metadata;constructor(message,status,graphqlCode,retryable,metadata=undefined){super(message);this.status=status;this.graphqlCode=graphqlCode;this.retryable=retryable;this.metadata=metadata;this.name="GrepBackendError"}}class GrepAccessError2 extends Error{constructor(message){super(message);this.name="GrepAccessError"}}class GrepNetworkError2 extends Error{constructor(message,options){super(message,options);this.name="GrepNetworkError"}}class MalformedGrepResponseError2 extends Error{constructor(){super("Malformed response from the grep service.");this.name="MalformedGrepResponseError"}}var traversal=z3.enum(["COMPLETE","RESUMABLE_LIMIT","NON_RESUMABLE_PARTIAL","FAILED","CURSOR_EXPIRED"]);var corpus=z3.enum(["SOURCE","DOCUMENTATION","ALL"]);var nonnegativeInt=z3.number().int().nonnegative();var nullableString=z3.string().nullable();var lineSlice=z3.object({content:z3.string(),startByte:nonnegativeInt,endByte:nonnegativeInt,originalLineBytes:nonnegativeInt});var readAction=z3.object({target:z3.string(),path:nullableString,startLine:z3.number().int().positive(),endLine:z3.number().int().positive()});var modifications=z3.array(z3.enum(["INVISIBLE_CONTROLS_STRIPPED","HTML_COMMENTS_STRIPPED","IMAGES_REPLACED","UNSAFE_LINKS_NEUTRALIZED"]));function resultSchema(detailed){const selected=(schema)=>detailed?schema:schema.optional();const recoveryRefs=z3.array(z3.object({ref:z3.string(),version:selected(nullableString)})).nullable();const safety=z3.object({filtered:z3.boolean(),modifications:selected(modifications)});const common={targetIndex:nonnegativeInt,line:z3.number().int().positive(),lineSlice,contextBeforeSlices:z3.array(lineSlice),contextAfterSlices:z3.array(lineSlice),read:readAction,contentSafety:safety,lineContent:selected(z3.string()),matchStartByte:nonnegativeInt,matchEndByte:nonnegativeInt,sourceMatchStartByte:selected(nonnegativeInt),sourceMatchEndByte:selected(nonnegativeInt)};return z3.object({pathWarnings:z3.array(z3.object({requestedInputIndices:z3.array(nonnegativeInt),target:z3.string(),path:z3.string(),repositorySubpath:z3.string(),message:z3.string(),suggestions:z3.array(z3.object({target:z3.string(),path:z3.string()}))})),targetResolutions:z3.array(z3.object({inputIndex:nonnegativeInt,target:z3.string(),targetResolution:requiredTargetResolutionSchema})),indexingEstimates:indexingEstimatesSchema,hits:z3.array(z3.discriminatedUnion("__typename",[z3.object({...common,__typename:z3.literal("GrepRepositoryHit"),read:readAction.extend({path:z3.string()}),filePath:z3.string(),repoUrl:selected(z3.string()),commitSha:selected(z3.string()),repositoryFilePath:selected(z3.string())}),z3.object({...common,__typename:z3.literal("GrepSiteHit"),read:readAction.extend({path:z3.null()}),pageUrl:z3.string()})])),targets:z3.array(z3.object({targetIndex:nonnegativeInt,requestedInputIndices:z3.array(nonnegativeInt),kind:z3.enum(["REPOSITORY","SITE"]),target:z3.string(),traversal,readiness:z3.enum(["UNSPECIFIED","CURRENT","STALE","NOT_AVAILABLE","MISSING_REF","READER_OPEN_FAILED","INCOMPLETE","RESOURCE_LIMIT","VERSION_UNSUPPORTED","READ_FAILED"]),errorCode:nullableString,retryable:z3.boolean(),publicMessage:nullableString,requestedRef:nullableString,commitSha:nullableString,corpus:corpus.nullable(),filesScanned:nonnegativeInt.nullable(),filesInScope:nonnegativeInt.nullable(),binaryFilesSkipped:nonnegativeInt.nullable(),filesTooLargeSkipped:nonnegativeInt.nullable(),fileIssuesOmitted:nonnegativeInt.nullable(),fileIssues:z3.array(z3.object({filePath:z3.string(),contentSafety:safety,code:z3.string(),line:nonnegativeInt,lineBytes:selected(nonnegativeInt),matchStartByte:selected(nonnegativeInt.nullable()),matchEndByte:selected(nonnegativeInt.nullable())})).nullable(),repoUrl:nullableString,canonicalSite:nullableString,urlPrefixes:selected(z3.array(z3.string()))})),unavailableTargets:z3.array(z3.object({message:nullableString.optional(),requestedVersion:selected(nullableString),suggestedRefs:selected(recoveryRefs),availableRefs:selected(recoveryRefs),availableVersions:selected(recoveryRefs),inputIndex:nonnegativeInt,target:z3.string(),reason:z3.string(),retryable:z3.boolean(),progressRef:nullableString,suggestedSiteTargets:z3.array(z3.string()).nullable()})),traversal,nextCursor:nullableString,totalMatches:nonnegativeInt})}function parseGrepResult(value,detailed=false){const parsed=resultSchema(detailed).safeParse(value);if(!parsed.success)throw new MalformedGrepResponseError2;const result=parsed.data;const indices=new Set(result.targets.map((target)=>target.targetIndex));if(indices.size!==result.targets.length||result.hits.some((hit)=>!indices.has(hit.targetIndex)||!validMatchCoordinates(hit))||result.traversal==="RESUMABLE_LIMIT"&&!result.nextCursor)throw new MalformedGrepResponseError2;return result}function validMatchCoordinates(hit){const bytes=new TextEncoder().encode(hit.lineSlice.content);const{matchStartByte:start,matchEndByte:end}=hit;const boundary=(offset)=>offset===bytes.length||((bytes[offset]??0)&192)!==128;return start<=end&&end<=bytes.length&&boundary(start)&&boundary(end)}var GRAPHQL_QUERY=`query Grep(
2
2
  $targets: [GrepTargetInput!]!, $pattern: String!, $patternType: GrepPatternType,
3
3
  $caseSensitive: Boolean, $contextLinesBefore: Int, $contextLinesAfter: Int,
4
4
  $maxMatches: Int, $cursor: String, $waitTimeoutMs: Int, $includeDetailedFields: Boolean!
@@ -66,7 +66,13 @@ import{parseHttpErrorDetail,DEFAULT_WAIT_TIMEOUT_MS,indexingRequestTimeoutMs,isF
66
66
  matchEndByte @include(if: $includeDetailedFields)
67
67
  }
68
68
  }
69
- unavailableTargets { inputIndex target reason retryable progressRef suggestedSiteTargets }
69
+ unavailableTargets {
70
+ inputIndex target reason retryable progressRef suggestedSiteTargets message
71
+ requestedVersion @include(if: $includeDetailedFields)
72
+ suggestedRefs { ref version @include(if: $includeDetailedFields) }
73
+ availableRefs @include(if: $includeDetailedFields) { ref version }
74
+ availableVersions @include(if: $includeDetailedFields) { ref version }
75
+ }
70
76
  }
71
77
  }
72
78
  fragment RepositoryMatch on GrepRepositoryHit {
@@ -83,7 +89,7 @@ fragment SiteMatch on GrepSiteHit {
83
89
  matchStartByte matchEndByte
84
90
  sourceMatchStartByte @include(if: $includeDetailedFields) sourceMatchEndByte @include(if: $includeDetailedFields)
85
91
  }
86
- fragment LineSlice on GrepRepoLineSlice { content startByte endByte originalLineBytes }`;var graphQLResponse=z3.object({data:z3.object({grep:z3.unknown().optional()}).nullable().optional(),errors:z3.array(z3.object({message:z3.string(),extensions:z3.record(z3.string(),z3.unknown()).optional()})).optional()});class GrepServiceImpl2{endpointUrl;tokenProvider;fetchFn;runtime;constructor(endpointUrl,tokenProvider,fetchFn=globalThis.fetch,runtime={}){this.endpointUrl=endpointUrl;this.tokenProvider=tokenProvider;this.fetchFn=fetchFn;this.runtime=runtime}async grep(params,options){const signal=options?.signal;params={...params,waitTimeoutMs:params.waitTimeoutMs??(params.cursor?0:DEFAULT_WAIT_TIMEOUT_MS)};return withServiceDiagnostics(this.runtime.diagnostics,"grep.request",()=>executeWithTokenRefresh({getToken:()=>this.tokenProvider.getToken(),forceRefresh:()=>this.tokenProvider.forceRefresh(),shouldRefresh:isTokenRefreshableError,signal,executeWithToken:(token)=>this.executeGrep(token,params,signal)}))}async executeGrep(token,params,signal){let response;const{includeDetailedFields,...controls}=params;try{response=await postPkgseerGraphql({endpointUrl:this.endpointUrl,token,query:GRAPHQL_QUERY,variables:{...controls,includeDetailedFields},signal,timeoutMs:indexingRequestTimeoutMs(params.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS),fetchFn:this.fetchFn,clientHeaders:this.runtime.clientHeaders,userAgent:this.runtime.userAgent,diagnostics:this.runtime.diagnostics})}catch(cause){if(!(cause instanceof PkgseerTransportError))throw cause;if(isFetchTimeoutError(cause.cause))throw new GrepBackendError2("Grep request timed out.",undefined,"TIMEOUT",true);throw new GrepNetworkError2("Could not reach the package and documentation service. Check your connection.",{cause})}if(response.status<200||response.status>=300)throw httpError(response);const envelope=graphQLResponse.safeParse(response.parsedBody);if(!envelope.success)throw new MalformedGrepResponseError2;const errors=envelope.data.errors;if(errors?.length){const message=errors.map((error)=>error.message).join(", ");const extensions=errors.find((error)=>error.extensions?.code)?.extensions??{};const code=typeof extensions.code==="string"?extensions.code:undefined;if(isClientUpdateRequiredGraphQLError({message,code}))throw new ClientUpdateRequiredError(undefined,undefined,this.runtime.clientVersion);if(isGraphQLSchemaMismatchError({message,code}))throw new GrepBackendError2("Backend protocol mismatch: the endpoint must support unified grep. Run `githits update-check` to check your client version.",undefined,code,false);if(code==="AUTHENTICATION_REQUIRED"||code==="UNAUTHORIZED")throw new AuthenticationError2(SERVER_AUTHENTICATION_REJECTED_MESSAGE,"server");if(code==="FORBIDDEN"||code==="ACCESS_DENIED")throw new GrepAccessError2(message);throw new GrepGraphQLError2(message,extensions)}return parseGrepResult(envelope.data.data?.grep,includeDetailedFields)}}function httpError(response){const detail=parseHttpErrorDetail(response.responseBody,["message","error","detail"]);if(response.status===401)return new AuthenticationError2(SERVER_AUTHENTICATION_REJECTED_MESSAGE,"server");if(response.status===403)return new GrepAccessError2(detail??"Grep access denied.");return new GrepBackendError2(detail??`Request failed with status ${response.status}`,response.status)}import{z as z4}from"zod";class ListAccessError2 extends Error{constructor(message){super(message);this.name="ListAccessError"}}class ListGraphQLError2 extends Error{code;retryable;repoUrl;commitSha;indexingRef;hint;indexingMetadata;recovery;constructor(message,code,retryable,repoUrl,commitSha,indexingRef,hint,indexingMetadata=undefined,recovery=undefined){super(message);this.code=code;this.retryable=retryable;this.repoUrl=repoUrl;this.commitSha=commitSha;this.indexingRef=indexingRef;this.hint=hint;this.indexingMetadata=indexingMetadata;this.recovery=recovery;this.name="ListGraphQLError"}}class ListBackendError2 extends Error{status;graphqlCode;retryable;constructor(message,status,graphqlCode,retryable){super(message);this.status=status;this.graphqlCode=graphqlCode;this.retryable=retryable;this.name="ListBackendError"}}class ListNetworkError2 extends Error{constructor(message,options){super(message,options);this.name="ListNetworkError"}}class MalformedListResponseError2 extends Error{constructor(message="Malformed response from the list service."){super(message);this.name="MalformedListResponseError"}}var nullableString2=z4.string().nullable();var optionalNullableString=nullableString2.optional();var nullableInt=z4.number().int().nullable();var optionalNullableInt=nullableInt.optional();var listReadActionSchema=z4.object({target:z4.string().min(1),path:nullableString2}).nullable();var listBrowseActionSchema=z4.object({target:z4.string(),paths:z4.array(z4.string()).nullable()}).nullable();var listEntrySchema=z4.object({kind:z4.enum(["FILE","PAGE","DIRECTORY"]),path:z4.string(),title:optionalNullableString,language:optionalNullableString,fileType:optionalNullableString,intent:optionalNullableString,byteSize:optionalNullableInt,lineCount:optionalNullableInt,contentHash:optionalNullableString,read:listReadActionSchema.optional(),browse:listBrowseActionSchema.optional()});var availableVersionSchema=z4.object({version:nullableString2,ref:z4.string()});var resolutionSchema=z4.object({requestedVersion:nullableString2,requestedRef:nullableString2,resolvedRef:nullableString2,commitSha:nullableString2});var targetIdentitySchema=z4.object({kind:optionalNullableString,registry:optionalNullableString,packageName:optionalNullableString,version:optionalNullableString,repoUrl:optionalNullableString,gitRef:nullableString2,commitSha:optionalNullableString,committedAt:optionalNullableString,releaseCorrespondence:optionalNullableString});var targetResolutionSchema=z4.object({requested:targetIdentitySchema.nullable(),resolvedRequested:targetIdentitySchema.nullable(),served:targetIdentitySchema.nullable(),freshness:nullableString2,freshnessReason:nullableString2,indexingRef:optionalNullableString,availableVersions:z4.array(availableVersionSchema).nullable().optional(),availableRefs:z4.array(availableVersionSchema).nullable().optional(),suggestedRefs:z4.array(availableVersionSchema).nullable().optional()});var indexingEstimateSchema=z4.object({lowerSeconds:nullableInt,upperSeconds:nullableInt,elapsedSeconds:nullableInt,sampleCount:nullableInt,source:nullableString2});var sitePreparationSchema=z4.object({selected:z4.number().int(),enqueued:z4.number().int(),activeJobs:z4.array(z4.object({mode:nullableString2,state:z4.string()})),awaited:z4.array(z4.object({mode:nullableString2,outcome:z4.enum(["COMPLETED","DISCARDED","CANCELLED","TIMEOUT","FAILED","SUPERSEDED"])}))}).nullable();var listResultSchema=z4.object({indexingEstimates:indexingEstimatesSchema,inventoryKind:z4.enum(["SOURCE","SITE"]),requestedTarget:z4.string(),canonicalTarget:nullableString2,entries:z4.array(listEntrySchema),hasMore:z4.boolean(),nextCursor:nullableString2,indexedVersion:nullableString2,resolution:resolutionSchema.nullable().optional(),targetResolution:targetResolutionSchema.nullable().optional(),codeIndexState:nullableString2,indexingStatus:nullableString2,indexingRef:nullableString2,availableVersions:z4.array(availableVersionSchema).nullable().optional(),indexingEstimate:indexingEstimateSchema.nullable().optional(),inventoryState:z4.enum(["AVAILABLE","EMPTY"]).nullable(),crawlStatus:z4.enum(["IDLE","RUNNING","COMPLETE","FAILED"]).nullable(),coverageState:z4.enum(["NONE","PARTIAL","CAPPED","COMPLETE"]).nullable(),coverageReason:nullableString2,preparation:sitePreparationSchema});var graphQLErrorSchema2=z4.object({message:z4.string(),extensions:z4.record(z4.string(),z4.unknown()).optional()});var listGraphQLResponseSchema=z4.object({data:z4.object({list:z4.unknown().nullable().optional()}).nullable().optional(),errors:z4.array(graphQLErrorSchema2).optional()});var LIST_QUERY=`
92
+ fragment LineSlice on GrepRepoLineSlice { content startByte endByte originalLineBytes }`;var graphQLResponse=z3.object({data:z3.object({grep:z3.unknown().optional()}).nullable().optional(),errors:z3.array(z3.object({message:z3.string(),extensions:z3.record(z3.string(),z3.unknown()).optional()})).optional()});class GrepServiceImpl2{endpointUrl;tokenProvider;fetchFn;runtime;constructor(endpointUrl,tokenProvider,fetchFn=globalThis.fetch,runtime={}){this.endpointUrl=endpointUrl;this.tokenProvider=tokenProvider;this.fetchFn=fetchFn;this.runtime=runtime}async grep(params,options){const signal=options?.signal;params={...params,waitTimeoutMs:params.waitTimeoutMs??(params.cursor?0:DEFAULT_WAIT_TIMEOUT_MS)};return withServiceDiagnostics(this.runtime.diagnostics,"grep.request",()=>executeWithTokenRefresh({getToken:()=>this.tokenProvider.getToken(),forceRefresh:()=>this.tokenProvider.forceRefresh(),shouldRefresh:isTokenRefreshableError,signal,executeWithToken:(token)=>this.executeGrep(token,params,signal)}))}async executeGrep(token,params,signal){let response;const{includeDetailedFields,...controls}=params;try{response=await postPkgseerGraphql({endpointUrl:this.endpointUrl,token,query:GRAPHQL_QUERY,variables:{...controls,includeDetailedFields},signal,timeoutMs:indexingRequestTimeoutMs(params.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS),fetchFn:this.fetchFn,clientHeaders:this.runtime.clientHeaders,userAgent:this.runtime.userAgent,diagnostics:this.runtime.diagnostics})}catch(cause){if(!(cause instanceof PkgseerTransportError))throw cause;if(isFetchTimeoutError(cause.cause))throw new GrepBackendError2("Grep request timed out.",undefined,"TIMEOUT",true);throw new GrepNetworkError2("Could not reach the package and documentation service. Check your connection.",{cause})}if(response.status<200||response.status>=300)throw httpError(response);const envelope=graphQLResponse.safeParse(response.parsedBody);if(!envelope.success)throw new MalformedGrepResponseError2;const errors=envelope.data.errors;if(errors?.length){const message=errors.map((error)=>error.message).join(", ");const extensions=getPrimaryExtensions(errors)??{};const code=typeof extensions.code==="string"?extensions.code:undefined;if(isClientUpdateRequiredGraphQLError({message,code}))throw new ClientUpdateRequiredError(undefined,undefined,this.runtime.clientVersion);if(isGraphQLSchemaMismatchError({message,code}))throw new GrepBackendError2("Backend protocol mismatch: the endpoint must support unified grep. Run `githits update-check` to check your client version.",undefined,code,false);if(code==="AUTHENTICATION_REQUIRED"||code==="UNAUTHORIZED")throw new AuthenticationError2(SERVER_AUTHENTICATION_REJECTED_MESSAGE,"server");if(code==="FORBIDDEN"||code==="ACCESS_DENIED")throw new GrepAccessError2(message);throw new GrepGraphQLError2(message,extensions)}return parseGrepResult(envelope.data.data?.grep,includeDetailedFields)}}function httpError(response){const detail=parseHttpErrorDetail(response.responseBody,["message","error","detail"]);if(response.status===429){const rateLimit=httpRateLimitError(response.parsedBody);return new GrepBackendError2(detail??rateLimit.message??"Request rate limited.",429,"RATE_LIMITED",true,parsePkgseerErrorDetails(rateLimit.extensions))}if(response.status===401)return new AuthenticationError2(SERVER_AUTHENTICATION_REJECTED_MESSAGE,"server");if(response.status===403)return new GrepAccessError2(detail??"Grep access denied.");return new GrepBackendError2(detail??`Request failed with status ${response.status}`,response.status)}import{z as z4}from"zod";class ListAccessError2 extends Error{constructor(message){super(message);this.name="ListAccessError"}}class ListGraphQLError2 extends Error{code;retryable;repoUrl;commitSha;indexingRef;hint;indexingMetadata;recovery;metadata;constructor(message,code,retryable,repoUrl,commitSha,indexingRef,hint,indexingMetadata=undefined,recovery=undefined,metadata=undefined){super(message);this.code=code;this.retryable=retryable;this.repoUrl=repoUrl;this.commitSha=commitSha;this.indexingRef=indexingRef;this.hint=hint;this.indexingMetadata=indexingMetadata;this.recovery=recovery;this.metadata=metadata;this.name="ListGraphQLError"}}class ListBackendError2 extends Error{status;graphqlCode;retryable;metadata;constructor(message,status,graphqlCode,retryable,metadata=undefined){super(message);this.status=status;this.graphqlCode=graphqlCode;this.retryable=retryable;this.metadata=metadata;this.name="ListBackendError"}}class ListNetworkError2 extends Error{constructor(message,options){super(message,options);this.name="ListNetworkError"}}class MalformedListResponseError2 extends Error{constructor(message="Malformed response from the list service."){super(message);this.name="MalformedListResponseError"}}var nullableString2=z4.string().nullable();var optionalNullableString=nullableString2.optional();var nullableInt=z4.number().int().nullable();var optionalNullableInt=nullableInt.optional();var listReadActionSchema=z4.object({target:z4.string().min(1),path:nullableString2}).nullable();var listBrowseActionSchema=z4.object({target:z4.string(),paths:z4.array(z4.string()).nullable()}).nullable();var listEntrySchema=z4.object({kind:z4.enum(["FILE","PAGE","DIRECTORY"]),path:z4.string(),title:optionalNullableString,language:optionalNullableString,fileType:optionalNullableString,intent:optionalNullableString,byteSize:optionalNullableInt,lineCount:optionalNullableInt,contentHash:optionalNullableString,read:listReadActionSchema.optional(),browse:listBrowseActionSchema.optional()});var availableVersionSchema=z4.object({version:nullableString2,ref:z4.string()});var resolutionSchema=z4.object({requestedVersion:nullableString2,requestedRef:nullableString2,resolvedRef:nullableString2,commitSha:nullableString2});var targetIdentitySchema=z4.object({kind:optionalNullableString,registry:optionalNullableString,packageName:optionalNullableString,version:optionalNullableString,repoUrl:optionalNullableString,gitRef:nullableString2,commitSha:optionalNullableString,committedAt:optionalNullableString,releaseCorrespondence:optionalNullableString});var targetResolutionSchema=z4.object({requested:targetIdentitySchema.nullable(),resolvedRequested:targetIdentitySchema.nullable(),served:targetIdentitySchema.nullable(),freshness:nullableString2,freshnessReason:nullableString2,indexingRef:optionalNullableString,availableVersions:z4.array(availableVersionSchema).nullable().optional(),availableRefs:z4.array(availableVersionSchema).nullable().optional(),suggestedRefs:z4.array(availableVersionSchema).nullable().optional()});var indexingEstimateSchema=z4.object({lowerSeconds:nullableInt,upperSeconds:nullableInt,elapsedSeconds:nullableInt,sampleCount:nullableInt,source:nullableString2});var sitePreparationSchema=z4.object({selected:z4.number().int(),enqueued:z4.number().int(),activeJobs:z4.array(z4.object({mode:nullableString2,state:z4.string()})),awaited:z4.array(z4.object({mode:nullableString2,outcome:z4.enum(["COMPLETED","DISCARDED","CANCELLED","TIMEOUT","FAILED","SUPERSEDED"])}))}).nullable();var listResultSchema=z4.object({hint:nullableString2.optional(),indexingEstimates:indexingEstimatesSchema,inventoryKind:z4.enum(["SOURCE","SITE"]),requestedTarget:z4.string(),canonicalTarget:nullableString2,entries:z4.array(listEntrySchema),hasMore:z4.boolean(),nextCursor:nullableString2,indexedVersion:nullableString2,resolution:resolutionSchema.nullable().optional(),targetResolution:targetResolutionSchema.nullable().optional(),codeIndexState:nullableString2,indexingStatus:nullableString2,indexingRef:nullableString2,availableVersions:z4.array(availableVersionSchema).nullable().optional(),indexingEstimate:indexingEstimateSchema.nullable().optional(),inventoryState:z4.enum(["AVAILABLE","EMPTY"]).nullable(),crawlStatus:z4.enum(["IDLE","RUNNING","COMPLETE","FAILED"]).nullable(),coverageState:z4.enum(["NONE","PARTIAL","CAPPED","COMPLETE"]).nullable(),coverageReason:nullableString2,preparation:sitePreparationSchema});var graphQLErrorSchema2=z4.object({message:z4.string(),extensions:z4.record(z4.string(),z4.unknown()).optional()});var listGraphQLResponseSchema=z4.object({data:z4.object({list:z4.unknown().nullable().optional()}).nullable().optional(),errors:z4.array(graphQLErrorSchema2).optional()});var LIST_QUERY=`
87
93
  query List(
88
94
  $target: String!
89
95
  $paths: [String!]
@@ -110,6 +116,7 @@ query List(
110
116
  waitTimeoutMs: $waitTimeoutMs
111
117
  ) {
112
118
  inventoryKind
119
+ hint @include(if: $includeTargetProvenance)
113
120
  ${INDEXING_ESTIMATES_SELECTION}
114
121
  requestedTarget
115
122
  canonicalTarget
@@ -221,7 +228,7 @@ query List(
221
228
  }
222
229
  }
223
230
  }
224
- }`;class ListServiceImpl2{endpointUrl;tokenProvider;fetchFn;runtime;constructor(endpointUrl,tokenProvider,fetchFn=globalThis.fetch,runtime={}){this.endpointUrl=endpointUrl;this.tokenProvider=tokenProvider;this.fetchFn=fetchFn;this.runtime=runtime}async list(params,options){const signal=options?.signal;params={...params,waitTimeoutMs:params.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS};return withServiceDiagnostics(this.runtime.diagnostics,"list.request",()=>executeWithTokenRefresh({getToken:()=>this.tokenProvider.getToken(),forceRefresh:()=>this.tokenProvider.forceRefresh(),shouldRefresh:isTokenRefreshableError,signal,executeWithToken:(token)=>this.executeList(token,params,signal)}))}async executeList(token,params,signal){let response;try{response=await postPkgseerGraphql({endpointUrl:this.endpointUrl,token,query:LIST_QUERY,timeoutMs:indexingRequestTimeoutMs(params.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS),variables:buildListVariables(params),signal,fetchFn:this.fetchFn,clientHeaders:this.runtime.clientHeaders,userAgent:this.runtime.userAgent,diagnostics:this.runtime.diagnostics})}catch(cause){if(cause instanceof PkgseerTransportError){throw createListTransportError(cause)}throw cause}if(response.status<200||response.status>=300){throw createListHttpError(response)}const parsed=listGraphQLResponseSchema.safeParse(response.parsedBody);if(!parsed.success)throw new MalformedListResponseError2;if(parsed.data.errors&&parsed.data.errors.length>0){throw createListGraphQLError(parsed.data.errors,this.runtime.clientVersion,this.runtime.diagnostics)}const resultParsed=listResultSchema.safeParse(parsed.data.data?.list);if(!resultParsed.success)throw new MalformedListResponseError2;const result=resultParsed.data;if((params.includeDetailedFields||params.includeReadActions===true)&&result.entries.some((entry)=>entry.read===undefined)){throw new MalformedListResponseError2}if(result.hasMore&&!result.nextCursor){throw new MalformedListResponseError2("Malformed response from the list service: a continuation cursor is missing.")}return result}}function buildListVariables(params){return{target:params.target,...params.paths!==undefined?{paths:params.paths}:{},...params.recursive!==undefined?{recursive:params.recursive}:{},...params.fileTypes!==undefined?{fileTypes:params.fileTypes}:{},...params.languages!==undefined?{languages:params.languages}:{},...params.intents!==undefined?{intents:params.intents}:{},...params.limit!==undefined?{limit:params.limit}:{},...params.after!==undefined?{after:params.after}:{},...params.waitTimeoutMs!==undefined?{waitTimeoutMs:params.waitTimeoutMs}:{},includeDetailedFields:params.includeDetailedFields,includeTargetProvenance:params.includeDetailedFields||params.includeTargetProvenance===true,includeReadActions:params.includeDetailedFields||params.includeReadActions===true}}function createListHttpError(response){const detail=parseHttpErrorDetail(response.responseBody,["message","error","detail"]);if(response.status===401){return new AuthenticationError2(SERVER_AUTHENTICATION_REJECTED_MESSAGE,"server")}if(response.status===403){return new ListAccessError2(detail??"List access denied.")}if(response.status>=500){return new ListBackendError2(detail?`Server error (${response.status}): ${detail}`:`Server error (${response.status})`,response.status)}return new ListBackendError2(detail??`Request failed with status ${response.status}`,response.status)}function createListTransportError(error){if(isFetchTimeoutError(error.cause)){return new ListBackendError2("List request timed out.",undefined,"TIMEOUT",true)}return new ListNetworkError2("Could not reach the package and documentation service. Check your connection.",{cause:error})}function createListGraphQLError(errors,clientVersion,diagnostics){const message=errors.map((error)=>error.message).join(", ");const extensions=errors.find((error)=>error.extensions&&Object.keys(error.extensions).length>0)?.extensions;const code=typeof extensions?.code==="string"?extensions.code:undefined;const retryable=typeof extensions?.retryable==="boolean"?extensions.retryable:undefined;if(isClientUpdateRequiredGraphQLError({message,code})){return new ClientUpdateRequiredError(undefined,undefined,clientVersion)}if(isGraphQLSchemaMismatchError({message,code})){const sanitized="Backend protocol mismatch. Your CLI may be newer than the server, or the server may require a newer CLI. Run `githits update-check` to verify your installed version. Set GITHITS_DEBUG=code-nav-wire to inspect GraphQL details during local development.";return new ListBackendError2(diagnostics?.isEnabled("code-nav-wire")?message:sanitized,undefined,code,retryable)}if(code==="AUTHENTICATION_REQUIRED"||code==="UNAUTHORIZED"){return new AuthenticationError2(SERVER_AUTHENTICATION_REJECTED_MESSAGE,"server")}if(code==="FORBIDDEN"||code==="ACCESS_DENIED"){return new ListAccessError2(message)}return new ListGraphQLError2(message,code,retryable,typeof extensions?.repo_url==="string"?extensions.repo_url:undefined,typeof extensions?.commit_sha==="string"?extensions.commit_sha:undefined,typeof extensions?.indexing_ref==="string"?extensions.indexing_ref:undefined,typeof extensions?.hint==="string"?extensions.hint:undefined,{indexingEstimate:parseIndexingDurationEstimate(extensions),availableVersions:parseAvailableArtifacts(extensions?.available_versions??extensions?.availableVersions),package:typeof extensions?.package==="string"?extensions.package:undefined},parseVersionRefRecovery(extensions))}import{z as z5}from"zod";var readResultTypeSchema=z5.object({__typename:z5.enum(["CodeContextResult","GetDocPageResult","CodeSymbolResolutionResult"])});var symbolResolutionSchema=z5.object({__typename:z5.literal("CodeSymbolResolutionResult"),status:z5.enum(["AMBIGUOUS","NOT_FOUND","SNAPSHOT_UNSUPPORTED"]),candidates:z5.array(z5.object({name:z5.string().nullable(),qualifiedPath:z5.string().nullable(),kind:z5.string().nullable(),arity:z5.number().int().nullable(),filePath:z5.string().nullable(),startLine:z5.number().int().nullable(),endLine:z5.number().int().nullable()})).max(10),suggestions:z5.array(z5.object({name:z5.string(),qualifiedPath:z5.string().nullable(),localId:z5.string().nullable(),arity:z5.number().int().nullable(),filePath:z5.string().nullable(),reason:z5.string().nullable()})).max(10),hasMore:z5.boolean(),repoUrl:z5.string(),gitRef:z5.string(),message:z5.string().nullable(),codeIndexState:z5.string()});var readGraphQLErrorSchema=z5.object({message:z5.string(),extensions:z5.record(z5.string(),z5.unknown()).optional()});var readGraphQLResponseSchema=z5.object({data:z5.object({read:z5.unknown().nullable().optional()}).nullable().optional(),errors:z5.array(readGraphQLErrorSchema).optional()});var READ_QUERY=`
231
+ }`;class ListServiceImpl2{endpointUrl;tokenProvider;fetchFn;runtime;constructor(endpointUrl,tokenProvider,fetchFn=globalThis.fetch,runtime={}){this.endpointUrl=endpointUrl;this.tokenProvider=tokenProvider;this.fetchFn=fetchFn;this.runtime=runtime}async list(params,options){const signal=options?.signal;params={...params,waitTimeoutMs:params.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS};return withServiceDiagnostics(this.runtime.diagnostics,"list.request",()=>executeWithTokenRefresh({getToken:()=>this.tokenProvider.getToken(),forceRefresh:()=>this.tokenProvider.forceRefresh(),shouldRefresh:isTokenRefreshableError,signal,executeWithToken:(token)=>this.executeList(token,params,signal)}))}async executeList(token,params,signal){let response;try{response=await postPkgseerGraphql({endpointUrl:this.endpointUrl,token,query:LIST_QUERY,timeoutMs:indexingRequestTimeoutMs(params.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS),variables:buildListVariables(params),signal,fetchFn:this.fetchFn,clientHeaders:this.runtime.clientHeaders,userAgent:this.runtime.userAgent,diagnostics:this.runtime.diagnostics})}catch(cause){if(cause instanceof PkgseerTransportError){throw createListTransportError(cause)}throw cause}if(response.status<200||response.status>=300){throw createListHttpError(response)}const parsed=listGraphQLResponseSchema.safeParse(response.parsedBody);if(!parsed.success)throw new MalformedListResponseError2;if(parsed.data.errors&&parsed.data.errors.length>0){throw createListGraphQLError(parsed.data.errors,this.runtime.clientVersion,this.runtime.diagnostics)}const resultParsed=listResultSchema.safeParse(parsed.data.data?.list);if(!resultParsed.success)throw new MalformedListResponseError2;const result=resultParsed.data;if((params.includeDetailedFields||params.includeTargetProvenance===true)&&result.hint===undefined){throw new MalformedListResponseError2("Malformed response from the list service: selected hint is missing.")}if((params.includeDetailedFields||params.includeReadActions===true)&&result.entries.some((entry)=>entry.read===undefined)){throw new MalformedListResponseError2}if(result.hasMore&&!result.nextCursor){throw new MalformedListResponseError2("Malformed response from the list service: a continuation cursor is missing.")}return result}}function buildListVariables(params){return{target:params.target,...params.paths!==undefined?{paths:params.paths}:{},...params.recursive!==undefined?{recursive:params.recursive}:{},...params.fileTypes!==undefined?{fileTypes:params.fileTypes}:{},...params.languages!==undefined?{languages:params.languages}:{},...params.intents!==undefined?{intents:params.intents}:{},...params.limit!==undefined?{limit:params.limit}:{},...params.after!==undefined?{after:params.after}:{},...params.waitTimeoutMs!==undefined?{waitTimeoutMs:params.waitTimeoutMs}:{},includeDetailedFields:params.includeDetailedFields,includeTargetProvenance:params.includeDetailedFields||params.includeTargetProvenance===true,includeReadActions:params.includeDetailedFields||params.includeReadActions===true}}function createListHttpError(response){const detail=parseHttpErrorDetail(response.responseBody,["message","error","detail"]);if(response.status===401){return new AuthenticationError2(SERVER_AUTHENTICATION_REJECTED_MESSAGE,"server")}if(response.status===429){const rateLimit=httpRateLimitError(response.parsedBody);return new ListBackendError2(detail??rateLimit.message??"Request rate limited.",429,"RATE_LIMITED",true,parsePkgseerErrorDetails(rateLimit.extensions))}if(response.status===403){return new ListAccessError2(detail??"List access denied.")}if(response.status>=500){return new ListBackendError2(detail?`Server error (${response.status}): ${detail}`:`Server error (${response.status})`,response.status)}return new ListBackendError2(detail??`Request failed with status ${response.status}`,response.status)}function createListTransportError(error){if(isFetchTimeoutError(error.cause)){return new ListBackendError2("List request timed out.",undefined,"TIMEOUT",true)}return new ListNetworkError2("Could not reach the package and documentation service. Check your connection.",{cause:error})}function createListGraphQLError(errors,clientVersion,diagnostics){const message=errors.map((error)=>error.message).join(", ");const extensions=getPrimaryExtensions(errors);const code=typeof extensions?.code==="string"?extensions.code:undefined;const retryable=typeof extensions?.retryable==="boolean"?extensions.retryable:undefined;if(isClientUpdateRequiredGraphQLError({message,code})){return new ClientUpdateRequiredError(undefined,undefined,clientVersion)}if(isGraphQLSchemaMismatchError({message,code})){const sanitized="Backend protocol mismatch. Your CLI may be newer than the server, or the server may require a newer CLI. Run `githits update-check` to verify your installed version. Set GITHITS_DEBUG=code-nav-wire to inspect GraphQL details during local development.";return new ListBackendError2(diagnostics?.isEnabled("code-nav-wire")?message:sanitized,undefined,code,retryable)}if(code==="AUTHENTICATION_REQUIRED"||code==="UNAUTHORIZED"){return new AuthenticationError2(SERVER_AUTHENTICATION_REJECTED_MESSAGE,"server")}if(code==="FORBIDDEN"||code==="ACCESS_DENIED"){return new ListAccessError2(message)}return new ListGraphQLError2(message,code,retryable,typeof extensions?.repo_url==="string"?extensions.repo_url:undefined,typeof extensions?.commit_sha==="string"?extensions.commit_sha:undefined,typeof extensions?.indexing_ref==="string"?extensions.indexing_ref:undefined,typeof extensions?.hint==="string"?extensions.hint:undefined,{indexingEstimate:parseIndexingDurationEstimate(extensions),availableVersions:parseAvailableArtifacts(extensions?.available_versions??extensions?.availableVersions),package:typeof extensions?.package==="string"?extensions.package:undefined},parseVersionRefRecovery(extensions),parsePkgseerErrorDetails(extensions))}import{z as z5}from"zod";var readResultTypeSchema=z5.object({__typename:z5.enum(["CodeContextResult","GetDocPageResult","CodeSymbolResolutionResult"])});var symbolResolutionSchema=z5.object({__typename:z5.literal("CodeSymbolResolutionResult"),status:z5.enum(["AMBIGUOUS","NOT_FOUND","SNAPSHOT_UNSUPPORTED"]),candidates:z5.array(z5.object({name:z5.string().nullable(),qualifiedPath:z5.string().nullable(),kind:z5.string().nullable(),arity:z5.number().int().nullable(),filePath:z5.string().nullable(),startLine:z5.number().int().nullable(),endLine:z5.number().int().nullable()})).max(10),suggestions:z5.array(z5.object({name:z5.string(),qualifiedPath:z5.string().nullable(),localId:z5.string().nullable(),arity:z5.number().int().nullable(),filePath:z5.string().nullable(),reason:z5.string().nullable()})).max(10),hasMore:z5.boolean(),repoUrl:z5.string(),gitRef:z5.string(),message:z5.string().nullable(),codeIndexState:z5.string()});var readGraphQLErrorSchema=z5.object({message:z5.string(),extensions:z5.record(z5.string(),z5.unknown()).optional()});var readGraphQLResponseSchema=z5.object({data:z5.object({read:z5.unknown().nullable().optional()}).nullable().optional(),errors:z5.array(readGraphQLErrorSchema).optional()});var READ_QUERY=`
225
232
  query Read(
226
233
  $target: String!
227
234
  $path: String
@@ -298,7 +305,7 @@ query Read(
298
305
  codeIndexState
299
306
  }
300
307
  }
301
- }`;class ReadServiceImpl2{endpointUrl;tokenProvider;fetchFn;runtime;constructor(endpointUrl,tokenProvider,fetchFn=globalThis.fetch,runtime={}){this.endpointUrl=endpointUrl;this.tokenProvider=tokenProvider;this.fetchFn=fetchFn;this.runtime=runtime}async read(params,options){const signal=options?.signal;const request=normaliseReadRequest(params);return withServiceDiagnostics(this.runtime.diagnostics,"read.request",()=>executeWithTokenRefresh({getToken:()=>this.tokenProvider.getToken(),forceRefresh:()=>this.tokenProvider.forceRefresh(),shouldRefresh:isTokenRefreshableError,signal,executeWithToken:(token)=>this.executeRead(token,request,signal)}))}async executeRead(token,request,signal){let response;try{response=await postPkgseerGraphql({endpointUrl:this.endpointUrl,token,query:READ_QUERY,timeoutMs:indexingRequestTimeoutMs(request.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS),variables:buildReadVariables(request),signal,fetchFn:this.fetchFn,clientHeaders:this.runtime.clientHeaders,userAgent:this.runtime.userAgent,diagnostics:this.runtime.diagnostics})}catch(cause){if(cause instanceof PkgseerTransportError){if(isFetchTimeoutError(cause.cause)){throw new CodeNavigationBackendError("Read request timed out.",undefined,"TIMEOUT",true)}throw new CodeNavigationNetworkError("Could not reach the read service. Check your connection or set GITHITS_CODE_NAV_URL.",{cause})}throw cause}if(response.status<200||response.status>=300){const error=createCodeNavigationHttpError(response);if(error instanceof CodeNavigationAccessError&&error.message==="Code navigation access denied."){throw new CodeNavigationAccessError("Read access denied.")}throw error}const parsed=readGraphQLResponseSchema.safeParse(response.parsedBody);if(!parsed.success)throw malformedReadResponse();if(parsed.data.errors&&parsed.data.errors.length>0){const backendCode=parsed.data.errors[0]?.extensions?.code;if(backendCode==="DOCUMENTATION_SECTION_UNRESOLVED"){throw createPackageIntelligenceGraphQLError(parsed.data.errors,this.runtime.clientVersion,this.runtime.diagnostics)}if(backendCode==="FORBIDDEN"){throw new CodeNavigationAccessError("Read access denied.")}throw createCodeNavigationGraphQLError(parsed.data.errors,this.runtime)}const data=parsed.data.data?.read;if(!data)throw malformedReadResponse();const resultType=readResultTypeSchema.safeParse(data);if(!resultType.success)throw malformedReadResponse();if(resultType.data.__typename==="CodeSymbolResolutionResult"){const resolution=symbolResolutionSchema.safeParse(data);if(!resolution.success)throw malformedReadResponse();return{source:"symbol_resolution",result:resolution.data}}if(resultType.data.__typename==="CodeContextResult"){const action=z5.object({codeAction:selectedReadTargetSchema.nullable()}).safeParse(data);if(!action.success)throw malformedReadResponse();return{source:"code",result:{...parseReadBranch(parseCodeContextResult,data),readTarget:action.data.codeAction}}}if(resultType.data.__typename==="GetDocPageResult"){const action=z5.object({docAction:selectedReadTargetSchema}).safeParse(data);if(!action.success)throw malformedReadResponse();return{source:"docs",result:{...parseReadBranch(parsePackageDocResult,data),readTarget:action.data.docAction}}}throw malformedReadResponse()}}function normaliseReadRequest(params){const path=params.path?.trim()||undefined;return{...params,path,waitTimeoutMs:params.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS}}function buildReadVariables(request){return{target:request.target,...request.path!==undefined?{path:request.path}:{},...request.selector!==undefined?{selector:request.selector}:{},...request.startLine!==undefined?{startLine:request.startLine}:{},...request.endLine!==undefined?{endLine:request.endLine}:{},...request.waitTimeoutMs!==undefined?{waitTimeoutMs:request.waitTimeoutMs}:{}}}function malformedReadResponse(){return new MalformedCodeNavigationResponseError("Malformed response from read service.")}function parseReadBranch(parse,data){try{return parse(data)}catch(error){if(error instanceof MalformedCodeNavigationResponseError||error instanceof MalformedPackageIntelligenceResponseError){throw malformedReadResponse()}throw error}}class RefreshingGitHitsService2{apiUrl;tokenProvider;serviceFactory;runtime;constructor(apiUrl,tokenProvider,serviceFactory=undefined,runtime={}){this.apiUrl=apiUrl;this.tokenProvider=tokenProvider;this.serviceFactory=serviceFactory;this.runtime=runtime}async search(params,options){return this.withTokenRefresh(options?(service)=>service.search(params,options):(service)=>service.search(params),options)}async withTokenRefresh(operation,options){return executeWithTokenRefresh({getToken:()=>{options?.signal?.throwIfAborted();return this.tokenProvider.getToken()},forceRefresh:()=>{options?.signal?.throwIfAborted();return this.tokenProvider.forceRefresh()},shouldRefresh:isTokenRefreshableError,executeWithToken:async(token)=>{options?.signal?.throwIfAborted();const service=this.serviceFactory?this.serviceFactory(this.apiUrl,token):new GitHitsServiceImpl2(this.apiUrl,token,undefined,undefined,this.runtime);return operation(service)}})}}import{z as z6}from"zod";var latestVersionMaliciousEvidenceSchema=z6.object({advisories:z6.array(z6.object({osvId:z6.string(),classificationReasons:z6.array(z6.string())})).max(5),totalCount:z6.number().int().nonnegative(),truncated:z6.boolean()}).nullable();var compactMatchSchema=z6.object({confidence:z6.string()});var candidateEvidenceSchema=z6.object({canonicalKey:z6.string(),nameSimilarity:z6.number().nullable()});var detailedMatchSchema=compactMatchSchema.extend({matchedAliases:z6.array(z6.string()),matchTier:z6.number().int(),score:z6.number()});var listTargetSchema=z6.object({kind:z6.string(),canonicalKey:z6.string(),searchTarget:z6.string(),latestVersionMaliciousStatus:z6.string(),latestVersionMaliciousEvidence:latestVersionMaliciousEvidenceSchema,description:z6.string().nullable().optional(),repositoryUrl:z6.string().nullable().optional(),stars:z6.number().int().nullable().optional(),downloadsLastMonth:z6.number().int().nullable().optional(),downloadsTotal:z6.number().int().nullable().optional(),docsAvailable:z6.boolean(),codeAvailable:z6.boolean(),groupKey:z6.string().nullable(),match:compactMatchSchema.nullable(),docsPageCount:z6.number().int().nullable(),codeFileCount:z6.number().int().nullable(),license:z6.string().nullable()});var targetReferenceSchema=z6.object({kind:z6.string(),canonicalKey:z6.string(),searchTarget:z6.string(),confidence:z6.string()});var detailedTargetSchema=listTargetSchema.omit({match:true}).extend({match:detailedMatchSchema.nullable(),displayName:z6.string(),registry:z6.string().nullable().optional(),packageName:z6.string().nullable().optional(),latestVersion:z6.string().nullable().optional(),repositoryOwner:z6.string().nullable().optional(),repositoryName:z6.string().nullable().optional(),documentationUrl:z6.string().nullable().optional()});var graphQLErrorSchema3=z6.object({message:z6.string(),extensions:z6.record(z6.string(),z6.unknown()).optional()});function responseSchema(targetSchema,includeNameSimilarity){const resultSchema=z6.object({best:targetReferenceSchema.nullable(),protectedMatches:z6.array(targetReferenceSchema),candidates:includeNameSimilarity?z6.array(candidateEvidenceSchema):z6.array(candidateEvidenceSchema).optional(),targets:z6.array(targetSchema),targetsTruncated:z6.boolean(),ambiguous:z6.boolean(),ambiguousReason:z6.string()});return z6.object({data:z6.object({resolveTarget:resultSchema.nullable()}).nullable().optional(),errors:z6.array(graphQLErrorSchema3).optional()})}var RESOLVE_TARGET_QUERY=`
308
+ }`;class ReadServiceImpl2{endpointUrl;tokenProvider;fetchFn;runtime;constructor(endpointUrl,tokenProvider,fetchFn=globalThis.fetch,runtime={}){this.endpointUrl=endpointUrl;this.tokenProvider=tokenProvider;this.fetchFn=fetchFn;this.runtime=runtime}async read(params,options){const signal=options?.signal;const request=normaliseReadRequest(params);return withServiceDiagnostics(this.runtime.diagnostics,"read.request",()=>executeWithTokenRefresh({getToken:()=>this.tokenProvider.getToken(),forceRefresh:()=>this.tokenProvider.forceRefresh(),shouldRefresh:isTokenRefreshableError,signal,executeWithToken:(token)=>this.executeRead(token,request,signal)}))}async executeRead(token,request,signal){let response;try{response=await postPkgseerGraphql({endpointUrl:this.endpointUrl,token,query:READ_QUERY,timeoutMs:indexingRequestTimeoutMs(request.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS),variables:buildReadVariables(request),signal,fetchFn:this.fetchFn,clientHeaders:this.runtime.clientHeaders,userAgent:this.runtime.userAgent,diagnostics:this.runtime.diagnostics})}catch(cause){if(cause instanceof PkgseerTransportError){if(isFetchTimeoutError(cause.cause)){throw new CodeNavigationBackendError("Read request timed out.",undefined,"TIMEOUT",true)}throw new CodeNavigationNetworkError("Could not reach the read service. Check your connection or set GITHITS_CODE_NAV_URL.",{cause})}throw cause}if(response.status<200||response.status>=300){const error=createCodeNavigationHttpError(response);if(error instanceof CodeNavigationAccessError&&error.message==="Code navigation access denied."){throw new CodeNavigationAccessError("Read access denied.")}throw error}const parsed=readGraphQLResponseSchema.safeParse(response.parsedBody);if(!parsed.success)throw malformedReadResponse();if(parsed.data.errors&&parsed.data.errors.length>0){const backendCode=parsed.data.errors[0]?.extensions?.code;if(backendCode==="DOCUMENTATION_SECTION_UNRESOLVED"){throw createPackageIntelligenceGraphQLError(parsed.data.errors,this.runtime.clientVersion,this.runtime.diagnostics)}if(backendCode==="FORBIDDEN"){throw new CodeNavigationAccessError("Read access denied.")}throw createCodeNavigationGraphQLError(parsed.data.errors,this.runtime)}const data=parsed.data.data?.read;if(!data)throw malformedReadResponse();const resultType=readResultTypeSchema.safeParse(data);if(!resultType.success)throw malformedReadResponse();if(resultType.data.__typename==="CodeSymbolResolutionResult"){const resolution=symbolResolutionSchema.safeParse(data);if(!resolution.success)throw malformedReadResponse();return{source:"symbol_resolution",result:resolution.data}}if(resultType.data.__typename==="CodeContextResult"){const action=z5.object({codeAction:selectedReadTargetSchema.nullable()}).safeParse(data);if(!action.success)throw malformedReadResponse();return{source:"code",result:{...parseReadBranch(parseCodeContextResult,data),readTarget:action.data.codeAction}}}if(resultType.data.__typename==="GetDocPageResult"){const action=z5.object({docAction:selectedReadTargetSchema}).safeParse(data);if(!action.success)throw malformedReadResponse();return{source:"docs",result:{...parseReadBranch(parsePackageDocResult,data),readTarget:action.data.docAction}}}throw malformedReadResponse()}}function normaliseReadRequest(params){const path=params.path!==undefined&&params.path.trim().length>0?params.path:undefined;return{...params,path,waitTimeoutMs:params.waitTimeoutMs??DEFAULT_WAIT_TIMEOUT_MS}}function buildReadVariables(request){return{target:request.target,...request.path!==undefined?{path:request.path}:{},...request.selector!==undefined?{selector:request.selector}:{},...request.startLine!==undefined?{startLine:request.startLine}:{},...request.endLine!==undefined?{endLine:request.endLine}:{},...request.waitTimeoutMs!==undefined?{waitTimeoutMs:request.waitTimeoutMs}:{}}}function malformedReadResponse(){return new MalformedCodeNavigationResponseError("Malformed response from read service.")}function parseReadBranch(parse,data){try{return parse(data)}catch(error){if(error instanceof MalformedCodeNavigationResponseError||error instanceof MalformedPackageIntelligenceResponseError){throw malformedReadResponse()}throw error}}class RefreshingGitHitsService2{apiUrl;tokenProvider;serviceFactory;runtime;constructor(apiUrl,tokenProvider,serviceFactory=undefined,runtime={}){this.apiUrl=apiUrl;this.tokenProvider=tokenProvider;this.serviceFactory=serviceFactory;this.runtime=runtime}async search(params,options){return this.withTokenRefresh(options?(service)=>service.search(params,options):(service)=>service.search(params),options)}async withTokenRefresh(operation,options){return executeWithTokenRefresh({getToken:()=>{options?.signal?.throwIfAborted();return this.tokenProvider.getToken()},forceRefresh:()=>{options?.signal?.throwIfAborted();return this.tokenProvider.forceRefresh()},shouldRefresh:isTokenRefreshableError,executeWithToken:async(token)=>{options?.signal?.throwIfAborted();const service=this.serviceFactory?this.serviceFactory(this.apiUrl,token):new GitHitsServiceImpl2(this.apiUrl,token,undefined,undefined,this.runtime);return operation(service)}})}}import{z as z6}from"zod";var latestVersionMaliciousEvidenceSchema=z6.object({advisories:z6.array(z6.object({osvId:z6.string(),classificationReasons:z6.array(z6.string())})).max(5),totalCount:z6.number().int().nonnegative(),truncated:z6.boolean()}).nullable();var compactMatchSchema=z6.object({confidence:z6.string()});var candidateEvidenceSchema=z6.object({canonicalKey:z6.string(),nameSimilarity:z6.number().nullable()});var detailedMatchSchema=compactMatchSchema.extend({matchedAliases:z6.array(z6.string()),matchTier:z6.number().int(),score:z6.number()});var listTargetSchema=z6.object({kind:z6.string(),canonicalKey:z6.string(),searchTarget:z6.string(),latestVersionMaliciousStatus:z6.string(),latestVersionMaliciousEvidence:latestVersionMaliciousEvidenceSchema,description:z6.string().nullable().optional(),repositoryUrl:z6.string().nullable().optional(),stars:z6.number().int().nullable().optional(),downloadsLastMonth:z6.number().int().nullable().optional(),downloadsTotal:z6.number().int().nullable().optional(),docsAvailable:z6.boolean(),codeAvailable:z6.boolean(),groupKey:z6.string().nullable(),match:compactMatchSchema.nullable(),docsPageCount:z6.number().int().nullable(),codeFileCount:z6.number().int().nullable(),license:z6.string().nullable()});var targetReferenceSchema=z6.object({kind:z6.string(),canonicalKey:z6.string(),searchTarget:z6.string(),confidence:z6.string()});var detailedTargetSchema=listTargetSchema.omit({match:true}).extend({match:detailedMatchSchema.nullable(),displayName:z6.string(),registry:z6.string().nullable().optional(),packageName:z6.string().nullable().optional(),latestVersion:z6.string().nullable().optional(),repositoryOwner:z6.string().nullable().optional(),repositoryName:z6.string().nullable().optional(),documentationUrl:z6.string().nullable().optional()});var graphQLErrorSchema3=z6.object({message:z6.string(),extensions:z6.record(z6.string(),z6.unknown()).optional()});function responseSchema(targetSchema,includeNameSimilarity){const resultSchema=z6.object({best:targetReferenceSchema.nullable(),protectedMatches:z6.array(targetReferenceSchema),candidates:includeNameSimilarity?z6.array(candidateEvidenceSchema):z6.array(candidateEvidenceSchema).optional(),targets:z6.array(targetSchema),targetsTruncated:z6.boolean(),ambiguous:z6.boolean(),ambiguousReason:z6.string()});return z6.object({data:z6.object({resolveTarget:resultSchema.nullable()}).nullable().optional(),errors:z6.array(graphQLErrorSchema3).optional()})}var RESOLVE_TARGET_QUERY=`
302
309
  query ResolveTarget(
303
310
  $name: String!
304
311
  $query: String