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

Function k87

package/cli.js:7728–7728  ·  view source on GitHub ↗
(q,K,_,z,Y=PO)

Source from the content-addressed store, hash-verified

7726${q.blockingError}`}function w_7(q){return`UserPromptSubmit operation blocked by hook:
7727${q.blockingError}`}async function*GR({hookInput:q,toolUseID:K,matchQuery:_,signal:z,timeoutMs:Y=PO,toolUseContext:$,messages:A,forceSyncExecution:O,requestPrompt:w,toolInputSummary:j}){if(j68())return;if(i6(process.env.CLAUDE_CODE_SIMPLE))return;let H=q.hook_event_name,J=_?`${H}:${_}`:H,M=w?.(J,j);if(Qq8()){N(`Skipping ${J} hook execution - workspace trust not accepted`);return}let X=$?$.getAppState():void 0,P=$?.agentId??N8(),W=await O_7(X,P,H,q,$?.options?.tools);if(W.length===0)return;if(z?.aborted)return;let D=W.filter((x)=>!NgK(x));if(D.length>0){let x=ygK(D),I=EgK(D);d("tengu_run_hook",{hookName:J,numCommands:D.length,hookTypeCounts:g6(I),...x&&{pluginHookCounts:g6(x)}})}else{let x=Date.now(),I=$?{getAppState:$.getAppState,updateAttributionState:$.updateAttributionState}:void 0;for(let[p,{hook:C}]of W.entries())if(C.type==="callback")await C.callback(q,K,z,p,I);let B=Date.now()-x;d36()?.observe("hook_duration_ms",B),s58(B),d("tengu_repl_hook_finished",{hookName:J,numCommands:W.length,numSuccess:W.length,numBlocking:0,numNonBlockingError:0,numCancelled:0,totalDurationMs:B});return}let f=bH()?g6(TgK(W)):"[]";if(bH())EA("hook_execution_start",{hook_event:H,hook_name:J,num_hooks:String(W.length),managed_only:String(fb()),hook_definitions:f,hook_source:fb()?"policySettings":"merged"});let G=Fg4(H,J,W.length,f);for(let{hook:x}of W)yield{message:{type:"progress",data:{type:"hook_progress",hookEvent:H,hookName:J,command:pL(x),...x.type==="prompt"&&{promptText:x.prompt},..."statusMessage"in x&&x.statusMessage!=null&&{statusMessage:x.statusMessage}},parentToolUseID:K,toolUseID:K,timestamp:new Date().toISOString(),uuid:vy()}};let Z=Date.now(),T;function v(){if(T!==void 0)return T;try{return T={ok:!0,value:g6(q)}}catch(x){return H6(Error(`Failed to stringify hook ${J} input`,{cause:x})),T={ok:!1,error:x}}}let V=W.map(async function*({hook:x,pluginRoot:I,pluginId:B,skillRoot:p},C){if(x.type==="callback"){let q6=x.timeout?x.timeout*1000:Y,{signal:e,cleanup:i}=Ty(z,{timeoutMs:q6});yield ohY({toolUseID:K,hook:x,hookEvent:H,hookInput:q,signal:e,hookIndex:C,toolUseContext:$}).finally(i);return}if(x.type==="function"){if(!A){yield{message:V4({type:"hook_error_during_execution",hookName:J,toolUseID:K,hookEvent:H,content:"Messages not provided for function hook"}),outcome:"non_blocking_error",hook:x};return}yield rhY({hook:x,messages:A,hookName:J,toolUseID:K,hookEvent:H,timeoutMs:Y,signal:z});return}let g=x.timeout?x.timeout*1000:Y,{signal:F,cleanup:U}=Ty(z,{timeoutMs:g}),c=vy(),K6=Date.now(),t=pL(x);try{let q6=v();if(!q6.ok){yield{message:V4({type:"hook_error_during_execution",hookName:J,toolUseID:K,hookEvent:H,content:`Failed to prepare hook input: ${d6(q6.error)}`,command:t,durationMs:Date.now()-K6}),outcome:"non_blocking_error",hook:x},U();return}let e=q6.value;if(x.type==="prompt"){if(!$)throw Error("ToolUseContext is required for prompt hooks. This is a bug.");let w6=await AgK(x,J,H,e,F,$,A,K);if(w6.message?.type==="attachment"){let o=w6.message.attachment;if(o.type==="hook_success"||o.type==="hook_non_blocking_error")o.command=t,o.durationMs=Date.now()-K6}yield w6,U?.();return}if(x.type==="agent"){if(!$)throw Error("ToolUseContext is required for agent hooks. This is a bug.");if(!A)throw Error("Messages are required for agent hooks. This is a bug.");let w6=await jgK(x,J,H,e,F,$,K,A,"agent_type"in q?q.agent_type:void 0);if(w6.message?.type==="attachment"){let o=w6.message.attachment;if(o.type==="hook_success"||o.type==="hook_non_blocking_error")o.command=t,o.durationMs=Date.now()-K6}yield w6,U?.();return}if(x.type==="http"){M17(c,J,H);let w6=await $_7(x,H,e,z);if(U?.(),w6.aborted){i0({hookId:c,hookName:J,hookEvent:H,output:"Hook cancelled",stdout:"",stderr:"",exitCode:void 0,outcome:"cancelled"}),yield{message:V4({type:"hook_cancelled",hookName:J,toolUseID:K,hookEvent:H}),outcome:"cancelled",hook:x};return}if(w6.error||!w6.ok){let a=w6.error||`HTTP ${w6.statusCode} from ${x.url}`;i0({hookId:c,hookName:J,hookEvent:H,output:a,stdout:"",stderr:a,exitCode:w6.statusCode,outcome:"error"}),yield{message:V4({type:"hook_non_blocking_error",hookName:J,toolUseID:K,hookEvent:H,stderr:a,stdout:"",exitCode:w6.statusCode??0}),outcome:"non_blocking_error",hook:x};return}let{json:o,validationError:s}=VgK(w6.body);if(s){i0({hookId:c,hookName:J,hookEvent:H,output:w6.body,stdout:w6.body,stderr:`JSON validation failed: ${s}`,exitCode:w6.statusCode,outcome:"error"}),yield{message:V4({type:"hook_non_blocking_error",hookName:J,toolUseID:K,hookEvent:H,stderr:`JSON validation failed: ${s}`,stdout:w6.body,exitCode:w6.statusCode??0}),outcome:"non_blocking_error",hook:x};return}if(o&&rb(o)){i0({hookId:c,hookName:J,hookEvent:H,output:w6.body,stdout:w6.body,stderr:"",exitCode:w6.statusCode,outcome:"success"}),yield{outcome:"success",hook:x};return}if(o){let a=A_7({json:o,command:x.url,hookName:J,toolUseID:K,hookEvent:H,expectedHookEvent:H,stdout:w6.body,stderr:"",exitCode:w6.statusCode});i0({hookId:c,hookName:J,hookEvent:H,output:w6.body,stdout:w6.body,stderr:"",exitCode:w6.statusCode,outcome:"success"}),yield{...a,outcome:"success",hook:x};return}return}M17(c,J,H);let i=await hQ8(x,H,J,e,F,c,C,I,B,p,O,M);U?.();let $6=Date.now()-K6;if(i.backgrounded){yield{outcome:"success",hook:x};return}if(i.aborted){i0({hookId:c,hookName:J,hookEvent:H,output:i.output,stdout:i.stdout,stderr:i.stderr,exitCode:i.status,outcome:"cancelled"}),yield{message:V4({type:"hook_cancelled",hookName:J,toolUseID:K,hookEvent:H,command:t,durationMs:$6}),outcome:"cancelled",hook:x};return}let{json:M6,plainText:j6,validationError:G6}=kgK(i.stdout);if(G6){i0({hookId:c,hookName:J,hookEvent:H,output:i.output,stdout:i.stdout,stderr:`JSON validation failed: ${G6}`,exitCode:1,outcome:"error"}),yield{message:V4({type:"hook_non_blocking_error",hookName:J,toolUseID:K,hookEvent:H,stderr:`JSON validation failed: ${G6}`,stdout:i.stdout,exitCode:1,command:t,durationMs:$6}),outcome:"non_blocking_error",hook:x};return}if(M6){if(rb(M6)){yield{outcome:"success",hook:x};return}let w6=A_7({json:M6,command:t,hookName:J,toolUseID:K,hookEvent:H,expectedHookEvent:H,stdout:i.stdout,stderr:i.stderr,exitCode:i.status,durationMs:$6});if(Cd(M6)&&!M6.suppressOutput&&j6&&i.status===0){let o=`${$8.bold(J)} completed`;i0({hookId:c,hookName:J,hookEvent:H,output:i.output,stdout:i.stdout,stderr:i.stderr,exitCode:i.status,outcome:"success"}),yield{...w6,message:w6.message||V4({type:"hook_success",hookName:J,toolUseID:K,hookEvent:H,content:o,stdout:i.stdout,stderr:i.stderr,exitCode:i.status,command:t,durationMs:$6}),outcome:"success",hook:x};return}i0({hookId:c,hookName:J,hookEvent:H,output:i.output,stdout:i.stdout,stderr:i.stderr,exitCode:i.status,outcome:i.status===0?"success":"error"}),yield{...w6,outcome:"success",hook:x};return}if(i.status===0){i0({hookId:c,hookName:J,hookEvent:H,output:i.output,stdout:i.stdout,stderr:i.stderr,exitCode:i.status,outcome:"success"}),yield{message:V4({type:"hook_success",hookName:J,toolUseID:K,hookEvent:H,content:i.stdout.trim(),stdout:i.stdout,stderr:i.stderr,exitCode:i.status,command:t,durationMs:$6}),outcome:"success",hook:x};return}if(i.status===2){i0({hookId:c,hookName:J,hookEvent:H,output:i.output,stdout:i.stdout,stderr:i.stderr,exitCode:i.status,outcome:"error"}),yield{blockingError:{blockingError:`[${x.command}]: ${i.stderr||"No stderr output"}`,command:x.command},outcome:"blocking",hook:x};return}i0({hookId:c,hookName:J,hookEvent:H,output:i.output,stdout:i.stdout,stderr:i.stderr,exitCode:i.status,outcome:"error"}),yield{message:V4({type:"hook_non_blocking_error",hookName:J,toolUseID:K,hookEvent:H,stderr:`Failed with non-blocking status code: ${i.stderr.trim()||"No stderr output"}`,stdout:i.stdout,exitCode:i.status,command:t,durationMs:$6}),outcome:"non_blocking_error",hook:x};return}catch(q6){U?.();let e=q6 instanceof Error?q6.message:String(q6);i0({hookId:c,hookName:J,hookEvent:H,output:`Failed to run: ${e}`,stdout:"",stderr:`Failed to run: ${e}`,exitCode:1,outcome:"error"}),yield{message:V4({type:"hook_non_blocking_error",hookName:J,toolUseID:K,hookEvent:H,stderr:`Failed to run: ${e}`,stdout:"",exitCode:1,command:t,durationMs:Date.now()-K6}),outcome:"non_blocking_error",hook:x};return}}),E={success:0,blocking:0,non_blocking_error:0,cancelled:0},S;for await(let x of CN8(V)){if(E[x.outcome]++,x.preventContinuation)N(`Hook ${H} (${pL(x.hook)}) requested preventContinuation`),yield{preventContinuation:!0,stopReason:x.stopReason};if(x.blockingError)yield{blockingError:x.blockingError};if(x.message)yield{message:x.message};if(x.systemMessage)yield{message:V4({type:"hook_system_message",content:x.systemMessage,hookName:J,toolUseID:K,hookEvent:H})};if(x.additionalContext)N(`Hook ${H} (${pL(x.hook)}) provided additionalContext (${x.additionalContext.length} chars)`),yield{additionalContexts:[x.additionalContext]};if(x.initialUserMessage)N(`Hook ${H} (${pL(x.hook)}) provided initialUserMessage (${x.initialUserMessage.length} chars)`),yield{initialUserMessage:x.initialUserMessage};if(x.watchPaths&&x.watchPaths.length>0)N(`Hook ${H} (${pL(x.hook)}) provided ${x.watchPaths.length} watchPaths`),yield{watchPaths:x.watchPaths};if(x.updatedMCPToolOutput)N(`Hook ${H} (${pL(x.hook)}) replaced MCP tool output`),yield{updatedMCPToolOutput:x.updatedMCPToolOutput};if(x.permissionBehavior)switch(N(`Hook ${H} (${pL(x.hook)}) returned permissionDecision: ${x.permissionBehavior}${x.hookPermissionDecisionReason?` (reason: ${x.hookPermissionDecisionReason})`:""}`),x.permissionBehavior){case"deny":S="deny";break;case"ask":if(S!=="deny")S="ask";break;case"allow":if(!S)S="allow";break;case"passthrough":break}if(S!==void 0){let I=x.updatedInput&&(x.permissionBehavior==="allow"||x.permissionBehavior==="ask")?x.updatedInput:void 0;if(I)N(`Hook ${H} (${pL(x.hook)}) modified tool input keys: [${Object.keys(I).join(", ")}]`);yield{permissionBehavior:S,hookPermissionDecisionReason:x.hookPermissionDecisionReason,hookSource:W.find((B)=>B.hook===x.hook)?.hookSource,updatedInput:I}}if(x.updatedInput&&x.permissionBehavior===void 0)N(`Hook ${H} (${pL(x.hook)}) modified tool input keys: [${Object.keys(x.updatedInput).join(", ")}]`),yield{updatedInput:x.updatedInput};if(x.permissionRequestResult)yield{permissionRequestResult:x.permissionRequestResult};if(x.retry)yield{retry:x.retry};if(x.elicitationResponse)yield{elicitationResponse:x.elicitationResponse};if(x.elicitationResultResponse)yield{elicitationResultResponse:x.elicitationResultResponse};if(X&&x.hook.type!=="callback"){let I=N8(),p=Tb4(X,I,H,_??"",x.hook);if(p?.onHookSuccess&&x.outcome==="success")try{p.onHookSuccess(x.hook,x)}catch(C){H6(Error("Session hook success callback failed",{cause:C}))}}}let R=Date.now()-Z;if(d36()?.observe("hook_duration_ms",R),s58(R),d("tengu_repl_hook_finished",{hookName:J,numCommands:W.length,numSuccess:E.success,numBlocking:E.blocking,numNonBlockingError:E.non_blocking_error,numCancelled:E.cancelled,totalDurationMs:R}),bH()){let x=TgK(W);EA("hook_execution_complete",{hook_event:H,hook_name:J,num_hooks:String(W.length),num_success:String(E.success),num_blocking:String(E.blocking),num_non_blocking_error:String(E.non_blocking_error),num_cancelled:String(E.cancelled),managed_only:String(fb()),hook_definitions:g6(x),hook_source:fb()?"policySettings":"merged"})}Ug4(G,{numSuccess:E.success,numBlocking:E.blocking,numNonBlockingError:E.non_blocking_error,numCancelled:E.cancelled})}function eT6(q){return q.some((K)=>K.blocked)}async function ob({getAppState:q,hookInput:K,matchQuery:_,signal:z,timeoutMs:Y=PO}){if(i6(process.env.CLAUDE_CODE_SIMPLE))return[];let $=K.hook_event_name,A=_?`${$}:${_}`:$;if(j68())return N(`Skipping hooks for ${A} due to 'disableAllHooks' managed setting`),[];if(Qq8())return N(`Skipping ${A} hook execution - workspace trust not accepted`),[];let O=q?q():void 0,w=N8(),j=await O_7(O,w,$,K);if(j.length===0)return[];if(z?.aborted)return[];let H=j.filter((X)=>!NgK(X));if(H.length>0){let X=ygK(H),P=EgK(H);d("tengu_run_hook",{hookName:A,numCommands:H.length,hookTypeCounts:g6(P),...X&&{pluginHookCounts:g6(X)}})}let J;try{J=g6(K)}catch(X){return H6(X),[]}let M=j.map(async({hook:X,pluginRoot:P,pluginId:W},D)=>{if(X.type==="callback"){let T=X.timeout?X.timeout*1000:Y,{signal:v,cleanup:V}=Ty(z,{timeoutMs:T});try{let E=vy(),S=await X.callback(K,E,v,D);if(V?.(),rb(S))return N(`${A} [callback] returned async response, returning empty output`),{command:"callback",succeeded:!0,output:"",blocked:!1};let R=$==="WorktreeCreate"&&Cd(S)&&S.hookSpecificOutput?.hookEventName==="WorktreeCreate"?S.hookSpecificOutput.worktreePath:S.systemMessage||"",x=Cd(S)&&S.decision==="block";return N(`${A} [callback] completed successfully`),{command:"callback",succeeded:!0,output:R,blocked:x}}catch(E){V?.();let S=E instanceof Error?E.message:String(E);return N(`${A} [callback] failed to run: ${S}`,{level:"error"}),{command:"callback",succeeded:!1,output:S,blocked:!1}}}if(X.type==="prompt")return{command:X.prompt,succeeded:!1,output:"Prompt stop hooks are not yet supported outside REPL",blocked:!1};if(X.type==="agent")return{command:X.prompt,succeeded:!1,output:"Agent stop hooks are not yet supported outside REPL",blocked:!1};if(X.type==="function")return H6(Error(`Function hook reached executeHooksOutsideREPL for ${$}. Function hooks should only be used in REPL context (Stop hooks).`)),{command:"function",succeeded:!1,output:"Internal error: function hook executed outside REPL context",blocked:!1};if(X.type==="http")try{let T=await $_7(X,$,J,z);if(T.aborted)return N(`${A} [${X.url}] cancelled`),{command:X.url,succeeded:!1,output:"Hook cancelled",blocked:!1};if(T.error||!T.ok){let R=T.error||`HTTP ${T.statusCode} from ${X.url}`;return N(`${A} [${X.url}] failed: ${R}`,{level:"error"}),{command:X.url,succeeded:!1,output:R,blocked:!1}}let{json:v,validationError:V}=VgK(T.body);if(V)throw Error(V);if(v&&!rb(v))N(`Parsed JSON output from HTTP hook: ${g6(v)}`,{level:"verbose"});let E=v&&!rb(v)&&Cd(v)&&v.decision==="block",S=$==="WorktreeCreate"?v&&Cd(v)&&v.hookSpecificOutput?.hookEventName==="WorktreeCreate"?v.hookSpecificOutput.worktreePath:"":T.body;return{command:X.url,succeeded:!0,output:S,blocked:!!E}}catch(T){let v=T instanceof Error?T.message:String(T);return N(`${A} [${X.url}] failed to run: ${v}`,{level:"error"}),{command:X.url,succeeded:!1,output:v,blocked:!1}}let f=X.timeout?X.timeout*1000:Y,{signal:G,cleanup:Z}=Ty(z,{timeoutMs:f});try{let T=await hQ8(X,$,A,J,G,vy(),D,P,W);if(Z?.(),T.aborted)return N(`${A} [${X.command}] cancelled`),{command:X.command,succeeded:!1,output:"Hook cancelled",blocked:!1};N(`${A} [${X.command}] completed with status ${T.status}`);let{json:v,validationError:V}=kgK(T.stdout);if(V)throw Error(V);if(v&&!rb(v))N(`Parsed JSON output from hook: ${g6(v)}`,{level:"verbose"});let E=v&&!rb(v)&&Cd(v)&&v.decision==="block",S=T.status===2||!!E,R=T.status===0?T.stdout||"":T.stderr||"",x=v&&Cd(v)&&v.hookSpecificOutput&&"watchPaths"in v.hookSpecificOutput?v.hookSpecificOutput.watchPaths:void 0,I=v&&Cd(v)?v.systemMessage:void 0;return{command:X.command,succeeded:T.status===0,output:R,blocked:S,watchPaths:x,systemMessage:I}}catch(T){Z?.();let v=T instanceof Error?T.message:String(T);return N(`${A} [${X.command}] failed to run: ${v}`,{level:"error"}),{command:X.command,succeeded:!1,output:v,blocked:!1}}});return await Promise.all(M)}async function*Y87(q,K,_,z,Y,$,A=PO,O,w){let j=z.getAppState(),H=z.agentId??N8();if(!iS6("PreToolUse",j,H))return;N(`executePreToolHooks called for tool: ${q}`,{level:"verbose"});let J={...C$(Y,void 0,z),hook_event_name:"PreToolUse",tool_name:q,tool_input:_,tool_use_id:K};yield*GR({hookInput:J,toolUseID:K,matchQuery:q,signal:$,timeoutMs:A,toolUseContext:z,requestPrompt:O,toolInputSummary:w})}async function*$87(q,K,_,z,Y,$,A,O=PO){let w={...C$($,void 0,Y),hook_event_name:"PostToolUse",tool_name:q,tool_input:_,tool_response:z,tool_use_id:K};yield*GR({hookInput:w,toolUseID:K,matchQuery:q,signal:A,timeoutMs:O,toolUseContext:Y})}async function*A87(q,K,_,z,Y,$,A,O,w=PO){let j=Y.getAppState(),H=Y.agentId??N8();if(!iS6("PostToolUseFailure",j,H))return;let J={...C$(A,void 0,Y),hook_event_name:"PostToolUseFailure",tool_name:q,tool_input:_,tool_use_id:K,error:z,is_interrupt:$};yield*GR({hookInput:J,toolUseID:K,matchQuery:q,signal:O,timeoutMs:w,toolUseContext:Y})}async function*j87(q,K,_,z,Y,$,A,O=PO){let w=Y.getAppState(),j=Y.agentId??N8();if(!iS6("PermissionDenied",w,j))return;let H={...C$($,void 0,Y),hook_event_name:"PermissionDenied",tool_name:q,tool_input:_,tool_use_id:K,reason:z};yield*GR({hookInput:H,toolUseID:K,matchQuery:q,signal:A,timeoutMs:O,toolUseContext:Y})}async function bU(q,K=PO){let{message:_,title:z,notificationType:Y}=q,$={...C$(void 0),hook_event_name:"Notification",message:_,title:z,notification_type:Y};await ob({hookInput:$,timeoutMs:K,matchQuery:Y})}async function kp8(q,K,_=PO){let z=K?.getAppState(),Y=N8();if(!iS6("StopFailure",z,Y))return;let $=L3(q.message.content,`
7728`).trim()||void 0,A=q.error??"unknown",O={...C$(void 0,void 0,K),hook_event_name:"StopFailure",error:A,error_details:q.errorDetails,last_assistant_message:$};await ob({getAppState:K?.getAppState,hookInput:O,timeoutMs:_,matchQuery:A})}async function*v87(q,K,_=PO,z=!1,Y,$,A,O,w){let j=Y?"SubagentStop":"Stop",H=$?.getAppState(),J=$?.agentId??N8();if(!iS6(j,H,J))return;let M=A?uP(A):void 0,X=M?L3(M.message.content,`
7729`).trim()||void 0:void 0,P=Y?{...C$(q),hook_event_name:"SubagentStop",stop_hook_active:z,agent_id:Y,agent_transcript_path:c0(Y),agent_type:O??"",last_assistant_message:X}:{...C$(q),hook_event_name:"Stop",stop_hook_active:z,last_assistant_message:X};yield*GR({hookInput:P,toolUseID:vy(),signal:K,timeoutMs:_,toolUseContext:$,messages:A,requestPrompt:w})}async function*k87(q,K,_,z,Y=PO){let $={...C$(_),hook_event_name:"TeammateIdle",teammate_name:q,team_name:K};yield*GR({hookInput:$,toolUseID:vy(),signal:z,timeoutMs:Y})}async function*$67(q,K,_,z,Y,$,A,O=PO,w){let j={...C$($),hook_event_name:"TaskCreated",task_id:q,task_subject:K,task_description:_,teammate_name:z,team_name:Y};yield*GR({hookInput:j,toolUseID:vy(),signal:A,timeoutMs:O,toolUseContext:w})}async function*B88(q,K,_,z,Y,$,A,O=PO,w){let j={...C$($),hook_event_name:"TaskCompleted",task_id:q,task_subject:K,task_description:_,teammate_name:z,team_name:Y};yield*GR({hookInput:j,toolUseID:vy(),signal:A,timeoutMs:O,toolUseContext:w})}async function*j_7(q,K,_,z){let Y=_.getAppState(),$=_.agentId??N8();if(!iS6("UserPromptSubmit",Y,$))return;let A={...C$(K),hook_event_name:"UserPromptSubmit",prompt:q};yield*GR({hookInput:A,toolUseID:vy(),signal:_.abortController.signal,timeoutMs:PO,toolUseContext:_,requestPrompt:z})}async function*Jo1(q,K,_,z,Y,$=PO,A){let O={...C$(void 0,K),hook_event_name:"SessionStart",source:q,agent_type:_,model:z};yield*GR({hookInput:O,toolUseID:vy(),matchQuery:q,signal:Y,timeoutMs:$,forceSyncExecution:A})}async function*Mo1(q,K,_=PO,z){let Y={...C$(void 0),hook_event_name:"Setup",trigger:q};yield*GR({hookInput:Y,toolUseID:vy(),matchQuery:q,signal:K,timeoutMs:_,forceSyncExecution:z})}async function*gr1(q,K,_,z=PO){let Y={...C$(void 0),hook_event_name:"SubagentStart",agent_id:q,agent_type:K};yield*GR({hookInput:Y,toolUseID:vy(),matchQuery:K,signal:_,timeoutMs:z})}async function qh6(q,K,_=PO){let z={...C$(void 0),hook_event_name:"PreCompact",trigger:q.trigger,custom_instructions:q.customInstructions},Y=await ob({hookInput:z,matchQuery:q.trigger,signal:K,timeoutMs:_});if(Y.length===0)return{};let $=Y.filter((O)=>O.succeeded&&O.output.trim().length>0).map((O)=>O.output.trim()),A=[];for(let O of Y)if(O.succeeded)if(O.output.trim())A.push(`PreCompact [${O.command}] completed successfully: ${O.output.trim()}`);else A.push(`PreCompact [${O.command}] completed successfully`);else if(O.output.trim())A.push(`PreCompact [${O.command}] failed: ${O.output.trim()}`);else A.push(`PreCompact [${O.command}] failed`);return{newCustomInstructions:$.length>0?$.join(`
7730
7731`):void 0,userDisplayMessage:A.length>0?A.join(`

Callers 1

vWKFunction · 0.85

Calls 2

C$Function · 0.85
GRFunction · 0.85

Tested by

no test coverage detected