| 7694 | `)}if(d("tengu_memdir_disabled",{disabled_by_env_var:i6(process.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY),disabled_by_setting:!i6(process.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY)&&N7().autoMemoryEnabled===!1}),g8("tengu_herring_clock",!1))d("tengu_team_memdir_disabled",{});return null}var mBK,oP="MEMORY.md",nK6=200,gq8=25000,$hY="auto memory",AhY,D87="This directory already exists — write to it directly with the Write tool (do not run mkdir or check for its existence).",uBK="Both directories already exist — write to them directly with the Write tool (do not run mkdir or check for their existence).";var n76=y(()=>{e7();rw();v8();o1();k8();qM();k16();_8();ju();m8();U7();_K();U1();j18();mBK=(YL(),Eq(Pi));AhY=(IBK(),Eq(xBK))});import{join as ys,normalize as OhY,sep as Rd}from"path";function whY(q){return q.replace(/:/g,"-")}function gBK(q){if(process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR)return ys(process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR,"projects",JP(jH(Fz())??Fz()),"agent-memory-local",q)+Rd;return ys(Z8(),".claude","agent-memory-local",q)+Rd}function Nk6(q,K){let _=whY(q);switch(K){case"project":return ys(Z8(),".claude","agent-memory",_)+Rd;case"local":return gBK(_);case"user":return ys(D16(),"agent-memory",_)+Rd}}function i88(q){let K=OhY(q),_=D16();if(K.startsWith(ys(_,"agent-memory")+Rd))return!0;if(K.startsWith(ys(Z8(),".claude","agent-memory")+Rd))return!0;if(process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR){if(K.includes(Rd+"agent-memory-local"+Rd)&&K.startsWith(ys(process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR,"projects")+Rd))return!0}else if(K.startsWith(ys(Z8(),".claude","agent-memory-local")+Rd))return!0;return!1}function IU8(q){switch(q){case"user":return`User (${ys(D16(),"agent-memory")}/)`;case"project":return"Project (.claude/agent-memory/)";case"local":return`Local (${gBK("...")})`;default:return"None"}}function kO6(q,K){let _;switch(K){case"user":_="- Since this memory is user-scope, keep learnings general since they apply across all projects";break;case"project":_="- Since this memory is project-scope and shared with your team via version control, tailor your memories to this project";break;case"local":_="- Since this memory is local-scope (not checked into version control), tailor your memories to this project and machine";break}let z=Nk6(q,K);ZQ8(z);let Y=process.env.CLAUDE_COWORK_MEMORY_EXTRA_GUIDELINES;return BBK({displayName:"Persistent Agent Memory",memoryDir:z,extraGuidelines:Y&&Y.trim().length>0?[_,Y]:[_]})}var pu=y(()=>{v8();n76();rw();I7();E5();dz()});import{randomBytes as jhY}from"crypto";import{homedir as UBK,tmpdir as HhY}from"os";import{join as Wk,normalize as cS6,posix as l56,sep as JZ}from"path";function oD(q){return q.toLowerCase()}function XhY(q){let K=lq(q),_=oD(K),z=[{dir:lq(Wk(r1(),".claude","skills")),prefix:"/.claude/skills/"},{dir:lq(Wk(UBK(),".claude","skills")),prefix:"~/.claude/skills/"}];for(let{dir:Y,prefix:$}of z){let A=oD(Y);for(let O of[JZ,"/"])if(_.startsWith(A+O.toLowerCase())){let w=K.slice(Y.length+O.length),j=w.indexOf("/"),H=JZ==="\\"?w.indexOf("\\"):-1,J=j===-1?H:H===-1?j:Math.min(j,H);if(J<=0)return null;let M=w.slice(0,J);if(!M||M==="."||M.includes(".."))return null;if(/[*?[\]]/.test(M))return null;return{skillName:M,pattern:$+M+"/**"}}}return null}function s97(q,K){if(Z1()==="windows"){let _=ff(q),z=ff(K);return l56.relative(_,z)}return l56.relative(q,K)}function MN4(q){if(Z1()==="windows")return ff(q);return q}function PhY(){return cT.map((q)=>Hj(q)).filter((q)=>q!==void 0)}function Hs1(q){let K=lq(q),_=oD(K);if(_.endsWith(`${JZ}.claude${JZ}settings.json`)||_.endsWith(`${JZ}.claude${JZ}settings.local.json`))return!0;return PhY().some((z)=>oD(z)===_)}function WhY(q){if(Hs1(q))return!0;let K=Wk(r1(),".claude","commands"),_=Wk(r1(),".claude","agents"),z=Wk(r1(),".claude","skills");return cV(q,K)||cV(q,_)||cV(q,z)}function QBK(q){let K=Wk(hA(),CQ()),_=cS6(q);return _.startsWith(K)&&_.endsWith(".md")}function TQ8(){return Wk(_2(Z8()),N8(),"session-memory")+JZ}function Fk6(){return Wk(TQ8(),"summary.md")}function DhY(q){return cS6(q).startsWith(TQ8())}function fhY(q){let K=_2(Z8()),_=cS6(q);return _===K||_.startsWith(K+JZ)}function Sd(){return tY("tengu_scratch")}function Na1(){if(Z1()==="windows")return"claude";return`claude-${process.getuid?.()??0}`}function vQ8(){return Wk(AC(),JP(r1()))+JZ}function n56(){return Wk(vQ8(),N8(),"scratchpad")}async function dBK(){if(!Sd())throw Error("Scratchpad directory feature is not enabled");let q=X8(),K=n56();return await q.mkdir(K,{mode:448}),K}function cBK(q){if(!Sd())return!1;let K=n56(),_=cS6(q);return _===K||_.startsWith(K+JZ)}function ZhY(q){let _=lq(q).split(JZ),z=_.at(-1);if(q.startsWith("\\\\")||q.startsWith("//"))return!0;for(let Y=0;Y<_.length;Y++){let $=_[Y],A=oD($);for(let O of MhY){if(A!==oD(O))continue;if(O===".claude"){let w=_[Y+1];if(w&&oD(w)==="worktrees")break}return!0}}if(z){let Y=oD(z);if(JhY.some(($)=>oD($)===Y))return!0}return!1}function lBK(q){if(Z1()==="windows"||Z1()==="wsl"){if(q.indexOf(":",2)!==-1)return!0}if(/~\d/.test(q))return!0;if(q.startsWith("\\\\?\\")||q.startsWith("\\\\.\\")||q.startsWith("//?/")||q.startsWith("//./"))return!0;if(/[.\s]+$/.test(q))return!0;if(/\.(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(q))return!0;if(/(^|\/|\\)\.{3,}(\/|\\|$)/.test(q))return!0;if(SF(q))return!0;return!1}function In6(q,K){let _=K??hx(q);for(let z of _)if(lBK(z))return{safe:!1,message:`Claude requested permissions to write to ${q}, which contains a suspicious Windows path pattern that requires manual approval.`,classifierApprovable:!1};for(let z of _)if(WhY(z))return{safe:!1,message:`Claude requested permissions to write to ${q}, but you haven't granted it yet.`,classifierApprovable:!0};for(let z of _)if(ZhY(z))return{safe:!1,message:`Claude requested permissions to edit ${q} which is a sensitive file.`,classifierApprovable:!0};return{safe:!0}}function ku(q){return new Set([r1(),...q.additionalWorkingDirectories.keys()])}function XL(q,K,_){let z=_??hx(q),Y=Array.from(ku(K)).flatMap(($)=>GhY($));return z.every(($)=>Y.some((A)=>cV($,A)))}function cV(q,K){let _=lq(q),z=lq(K),Y=_.replace(/^\/private\/var\//,"/var/").replace(/^\/private\/tmp(\/|$)/,"/tmp$1"),$=z.replace(/^\/private\/var\//,"/var/").replace(/^\/private\/tmp(\/|$)/,"/tmp$1"),A=oD(Y),O=oD($),w=s97(O,A);if(w==="")return!0;if(yB(w))return!1;return!l56.isAbsolute(w)}function ThY(q){switch(q){case"cliArg":case"command":case"session":return lq(r1());case"userSettings":case"policySettings":case"projectSettings":case"localSettings":case"flagSettings":return V_6(q)}}function a97(q){return l56.join(hd,q)}function vhY({patternRoot:q,pattern:K,rootPath:_}){let z=l56.join(q,K);if(q===_)return a97(K);else if(z.startsWith(`${_}${hd}`)){let Y=z.slice(_.length);return a97(Y)}else{let Y=l56.relative(_,q);if(!Y||Y.startsWith(`..${hd}`)||Y==="..")return null;else{let $=l56.join(Y,K);return a97($)}}}function oL6(q,K){let _=new Set(q.get(null)??[]);for(let[z,Y]of q.entries()){if(z===null)continue;for(let $ of Y){let A=vhY({patternRoot:z,pattern:$,rootPath:K});if(A)_.add(A)}}return Array.from(_)}function aL6(q){let K=nBK(q,"read","deny"),_=new Map;for(let[z,Y]of K.entries())_.set(z,Array.from(Y.keys()));return _}function khY(q,K){if(q.startsWith(`${hd}${hd}`)){let z=q.slice(1);if(Z1()==="windows"&&z.match(/^\/[a-z]\//i)){let Y=z[1]?.toUpperCase()??"C",$=z.slice(2),A=`${Y}:\\`;return{relativePattern:$.startsWith("/")?$.slice(1):$,root:A}}return{relativePattern:z,root:hd}}else if(q.startsWith(`~${hd}`))return{relativePattern:q.slice(1),root:UBK().normalize("NFC")};else if(q.startsWith(hd))return{relativePattern:q,root:ThY(K)};let _=q;if(q.startsWith(`.${hd}`))_=q.slice(2);return{relativePattern:_,root:null}}function nBK(q,K,_){let z=(()=>{switch(K){case"edit":return X4;case"read":return Cq}})(),Y=uj6(q,z,_),$=new Map;for(let[A,O]of Y.entries()){let{relativePattern:w,root:j}=khY(A,O.source),H=$.get(j);if(H===void 0)H=new Map,$.set(j,H);H.set(w,O)}return $}function VH(q,K,_,z){let Y=lq(q);if(Z1()==="windows"&&Y.includes("\\"))Y=ff(Y);let $=nBK(K,_,z);for(let[A,O]of $.entries()){let w=Array.from(O.keys()).map((M)=>{let X=M;if(X.endsWith("/**"))X=X.slice(0,-3);return X}),j=FBK.default().add(w),H=s97(A??Z8(),Y??Z8());if(H.startsWith(`..${hd}`))continue;if(!H)continue;let J=j.test(H);if(J.ignored&&J.rule){let M=J.rule.pattern,X=M+"/**";if(O.has(X))return O.get(X)??null;return O.get(M)??null}}return null}function RK6(q,K,_){if(typeof q.getPath!=="function")return{behavior:"ask",message:`Claude requested permissions to use ${q.name}, but you haven't granted it yet.`};let z=q.getPath(K),Y=hx(z);for(let H of Y)if(H.startsWith("\\\\")||H.startsWith("//"))return{behavior:"ask",message:`Claude requested permissions to read from ${z}, which appears to be a UNC path that could access network resources.`,decisionReason:{type:"other",reason:"UNC path detected (defense-in-depth check)"}};for(let H of Y)if(lBK(H))return{behavior:"ask",message:`Claude requested permissions to read from ${z}, which contains a suspicious Windows path pattern that requires manual approval.`,decisionReason:{type:"other",reason:"Path contains suspicious Windows-specific patterns (alternate data streams, short names, long path prefixes, or three or more consecutive dots) that require manual verification"}};for(let H of Y){let J=VH(H,_,"read","deny");if(J)return{behavior:"deny",message:`Permission to read ${z} has been denied.`,decisionReason:{type:"rule",rule:J}}}for(let H of Y){let J=VH(H,_,"read","ask");if(J)return{behavior:"ask",message:`Claude requested permissions to read from ${z}, but you haven't granted it yet.`,decisionReason:{type:"rule",rule:J}}}let $=Qj6(q,K,_,Y);if($.behavior==="allow")return $;if(XL(z,_,Y))return{behavior:"allow",updatedInput:K,decisionReason:{type:"mode",mode:"default"}};let O=lq(z),w=mn6(O,K);if(w.behavior!=="passthrough")return w;let j=VH(z,_,"read","allow");if(j)return{behavior:"allow",updatedInput:K,decisionReason:{type:"rule",rule:j}};return{behavior:"ask",message:`Claude requested permissions to read from ${z}, but you haven't granted it yet.`,suggestions:Fq8(z,"read",_,Y),decisionReason:{type:"workingDir",reason:"Path is outside allowed working directories"}}}function Qj6(q,K,_,z){if(typeof q.getPath!=="function")return{behavior:"ask",message:`Claude requested permissions to use ${q.name}, but you haven't granted it yet.`};let Y=q.getPath(K),$=z??hx(Y);for(let M of $){let X=VH(M,_,"edit","deny");if(X)return{behavior:"deny",message:`Permission to edit ${Y} has been denied.`,decisionReason:{type:"rule",rule:X}}}let A=lq(Y),O=un6(A,K);if(O.behavior!=="passthrough")return O;let w=VH(Y,{..._,alwaysAllowRules:{session:_.alwaysAllowRules.session??[]}},"edit","allow");if(w){let M=w.ruleValue.ruleContent;if(M&&(M.startsWith(Uf8.slice(0,-2))||M.startsWith(Qf8.slice(0,-2)))&&!M.includes("..")&&M.endsWith("/**"))return{behavior:"allow",updatedInput:K,decisionReason:{type:"rule",rule:w}}}let j=In6(Y,$);if(!j.safe){let M=XhY(Y),X=M?[{type:"addRules",rules:[{toolName:X4,ruleContent:M.pattern}],behavior:"allow",destination:"session"}]:Fq8(Y,"write",_,$);return{behavior:"ask",message:j.message,suggestions:X,decisionReason:{type:"safetyCheck",reason:j.message,classifierApprovable:j.classifierApprovable}}}for(let M of $){let X=VH(M,_,"edit","ask");if(X)return{behavior:"ask",message:`Claude requested permissions to write to ${Y}, but you haven't granted it yet.`,decisionReason:{type:"rule",rule:X}}}let H=XL(Y,_,$);if(_.mode==="acceptEdits"&&H)return{behavior:"allow",updatedInput:K,decisionReason:{type:"mode",mode:_.mode}};let J=VH(Y,_,"edit","allow");if(J)return{behavior:"allow",updatedInput:K,decisionReason:{type:"rule",rule:J}};return{behavior:"ask",message:`Claude requested permissions to write to ${Y}, but you haven't granted it yet.`,suggestions:Fq8(Y,"write",_,$),decisionReason:!H?{type:"workingDir",reason:"Path is outside allowed working directories"}:void 0}}function Fq8(q,K,_,z){let Y=!XL(q,_,z);if(K==="read"&&Y){let A=IZ(q);return hx(A).map((j)=>Kw6(j,"session")).filter((j)=>j!==void 0)}let $=_.mode==="default"||_.mode==="plan";if(K==="write"||K==="create"){let A=$?[{type:"setMode",mode:"acceptEdits",destination:"session"}]:[];if(Y){let O=IZ(q),w=hx(O);A.push({type:"addDirectories",directories:w,destination:"session"})}return A}return $?[{type:"setMode",mode:"acceptEdits",destination:"session"}]:[]}function un6(q,K){let _=cS6(q);if(QBK(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Plan files for current session are allowed for writing"}};if(cBK(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Scratchpad files for current session are allowed for writing"}};if(i88(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Agent memory files are allowed for writing"}};if(!Gf8()&&f16(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"auto memory files are allowed for writing"}};if(oD(_)===oD(Wk(r1(),".claude","launch.json")))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Preview launch config is allowed for writing"}};return{behavior:"passthrough",message:""}}function mn6(q,K){let _=cS6(q);if(DhY(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Session memory files are allowed for reading"}};if(fhY(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Project directory files are allowed for reading"}};if(QBK(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Plan files for current session are allowed for reading"}};let z=Bq6(),Y=z.endsWith(JZ)?z:z+JZ;if(_===z||_.startsWith(Y))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Tool result files are allowed for reading"}};if(cBK(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Scratchpad files for current session are allowed for reading"}};let $=vQ8();if(_.startsWith($))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Project temp directory files are allowed for reading"}};if(i88(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Agent memory files are allowed for reading"}};if(f16(_))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"auto memory files are allowed for reading"}};let A=Wk(c1(),"tasks")+JZ;if(_===A.slice(0,-1)||_.startsWith(A))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Task files are allowed for reading"}};let O=Wk(c1(),"teams")+JZ;if(_===O.slice(0,-1)||_.startsWith(O))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Team files are allowed for reading"}};let w=o37()+JZ;if(_.startsWith(w))return{behavior:"allow",updatedInput:K,decisionReason:{type:"other",reason:"Bundled skill reference files are allowed for reading"}};return{behavior:"passthrough",message:""}}var FBK,JhY,MhY,hd,AC,o37,GhY;var Tz=y(()=>{F4();rw();pu();v8();o1();IY();I7();m8();e7();dz();SJ();vK();_K();kO();U1();Vv6();IG();NB();LH();Fj();FBK=O6(n$6(),1),JhY=[".gitconfig",".gitmodules",".bashrc",".bash_profile",".zshrc",".zprofile",".profile",".ripgreprc",".mcp.json",".claude.json"],MhY=[".git",".vscode",".idea",".claude"];hd=l56.sep;AC=_1(function(){let K=process.env.CLAUDE_CODE_TMPDIR||(Z1()==="windows"?HhY():"/tmp"),_=X8(),z=K;try{z=_.realpathSync(K)}catch{}return Wk(z,Na1())+JZ}),o37=_1(function(){let K=jhY(16).toString("hex");return Wk(AC(),"bundled-skills",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://code.claude.com/docs/en/overview",VERSION:"2.1.88",FEEDBACK_CHANNEL:"https://github.com/anthropics/claude-code/issues",BUILD_TIME:"2026-03-30T21:59:52Z"}.VERSION,K)});GhY=_1(hx)});import{constants as VJ6}from"fs";import{mkdir as VhY,open as oBK,stat as nl2,symlink as iBK,unlink as NhY}from"fs/promises";import{join as aBK}from"path";function vL6(){if(t97===void 0)t97=aBK(vQ8(),N8(),"tasks");return t97}async function q_7(){await VhY(vL6(),{recursive:!0})}function sz(q){return aBK(vL6(),`${q}.output`)}function NQ8(q){return rBK.add(q),q.finally(()=>rBK.delete(q)).catch(()=>{}),q}class jI8{#q;#K=null;#_=[];#Y=0;#z=!1;#O=null;#$=null;constructor(q){this.#q=sz(q)}append(q){if(this.#z)return;if(this.#Y+=q.length,this.#Y>VQ8)this.#z=!0,this.#_.push(` |
| 7697 | ${_}`;return _}catch(_){if(s1(_)==="ENOENT")return"";return H6(_),""}}function px8(q){return NQ8((async()=>{await q_7();let K=sz(q);return await(await oBK(K,process.platform==="win32"?"wx":VJ6.O_WRONLY|VJ6.O_CREAT|VJ6.O_EXCL|sBK)).close(),K})())}function zH6(q,K){return NQ8((async()=>{try{await q_7();let _=sz(q);try{await iBK(K,_)}catch{await NhY(_),await iBK(K,_)}return _}catch(_){return H6(_),px8(q)}})())}var sBK,tBK=8388608,VQ8=5368709120,e97="5GB",t97,rBK,kQ8;var Ij=y(()=>{v8();y8();e7();E8();Tz();sBK=VJ6.O_NOFOLLOW??0;rBK=new Set;kQ8=new Map});import{randomBytes as EhY}from"crypto";function mr(q){return q==="completed"||q==="failed"||q==="killed"}function RhY(q){return LhY[q]??"x"}function aL(q){let K=RhY(q),_=EhY(8),z=K;for(let Y=0;Y<8;Y++)z+=eBK[_[Y]%eBK.length];return z}function C0(q,K,_,z){return{id:q,type:K,status:"pending",description:_,toolUseId:z,startTime:Date.now(),outputFile:sz(q),outputOffset:0,notified:!1}}var LhY,eBK="0123456789abcdefghijklmnopqrstuvwxyz";var GN=y(()=>{Ij();LhY={local_bash:"b",local_agent:"a",remote_agent:"r",in_process_teammate:"t",local_workflow:"w",monitor_mcp:"m",dream:"d"}});import{stat as hhY}from"fs/promises";function KgK(q,K){return K?`${q} ${K}`:q}class __7{#q;#K=!1;#_;#Y;#z=this.#O.bind(this);constructor(q,K,_){this.#q=q,this.#_=K,this.#Y=_,q.setEncoding("utf-8"),q.on("data",this.#z)}#O(q){let K=typeof q==="string"?q:q.toString();if(this.#Y)this.#_.writeStderr(K);else this.#_.writeStdout(K)}cleanup(){if(this.#K)return;this.#K=!0,this.#q.removeListener("data",this.#z),this.#q=null,this.#_=null,this.#z=()=>{}}}class z_7{#q="running";#K;#_;#Y;#z;#O=null;#$=null;#w=!1;#H;#j;#A;#M;#D;#P=null;#J=null;#f=null;taskOutput;static#W(q){if(q.#D&&q.#A)q.#A(q.background.bind(q));else q.#S(qgK)}result;onTimeout;constructor(q,K,_,z,Y=!1,$=VQ8){if(this.#z=q,this.#j=K,this.#M=_,this.#D=Y,this.#H=$,this.taskOutput=z,this.#Y=q.stderr?new __7(q.stderr,z,!0):null,this.#_=q.stdout?new __7(q.stdout,z,!1):null,Y)this.onTimeout=(A)=>{this.#A=A};this.result=this.#h()}get status(){return this.#q}#G(){if(this.#j.reason==="interrupt")return;this.kill()}#k(q,K){let _=q!==null&&q!==void 0?q:K==="SIGTERM"?144:1;this.#v(_)}#T(){this.#v(1)}#v(q){if(this.#J)this.#J(q),this.#J=null}#N(){this.#Z();let q=this.#O;if(q)clearTimeout(q),this.#O=null;let K=this.#f;if(K)this.#j.removeEventListener("abort",K),this.#f=null}#Z(){if(this.#$)clearInterval(this.#$),this.#$=null}#C(){this.#$=setInterval(()=>{hhY(this.taskOutput.path).then((q)=>{if(q.size>this.#H&&this.#q==="backgrounded"&&this.#$!==null)this.#w=!0,this.#Z(),this.#S(K_7)},()=>{})},ShY),this.#$.unref()}#h(){this.#f=this.#G.bind(this),this.#j.addEventListener("abort",this.#f,{once:!0}),this.#z.once("exit",this.#k.bind(this)),this.#z.once("error",this.#T.bind(this)),this.#O=setTimeout(z_7.#W,this.#M,this);let q=new Promise((K)=>{this.#J=K});return new Promise((K)=>{this.#P=K,q.then(this.#y.bind(this))})}async#y(q){if(this.#N(),this.#q==="running"||this.#q==="backgrounded")this.#q="completed";let K=await this.taskOutput.getStdout(),_={code:q,stdout:K,stderr:this.taskOutput.getStderr(),interrupted:q===K_7,backgroundTaskId:this.#K};if(this.taskOutput.stdoutToFile&&!this.#K)if(this.taskOutput.outputFileRedundant)this.taskOutput.deleteOutputFile();else _.outputFilePath=this.taskOutput.path,_.outputFileSize=this.taskOutput.outputFileSize,_.outputTaskId=this.taskOutput.taskId;if(this.#w)_.stderr=KgK(`Background command killed: output file exceeded ${e97}`,_.stderr);else if(q===qgK)_.stderr=KgK(`Command timed out after ${I5(this.#M)}`,_.stderr);let z=this.#P;if(z)this.#P=null,z(_)}#S(q){if(this.#q="killed",this.#z.pid)_gK.default(this.#z.pid,"SIGKILL");this.#v(q??K_7)}kill(){this.#S()}background(q){if(this.#q==="running"){if(this.#K=q,this.#q="backgrounded",this.#N(),this.taskOutput.stdoutToFile)this.#C();else this.taskOutput.spillToDisk();return!0}return!1}cleanup(){this.#_?.cleanup(),this.#Y?.cleanup(),this.taskOutput.clear(),this.#N(),this.#z=null,this.#j=null,this.#A=void 0}}function WI8(q,K,_,z,Y=!1,$=VQ8){return new z_7(q,K,_,z,Y,$)}class zgK{status="killed";result;taskOutput;constructor(q){this.taskOutput=new JO(aL("local_bash"),null),this.result=Promise.resolve({code:q?.code??145,stdout:"",stderr:q?.stderr??"Command aborted before execution",interrupted:!0,backgroundTaskId:q?.backgroundTaskId})}background(){return!1}kill(){}cleanup(){}}function Va1(q,K){return new zgK({backgroundTaskId:q,...K})}function ZzK(q){let K=new JO(aL("local_bash"),null);return{status:"completed",result:Promise.resolve({code:1,stdout:"",stderr:q,interrupted:!1,preSpawnError:q}),taskOutput:K,background(){return!1},kill(){},cleanup(){}}}var _gK,K_7=137,qgK=143,ShY=5000;var ya1=y(()=>{GN();U7();Ij();ZL6();_gK=O6(foq(),1)});function Cd(q){return!(("async"in q)&&q.async===!0)}function rb(q){return"async"in q&&q.async===!0}var YgK,ChY,lS6;var Y_7=y(()=>{x7();_D6();Wi1();dC8();YgK=B6(()=>L.object({prompt:L.string(),message:L.string(),options:L.array(L.object({key:L.string(),label:L.string(),description:L.string().optional()}))})),ChY=B6(()=>L.object({continue:L.boolean().describe("Whether Claude should continue after hook (default: true)").optional(),suppressOutput:L.boolean().describe("Hide stdout from transcript (default: false)").optional(),stopReason:L.string().describe("Message shown when continue is false").optional(),decision:L.enum(["approve","block"]).optional(),reason:L.string().describe("Explanation for the decision").optional(),systemMessage:L.string().describe("Warning message shown to the user").optional(),hookSpecificOutput:L.union([L.object({hookEventName:L.literal("PreToolUse"),permissionDecision:ZE6().optional(),permissionDecisionReason:L.string().optional(),updatedInput:L.record(L.string(),L.unknown()).optional(),additionalContext:L.string().optional()}),L.object({hookEventName:L.literal("UserPromptSubmit"),additionalContext:L.string().optional()}),L.object({hookEventName:L.literal("SessionStart"),additionalContext:L.string().optional(),initialUserMessage:L.string().optional(),watchPaths:L.array(L.string()).describe("Absolute paths to watch for FileChanged hooks").optional()}),L.object({hookEventName:L.literal("Setup"),additionalContext:L.string().optional()}),L.object({hookEventName:L.literal("SubagentStart"),additionalContext:L.string().optional()}),L.object({hookEventName:L.literal("PostToolUse"),additionalContext:L.string().optional(),updatedMCPToolOutput:L.unknown().describe("Updates the output for MCP tools").optional()}),L.object({hookEventName:L.literal("PostToolUseFailure"),additionalContext:L.string().optional()}),L.object({hookEventName:L.literal("PermissionDenied"),retry:L.boolean().optional()}),L.object({hookEventName:L.literal("Notification"),additionalContext:L.string().optional()}),L.object({hookEventName:L.literal("PermissionRequest"),decision:L.union([L.object({behavior:L.literal("allow"),updatedInput:L.record(L.string(),L.unknown()).optional(),updatedPermissions:L.array(TE6()).optional()}),L.object({behavior:L.literal("deny"),message:L.string().optional(),interrupt:L.boolean().optional()})])}),L.object({hookEventName:L.literal("Elicitation"),action:L.enum(["accept","decline","cancel"]).optional(),content:L.record(L.string(),L.unknown()).optional()}),L.object({hookEventName:L.literal("ElicitationResult"),action:L.enum(["accept","decline","cancel"]).optional(),content:L.record(L.string(),L.unknown()).optional()}),L.object({hookEventName:L.literal("CwdChanged"),watchPaths:L.array(L.string()).describe("Absolute paths to watch for FileChanged hooks").optional()}),L.object({hookEventName:L.literal("FileChanged"),watchPaths:L.array(L.string()).describe("Absolute paths to watch for FileChanged hooks").optional()}),L.object({hookEventName:L.literal("WorktreeCreate"),worktreePath:L.string()})]).optional()})),lS6=B6(()=>{let q=L.object({async:L.literal(!0),asyncTimeout:L.number().optional()});return L.union([q,ChY()])})});function Ty(q,K){let{signalB:_,timeoutMs:z}=K??{},Y=P3();if(q?.aborted||_?.aborted)return Y.abort(),{signal:Y.signal,cleanup:()=>{}};let $,A=()=>{if($!==void 0)clearTimeout($);Y.abort()};if(z!==void 0)$=setTimeout(A,z),$.unref?.();q?.addEventListener("abort",A),_?.addEventListener("abort",A);let O=()=>{if($!==void 0)clearTimeout($);q?.removeEventListener("abort",A),_?.removeEventListener("abort",A)};return{signal:Y.signal,cleanup:O}}var nS6=y(()=>{B2()});function yQ8(q,K){return DL6(q,K)}function $gK(){return{...$p1,inputSchema:Uq8(),inputJSONSchema:{type:"object",properties:{ok:{type:"boolean",description:"Whether the condition was met"},reason:{type:"string",description:"Reason, if the condition was not met"}},required:["ok"],additionalProperties:!1},async prompt(){return"Use this tool to return your verification result. You MUST call this tool exactly once at the end of your response."}}}function EQ8(q,K){ML8(q,K,"Stop","",(_)=>qZK(_,MD),`You MUST call the ${MD} tool to complete this request. Call this tool now.`,{timeout:5000})}var Uq8;var LQ8=y(()=>{x7();GU();S68();i1();zo();Uq8=B6(()=>L.object({ok:L.boolean().describe("Whether the condition was met"),reason:L.string().describe("Reason, if the condition was not met").optional()}))});import{randomUUID as bhY}from"crypto";async function AgK(q,K,_,z,Y,$,A,O){let w=O||`hook-${bhY()}`;try{let j=yQ8(q.prompt,z);N(`Hooks: Processing prompt hook with prompt: ${j}`);let H=U8({content:j}),J=A&&A.length>0?[...A,H]:[H];N(`Hooks: Querying model with ${J.length} messages`);let M=q.timeout?q.timeout*1000:30000,{signal:X,cleanup:P}=Ty(Y,{timeoutMs:M});try{let W=await Ed({messages:J,systemPrompt:iK([`You are evaluating a hook in Claude Code. |
| 7701 | 2. If the condition is not met, return: {"ok": false, "reason": "Reason for why it is not met"}`]),thinkingConfig:{type:"disabled"},tools:$.options.tools,signal:X,options:{async getToolPermissionContext(){return $.getAppState().toolPermissionContext},model:q.model??PH(),toolChoice:void 0,isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,agents:[],querySource:"hook_prompt",mcpTools:[],agentId:$.agentId,outputFormat:{type:"json_schema",schema:{type:"object",properties:{ok:{type:"boolean"},reason:{type:"string"}},required:["ok"],additionalProperties:!1}}}});P();let D=L3(W.message.content);$.setResponseLength((T)=>T+D.length);let f=D.trim();N(`Hooks: Model response: ${f}`);let G=m5(f);if(!G)return N(`Hooks: error parsing response as JSON: ${f}`),{hook:q,outcome:"non_blocking_error",message:V4({type:"hook_non_blocking_error",hookName:K,toolUseID:w,hookEvent:_,stderr:"JSON validation failed",stdout:f,exitCode:1})};let Z=Uq8().safeParse(G);if(!Z.success)return N(`Hooks: model response does not conform to expected schema: ${Z.error.message}`),{hook:q,outcome:"non_blocking_error",message:V4({type:"hook_non_blocking_error",hookName:K,toolUseID:w,hookEvent:_,stderr:`Schema validation failed: ${Z.error.message}`,stdout:f,exitCode:1})};if(!Z.data.ok)return N(`Hooks: Prompt hook condition was not met: ${Z.data.reason}`),{hook:q,outcome:"blocking",blockingError:{blockingError:`Prompt hook condition was not met: ${Z.data.reason}`,command:q.prompt},preventContinuation:!0,stopReason:Z.data.reason};return N("Hooks: Prompt hook condition was met"),{hook:q,outcome:"success",message:V4({type:"hook_success",hookName:K,toolUseID:w,hookEvent:_,content:""})}}catch(W){if(P(),X.aborted)return{hook:q,outcome:"cancelled"};throw W}}catch(j){let H=d6(j);return N(`Hooks: Prompt hook error: ${H}`),{hook:q,outcome:"non_blocking_error",message:V4({type:"hook_non_blocking_error",hookName:K,toolUseID:w,hookEvent:_,stderr:`Error executing prompt hook: ${H}`,stdout:"",exitCode:1})}}}var OgK=y(()=>{ew();lP();nS6();_8();y8();vO();i1();aq();LQ8()});import{randomUUID as wgK}from"crypto";async function jgK(q,K,_,z,Y,$,A,O,w){let j=A||`hook-${wgK()}`,H=$.agentId?c0($.agentId):Y$(),J=Date.now();try{let M=yQ8(q.prompt,z);N(`Hooks: Processing agent hook with prompt: ${M}`);let P=[U8({content:M})];N(`Hooks: Starting agent query with ${P.length} messages`);let W=q.timeout?q.timeout*1000:60000,D=P3(),{signal:f,cleanup:G}=Ty(Y,{timeoutMs:W}),Z=()=>D.abort();f.addEventListener("abort",Z);let T=D.signal;try{let v=$gK(),E=[...$.options.tools.filter((F)=>!g_(F,MD)).filter((F)=>!mV6.has(F.name)),v],S=iK([`You are verifying a stop condition in Claude Code. Your task is to verify that the agent completed the given plan. The conversation transcript is available at: ${H} |