markdown-agent-studio 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -84,7 +84,7 @@ ${JSON.stringify(Ae.resultSchema,null,2)}`);const He=Oe+De,Je={authorAgentId:a.c
|
|
|
84
84
|
|
|
85
85
|
`+He)}catch{}for(let Je=0;Je<25;Je++){let Ke="",We=!1;hasRegisterSession(this.deps.aiProvider)&&this.deps.aiProvider.registerSession(r.id,r.agentId);const mt=this.deps.aiProvider.chat({sessionId:r.id,systemPrompt:He,model:this.resolveSessionModel(ke.model)},Ce.history,Te.toToolDefinitions());for await(const ot of mt){if(a.signal.aborted){Ce.status="aborted";break}switch(this.deps.onStreamChunk?.(r.agentId,ot),this.deps.sessionStore?.getState().appendChunk(r.id,ot),ot.type){case"text":Ke+=ot.text??"";break;case"tool_call":{if(this._paused&&(await this.waitForResume(a.signal),a.signal.aborted)){Ce.status="aborted";break}We=!0;const ht=ot.toolCall,pt=await Oe.handle(ht.name,ht.args),rt={id:ht.id,name:ht.name,args:ht.args,result:pt,timestamp:Date.now()};if(Ce.toolCalls.push(rt),Ce.history.push({role:"tool",content:pt,toolCall:rt}),this.deps.sessionStore?.getState().addToolResult(r.id,rt.id,rt.name,rt.args,rt.result),ht.name==="spawn_agent"){const at=this.childCounts.get(r.agentId)??0;this.childCounts.set(r.agentId,at+1)}break}case"done":ot.tokenCount&&(Ce.tokenCount+=ot.tokenCount,this._totalTokens+=ot.tokenCount);break;case"error":Ce.status="error";{const ht=ot.error??"Unknown stream error";this.isQuotaError(ht)&&this.haltForQuota(r,ht)}this.deps.eventLog.getState().append({type:"error",agentId:r.agentId,activationId:r.id,data:{error:ot.error}});break}}if(Ke&&!We&&Ce.history.push({role:"model",content:Ke}),!We||Ce.status!=="running")break;if(this._totalTokens>=this.deps.config.tokenBudget){this.haltForBudget(r,"mid-session");break}}Ce.status==="running"&&(Ce.status="completed"),this.deps.eventLog.getState().append({type:"complete",agentId:r.agentId,activationId:r.id,data:{status:Ce.status,tokens:Ce.tokenCount}})}catch(De){Ce.status="error";const He=De instanceof Error?De.message:String(De);this.isQuotaError(He)&&this.haltForQuota(r,He),this.deps.eventLog.getState().append({type:"error",agentId:r.agentId,activationId:r.id,data:{error:He}})}finally{this._completedSessions.push(Ce),this.activeSessions.delete(r.id),this.globalController.signal.removeEventListener("abort",h),this.deps.sessionStore?.getState().closeSession(r.id,Ce.status),this.deps.aiProvider.endSession?.(r.id),o(),this.deps.onSessionUpdate?.(Ce),this._paused||this.processQueue()}}async runSessionAndReturn(r){const o={...r,id:`act-${++activationCounter}`,createdAt:Date.now()},a=computeHash(`${o.agentId}:${o.input}`);return this.seenHashes.has(a)?"Error: Loop detected, skipping activation.":(this.seenHashes.add(a),this._runSessionForResult(o))}async _runSessionForResult(r){const o=new AbortController,a=()=>o.abort();this.globalController.signal.addEventListener("abort",a);const h={agentId:r.agentId,activationId:r.id,controller:o,status:"running",history:[{role:"user",content:r.input}],toolCalls:[],tokenCount:0};this.activeSessions.set(r.id,h),this.deps.onSessionUpdate?.(h),this.deps.sessionStore?.getState().openSession(r.agentId,r.id),this.deps.sessionStore?.getState().addUserMessage(r.id,r.input),this.deps.eventLog.getState().append({type:"activation",agentId:r.agentId,activationId:r.id,data:{input:r.input,depth:r.spawnDepth}});const Ce=this.deps.agentRegistry.getState().get(r.agentId);if(!Ce)return h.status="error",this._completedSessions.push(h),this.activeSessions.delete(r.id),this.globalController.signal.removeEventListener("abort",a),"Error: Agent profile not found.";let ke=this.deps.toolRegistry;if(Ce.customTools&&Ce.customTools.length>0){const De=Ce.customTools.map(createCustomToolPlugin);ke=this.deps.toolRegistry.cloneWith(De)}const Te=resolvePolicyForInput(Ce.policy,r.input),je=new ToolHandler({pluginRegistry:ke,vfs:this.deps.vfs,agentRegistry:this.deps.agentRegistry,eventLog:this.deps.eventLog,onSpawnActivation:De=>this.enqueue(De),onRunSessionAndReturn:De=>this.runSessionAndReturn(De),currentAgentId:r.agentId,currentActivationId:r.id,parentAgentId:r.parentId,spawnDepth:r.spawnDepth,maxDepth:this.deps.config.maxDepth,maxFanout:this.deps.config.maxFanout,childCount:this.childCounts.get(r.agentId)??0,policy:Te.policy,apiKey:this.deps.apiKey,preferredModel:this.resolvePreferredModel(),memoryStore:this.memoryStore});let Oe="";try{let He=Ce.systemPrompt;if(this.memoryManager&&this.deps.config.memoryEnabled!==!1)try{const Je=await this.memoryManager.buildMemoryPrompt(r.agentId,r.input);Je&&(He=Je+`
|
|
86
86
|
|
|
87
|
-
`+He)}catch{}for(let Je=0;Je<25;Je++){let Ke="",We=!1;hasRegisterSession(this.deps.aiProvider)&&this.deps.aiProvider.registerSession(r.id,r.agentId);const mt=this.deps.aiProvider.chat({sessionId:r.id,systemPrompt:He,model:this.resolveSessionModel(Ce.model)},h.history,ke.toToolDefinitions());for await(const ot of mt){if(o.signal.aborted){h.status="aborted";break}switch(this.deps.onStreamChunk?.(r.agentId,ot),this.deps.sessionStore?.getState().appendChunk(r.id,ot),ot.type){case"text":Ke+=ot.text??"";break;case"tool_call":{We=!0;const ht=ot.toolCall,pt=await je.handle(ht.name,ht.args),rt={id:ht.id,name:ht.name,args:ht.args,result:pt,timestamp:Date.now()};if(h.toolCalls.push(rt),h.history.push({role:"tool",content:pt,toolCall:rt}),this.deps.sessionStore?.getState().addToolResult(r.id,rt.id,rt.name,rt.args,rt.result),ht.name==="spawn_agent"){const at=this.childCounts.get(r.agentId)??0;this.childCounts.set(r.agentId,at+1)}break}case"done":ot.tokenCount&&(h.tokenCount+=ot.tokenCount,this._totalTokens+=ot.tokenCount);break;case"error":h.status="error",this.deps.eventLog.getState().append({type:"error",agentId:r.agentId,activationId:r.id,data:{error:ot.error}});break}}if(Ke&&!We&&(h.history.push({role:"model",content:Ke}),Oe=Ke),!We||h.status!=="running")break;if(this._totalTokens>=this.deps.config.tokenBudget){this.haltForBudget(r,"mid-session");break}}h.status==="running"&&(h.status="completed"),this.deps.eventLog.getState().append({type:"complete",agentId:r.agentId,activationId:r.id,data:{status:h.status,tokens:h.tokenCount}})}catch(De){h.status="error";const He=De instanceof Error?De.message:String(De);this.deps.eventLog.getState().append({type:"error",agentId:r.agentId,activationId:r.id,data:{error:He}}),Oe=`Error: ${He}`}finally{this._completedSessions.push(h),this.activeSessions.delete(r.id),this.globalController.signal.removeEventListener("abort",a),this.deps.sessionStore?.getState().closeSession(r.id,h.status),this.deps.aiProvider.endSession?.(r.id),this.deps.onSessionUpdate?.(h)}return Oe}waitForResume(r){return new Promise(o=>{const a=()=>{if(!this._paused||r.aborted){o();return}setTimeout(a,50)};a()})}resolvePreferredModel(){const r=typeof this.deps.config.model=="string"?this.deps.config.model.trim():"";return r&&!LEGACY_GEMINI_MODEL.test(r)?r:DEFAULT_MODEL}resolveSessionModel(r){const o=this.resolvePreferredModel();if(o!==DEFAULT_MODEL)return o;const a=typeof r=="string"?r.trim():"";return a&&!LEGACY_GEMINI_MODEL.test(a)?a:o}isQuotaError(r){return typeof r!="string"?!1:QUOTA_ERROR_PATTERNS.some(o=>o.test(r))}haltForQuota(r,o){if(!this.quotaHaltTriggered){this.quotaHaltTriggered=!0,this._paused=!0;for(const[a,h]of this.activeSessions.entries())a!==r.id&&h.controller.abort();this.deps.eventLog.getState().append({type:"warning",agentId:r.agentId,activationId:r.id,data:{message:`Quota/rate-limit detected, pausing run and aborting other sessions. Error: ${o}`}})}}haltForBudget(r,o){if(this.budgetHaltTriggered)return;this.budgetHaltTriggered=!0,this._paused=!0;for(const[h,Ce]of this.activeSessions.entries())h!==r.id&&Ce.controller.abort();const a=o==="before-start"?"before starting the next activation":"during an active session";this.deps.eventLog.getState().append({type:"warning",agentId:r.agentId,activationId:r.id,data:{message:`Token budget reached (${this._totalTokens}/${this.deps.config.tokenBudget}) ${a}. Run paused and other sessions aborted.`}})}}class GeminiProvider{client;activeStreams=new Map;sessionContents=new Map;constructor(r){this.client=new GoogleGenerativeAI(r)}async*chat(r,o,a){const h=new AbortController;this.activeStreams.set(r.sessionId,h);try{const Ce=this.client.getGenerativeModel({model:r.model??"gemini-3-flash-preview",systemInstruction:r.systemPrompt}),ke=a.length>0?[{functionDeclarations:a.map(Je=>({name:Je.name,description:Je.description,parameters:Je.parameters}))}]:void 0;let Te;if(this.sessionContents.has(r.sessionId)){Te=[...this.sessionContents.get(r.sessionId)];const Je=[];for(let Ke=o.length-1;Ke>=0&&o[Ke].role==="tool";Ke--)Je.unshift(o[Ke]);Je.length>0&&Te.push({role:"function",parts:Je.map(Ke=>({functionResponse:{name:Ke.toolCall.name,response:{result:Ke.content}}}))})}else Te=o.filter(Je=>Je.role!=="tool").map(Je=>({role:Je.role==="model"?"model":"user",parts:[{text:Je.content}]}));const je=await Ce.generateContentStream({contents:Te,tools:ke},{signal:h.signal});let Oe=0;const De=[];let He="model";for await(const Je of je.stream){if(h.signal.aborted){yield{type:"error",error:"Aborted"};return}const Ke=Je.candidates?.[0];if(Ke){Ke.content?.role&&(He=Ke.content.role);for(const We of Ke.content?.parts??[])De.push(We),We.text&&(yield{type:"text",text:We.text}),We.functionCall&&(yield{type:"tool_call",toolCall:{id:We.functionCall.id??`tc-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:We.functionCall.name,args:We.functionCall.args??{}}});Je.usageMetadata&&(Oe=Je.usageMetadata.candidatesTokenCount??Oe)}}if(De.length>0){const Je={role:He,parts:De};this.sessionContents.set(r.sessionId,[...Te,Je])}else this.sessionContents.set(r.sessionId,Te);yield{type:"done",tokenCount:Oe}}catch(Ce){h.signal.aborted?yield{type:"error",error:"Aborted"}:yield{type:"error",error:Ce instanceof Error?Ce.message:String(Ce)}}finally{this.activeStreams.delete(r.sessionId)}}async abort(r){const o=this.activeStreams.get(r);o&&(o.abort(),this.activeStreams.delete(r)),this.sessionContents.delete(r)}endSession(r){this.sessionContents.delete(r)}}const CHUNK_DELAY_MS=
|
|
87
|
+
`+He)}catch{}for(let Je=0;Je<25;Je++){let Ke="",We=!1;hasRegisterSession(this.deps.aiProvider)&&this.deps.aiProvider.registerSession(r.id,r.agentId);const mt=this.deps.aiProvider.chat({sessionId:r.id,systemPrompt:He,model:this.resolveSessionModel(Ce.model)},h.history,ke.toToolDefinitions());for await(const ot of mt){if(o.signal.aborted){h.status="aborted";break}switch(this.deps.onStreamChunk?.(r.agentId,ot),this.deps.sessionStore?.getState().appendChunk(r.id,ot),ot.type){case"text":Ke+=ot.text??"";break;case"tool_call":{We=!0;const ht=ot.toolCall,pt=await je.handle(ht.name,ht.args),rt={id:ht.id,name:ht.name,args:ht.args,result:pt,timestamp:Date.now()};if(h.toolCalls.push(rt),h.history.push({role:"tool",content:pt,toolCall:rt}),this.deps.sessionStore?.getState().addToolResult(r.id,rt.id,rt.name,rt.args,rt.result),ht.name==="spawn_agent"){const at=this.childCounts.get(r.agentId)??0;this.childCounts.set(r.agentId,at+1)}break}case"done":ot.tokenCount&&(h.tokenCount+=ot.tokenCount,this._totalTokens+=ot.tokenCount);break;case"error":h.status="error",this.deps.eventLog.getState().append({type:"error",agentId:r.agentId,activationId:r.id,data:{error:ot.error}});break}}if(Ke&&!We&&(h.history.push({role:"model",content:Ke}),Oe=Ke),!We||h.status!=="running")break;if(this._totalTokens>=this.deps.config.tokenBudget){this.haltForBudget(r,"mid-session");break}}h.status==="running"&&(h.status="completed"),this.deps.eventLog.getState().append({type:"complete",agentId:r.agentId,activationId:r.id,data:{status:h.status,tokens:h.tokenCount}})}catch(De){h.status="error";const He=De instanceof Error?De.message:String(De);this.deps.eventLog.getState().append({type:"error",agentId:r.agentId,activationId:r.id,data:{error:He}}),Oe=`Error: ${He}`}finally{this._completedSessions.push(h),this.activeSessions.delete(r.id),this.globalController.signal.removeEventListener("abort",a),this.deps.sessionStore?.getState().closeSession(r.id,h.status),this.deps.aiProvider.endSession?.(r.id),this.deps.onSessionUpdate?.(h)}return Oe}waitForResume(r){return new Promise(o=>{const a=()=>{if(!this._paused||r.aborted){o();return}setTimeout(a,50)};a()})}resolvePreferredModel(){const r=typeof this.deps.config.model=="string"?this.deps.config.model.trim():"";return r&&!LEGACY_GEMINI_MODEL.test(r)?r:DEFAULT_MODEL}resolveSessionModel(r){const o=this.resolvePreferredModel();if(o!==DEFAULT_MODEL)return o;const a=typeof r=="string"?r.trim():"";return a&&!LEGACY_GEMINI_MODEL.test(a)?a:o}isQuotaError(r){return typeof r!="string"?!1:QUOTA_ERROR_PATTERNS.some(o=>o.test(r))}haltForQuota(r,o){if(!this.quotaHaltTriggered){this.quotaHaltTriggered=!0,this._paused=!0;for(const[a,h]of this.activeSessions.entries())a!==r.id&&h.controller.abort();this.deps.eventLog.getState().append({type:"warning",agentId:r.agentId,activationId:r.id,data:{message:`Quota/rate-limit detected, pausing run and aborting other sessions. Error: ${o}`}})}}haltForBudget(r,o){if(this.budgetHaltTriggered)return;this.budgetHaltTriggered=!0,this._paused=!0;for(const[h,Ce]of this.activeSessions.entries())h!==r.id&&Ce.controller.abort();const a=o==="before-start"?"before starting the next activation":"during an active session";this.deps.eventLog.getState().append({type:"warning",agentId:r.agentId,activationId:r.id,data:{message:`Token budget reached (${this._totalTokens}/${this.deps.config.tokenBudget}) ${a}. Run paused and other sessions aborted.`}})}}class GeminiProvider{client;activeStreams=new Map;sessionContents=new Map;constructor(r){this.client=new GoogleGenerativeAI(r)}async*chat(r,o,a){const h=new AbortController;this.activeStreams.set(r.sessionId,h);try{const Ce=this.client.getGenerativeModel({model:r.model??"gemini-3-flash-preview",systemInstruction:r.systemPrompt}),ke=a.length>0?[{functionDeclarations:a.map(Je=>({name:Je.name,description:Je.description,parameters:Je.parameters}))}]:void 0;let Te;if(this.sessionContents.has(r.sessionId)){Te=[...this.sessionContents.get(r.sessionId)];const Je=[];for(let Ke=o.length-1;Ke>=0&&o[Ke].role==="tool";Ke--)Je.unshift(o[Ke]);Je.length>0&&Te.push({role:"function",parts:Je.map(Ke=>({functionResponse:{name:Ke.toolCall.name,response:{result:Ke.content}}}))})}else Te=o.filter(Je=>Je.role!=="tool").map(Je=>({role:Je.role==="model"?"model":"user",parts:[{text:Je.content}]}));const je=await Ce.generateContentStream({contents:Te,tools:ke},{signal:h.signal});let Oe=0;const De=[];let He="model";for await(const Je of je.stream){if(h.signal.aborted){yield{type:"error",error:"Aborted"};return}const Ke=Je.candidates?.[0];if(Ke){Ke.content?.role&&(He=Ke.content.role);for(const We of Ke.content?.parts??[])De.push(We),We.text&&(yield{type:"text",text:We.text}),We.functionCall&&(yield{type:"tool_call",toolCall:{id:We.functionCall.id??`tc-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:We.functionCall.name,args:We.functionCall.args??{}}});Je.usageMetadata&&(Oe=Je.usageMetadata.candidatesTokenCount??Oe)}}if(De.length>0){const Je={role:He,parts:De};this.sessionContents.set(r.sessionId,[...Te,Je])}else this.sessionContents.set(r.sessionId,Te);yield{type:"done",tokenCount:Oe}}catch(Ce){h.signal.aborted?yield{type:"error",error:"Aborted"}:yield{type:"error",error:Ce instanceof Error?Ce.message:String(Ce)}}finally{this.activeStreams.delete(r.sessionId)}}async abort(r){const o=this.activeStreams.get(r);o&&(o.abort(),this.activeStreams.delete(r)),this.sessionContents.delete(r)}endSession(r){this.sessionContents.delete(r)}}const CHUNK_DELAY_MS={text:120,tool_call:600,done:1200,error:0},FALLBACK_TEXT="[ScriptedAIProvider] No script available for this agent or turn.";class ScriptedAIProvider{scripts;sessionAgentMap=new Map;turnCounters=new Map;aborted=new Set;constructor(r){this.scripts=r}registerSession(r,o){this.sessionAgentMap.set(r,o),this.turnCounters.has(r)||this.turnCounters.set(r,0)}async*chat(r,o,a){const{sessionId:h}=r;if(this.aborted.has(h)){yield{type:"error",error:"Aborted"};return}const Ce=this.sessionAgentMap.get(h),ke=Ce?this.scripts[Ce]:void 0,Te=this.turnCounters.get(h)??0;let je;!ke||Te>=ke.length?je=[{type:"text",text:FALLBACK_TEXT},{type:"done",tokenCount:0}]:je=ke[Te],this.turnCounters.set(h,Te+1);for(const Oe of je){if(this.aborted.has(h)){yield{type:"error",error:"Aborted"};return}await new Promise(De=>setTimeout(De,CHUNK_DELAY_MS[Oe.type])),yield Oe}}async abort(r){this.aborted.add(r)}endSession(r){this.sessionAgentMap.delete(r),this.turnCounters.delete(r),this.aborted.delete(r)}}function text$1(Ae){return{type:"text",text:Ae}}function tc(Ae,r,o){return{type:"tool_call",toolCall:{id:Ae,name:r,args:o}}}function done(Ae){return{type:"done",tokenCount:Ae}}const DESIGN_SPEC=`# Portfolio Website Design Specification
|
|
88
88
|
|
|
89
89
|
## Layout
|
|
90
90
|
- Single-page scrolling layout with fixed navigation header
|
|
@@ -123,7 +123,7 @@ ${JSON.stringify(Ae.resultSchema,null,2)}`);const He=Oe+De,Je={authorAgentId:a.c
|
|
|
123
123
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
124
124
|
<meta name="description" content="Alex Morgan - Full-Stack Developer Portfolio" />
|
|
125
125
|
<title>Alex Morgan | Full-Stack Developer</title>
|
|
126
|
-
<link rel="stylesheet" href="
|
|
126
|
+
<link rel="stylesheet" href="styles.css" />
|
|
127
127
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
128
128
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
129
129
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet" />
|
|
@@ -1185,4 +1185,4 @@ You are a tool builder agent that uses custom tools to process information.
|
|
|
1185
1185
|
- Write your findings to artifacts/
|
|
1186
1186
|
- Use web_fetch if you need to gather source material
|
|
1187
1187
|
`}];function getTemplates(Ae){const r=[];for(const[o,a]of Ae){if(!o.startsWith("templates/")||!o.endsWith(".md"))continue;let Ce=o.split("/").pop()?.replace(/\.md$/,"")??o,ke="User template";try{const je=matter(a.content).data;typeof je.name=="string"&&(Ce=je.name),typeof je.description=="string"&&(ke=je.description)}catch{}r.push({id:o,name:Ce,description:ke,content:a.content,builtIn:!1})}return[...BUILT_IN_TEMPLATES,...r]}const wrapper="_wrapper_1ekqp_1",trigger="_trigger_1ekqp_9",dropdown="_dropdown_1ekqp_43",sectionLabel="_sectionLabel_1ekqp_73",item$1="_item_1ekqp_93",itemName="_itemName_1ekqp_117",itemDesc="_itemDesc_1ekqp_127",divider$1="_divider_1ekqp_137",styles$9={wrapper,trigger,dropdown,sectionLabel,item:item$1,itemName,itemDesc,divider:divider$1};function TemplatePicker({onSelect:Ae}){const r=useVFS(je=>je.files),[o,a]=reactExports.useState(!1),h=reactExports.useRef(null),Ce=reactExports.useMemo(()=>getTemplates(r),[r]),ke=Ce.filter(je=>je.builtIn),Te=Ce.filter(je=>!je.builtIn);return reactExports.useEffect(()=>{if(!o)return;const je=Oe=>{h.current&&!h.current.contains(Oe.target)&&a(!1)};return document.addEventListener("mousedown",je),()=>document.removeEventListener("mousedown",je)},[o]),jsxRuntimeExports.jsxs("div",{ref:h,className:styles$9.wrapper,children:[jsxRuntimeExports.jsx("button",{onClick:()=>a(!o),className:styles$9.trigger,children:"New from template..."}),o&&jsxRuntimeExports.jsxs("div",{className:styles$9.dropdown,children:[jsxRuntimeExports.jsx("div",{className:styles$9.sectionLabel,children:"Built-in"}),ke.map(je=>jsxRuntimeExports.jsxs("div",{onClick:()=>{Ae(je),a(!1)},role:"button",tabIndex:0,onKeyDown:Oe=>{(Oe.key==="Enter"||Oe.key===" ")&&(Oe.preventDefault(),Ae(je),a(!1))},className:styles$9.item,children:[jsxRuntimeExports.jsx("div",{className:styles$9.itemName,children:je.name}),jsxRuntimeExports.jsx("div",{className:styles$9.itemDesc,children:je.description})]},je.id)),Te.length>0&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:styles$9.divider}),jsxRuntimeExports.jsx("div",{className:styles$9.sectionLabel,children:"My Templates"}),Te.map(je=>jsxRuntimeExports.jsxs("div",{onClick:()=>{Ae(je),a(!1)},role:"button",tabIndex:0,onKeyDown:Oe=>{(Oe.key==="Enter"||Oe.key===" ")&&(Oe.preventDefault(),Ae(je),a(!1))},className:styles$9.item,children:[jsxRuntimeExports.jsx("div",{className:styles$9.itemName,children:je.name}),jsxRuntimeExports.jsx("div",{className:styles$9.itemDesc,children:je.description})]},je.id))]})]})]})}const toolbar="_toolbar_v25xj_1",filePath="_filePath_v25xj_29",pathInput="_pathInput_v25xj_53",formRow="_formRow_v25xj_75",spacer="_spacer_v25xj_85",unsaved="_unsaved_v25xj_93",ghostBtn$1="_ghostBtn_v25xj_103",primary="_primary_v25xj_141",hint="_hint_v25xj_159",externalModified="_externalModified_v25xj_171",reloadBtn="_reloadBtn_v25xj_197",styles$8={toolbar,filePath,pathInput,formRow,spacer,unsaved,ghostBtn:ghostBtn$1,primary,hint,externalModified,reloadBtn};function EditorToolbar({content:Ae,onContentChange:r}){const o=useUI(ht=>ht.editingFilePath),a=useUI(ht=>ht.editorDirty),h=useUI(ht=>ht.setEditingFile),Ce=useUI(ht=>ht.setEditorDirty),ke=useVFS(ht=>ht.files),[Te,je]=reactExports.useState(!1),[Oe,De]=reactExports.useState(""),He=reactExports.useCallback(()=>{o&&(vfsStore.getState().write(o,Ae,{}),o.startsWith("agents/")&&agentRegistry.getState().registerFromFile(o,Ae),Ce(!1))},[o,Ae,Ce]),Je=reactExports.useCallback(()=>{const ht=window.prompt("Template name:");if(!ht)return;const rt=`templates/${ht.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}.md`;vfsStore.getState().write(rt,Ae,{})},[Ae]),Ke=reactExports.useCallback(ht=>{if(a&&!window.confirm("You have unsaved changes. Discard them?"))return;const at=`agents/untitled-${[...ke.keys()].filter(bt=>bt.match(/^agents\/untitled-\d+\.md$/)).length+1}.md`;vfsStore.getState().write(at,ht.content,{}),agentRegistry.getState().registerFromFile(at,ht.content),r(ht.content),h(at),Ce(!1)},[a,r,h,Ce,ke]),We=reactExports.useCallback(()=>{if(!Oe.trim()||!o)return;const ht=o,pt=Oe.trim();vfsStore.getState().write(pt,Ae,{}),pt.startsWith("agents/")&&agentRegistry.getState().registerFromFile(pt,Ae),ht!==pt&&vfsStore.getState().exists(ht)&&(vfsStore.getState().deleteFile(ht),ht.startsWith("agents/")&&agentRegistry.getState().unregister(ht)),h(pt),je(!1)},[Oe,o,Ae,h]),mt=o?ke.get(o)?.content:null,ot=o&&mt!==null&&mt!==void 0&&mt!==Ae&&!a;return jsxRuntimeExports.jsxs("div",{className:styles$8.toolbar,children:[jsxRuntimeExports.jsx(TemplatePicker,{onSelect:Ke}),o&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[Te?jsxRuntimeExports.jsxs("form",{onSubmit:ht=>{ht.preventDefault(),We()},className:styles$8.formRow,children:[jsxRuntimeExports.jsx("input",{type:"text",value:Oe,onChange:ht=>De(ht.target.value),autoFocus:!0,className:styles$8.pathInput}),jsxRuntimeExports.jsx("button",{type:"submit",className:`${styles$8.ghostBtn} ${styles$8.primary}`,children:"OK"}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>je(!1),className:styles$8.ghostBtn,children:"Cancel"})]}):jsxRuntimeExports.jsx("span",{onClick:()=>{De(o),je(!0)},role:"button",tabIndex:0,onKeyDown:ht=>{(ht.key==="Enter"||ht.key===" ")&&(ht.preventDefault(),De(o),je(!0))},className:styles$8.filePath,title:"Click to rename/move",children:o}),jsxRuntimeExports.jsx("div",{className:styles$8.spacer}),a&&jsxRuntimeExports.jsx("span",{className:styles$8.unsaved,children:"Unsaved"}),jsxRuntimeExports.jsx("button",{onClick:He,className:`${styles$8.ghostBtn} ${styles$8.primary}`,children:"Save"}),jsxRuntimeExports.jsx("button",{onClick:Je,className:styles$8.ghostBtn,children:"Save as Template"})]}),!o&&jsxRuntimeExports.jsx("span",{className:styles$8.hint,children:"Select a file or pick a template to start editing"}),ot&&jsxRuntimeExports.jsxs("div",{className:styles$8.externalModified,children:["File changed externally.",jsxRuntimeExports.jsx("button",{onClick:()=>{mt&&r(mt)},className:styles$8.reloadBtn,children:"Reload"})]})]})}const KNOWN_MODELS=["gemini-3-pro-preview","gemini-3-flash-preview","gemini-2.5-flash","gemini-2.5-pro","gemini-2.0-flash"],KNOWN_MODES=["safe","balanced","gloves_off","gloves-off","glovesoff","street","track"];function hasNonStringItems(Ae){return Ae.some(r=>typeof r!="string")}function validateAgentContent(Ae,r=!0){if(!r)return[];const o=[],a=Ae.split(`
|
|
1188
|
-
`);if(!Ae.trimStart().startsWith("---"))return o.push({startLine:1,endLine:1,startCol:1,endCol:(a[0]?.length??0)+1,message:"Agent files should have YAML frontmatter (---)",severity:"warning"}),o;let Ce;try{Ce=matter(Ae)}catch(He){return o.push({startLine:1,endLine:3,startCol:1,endCol:4,message:`Invalid YAML: ${He instanceof Error?He.message:String(He)}`,severity:"error"}),o}const ke=Ce.data,Te=a.indexOf("---",1)+1;if((typeof ke.name!="string"||ke.name.trim()==="")&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Missing required field: name",severity:"warning"}),typeof ke.model=="string"&&!KNOWN_MODELS.includes(ke.model)){const He=a.findIndex(Je=>Je.trimStart().startsWith("model:"))+1;o.push({startLine:He||2,endLine:He||2,startCol:1,endCol:(a[He-1]?.length??0)+1,message:`Unknown model '${ke.model}'. Known: ${KNOWN_MODELS.join(", ")}`,severity:"info"})}const je=ke.safety_mode??ke.mode;if(je!=null)if(typeof je!="string")o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'safety_mode'/'mode' should be a string.",severity:"warning"});else if(!KNOWN_MODES.includes(je.trim().toLowerCase()))o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:`Unknown safety mode '${je}'. Known: safe, balanced, gloves_off.`,severity:"warning"});else{const He=je.trim().toLowerCase();(He==="gloves_off"||He==="gloves-off"||He==="glovesoff"||He==="track")&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Mode 'gloves_off' enables unrestricted execution for this agent.",severity:"warning"})}ke.reads!=null&&(Array.isArray(ke.reads)?hasNonStringItems(ke.reads)&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'reads' must only contain strings.",severity:"warning"}):o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'reads' should be an array of path patterns.",severity:"warning"})),ke.writes!=null&&(Array.isArray(ke.writes)?hasNonStringItems(ke.writes)&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'writes' must only contain strings.",severity:"warning"}):o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'writes' should be an array of path patterns.",severity:"warning"})),ke.allowed_tools!=null&&(!Array.isArray(ke.allowed_tools)||hasNonStringItems(ke.allowed_tools))&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'allowed_tools' must be an array of tool names.",severity:"warning"}),ke.blocked_tools!=null&&(!Array.isArray(ke.blocked_tools)||hasNonStringItems(ke.blocked_tools))&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'blocked_tools' must be an array of tool names.",severity:"warning"});const Oe=ke.gloves_off_triggers??ke.glovesOffTriggers;if(Oe!=null&&(!Array.isArray(Oe)||hasNonStringItems(Oe)?o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'gloves_off_triggers' should be an array of strings.",severity:"warning"}):Oe.length===0&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'gloves_off_triggers' is empty and will never match.",severity:"info"})),ke.permissions!=null)if(Array.isArray(ke.permissions))if(hasNonStringItems(ke.permissions))o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'permissions' array must contain only strings.",severity:"warning"});else{const He=ke.permissions.map(Je=>Je.toLowerCase());(He.includes("*")||He.includes("allow_all")||He.includes("all"))&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter permissions include allow-all behavior.",severity:"warning"})}else if(typeof ke.permissions=="object"){const He=ke.permissions;for(const[Je,Ke]of Object.entries(He))typeof Ke!="boolean"&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:`Permission '${Je}' should be boolean.`,severity:"warning"});He.allow_all===!0&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"permissions.allow_all=true makes this agent effectively unrestricted.",severity:"warning"})}else o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'permissions' should be an object or array.",severity:"warning"});if(Ce.content.trim().length===0){const He=Te+1||a.length;o.push({startLine:He,endLine:He,startCol:1,endCol:1,message:"Agent has no system prompt instructions",severity:"warning"})}if(Array.isArray(ke.tools))for(const He of ke.tools){if(typeof He!="object"||He===null)continue;const Je=He,Ke=typeof Je.name=="string"?`tool '${Je.name}'`:"tool entry";if((typeof Je.name!="string"||Je.name.trim()==="")&&o.push({startLine:Te||2,endLine:Te||2,startCol:1,endCol:4,message:"Custom tool is missing required field: name",severity:"warning"}),(typeof Je.description!="string"||Je.description.trim()==="")&&o.push({startLine:Te||2,endLine:Te||2,startCol:1,endCol:4,message:`Custom ${Ke} is missing required field: description`,severity:"warning"}),(typeof Je.prompt!="string"||Je.prompt.trim()==="")&&o.push({startLine:Te||2,endLine:Te||2,startCol:1,endCol:4,message:`Custom ${Ke} is missing required field: prompt`,severity:"warning"}),typeof Je.prompt=="string"){const We=[...Je.prompt.matchAll(/\{\{(\w+)\}\}/g)].map(ot=>ot[1]),mt=typeof Je.parameters=="object"&&Je.parameters!==null?Object.keys(Je.parameters):[];for(const ot of We)mt.includes(ot)||o.push({startLine:Te||2,endLine:Te||2,startCol:1,endCol:4,message:`Custom ${Ke} prompt references '{{${ot}}}' but no parameter '${ot}' is defined`,severity:"info"})}}return o}const container$4="_container_14fj4_1",editorArea="_editorArea_14fj4_3",emptyState="_emptyState_14fj4_5",styles$7={container:container$4,editorArea,emptyState};let themeRegistered=!1;function AgentEditor(){const Ae=useUI(Ke=>Ke.editingFilePath),r=useUI(Ke=>Ke.setEditorDirty),o=reactExports.useRef(null),a=reactExports.useRef(null),[h,Ce]=reactExports.useState(""),ke=reactExports.useRef(null);reactExports.useEffect(()=>()=>{ke.current&&clearTimeout(ke.current)},[]);const[Te,je]=reactExports.useState(Ae);if(Ae!==Te){je(Ae);const Ke=Ae?vfsStore.getState().read(Ae)??"":"";Ce(Ke)}const Oe=reactExports.useCallback(Ke=>{const We=o.current,mt=a.current;if(!We||!mt)return;const ot=We.getModel();if(!ot)return;const ht=Ae?.startsWith("agents/")??!1,rt=validateAgentContent(Ke,ht).map(at=>({startLineNumber:at.startLine,endLineNumber:at.endLine,startColumn:at.startCol,endColumn:at.endCol,message:at.message,severity:at.severity==="error"?mt.MarkerSeverity.Error:at.severity==="warning"?mt.MarkerSeverity.Warning:mt.MarkerSeverity.Info}));mt.editor.setModelMarkers(ot,"agent-validator",rt)},[Ae]),De=reactExports.useCallback((Ke,We)=>{o.current=Ke,a.current=We,themeRegistered||(We.editor.defineTheme("catppuccin-mocha",{base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"6c7086"},{token:"keyword",foreground:"cba6f7"},{token:"string",foreground:"a6e3a1"},{token:"number",foreground:"fab387"},{token:"type",foreground:"89b4fa"}],colors:{"editor.background":"#1e1e2e","editor.foreground":"#cdd6f4","editor.lineHighlightBackground":"#33324a","editor.selectionBackground":"#45475a","editorCursor.foreground":"#e0a650","editorGutter.background":"#181825"}}),themeRegistered=!0),We.editor.setTheme("catppuccin-mocha"),Ke.addAction({id:"agent-editor-save",label:"Save File",keybindings:[We.KeyMod.CtrlCmd|We.KeyCode.KeyS],run:mt=>{const ot=uiStore.getState().editingFilePath;if(!ot)return;const ht=mt.getValue();vfsStore.getState().write(ot,ht,{}),ot.startsWith("agents/")&&agentRegistry.getState().registerFromFile(ot,ht),uiStore.getState().setEditorDirty(!1)}}),Oe(h)},[h,Oe]),He=reactExports.useCallback(Ke=>{const We=Ke??"";Ce(We),r(!0),ke.current&&clearTimeout(ke.current),ke.current=setTimeout(()=>Oe(We),300)},[r,Oe]),Je=reactExports.useCallback(Ke=>{Ce(Ke),setTimeout(()=>Oe(Ke),50)},[Oe]);return jsxRuntimeExports.jsxs("div",{className:styles$7.container,children:[jsxRuntimeExports.jsx(EditorToolbar,{content:h,onContentChange:Je}),jsxRuntimeExports.jsx("div",{className:styles$7.editorArea,children:Ae?jsxRuntimeExports.jsx(Ft$1,{height:"100%",language:"markdown",value:h,onChange:He,onMount:De,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8}}}):jsxRuntimeExports.jsx("div",{className:styles$7.emptyState,children:"Select a file from the workspace or create a new agent from a template."})})]})}const aria=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],defaultSchema={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...aria,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...aria],h2:[["className","sr-only"]],img:[...aria,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...aria,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...aria],table:[...aria],ul:[...aria,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},own={}.hasOwnProperty;function sanitize(Ae,r){let o={type:"root",children:[]};const a={schema:r?{...defaultSchema,...r}:defaultSchema,stack:[]},h=transform(a,Ae);return h&&(Array.isArray(h)?h.length===1?o=h[0]:o.children=h:o=h),o}function transform(Ae,r){if(r&&typeof r=="object"){const o=r;switch(typeof o.type=="string"?o.type:""){case"comment":return comment(Ae,o);case"doctype":return doctype(Ae,o);case"element":return element(Ae,o);case"root":return root$1(Ae,o);case"text":return text(Ae,o)}}}function comment(Ae,r){if(Ae.schema.allowComments){const o=typeof r.value=="string"?r.value:"",a=o.indexOf("-->"),Ce={type:"comment",value:a<0?o:o.slice(0,a)};return patch(Ce,r),Ce}}function doctype(Ae,r){if(Ae.schema.allowDoctypes){const o={type:"doctype"};return patch(o,r),o}}function element(Ae,r){const o=typeof r.tagName=="string"?r.tagName:"";Ae.stack.push(o);const a=children(Ae,r.children),h=properties(Ae,r.properties);Ae.stack.pop();let Ce=!1;if(o&&o!=="*"&&(!Ae.schema.tagNames||Ae.schema.tagNames.includes(o))&&(Ce=!0,Ae.schema.ancestors&&own.call(Ae.schema.ancestors,o))){const Te=Ae.schema.ancestors[o];let je=-1;for(Ce=!1;++je<Te.length;)Ae.stack.includes(Te[je])&&(Ce=!0)}if(!Ce)return Ae.schema.strip&&!Ae.schema.strip.includes(o)?a:void 0;const ke={type:"element",tagName:o,properties:h,children:a};return patch(ke,r),ke}function root$1(Ae,r){const a={type:"root",children:children(Ae,r.children)};return patch(a,r),a}function text(Ae,r){const a={type:"text",value:typeof r.value=="string"?r.value:""};return patch(a,r),a}function children(Ae,r){const o=[];if(Array.isArray(r)){const a=r;let h=-1;for(;++h<a.length;){const Ce=transform(Ae,a[h]);Ce&&(Array.isArray(Ce)?o.push(...Ce):o.push(Ce))}}return o}function properties(Ae,r){const o=Ae.stack[Ae.stack.length-1],a=Ae.schema.attributes,h=Ae.schema.required,Ce=a&&own.call(a,o)?a[o]:void 0,ke=a&&own.call(a,"*")?a["*"]:void 0,Te=r&&typeof r=="object"?r:{},je={};let Oe;for(Oe in Te)if(own.call(Te,Oe)){const De=Te[Oe];let He=propertyValue(Ae,findDefinition(Ce,Oe),Oe,De);He==null&&(He=propertyValue(Ae,findDefinition(ke,Oe),Oe,De)),He!=null&&(je[Oe]=He)}if(h&&own.call(h,o)){const De=h[o];for(Oe in De)own.call(De,Oe)&&!own.call(je,Oe)&&(je[Oe]=De[Oe])}return je}function propertyValue(Ae,r,o,a){return r?Array.isArray(a)?propertyValueMany(Ae,r,o,a):propertyValuePrimitive(Ae,r,o,a):void 0}function propertyValueMany(Ae,r,o,a){let h=-1;const Ce=[];for(;++h<a.length;){const ke=propertyValuePrimitive(Ae,r,o,a[h]);(typeof ke=="number"||typeof ke=="string")&&Ce.push(ke)}return Ce}function propertyValuePrimitive(Ae,r,o,a){if(!(typeof a!="boolean"&&typeof a!="number"&&typeof a!="string")&&safeProtocol(Ae,o,a)){if(typeof r=="object"&&r.length>1){let h=!1,Ce=0;for(;++Ce<r.length;){const ke=r[Ce];if(ke&&typeof ke=="object"&&"flags"in ke){if(ke.test(String(a))){h=!0;break}}else if(ke===a){h=!0;break}}if(!h)return}return Ae.schema.clobber&&Ae.schema.clobberPrefix&&Ae.schema.clobber.includes(o)?Ae.schema.clobberPrefix+a:a}}function safeProtocol(Ae,r,o){const a=Ae.schema.protocols&&own.call(Ae.schema.protocols,r)?Ae.schema.protocols[r]:void 0;if(!a||a.length===0)return!0;const h=String(o),Ce=h.indexOf(":"),ke=h.indexOf("?"),Te=h.indexOf("#"),je=h.indexOf("/");if(Ce<0||je>-1&&Ce>je||ke>-1&&Ce>ke||Te>-1&&Ce>Te)return!0;let Oe=-1;for(;++Oe<a.length;){const De=a[Oe];if(Ce===De.length&&h.slice(0,De.length)===De)return!0}return!1}function patch(Ae,r){const o=position(r);r.data&&(Ae.data=structuredClone$1(r.data)),o&&(Ae.position=o)}function findDefinition(Ae,r){let o,a=-1;if(Ae)for(;++a<Ae.length;){const h=Ae[a],Ce=typeof h=="string"?h:h[0];if(Ce===r)return h;Ce==="data*"&&(o=h)}if(r.length>4&&r.slice(0,4).toLowerCase()==="data")return o}function rehypeSanitize(Ae){return function(r){return sanitize(r,Ae)}}const oneDark={'code[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"]::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},prolog:{color:"hsl(220, 10%, 40%)"},cdata:{color:"hsl(220, 10%, 40%)"},doctype:{color:"hsl(220, 14%, 71%)"},punctuation:{color:"hsl(220, 14%, 71%)"},entity:{color:"hsl(220, 14%, 71%)",cursor:"help"},"attr-name":{color:"hsl(29, 54%, 61%)"},"class-name":{color:"hsl(29, 54%, 61%)"},boolean:{color:"hsl(29, 54%, 61%)"},constant:{color:"hsl(29, 54%, 61%)"},number:{color:"hsl(29, 54%, 61%)"},atrule:{color:"hsl(29, 54%, 61%)"},keyword:{color:"hsl(286, 60%, 67%)"},property:{color:"hsl(355, 65%, 65%)"},tag:{color:"hsl(355, 65%, 65%)"},symbol:{color:"hsl(355, 65%, 65%)"},deleted:{color:"hsl(355, 65%, 65%)"},important:{color:"hsl(355, 65%, 65%)"},selector:{color:"hsl(95, 38%, 62%)"},string:{color:"hsl(95, 38%, 62%)"},char:{color:"hsl(95, 38%, 62%)"},builtin:{color:"hsl(95, 38%, 62%)"},inserted:{color:"hsl(95, 38%, 62%)"},regex:{color:"hsl(95, 38%, 62%)"},"attr-value":{color:"hsl(95, 38%, 62%)"},"attr-value > .token.punctuation":{color:"hsl(95, 38%, 62%)"},variable:{color:"hsl(207, 82%, 66%)"},operator:{color:"hsl(207, 82%, 66%)"},function:{color:"hsl(207, 82%, 66%)"},url:{color:"hsl(187, 47%, 55%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(220, 14%, 71%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(220, 14%, 71%)"},".language-css .token.selector":{color:"hsl(355, 65%, 65%)"},".language-css .token.property":{color:"hsl(220, 14%, 71%)"},".language-css .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.string.url":{color:"hsl(95, 38%, 62%)"},".language-css .token.important":{color:"hsl(286, 60%, 67%)"},".language-css .token.atrule .token.rule":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.operator":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(5, 48%, 51%)"},".language-json .token.operator":{color:"hsl(220, 14%, 71%)"},".language-json .token.null.keyword":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.url":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.operator":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.content":{color:"hsl(207, 82%, 66%)"},".language-markdown .token.url > .token.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.url-reference.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(95, 38%, 62%)"},".language-markdown .token.bold .token.content":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.italic .token.content":{color:"hsl(286, 60%, 67%)"},".language-markdown .token.strike .token.content":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.list.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(355, 65%, 65%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.cr:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.lf:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.space:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},".line-highlight.line-highlight":{background:"hsla(220, 100%, 80%, 0.04)"},".line-highlight.line-highlight:before":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(220, 100%, 80%, 0.04)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".command-line .command-line-prompt":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(220, 14%, 45%)"},".command-line .command-line-prompt > span:before":{color:"hsl(220, 14%, 45%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(286, 60%, 67%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(224, 13%, 17%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(224, 13%, 17%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(224, 13%, 17%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(224, 13%, 17%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(219, 13%, 22%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(220, 14%, 71%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(220, 14%, 71%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(220, 14%, 71%)"}},container$3="_container_1s69j_1",empty$3="_empty_1s69j_19",timeDivider="_timeDivider_1s69j_35",userBubble="_userBubble_1s69j_91 _messageBubble_1s69j_71",assistantBubble="_assistantBubble_1s69j_107 _messageBubble_1s69j_71",toolBlock="_toolBlock_1s69j_123",toolHeader="_toolHeader_1s69j_143",toolName="_toolName_1s69j_173",toolChevron="_toolChevron_1s69j_183",expanded="_expanded_1s69j_197",toolSummary="_toolSummary_1s69j_205",toolResult="_toolResult_1s69j_217",streamCursor="_streamCursor_1s69j_239",thinkingRing="_thinkingRing_1s69j_263",tokenCounter="_tokenCounter_1s69j_297",jumpToBottom="_jumpToBottom_1s69j_321",jumpBtn="_jumpBtn_1s69j_335",styles$6={container:container$3,empty:empty$3,timeDivider,userBubble,assistantBubble,toolBlock,toolHeader,toolName,toolChevron,expanded,toolSummary,toolResult,streamCursor,thinkingRing,tokenCounter,jumpToBottom,jumpBtn};function formatTime(Ae){const r=new Date(Ae),o=String(r.getHours()).padStart(2,"0"),a=String(r.getMinutes()).padStart(2,"0"),h=String(r.getSeconds()).padStart(2,"0");return`${o}:${a}:${h}`}const oneDarkStyles=oneDark,codeStyle={...oneDark,'pre[class*="language-"]':{...oneDarkStyles['pre[class*="language-"]']??{},background:"#11111b",margin:"8px 0",padding:"12px",borderRadius:"6px",fontSize:"12px"},'code[class*="language-"]':{...oneDarkStyles['code[class*="language-"]']??{},background:"transparent"}},sanitizeSchema={...defaultSchema,attributes:{...defaultSchema.attributes,code:[...defaultSchema.attributes?.code??[],"className"]}},markdownComponents={code({className:Ae,children:r,...o}){const a=/language-(\w+)/.exec(Ae||""),h=String(r).replace(/\n$/,"");return a?jsxRuntimeExports.jsx(highlighter,{language:a[1],style:codeStyle,customStyle:{margin:"8px 0",padding:"12px",borderRadius:"6px",fontSize:"12px",background:"#11111b"},children:h}):jsxRuntimeExports.jsx("code",{className:Ae,...o,children:r})},a({href:Ae,children:r,...o}){return jsxRuntimeExports.jsx("a",{href:Ae,target:"_blank",rel:"noopener noreferrer",...o,children:r})},img({src:Ae,alt:r,...o}){return jsxRuntimeExports.jsx("img",{src:Ae,alt:r??"",loading:"lazy",...o})}};function ToolCallRow({msg:Ae}){const[r,o]=reactExports.useState(!1),a=Ae.toolCall;if(!a)return null;const h=a.result.length;return jsxRuntimeExports.jsxs("div",{className:styles$6.toolBlock,children:[jsxRuntimeExports.jsxs("div",{className:styles$6.toolHeader,role:"button",tabIndex:0,onClick:()=>o(!r),onKeyDown:Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),o(!r))},children:[jsxRuntimeExports.jsx("span",{className:styles$6.toolName,children:a.name}),!r&&jsxRuntimeExports.jsxs("span",{className:styles$6.toolSummary,children:["(",h.toLocaleString()," chars)"]}),jsxRuntimeExports.jsx("span",{className:`${styles$6.toolChevron}${r?` ${styles$6.expanded}`:""}`,children:">"})]}),r&&jsxRuntimeExports.jsx("div",{className:styles$6.toolResult,children:a.result})]})}function ChatLog({agentId:Ae,messages:r,streamingText:o=""}){const a=reactExports.useRef(null),[h,Ce]=reactExports.useState(!0),ke=reactExports.useCallback(()=>{const je=a.current;if(!je)return;const Oe=je.scrollHeight-je.scrollTop-je.clientHeight<24;Ce(Oe)},[]);reactExports.useEffect(()=>{h&&a.current&&a.current.scrollTo({top:a.current.scrollHeight,behavior:"smooth"})},[r,o,h]);const Te=r.length===0&&!o;return jsxRuntimeExports.jsxs("div",{ref:a,onScroll:ke,className:styles$6.container,children:[Te&&jsxRuntimeExports.jsx("div",{className:styles$6.empty,children:"Run an agent to see output here"}),o&&jsxRuntimeExports.jsxs("div",{className:styles$6.tokenCounter,children:["~",Math.round(o.length/4).toLocaleString()," tokens"]}),r.map((je,Oe)=>{const De=Oe>0?r[Oe-1]:null,He=De&&je.timestamp-De.timestamp>6e4;return jsxRuntimeExports.jsxs("div",{children:[He&&jsxRuntimeExports.jsx("div",{className:styles$6.timeDivider,children:jsxRuntimeExports.jsx("span",{children:formatTime(je.timestamp)})}),je.role==="tool"&&jsxRuntimeExports.jsx(ToolCallRow,{msg:je}),je.role==="user"&&jsxRuntimeExports.jsx("div",{className:styles$6.userBubble,children:je.content}),je.role==="assistant"&&jsxRuntimeExports.jsx("div",{className:styles$6.assistantBubble,children:jsxRuntimeExports.jsx(Markdown,{remarkPlugins:[remarkGfm],rehypePlugins:[[rehypeSanitize,sanitizeSchema]],components:markdownComponents,children:je.content})})]},Oe)}),o&&jsxRuntimeExports.jsxs("div",{className:styles$6.assistantBubble,children:[jsxRuntimeExports.jsx(Markdown,{remarkPlugins:[remarkGfm],rehypePlugins:[[rehypeSanitize,sanitizeSchema]],components:markdownComponents,children:o}),jsxRuntimeExports.jsx("span",{className:styles$6.streamCursor,children:"|"}),jsxRuntimeExports.jsx("span",{className:styles$6.thinkingRing})]}),!h&&jsxRuntimeExports.jsx("div",{className:styles$6.jumpToBottom,children:jsxRuntimeExports.jsx("button",{className:styles$6.jumpBtn,onClick:()=>{a.current?.scrollTo({top:a.current.scrollHeight,behavior:"smooth"})},children:"Jump to latest"})})]})}const container$2="_container_1kh8y_1",header="_header_1kh8y_15",meta="_meta_1kh8y_31",status="_status_1kh8y_45",timeline="_timeline_1kh8y_57",event="_event_1kh8y_87",eventDot="_eventDot_1kh8y_115",eventTime="_eventTime_1kh8y_135",eventType="_eventType_1kh8y_145",eventAgent="_eventAgent_1kh8y_163",eventActions="_eventActions_1kh8y_171",ghostBtn="_ghostBtn_1kh8y_195",eventError="_eventError_1kh8y_239",eventMessage="_eventMessage_1kh8y_251",empty$2="_empty_1kh8y_261",styles$5={container:container$2,header,meta,status,timeline,event,eventDot,eventTime,eventType,eventAgent,eventActions,ghostBtn,eventError,eventMessage,empty:empty$2};function EventLogView(){const Ae=useEventLog(Ke=>Ke.entries),r=useEventLog(Ke=>Ke.checkpoints),{replayFromEvent:o,restoreFromEvent:a,isRunning:h,lastReplayEventId:Ce}=useKernel(),[ke,Te]=reactExports.useState(""),[je,Oe]=reactExports.useTransition(),De=Ae.slice(-100).reverse(),He=Ke=>{Oe(async()=>{Te(`Replaying from ${Ke}...`);const We=await o(Ke);Te(We.message)})},Je=Ke=>{const We=a(Ke);Te(We.message)};return jsxRuntimeExports.jsxs("div",{className:styles$5.container,children:[jsxRuntimeExports.jsxs("div",{className:styles$5.header,children:["Event Log (",Ae.length," entries)"]}),jsxRuntimeExports.jsxs("div",{className:styles$5.meta,children:["Replay checkpoints: ",r.length,Ce?` | Last replay: ${Ce}`:""]}),ke&&jsxRuntimeExports.jsx("div",{className:styles$5.status,children:ke}),jsxRuntimeExports.jsx("div",{className:styles$5.timeline,children:De.map(Ke=>{const We=typeColor(Ke.type);return jsxRuntimeExports.jsxs("div",{className:styles$5.event,children:[jsxRuntimeExports.jsx("div",{className:styles$5.eventDot,style:{background:We}}),jsxRuntimeExports.jsx("span",{className:styles$5.eventTime,children:new Date(Ke.timestamp).toLocaleTimeString()}),jsxRuntimeExports.jsx("span",{className:styles$5.eventType,style:{color:We,background:`${We}26`},children:Ke.type}),jsxRuntimeExports.jsx("span",{className:styles$5.eventAgent,children:Ke.agentId}),jsxRuntimeExports.jsxs("div",{className:styles$5.eventActions,children:[jsxRuntimeExports.jsx("button",{className:styles$5.ghostBtn,onClick:()=>Je(Ke.id),children:"Restore"}),jsxRuntimeExports.jsx("button",{className:styles$5.ghostBtn,onClick:()=>He(Ke.id),disabled:h||je,children:je?"Replaying...":"Replay"})]}),Ke.data?.error!=null&&jsxRuntimeExports.jsx("div",{className:styles$5.eventError,children:String(Ke.data.error)}),Ke.data?.message!=null&&jsxRuntimeExports.jsx("div",{className:styles$5.eventMessage,children:String(Ke.data.message)})]},Ke.id)})}),Ae.length===0&&jsxRuntimeExports.jsx("div",{className:styles$5.empty,children:"No events yet. Press Run to start."})]})}function typeColor(Ae){switch(Ae){case"error":return"var(--status-red)";case"warning":return"var(--status-orange)";case"spawn":return"var(--status-green)";case"activation":return"var(--status-blue)";case"complete":return"var(--status-teal)";default:return"var(--text-primary)"}}const container$1="_container_7sqle_1",tabRow="_tabRow_7sqle_15",tab$2="_tab_7sqle_15",active$2="_active_7sqle_63",refreshBtn="_refreshBtn_7sqle_73",content$1="_content_7sqle_107",empty$1="_empty_7sqle_119",entry="_entry_7sqle_133",entryHeader="_entryHeader_7sqle_149",entryKey="_entryKey_7sqle_163",typeBadge="_typeBadge_7sqle_183",entryAuthor="_entryAuthor_7sqle_199",accessCount="_accessCount_7sqle_209",entryValue="_entryValue_7sqle_221",tagRow="_tagRow_7sqle_233",tag="_tag_7sqle_233",styles$4={container:container$1,tabRow,tab:tab$2,active:active$2,refreshBtn,content:content$1,empty:empty$1,entry,entryHeader,entryKey,typeBadge,entryAuthor,accessCount,entryValue,tagRow,tag},typeColors={fact:"var(--status-blue)",procedure:"var(--status-cyan)",observation:"var(--status-green)",mistake:"var(--status-red)",preference:"var(--status-purple)"};function MemoryPanel(){const Ae=useMemoryStore(je=>je.entries),r=useMemoryStore(je=>je.runId),[o,a]=reactExports.useState([]),[h,Ce]=reactExports.useState("working"),[ke,Te]=reactExports.useState(0);return reactExports.useEffect(()=>{if(h==="longterm"){const je=createMemoryDB();new MemoryManager(je).getAll().then(a).catch(()=>{})}},[h,ke]),jsxRuntimeExports.jsxs("div",{className:styles$4.container,children:[jsxRuntimeExports.jsxs("div",{className:styles$4.tabRow,children:[jsxRuntimeExports.jsxs("button",{onClick:()=>Ce("working"),className:`${styles$4.tab}${h==="working"?` ${styles$4.active}`:""}`,children:["Working",r?` (${Ae.length})`:""]}),jsxRuntimeExports.jsxs("button",{onClick:()=>Ce("longterm"),className:`${styles$4.tab}${h==="longterm"?` ${styles$4.active}`:""}`,children:["Long-Term (",o.length,")"]}),h==="longterm"&&jsxRuntimeExports.jsx("button",{onClick:()=>Te(je=>je+1),className:styles$4.refreshBtn,title:"Refresh",children:"Refresh"})]}),jsxRuntimeExports.jsxs("div",{className:styles$4.content,children:[h==="working"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!r&&jsxRuntimeExports.jsx("div",{className:styles$4.empty,children:"No active run. Working memory is created during runs."}),r&&Ae.length===0&&jsxRuntimeExports.jsx("div",{className:styles$4.empty,children:"Working memory is empty. Agents will write here during the run."}),Ae.map(je=>jsxRuntimeExports.jsxs("div",{className:styles$4.entry,children:[jsxRuntimeExports.jsxs("div",{className:styles$4.entryHeader,children:[jsxRuntimeExports.jsx("span",{className:styles$4.entryKey,children:je.key}),jsxRuntimeExports.jsx("span",{className:styles$4.entryAuthor,children:je.authorAgentId.split("/").pop()})]}),jsxRuntimeExports.jsx("div",{className:styles$4.entryValue,children:je.value}),je.tags.length>0&&jsxRuntimeExports.jsx("div",{className:styles$4.tagRow,children:je.tags.map(Oe=>jsxRuntimeExports.jsx("span",{className:styles$4.tag,children:Oe},Oe))})]},je.id))]}),h==="longterm"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[o.length===0&&jsxRuntimeExports.jsx("div",{className:styles$4.empty,children:"No long-term memories yet. Complete a run with memory enabled."}),o.map(je=>jsxRuntimeExports.jsxs("div",{className:styles$4.entry,children:[jsxRuntimeExports.jsxs("div",{className:styles$4.entryHeader,children:[jsxRuntimeExports.jsx("span",{className:styles$4.typeBadge,style:{color:typeColors[je.type]??"var(--text-primary)"},children:je.type}),jsxRuntimeExports.jsx("span",{className:styles$4.entryAuthor,children:je.agentId==="global"?"global":je.agentId.split("/").pop()}),jsxRuntimeExports.jsxs("span",{className:styles$4.accessCount,children:[je.accessCount,"x"]})]}),jsxRuntimeExports.jsx("div",{className:styles$4.entryValue,children:je.content}),je.tags.length>0&&jsxRuntimeExports.jsx("div",{className:styles$4.tagRow,children:je.tags.map(Oe=>jsxRuntimeExports.jsx("span",{className:styles$4.tag,children:Oe},Oe))})]},je.id))]})]})]})}const container="_container_u69wf_1",chatArea="_chatArea_u69wf_13",policyBanner="_policyBanner_u69wf_23",modeDot="_modeDot_u69wf_51",modeLabel="_modeLabel_u69wf_65",permPill="_permPill_u69wf_79",permIcon="_permIcon_u69wf_103",tabBar$1="_tabBar_u69wf_111",tab$1="_tab_u69wf_111",active$1="_active_u69wf_159",sessionPicker="_sessionPicker_u69wf_169",sessionSelect="_sessionSelect_u69wf_181",styles$3={container,chatArea,policyBanner,modeDot,modeLabel,permPill,permIcon,tabBar:tabBar$1,tab:tab$1,active:active$1,sessionPicker,sessionSelect};function InspectorPanel(){const Ae=useUI(Je=>Je.selectedAgentId),r=useSessionStore(Je=>Je.sessions),o=useAgentRegistry(Je=>Je.agents),[a,h]=reactExports.useState("chat"),Ce=Ae?[...r.values()].filter(Je=>Je.agentId===Ae).sort((Je,Ke)=>Ke.startedAt-Je.startedAt):[],[ke,Te]=reactExports.useState(0),[je,Oe]=reactExports.useState(Ae);Ae!==je&&(Oe(Ae),Te(0));const De=Ce[ke],He=Ae?o.get(Ae):void 0;return jsxRuntimeExports.jsxs("div",{className:styles$3.container,children:[jsxRuntimeExports.jsxs("div",{className:styles$3.tabBar,children:[jsxRuntimeExports.jsx("button",{onClick:()=>h("chat"),className:`${styles$3.tab}${a==="chat"?` ${styles$3.active}`:""}`,children:"Chat"}),jsxRuntimeExports.jsx("button",{onClick:()=>h("events"),className:`${styles$3.tab}${a==="events"?` ${styles$3.active}`:""}`,children:"Events"}),jsxRuntimeExports.jsx("button",{onClick:()=>h("memory"),className:`${styles$3.tab}${a==="memory"?` ${styles$3.active}`:""}`,children:"Memory"})]}),He&&jsxRuntimeExports.jsx(PolicyBanner,{profile:He}),a==="chat"&&Ce.length>1&&jsxRuntimeExports.jsx("div",{className:styles$3.sessionPicker,children:jsxRuntimeExports.jsx("select",{value:ke,onChange:Je=>Te(Number(Je.target.value)),className:styles$3.sessionSelect,children:Ce.map((Je,Ke)=>jsxRuntimeExports.jsxs("option",{value:Ke,children:[new Date(Je.startedAt).toLocaleTimeString()," - ",Je.status,Je.tokenCount>0?` (${Math.round(Je.tokenCount/1e3)}K tok)`:""]},Je.activationId))})}),jsxRuntimeExports.jsxs("div",{className:styles$3.chatArea,children:[a==="chat"&&jsxRuntimeExports.jsx(ChatLog,{agentId:Ae??"",messages:De?.messages??[],streamingText:De?.streamingText??""}),a==="events"&&jsxRuntimeExports.jsx(EventLogView,{}),a==="memory"&&jsxRuntimeExports.jsx(MemoryPanel,{})]})]})}const modeColors={gloves_off:"var(--status-red)",safe:"var(--status-green)",balanced:"var(--status-yellow)"};function PolicyBanner({profile:Ae}){const{policy:r}=Ae,o=modeColors[r.mode]??"var(--text-primary)",a=[{label:"spawn",enabled:r.permissions.spawnAgents},{label:"web",enabled:r.permissions.webAccess},{label:"edit_agents",enabled:r.permissions.editAgents},{label:`reads:${r.reads.length}`,enabled:r.reads.length>0},{label:`writes:${r.writes.length}`,enabled:r.writes.length>0}];return jsxRuntimeExports.jsxs("div",{className:styles$3.policyBanner,children:[jsxRuntimeExports.jsx("span",{className:styles$3.modeDot,style:{background:o}}),jsxRuntimeExports.jsx("span",{className:styles$3.modeLabel,style:{color:o},children:r.mode}),a.map(h=>jsxRuntimeExports.jsxs("span",{className:styles$3.permPill,children:[jsxRuntimeExports.jsx("span",{className:styles$3.permIcon,children:h.enabled?"✓":"✕"})," ",h.label]},h.label))]})}const isIterable=Ae=>Symbol.iterator in Ae,hasIterableEntries=Ae=>"entries"in Ae,compareEntries=(Ae,r)=>{const o=Ae instanceof Map?Ae:new Map(Ae.entries()),a=r instanceof Map?r:new Map(r.entries());if(o.size!==a.size)return!1;for(const[h,Ce]of o)if(!a.has(h)||!Object.is(Ce,a.get(h)))return!1;return!0},compareIterables=(Ae,r)=>{const o=Ae[Symbol.iterator](),a=r[Symbol.iterator]();let h=o.next(),Ce=a.next();for(;!h.done&&!Ce.done;){if(!Object.is(h.value,Ce.value))return!1;h=o.next(),Ce=a.next()}return!!h.done&&!!Ce.done};function shallow(Ae,r){return Object.is(Ae,r)?!0:typeof Ae!="object"||Ae===null||typeof r!="object"||r===null||Object.getPrototypeOf(Ae)!==Object.getPrototypeOf(r)?!1:isIterable(Ae)&&isIterable(r)?hasIterableEntries(Ae)&&hasIterableEntries(r)?compareEntries(Ae,r):compareIterables(Ae,r):compareEntries({entries:()=>Object.entries(Ae)},{entries:()=>Object.entries(r)})}function useShallow(Ae){const r=React.useRef(void 0);return o=>{const a=Ae(o);return shallow(r.current,a)?r.current:r.current=a}}const backdrop$1="_backdrop_lsia5_1",modal="_modal_lsia5_23",headerRow="_headerRow_lsia5_49",title="_title_lsia5_63",closeBtn="_closeBtn_lsia5_79",section="_section_lsia5_109",sectionTitle="_sectionTitle_lsia5_117",label="_label_lsia5_133",labelText="_labelText_lsia5_147",input="_input_lsia5_159",flexGrow="_flexGrow_lsia5_197",select="_select_lsia5_205 _input_lsia5_159",divider="_divider_lsia5_215",dangerZone="_dangerZone_lsia5_227",dangerText="_dangerText_lsia5_241",dangerBtn="_dangerBtn_lsia5_253",showKeyBtn="_showKeyBtn_lsia5_299",inputRow="_inputRow_lsia5_335",outlineBtn="_outlineBtn_lsia5_345",styles$2={backdrop:backdrop$1,modal,headerRow,title,closeBtn,section,sectionTitle,label,labelText,input,flexGrow,select,divider,dangerZone,dangerText,dangerBtn,showKeyBtn,inputRow,outlineBtn};function SettingsModal(){const Ae=useUI(We=>We.settingsOpen),r=useUI(We=>We.apiKey),o=useUI(useShallow(We=>We.kernelConfig)),[a,h]=reactExports.useState(!1),[Ce,ke]=reactExports.useState(""),Te=reactExports.useCallback(We=>{We.key==="Escape"&&uiStore.getState().setSettingsOpen(!1)},[]);reactExports.useEffect(()=>{if(Ae)return document.addEventListener("keydown",Te),()=>document.removeEventListener("keydown",Te)},[Ae,Te]);const[je,Oe]=reactExports.useState(Ae);if(Ae!==je&&(Oe(Ae),Ae&&(h(!1),ke(""))),!Ae)return null;const De=()=>uiStore.getState().setSettingsOpen(!1),He=We=>{We.target===We.currentTarget&&De()},Je=()=>{try{vfsStore.setState({files:new Map})}catch{}try{agentRegistry.setState({agents:new Map})}catch{}try{eventLogStore.getState().clear()}catch{}try{sessionStore.getState().clearAll()}catch{}De()},Ke=o.model??"gemini-3-flash-preview";return jsxRuntimeExports.jsx("div",{className:styles$2.backdrop,onClick:He,children:jsxRuntimeExports.jsxs("div",{className:styles$2.modal,children:[jsxRuntimeExports.jsxs("div",{className:styles$2.headerRow,children:[jsxRuntimeExports.jsx("h2",{className:styles$2.title,children:"Settings"}),jsxRuntimeExports.jsx("button",{onClick:De,className:styles$2.closeBtn,"aria-label":"Close settings",children:"x"})]}),jsxRuntimeExports.jsxs("div",{className:styles$2.section,children:[jsxRuntimeExports.jsx("h3",{className:styles$2.sectionTitle,children:"API Configuration"}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"API Key"}),jsxRuntimeExports.jsxs("div",{className:styles$2.inputRow,children:[jsxRuntimeExports.jsx("input",{type:a?"text":"password",value:r,onChange:We=>uiStore.getState().setApiKey(We.target.value),placeholder:"Enter your Gemini API key",className:`${styles$2.input} ${styles$2.flexGrow}`}),jsxRuntimeExports.jsx("button",{onClick:()=>h(We=>!We),className:styles$2.showKeyBtn,children:a?"Hide":"Show"})]})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Model"}),jsxRuntimeExports.jsxs("select",{value:Ke,onChange:We=>uiStore.getState().setKernelConfig({model:We.target.value}),className:styles$2.select,children:[jsxRuntimeExports.jsx("option",{value:"gemini-3-flash-preview",children:"gemini-3-flash-preview"}),jsxRuntimeExports.jsx("option",{value:"gemini-3-pro-preview",children:"gemini-3-pro-preview"}),jsxRuntimeExports.jsx("option",{value:"gemini-2.5-flash",children:"gemini-2.5-flash"}),jsxRuntimeExports.jsx("option",{value:"gemini-2.5-pro",children:"gemini-2.5-pro"}),jsxRuntimeExports.jsx("option",{value:"gemini-2.0-flash",children:"gemini-2.0-flash"})]})]})]}),jsxRuntimeExports.jsx("hr",{className:styles$2.divider}),jsxRuntimeExports.jsxs("div",{className:styles$2.section,children:[jsxRuntimeExports.jsx("h3",{className:styles$2.sectionTitle,children:"Kernel Limits"}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Max Concurrency"}),jsxRuntimeExports.jsx("input",{type:"number",min:1,max:10,value:o.maxConcurrency,onChange:We=>uiStore.getState().setKernelConfig({maxConcurrency:Number(We.target.value)}),className:styles$2.input})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Max Depth"}),jsxRuntimeExports.jsx("input",{type:"number",min:1,max:20,value:o.maxDepth,onChange:We=>uiStore.getState().setKernelConfig({maxDepth:Number(We.target.value)}),className:styles$2.input})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Max Fanout"}),jsxRuntimeExports.jsx("input",{type:"number",min:1,max:20,value:o.maxFanout,onChange:We=>uiStore.getState().setKernelConfig({maxFanout:Number(We.target.value)}),className:styles$2.input})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Token Budget"}),jsxRuntimeExports.jsx("input",{type:"number",min:5e4,step:5e4,value:o.tokenBudget,onChange:We=>uiStore.getState().setKernelConfig({tokenBudget:Number(We.target.value)}),className:styles$2.input})]})]}),jsxRuntimeExports.jsx("hr",{className:styles$2.divider}),jsxRuntimeExports.jsxs("div",{className:styles$2.section,children:[jsxRuntimeExports.jsx("h3",{className:styles$2.sectionTitle,children:"Memory System"}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Enable Memory"}),jsxRuntimeExports.jsxs("select",{value:o.memoryEnabled!==!1?"on":"off",onChange:We=>uiStore.getState().setKernelConfig({memoryEnabled:We.target.value==="on"}),className:styles$2.select,children:[jsxRuntimeExports.jsx("option",{value:"on",children:"Enabled"}),jsxRuntimeExports.jsx("option",{value:"off",children:"Disabled"})]})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Memory Token Budget"}),jsxRuntimeExports.jsx("input",{type:"number",min:500,max:8e3,step:500,value:o.memoryTokenBudget??2e3,onChange:We=>uiStore.getState().setKernelConfig({memoryTokenBudget:Number(We.target.value)}),className:styles$2.input})]}),jsxRuntimeExports.jsx("button",{onClick:async()=>{const We=createMemoryDB();await new MemoryManager(We).clearAll()},className:styles$2.dangerBtn,style:{marginTop:8},children:"Clear All Memories"})]}),jsxRuntimeExports.jsx("hr",{className:styles$2.divider}),jsxRuntimeExports.jsxs("div",{className:styles$2.section,children:[jsxRuntimeExports.jsx("h3",{className:styles$2.sectionTitle,children:"Danger Zone"}),jsxRuntimeExports.jsx("button",{onClick:()=>{Je(),loadSampleProject(vfsStore,agentRegistry)},className:styles$2.outlineBtn,style:{marginBottom:8},children:"Reset to Sample Project"}),jsxRuntimeExports.jsxs("div",{className:styles$2.dangerZone,children:[jsxRuntimeExports.jsx("p",{className:styles$2.dangerText,children:"This will clear all files, agents, and event logs from the workspace. This action cannot be undone."}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:'Type "CLEAR" to confirm'}),jsxRuntimeExports.jsx("input",{type:"text",placeholder:'Type "CLEAR" to confirm',value:Ce,onChange:We=>ke(We.target.value),className:styles$2.input})]}),jsxRuntimeExports.jsx("button",{disabled:Ce!=="CLEAR",onClick:Je,className:styles$2.dangerBtn,children:"Clear Workspace"})]})]})]})})}const backdrop="_backdrop_1hk4l_1",palette="_palette_1hk4l_33",searchInput="_searchInput_1hk4l_69",list="_list_1hk4l_99",item="_item_1hk4l_111",selected="_selected_1hk4l_129",itemCategory="_itemCategory_1hk4l_137",itemLabel="_itemLabel_1hk4l_157",empty="_empty_1hk4l_171",styles$1={backdrop,palette,searchInput,list,item,selected,itemCategory,itemLabel,empty};function useCommands(Ae){const r=useAgentRegistry(a=>a.agents),o=useVFS(a=>a.files);return reactExports.useMemo(()=>{const a=[];for(const h of r.values())a.push({id:`select-${h.path}`,label:`Select ${h.name}`,category:"Agents",action:()=>{uiStore.getState().setSelectedAgent(h.path),Ae()}}),a.push({id:`edit-${h.path}`,label:`Edit ${h.name}`,category:"Agents",action:()=>{uiStore.getState().openFileInEditor(h.path),Ae()}});a.push({id:"pause",label:"Pause All",category:"Actions",action:()=>{runController.pause(),Ae()}}),a.push({id:"resume",label:"Resume All",category:"Actions",action:()=>{runController.resume(),Ae()}}),a.push({id:"kill",label:"Kill All",category:"Actions",action:()=>{runController.killAll(),Ae()}}),a.push({id:"nav-graph",label:"Switch to Graph",category:"Navigation",action:()=>{uiStore.getState().setActiveTab("graph"),Ae()}}),a.push({id:"nav-editor",label:"Switch to Editor",category:"Navigation",action:()=>{uiStore.getState().setActiveTab("editor"),Ae()}}),a.push({id:"nav-settings",label:"Open Settings",category:"Navigation",action:()=>{uiStore.getState().setSettingsOpen(!0),Ae()}});for(const h of o.keys())a.push({id:`open-${h}`,label:`Open ${h}`,category:"Files",action:()=>{uiStore.getState().openFileInEditor(h),Ae()}});return a},[r,o,Ae])}function CommandPalette({onClose:Ae}){const[r,o]=reactExports.useState(""),[a,h]=reactExports.useState(0),Ce=reactExports.useRef(null),ke=useCommands(Ae),Te=r.trim()?ke.filter(He=>He.label.toLowerCase().includes(r.toLowerCase())):ke;reactExports.useEffect(()=>{Ce.current?.focus()},[]);const[je,Oe]=reactExports.useState(r);je!==r&&(Oe(r),h(0));const De=He=>{He.key==="ArrowDown"&&(He.preventDefault(),h(Je=>Math.min(Je+1,Te.length-1))),He.key==="ArrowUp"&&(He.preventDefault(),h(Je=>Math.max(Je-1,0))),He.key==="Enter"&&Te[a]&&Te[a].action(),He.key==="Escape"&&Ae()};return jsxRuntimeExports.jsx("div",{className:styles$1.backdrop,onClick:Ae,children:jsxRuntimeExports.jsxs("div",{className:styles$1.palette,onClick:He=>He.stopPropagation(),children:[jsxRuntimeExports.jsx("input",{ref:Ce,type:"text",value:r,onChange:He=>o(He.target.value),onKeyDown:De,placeholder:"Type a command...",className:styles$1.searchInput}),jsxRuntimeExports.jsxs("div",{className:styles$1.list,children:[Te.slice(0,20).map((He,Je)=>jsxRuntimeExports.jsxs("div",{className:`${styles$1.item}${Je===a?` ${styles$1.selected}`:""}`,onClick:()=>He.action(),onMouseEnter:()=>h(Je),children:[jsxRuntimeExports.jsx("span",{className:styles$1.itemCategory,children:He.category}),jsxRuntimeExports.jsx("span",{className:styles$1.itemLabel,children:He.label})]},He.id)),Te.length===0&&jsxRuntimeExports.jsx("div",{className:styles$1.empty,children:"No matching commands"})]})]})})}const root="_root_d6m13_1",content="_content_d6m13_13",centerPane="_centerPane_d6m13_23",tabBar="_tabBar_d6m13_35",tab="_tab_d6m13_35",active="_active_d6m13_87",paneContent="_paneContent_d6m13_97",styles={root,content,centerPane,tabBar,tab,active,paneContent};function AppLayout(){const Ae=useUI(h=>h.activeTab),r=useUI(h=>h.setActiveTab),[o,a]=reactExports.useState(!1);return reactExports.useEffect(()=>{const h=Ce=>{(Ce.metaKey||Ce.ctrlKey)&&Ce.key==="k"&&(Ce.preventDefault(),a(ke=>!ke))};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:styles.root,children:[jsxRuntimeExports.jsx(TopBar,{}),jsxRuntimeExports.jsx("div",{className:styles.content,children:jsxRuntimeExports.jsxs(Ve,{children:[jsxRuntimeExports.jsx(Ve.Pane,{preferredSize:250,minSize:180,children:jsxRuntimeExports.jsx(WorkspaceExplorer,{})}),jsxRuntimeExports.jsx(Ve.Pane,{children:jsxRuntimeExports.jsxs("div",{className:styles.centerPane,children:[jsxRuntimeExports.jsxs("div",{className:styles.tabBar,children:[jsxRuntimeExports.jsx("button",{onClick:()=>r("graph"),className:`${styles.tab}${Ae==="graph"?` ${styles.active}`:""}`,children:"Graph"}),jsxRuntimeExports.jsx("button",{onClick:()=>r("editor"),className:`${styles.tab}${Ae==="editor"?` ${styles.active}`:""}`,children:"Editor"})]}),jsxRuntimeExports.jsx("div",{className:styles.paneContent,children:Ae==="graph"?jsxRuntimeExports.jsx(GraphView,{}):jsxRuntimeExports.jsx(AgentEditor,{})})]})}),jsxRuntimeExports.jsx(Ve.Pane,{preferredSize:350,minSize:250,children:jsxRuntimeExports.jsx(InspectorPanel,{})})]})})]}),jsxRuntimeExports.jsx(SettingsModal,{}),o&&jsxRuntimeExports.jsx(CommandPalette,{onClose:()=>a(!1)})]})}function App(){return jsxRuntimeExports.jsx(AppLayout,{})}globalThis.Buffer=bufferExports.Buffer;clientExports.createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(reactExports.StrictMode,{children:jsxRuntimeExports.jsx(App,{})}));
|
|
1188
|
+
`);if(!Ae.trimStart().startsWith("---"))return o.push({startLine:1,endLine:1,startCol:1,endCol:(a[0]?.length??0)+1,message:"Agent files should have YAML frontmatter (---)",severity:"warning"}),o;let Ce;try{Ce=matter(Ae)}catch(He){return o.push({startLine:1,endLine:3,startCol:1,endCol:4,message:`Invalid YAML: ${He instanceof Error?He.message:String(He)}`,severity:"error"}),o}const ke=Ce.data,Te=a.indexOf("---",1)+1;if((typeof ke.name!="string"||ke.name.trim()==="")&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Missing required field: name",severity:"warning"}),typeof ke.model=="string"&&!KNOWN_MODELS.includes(ke.model)){const He=a.findIndex(Je=>Je.trimStart().startsWith("model:"))+1;o.push({startLine:He||2,endLine:He||2,startCol:1,endCol:(a[He-1]?.length??0)+1,message:`Unknown model '${ke.model}'. Known: ${KNOWN_MODELS.join(", ")}`,severity:"info"})}const je=ke.safety_mode??ke.mode;if(je!=null)if(typeof je!="string")o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'safety_mode'/'mode' should be a string.",severity:"warning"});else if(!KNOWN_MODES.includes(je.trim().toLowerCase()))o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:`Unknown safety mode '${je}'. Known: safe, balanced, gloves_off.`,severity:"warning"});else{const He=je.trim().toLowerCase();(He==="gloves_off"||He==="gloves-off"||He==="glovesoff"||He==="track")&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Mode 'gloves_off' enables unrestricted execution for this agent.",severity:"warning"})}ke.reads!=null&&(Array.isArray(ke.reads)?hasNonStringItems(ke.reads)&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'reads' must only contain strings.",severity:"warning"}):o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'reads' should be an array of path patterns.",severity:"warning"})),ke.writes!=null&&(Array.isArray(ke.writes)?hasNonStringItems(ke.writes)&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'writes' must only contain strings.",severity:"warning"}):o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'writes' should be an array of path patterns.",severity:"warning"})),ke.allowed_tools!=null&&(!Array.isArray(ke.allowed_tools)||hasNonStringItems(ke.allowed_tools))&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'allowed_tools' must be an array of tool names.",severity:"warning"}),ke.blocked_tools!=null&&(!Array.isArray(ke.blocked_tools)||hasNonStringItems(ke.blocked_tools))&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'blocked_tools' must be an array of tool names.",severity:"warning"});const Oe=ke.gloves_off_triggers??ke.glovesOffTriggers;if(Oe!=null&&(!Array.isArray(Oe)||hasNonStringItems(Oe)?o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'gloves_off_triggers' should be an array of strings.",severity:"warning"}):Oe.length===0&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'gloves_off_triggers' is empty and will never match.",severity:"info"})),ke.permissions!=null)if(Array.isArray(ke.permissions))if(hasNonStringItems(ke.permissions))o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'permissions' array must contain only strings.",severity:"warning"});else{const He=ke.permissions.map(Je=>Je.toLowerCase());(He.includes("*")||He.includes("allow_all")||He.includes("all"))&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter permissions include allow-all behavior.",severity:"warning"})}else if(typeof ke.permissions=="object"){const He=ke.permissions;for(const[Je,Ke]of Object.entries(He))typeof Ke!="boolean"&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:`Permission '${Je}' should be boolean.`,severity:"warning"});He.allow_all===!0&&o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"permissions.allow_all=true makes this agent effectively unrestricted.",severity:"warning"})}else o.push({startLine:1,endLine:Te||2,startCol:1,endCol:4,message:"Frontmatter field 'permissions' should be an object or array.",severity:"warning"});if(Ce.content.trim().length===0){const He=Te+1||a.length;o.push({startLine:He,endLine:He,startCol:1,endCol:1,message:"Agent has no system prompt instructions",severity:"warning"})}if(Array.isArray(ke.tools))for(const He of ke.tools){if(typeof He!="object"||He===null)continue;const Je=He,Ke=typeof Je.name=="string"?`tool '${Je.name}'`:"tool entry";if((typeof Je.name!="string"||Je.name.trim()==="")&&o.push({startLine:Te||2,endLine:Te||2,startCol:1,endCol:4,message:"Custom tool is missing required field: name",severity:"warning"}),(typeof Je.description!="string"||Je.description.trim()==="")&&o.push({startLine:Te||2,endLine:Te||2,startCol:1,endCol:4,message:`Custom ${Ke} is missing required field: description`,severity:"warning"}),(typeof Je.prompt!="string"||Je.prompt.trim()==="")&&o.push({startLine:Te||2,endLine:Te||2,startCol:1,endCol:4,message:`Custom ${Ke} is missing required field: prompt`,severity:"warning"}),typeof Je.prompt=="string"){const We=[...Je.prompt.matchAll(/\{\{(\w+)\}\}/g)].map(ot=>ot[1]),mt=typeof Je.parameters=="object"&&Je.parameters!==null?Object.keys(Je.parameters):[];for(const ot of We)mt.includes(ot)||o.push({startLine:Te||2,endLine:Te||2,startCol:1,endCol:4,message:`Custom ${Ke} prompt references '{{${ot}}}' but no parameter '${ot}' is defined`,severity:"info"})}}return o}const container$4="_container_14fj4_1",editorArea="_editorArea_14fj4_3",emptyState="_emptyState_14fj4_5",styles$7={container:container$4,editorArea,emptyState};let themeRegistered=!1;function AgentEditor(){const Ae=useUI(Ke=>Ke.editingFilePath),r=useUI(Ke=>Ke.setEditorDirty),o=reactExports.useRef(null),a=reactExports.useRef(null),[h,Ce]=reactExports.useState(""),ke=reactExports.useRef(null);reactExports.useEffect(()=>()=>{ke.current&&clearTimeout(ke.current)},[]);const[Te,je]=reactExports.useState(Ae);if(Ae!==Te){je(Ae);const Ke=Ae?vfsStore.getState().read(Ae)??"":"";Ce(Ke)}const Oe=reactExports.useCallback(Ke=>{const We=o.current,mt=a.current;if(!We||!mt)return;const ot=We.getModel();if(!ot)return;const ht=Ae?.startsWith("agents/")??!1,rt=validateAgentContent(Ke,ht).map(at=>({startLineNumber:at.startLine,endLineNumber:at.endLine,startColumn:at.startCol,endColumn:at.endCol,message:at.message,severity:at.severity==="error"?mt.MarkerSeverity.Error:at.severity==="warning"?mt.MarkerSeverity.Warning:mt.MarkerSeverity.Info}));mt.editor.setModelMarkers(ot,"agent-validator",rt)},[Ae]),De=reactExports.useCallback((Ke,We)=>{o.current=Ke,a.current=We,themeRegistered||(We.editor.defineTheme("catppuccin-mocha",{base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"6c7086"},{token:"keyword",foreground:"cba6f7"},{token:"string",foreground:"a6e3a1"},{token:"number",foreground:"fab387"},{token:"type",foreground:"89b4fa"}],colors:{"editor.background":"#1e1e2e","editor.foreground":"#cdd6f4","editor.lineHighlightBackground":"#33324a","editor.selectionBackground":"#45475a","editorCursor.foreground":"#e0a650","editorGutter.background":"#181825"}}),themeRegistered=!0),We.editor.setTheme("catppuccin-mocha"),Ke.addAction({id:"agent-editor-save",label:"Save File",keybindings:[We.KeyMod.CtrlCmd|We.KeyCode.KeyS],run:mt=>{const ot=uiStore.getState().editingFilePath;if(!ot)return;const ht=mt.getValue();vfsStore.getState().write(ot,ht,{}),ot.startsWith("agents/")&&agentRegistry.getState().registerFromFile(ot,ht),uiStore.getState().setEditorDirty(!1)}}),Oe(h)},[h,Oe]),He=reactExports.useCallback(Ke=>{const We=Ke??"";Ce(We),r(!0),ke.current&&clearTimeout(ke.current),ke.current=setTimeout(()=>Oe(We),300)},[r,Oe]),Je=reactExports.useCallback(Ke=>{Ce(Ke),setTimeout(()=>Oe(Ke),50)},[Oe]);return jsxRuntimeExports.jsxs("div",{className:styles$7.container,children:[jsxRuntimeExports.jsx(EditorToolbar,{content:h,onContentChange:Je}),jsxRuntimeExports.jsx("div",{className:styles$7.editorArea,children:Ae?jsxRuntimeExports.jsx(Ft$1,{height:"100%",language:"markdown",value:h,onChange:He,onMount:De,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8}}},Ae):jsxRuntimeExports.jsx("div",{className:styles$7.emptyState,children:"Select a file from the workspace or create a new agent from a template."})})]})}const aria=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],defaultSchema={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...aria,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...aria],h2:[["className","sr-only"]],img:[...aria,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...aria,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...aria],table:[...aria],ul:[...aria,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},own={}.hasOwnProperty;function sanitize(Ae,r){let o={type:"root",children:[]};const a={schema:r?{...defaultSchema,...r}:defaultSchema,stack:[]},h=transform(a,Ae);return h&&(Array.isArray(h)?h.length===1?o=h[0]:o.children=h:o=h),o}function transform(Ae,r){if(r&&typeof r=="object"){const o=r;switch(typeof o.type=="string"?o.type:""){case"comment":return comment(Ae,o);case"doctype":return doctype(Ae,o);case"element":return element(Ae,o);case"root":return root$1(Ae,o);case"text":return text(Ae,o)}}}function comment(Ae,r){if(Ae.schema.allowComments){const o=typeof r.value=="string"?r.value:"",a=o.indexOf("-->"),Ce={type:"comment",value:a<0?o:o.slice(0,a)};return patch(Ce,r),Ce}}function doctype(Ae,r){if(Ae.schema.allowDoctypes){const o={type:"doctype"};return patch(o,r),o}}function element(Ae,r){const o=typeof r.tagName=="string"?r.tagName:"";Ae.stack.push(o);const a=children(Ae,r.children),h=properties(Ae,r.properties);Ae.stack.pop();let Ce=!1;if(o&&o!=="*"&&(!Ae.schema.tagNames||Ae.schema.tagNames.includes(o))&&(Ce=!0,Ae.schema.ancestors&&own.call(Ae.schema.ancestors,o))){const Te=Ae.schema.ancestors[o];let je=-1;for(Ce=!1;++je<Te.length;)Ae.stack.includes(Te[je])&&(Ce=!0)}if(!Ce)return Ae.schema.strip&&!Ae.schema.strip.includes(o)?a:void 0;const ke={type:"element",tagName:o,properties:h,children:a};return patch(ke,r),ke}function root$1(Ae,r){const a={type:"root",children:children(Ae,r.children)};return patch(a,r),a}function text(Ae,r){const a={type:"text",value:typeof r.value=="string"?r.value:""};return patch(a,r),a}function children(Ae,r){const o=[];if(Array.isArray(r)){const a=r;let h=-1;for(;++h<a.length;){const Ce=transform(Ae,a[h]);Ce&&(Array.isArray(Ce)?o.push(...Ce):o.push(Ce))}}return o}function properties(Ae,r){const o=Ae.stack[Ae.stack.length-1],a=Ae.schema.attributes,h=Ae.schema.required,Ce=a&&own.call(a,o)?a[o]:void 0,ke=a&&own.call(a,"*")?a["*"]:void 0,Te=r&&typeof r=="object"?r:{},je={};let Oe;for(Oe in Te)if(own.call(Te,Oe)){const De=Te[Oe];let He=propertyValue(Ae,findDefinition(Ce,Oe),Oe,De);He==null&&(He=propertyValue(Ae,findDefinition(ke,Oe),Oe,De)),He!=null&&(je[Oe]=He)}if(h&&own.call(h,o)){const De=h[o];for(Oe in De)own.call(De,Oe)&&!own.call(je,Oe)&&(je[Oe]=De[Oe])}return je}function propertyValue(Ae,r,o,a){return r?Array.isArray(a)?propertyValueMany(Ae,r,o,a):propertyValuePrimitive(Ae,r,o,a):void 0}function propertyValueMany(Ae,r,o,a){let h=-1;const Ce=[];for(;++h<a.length;){const ke=propertyValuePrimitive(Ae,r,o,a[h]);(typeof ke=="number"||typeof ke=="string")&&Ce.push(ke)}return Ce}function propertyValuePrimitive(Ae,r,o,a){if(!(typeof a!="boolean"&&typeof a!="number"&&typeof a!="string")&&safeProtocol(Ae,o,a)){if(typeof r=="object"&&r.length>1){let h=!1,Ce=0;for(;++Ce<r.length;){const ke=r[Ce];if(ke&&typeof ke=="object"&&"flags"in ke){if(ke.test(String(a))){h=!0;break}}else if(ke===a){h=!0;break}}if(!h)return}return Ae.schema.clobber&&Ae.schema.clobberPrefix&&Ae.schema.clobber.includes(o)?Ae.schema.clobberPrefix+a:a}}function safeProtocol(Ae,r,o){const a=Ae.schema.protocols&&own.call(Ae.schema.protocols,r)?Ae.schema.protocols[r]:void 0;if(!a||a.length===0)return!0;const h=String(o),Ce=h.indexOf(":"),ke=h.indexOf("?"),Te=h.indexOf("#"),je=h.indexOf("/");if(Ce<0||je>-1&&Ce>je||ke>-1&&Ce>ke||Te>-1&&Ce>Te)return!0;let Oe=-1;for(;++Oe<a.length;){const De=a[Oe];if(Ce===De.length&&h.slice(0,De.length)===De)return!0}return!1}function patch(Ae,r){const o=position(r);r.data&&(Ae.data=structuredClone$1(r.data)),o&&(Ae.position=o)}function findDefinition(Ae,r){let o,a=-1;if(Ae)for(;++a<Ae.length;){const h=Ae[a],Ce=typeof h=="string"?h:h[0];if(Ce===r)return h;Ce==="data*"&&(o=h)}if(r.length>4&&r.slice(0,4).toLowerCase()==="data")return o}function rehypeSanitize(Ae){return function(r){return sanitize(r,Ae)}}const oneDark={'code[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"]::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},prolog:{color:"hsl(220, 10%, 40%)"},cdata:{color:"hsl(220, 10%, 40%)"},doctype:{color:"hsl(220, 14%, 71%)"},punctuation:{color:"hsl(220, 14%, 71%)"},entity:{color:"hsl(220, 14%, 71%)",cursor:"help"},"attr-name":{color:"hsl(29, 54%, 61%)"},"class-name":{color:"hsl(29, 54%, 61%)"},boolean:{color:"hsl(29, 54%, 61%)"},constant:{color:"hsl(29, 54%, 61%)"},number:{color:"hsl(29, 54%, 61%)"},atrule:{color:"hsl(29, 54%, 61%)"},keyword:{color:"hsl(286, 60%, 67%)"},property:{color:"hsl(355, 65%, 65%)"},tag:{color:"hsl(355, 65%, 65%)"},symbol:{color:"hsl(355, 65%, 65%)"},deleted:{color:"hsl(355, 65%, 65%)"},important:{color:"hsl(355, 65%, 65%)"},selector:{color:"hsl(95, 38%, 62%)"},string:{color:"hsl(95, 38%, 62%)"},char:{color:"hsl(95, 38%, 62%)"},builtin:{color:"hsl(95, 38%, 62%)"},inserted:{color:"hsl(95, 38%, 62%)"},regex:{color:"hsl(95, 38%, 62%)"},"attr-value":{color:"hsl(95, 38%, 62%)"},"attr-value > .token.punctuation":{color:"hsl(95, 38%, 62%)"},variable:{color:"hsl(207, 82%, 66%)"},operator:{color:"hsl(207, 82%, 66%)"},function:{color:"hsl(207, 82%, 66%)"},url:{color:"hsl(187, 47%, 55%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(220, 14%, 71%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(220, 14%, 71%)"},".language-css .token.selector":{color:"hsl(355, 65%, 65%)"},".language-css .token.property":{color:"hsl(220, 14%, 71%)"},".language-css .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.string.url":{color:"hsl(95, 38%, 62%)"},".language-css .token.important":{color:"hsl(286, 60%, 67%)"},".language-css .token.atrule .token.rule":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.operator":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(5, 48%, 51%)"},".language-json .token.operator":{color:"hsl(220, 14%, 71%)"},".language-json .token.null.keyword":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.url":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.operator":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.content":{color:"hsl(207, 82%, 66%)"},".language-markdown .token.url > .token.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.url-reference.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(95, 38%, 62%)"},".language-markdown .token.bold .token.content":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.italic .token.content":{color:"hsl(286, 60%, 67%)"},".language-markdown .token.strike .token.content":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.list.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(355, 65%, 65%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.cr:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.lf:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.space:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},".line-highlight.line-highlight":{background:"hsla(220, 100%, 80%, 0.04)"},".line-highlight.line-highlight:before":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(220, 100%, 80%, 0.04)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".command-line .command-line-prompt":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(220, 14%, 45%)"},".command-line .command-line-prompt > span:before":{color:"hsl(220, 14%, 45%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(286, 60%, 67%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(224, 13%, 17%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(224, 13%, 17%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(224, 13%, 17%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(224, 13%, 17%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(219, 13%, 22%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(220, 14%, 71%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(220, 14%, 71%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(220, 14%, 71%)"}},container$3="_container_1s69j_1",empty$3="_empty_1s69j_19",timeDivider="_timeDivider_1s69j_35",userBubble="_userBubble_1s69j_91 _messageBubble_1s69j_71",assistantBubble="_assistantBubble_1s69j_107 _messageBubble_1s69j_71",toolBlock="_toolBlock_1s69j_123",toolHeader="_toolHeader_1s69j_143",toolName="_toolName_1s69j_173",toolChevron="_toolChevron_1s69j_183",expanded="_expanded_1s69j_197",toolSummary="_toolSummary_1s69j_205",toolResult="_toolResult_1s69j_217",streamCursor="_streamCursor_1s69j_239",thinkingRing="_thinkingRing_1s69j_263",tokenCounter="_tokenCounter_1s69j_297",jumpToBottom="_jumpToBottom_1s69j_321",jumpBtn="_jumpBtn_1s69j_335",styles$6={container:container$3,empty:empty$3,timeDivider,userBubble,assistantBubble,toolBlock,toolHeader,toolName,toolChevron,expanded,toolSummary,toolResult,streamCursor,thinkingRing,tokenCounter,jumpToBottom,jumpBtn};function formatTime(Ae){const r=new Date(Ae),o=String(r.getHours()).padStart(2,"0"),a=String(r.getMinutes()).padStart(2,"0"),h=String(r.getSeconds()).padStart(2,"0");return`${o}:${a}:${h}`}const oneDarkStyles=oneDark,codeStyle={...oneDark,'pre[class*="language-"]':{...oneDarkStyles['pre[class*="language-"]']??{},background:"#11111b",margin:"8px 0",padding:"12px",borderRadius:"6px",fontSize:"12px"},'code[class*="language-"]':{...oneDarkStyles['code[class*="language-"]']??{},background:"transparent"}},sanitizeSchema={...defaultSchema,attributes:{...defaultSchema.attributes,code:[...defaultSchema.attributes?.code??[],"className"]}},markdownComponents={code({className:Ae,children:r,...o}){const a=/language-(\w+)/.exec(Ae||""),h=String(r).replace(/\n$/,"");return a?jsxRuntimeExports.jsx(highlighter,{language:a[1],style:codeStyle,customStyle:{margin:"8px 0",padding:"12px",borderRadius:"6px",fontSize:"12px",background:"#11111b"},children:h}):jsxRuntimeExports.jsx("code",{className:Ae,...o,children:r})},a({href:Ae,children:r,...o}){return jsxRuntimeExports.jsx("a",{href:Ae,target:"_blank",rel:"noopener noreferrer",...o,children:r})},img({src:Ae,alt:r,...o}){return jsxRuntimeExports.jsx("img",{src:Ae,alt:r??"",loading:"lazy",...o})}};function ToolCallRow({msg:Ae}){const[r,o]=reactExports.useState(!1),a=Ae.toolCall;if(!a)return null;const h=a.result.length;return jsxRuntimeExports.jsxs("div",{className:styles$6.toolBlock,children:[jsxRuntimeExports.jsxs("div",{className:styles$6.toolHeader,role:"button",tabIndex:0,onClick:()=>o(!r),onKeyDown:Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),o(!r))},children:[jsxRuntimeExports.jsx("span",{className:styles$6.toolName,children:a.name}),!r&&jsxRuntimeExports.jsxs("span",{className:styles$6.toolSummary,children:["(",h.toLocaleString()," chars)"]}),jsxRuntimeExports.jsx("span",{className:`${styles$6.toolChevron}${r?` ${styles$6.expanded}`:""}`,children:">"})]}),r&&jsxRuntimeExports.jsx("div",{className:styles$6.toolResult,children:a.result})]})}function ChatLog({agentId:Ae,messages:r,streamingText:o=""}){const a=reactExports.useRef(null),[h,Ce]=reactExports.useState(!0),ke=reactExports.useCallback(()=>{const je=a.current;if(!je)return;const Oe=je.scrollHeight-je.scrollTop-je.clientHeight<24;Ce(Oe)},[]);reactExports.useEffect(()=>{h&&a.current&&a.current.scrollTo({top:a.current.scrollHeight,behavior:"smooth"})},[r,o,h]);const Te=r.length===0&&!o;return jsxRuntimeExports.jsxs("div",{ref:a,onScroll:ke,className:styles$6.container,children:[Te&&jsxRuntimeExports.jsx("div",{className:styles$6.empty,children:"Run an agent to see output here"}),o&&jsxRuntimeExports.jsxs("div",{className:styles$6.tokenCounter,children:["~",Math.round(o.length/4).toLocaleString()," tokens"]}),r.map((je,Oe)=>{const De=Oe>0?r[Oe-1]:null,He=De&&je.timestamp-De.timestamp>6e4;return jsxRuntimeExports.jsxs("div",{children:[He&&jsxRuntimeExports.jsx("div",{className:styles$6.timeDivider,children:jsxRuntimeExports.jsx("span",{children:formatTime(je.timestamp)})}),je.role==="tool"&&jsxRuntimeExports.jsx(ToolCallRow,{msg:je}),je.role==="user"&&jsxRuntimeExports.jsx("div",{className:styles$6.userBubble,children:je.content}),je.role==="assistant"&&jsxRuntimeExports.jsx("div",{className:styles$6.assistantBubble,children:jsxRuntimeExports.jsx(Markdown,{remarkPlugins:[remarkGfm],rehypePlugins:[[rehypeSanitize,sanitizeSchema]],components:markdownComponents,children:je.content})})]},Oe)}),o&&jsxRuntimeExports.jsxs("div",{className:styles$6.assistantBubble,children:[jsxRuntimeExports.jsx(Markdown,{remarkPlugins:[remarkGfm],rehypePlugins:[[rehypeSanitize,sanitizeSchema]],components:markdownComponents,children:o}),jsxRuntimeExports.jsx("span",{className:styles$6.streamCursor,children:"|"}),jsxRuntimeExports.jsx("span",{className:styles$6.thinkingRing})]}),!h&&jsxRuntimeExports.jsx("div",{className:styles$6.jumpToBottom,children:jsxRuntimeExports.jsx("button",{className:styles$6.jumpBtn,onClick:()=>{a.current?.scrollTo({top:a.current.scrollHeight,behavior:"smooth"})},children:"Jump to latest"})})]})}const container$2="_container_1kh8y_1",header="_header_1kh8y_15",meta="_meta_1kh8y_31",status="_status_1kh8y_45",timeline="_timeline_1kh8y_57",event="_event_1kh8y_87",eventDot="_eventDot_1kh8y_115",eventTime="_eventTime_1kh8y_135",eventType="_eventType_1kh8y_145",eventAgent="_eventAgent_1kh8y_163",eventActions="_eventActions_1kh8y_171",ghostBtn="_ghostBtn_1kh8y_195",eventError="_eventError_1kh8y_239",eventMessage="_eventMessage_1kh8y_251",empty$2="_empty_1kh8y_261",styles$5={container:container$2,header,meta,status,timeline,event,eventDot,eventTime,eventType,eventAgent,eventActions,ghostBtn,eventError,eventMessage,empty:empty$2};function EventLogView(){const Ae=useEventLog(Ke=>Ke.entries),r=useEventLog(Ke=>Ke.checkpoints),{replayFromEvent:o,restoreFromEvent:a,isRunning:h,lastReplayEventId:Ce}=useKernel(),[ke,Te]=reactExports.useState(""),[je,Oe]=reactExports.useTransition(),De=Ae.slice(-100).reverse(),He=Ke=>{Oe(async()=>{Te(`Replaying from ${Ke}...`);const We=await o(Ke);Te(We.message)})},Je=Ke=>{const We=a(Ke);Te(We.message)};return jsxRuntimeExports.jsxs("div",{className:styles$5.container,children:[jsxRuntimeExports.jsxs("div",{className:styles$5.header,children:["Event Log (",Ae.length," entries)"]}),jsxRuntimeExports.jsxs("div",{className:styles$5.meta,children:["Replay checkpoints: ",r.length,Ce?` | Last replay: ${Ce}`:""]}),ke&&jsxRuntimeExports.jsx("div",{className:styles$5.status,children:ke}),jsxRuntimeExports.jsx("div",{className:styles$5.timeline,children:De.map(Ke=>{const We=typeColor(Ke.type);return jsxRuntimeExports.jsxs("div",{className:styles$5.event,children:[jsxRuntimeExports.jsx("div",{className:styles$5.eventDot,style:{background:We}}),jsxRuntimeExports.jsx("span",{className:styles$5.eventTime,children:new Date(Ke.timestamp).toLocaleTimeString()}),jsxRuntimeExports.jsx("span",{className:styles$5.eventType,style:{color:We,background:`${We}26`},children:Ke.type}),jsxRuntimeExports.jsx("span",{className:styles$5.eventAgent,children:Ke.agentId}),jsxRuntimeExports.jsxs("div",{className:styles$5.eventActions,children:[jsxRuntimeExports.jsx("button",{className:styles$5.ghostBtn,onClick:()=>Je(Ke.id),children:"Restore"}),jsxRuntimeExports.jsx("button",{className:styles$5.ghostBtn,onClick:()=>He(Ke.id),disabled:h||je,children:je?"Replaying...":"Replay"})]}),Ke.data?.error!=null&&jsxRuntimeExports.jsx("div",{className:styles$5.eventError,children:String(Ke.data.error)}),Ke.data?.message!=null&&jsxRuntimeExports.jsx("div",{className:styles$5.eventMessage,children:String(Ke.data.message)})]},Ke.id)})}),Ae.length===0&&jsxRuntimeExports.jsx("div",{className:styles$5.empty,children:"No events yet. Press Run to start."})]})}function typeColor(Ae){switch(Ae){case"error":return"var(--status-red)";case"warning":return"var(--status-orange)";case"spawn":return"var(--status-green)";case"activation":return"var(--status-blue)";case"complete":return"var(--status-teal)";default:return"var(--text-primary)"}}const container$1="_container_7sqle_1",tabRow="_tabRow_7sqle_15",tab$2="_tab_7sqle_15",active$2="_active_7sqle_63",refreshBtn="_refreshBtn_7sqle_73",content$1="_content_7sqle_107",empty$1="_empty_7sqle_119",entry="_entry_7sqle_133",entryHeader="_entryHeader_7sqle_149",entryKey="_entryKey_7sqle_163",typeBadge="_typeBadge_7sqle_183",entryAuthor="_entryAuthor_7sqle_199",accessCount="_accessCount_7sqle_209",entryValue="_entryValue_7sqle_221",tagRow="_tagRow_7sqle_233",tag="_tag_7sqle_233",styles$4={container:container$1,tabRow,tab:tab$2,active:active$2,refreshBtn,content:content$1,empty:empty$1,entry,entryHeader,entryKey,typeBadge,entryAuthor,accessCount,entryValue,tagRow,tag},typeColors={fact:"var(--status-blue)",procedure:"var(--status-cyan)",observation:"var(--status-green)",mistake:"var(--status-red)",preference:"var(--status-purple)"};function MemoryPanel(){const Ae=useMemoryStore(je=>je.entries),r=useMemoryStore(je=>je.runId),[o,a]=reactExports.useState([]),[h,Ce]=reactExports.useState("working"),[ke,Te]=reactExports.useState(0);return reactExports.useEffect(()=>{if(h==="longterm"){const je=createMemoryDB();new MemoryManager(je).getAll().then(a).catch(()=>{})}},[h,ke]),jsxRuntimeExports.jsxs("div",{className:styles$4.container,children:[jsxRuntimeExports.jsxs("div",{className:styles$4.tabRow,children:[jsxRuntimeExports.jsxs("button",{onClick:()=>Ce("working"),className:`${styles$4.tab}${h==="working"?` ${styles$4.active}`:""}`,children:["Working",r?` (${Ae.length})`:""]}),jsxRuntimeExports.jsxs("button",{onClick:()=>Ce("longterm"),className:`${styles$4.tab}${h==="longterm"?` ${styles$4.active}`:""}`,children:["Long-Term (",o.length,")"]}),h==="longterm"&&jsxRuntimeExports.jsx("button",{onClick:()=>Te(je=>je+1),className:styles$4.refreshBtn,title:"Refresh",children:"Refresh"})]}),jsxRuntimeExports.jsxs("div",{className:styles$4.content,children:[h==="working"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!r&&jsxRuntimeExports.jsx("div",{className:styles$4.empty,children:"No active run. Working memory is created during runs."}),r&&Ae.length===0&&jsxRuntimeExports.jsx("div",{className:styles$4.empty,children:"Working memory is empty. Agents will write here during the run."}),Ae.map(je=>jsxRuntimeExports.jsxs("div",{className:styles$4.entry,children:[jsxRuntimeExports.jsxs("div",{className:styles$4.entryHeader,children:[jsxRuntimeExports.jsx("span",{className:styles$4.entryKey,children:je.key}),jsxRuntimeExports.jsx("span",{className:styles$4.entryAuthor,children:je.authorAgentId.split("/").pop()})]}),jsxRuntimeExports.jsx("div",{className:styles$4.entryValue,children:je.value}),je.tags.length>0&&jsxRuntimeExports.jsx("div",{className:styles$4.tagRow,children:je.tags.map(Oe=>jsxRuntimeExports.jsx("span",{className:styles$4.tag,children:Oe},Oe))})]},je.id))]}),h==="longterm"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[o.length===0&&jsxRuntimeExports.jsx("div",{className:styles$4.empty,children:"No long-term memories yet. Complete a run with memory enabled."}),o.map(je=>jsxRuntimeExports.jsxs("div",{className:styles$4.entry,children:[jsxRuntimeExports.jsxs("div",{className:styles$4.entryHeader,children:[jsxRuntimeExports.jsx("span",{className:styles$4.typeBadge,style:{color:typeColors[je.type]??"var(--text-primary)"},children:je.type}),jsxRuntimeExports.jsx("span",{className:styles$4.entryAuthor,children:je.agentId==="global"?"global":je.agentId.split("/").pop()}),jsxRuntimeExports.jsxs("span",{className:styles$4.accessCount,children:[je.accessCount,"x"]})]}),jsxRuntimeExports.jsx("div",{className:styles$4.entryValue,children:je.content}),je.tags.length>0&&jsxRuntimeExports.jsx("div",{className:styles$4.tagRow,children:je.tags.map(Oe=>jsxRuntimeExports.jsx("span",{className:styles$4.tag,children:Oe},Oe))})]},je.id))]})]})]})}const container="_container_u69wf_1",chatArea="_chatArea_u69wf_13",policyBanner="_policyBanner_u69wf_23",modeDot="_modeDot_u69wf_51",modeLabel="_modeLabel_u69wf_65",permPill="_permPill_u69wf_79",permIcon="_permIcon_u69wf_103",tabBar$1="_tabBar_u69wf_111",tab$1="_tab_u69wf_111",active$1="_active_u69wf_159",sessionPicker="_sessionPicker_u69wf_169",sessionSelect="_sessionSelect_u69wf_181",styles$3={container,chatArea,policyBanner,modeDot,modeLabel,permPill,permIcon,tabBar:tabBar$1,tab:tab$1,active:active$1,sessionPicker,sessionSelect};function InspectorPanel(){const Ae=useUI(Je=>Je.selectedAgentId),r=useSessionStore(Je=>Je.sessions),o=useAgentRegistry(Je=>Je.agents),[a,h]=reactExports.useState("chat"),Ce=Ae?[...r.values()].filter(Je=>Je.agentId===Ae).sort((Je,Ke)=>Ke.startedAt-Je.startedAt):[],[ke,Te]=reactExports.useState(0),[je,Oe]=reactExports.useState(Ae);Ae!==je&&(Oe(Ae),Te(0));const De=Ce[ke],He=Ae?o.get(Ae):void 0;return jsxRuntimeExports.jsxs("div",{className:styles$3.container,children:[jsxRuntimeExports.jsxs("div",{className:styles$3.tabBar,children:[jsxRuntimeExports.jsx("button",{onClick:()=>h("chat"),className:`${styles$3.tab}${a==="chat"?` ${styles$3.active}`:""}`,children:"Chat"}),jsxRuntimeExports.jsx("button",{onClick:()=>h("events"),className:`${styles$3.tab}${a==="events"?` ${styles$3.active}`:""}`,children:"Events"}),jsxRuntimeExports.jsx("button",{onClick:()=>h("memory"),className:`${styles$3.tab}${a==="memory"?` ${styles$3.active}`:""}`,children:"Memory"})]}),He&&jsxRuntimeExports.jsx(PolicyBanner,{profile:He}),a==="chat"&&Ce.length>1&&jsxRuntimeExports.jsx("div",{className:styles$3.sessionPicker,children:jsxRuntimeExports.jsx("select",{value:ke,onChange:Je=>Te(Number(Je.target.value)),className:styles$3.sessionSelect,children:Ce.map((Je,Ke)=>jsxRuntimeExports.jsxs("option",{value:Ke,children:[new Date(Je.startedAt).toLocaleTimeString()," - ",Je.status,Je.tokenCount>0?` (${Math.round(Je.tokenCount/1e3)}K tok)`:""]},Je.activationId))})}),jsxRuntimeExports.jsxs("div",{className:styles$3.chatArea,children:[a==="chat"&&jsxRuntimeExports.jsx(ChatLog,{agentId:Ae??"",messages:De?.messages??[],streamingText:De?.streamingText??""}),a==="events"&&jsxRuntimeExports.jsx(EventLogView,{}),a==="memory"&&jsxRuntimeExports.jsx(MemoryPanel,{})]})]})}const modeColors={gloves_off:"var(--status-red)",safe:"var(--status-green)",balanced:"var(--status-yellow)"};function PolicyBanner({profile:Ae}){const{policy:r}=Ae,o=modeColors[r.mode]??"var(--text-primary)",a=[{label:"spawn",enabled:r.permissions.spawnAgents},{label:"web",enabled:r.permissions.webAccess},{label:"edit_agents",enabled:r.permissions.editAgents},{label:`reads:${r.reads.length}`,enabled:r.reads.length>0},{label:`writes:${r.writes.length}`,enabled:r.writes.length>0}];return jsxRuntimeExports.jsxs("div",{className:styles$3.policyBanner,children:[jsxRuntimeExports.jsx("span",{className:styles$3.modeDot,style:{background:o}}),jsxRuntimeExports.jsx("span",{className:styles$3.modeLabel,style:{color:o},children:r.mode}),a.map(h=>jsxRuntimeExports.jsxs("span",{className:styles$3.permPill,children:[jsxRuntimeExports.jsx("span",{className:styles$3.permIcon,children:h.enabled?"✓":"✕"})," ",h.label]},h.label))]})}const isIterable=Ae=>Symbol.iterator in Ae,hasIterableEntries=Ae=>"entries"in Ae,compareEntries=(Ae,r)=>{const o=Ae instanceof Map?Ae:new Map(Ae.entries()),a=r instanceof Map?r:new Map(r.entries());if(o.size!==a.size)return!1;for(const[h,Ce]of o)if(!a.has(h)||!Object.is(Ce,a.get(h)))return!1;return!0},compareIterables=(Ae,r)=>{const o=Ae[Symbol.iterator](),a=r[Symbol.iterator]();let h=o.next(),Ce=a.next();for(;!h.done&&!Ce.done;){if(!Object.is(h.value,Ce.value))return!1;h=o.next(),Ce=a.next()}return!!h.done&&!!Ce.done};function shallow(Ae,r){return Object.is(Ae,r)?!0:typeof Ae!="object"||Ae===null||typeof r!="object"||r===null||Object.getPrototypeOf(Ae)!==Object.getPrototypeOf(r)?!1:isIterable(Ae)&&isIterable(r)?hasIterableEntries(Ae)&&hasIterableEntries(r)?compareEntries(Ae,r):compareIterables(Ae,r):compareEntries({entries:()=>Object.entries(Ae)},{entries:()=>Object.entries(r)})}function useShallow(Ae){const r=React.useRef(void 0);return o=>{const a=Ae(o);return shallow(r.current,a)?r.current:r.current=a}}const backdrop$1="_backdrop_lsia5_1",modal="_modal_lsia5_23",headerRow="_headerRow_lsia5_49",title="_title_lsia5_63",closeBtn="_closeBtn_lsia5_79",section="_section_lsia5_109",sectionTitle="_sectionTitle_lsia5_117",label="_label_lsia5_133",labelText="_labelText_lsia5_147",input="_input_lsia5_159",flexGrow="_flexGrow_lsia5_197",select="_select_lsia5_205 _input_lsia5_159",divider="_divider_lsia5_215",dangerZone="_dangerZone_lsia5_227",dangerText="_dangerText_lsia5_241",dangerBtn="_dangerBtn_lsia5_253",showKeyBtn="_showKeyBtn_lsia5_299",inputRow="_inputRow_lsia5_335",outlineBtn="_outlineBtn_lsia5_345",styles$2={backdrop:backdrop$1,modal,headerRow,title,closeBtn,section,sectionTitle,label,labelText,input,flexGrow,select,divider,dangerZone,dangerText,dangerBtn,showKeyBtn,inputRow,outlineBtn};function SettingsModal(){const Ae=useUI(We=>We.settingsOpen),r=useUI(We=>We.apiKey),o=useUI(useShallow(We=>We.kernelConfig)),[a,h]=reactExports.useState(!1),[Ce,ke]=reactExports.useState(""),Te=reactExports.useCallback(We=>{We.key==="Escape"&&uiStore.getState().setSettingsOpen(!1)},[]);reactExports.useEffect(()=>{if(Ae)return document.addEventListener("keydown",Te),()=>document.removeEventListener("keydown",Te)},[Ae,Te]);const[je,Oe]=reactExports.useState(Ae);if(Ae!==je&&(Oe(Ae),Ae&&(h(!1),ke(""))),!Ae)return null;const De=()=>uiStore.getState().setSettingsOpen(!1),He=We=>{We.target===We.currentTarget&&De()},Je=()=>{try{vfsStore.setState({files:new Map})}catch{}try{agentRegistry.setState({agents:new Map})}catch{}try{eventLogStore.getState().clear()}catch{}try{sessionStore.getState().clearAll()}catch{}De()},Ke=o.model??"gemini-3-flash-preview";return jsxRuntimeExports.jsx("div",{className:styles$2.backdrop,onClick:He,children:jsxRuntimeExports.jsxs("div",{className:styles$2.modal,children:[jsxRuntimeExports.jsxs("div",{className:styles$2.headerRow,children:[jsxRuntimeExports.jsx("h2",{className:styles$2.title,children:"Settings"}),jsxRuntimeExports.jsx("button",{onClick:De,className:styles$2.closeBtn,"aria-label":"Close settings",children:"x"})]}),jsxRuntimeExports.jsxs("div",{className:styles$2.section,children:[jsxRuntimeExports.jsx("h3",{className:styles$2.sectionTitle,children:"API Configuration"}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"API Key"}),jsxRuntimeExports.jsxs("div",{className:styles$2.inputRow,children:[jsxRuntimeExports.jsx("input",{type:a?"text":"password",value:r,onChange:We=>uiStore.getState().setApiKey(We.target.value),placeholder:"Enter your Gemini API key",className:`${styles$2.input} ${styles$2.flexGrow}`}),jsxRuntimeExports.jsx("button",{onClick:()=>h(We=>!We),className:styles$2.showKeyBtn,children:a?"Hide":"Show"})]})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Model"}),jsxRuntimeExports.jsxs("select",{value:Ke,onChange:We=>uiStore.getState().setKernelConfig({model:We.target.value}),className:styles$2.select,children:[jsxRuntimeExports.jsx("option",{value:"gemini-3-flash-preview",children:"gemini-3-flash-preview"}),jsxRuntimeExports.jsx("option",{value:"gemini-3-pro-preview",children:"gemini-3-pro-preview"}),jsxRuntimeExports.jsx("option",{value:"gemini-2.5-flash",children:"gemini-2.5-flash"}),jsxRuntimeExports.jsx("option",{value:"gemini-2.5-pro",children:"gemini-2.5-pro"}),jsxRuntimeExports.jsx("option",{value:"gemini-2.0-flash",children:"gemini-2.0-flash"})]})]})]}),jsxRuntimeExports.jsx("hr",{className:styles$2.divider}),jsxRuntimeExports.jsxs("div",{className:styles$2.section,children:[jsxRuntimeExports.jsx("h3",{className:styles$2.sectionTitle,children:"Kernel Limits"}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Max Concurrency"}),jsxRuntimeExports.jsx("input",{type:"number",min:1,max:10,value:o.maxConcurrency,onChange:We=>uiStore.getState().setKernelConfig({maxConcurrency:Number(We.target.value)}),className:styles$2.input})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Max Depth"}),jsxRuntimeExports.jsx("input",{type:"number",min:1,max:20,value:o.maxDepth,onChange:We=>uiStore.getState().setKernelConfig({maxDepth:Number(We.target.value)}),className:styles$2.input})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Max Fanout"}),jsxRuntimeExports.jsx("input",{type:"number",min:1,max:20,value:o.maxFanout,onChange:We=>uiStore.getState().setKernelConfig({maxFanout:Number(We.target.value)}),className:styles$2.input})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Token Budget"}),jsxRuntimeExports.jsx("input",{type:"number",min:5e4,step:5e4,value:o.tokenBudget,onChange:We=>uiStore.getState().setKernelConfig({tokenBudget:Number(We.target.value)}),className:styles$2.input})]})]}),jsxRuntimeExports.jsx("hr",{className:styles$2.divider}),jsxRuntimeExports.jsxs("div",{className:styles$2.section,children:[jsxRuntimeExports.jsx("h3",{className:styles$2.sectionTitle,children:"Memory System"}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Enable Memory"}),jsxRuntimeExports.jsxs("select",{value:o.memoryEnabled!==!1?"on":"off",onChange:We=>uiStore.getState().setKernelConfig({memoryEnabled:We.target.value==="on"}),className:styles$2.select,children:[jsxRuntimeExports.jsx("option",{value:"on",children:"Enabled"}),jsxRuntimeExports.jsx("option",{value:"off",children:"Disabled"})]})]}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:"Memory Token Budget"}),jsxRuntimeExports.jsx("input",{type:"number",min:500,max:8e3,step:500,value:o.memoryTokenBudget??2e3,onChange:We=>uiStore.getState().setKernelConfig({memoryTokenBudget:Number(We.target.value)}),className:styles$2.input})]}),jsxRuntimeExports.jsx("button",{onClick:async()=>{const We=createMemoryDB();await new MemoryManager(We).clearAll()},className:styles$2.dangerBtn,style:{marginTop:8},children:"Clear All Memories"})]}),jsxRuntimeExports.jsx("hr",{className:styles$2.divider}),jsxRuntimeExports.jsxs("div",{className:styles$2.section,children:[jsxRuntimeExports.jsx("h3",{className:styles$2.sectionTitle,children:"Danger Zone"}),jsxRuntimeExports.jsx("button",{onClick:()=>{Je(),loadSampleProject(vfsStore,agentRegistry)},className:styles$2.outlineBtn,style:{marginBottom:8},children:"Reset to Sample Project"}),jsxRuntimeExports.jsxs("div",{className:styles$2.dangerZone,children:[jsxRuntimeExports.jsx("p",{className:styles$2.dangerText,children:"This will clear all files, agents, and event logs from the workspace. This action cannot be undone."}),jsxRuntimeExports.jsxs("label",{className:styles$2.label,children:[jsxRuntimeExports.jsx("span",{className:styles$2.labelText,children:'Type "CLEAR" to confirm'}),jsxRuntimeExports.jsx("input",{type:"text",placeholder:'Type "CLEAR" to confirm',value:Ce,onChange:We=>ke(We.target.value),className:styles$2.input})]}),jsxRuntimeExports.jsx("button",{disabled:Ce!=="CLEAR",onClick:Je,className:styles$2.dangerBtn,children:"Clear Workspace"})]})]})]})})}const backdrop="_backdrop_1hk4l_1",palette="_palette_1hk4l_33",searchInput="_searchInput_1hk4l_69",list="_list_1hk4l_99",item="_item_1hk4l_111",selected="_selected_1hk4l_129",itemCategory="_itemCategory_1hk4l_137",itemLabel="_itemLabel_1hk4l_157",empty="_empty_1hk4l_171",styles$1={backdrop,palette,searchInput,list,item,selected,itemCategory,itemLabel,empty};function useCommands(Ae){const r=useAgentRegistry(a=>a.agents),o=useVFS(a=>a.files);return reactExports.useMemo(()=>{const a=[];for(const h of r.values())a.push({id:`select-${h.path}`,label:`Select ${h.name}`,category:"Agents",action:()=>{uiStore.getState().setSelectedAgent(h.path),Ae()}}),a.push({id:`edit-${h.path}`,label:`Edit ${h.name}`,category:"Agents",action:()=>{uiStore.getState().openFileInEditor(h.path),Ae()}});a.push({id:"pause",label:"Pause All",category:"Actions",action:()=>{runController.pause(),Ae()}}),a.push({id:"resume",label:"Resume All",category:"Actions",action:()=>{runController.resume(),Ae()}}),a.push({id:"kill",label:"Kill All",category:"Actions",action:()=>{runController.killAll(),Ae()}}),a.push({id:"nav-graph",label:"Switch to Graph",category:"Navigation",action:()=>{uiStore.getState().setActiveTab("graph"),Ae()}}),a.push({id:"nav-editor",label:"Switch to Editor",category:"Navigation",action:()=>{uiStore.getState().setActiveTab("editor"),Ae()}}),a.push({id:"nav-settings",label:"Open Settings",category:"Navigation",action:()=>{uiStore.getState().setSettingsOpen(!0),Ae()}});for(const h of o.keys())a.push({id:`open-${h}`,label:`Open ${h}`,category:"Files",action:()=>{uiStore.getState().openFileInEditor(h),Ae()}});return a},[r,o,Ae])}function CommandPalette({onClose:Ae}){const[r,o]=reactExports.useState(""),[a,h]=reactExports.useState(0),Ce=reactExports.useRef(null),ke=useCommands(Ae),Te=r.trim()?ke.filter(He=>He.label.toLowerCase().includes(r.toLowerCase())):ke;reactExports.useEffect(()=>{Ce.current?.focus()},[]);const[je,Oe]=reactExports.useState(r);je!==r&&(Oe(r),h(0));const De=He=>{He.key==="ArrowDown"&&(He.preventDefault(),h(Je=>Math.min(Je+1,Te.length-1))),He.key==="ArrowUp"&&(He.preventDefault(),h(Je=>Math.max(Je-1,0))),He.key==="Enter"&&Te[a]&&Te[a].action(),He.key==="Escape"&&Ae()};return jsxRuntimeExports.jsx("div",{className:styles$1.backdrop,onClick:Ae,children:jsxRuntimeExports.jsxs("div",{className:styles$1.palette,onClick:He=>He.stopPropagation(),children:[jsxRuntimeExports.jsx("input",{ref:Ce,type:"text",value:r,onChange:He=>o(He.target.value),onKeyDown:De,placeholder:"Type a command...",className:styles$1.searchInput}),jsxRuntimeExports.jsxs("div",{className:styles$1.list,children:[Te.slice(0,20).map((He,Je)=>jsxRuntimeExports.jsxs("div",{className:`${styles$1.item}${Je===a?` ${styles$1.selected}`:""}`,onClick:()=>He.action(),onMouseEnter:()=>h(Je),children:[jsxRuntimeExports.jsx("span",{className:styles$1.itemCategory,children:He.category}),jsxRuntimeExports.jsx("span",{className:styles$1.itemLabel,children:He.label})]},He.id)),Te.length===0&&jsxRuntimeExports.jsx("div",{className:styles$1.empty,children:"No matching commands"})]})]})})}const root="_root_d6m13_1",content="_content_d6m13_13",centerPane="_centerPane_d6m13_23",tabBar="_tabBar_d6m13_35",tab="_tab_d6m13_35",active="_active_d6m13_87",paneContent="_paneContent_d6m13_97",styles={root,content,centerPane,tabBar,tab,active,paneContent};function AppLayout(){const Ae=useUI(h=>h.activeTab),r=useUI(h=>h.setActiveTab),[o,a]=reactExports.useState(!1);return reactExports.useEffect(()=>{const h=Ce=>{(Ce.metaKey||Ce.ctrlKey)&&Ce.key==="k"&&(Ce.preventDefault(),a(ke=>!ke))};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:styles.root,children:[jsxRuntimeExports.jsx(TopBar,{}),jsxRuntimeExports.jsx("div",{className:styles.content,children:jsxRuntimeExports.jsxs(Ve,{children:[jsxRuntimeExports.jsx(Ve.Pane,{preferredSize:250,minSize:180,children:jsxRuntimeExports.jsx(WorkspaceExplorer,{})}),jsxRuntimeExports.jsx(Ve.Pane,{children:jsxRuntimeExports.jsxs("div",{className:styles.centerPane,children:[jsxRuntimeExports.jsxs("div",{className:styles.tabBar,children:[jsxRuntimeExports.jsx("button",{onClick:()=>r("graph"),className:`${styles.tab}${Ae==="graph"?` ${styles.active}`:""}`,children:"Graph"}),jsxRuntimeExports.jsx("button",{onClick:()=>r("editor"),className:`${styles.tab}${Ae==="editor"?` ${styles.active}`:""}`,children:"Editor"})]}),jsxRuntimeExports.jsx("div",{className:styles.paneContent,children:Ae==="graph"?jsxRuntimeExports.jsx(GraphView,{}):jsxRuntimeExports.jsx(AgentEditor,{})})]})}),jsxRuntimeExports.jsx(Ve.Pane,{preferredSize:350,minSize:250,children:jsxRuntimeExports.jsx(InspectorPanel,{})})]})})]}),jsxRuntimeExports.jsx(SettingsModal,{}),o&&jsxRuntimeExports.jsx(CommandPalette,{onClose:()=>a(!1)})]})}function App(){return jsxRuntimeExports.jsx(AppLayout,{})}globalThis.Buffer=bufferExports.Buffer;clientExports.createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(reactExports.StrictMode,{children:jsxRuntimeExports.jsx(App,{})}));
|
package/dist/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<link rel="preload" href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap" as="style">
|
|
10
10
|
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
|
11
11
|
<title>Markdown Agent Studio</title>
|
|
12
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
+
<script type="module" crossorigin src="/assets/index-DL1kJmD1.js"></script>
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/vendor-flow-DOjU6Ffq.js">
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assets/vendor-markdown-DmDC9MiR.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/vendor-google-eZp-A-GY.js">
|