| 3054 | `+Y.text,z;return z.push(Y),z},[])}}function Y88(q){let K=q.match(/^cell-(\d+)$/);if(K&&K[1]){let _=parseInt(K[1],10);return isNaN(_)?void 0:_}return}var Dsz=1e4;var ku8=y(()=>{NI8();e7();dz();l8()});var TAK="Replace the contents of a specific cell in a Jupyter notebook.",vAK="Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source. Jupyter notebooks are interactive documents that combine code, text, and visualizations, commonly used for data analysis and scientific computing. The notebook_path parameter must be an absolute path, not a relative path. The cell_number is 0-indexed. Use edit_mode=insert to add a new cell at the index specified by cell_number. Use edit_mode=delete to delete the cell at the index specified by cell_number.";import{relative as Vsz}from"path";function kAK(q){let K=z6(20),{notebook_path:_,cell_id:z,new_source:Y,cell_type:$,edit_mode:A,verbose:O}=q,w=A===void 0?"replace":A,j=w==="delete"?"delete":`${w} cell in`,H;if(K[0]!==j)H=g0.createElement(k,{color:"subtle"},"User rejected ",j," "),K[0]=j,K[1]=H;else H=K[1];let J;if(K[2]!==_||K[3]!==O)J=O?_:Vsz(Z8(),_),K[2]=_,K[3]=O,K[4]=J;else J=K[4];let M;if(K[5]!==J)M=g0.createElement(k,{bold:!0,color:"subtle"},J),K[5]=J,K[6]=M;else M=K[6];let X;if(K[7]!==z)X=g0.createElement(k,{color:"subtle"}," at cell ",z),K[7]=z,K[8]=X;else X=K[8];let P;if(K[9]!==H||K[10]!==M||K[11]!==X)P=g0.createElement(u,{flexDirection:"row"},H,M,X),K[9]=H,K[10]=M,K[11]=X,K[12]=P;else P=K[12];let W;if(K[13]!==$||K[14]!==w||K[15]!==Y)W=w!=="delete"&&g0.createElement(u,{marginTop:1,flexDirection:"column"},g0.createElement(zy,{code:Y,filePath:$==="markdown"?"file.md":"file.py",dim:!0})),K[13]=$,K[14]=w,K[15]=Y,K[16]=W;else W=K[16];let D;if(K[17]!==P||K[18]!==W)D=g0.createElement(s8,null,g0.createElement(u,{flexDirection:"column"},P,W)),K[17]=P,K[18]=W,K[19]=D;else D=K[19];return D}var g0;var VAK=y(()=>{q8();I7();s6();gj6();gK();g0=O6(D6(),1)});function Fs1(q){if(!q?.notebook_path)return null;return _3(q.notebook_path)}function NAK({notebook_path:q,cell_id:K,new_source:_,cell_type:z,edit_mode:Y},{verbose:$}){if(!q||!_||!z)return null;let A=$?q:_3(q);if($)return Hz.createElement(Hz.Fragment,null,Hz.createElement(x0,{filePath:q},A),`@${K}, content: ${_.slice(0,30)}…, cell_type: ${z}, edit_mode: ${Y??"replace"}`);return Hz.createElement(Hz.Fragment,null,Hz.createElement(x0,{filePath:q},A),`@${K}`)}function yAK(q,{verbose:K}){return Hz.createElement(kAK,{notebook_path:q.notebook_path,cell_id:q.cell_id,new_source:q.new_source,cell_type:q.cell_type,edit_mode:q.edit_mode,verbose:K})}function EAK(q,{verbose:K}){if(!K&&typeof q==="string"&&o4(q,"tool_use_error"))return Hz.createElement(s8,null,Hz.createElement(k,{color:"error"},"Error editing notebook"));return Hz.createElement(Y2,{result:q,verbose:K})}function LAK({cell_id:q,new_source:K,error:_}){if(_)return Hz.createElement(s8,null,Hz.createElement(k,{color:"error"},_));return Hz.createElement(s8,null,Hz.createElement(u,{flexDirection:"column"},Hz.createElement(k,null,"Updated cell ",Hz.createElement(k,{bold:!0},q),":"),Hz.createElement(u,{marginLeft:2},Hz.createElement(zy,{code:K,filePath:"notebook.py"}))))}var Hz;var RAK=y(()=>{i1();bN();YK6();gj6();gK();VAK();s6();bK();Hz=O6(D6(),1)});import{extname as Nsz,isAbsolute as hAK,resolve as SAK}from"path";var ysz,Esz,qp;var eL6=y(()=>{oN();x7();Bq();I7();y8();bK();ZE();vO();ku8();Tz();l8();RAK();ysz=B6(()=>L.strictObject({notebook_path:L.string().describe("The absolute path to the Jupyter notebook file to edit (must be absolute, not relative)"),cell_id:L.string().optional().describe("The ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified."),new_source:L.string().describe("The new source for the cell"),cell_type:L.enum(["code","markdown"]).optional().describe("The type of the cell (code or markdown). If not specified, it defaults to the current cell type. If using edit_mode=insert, this is required."),edit_mode:L.enum(["replace","insert","delete"]).optional().describe("The type of edit to make (replace, insert, delete). Defaults to replace.")})),Esz=B6(()=>L.object({new_source:L.string().describe("The new source code that was written to the cell"),cell_id:L.string().optional().describe("The ID of the cell that was edited"),cell_type:L.enum(["code","markdown"]).describe("The type of the cell"),language:L.string().describe("The programming language of the notebook"),edit_mode:L.string().describe("The edit mode that was used"),error:L.string().optional().describe("Error message if the operation failed"),notebook_path:L.string().describe("The path to the notebook file"),original_file:L.string().describe("The original notebook content before modification"),updated_file:L.string().describe("The updated notebook content after modification")})),qp=sq({name:nW,searchHint:"edit Jupyter notebook cells (.ipynb)",maxResultSizeChars:1e5,shouldDefer:!0,async description(){return TAK},async prompt(){return vAK},userFacingName(){return"Edit Notebook"},getToolUseSummary:Fs1,getActivityDescription(q){let K=Fs1(q);return K?`Editing notebook ${K}`:"Editing notebook"},get inputSchema(){return ysz()},get outputSchema(){return Esz()},toAutoClassifierInput(q){{let K=q.edit_mode??"replace";return`${q.notebook_path} ${K}: ${q.new_source}`}return""},getPath(q){return q.notebook_path},async checkPermissions(q,K){let _=K.getAppState();return Qj6(qp,q,_.toolPermissionContext)},mapToolResultToToolResultBlockParam({cell_id:q,edit_mode:K,new_source:_,error:z},Y){if(z)return{tool_use_id:Y,type:"tool_result",content:z,is_error:!0};switch(K){case"replace":return{tool_use_id:Y,type:"tool_result",content:`Updated cell ${q} with ${_}`};case"insert":return{tool_use_id:Y,type:"tool_result",content:`Inserted cell ${q} with ${_}`};case"delete":return{tool_use_id:Y,type:"tool_result",content:`Deleted cell ${q}`};default:return{tool_use_id:Y,type:"tool_result",content:"Unknown edit mode"}}},renderToolUseMessage:NAK,renderToolUseRejectedMessage:yAK,renderToolUseErrorMessage:EAK,renderToolResultMessage:LAK,async validateInput({notebook_path:q,cell_type:K,cell_id:_,edit_mode:z="replace"},Y){let $=hAK(q)?q:SAK(Z8(),q);if($.startsWith("\\\\")||$.startsWith("//"))return{result:!0};if(Nsz($)!==".ipynb")return{result:!1,message:"File must be a Jupyter notebook (.ipynb file). For editing other file types, use the FileEdit tool.",errorCode:2};if(z!=="replace"&&z!=="insert"&&z!=="delete")return{result:!1,message:"Edit mode must be replace, insert, or delete.",errorCode:4};if(z==="insert"&&!K)return{result:!1,message:"Cell type is required when using edit_mode=insert.",errorCode:5};let A=Y.readFileState.get($);if(!A)return{result:!1,message:"File has not been read yet. Read it first before writing to it.",errorCode:9};if(ik($)>A.timestamp)return{result:!1,message:"File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.",errorCode:10};let O;try{O=vB($).content}catch(j){if(_7(j))return{result:!1,message:"Notebook file does not exist.",errorCode:1};throw j}let w=m5(O);if(!w)return{result:!1,message:"Notebook is not valid JSON.",errorCode:6};if(!_){if(z!=="insert")return{result:!1,message:"Cell ID must be specified when not inserting a new cell.",errorCode:7}}else if(w.cells.findIndex((H)=>H.id===_)===-1){let H=Y88(_);if(H!==void 0){if(!w.cells[H])return{result:!1,message:`Cell with index ${H} does not exist in notebook.`,errorCode:7}}else return{result:!1,message:`Cell with ID "${_}" not found in notebook.`,errorCode:8}}return{result:!0}},async call({notebook_path:q,new_source:K,cell_id:_,cell_type:z,edit_mode:Y},{readFileState:$,updateFileHistoryState:A},O,w){let j=hAK(q)?q:SAK(Z8(),q);if(e$())await OK6(A,j,w.uuid);try{let{content:H,encoding:J,lineEndings:M}=vB(j),X;try{X=r8(H)}catch{return{data:{new_source:K,cell_type:z??"code",language:"python",edit_mode:"replace",error:"Notebook is not valid JSON.",cell_id:_,notebook_path:j,original_file:"",updated_file:""}}}let P;if(!_)P=0;else{if(P=X.cells.findIndex((v)=>v.id===_),P===-1){let v=Y88(_);if(v!==void 0)P=v}if(Y==="insert")P+=1}let W=Y;if(W==="replace"&&P===X.cells.length){if(W="insert",!z)z="code"}let D=X.metadata.language_info?.name??"python",f=void 0;if(X.nbformat>4||X.nbformat===4&&X.nbformat_minor>=5){if(W==="insert")f=Math.random().toString(36).substring(2,15);else if(_!==null)f=_}if(W==="delete")X.cells.splice(P,1);else if(W==="insert"){let v;if(z==="markdown")v={cell_type:"markdown",id:f,source:K,metadata:{}};else v={cell_type:"code",id:f,source:K,metadata:{},execution_count:null,outputs:[]};X.cells.splice(P,0,v)}else{let v=X.cells[P];if(v.source=K,v.cell_type==="code")v.execution_count=null,v.outputs=[];if(z&&z!==v.cell_type)v.cell_type=z}let Z=g6(X,null,1);return me(j,Z,J,M),$.set(j,{content:Z,timestamp:ik(j),offset:void 0,limit:void 0}),{data:{new_source:K,cell_type:z??"code",language:D,edit_mode:W??"replace",cell_id:f||void 0,error:"",notebook_path:j,original_file:H,updated_file:Z}}}catch(H){if(H instanceof Error)return{data:{new_source:K,cell_type:z??"code",language:"python",edit_mode:"replace",error:H.message,cell_id:_,notebook_path:j,original_file:"",updated_file:""}};return{data:{new_source:K,cell_type:z??"code",language:"python",edit_mode:"replace",error:"Unknown error occurred while editing notebook",cell_id:_,notebook_path:j,original_file:"",updated_file:""}}}}})});function Vu8(q,K){if(Rsz.has(q))return!0;let _=hsz.get(q);if(_){for(let z of _)if(K===z||K.startsWith(z+"/"))return!0}return!1}var Lsz,Rsz,hsz;var Us1=y(()=>{Lsz=new Set(["platform.claude.com","code.claude.com","modelcontextprotocol.io","github.com/anthropics","agentskills.io","docs.python.org","en.cppreference.com","docs.oracle.com","learn.microsoft.com","developer.mozilla.org","go.dev","pkg.go.dev","www.php.net","docs.swift.org","kotlinlang.org","ruby-doc.org","doc.rust-lang.org","www.typescriptlang.org","react.dev","angular.io","vuejs.org","nextjs.org","expressjs.com","nodejs.org","bun.sh","jquery.com","getbootstrap.com","tailwindcss.com","d3js.org","threejs.org","redux.js.org","webpack.js.org","jestjs.io","reactrouter.com","docs.djangoproject.com","flask.palletsprojects.com","fastapi.tiangolo.com","pandas.pydata.org","numpy.org","www.tensorflow.org","pytorch.org","scikit-learn.org","matplotlib.org","requests.readthedocs.io","jupyter.org","laravel.com","symfony.com","wordpress.org","docs.spring.io","hibernate.org","tomcat.apache.org","gradle.org","maven.apache.org","asp.net","dotnet.microsoft.com","nuget.org","blazor.net","reactnative.dev","docs.flutter.dev","developer.apple.com","developer.android.com","keras.io","spark.apache.org","huggingface.co","www.kaggle.com","www.mongodb.com","redis.io","www.postgresql.org","dev.mysql.com","www.sqlite.org","graphql.org","prisma.io","docs.aws.amazon.com","cloud.google.com","learn.microsoft.com","kubernetes.io","www.docker.com","www.terraform.io","www.ansible.com","vercel.com/docs","docs.netlify.com","devcenter.heroku.com","cypress.io","selenium.dev","docs.unity.com","docs.unrealengine.com","git-scm.com","nginx.org","httpd.apache.org"]),{HOSTNAME_ONLY:Rsz,PATH_PREFIXES:hsz}=(()=>{let q=new Set,K=new Map;for(let _ of Lsz){let z=_.indexOf("/");if(z===-1)q.add(_);else{let Y=_.slice(0,z),$=_.slice(z),A=K.get(Y);if(A)A.push($);else K.set(Y,[$])}}return{HOSTNAME_ONLY:q,PATH_PREFIXES:K}})()});function CAK({url:q,prompt:K},{verbose:_}){if(!q)return null;if(_)return`url: "${q}"${_&&K?`, prompt: "${K}"`:""}`;return q}function bAK(){return Vb.default.createElement(s8,{height:1},Vb.default.createElement(k,{dimColor:!0},"Fetching…"))}function xAK({bytes:q,code:K,codeText:_,result:z},Y,{verbose:$}){let A=m4(q);if($)return Vb.default.createElement(u,{flexDirection:"column"},Vb.default.createElement(s8,{height:1},Vb.default.createElement(k,null,"Received ",Vb.default.createElement(k,{bold:!0},A)," (",K," ",_,")")),Vb.default.createElement(u,{flexDirection:"column"},Vb.default.createElement(k,null,z)));return Vb.default.createElement(s8,{height:1},Vb.default.createElement(k,null,"Received ",Vb.default.createElement(k,{bold:!0},A)," (",K," ",_,")"))}function Qs1(q){if(!q?.url)return null;return d5(q.url,PN)}var Vb;var IAK=y(()=>{gK();s6();U7();Vb=O6(D6(),1)});var qR6=m((yjw,uAK)=>{uAK.exports=nj6;nj6.CAPTURING_PHASE=1;nj6.AT_TARGET=2;nj6.BUBBLING_PHASE=3;function nj6(q,K){if(this.type="",this.target=null,this.currentTarget=null,this.eventPhase=nj6.AT_TARGET,this.bubbles=!1,this.cancelable=!1,this.isTrusted=!1,this.defaultPrevented=!1,this.timeStamp=Date.now(),this._propagationStopped=!1,this._immediatePropagationStopped=!1,this._initialized=!0,this._dispatching=!1,q)this.type=q;if(K)for(var _ in K)this[_]=K[_]}nj6.prototype=Object.create(Object.prototype,{constructor:{value:nj6},stopPropagation:{value:function(){this._propagationStopped=!0}},stopImmediatePropagation:{value:function(){this._propagationStopped=!0,this._immediatePropagationStopped=!0}},preventDefault:{value:function(){if(this.cancelable)this.defaultPrevented=!0}},initEvent:{value:function(K,_,z){if(this._initialized=!0,this._dispatching)return;this._propagationStopped=!1,this._immediatePropagationStopped=!1,this.defaultPrevented=!1,this.isTrusted=!1,this.target=null,this.type=K,this.bubbles=_,this.cancelable=z}}})});var cs1=m((Ejw,pAK)=>{var mAK=qR6();pAK.exports=ds1;function ds1(){mAK.call(this),this.view=null,this.detail=0}ds1.prototype=Object.create(mAK.prototype,{constructor:{value:ds1},initUIEvent:{value:function(q,K,_,z,Y){this.initEvent(q,K,_),this.view=z,this.detail=Y}}})});var ns1=m((Ljw,gAK)=>{var BAK=cs1();gAK.exports=ls1;function ls1(){BAK.call(this),this.screenX=this.screenY=this.clientX=this.clientY=0,this.ctrlKey=this.altKey=this.shiftKey=this.metaKey=!1,this.button=0,this.buttons=1,this.relatedTarget=null}ls1.prototype=Object.create(BAK.prototype,{constructor:{value:ls1},initMouseEvent:{value:function(q,K,_,z,Y,$,A,O,w,j,H,J,M,X,P){switch(this.initEvent(q,K,_,z,Y),this.screenX=$,this.screenY=A,this.clientX=O,this.clientY=w,this.ctrlKey=j,this.altKey=H,this.shiftKey=J,this.metaKey=M,this.button=X,X){case 0:this.buttons=1;break;case 1:this.buttons=4;break;case 2:this.buttons=2;break;default:this.buttons=0;break}this.relatedTarget=P}},getModifierState:{value:function(q){switch(q){case"Alt":return this.altKey;case"Control":return this.ctrlKey;case"Shift":return this.shiftKey;case"Meta":return this.metaKey;default:return!1}}}})});var Eu8=m((Rjw,UAK)=>{UAK.exports=yu8;var Ssz=1,Csz=3,bsz=4,xsz=5,Isz=7,usz=8,msz=9,psz=11,Bsz=12,gsz=13,Fsz=14,Usz=15,Qsz=17,dsz=18,csz=19,lsz=20,nsz=21,isz=22,rsz=23,osz=24,asz=25,ssz=[null,"INDEX_SIZE_ERR",null,"HIERARCHY_REQUEST_ERR","WRONG_DOCUMENT_ERR","INVALID_CHARACTER_ERR",null,"NO_MODIFICATION_ALLOWED_ERR","NOT_FOUND_ERR","NOT_SUPPORTED_ERR","INUSE_ATTRIBUTE_ERR","INVALID_STATE_ERR","SYNTAX_ERR","INVALID_MODIFICATION_ERR","NAMESPACE_ERR","INVALID_ACCESS_ERR",null,"TYPE_MISMATCH_ERR","SECURITY_ERR","NETWORK_ERR","ABORT_ERR","URL_MISMATCH_ERR","QUOTA_EXCEEDED_ERR","TIMEOUT_ERR","INVALID_NODE_TYPE_ERR","DATA_CLONE_ERR"],tsz=[null,"INDEX_SIZE_ERR (1): the index is not in the allowed range",null,"HIERARCHY_REQUEST_ERR (3): the operation would yield an incorrect nodes model","WRONG_DOCUMENT_ERR (4): the object is in the wrong Document, a call to importNode is required","INVALID_CHARACTER_ERR (5): the string contains invalid characters",null,"NO_MODIFICATION_ALLOWED_ERR (7): the object can not be modified","NOT_FOUND_ERR (8): the object can not be found here","NOT_SUPPORTED_ERR (9): this operation is not supported","INUSE_ATTRIBUTE_ERR (10): setAttributeNode called on owned Attribute","INVALID_STATE_ERR (11): the object is in an invalid state","SYNTAX_ERR (12): the string did not match the expected pattern","INVALID_MODIFICATION_ERR (13): the object can not be modified in this way","NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML","INVALID_ACCESS_ERR (15): the object does not support the operation or argument",null,"TYPE_MISMATCH_ERR (17): the type of the object does not match the expected type","SECURITY_ERR (18): the operation is insecure","NETWORK_ERR (19): a network error occurred","ABORT_ERR (20): the user aborted an operation","URL_MISMATCH_ERR (21): the given URL does not match another URL","QUOTA_EXCEEDED_ERR (22): the quota has been exceeded","TIMEOUT_ERR (23): a timeout occurred","INVALID_NODE_TYPE_ERR (24): the supplied node is invalid or has an invalid ancestor for this operation","DATA_CLONE_ERR (25): the object can not be cloned."],FAK={INDEX_SIZE_ERR:Ssz,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:Csz,WRONG_DOCUMENT_ERR:bsz,INVALID_CHARACTER_ERR:xsz,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:Isz,NOT_FOUND_ERR:usz,NOT_SUPPORTED_ERR:msz,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:psz,SYNTAX_ERR:Bsz,INVALID_MODIFICATION_ERR:gsz,NAMESPACE_ERR:Fsz,INVALID_ACCESS_ERR:Usz,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:Qsz,SECURITY_ERR:dsz,NETWORK_ERR:csz,ABORT_ERR:lsz,URL_MISMATCH_ERR:nsz,QUOTA_EXCEEDED_ERR:isz,TIMEOUT_ERR:rsz,INVALID_NODE_TYPE_ERR:osz,DATA_CLONE_ERR:asz};function yu8(q){Error.call(this),Error.captureStackTrace(this,this.constructor),this.code=q,this.message=tsz[q],this.name=ssz[q]}yu8.prototype.__proto__=Error.prototype;for($88 in FAK)Nu8={value:FAK[$88]},Object.defineProperty(yu8,$88,Nu8),Object.defineProperty(yu8.prototype,$88,Nu8);var Nu8,$88});var Lu8=m((esz)=>{esz.isApiWritable=!globalThis.__domino_frozen__});var xJ=m((_tz)=>{var bJ=Eu8(),yM=bJ,Ktz=Lu8().isApiWritable;_tz.NAMESPACE={HTML:"http://www.w3.org/1999/xhtml",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/",MATHML:"http://www.w3.org/1998/Math/MathML",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink"};_tz.IndexSizeError=function(){throw new bJ(yM.INDEX_SIZE_ERR)};_tz.HierarchyRequestError=function(){throw new bJ(yM.HIERARCHY_REQUEST_ERR)};_tz.WrongDocumentError=function(){throw new bJ(yM.WRONG_DOCUMENT_ERR)};_tz.InvalidCharacterError=function(){throw new bJ(yM.INVALID_CHARACTER_ERR)};_tz.NoModificationAllowedError=function(){throw new bJ(yM.NO_MODIFICATION_ALLOWED_ERR)};_tz.NotFoundError=function(){throw new bJ(yM.NOT_FOUND_ERR)};_tz.NotSupportedError=function(){throw new bJ(yM.NOT_SUPPORTED_ERR)};_tz.InvalidStateError=function(){throw new bJ(yM.INVALID_STATE_ERR)};_tz.SyntaxError=function(){throw new bJ(yM.SYNTAX_ERR)};_tz.InvalidModificationError=function(){throw new bJ(yM.INVALID_MODIFICATION_ERR)};_tz.NamespaceError=function(){throw new bJ(yM.NAMESPACE_ERR)};_tz.InvalidAccessError=function(){throw new bJ(yM.INVALID_ACCESS_ERR)};_tz.TypeMismatchError=function(){throw new bJ(yM.TYPE_MISMATCH_ERR)};_tz.SecurityError=function(){throw new bJ(yM.SECURITY_ERR)};_tz.NetworkError=function(){throw new bJ(yM.NETWORK_ERR)};_tz.AbortError=function(){throw new bJ(yM.ABORT_ERR)};_tz.UrlMismatchError=function(){throw new bJ(yM.URL_MISMATCH_ERR)};_tz.QuotaExceededError=function(){throw new bJ(yM.QUOTA_EXCEEDED_ERR)};_tz.TimeoutError=function(){throw new bJ(yM.TIMEOUT_ERR)};_tz.InvalidNodeTypeError=function(){throw new bJ(yM.INVALID_NODE_TYPE_ERR)};_tz.DataCloneError=function(){throw new bJ(yM.DATA_CLONE_ERR)};_tz.nyi=function(){throw Error("NotYetImplemented")};_tz.shouldOverride=function(){throw Error("Abstract function; should be overriding in subclass.")};_tz.assert=function(q,K){if(!q)throw Error("Assertion failed: "+(K||"")+` |