PageSourceSearch

https://calafia.ai/assets/AgentBuilderPage-DvSv4HZA.js

js calafia.ai collected 2026-10-04 01:54:59 UTC 36,861 bytes, 2 lines download raw bytes

1import{j as e,R as Ie,a as Ne,u as Be,U as Pe,Y as Ee,C as De,r as d,G as x,bL as Oe,bS as He}from"./index-CFVicvh_.js";import{g as B}from"./toolLabels-Ba0NA2dv.js";import{I as P}from"./InfoTip-CC_x-2or.js";import{D as Le}from"./DismissibleCard-CZmzAwwW.js";const ge={"google.gmail.search":"read","google.gmail.sendMessage":"write","google.drive.searchFiles":"read","google.drive.getFileContent":"read","google.list_files":"read","google.read_file":"read","google.list_events":"read","google.create_event":"write","google.calendar.listEvents":"read","google.calendar.createEvent":"write","github.list_repos":"read","github.get_repo":"read","github.list_issues":"read","github.create_issue":"write","github.search_code":"read","github.get_file_contents":"read","github.list_pull_requests":"read","github.listIssues":"read","github.createIssue":"write","slack.list_channels":"read","slack.post_message":"write","slack.search_messages":"read","slack.get_channel_history":"read","slack.postMessage":"write","jira.search_issues":"read","jira.get_issue":"read","jira.create_issue":"write","jira.update_issue":"write","salesforce.query":"read","salesforce.get_record":"read","salesforce.create_record":"write","salesforce.update_record":"write","salesforce.describe_object":"read","notion.search":"read","notion.get_page":"read","notion.create_page":"write","notion.query_database":"read","linear.list_issues":"read","linear.create_issue":"write","linear.update_issue":"write","linear.list_projects":"read","confluence.search":"read","confluence.get_page":"read","confluence.create_page":"write","hubspot.list_contacts":"read","hubspot.get_contact":"read","hubspot.create_contact":"write","hubspot.list_deals":"read","files.list":"read","files.read":"read","files.search":"read","apitools.webSearch":"read","apitools.fetchUrl":"read","apitools.news":"read","apitools.weather":"read","apitools.stockQuote":"read","apitools.calculate":"read","memory.save":"write","memory.search":"read","memory.list":"read","memory.delete":"write"},We=["create","send","write","delete","update","post","remove","save","put","patch"];function E(n){if(ge[n])return ge[n];const m=n.toLowerCase();return We.some(i=>m.includes(i))?"write":"read"}const Fe={scheduleType:"daily",intervalMinutes:60,dailyAtHour:9,dailyAtMinute:0,hourlyAtMinute:0,prompt:""},Ge=[{provider:"gemini",model:"gemini-2.5-flash",label:"Gemini 2.5 Flash"},{provider:"gemini",model:"gemini-2.5-pro",label:"Gemini 2.5 Pro"},{provider:"openai",model:"gpt-4o",label:"GPT-4o"},{provider:"openai",model:"gpt-4o-mini",label:"GPT-4o Mini"},{provider:"anthropic",model:"claude-sonnet-4-5-20250929",label:"Claude Sonnet 4.5"},{provider:"anthropic",model:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5"}],Ue="gemini-2.5-flash",qe=["🤖","🧠","⚡","🔍","📊","📝","🛡️","🔔","📬","🗂️","💬","🌐","🧹","📈","🎯","🚀"],Je=new Set(["memory","starter"]),Ye=new Set(["apitools"]),Ke={github:{label:"GitHub",icon:"⚙️",desc:"Repos, code & issues"},slack:{label:"Slack",icon:"💬",desc:"Messages & channels"},jira:{label:"Jira",icon:"📋",desc:"Issues & projects"},google:{label:"Google",icon:"📧",desc:"Gmail, Calendar, Drive & YouTube"},salesforce:{label:"Salesforce",icon:"☁️",desc:"CRM queries & records"},notion:{label:"Notion",icon:"📓",desc:"Pages & databases"},linear:{label:"Linear",icon:"📐",desc:"Issues & projects"},confluence:{label:"Confluence",icon:"📖",desc:"Pages & spaces"},hubspot:{label:"HubSpot",icon:"🔶",desc:"Contacts & deals"},spotify:{label:"Spotify",icon:"🎵",desc:"Music, playlists & playback"},todoist:{label:"Todoist",icon:"✅",desc:"Tasks & projects"},microsoft:{label:"Microsoft 365",icon:"📎",desc:"Email, calendar & OneDrive"},discord:{label:"Discord",icon:"🎮",desc:"Servers, channels & messages"},strava:{label:"Strava",icon:"🏃",desc:"Activities & fitness stats"},reddit:{label:"Reddit",icon:"🔗",desc:"Subreddits & saved posts"},airtable:{label:"Airtable",icon:"📊",desc:"Bases, tables & records"},trello:{label:"Trello",icon:"📌",desc:"Boards, lists & cards"},files:{label:"Your Files",icon:"📁",desc:"Read & search uploads"},demo:{label:"Demo CRM",icon:"🧪",desc:"Sample business data"},"demo-sales":{label:"Demo Sales",icon:"🧪",desc:"Sample sales data"},"demo-logistics":{label:"Demo Logistics",icon:"🧪",desc:"Sample shipping data"},"demo-manufacturing":{label:"Demo Manufacturing",icon:"🧪",desc:"Sample factory data"}},Qe={"apitools.webSearch":{label:"Web Search",icon:"🔍",desc:"Search the internet"},"apitools.fetchUrl":{label:"Read Websites",icon:"🌐",desc:"Fetch & extract page content"},"apitools.news":{label:"News",icon:"📰",desc:"Recent news by topic"},"apitools.weather":{label:"Weather",icon:"🌤️",desc:"Current weather by city"},"apitools.stockQuote":{label:"Stock Quotes",icon:"📈",desc:"Real-time stock prices"},"apitools.calculate":{label:"Calculator",icon:"🧮",desc:"Math & expressions"}},ue=["apitools.webSearch","apitools.fetchUrl","apitools.news","apitools.weather","a
1pitools.stockQuote","apitools.calculate","github","slack","google","jira","salesforce","notion","linear","confluence","hubspot","spotify","todoist","microsoft","discord","strava","reddit","airtable","trello","files","demo","demo-sales","demo-logistics","demo-manufacturing"];function nt(){return e.jsx(Ie,{children:e.jsx(Ve,{})})}function Ve(){const{user:n}=Ne(),{activeTenant:m}=Be(),i=m?.slug??"",g=Pe(),{agentId:v}=Ee(),[h]=De(),[f,D]=d.useState(""),[O,H]=d.useState(!1),[L,R]=d.useState(null),[W,F]=d.useState(!1),[he,T]=d.useState(!1),[k,G]=d.useState(!1),[U,fe]=d.useState([]),[q,me]=d.useState([]),[A,J]=d.useState(""),[be,ye]=d.useState(new Set),[a,c]=d.useState({name:"",description:"",icon:"🤖",model:"",systemPrompt:"",enabledTools:[],trigger:"manual"}),[Y,K]=d.useState([]),[Q,V]=d.useState(!1),[z,xe]=d.useState(null),[X,Z]=d.useState(!1),[ee,I]=d.useState(null),[ve,te]=d.useState(new Set),[M,Se]=d.useState(""),[oe,se]=d.useState(!1),[ae,N]=d.useState(null),[$,ne]=d.useState(null),[S,ie]=d.useState(null),b=!!v&&v!=="new";d.useEffect(()=>{if(!i)return;let t=!1;async function o(){const s=await n.getIdToken(),[l,r]=await Promise.allSettled([fetch(`${x(i)}/chat/config`,{headers:{Authorization:`Bearer ${s}`}}),fetch(`${x(i)}/chat/tools`,{headers:{Authorization:`Bearer ${s}`}})]);let u=[],_=Ue;if(l.status==="fulfilled"&&l.value.ok){const p=await l.value.json();p.config?.models?.length&&(u=p.config.models,p.config.defaultModel&&(_=p.config.defaultModel))}if(u.length===0&&(u=Ge),r.status==="fulfilled"&&r.value.ok){const p=await r.value.json();!t&&p.tools&&me(p.tools)}if(t||(fe(u),c(p=>p.model?p:{...p,model:_})),b){const p=await fetch(`${x(i)}/chat/agent-profiles/${v}`,{headers:{Authorization:`Bearer ${s}`}});if(p.ok){const y=await p.json();if(!t&&y.profile){const j=y.profile.heartbeat;c({name:y.profile.name??"",description:y.profile.description??"",icon:y.profile.icon??"🤖",model:y.profile.model??"",systemPrompt:y.profile.systemPrompt??"",enabledTools:y.profile.enabledTools??[],trigger:j?.enabled?"heartbeat":"manual",heartbeatConfig:j?.enabled?{scheduleType:j.scheduleType??"interval",intervalMinutes:j.intervalMinutes??60,dailyAtHour:j.dailyAtHour??9,dailyAtMinute:j.dailyAtMinute??0,hourlyAtMinute:j.hourlyAtMinute??0,prompt:j.prompt??""}:void 0})}}}const ce=h.get("fromConv");if(ce){const p=await fetch(`${x(i)}/chat/conversations/${ce}`,{headers:{Authorization:`Bearer ${s}`}});if(p.ok){const y=await p.json();!t&&y.conversation&&D(`Create an agent based on this conversation: "${y.conversation.title||"Untitled"}". It should be able to handle similar requests.`)}}}return o().catch(console.error),()=>{t=!0}},[i,v]),d.useEffect(()=>{if(!i||!f.trim()||f.length<10){K([]);return}const t=setTimeout(async()=>{V(!0);try{const o=await n.getIdToken(),s=await fetch(`${x(i)}/skills/search?q=${encodeURIComponent(f.slice(0,100))}&limit=4`,{headers:{Authorization:`Bearer ${o}`}});if(s.ok){const l=await s.json();K(l.skills??[])}}catch{}V(!1)},800);return()=>clearTimeout(t)},[i,f]),d.useEffect(()=>{if(!b&&h.get("prefill")==="1")try{const t=localStorage.getItem("acp:agentDraft");if(!t)return;const o=JSON.parse(decodeURIComponent(escape(atob(t))));c(s=>({...s,name:o.name??s.name,description:o.description??s.description,icon:o.icon??s.icon,model:o.model??s.model,systemPrompt:o.systemPrompt??s.systemPrompt,enabledTools:o.enabledTools??s.enabledTools,trigger:o.trigger??s.trigger,heartbeatConfig:o.heartbeatConfig?{scheduleType:o.heartbeatConfig.intervalMinutes>=1440?"daily":o.heartbeatConfig.intervalMinutes>=60?"hourly":"interval",intervalMinutes:o.heartbeatConfig.intervalMinutes??60,dailyAtHour:9,dailyAtMinute:0,hourlyAtMinute:0,prompt:o.heartbeatConfig.prompt??""}:s.heartbeatConfig})),localStorage.removeItem("acp:agentDraft")}catch{}},[b,h]);async function je(t){c(o=>({...o,name:t.name||o.name,description:t.description||o.description,icon:t.icon||o.icon,systemPrompt:t.instructions||o.systemPrompt}))}const Ce=q.reduce((t,o)=>((t[o.category]??=[]).push(o),t),{}),C=[];for(const[t,o]of Object.entries(Ce))if(!Je.has(t))if(Ye.has(t))for(const s of o){const l=Qe[s.name];C.push({id:s.name,label:l?.label??B(s.name),icon:l?.icon??"🔧",desc:l?.desc??s.description??"",toolNames:[s.name]})}else{const s=Ke[t];C.push({id:`cat:${t}`,label:s?.label??t,icon:s?.icon??"🔧",desc:s?.desc??`${o.length}
1 tools`,toolNames:o.map(l=>l.name)})}C.sort((t,o)=>{const s=t.id.startsWith("cat:")?t.id.slice(4):t.id,l=o.id.startsWith("cat:")?o.id.slice(4):o.id,r=ue.indexOf(s),u=ue.indexOf(l);return(r===-1?999:r)-(u===-1?999:u)});const w=A.toLowerCase(),le=w?C.filter(t=>t.label.toLowerCase().includes(w)||t.desc.toLowerCase().includes(w)||t.toolNames.some(o=>o.toLowerCase().includes(w)||B(o).toLowerCase().includes(w))):C,re=C.filter(t=>t.toolNames.some(o=>a.enabledTools.includes(o)));function we(t){c(o=>({...o,enabledTools:o.enabledTools.includes(t)?o.enabledTools.filter(s=>s!==t):[...o.enabledTools,t]}))}function Te(t){const o=t.toolNames.every(s=>a.enabledTools.includes(s));c(s=>({...s,enabledTools:o?s.enabledTools.filter(l=>!t.toolNames.includes(l)):[...new Set([...s.enabledTools,...t.toolNames])]}))}function ke(t){c(o=>({...o,enabledTools:o.enabledTools.filter(s=>!t.toolNames.includes(s))}))}async function Ae(){if(f.trim()){H(!0),R(null);try{const t=await n.getIdToken(),o=await fetch(`${x(i)}/chat/agent-builder/parse`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({description:f})});if(o.ok){const s=await o.json();s.config&&c(l=>({...l,...s.config,model:s.config.model||l.model}))}else{const s=await o.json().catch(()=>({}));R(s.error??`Builder failed (${o.status})`)}}catch(t){R(t?.message??"Builder failed")}H(!1)}}async function ze(){if(a.name.trim()){F(!0);try{const t=await n.getIdToken(),o=a.heartbeatConfig,s={name:a.name,description:a.description,icon:a.icon,model:a.model,systemPrompt:a.systemPrompt,enabledTools:a.enabledTools,heartbeat:a.trigger==="heartbeat"&&o?{enabled:!0,scheduleType:o.scheduleType,intervalMinutes:o.intervalMinutes,dailyAtHour:o.dailyAtHour,dailyAtMinute:o.dailyAtMinute,hourlyAtMinute:o.hourlyAtMinute,prompt:o.prompt}:null},l=b?`${x(i)}/chat/agent-profiles/${v}`:`${x(i)}/chat/agent-profiles`;(await fetch(l,{method:b?"PUT":"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(s)})).ok&&(b||(Oe(a.name),a.trigger==="heartbeat"&&o&&He(o.scheduleType)),g("/home"))}catch(t){console.error("Save failed:",t)}F(!1)}}async function Me(){if(!(!a.name.trim()||!a.model)){Z(!0),I(null);try{const t=await n.getIdToken(),o=a.heartbeatConfig,s={name:a.name,description:a.description,icon:a.icon,model:a.model,systemPrompt:a.systemPrompt,enabledTools:a.enabledTools,heartbeat:a.trigger==="heartbeat"&&o?{enabled:!0,scheduleType:o.scheduleType,intervalMinutes:o.intervalMinutes,dailyAtHour:o.dailyAtHour,dailyAtMinute:o.dailyAtMinute,hourlyAtMinute:o.hourlyAtMinute,prompt:o.prompt}:null},l=await fetch(`${x(i)}/chat/codegen`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({profile:s})});if(l.ok){const r=await l.json();xe(r.files??[]);const u=new Set;(r.files??[]).find(_=>_.path==="src/index.ts")&&u.add("src/index.ts"),te(u)}else{const r=await l.json().catch(()=>({}));I(r.error??`Codegen failed (${l.status})`)}}catch(t){I(t?.message??"Codegen failed")}finally{Z(!1)}}}function $e(t){te(o=>{const s=new Set(o);return s.has(t)?s.delete(t):s.add(t),s})}async function _e(){if(!(!M.trim()||!a.name.trim()||!a.model)){se(!0),N(null),ne(null),ie(null);try{const t=await n.getIdToken(),o=a.heartbeatConfig,s={name:a.name,description:a.description,icon:a.icon,model:a.model,systemPrompt:a.systemPrompt,enabledTools:a.enabledTools,heartbeat:a.trigger==="heartbeat"&&o?{enabled:!0,scheduleType:o.scheduleType,intervalMinutes:o.intervalMinutes,dailyAtHour:o.dailyAtHour,dailyAtMinute:o.dailyAtMinute,hourlyAtMinute:o.hourlyAtMinute,prompt:o.prompt}:null},l=await fetch(`${x(i)}/chat/codegen/test-run`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({profile:s,prompt:M})});if(l.ok){const r=await l.json();ne(r.trace??[]),ie({ok:!!r.ok,finalOutput:r.finalOutput??null,rounds:r.rounds??0})}else{const r=await l.json().catch(()=>({}));N(r.error??`Test run failed (${l.status})`)}}catch(t){N(t?.message??"Test run failed")}finally{se(!1)}}}async function Re(){if(b){G(!0);try{const t=await n.getIdToken();(await fetch(`${x(i)}/chat/agent-profiles/${v}`,{method:"DELETE",headers:{Authorization:`Bearer ${t}`}})).ok&&g("/u/agents")}catch(t){console.error("Delete failed:",t)}G(!1),T(!1)}}const de=a.enabledTools.length;return e.jsxs("div",{style:{maxWidth:1100,margin:"0 auto",padding:"32px 24px"},children:[e.jsx("h1",{className:"gs-h1",style:{marginBottom:24},children:b?"Edit Agent":"Create Agent"}
1),e.jsxs("div",{className:b?"":"gs-agent-builder-grid",children:[!b&&e.jsxs("div",{className:"gs-card gs-card-pad",children:[e.jsx("h2",{className:"gs-h2",style:{marginBottom:12},children:"Describe your agent"}),e.jsx("p",{style:{fontSize:13,color:"var(--gs-text-dim)",marginBottom:12,lineHeight:1.5},children:"Tell us what you want your agent to do in plain language, and we'll configure it for you."}),e.jsx("textarea",{className:"gs-textarea",value:f,onChange:t=>D(t.target.value),placeholder:"e.g., Monitor our GitHub repos for new issues with the 'urgent' label and post a summary to Slack every morning...",rows:8,style:{resize:"vertical",fontFamily:"inherit",fontSize:14,marginBottom:12}}),e.jsx("button",{className:"gs-btn gs-btn-primary",onClick:Ae,disabled:O||!f.trim(),style:{width:"100%"},children:O?"Building...":"Build from description"}),L&&e.jsx("div",{style:{marginTop:8,color:"var(--gs-danger, #dc2626)",fontSize:12,padding:"8px 10px",background:"rgba(220, 38, 38, 0.06)",borderRadius:6,lineHeight:1.4},children:L}),(Y.length>0||Q)&&e.jsxs("div",{style:{marginTop:16},children:[e.jsx("h3",{style:{fontSize:13,fontWeight:600,color:"var(--gs-text-dim)",marginBottom:8},children:"Suggested Skills"}),Q?e.jsx("div",{style:{fontSize:12,color:"var(--gs-text-faint)",padding:8},children:"Searching skills..."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:Y.map(t=>e.jsxs("button",{onClick:()=>je(t),style:{background:"var(--gs-bg-elev)",border:"1px solid var(--gs-border)",borderRadius:8,padding:"8px 12px",textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:18,flexShrink:0},children:t.icon??"🔧"}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--gs-text)"},children:t.name}),e.jsx("div",{style:{fontSize:11,color:"var(--gs-text-faint)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.description?.slice(0,80)})]})]},t.id))}),e.jsx("div",{style:{fontSize:10,color:"var(--gs-text-faint)",marginTop:6},children:"Click a skill to apply its configuration"})]})]}),e.jsx(Le,{storageKey:"agent-builder-intro",children:"Agents are AI assistants that can use your connected tools. Give it a name, choose what it can do, and optionally set a schedule to run automatically."}),e.jsxs("div",{className:"gs-card gs-card-pad",children:[e.jsx("h2",{className:"gs-h2",style:{marginBottom:12},children:"Agent Configuration"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("div",{style:{flex:0},children:[e.jsx("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:"Icon"}),e.jsx(Xe,{value:a.icon,onChange:t=>c(o=>({...o,icon:t}))})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:"Name"}),e.jsx("input",{className:"gs-input",value:a.name,onChange:t=>c(o=>({...o,name:t.target.value})),placeholder:"Agent name"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:"Description"}),e.jsx("input",{className:"gs-input",value:a.description,onChange:t=>c(o=>({...o,description:t.target.value})),placeholder:"What does this agent do?"})]}),U.length>1&&e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:["Model ",e.jsx(P,{text:"Different models have different strengths — larger models are more capable but slower."})]}),e.jsxs("select",{className:"gs-input",value:a.model,onChange:t=>c(o=>({...o,model:t.target.value})),children:[e.jsx("option",{value:"",children:"Select a model"}),U.map(t=>e.jsx("option",{value:t.model,children:t.label},t.model))]})]}),e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:["Agent Instructions ",e.jsx(P,{text:"Tell the AI how to behave, what tone to use, and what rules to follow."})]}),e.jsx("textarea",{className:"gs-textarea",value:a.systemPrompt,onChange:t=>c(o=>({...o,systemPrompt:t.target.value})),placeholder:"Instructions for the agent...",rows:12,style:{resize:"vertical",fontFamily:"inherit",fontSize:13,minHeight:180}})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},children:[e.jsxs("label",{style:{fontSize:12,color:"var(--gs-text-dim)"},children:["Tools ",e.jsx(P,{text:"Tools are the actions your agent can take — like reading files, sending messages, or querying data."})]}),e.jsx("span",{style:{fontSize:11,color:"var(--gs-text-faint)"},children:de===0?"None selected":(()=>{const t=a.enabledTools.filter(s=>E(s)==="read").length,o=a.enabledTools.filter(s=>E(s)==="write").length;return`${t} read, ${o} write tool${de===1?"":"s"} selected`})()})]}),e.jsxs("div",{style:{position:"relative",marginBottom:8},children:[e.jsx("input",{className:"gs-input",value:A,onChange:t=>J(t.target.value),placeholder:"Search tools...",style:{fontSize:13,paddingRight:28}}),A&&e.jsx("button",{onClick:()=>J(""),style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:"var(--gs-text-faint)",fontSize:14,lineHeight:1,padding:0},children:"×"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:6,maxHeight:260,overflowY:"auto",padding:2},children:q.length===0?e.jsx("div",{style:{gridColumn:"1 / -1",textAlign:"center",color:"var(--gs-text-faint)",fontSize:13,padding:16},children:"Loading tools..."}):le.length===0?e.jsxs("div",{style:{gridColumn:"1 / -1",textAlign:"center",color:"var(--gs-text-faint)",fontSize:12,padding:12},children:['No tools match "',A,'"']}):le.map(t=>{const o=t.toolNames.some(s=>a.enabledTools.includes(s));return e.jsxs("button",{onClick:()=>Te(t),style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:"10px 6px",borderRadius:8,border:o?"1.5px solid var(--gs-accent)":"1px solid var(--gs-border)",background:o?"rgba(124,58,237,0.06)":"var(--gs-bg-elev)",cursor:"pointer",transition:"border-color 0.15s, background 0.15s",minHeight:64},children:[e.jsx("span",{style:{fontSize:22,lineHeight:1},children:t.icon}),e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--gs-text)",lineHeight:1.2,textAlign:"center"},children:t.label}
1),e.jsx("span",{style:{fontSize:10,color:"var(--gs-text-faint)",lineHeight:1.2,textAlign:"center"},children:t.desc}),t.toolNames.length===1&&e.jsx(pe,{toolName:t.toolNames[0]})]},t.id)})}),re.length>0&&e.jsxs("div",{style:{marginTop:12},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--gs-text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"Selected Tools"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:re.map(t=>{const o=t.toolNames.length>1,s=be.has(t.id),l=t.toolNames.filter(r=>a.enabledTools.includes(r)).length;return e.jsxs("div",{style:{border:"1px solid var(--gs-border)",borderRadius:8,background:"var(--gs-bg-elev)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"8px 10px",cursor:o?"pointer":"default"},onClick:()=>{o&&ye(r=>{const u=new Set(r);return u.has(t.id)?u.delete(t.id):u.add(t.id),u})},children:[o&&e.jsx("span",{style:{fontSize:10,color:"var(--gs-text-faint)",transform:s?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",lineHeight:1},children:"▶"}),e.jsx("span",{style:{fontSize:16,lineHeight:1},children:t.icon}),e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--gs-text)",flex:1},children:t.label}),o&&e.jsxs("span",{style:{fontSize:10,color:"var(--gs-accent)",fontWeight:600,background:"rgba(124,58,237,0.08)",borderRadius:4,padding:"2px 6px"},children:[l," / ",t.toolNames.length]}),e.jsx("button",{onClick:r=>{r.stopPropagation(),ke(t)},style:{background:"none",border:"none",cursor:"pointer",color:"var(--gs-text-faint)",fontSize:14,lineHeight:1,padding:"0 2px"},title:"Remove",children:"×"})]}),o&&s&&e.jsx("div",{style:{borderTop:"1px solid var(--gs-border)",padding:"8px 10px"},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"4px 12px"},children:t.toolNames.map(r=>{const u=a.enabledTools.includes(r);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",padding:"3px 0"},children:[e.jsx("button",{onClick:()=>we(r),style:{width:28,height:16,borderRadius:8,border:"none",cursor:"pointer",padding:0,background:u?"var(--gs-accent)":"var(--gs-border-strong)",position:"relative",flexShrink:0,transition:"background 0.15s"},children:e.jsx("span",{style:{position:"absolute",top:2,left:u?14:2,width:12,height:12,borderRadius:"50%",background:"#fff",transition:"left 0.15s"}})}),e.jsx("span",{style:{fontSize:12,color:"var(--gs-text)",fontWeight:500},children:B(r)}),e.jsx(pe,{toolName:r})]},r)})})})]},t.id)})})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:"Trigger"}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{className:`gs-btn ${a.trigger==="manual"?"gs-btn-primary":""}`,onClick:()=>c(t=>({...t,trigger:"manual",heartbeatConfig:void 0})),style:{flex:1,fontSize:13},children:"Manual"}),e.jsx("button",{className:`gs-btn ${a.trigger==="heartbeat"?"gs-btn-primary":""}`,onClick:()=>c(t=>({...t,trigger:"heartbeat",heartbeatConfig:t.heartbeatConfig||{...Fe}})),style:{flex:1,fontSize:13},children:"Scheduled"})]})]}),a.trigger==="heartbeat"&&a.heartbeatConfig&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:12,background:"var(--gs-bg-elev)",borderRadius:10},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:"Frequency"}),e.jsx("div",{style:{display:"flex",gap:6},children:[["daily","Daily"],["hourly","Hourly"],["interval","Custom"]].map(([t,o])=>e.jsx("button",{className:`gs-btn ${a.heartbeatConfig.scheduleType===t?"gs-btn-primary":""}`,onClick:()=>c(s=>({...s,heartbeatConfig:{...s.heartbeatConfig,scheduleType:t}})),style:{flex:1,fontSize:12,padding:"6px 10px"},children:o},t))})]}),a.heartbeatConfig.scheduleType==="daily"&&e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:"Run every day at (UTC)"}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("select",{className:"gs-input",value:a.heartbeatConfig.dailyAtHour,onCh
1ange:t=>c(o=>({...o,heartbeatConfig:{...o.heartbeatConfig,dailyAtHour:parseInt(t.target.value)}})),style:{width:80,fontSize:13},children:Array.from({length:24},(t,o)=>e.jsx("option",{value:o,children:o===0?"12 AM":o<12?`${o} AM`:o===12?"12 PM":`${o-12} PM`},o))}),e.jsx("span",{style:{fontSize:13,color:"var(--gs-text-dim)"},children:":"}),e.jsx("select",{className:"gs-input",value:a.heartbeatConfig.dailyAtMinute,onChange:t=>c(o=>({...o,heartbeatConfig:{...o.heartbeatConfig,dailyAtMinute:parseInt(t.target.value)}})),style:{width:70,fontSize:13},children:[0,5,10,15,20,25,30,35,40,45,50,55].map(t=>e.jsx("option",{value:t,children:String(t).padStart(2,"0")},t))})]})]}),a.heartbeatConfig.scheduleType==="hourly"&&e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:"Run every hour at (UTC)"}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("span",{style:{fontSize:13,color:"var(--gs-text-dim)"},children:":"}),e.jsx("select",{className:"gs-input",value:a.heartbeatConfig.hourlyAtMinute,onChange:t=>c(o=>({...o,heartbeatConfig:{...o.heartbeatConfig,hourlyAtMinute:parseInt(t.target.value)}})),style:{width:70,fontSize:13},children:[0,5,10,15,20,25,30,35,40,45,50,55].map(t=>e.jsx("option",{value:t,children:String(t).padStart(2,"0")},t))}),e.jsx("span",{style:{fontSize:12,color:"var(--gs-text-faint)"},children:"minutes past"})]})]}),a.heartbeatConfig.scheduleType==="interval"&&e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:"Run every"}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"gs-input",type:"number",min:5,value:a.heartbeatConfig.intervalMinutes,onChange:t=>c(o=>({...o,heartbeatConfig:{...o.heartbeatConfig,intervalMinutes:parseInt(t.target.value)||60}})),style:{width:80,fontSize:13}}),e.jsx("span",{style:{fontSize:12,color:"var(--gs-text-faint)"},children:"minutes"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:"var(--gs-text-dim)",display:"block",marginBottom:4},children:"What should the agent do each run?"}),e.jsx("textarea",{className:"gs-textarea",value:a.heartbeatConfig.prompt,onChange:t=>c(o=>({...o,heartbeatConfig:{...o.heartbeatConfig,prompt:t.target.value}})),placeholder:"What should the agent do on each run?",rows:2,style:{resize:"vertical",fontFamily:"inherit",fontSize:13}})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[b&&e.jsx("button",{className:"gs-btn",onClick:()=>T(!0),style:{fontSize:13,color:"var(--gs-danger, #dc2626)",border:"1px solid var(--gs-danger, #dc2626)",background:"transparent"},children:"Delete"}),e.jsx("button",{className:"gs-btn gs-btn-primary",onClick:ze,disabled:W||!a.name.trim()||!a.model,style:{flex:1},children:W?"Saving...":b?"Update Agent":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"gs-card gs-card-pad",style:{marginTop:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[e.jsx("h2",{className:"gs-h2",style:{margin:0},children:"Preview Generated Code"}),e.jsx("button",{className:"gs-btn",onClick:Me,disabled:X||!a.name.trim()||!a.model,style:{fontSize:13},children:X?"Generating...":z?"Regenerate":"Generate"})]}),e.jsxs("p",{style:{fontSize:13,color:"var(--gs-text-dim)",marginBottom:12,lineHeight:1.5},children:["A standalone TypeScript project — Express + Anthropic SDK. Every tool call is wrapped in"," ",e.jsx("code",{style:{fontSize:12},children:"@agenticcontrolplane/governance-anthropic"})," for policy + audit. MIT-licensed; this code is yours."]}),ee&&e.jsx("div",{style:{color:"var(--gs-danger, #dc2626)",fontSize:13,marginBottom:8,padding:"8px 10px",background:"rgba(220, 38, 38, 0.06)",borderRadius:6},children:ee}),z&&z.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:z.map(t=>{const o=ve.has(t.path),s=t.contents.split(`
2`).length;return e.jsxs("div",{style:{border:"1px solid var(--gs-border)",borderRadius:8,overflow:"hidden"},children:[e.jsxs("button",{onClick:()=>$e(t.path),style:{width:"100%",textAlign:"left",padding:"8px 12px",background:"var(--gs-bg-elev)",border:"none",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:8,color:"var(--gs-text)"}
2,children:[e.jsx("span",{style:{fontSize:10,color:"var(--gs-text-faint)",transform:o?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",lineHeight:1,display:"inline-block"},children:"▶"}),e.jsx("span",{style:{fontWeight:600},children:t.path}),e.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--gs-text-faint)"},children:[s," line",s===1?"":"s"]})]}),o&&e.jsx("pre",{style:{margin:0,padding:"12px 14px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,lineHeight:1.5,overflowX:"auto",whiteSpace:"pre",borderTop:"1px solid var(--gs-border)",background:"var(--gs-bg)",color:"var(--gs-text)"},children:t.contents})]},t.path)})})]}),e.jsxs("div",{className:"gs-card gs-card-pad",style:{marginTop:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[e.jsx("h2",{className:"gs-h2",style:{margin:0},children:"Test Run"}),e.jsx("button",{className:"gs-btn gs-btn-primary",onClick:_e,disabled:oe||!M.trim()||!a.name.trim()||!a.model,style:{fontSize:13},children:oe?"Running...":"Run"})]}),e.jsx("p",{style:{fontSize:13,color:"var(--gs-text-dim)",marginBottom:12,lineHeight:1.5},children:"Run the agent in-process against a synthetic prompt — same governance pipeline as production, no persistence. Use this to verify behavior before deploying."}),e.jsx("textarea",{className:"gs-textarea",value:M,onChange:t=>Se(t.target.value),placeholder:"Synthetic prompt — e.g. 'List the last 5 issues in the foo/bar repo'",rows:3,style:{resize:"vertical",fontFamily:"inherit",fontSize:13,marginBottom:12}}),ae&&e.jsx("div",{style:{color:"var(--gs-danger, #dc2626)",fontSize:13,marginBottom:8,padding:"8px 10px",background:"rgba(220, 38, 38, 0.06)",borderRadius:6},children:ae}),S&&e.jsxs("div",{style:{fontSize:13,padding:"10px 12px",marginBottom:12,background:S.ok?"rgba(34, 197, 94, 0.06)":"rgba(220, 38, 38, 0.06)",border:`1px solid ${S.ok?"rgba(34, 197, 94, 0.3)":"rgba(220, 38, 38, 0.3)"}`,borderRadius:8},children:[e.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:[S.ok?"✓ Completed":"✗ Failed"," in ",S.rounds," round",S.rounds===1?"":"s"]}),S.finalOutput&&e.jsx("div",{style:{whiteSpace:"pre-wrap",color:"var(--gs-text)",fontSize:13},children:S.finalOutput})]}),$&&$.length>0&&e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:10,fontWeight:700,color:"var(--gs-text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:["Trace (",$.length," events)"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:$.map((t,o)=>e.jsx(et,{event:t},o))})]})]}),he&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.4)",backdropFilter:"blur(2px)"},onClick:()=>!k&&T(!1)}),e.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:101,width:"100%",maxWidth:400,background:"var(--gs-surface)",border:"1px solid var(--gs-border)",borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.15)",padding:"24px"},children:[e.jsxs("div",{style:{fontSize:16,fontWeight:600,marginBottom:8},children:['Delete "',a.name||"this agent",'"?']}),e.jsx("p",{style:{fontSize:14,color:"var(--gs-text-dim)",marginBottom:20,lineHeight:1.5},children:"This will permanently delete the agent and its configuration. This action cannot be undone."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{className:"gs-btn gs-btn-ghost",onClick:()=>T(!1),disabled:k,style:{fontSize:13},children:"Cancel"}),e.jsx("button",{className:"gs-btn",onClick:Re,disabled:k,style:{fontSize:13,background:"var(--gs-danger, #dc2626)",color:"#fff",border:"none"},children:k?"Deleting...":"Delete Agent"})]})]})]})]})}function pe({toolName:n}){const m=E(n),i=m==="write";return e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",borderRadius:4,fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.03em",background:i?"#fffbeb":"#f0f4ff",color:i?"#b45309":"#4b6baf",border:`1px solid ${i?"#fde68a":"#dbeafe"}`,flexShrink:0},children:m})}function Xe({value:n,onChange:m}){const[i,g]=d.useState(!1),v=d.useRef(null);return d.useEffect(()=>{if(!i)return;function h(f){v.current&&!v.current.contains(f.target)&&g(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[i]),e.jsxs("div",{ref:v,style:{position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>g(h=>!h),className:"gs-input",style:{width:48,height:38,display:"flex",alignItems:"center",justifyContent:"center",fontSize:20,cursor:"pointer",padding:0},children:n}),i&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"var(--gs-surface)",border:"1px solid var(--gs-border)",borderRadius:8,padding:6,display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2,boxShadow:"0 4px 12px rgba(0,0,0,0.1)"},children:qe.map(h=>e.jsx("button",{type:"button",onClick:()=>{m(h),g(!1)},style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",fontSize:20,border:"none",borderRadius:6,cursor:"pointer",background:h===n?"rgba(124, 58, 237, 0.1)":"transparent",transition:"background 80ms ease"},onMouseEnter:f=>f.currentTarget.style.background="rgba(124, 58, 237, 0.08)",onMouseLeave:f=>f.currentTarget.style.background=h===n?"rgba(124, 58, 237, 0.1)":"transparent",children:h},h))})]})}const Ze={agent_start:{label:"start",icon:"🚀",color:"#7c3aed"},llm_request:{label:"→ llm",icon:"📤",color:"#6b7280"},llm_response:{label:"← llm",icon:"💬",color:"#3b82f6"},tool_call:{label:"tool",icon:"🔧",color:"#0ea5e9"},governance:{label:"gov",icon:"🛡️",color:"#f59e0b"},tool_result:{label:"result",icon:"✓",color:"#22c55e"},agent_done:{label:"done",icon:"🏁",color:"#22c55e"},agent_error:{label:"error",icon:"✗",color:"#dc2626"}};function et({event:n}){const m=Ze[n.type]??{label:n.type,icon:"•",color:"#6b7280"};let i="";if(n.type==="agent_start"){const g=n.toolsAvailable??[];i=`model: ${n.model}${g.length?`, tools: ${g.join(", ")}`:", no tools"}`}else if(n.type==="llm_request")i=`round ${n.round}, ${n.messagesCount} message${n.messagesCount===1?"":"s"}`;else if(n.type==="llm_response"){const g=(n.text??"").trim();i=`round ${n.round}${n.toolCallsCount?`, ${n.toolCallsCount} tool call${n.toolCallsCount===1?"":"s"}`:""}${g?`: ${g.slice(0,200)}`:""}`}else if(n.type==="tool_call"){const g=typeof n.input=="string"?n.input
2:JSON.stringify(n.input);i=`${n.tool}(${g.length>200?g.slice(0,200)+"…":g})`}else if(n.type==="governance")i=`${n.tool} → ${n.decision}${n.layer?` [${n.layer}]`:""}${n.reason?`: ${n.reason}`:""}`;else if(n.type==="tool_result"){const g=(n.output??"").slice(0,300);i=`${n.tool}${n.ok?"":" (failed)"} in ${n.durationMs}ms: ${g}`}else n.type==="agent_done"?i=`${n.rounds} round${n.rounds===1?"":"s"}, tokens: ${n.promptTokens} in / ${n.completionTokens} out`:n.type==="agent_error"&&(i=n.error??"unknown error");return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,padding:"6px 10px",borderLeft:`3px solid ${m.color}`,background:"var(--gs-bg-elev)",borderRadius:4,fontSize:12,lineHeight:1.4},children:[e.jsx("span",{style:{flexShrink:0,width:18,textAlign:"center"},children:m.icon}),e.jsx("span",{style:{flexShrink:0,fontWeight:600,color:m.color,fontSize:10,textTransform:"uppercase",letterSpacing:"0.04em",minWidth:56,paddingTop:2},children:m.label}),e.jsx("span",{style:{flex:1,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"var(--gs-text)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i})]})}export{nt as AgentBuilderPage};

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.