| 4551 | `,e9Y,tDK;var $p=y(()=>{x7();y41();o1();k8();kj();ON();Ga();Bq();I7();m8();y8();bK();zu8();U7();e7();RL();E8();n88();i1();aq();ku8();dz();$17();cf8();Tz();br();sR6();B68();l8();A17();IY();rDK();Q9Y=new Set(["/dev/zero","/dev/random","/dev/urandom","/dev/full","/dev/stdin","/dev/tty","/dev/console","/dev/stdout","/dev/stderr","/dev/fd/0","/dev/fd/1","/dev/fd/2"]);c9Y=String.fromCharCode(8239);n9Y=[];sp8=class sp8 extends Error{tokenCount;maxTokens;constructor(q,K){super(`File content (${q} tokens) exceeds maximum allowed tokens (${K}). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.`);this.tokenCount=q;this.maxTokens=K;this.name="MaxFileReadTokenExceededError"}};sDK=new Set(["png","jpg","jpeg","gif","webp"]);r9Y=B6(()=>L.strictObject({file_path:L.string().describe("The absolute path to the file to read"),offset:eN(L.number().int().nonnegative().optional()).describe("The line number to start reading from. Only provide if the file is too large to read at once"),limit:eN(L.number().int().positive().optional()).describe("The number of lines to read. Only provide if the file is too large to read at once."),pages:L.string().optional().describe(`Page range for PDF files (e.g., "1-5", "3", "10-20"). Only applicable to PDF files. Maximum ${LO6} pages per request.`)})),o9Y=B6(()=>{let q=L.enum(["image/jpeg","image/png","image/gif","image/webp"]);return L.discriminatedUnion("type",[L.object({type:L.literal("text"),file:L.object({filePath:L.string().describe("The path to the file that was read"),content:L.string().describe("The content of the file"),numLines:L.number().describe("Number of lines in the returned content"),startLine:L.number().describe("The starting line number"),totalLines:L.number().describe("Total number of lines in the file")})}),L.object({type:L.literal("image"),file:L.object({base64:L.string().describe("Base64-encoded image data"),type:q.describe("The MIME type of the image"),originalSize:L.number().describe("Original file size in bytes"),dimensions:L.object({originalWidth:L.number().optional().describe("Original image width in pixels"),originalHeight:L.number().optional().describe("Original image height in pixels"),displayWidth:L.number().optional().describe("Displayed image width in pixels (after resizing)"),displayHeight:L.number().optional().describe("Displayed image height in pixels (after resizing)")}).optional().describe("Image dimension info for coordinate mapping")})}),L.object({type:L.literal("notebook"),file:L.object({filePath:L.string().describe("The path to the notebook file"),cells:L.array(L.any()).describe("Array of notebook cells")})}),L.object({type:L.literal("pdf"),file:L.object({filePath:L.string().describe("The path to the PDF file"),base64:L.string().describe("Base64-encoded PDF data"),originalSize:L.number().describe("Original file size in bytes")})}),L.object({type:L.literal("parts"),file:L.object({filePath:L.string().describe("The path to the PDF file"),originalSize:L.number().describe("Original file size in bytes"),count:L.number().describe("Number of pages extracted"),outputDir:L.string().describe("Directory containing extracted page images")})}),L.object({type:L.literal("file_unchanged"),file:L.object({filePath:L.string().describe("The path to the file")})})])}),i_=sq({name:Cq,searchHint:"read files, images, PDFs, notebooks",maxResultSizeChars:1/0,strict:!0,async description(){return Zoq},async prompt(){let q=GH6(),K=q.includeMaxSizeInPrompt?`. Files larger than ${m4(q.maxSizeBytes)} will return an error; use offset and limit for larger files`:"",_=q.targetedRangeNudge?voq:Toq;return koq(a9Y(),K,_)},get inputSchema(){return r9Y()},get outputSchema(){return o9Y()},userFacingName:iDK,getToolUseSummary:O17,getActivityDescription(q){let K=O17(q);return K?`Reading ${K}`:"Reading file"},isConcurrencySafe(){return!0},isReadOnly(){return!0},toAutoClassifierInput(q){return q.file_path},isSearchOrReadCommand(){return{isSearch:!1,isRead:!0}},getPath({file_path:q}){return q||Z8()},backfillObservableInput(q){if(typeof q.file_path==="string")q.file_path=lq(q.file_path)},async preparePermissionMatcher({file_path:q}){return(K)=>lv(K,q)},async checkPermissions(q,K){let _=K.getAppState();return RK6(i_,q,_.toolPermissionContext)},renderToolUseMessage:dDK,renderToolUseTag:cDK,renderToolResultMessage:lDK,extractSearchText(){return""},renderToolUseErrorMessage:nDK,async validateInput({file_path:q,pages:K},_){if(K!==void 0){let w=PN1(K);if(!w)return{result:!1,message:`Invalid pages parameter: "${K}". Use formats like "1-5", "3", or "10-20". Pages are 1-indexed.`,errorCode:7};if((w.lastPage===1/0?LO6+1:w.lastPage-w.firstPage+1)>LO6)return{result:!1,message:`Page range "${K}" exceeds maximum of ${LO6} pages per request. Please use a smaller range.`,errorCode:8}}let z=lq(q),Y=_.getAppState();if(VH(z,Y.toolPermissionContext,"read","deny")!==null)return{result:!1,message:"File is in a directory that is denied by your permission settings.",errorCode:1};if(z.startsWith("\\\\")||z.startsWith("//"))return{result:!0};let O=TH6.extname(z).toLowerCase();if(c$8(z)&&!KT6(O)&&!sDK.has(O.slice(1)))return{result:!1,message:`This tool cannot read binary files. The file appears to be a binary ${O} file. Please use appropriate tools for binary file analysis.`,errorCode:4};if(d9Y(z))return{result:!1,message:`Cannot read '${q}': this device file would block or produce infinite output.`,errorCode:9};return{result:!0}},async call({file_path:q,offset:K=1,limit:_=void 0,pages:z},Y,$,A){let{readFileState:O,fileReadingLimits:w}=Y,j=GH6(),H=w?.maxSizeBytes??j.maxSizeBytes,J=w?.maxTokens??j.maxTokens;if(w!==void 0)d("tengu_file_read_limits_override",{hasMaxTokens:w.maxTokens!==void 0,hasMaxSizeBytes:w.maxSizeBytes!==void 0});let M=TH6.extname(q).toLowerCase().slice(1),X=lq(q),W=g8("tengu_read_dedup_killswitch",!1)?void 0:O.get(X);if(W&&!W.isPartialView&&W.offset!==void 0){if(W.offset===K&&W.limit===_)try{if(await zp6(X)===W.timestamp){let Z=M16(X);return d("tengu_file_read_dedup",{...Z!==void 0&&{ext:Z}}),{data:{type:"file_unchanged",file:{filePath:q}}}}}catch{}}let D=Z8();if(!i6(process.env.CLAUDE_CODE_SIMPLE)){let f=await gL6([X],D);if(f.length>0){for(let G of f)Y.dynamicSkillDirTriggers?.add(G);FL6(f).catch(()=>{})}UL6([X],D)}try{return await aDK(q,X,X,M,K,_,z,H,J,O,Y,A?.message.id)}catch(f){if(s1(f)==="ENOENT"){let Z=l9Y(X);if(Z)try{return await aDK(q,X,Z,M,K,_,z,H,J,O,Y,A?.message.id)}catch(E){if(!_7(E))throw E}let T=U$8(X),v=await pe(X),V=`File does not exist. ${uZ} ${Z8()}.`;if(v)V+=` Did you mean ${v}?`;else if(T)V+=` Did you mean ${T}?`;throw Error(V)}throw f}},mapToolResultToToolResultBlockParam(q,K){switch(q.type){case"image":return{tool_use_id:K,type:"tool_result",content:[{type:"image",source:{type:"base64",data:q.file.base64,media_type:q.file.type}}]};case"notebook":return GAK(q.file.cells,K);case"pdf":return{tool_use_id:K,type:"tool_result",content:`PDF file read: ${q.file.filePath} (${m4(q.file.originalSize)})`};case"parts":return{tool_use_id:K,type:"tool_result",content:`PDF pages extracted: ${q.file.count} page(s) from ${q.file.filePath} (${m4(q.file.originalSize)})`};case"file_unchanged":return{tool_use_id:K,type:"tool_result",content:_T6};case"text":{let _;if(q.file.content)_=K_Y(q)+s9Y(q.file)+(q_Y()?t9Y:"");else _=q.file.totalLines===0?"<system-reminder>Warning: the file exists but the contents are empty.</system-reminder>":`<system-reminder>Warning: the file exists but is shorter than the provided offset (${q.file.startLine}). The file has ${q.file.totalLines} lines.</system-reminder>`;return{tool_use_id:K,type:"tool_result",content:_}}}}});e9Y=new Set(["claude-opus-4-6"]);tDK=new WeakMap});function vH6(q){return q.type==="image"&&q.content.length>0}function eDK(q){if(!q)return;let K=Object.values(q).filter(vH6).map((_)=>_.id);return K.length>0?K:void 0}function _h6(){if(i6(process.env.CLAUDE_CODE_MCP_INSTR_DELTA))return!0;if(k_(process.env.CLAUDE_CODE_MCP_INSTR_DELTA))return!1;return g8("tengu_basalt_3kr",!1)}function qfK(q,K,_){let z=new Set,Y=0,$=0;for(let J of K){if(J.type!=="attachment")continue;if(Y++,J.attachment.type!=="mcp_instructions_delta")continue;$++;for(let M of J.attachment.addedNames)z.add(M);for(let M of J.attachment.removedNames)z.delete(M)}let A=q.filter((J)=>J.type==="connected"),O=new Set(A.map((J)=>J.name)),w=new Map;for(let J of A)if(J.instructions)w.set(J.name,`## ${J.name} |