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

Function Tg4

package/cli.js:2061–2062  ·  view source on GitHub ↗
(q,K)

Source from the content-addressed store, hash-verified

2059[TRUNCATED - Content exceeds 60KB limit]`,truncated:!0}}function bU1(q){return Ofz("sha256").update(q).digest("hex").slice(0,12)}function jfz(q){return`sp_${bU1(q)}`}function Zg4(q){let K=g6(q.message.content);return`msg_${bU1(K)}`}function SU1(q){let K=q.trim().match(Hfz);return K&&K[1]?K[1].trim():null}function Jfz(q){let K=[],_=[];for(let z of q){let Y=z.message.content;if(typeof Y==="string"){let $=SU1(Y);if($)_.push($);else K.push(`[USER]
2060${Y}`)}else if(Array.isArray(Y)){for(let $ of Y)if($.type==="text"){let A=SU1($.text);if(A)_.push(A);else K.push(`[USER]
2061${$.text}`)}else if($.type==="tool_result"){let A=typeof $.content==="string"?$.content:g6($.content),O=SU1(A);if(O)_.push(O);else K.push(`[TOOL RESULT: ${$.tool_use_id}]
2062${A}`)}}}return{contextParts:K,systemReminders:_}}function Tg4(q,K){if(!bH())return;let{content:_,truncated:z}=rU(`[USER PROMPT]
2063${K}`);q.setAttributes({new_context:_,...z&&{new_context_truncated:!0,new_context_original_length:K.length}})}function vg4(q,K,_){if(!bH())return;if(K?.systemPrompt){let z=jfz(K.systemPrompt),Y=K.systemPrompt.slice(0,500);if(q.setAttribute("system_prompt_hash",z),q.setAttribute("system_prompt_preview",Y),q.setAttribute("system_prompt_length",K.systemPrompt.length),!Gs6.has(z)){Gs6.add(z);let{content:$,truncated:A}=rU(K.systemPrompt);EA("system_prompt",{system_prompt_hash:z,system_prompt:$,system_prompt_length:String(K.systemPrompt.length),...A&&{system_prompt_truncated:"true"}})}}if(K?.tools)try{let Y=r8(K.tools).map(($)=>{let A=g6($),O=bU1(A);return{name:typeof $.name==="string"?$.name:"unknown",hash:O,json:A}});q.setAttribute("tools",g6(Y.map(({name:$,hash:A})=>({name:$,hash:A})))),q.setAttribute("tools_count",Y.length);for(let{name:$,hash:A,json:O}of Y)if(!Gs6.has(`tool_${A}`)){Gs6.add(`tool_${A}`);let{content:w,truncated:j}=rU(O);EA("tool",{tool_name:wK($),tool_hash:A,tool:w,...j&&{tool_truncated:"true"}})}}catch{q.setAttribute("tools_parse_error",!0)}if(_&&_.length>0&&K?.querySource){let z=K.querySource,Y=CU1.get(z),$=0;if(Y)for(let O=0;O<_.length;O++){let w=_[O];if(w&&Zg4(w)===Y){$=O+1;break}}let A=_.slice($).filter((O)=>O.type==="user");if(A.length>0){let{contextParts:O,systemReminders:w}=Jfz(A);if(O.length>0){let H=O.join(`
2064
2065---

Callers 1

Ig4Function · 0.85

Calls 3

bHFunction · 0.85
rUFunction · 0.85
setAttributesMethod · 0.45

Tested by

no test coverage detected