MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / w17

Function w17

package/cli.js:4545–4545  ·  view source on GitHub ↗
(q,K=GH6().maxTokens,_)

Source from the content-addressed store, hash-verified

4543 cat "${q}" | jq '.cells[:20]' # First 20 cells
4544 cat "${q}" | jq '.cells[100:120]' # Cells 100-120
4545 cat "${q}" | jq '.cells | length' # Count total cells
4546 cat "${q}" | jq '.cells[] | select(.cell_type=="code") | .source' # All code sources`);await oDK(E,z,w);let R=await X8().stat(_);j.set(K,{content:E,timestamp:Math.floor(R.mtimeMs),offset:Y,limit:$}),H.nestedMemoryAttachmentTriggers?.add(K);let x={type:"notebook",file:{filePath:q,cells:V}};return em({operation:"read",tool:"FileReadTool",filePath:K,content:E}),{data:x}}if(sDK.has(z)){let V=await w17(_,w);H.nestedMemoryAttachmentTriggers?.add(K),em({operation:"read",tool:"FileReadTool",filePath:K,content:V.file.base64});let E=V.file.dimensions?_V6(V.file.dimensions):null;return{data:V,...E&&{newMessages:[U8({content:E,isMeta:!0})]}}}if(KT6(z)){if(A){let B=PN1(A),p=await Y17(_,B??void 0);if(!p.success)throw Error(p.error.message);d("tengu_pdf_page_extraction",{success:!0,pageCount:p.data.file.count,fileSize:p.data.file.originalSize,hasPageRange:!0}),em({operation:"read",tool:"FileReadTool",filePath:K,content:`PDF pages ${A}`});let g=(await B9Y(p.data.file.outputDir)).filter((U)=>U.endsWith(".jpg")).sort(),F=await Promise.all(g.map(async(U)=>{let c=TH6.join(p.data.file.outputDir,U),K6=await g9Y(c),t=await LL(K6,K6.length,"jpeg");return{type:"image",source:{type:"base64",media_type:`image/${t.mediaType}`,data:t.buffer.toString("base64")}}}));return{data:p.data,...F.length>0&&{newMessages:[U8({content:F,isMeta:!0})]}}}let V=await rp8(_);if(V!==null&&V>Zk8)throw Error(`This PDF has ${V} pages, which is too many to read at once. Use the pages parameter to read specific page ranges (e.g., pages: "1-5"). Maximum ${LO6} pages per request.`);let S=await X8().stat(_);if(!uc6()||S.size>zj4){let B=await Y17(_);if(B.success)d("tengu_pdf_page_extraction",{success:!0,pageCount:B.data.file.count,fileSize:B.data.file.originalSize});else d("tengu_pdf_page_extraction",{success:!1,available:B.error.reason!=="unavailable",fileSize:S.size})}if(!uc6())throw Error(`Reading full PDFs is not supported with this model. Use a newer model (Sonnet 3.5 v2 or later), or use the pages parameter to read specific page ranges (e.g., pages: "1-5", maximum ${LO6} pages per request). Page extraction requires poppler-utils: install with \`brew install poppler\` on macOS or \`apt-get install poppler-utils\` on Debian/Ubuntu.`);let x=await QDK(_);if(!x.success)throw Error(x.error.message);let I=x.data;return em({operation:"read",tool:"FileReadTool",filePath:K,content:I.file.base64}),{data:I,newMessages:[U8({content:[{type:"document",source:{type:"base64",media_type:"application/pdf",data:I.file.base64}}],isMeta:!0})]}}let M=Y===0?0:Y-1,{content:X,lineCount:P,totalLines:W,totalBytes:D,readBytes:f,mtimeMs:G}=await lK6(_,M,$,$===void 0?O:void 0,H.abortController.signal);await oDK(X,z,w),j.set(K,{content:X,timestamp:Math.floor(G),offset:Y,limit:$}),H.nestedMemoryAttachmentTriggers?.add(K);for(let V of n9Y.slice())V(_,X);let Z={type:"text",file:{filePath:q,content:X,numLines:P,startLine:Y,totalLines:W}};if(pR6(K))tDK.set(Z,G);em({operation:"read",tool:"FileReadTool",filePath:K,content:X});let T=i9Y(K),v=M16(K);return d("tengu_session_file_read",{totalLines:W,readLines:P,totalBytes:D,readBytes:f,offset:Y,...$!==void 0&&{limit:$},...v!==void 0&&{ext:v},...J!==void 0&&{messageID:J},is_session_memory:T==="session_memory",is_session_transcript:T==="session_transcript"}),{data:Z}}async function w17(q,K=GH6().maxTokens,_){let z=await X8().readFileBytes(q,_),Y=z.length;if(Y===0)throw Error(`Image file is empty: ${q}`);let $=Sr6(z),A=$.split("/")[1]||"png",O;try{let j=await LL(z,Y,A);O=ap8(j.buffer,j.mediaType,Y,j.dimensions)}catch(j){if(j instanceof wU)throw j;H6(j),O=ap8(z,A,Y)}if(Math.ceil(O.file.base64.length*0.125)>K)try{let j=await rX4(z,K,$);return{type:"image",file:{base64:j.base64,type:j.mediaType,originalSize:Y}}}catch(j){H6(j);try{let H=await Promise.resolve().then(() => O6(oI1(),1)),M=await(H.default||H)(z).resize(400,400,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:20}).toBuffer();return ap8(M,"jpeg",Y)}catch(H){return H6(H),ap8(z,A,Y)}}return O}var Q9Y,c9Y,n9Y,sp8,sDK,r9Y,o9Y,i_,t9Y=`
4547
4548<system-reminder>

Callers 2

aDKFunction · 0.85
x_YFunction · 0.85

Calls 9

X8Function · 0.85
Sr6Function · 0.85
LLFunction · 0.85
ap8Function · 0.85
H6Function · 0.85
rX4Function · 0.85
O6Function · 0.85
thenMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected