PageSourceSearch

https://assets.app.kiro.dev/releases/94a483a67fae4e30/SettingsCustomAgentsPage.js

js kiro.dev collected 2026-09-24 15:18:52 UTC 26,066 bytes, 6 lines download raw bytes

1import{bR as ae,bq as s,bL as w,eA as Te,es as Q,bP as L,en as P,f1 as Ae,bl as v,ew as xe,bK as fe,fO as Re,gr as Ne,bO as je,eu as O,et as H,er as ue,gf as ze,fH as re,gE as De,ev as Oe,g$ as be,h0 as Le,fV as Me,f5 as Be,fc as He}from"./vendor.js";import{W as Ve,d as Ue,ce as We,ci as qe,cj as Ye,ck as Je,cf as Ge,cg as Ke,ch as Qe,cl as Xe,r as Ze,bn as oe,bp as Ce}from"./main.js";import"./mermaid.js";import{C as et}from"./ConfigSyncBanner.js";import{u as tt,a as nt,B as st}from"./useBulkDeleteConfigs.js";import{l as le,u as at,i as we,f as it,v as Se,p as ot}from"./useConfigFile.js";import{g as rt}from"./MarkdownPreview.js";import{t as me}from"./storedContent.js";import{a as lt}from"./SettingsAgent.module.js";import{r as ct}from"./optimisticMutation.js";import"./useUserSettings.js";import"./submitQueue.js";const dt="_pageHeader_2032u_1",ft="_headerActions_2032u_8",ut="_loadErrorNotice_2032u_12",mt="_fileTable_2032u_22",pt="_fileTableHeader_2032u_29",ht="_fileRow_2032u_41",gt="_fileRowWrapper_2032u_52",xt="_fileRowCheckbox_2032u_65",vt="_fileTableHeaderCheckbox_2032u_72",yt="_selectionToolbar_2032u_78",jt="_fileRowName_2032u_85",bt="_fileViewPanel_2032u_97",Ct="_fileViewHeader_2032u_104",wt="_fileViewTitle_2032u_113",St="_filePath_2032u_120",kt="_editorContainer_2032u_126",_t="_previewBody_2032u_131",Tt="_editorLoader_2032u_138",At="_editorFooter_2032u_145",Nt="_validationError_2032u_154",Ft="_emptyState_2032u_163",Pt="_emptyStateIcon_2032u_175",Et="_emptyStateText_2032u_185",b={pageHeader:dt,headerActions:ft,loadErrorNotice:ut,fileTable:mt,fileTableHeader:pt,fileRow:ht,fileRowWrapper:gt,fileRowCheckbox:xt,fileTableHeaderCheckbox:vt,selectionToolbar:yt,fileRowName:jt,fileViewPanel:bt,fileViewHeader:Ct,fileViewTitle:wt,filePath:St,editorContainer:kt,previewBody:_t,editorLoader:Tt,editorFooter:At,validationError:Nt,emptyState:Ft,emptyStateIcon:Pt,emptyStateText:Et},$t=t=>{const e=ae.c(28),{entry:n,filePath:a,selected:r,onToggleSelect:i}=t;let f;e[0]!==n.path||e[1]!==a?(f=a(n.path),e[0]=n.path,e[1]=a,e[2]=f):f=e[2];const l=n.kind==="folder"?"folder":"file",y=n.kind==="folder"?"var(--color-text-link)":"var(--color-text-secondary)";let o;e[3]!==l||e[4]!==y?(o=s.jsx(L,{id:l,size:"sm",c:y}),e[3]=l,e[4]=y,e[5]=o):o=e[5];let p;e[6]!==n.name?(p=s.jsx(P,{component:"span",className:b.fileRowName,children:n.name}),e[6]=n.name,e[7]=p):p=e[7];let c;e[8]!==f||e[9]!==o||e[10]!==p?(c=s.jsxs(Ae,{to:f,className:b.fileRow,children:[o,p]}),e[8]=f,e[9]=o,e[10]=p,e[11]=c):c=e[11];let m;e[12]!==n.path||e[13]!==i?(m=()=>i(n.path),e[12]=n.path,e[13]=i,e[14]=m):m=e[14];const j=`Select ${n.kind} ${n.name}`;let u;e[15]!==n.path||e[16]!==i?(u=()=>i(n.path),e[15]=n.path,e[16]=i,e[17]=u):u=e[17];let x;e[18]!==r||e[19]!==j||e[20]!==u?(x=s.jsx(Te,{size:"sm","aria-label":j,checked:r,onClick:Rt,onChange:u}),e[18]=r,e[19]=j,e[20]=u,e[21]=x):x=e[21];let h;e[22]!==x||e[23]!==m?(h=s.jsx(w,{className:b.fileRowCheckbox,onClick:m,children:x}),e[22]=x,e[23]=m,e[24]=h):h=e[24];let _;return e[25]!==h||e[26]!==c?(_=s.jsxs(w,{className:b.fileRowWrapper,children:[c,h]}),e[25]=h,e[26]=c,e[27]=_):_=e[27],_},It=t=>{const e=ae.c(28),{files:n,dirPath:a,filePath:r,selectedPaths:i,onToggleSelect:f,onToggleSelectAll:l}=t;let y,o,p,c,m,j;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==f||e[4]!==l||e[5]!==i){const h=le({files:n,dirPath:a}),_=h.length>0&&h.every(C=>i.has(C.path)),T=!_&&h.some(C=>i.has(C.path));o=Q,j="md",y=w,p=b.fileTable;let A;e[12]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(L,{id:"files",size:"sm",c:"var(--color-text-secondary)"}),e[12]=A):A=e[12];const E=s.jsx(w,{className:b.fileTableHeaderCheckbox,children:s.jsx(Te,{size:"sm","aria-label":"Select all files and folders",checked:_,indeterminate:T,onChange:l})});e[13]!==E?(c=s.jsxs(w,{className:b.fileTableHeader,children:[A,"Files",E]}),e[13]=E,e[14]=c):c=e[14];let S;e[15]!==r||e[16]!==f||e[17]!==i?(S=C=>s.jsx($t,{entry:C,filePath:r,selected:i.has(C.path),onToggleSelect:f},C.path),e[15]=r,e[16]=f,e[17]=i,e[18]=S):S=e[18],m=h.map(S),e[0]=a,e[1]=r,e[2]=n,e[3]=f,e[4]=l,e[5]=i,e[6]=y,e[7]=o,e[8]=p,e[9]=c,e[10]=m,e[11]=j}else y=e[6],o=e[7],p=e[8],c=e[9],m=e[10],j=e[11];let u;e[19]!==y||e[20]!==p||e[21]!==c||e[22]!==m?(u=s.jsxs(y,{className:p,children:[c,m]}),e[19]=y,e[20]=p,e[21]=c,e[22]=m,e[23]=u):u=e[23];let x;return e[24]!==o||e[25]!==j||e[26]!==u?(x=s.jsx(o,{gap:j,children:u}),e[24]=o,e[25]=j,e[26]=u,e[27]=x):x=e[27],x};function Rt(t){return t.stopPropagation()}function ve(t){return/\.json$/i.test(t)?"json":/\.(md|markdown)$/i.test(t)?"markdown":"other"}function zt(t){return t.trimStart().startsWith("---")}function Dt({path:t,content:e}){const n=ve(t);return n==="json"?"definition":n==="other"?"supporting":e===void 0?"pending":zt(e)?"definition":"supporting"}function Ot({path:t,content:e}){return ve(t)==="json"?Lt(e):Bt(e)}function Lt(t){let e;try{e=JSON.parse(t)}
1catch(i){return{config:null,error:`This file is not valid JSON: ${i instanceof Error?i.message:"Unexpected token."}`}}if(e===null||typeof e!="object"||Array.isArray(e))return{config:null,error:"An agent configuration must be a JSON object."};const n={...e},a={};typeof n.description=="string"&&(a.description=n.description),typeof n.model=="string"&&(a.model=n.model);const r=Mt(n.tools);return r!==void 0&&(a.tools=r),{config:a,error:null}}function Mt(t){if(t==="*")return"*";if(!Array.isArray(t))return;const e=t.filter(n=>typeof n=="string");return e.includes("*")?"*":e}function Bt(t){const e=t.trimStart();if(!e.startsWith("---"))return{config:{},error:null};const a=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e)?.[1];return a===void 0?{config:null,error:'The frontmatter block is not closed. Add a "---" line after the configuration.'}:{config:Ht(a),error:null}}function Ht(t){const e={},n=ke(t,"description");n!==void 0&&(e.description=n);const a=ke(t,"model");a!==void 0&&(e.model=a);const r=Vt(t);return r!==void 0&&(e.tools=r),e}function ke(t,e){const a=new RegExp(`^${e}:[ \\t]*(.+)$`,"m").exec(t)?.[1];if(a===void 0)return;const r=a.trim(),i=/^(['"])(.*)\1$/.exec(r);if(!i)return r;const[,f,l]=i;return f==='"'?l.replace(/\\([\\"n])/g,(y,o)=>o==="n"?`
2`:o):l}function Vt(t){const n=/^tools:[ \t]*(.+)$/m.exec(t)?.[1]?.trim();if(n){if(n.replace(/^(['"])(.*)\1$/,"$2")==="*")return"*";const f=/^\[(.*)\]$/.exec(n);return f?f[1].split(",").map(l=>l.trim().replace(/^(['"])(.*)\1$/,"$2")).filter(l=>l.length>0):void 0}const r=/^tools:[ \t]*$\r?\n((?:[ \t]+-[ \t]*.+\r?\n?)+)/m.exec(t)?.[1];if(r!==void 0)return r.split(/\r?\n/).map(i=>/^[ \t]+-[ \t]*(.+)$/.exec(i)?.[1]).filter(i=>i!==void 0).map(i=>i.trim().replace(/^(['"])(.*)\1$/,"$2"))}function Ut(t){const e=t.trimStart(),n=/^---\r?\n[\s\S]*?\r?\n---[ \t]*(\r?\n|$)/.exec(e);return n?e.slice(n[0].length).replace(/^\s*\n/,""):t}const pe="agents/";function Wt(t){return`${pe}${t}`}function qt(t){if(!t.startsWith(pe))return null;const e=t.slice(pe.length);return e.length>0?e:null}function Yt(t){const e=t.slice(t.lastIndexOf("/")+1),n=e.lastIndexOf(".");return n>0?e.slice(0,n):e}function Jt(t){const e=[];for(const n of t){if(!n.configId||!n.path||n.isDirectory)continue;const a=qt(n.path);a!==null&&e.push({configId:n.configId,path:a,createdAt:n.createdAt,updatedAt:n.updatedAt})}return e.sort((n,a)=>n.path.localeCompare(a.path))}const he={content:{background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-default)",boxShadow:"0 10px 40px color-mix(in srgb, var(--kiro-kiro-black) 20%, transparent)",borderRadius:"var(--border-radius-kiro-lg)"},header:{background:"transparent",padding:"var(--mantine-spacing-md)",borderBottom:"1px solid var(--color-border-subtle)"},body:{padding:"var(--mantine-spacing-md)"}},ge={blur:4,backgroundOpacity:.55},ye="var(--mantine-color-kiro-purple-filled, var(--kiro-purple-500))";function Gt(t){return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r?\n/g,"\\n")}"`}const Fe="Describe what this agent is for.",Pe="You are a helpful coding assistant.",Ee=["read","write","shell"];function Kt({description:t,prompt:e,model:n}){const a=["---",`description: ${Gt(t||Fe)}`];return n&&a.push(`model: ${n}`),a.push(`tools: [${Ee.join(", ")}]`,"---","",e||Pe,""),a.join(`
3`)}
3function Qt({description:t,prompt:e,model:n}){const a={description:t||Fe,prompt:e||Pe,tools:Ee};return n&&(a.model=n),`${JSON.stringify(a,null,2)}
4`}function Xt({format:t,...e}){return t==="json"?{path:`${e.name}.json`,content:Qt(e)}:{path:`${e.name}.md`,content:Kt(e)}}function Zt({path:t,content:e}){const n=e.endsWith(`
5`)?e:`${e}
6`,a=new Blob([n],{type:"text/plain"}),r=URL.createObjectURL(a),i=document.createElement("a");i.href=r;const f=t.slice(t.lastIndexOf("/")+1);i.download=f===""?`${Yt(t)}.txt`:f,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}const en=t=>{const e=ae.c(70),{path:n,content:a,isSaving:r,onSave:i,onRequestDelete:f}=t,[l,y]=v.useState(a),[o,p]=v.useState("edit");let c;e[0]!==n?(c=ve(n),e[0]=n,e[1]=c):c=e[1];const m=c;let j;e[2]!==l||e[3]!==n?(j=Dt({path:n,content:l}),e[2]=l,e[3]=n,e[4]=j):j=e[4];const u=j;let x;e[5]!==l||e[6]!==u||e[7]!==n?(x=u==="definition"?Ot({path:n,content:l}):null,e[5]=l,e[6]=u,e[7]=n,e[8]=x):x=e[8];const h=x;let _;e[9]!==l?(_=me(l),e[9]=l,e[10]=_):_=e[10];let T;e[11]!==a?(T=me(a),e[11]=a,e[12]=T):T=e[12];const A=_!==T;let E;e[13]!==l||e[14]!==i||e[15]!==n?(E=async()=>{try{await i({path:n,content:l}),fe.show({title:"File saved",message:n,color:"green"})}catch{}},e[13]=l,e[14]=i,e[15]=n,e[16]=E):E=e[16];const S=E;let C;e[17]!==n?(C=s.jsx(P,{size:"sm",fw:500,className:b.filePath,children:n}),e[17]=n,e[18]=C):C=e[18];let g;e[19]!==u?(g=u==="definition"?s.jsx(Re,{variant:"light",color:"gray",radius:"sm",size:"xs",children:"Agent definition"}):null,e[19]=u,e[20]=g):g=e[20];let R;e[21]!==C||e[22]!==g?(R=s.jsxs(w,{className:b.fileViewTitle,children:[C,g]}),e[21]=C,e[22]=g,e[23]=R):R=e[23];let z;e[24]!==m||e[25]!==o?(z=m==="markdown"?s.jsx(Ne,{size:"xs",value:o,data:[{label:"Preview",value:"preview"},{label:"Edit",value:"edit"}],onChange:ie=>p(ie==="edit"?"edit":"preview")}):null,e[24]=m,e[25]=o,e[26]=z):z=e[26];const V=`Download ${n}`;let I;e[27]!==l||e[28]!==n?(I=()=>Zt({path:n,content:l}),e[27]=l,e[28]=n,e[29]=I):I=e[29];let U;e[30]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(L,{id:"download",size:"sm"}),e[30]=U):U=e[30];let D;e[31]!==V||e[32]!==I?(D=s.jsx(je,{variant:"subtle",size:"sm",c:"var(--color-text-muted)","aria-label":V,onClick:I,children:U}),e[31]=V,e[32]=I,e[33]=D):D=e[33];const J=`Delete ${n}`;let $;e[34]!==f||e[35]!==n?($=()=>f(n),e[34]=f,e[35]=n,e[36]=$):$=e[36];let M;e[37]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(L,{id:"trash",size:"sm"}),e[37]=M):M=e[37];let F;e[38]!==J||e[39]!==$?(F=s.jsx(je,{variant:"subtle",size:"sm",c:"var(--color-text-muted)",className:lt.deleteButton,"aria-label":J,onClick:$,children:M}),e[38]=J,e[39]=$,e[40]=F):F=e[40];const W=!A;let B;e[41]!==S?(B=()=>{S()},e[41]=S,e[42]=B):B=e[42];let q;e[43]!==r||e[44]!==W||e[45]!==B?(q=s.jsx(O,{variant:"primary","data-variant":"primary","data-size":"small",loading:r,disabled:W,onClick:B,children:"Save"}),e[43]=r,e[44]=W,e[45]=B,e[46]=q):q=e[46];let X;e[47]!==z||e[48]!==D||e[49]!==F||e[50]!==q?(X=s.jsxs(H,{gap:"sm",wrap:"nowrap",children:[z,D,F,q]}),e[47]=z,e[48]=D,e[49]=F,e[50]=q,e[51]=X):X=e[51];let Z;e[52]!==X||e[53]!==R?(Z=s.jsxs(w,{className:b.fileViewHeader,children:[R,X]}),e[52]=X,e[53]=R,e[54]=Z):Z=e[54];let Y;e[55]!==l||e[56]!==m||e[57]!==o||e[58]!==n?(Y=m==="markdown"&&o==="preview"?s.jsx(w,{className:b.previewBody,children:s.jsx(rt,{content:Ut(l)})}):s.jsx(w,{className:b.editorContainer,children:s.jsx(Ve,{value:l,path:n,readOnly:!1,loading:s.jsx(w,{className:b.editorLoader,children:s.jsx(xe,{size:"sm",color:ye})}),onChange:y})}),e[55]=l,e[56]=m,e[57]=o,e[58]=n,e[59]=Y):Y=e[59];let G;e[60]!==h?(G=h?.error?s.jsxs(w,{className:b.validationError,role:"alert",children:[s.jsx(L,{id:"error",size:"sm",c:"var(--color-feedback-error)"}),s.jsx(P,{size:"xs",children:h.error})]}):null,e[60]=h,e[61]=G):G=e[61];let K;e[62]!==a||e[63]!==A?(K=A?s.jsxs(w,{className:b.editorFooter,children:[s.jsx(P,{size:"xs",c:"var(--color-text-muted)",children:"Unsaved changes"}),s.jsx(O,{variant:"tertiary","data-variant":"tertiary","data-size":"small",onClick:()=>y(a),children:"Discard changes"})]}):null,e[62]=a,e[63]=A,e[64]=K):K=e[64];let ee;return e[65]!==Z||e[66]!==Y||e[67]!==G||e[68]!==K?(ee=s.jsxs(w,{className:b.fileViewPanel,children:[Z,Y,G,K]}),e[65]=Z,e[66]=Y,e[67]=G,e[68]=K,e[69]=ee):ee=e[69],ee},tn=t=>{const e=ae.c(16),{entry:n,isSaving:a,onSave:r,onRequestDelete:i}=t,{content:f,isLoading:l,isNotFound:y,loadError:o}=at(n.configId);if(l){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(w,{className:b.fileViewPanel,children:s.jsx(H,{justify:"center",p:"xl",children:s.jsx(xe,{size:"sm",color:ye})})}),e[0]=c):c=e[0],c}if(y||o||f===null){let c;e[1]!==n.path?(c=s.jsx(w,{className:b.fileViewHeader,children:s.jsx(P,{size:"sm",fw:500,children:n.path})}),e[1]=n.path,e[2]=c):c=e[2];let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(L,{id:"warning",size:"sm",c:"var(--color-feedback-warning-strong)"}),e[3]=m):m=e[3];const j=y?"This file no longer exists.":"This file could not be loaded. Try reloading the page.";let u;e[4]!==j?(u=s.jsxs(H,{gap:"xs",p:"md",children:[m,s.jsx(P,{size:"sm",c:"var(--color-text-secondary)",children:j})]}),e[4]=j,e[5]=u):u=e[5];let x;return e[6]!==c||e[7]!==u?(x=s.jsxs(w,{className:b.fileViewPanel,children:[c,u]}),e[6]=c,e[7]=u,e[8]=x):x=e[8],x}let p;return e[9]!==f||e[10]!==n.configId||e[11]!==n.path||e[12]!==a||e[13]!==i||e[14]!==r?(p=s.jsx(Q,{gap:"md",children:s.jsx(en,{path:n.path,content:f,isSaving:a,onSave:r,onRequestDelete:i},n.configId)}),e[9]=f,e[10]=n.configId,e[11]=n.path,e[12]=a,e[13]=i,e[14]=r,e[15]=p):p=e[15],p},nn=[{label:"Markdown",value:"markdown"},{label:"JSON",value:"json"}],sn={markdown:"Configuration (tools, model, MCP servers, permissions) in YAML frontmatter, document body as the system prompt.",json:"Configuration and prompt in one object — the CLI's canonical format. The prompt may be inline text or a file:// URI."},an=({opened:t,takenPaths:e,onClose:n,onCreate:a})=>{const[r,i]=v.useState("markdown"),[f,l]=v.useState(""),[y,o]=v.useState(""),[p,c]=v.useState(""),[m,j]=v.useState(""),[u,x]=v.useState(!1),h=f.trim(),_=r==="json"?".json":".md",T=h===""?"":`${h}${_}`,A=h.includes("/")||h.includes("\\"),E=T!==""&&e.has(T),S=A?"Agent names cannot contain slashes.":E?`A file named ${T} already exists.`:void 0,C=v.useCallback(async()=>{x(!0);try{await a(Xt({format:r,name:h,description:y.trim(),prompt:p.trim(),model:m.trim()})),n()}catch{}finally{x(!1)}},[r,h,y,p,m,a,n]);return s.jsx(ue,{centered:!0,size:"lg",opened:t,title:s.jsx(P,{c:"var(--color-text-primary)",fw:500,size:"sm",children:"Create agent"}),styles:he,overlayProps:ge,onClose:n,children:s.jsxs(Q,{gap:"md",children:[s.jsx(P,{size:"sm",c:"var(--color-text-secondary)",children:"An agent is one document in .kiro/agents/, in either format Kiro reads. You can edit the full document after creating it."}),s.jsx(ze.Wrapper,{label:"Format",description:sn[r],children:s.jsx(Ne,{fullWidth:!0,size:"xs",value:r,data:nn,onChange:g=>i(g)})}),s.jsx(re,{label:"Name",required:!0,placeholder:"backend-specialist",description:T===""?`Becomes the filename (<name>${_}) in .kiro/agents/.`:`Creates agents/${T}. The filename is the agent's name.`,value:f,error:S,onChange:g=>l(g.currentTarget.value)}),s.jsx(re,{label:"Description",placeholder:"A specialist in backend coding practices",value:y,onChange:g=>o(g.currentTarget.value)}),s.jsx(De,{label:"Prompt",placeholder:"You are a helpful coding assistant.",description:"High-level context for the agent, similar to a system prompt.",autosize:!0,minRows:2,value:p,onChange:g=>c(g.currentTarget.value)}),s.jsx(re,{label:"Model",placeholder:"claude-sonnet-4",description:"Optional model ID. Falls back to the default model when empty or unavailable.",value:m,onChange:g=>j(g.currentTarget.value)}),s.jsxs(H,{justify:"flex-end",gap:"sm",children:[s.jsx(O,{variant:"tertiary","data-variant":"tertiary",onClick:n,children:"Cancel"}),s.jsx(O,{variant:"primary","data-variant":"primary",disabled:h===""||S!==void 0,loading:u,onClick:()=>{C()},children:"Create agent"})]})]})})};function on(){const t=ae.c(35),e=Oe(),{getCsrfToken:n}=Ue();let a;t[0]!==n?(a=n(),t[0]=n,t[1]=a):a=t[1];let r;t[2]!==a?(r={csrfToken:a,type:be.AGENT,maxResults:600},t[2]=a,t[3]=r):r=t[3];let i;t[4]===Symbol.for("react.memo_cache_sentinel")?(i={...Ge,meta:{getErrorMessage:dn}},t[4]=i):i=t[4];let f;t[5]!==r?(f={input:r,options:i},t[5]=r,t[6]=f):f=t[6];const{data:l,isLoading:y,isError:o}=We(f);let p;
6t[7]!==e?(p=()=>{e.invalidateQueries({queryKey:[Ke]}),e.invalidateQueries({queryKey:[Qe]})},t[7]=e,t[8]=p):p=t[8];const c=p;let m;t[9]===Symbol.for("react.memo_cache_sentinel")?(m={options:{meta:{getErrorMessage:cn}}},t[9]=m):m=t[9];const j=qe(m);let u;t[10]===Symbol.for("react.memo_cache_sentinel")?(u={options:{meta:{getErrorMessage:ln}}},t[10]=u):u=t[10];const x=Ye(u);let h;t[11]===Symbol.for("react.memo_cache_sentinel")?(h={options:{meta:{getErrorMessage:rn}}},t[11]=h):h=t[11];const _=Je(h),{mutateAsync:T}=j,{mutateAsync:A}=x,{mutateAsync:E}=_;let S;t[12]!==l?.items?(S=l?.items??[],t[12]=l?.items,t[13]=S):S=t[13];let C;t[14]!==S?(C=Jt(S),t[14]=S,t[15]=C):C=t[15];const g=C;let R;t[16]!==T||t[17]!==g||t[18]!==n||t[19]!==c||t[20]!==A?(R=async J=>{const{path:$,content:M}=J,F=g.find(q=>q.path===$),W=Wt($),B=me(M);F?await A({csrfToken:n(),configId:F.configId,path:W,content:B}):await T({csrfToken:n(),type:be.AGENT,scope:Le.INSTANCE_SPECIFIC,path:W,content:B}),c()},t[16]=T,t[17]=g,t[18]=n,t[19]=c,t[20]=A,t[21]=R):R=t[21];const z=R;let V;t[22]!==E||t[23]!==g||t[24]!==n||t[25]!==c||t[26]!==e?(V=async J=>{const $=g.find(F=>F.path===J);if(!$)return;const{configId:M}=$;await ct({queryClient:e,matches:Xe,apply:F=>F?.items?{...F,items:F.items.filter(W=>W.configId!==M)}:F,mutate:()=>E({csrfToken:n(),configId:M})}),c()},t[22]=E,t[23]=g,t[24]=n,t[25]=c,t[26]=e,t[27]=V):V=t[27];const I=V,U=j.isPending||x.isPending;let D;return t[28]!==I||t[29]!==g||t[30]!==o||t[31]!==y||t[32]!==z||t[33]!==U?(D={files:g,isLoading:y,loadError:o,saveFile:z,deleteFile:I,isSaving:U},t[28]=I,t[29]=g,t[30]=o,t[31]=y,t[32]=z,t[33]=U,t[34]=D):D=t[34],D}function rn(t){return t instanceof Error?`Failed to delete: ${t.message}`:"Failed to delete."}function ln(t){return t instanceof Error?`Failed to save file: ${t.message}`:"Failed to save file."}function cn(t){return t instanceof Error?`Failed to add file: ${t.message}`:"Failed to add file."}function dn(t){return t instanceof Error?`Failed to load custom agents: ${t.message}`:"Failed to load custom agents."}const ce="/settings/custom-agents",_e=new Set;function se(t){return t?`${ce}?path=${encodeURIComponent(t)}`:ce}function fn(t){return["Settings",{label:"Custom agents",href:ce},...ot(t).map(e=>({label:e.name,href:se(e.path)}))]}const Sn=()=>{Ze("Custom Agents Settings");const[t]=Me(),e=Be(),{files:n,isLoading:a,loadError:r,saveFile:i,deleteFile:f,isSaving:l}=on(),{deleteConfigItems:y}=tt(),o=t.get("path")??"",[p,c]=v.useState({opened:!1,session:0}),[m,j]=v.useState(!1),[u,x]=v.useState(""),[h,_]=v.useState(!1),[T,A]=v.useState({isOpen:!1,path:null}),[E,S]=v.useState(!1),[C,g]=v.useState({dirPath:"",paths:new Set}),[R,z]=v.useState({opened:!1,targets:[]}),V=nt("agents-delete"),I=C.dirPath===o?C.paths:_e,U=v.useCallback(d=>{g(N=>{const k=new Set(N.dirPath===o?N.paths:[]);return k.has(d)?k.delete(d):k.add(d),{dirPath:o,paths:k}})},[o]),D=v.useCallback(()=>{c(d=>({opened:!0,session:d.session+1}))},[]),J=v.useCallback(()=>{c(d=>({...d,opened:!1}))},[]),$=v.useCallback(()=>{j(!1),x("")},[]),M=v.useCallback(async d=>{await i(d),fe.show({title:"Agent created",message:d.path,color:"green"}),e(se(d.path))},[i,e]),F=v.useCallback(d=>{A({isOpen:!0,path:d})},[]),W=v.useCallback(()=>{g(d=>{const N=d.dirPath===o?d.paths:_e,k=le({files:n,dirPath:o}),te=k.length>0&&k.every(ne=>N.has(ne.path));return{dirPath:o,paths:te?new Set:new Set(k.map(ne=>ne.path))}})},[n,o]),B=v.useCallback(()=>{g({dirPath:o,paths:new Set})},[o]),q=v.useCallback(()=>{const d=le({files:n,dirPath:o}).filter(N=>I.has(N.path)).map(N=>N.kind==="folder"?{name:`${N.path}/`,configIds:n.filter(k=>k.path.startsWith(`${N.path}/`)).map(k=>k.configId)}:{name:N.path,configIds:n.filter(k=>k.path===N.path).map(k=>k.configId)});d.length!==0&&z({opened:!0,targets:d})},[n,o,I]),X=v.useCallback(()=>{z(d=>({...d,opened:!1}))},[]),Z=v.useCallback(d=>{g(N=>{const k=new Set(N.paths);for(const te of d)k.delete(te.endsWith("/")?te.slice(0,-1):te);return{...N,paths:k}})},[]);if(a)return s.jsx(w,{className:oe.container,children:s.jsxs(Q,{gap:"md",className:oe.innerContent,children:[s.jsx(Ce,{segments:["Settings","Custom agents"]}),s.jsx(H,{justify:"center",mt:"xl",children:s.jsx(xe,{size:"sm",color:ye})})]})});const Y=we({files:n,path:o}),G=Y?void 0:it({files:n,path:o}),K=Y?le({files:n,dirPath:o}).filter(d=>I.has(d.path)).length:0,ee=new Set(n.map(d=>d.path)),ie=u.trim(),de=ie.length>0?Se(u,ee):null,$e=async()=>{const d=u.trim();if(Se(d,ee)===null){_(!0);try{await i({path:d,content:""}),$(),e(se(d))}catch{}finally{_(!1)}}},Ie=async()=>{const d=T.path;if(d!==null){S(!0);try{await f(d),A({isOpen:!1,path:null}),fe.show({title:"File deleted",message:d,color:"green"});const N=d.includes("/")?d.slice(0,d.lastIndexOf("/")):"",k=n.filter(ne=>ne.path!==d),te=N!==""&&we({files:k,path:N});e(se(te?N:void 0))}catch{}finally{S(!1)}}};return R.opened||V!==void 0?s.jsx(st,{scope:"agents-delete",items:R.targets,noun:{singular:"item",plural:"items"},warning:"If other agents reference these files, they will stop resolving them.",deleteConfigItems:y,onClose:X,onCompleted:Z}):s.jsxs(w,{className:oe.container,children:[s.jsxs(Q,{gap:"lg",className:oe.innerContent,children:[s.jsx(Ce,{segments:fn(o)}),o===""?s.jsxs(w,{className:b.pageHeader,children:[s.jsxs(w,{children:[s.jsx(He,{order:2,size:"h3",children:"Custom agents"}),s.jsx(P,{size:"sm",c:"var(--color-text-secondary)",mt:"var(--spacing-kiro-xs)",children:"Custom agents tailor Kiro for specific tasks. An agent is defined by a JSON config or a Markdown document with YAML frontmatter in .kiro/agents/ (workspace) or ~/.kiro/agents/ (user-level). Other files in the folder — prompt bodies referenced with file://, templates, hook scripts — are supporting files shared across agents."})]}),s.jsxs(H,{gap:"sm",wrap:"nowrap",className:b.headerActions,children:[s.jsx(O,{variant:"secondary","data-variant":"secondary",leftSection:s.jsx(L,{id:"file",size:"sm"}),onClick:()=>j(!0),children:"Add file"}),s.jsx(O,{variant:"primary","data-variant":"primary",leftSection:s.jsx(L,{id:"add",size:"sm"}),onClick:D,children:"Add agent"})]})]}):null,o===""?s.jsx(et,{surface:"agents"}):null,r?s.jsxs(w,{className:b.loadErrorNotice,children:[s.jsx(L,{id:"warning",size:"md",c:"var(--color-feedback-warning-strong)"}),s.jsx(P,{size:"sm",children:"Your agents could not be loaded. Try reloading the page."})]}):null,n.length===0&&!r&&o===""?s.jsxs(w,{className:b.emptyState,children:[s.jsx(w,{className:b.emptyStateIcon,children:s.jsx(L,{id:"robot",size:"lg"})}),s.jsxs(Q,{gap:"xs",className:b.emptyStateText,children:[s.jsx(P,{fw:500,c:"var(--color-text-primary)",children:"No custom agents yet"}),s.jsx(P,{size:"sm",c:"var(--color-text-secondary)",children:"Create agents tailored to specific workflows — a code reviewer with read-only tools, an AWS specialist with pre-approved commands, or a backend expert with your project docs loaded."})]})]}):Y?s.jsxs(s.Fragment,{children:[K>
60?s.jsxs(H,{className:b.selectionToolbar,justify:"space-between",children:[s.jsxs(P,{size:"sm",c:"var(--color-text-secondary)",children:[K," selected"]}),s.jsxs(H,{gap:"sm",children:[s.jsx(O,{variant:"tertiary","data-variant":"tertiary","data-size":"small",onClick:B,children:"Clear selection"}),s.jsx(O,{variant:"danger","data-variant":"danger","data-size":"small",leftSection:s.jsx(L,{id:"trash",size:"sm"}),onClick:q,children:"Delete selected"})]})]}):null,s.jsx(It,{files:n,dirPath:o,filePath:se,selectedPaths:I,onToggleSelect:U,onToggleSelectAll:W})]}):G?s.jsx(tn,{entry:G,isSaving:l,onSave:i,onRequestDelete:F}):s.jsxs(Q,{gap:"sm",children:[s.jsxs(P,{size:"sm",c:"var(--color-text-secondary)",children:['No file or folder at "',o,'".']}),s.jsx(w,{children:s.jsx(O,{component:Ae,to:ce,variant:"secondary","data-variant":"secondary",children:"Back to custom agents"})})]})]}),s.jsx(an,{opened:p.opened,takenPaths:ee,onClose:J,onCreate:M},p.session),s.jsx(ue,{centered:!0,opened:m,title:s.jsx(P,{c:"var(--color-text-primary)",fw:500,size:"sm",children:"Add file"}),styles:he,overlayProps:ge,onClose:$,children:s.jsxs(Q,{gap:"md",children:[s.jsx(re,{label:"File path",placeholder:"prompts/reviewer.md",description:"Relative to .kiro/agents/. Supporting files are not owned by a single agent.",required:!0,value:u,error:de?`Error: ${de}`:void 0,onChange:d=>x(d.currentTarget.value)}),s.jsxs(H,{gap:"sm",justify:"flex-end",children:[s.jsx(O,{variant:"tertiary","data-variant":"tertiary",onClick:$,children:"Cancel"}),s.jsx(O,{variant:"primary","data-variant":"primary",loading:h,disabled:ie.length===0||de!==null,onClick:()=>{$e()},children:"Add"})]})]})}),s.jsx(ue,{centered:!0,opened:T.isOpen,title:s.jsxs(H,{gap:"xs",children:[s.jsx(L,{c:"var(--color-feedback-error)",id:"trash",size:"sm"}),s.jsx(P,{c:"var(--color-text-primary)",fw:500,size:"sm",children:"Delete file"})]}),styles:he,overlayProps:ge,onClose:()=>A({isOpen:!1,path:null}),children:s.jsxs(Q,{gap:"md",children:[s.jsxs(P,{c:"var(--color-text-secondary)",size:"sm",children:['Deleting "',T.path,'" is permanent. If other agents reference this file, they will stop resolving it. Want to proceed?']}),s.jsxs(H,{gap:"sm",justify:"flex-end",children:[s.jsx(O,{variant:"tertiary","data-variant":"tertiary",onClick:()=>A({isOpen:!1,path:null}),children:"Cancel"}),s.jsx(O,{variant:"danger","data-variant":"danger",loading:E,onClick:()=>{Ie()},children:"Delete"})]})]})})]})};export{Sn as SettingsCustomAgentsPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.