From 43c0694899a3139f983cc16a8be22cecbb1df6c7 Mon Sep 17 00:00:00 2001 From: dhairya Date: Sat, 3 Oct 2026 00:29:01 +0530 Subject: [PATCH 1/8] fix(devui): read configured context provider metadata Refactor context provider retrieval to use the walrus operator for cleaner code. --- python/packages/devui/agent_framework_devui/_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/packages/devui/agent_framework_devui/_utils.py b/python/packages/devui/agent_framework_devui/_utils.py index 2165a9592c7..01231dd078e 100644 --- a/python/packages/devui/agent_framework_devui/_utils.py +++ b/python/packages/devui/agent_framework_devui/_utils.py @@ -101,7 +101,9 @@ def extract_agent_metadata(entity_object: Any) -> dict[str, Any]: metadata["chat_client_type"] = entity_object.client.__class__.__name__ # Try to get context providers - if ( + if context_providers := getattr(entity_object, "context_providers", None): + metadata["context_provider"] = [provider.__class__.__name__ for provider in context_providers] # type: ignore + elif ( hasattr(entity_object, "context_provider") and entity_object.context_provider and hasattr(entity_object.context_provider, "__class__") From c86050e53c5efbd6c1b2c315538621cc99db07ec Mon Sep 17 00:00:00 2001 From: dhairya Date: Sat, 3 Oct 2026 00:31:02 +0530 Subject: [PATCH 2/8] test(devui): cover current and legacy context providers Added tests for context providers in agent metadata and legacy support. --- .../devui/tests/devui/test_discovery.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/python/packages/devui/tests/devui/test_discovery.py b/python/packages/devui/tests/devui/test_discovery.py index f7cd22e7be5..35e11bca229 100644 --- a/python/packages/devui/tests/devui/test_discovery.py +++ b/python/packages/devui/tests/devui/test_discovery.py @@ -5,12 +5,44 @@ import asyncio import tempfile from pathlib import Path +from types import SimpleNamespace + +import pytest +from agent_framework import Agent, ContextProvider, InMemoryHistoryProvider from agent_framework_devui._discovery import EntityDiscovery +from agent_framework_devui._utils import extract_agent_metadata # Note: test_entities_dir fixture is provided by conftest.py +@pytest.mark.parametrize( + "context_providers, expected", + [ + ([], None), + ([InMemoryHistoryProvider()], ["InMemoryHistoryProvider"]), + ( + [InMemoryHistoryProvider(), ContextProvider("additional")], + ["InMemoryHistoryProvider", "ContextProvider"], + ), + ], +) +async def test_context_providers_in_agent_metadata(mock_chat_client, context_providers, expected): + """Discovery includes all configured providers in their configured order.""" + agent = Agent(client=mock_chat_client, name="Example", context_providers=context_providers) + + entity_info = await EntityDiscovery().create_entity_info_from_object(agent) + + assert entity_info.context_provider == expected + + +def test_legacy_context_provider_in_agent_metadata(): + """Agent-like objects using the singular attribute retain their metadata.""" + agent = SimpleNamespace(context_provider=InMemoryHistoryProvider()) + + assert extract_agent_metadata(agent)["context_provider"] == ["InMemoryHistoryProvider"] + + async def test_discover_agents(test_entities_dir): """Test that agent discovery works and returns valid agent entities.""" discovery = EntityDiscovery(test_entities_dir) From 6574f75ba0e2800970a216ff816c3b88fae74f98 Mon Sep 17 00:00:00 2001 From: dhairya Date: Mon, 5 Oct 2026 17:50:17 +0530 Subject: [PATCH 3/8] test(devui): add agent details rendering test command --- python/packages/devui/frontend/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/python/packages/devui/frontend/package.json b/python/packages/devui/frontend/package.json index 19019ddb87e..b5d56c0bf42 100644 --- a/python/packages/devui/frontend/package.json +++ b/python/packages/devui/frontend/package.json @@ -7,6 +7,7 @@ "dev": "vite", "build": "tsc -b && vite build", "lint": "eslint .", + "test:agent-details": "node --test test/agent-details.test.mjs", "test:tracing": "node --test test/trace-polling.test.mjs", "preview": "vite preview" }, From 4cd858d17941020283df90f55ea7fd1f7df7b12c Mon Sep 17 00:00:00 2001 From: dhairya Date: Mon, 5 Oct 2026 17:52:46 +0530 Subject: [PATCH 4/8] fix(devui): type context providers as a list --- python/packages/devui/frontend/src/types/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/packages/devui/frontend/src/types/index.ts b/python/packages/devui/frontend/src/types/index.ts index a8f62bfdfa2..86583be9fcd 100644 --- a/python/packages/devui/frontend/src/types/index.ts +++ b/python/packages/devui/frontend/src/types/index.ts @@ -39,7 +39,7 @@ export interface AgentInfo { instructions?: string; model_id?: string; chat_client_type?: string; - context_provider?: string | undefined; + context_provider?: string[] | undefined; middleware?: string[] | undefined; } From 3a2a8c96406892028527c50159c2228fb6442a2e Mon Sep 17 00:00:00 2001 From: dhairya Date: Mon, 5 Oct 2026 17:53:38 +0530 Subject: [PATCH 5/8] fix(devui): separate context provider names in agent details --- .../src/components/features/agent/agent-details-modal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/packages/devui/frontend/src/components/features/agent/agent-details-modal.tsx b/python/packages/devui/frontend/src/components/features/agent/agent-details-modal.tsx index 117e6e2e95a..2f23f26ee96 100644 --- a/python/packages/devui/frontend/src/components/features/agent/agent-details-modal.tsx +++ b/python/packages/devui/frontend/src/components/features/agent/agent-details-modal.tsx @@ -203,7 +203,7 @@ export function AgentDetailsModal({ className={!agent.middleware || agent.middleware.length === 0 ? "md:col-start-2" : ""} >
- {agent.context_provider} + {agent.context_provider.join(", ")}
)} From 0e1e6ffa88177125d1c9d93f35e54d85408f5851 Mon Sep 17 00:00:00 2001 From: dhairya Date: Mon, 5 Oct 2026 17:55:53 +0530 Subject: [PATCH 6/8] test(devui): cover context provider names in the rendered UI --- .../frontend/test/agent-details.test.mjs | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 python/packages/devui/frontend/test/agent-details.test.mjs diff --git a/python/packages/devui/frontend/test/agent-details.test.mjs b/python/packages/devui/frontend/test/agent-details.test.mjs new file mode 100644 index 00000000000..7797cc9a7b5 --- /dev/null +++ b/python/packages/devui/frontend/test/agent-details.test.mjs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft. All rights reserved. + +import assert from "node:assert/strict"; +import { after, before, test } from "node:test"; +import { fileURLToPath } from "node:url"; +import { createElement } from "react"; +import { renderToStaticMarkup } from "react-dom/server"; +import { createServer } from "vite"; + +let server; +let ApiClient; +let AgentDetailsModal; +const originalStorage = globalThis.localStorage; + +before(async () => { + globalThis.localStorage = { getItem: () => null, removeItem: () => {} }; + server = await createServer({ + configFile: false, + root: fileURLToPath(new URL("..", import.meta.url)), + resolve: { alias: { "@": fileURLToPath(new URL("../src", import.meta.url)) } }, + server: { middlewareMode: true, hmr: false, ws: false, watch: null }, + optimizeDeps: { noDiscovery: true, include: [] }, + }); + ({ ApiClient } = await server.ssrLoadModule("/src/services/api.ts")); + ({ AgentDetailsModal } = await server.ssrLoadModule( + "/src/components/features/agent/agent-details-modal.tsx" + )); +}); + +after(async () => { + await server?.close(); + globalThis.localStorage = originalStorage; +}); + +async function renderDiscoveredAgent(t, contextProvider) { + t.mock.method(globalThis, "fetch", async () => ({ + ok: true, + json: async () => ({ + entities: [{ + id: "test-agent", + type: "agent", + source: "in_memory", + context_provider: contextProvider, + }], + }), + })); + const { agents } = await new ApiClient("http://localhost").getEntities(); + return renderToStaticMarkup(createElement(AgentDetailsModal, { + agent: agents[0], + open: true, + onOpenChange: () => {}, + })); +} + +test("separates multiple context provider names in discovery order", async (t) => { + const html = await renderDiscoveredAgent(t, [ + "InMemoryHistoryProvider", + "ContextProvider", + ]); + + assert.match(html, />InMemoryHistoryProvider, ContextProvider<\/div>/); + assert.doesNotMatch(html, /InMemoryHistoryProviderContextProvider/); +}); + +test("renders a single context provider without an added separator", async (t) => { + const html = await renderDiscoveredAgent(t, ["InMemoryHistoryProvider"]); + + assert.match(html, />InMemoryHistoryProvider<\/div>/); +}); + +test("omits the context provider card when discovery has no providers", async (t) => { + const html = await renderDiscoveredAgent(t, undefined); + + assert.doesNotMatch(html, /Context Provider/); +}); From fdb7ec3433987c0a6183ff993582dcf174f92051 Mon Sep 17 00:00:00 2001 From: dhairya Date: Mon, 5 Oct 2026 17:57:45 +0530 Subject: [PATCH 7/8] fix(devui): refresh the packaged provider-name renderer --- .../packages/devui/agent_framework_devui/ui/assets/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/packages/devui/agent_framework_devui/ui/assets/index.js b/python/packages/devui/agent_framework_devui/ui/assets/index.js index 087e11c5df4..5bde6ac0b1d 100644 --- a/python/packages/devui/agent_framework_devui/ui/assets/index.js +++ b/python/packages/devui/agent_framework_devui/ui/assets/index.js @@ -135,7 +135,7 @@ asyncio.run(main())`})]})]}),(0,T.jsxs)(`div`,{className:`flex gap-2 pt-4 border transition-all duration-200 opacity-0 group-hover:opacity-100`,title:n?`Copied!`:`Copy code`,children:n?(0,T.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-green-600 dark:text-green-400`,children:(0,T.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,T.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,T.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,T.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})})]})}function mg({content:e,className:t=``}){let n=e.split(` `),r=[],i=0;for(;i(0,T.jsx)(`li`,{className:`text-sm break-words`,children:hg(e)},t))},r.length));continue}if(e.match(/^[\s]*\d+\.\s+/)){let e=[];for(;i(0,T.jsx)(`li`,{className:`text-sm break-words`,children:hg(e)},t))},r.length));continue}if(e.trim().startsWith(`|`)&&e.trim().endsWith(`|`)){let e=[];for(;i=2){let t=e[0].split(`|`).slice(1,-1).map(e=>e.trim());if(e[1].match(/^\|[\s\-:|]+\|$/)){let n=e.slice(2).map(e=>e.split(`|`).slice(1,-1).map(e=>e.trim()));r.push((0,T.jsx)(`div`,{className:`my-3 overflow-x-auto`,children:(0,T.jsxs)(`table`,{className:`min-w-full border border-foreground/10 text-sm`,children:[(0,T.jsx)(`thead`,{className:`bg-foreground/5`,children:(0,T.jsx)(`tr`,{children:t.map((e,t)=>(0,T.jsx)(`th`,{className:`border-b border-foreground/10 px-3 py-2 text-left font-semibold break-words`,children:hg(e)},t))})}),(0,T.jsx)(`tbody`,{children:n.map((e,t)=>(0,T.jsx)(`tr`,{className:`border-b border-foreground/5 last:border-b-0`,children:e.map((e,t)=>(0,T.jsx)(`td`,{className:`px-3 py-2 border-r border-foreground/5 last:border-r-0 break-words`,children:hg(e)},t))},t))})]})},r.length));continue}}for(let t of e)r.push((0,T.jsx)(`p`,{className:`my-1`,children:hg(t)},r.length));continue}if(e.trim().startsWith(`>`)){let e=[];for(;i`);)e.push(n[i].replace(/^>\s?/,``)),i++;r.push((0,T.jsx)(`blockquote`,{className:`my-2 pl-4 border-l-4 border-current/30 opacity-80 italic break-words`,children:e.map((e,t)=>(0,T.jsx)(`div`,{className:`break-words`,children:hg(e)},t))},r.length));continue}if(e.match(/^[\s]*[-*_]{3,}[\s]*$/)){r.push((0,T.jsx)(`hr`,{className:`my-4 border-t border-border`},r.length)),i++;continue}if(e.trim()===``){r.push((0,T.jsx)(`div`,{className:`h-2`},r.length)),i++;continue}r.push((0,T.jsx)(`p`,{className:`my-1 break-words`,children:hg(e)},r.length)),i++}return(0,T.jsx)(`div`,{className:`markdown-content break-words ${t}`,children:r})}function hg(e){let t=[],n=e,r=0;for(;n.length>0;){let e=n.match(/`([^`]+)`/);if(e&&e.index!==void 0){e.index>0&&t.push((0,T.jsx)(`span`,{children:gg(n.slice(0,e.index))},r++)),t.push((0,T.jsx)(`code`,{className:`px-1.5 py-0.5 bg-foreground/10 rounded text-xs font-mono border border-foreground/20`,children:e[1]},r++)),n=n.slice(e.index+e[0].length);continue}t.push((0,T.jsx)(`span`,{children:gg(n)},r++));break}return t}function gg(e){let t=[],n=e,r=0;for(;n.length>0;){let e=[{regex:/\*\*\[([^\]]+)\]\(([^)]+)\)\*\*/,component:`strong-link`},{regex:/__\[([^\]]+)\]\(([^)]+)\)__/,component:`strong-link`},{regex:/\*\[([^\]]+)\]\(([^)]+)\)\*/,component:`em-link`},{regex:/_\[([^\]]+)\]\(([^)]+)\)_/,component:`em-link`},{regex:/\[([^\]]+)\]\(([^)]+)\)/,component:`link`},{regex:/\*\*(.+?)\*\*/,component:`strong`},{regex:/__(.+?)__/,component:`strong`},{regex:/\*(.+?)\*/,component:`em`},{regex:/_(.+?)_/,component:`em`}],i=!1;for(let a of e){let e=n.match(a.regex);if(e&&e.index!==void 0){if(e.index>0&&t.push(n.slice(0,e.index)),a.component===`strong`)t.push((0,T.jsx)(`strong`,{className:`font-semibold`,children:e[1]},r++));else if(a.component===`em`)t.push((0,T.jsx)(`em`,{className:`italic`,children:e[1]},r++));else if(a.component===`strong-link`){let n=e[1],i=e[2],a=gg(n);t.push((0,T.jsx)(`strong`,{className:`font-semibold`,children:(0,T.jsx)(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline break-words`,children:a})},r++))}else if(a.component===`em-link`){let n=e[1],i=e[2],a=gg(n);t.push((0,T.jsx)(`em`,{className:`italic`,children:(0,T.jsx)(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline break-words`,children:a})},r++))}else if(a.component===`link`){let n=e[1],i=e[2],a=gg(n);t.push((0,T.jsx)(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline break-words`,children:a},r++))}n=n.slice(e.index+e[0].length),i=!0;break}}if(!i){n.length>0&&t.push(n);break}}return t}function _g({content:e,className:t,isStreaming:n}){if(e.type!==`text`&&e.type!==`input_text`&&e.type!==`output_text`&&e.type!==`refusal`)return null;let r=e.type===`refusal`?e.refusal:e.text;return(0,T.jsxs)(`div`,{className:`break-words ${t||``}`,children:[(0,T.jsx)(mg,{content:r}),n&&r.length>0&&(0,T.jsx)(`span`,{className:`ml-1 inline-block h-2 w-2 animate-pulse rounded-full bg-current`})]})}function vg({content:e,className:t}){let[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(!1);if(e.type!==`input_image`&&e.type!==`output_image`)return null;let o=e.image_url;return n?(0,T.jsx)(`div`,{className:`my-2 p-3 border rounded-lg bg-muted ${t||``}`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,T.jsx)(Hl,{className:`h-4 w-4`}),(0,T.jsx)(`span`,{children:`Image could not be loaded`})]})}):(0,T.jsxs)(`div`,{className:`my-2 ${t||``}`,children:[(0,T.jsx)(`img`,{src:o,alt:`Uploaded image`,className:`rounded-lg border max-w-full transition-all cursor-pointer ${i?`max-h-none`:`max-h-64`}`,onClick:()=>a(!i),onError:()=>r(!0)}),i&&(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Click to collapse`})]})}function yg(e,t){let[n,r]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(!e){r(null);return}try{let n;if(e.startsWith(`data:`)){let t=e.split(`,`);if(t.length!==2){r(null);return}n=t[1]}else n=e;let i=atob(n),a=new Uint8Array(i.length);for(let e=0;e{URL.revokeObjectURL(s)}}catch(e){console.error(`Failed to convert base64 to blob URL:`,e),r(null)}},[e,t]),n}function bg({content:e,className:t}){let[n,r]=(0,y.useState)(!0),i=e.type===`input_file`||e.type===`output_file`,a=i?e.file_url||e.file_data:void 0,o=i?e.filename||`file`:void 0,s=o?.toLowerCase().endsWith(`.pdf`)||a?.includes(`application/pdf`),c=o?.toLowerCase().match(/\.(mp3|wav|m4a|ogg|flac|aac)$/),l=yg(i&&s?e.file_data||e.file_url:void 0,`application/pdf`);if(!i)return null;let u=l||a;return s&&a?(0,T.jsxs)(`div`,{className:`my-2 ${t||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 mb-2 px-1`,children:[(0,T.jsx)(Hl,{className:`h-4 w-4 text-red-500`}),(0,T.jsx)(`span`,{className:`text-sm font-medium truncate flex-1`,children:o}),(0,T.jsx)(`button`,{onClick:()=>r(!n),className:`text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,children:n?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(X,{className:`h-3 w-3`}),`Collapse`]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(Z,{className:`h-3 w-3`}),`Expand`]})})]}),n&&(0,T.jsxs)(`div`,{className:`border rounded-lg p-6 bg-muted/50 flex flex-col items-center justify-center gap-4`,children:[(0,T.jsx)(Hl,{className:`h-16 w-16 text-red-400`}),(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium mb-1`,children:o}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`PDF Document`})]}),(0,T.jsxs)(`div`,{className:`flex gap-3`,children:[(0,T.jsx)(`button`,{onClick:()=>{u&&window.open(u,`_blank`)},className:`text-sm bg-primary text-primary-foreground hover:bg-primary/90 flex items-center gap-2 px-4 py-2 rounded-md transition-colors`,children:`Open in new tab`}),(0,T.jsxs)(`a`,{href:u||a,download:o,className:`text-sm text-foreground hover:bg-accent flex items-center gap-2 px-4 py-2 border rounded-md transition-colors`,children:[(0,T.jsx)(zl,{className:`h-4 w-4`}),`Download`]})]})]})]}):c&&a?(0,T.jsxs)(`div`,{className:`my-2 p-3 border rounded-lg ${t||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,T.jsx)(iu,{className:`h-4 w-4 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`text-sm font-medium`,children:o})]}),(0,T.jsxs)(`audio`,{controls:!0,className:`w-full`,children:[(0,T.jsx)(`source`,{src:a}),`Your browser does not support audio playback.`]})]}):(0,T.jsx)(`div`,{className:`my-2 p-3 border rounded-lg bg-muted ${t||``}`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Hl,{className:`h-4 w-4 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`text-sm`,children:o})]}),a&&(0,T.jsxs)(`a`,{href:a,download:o,className:`text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,T.jsx)(zl,{className:`h-3 w-3`}),`Download`]})]})})}function xg({content:e,className:t}){let[n,r]=(0,y.useState)(!1);if(e.type!==`output_data`)return null;let i=e.data,a=e.mime_type,o=e.description,s=i;try{let e=JSON.parse(i);s=JSON.stringify(e,null,2)}catch{}return(0,T.jsxs)(`div`,{className:`my-2 p-3 border rounded-lg bg-muted ${t||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 cursor-pointer`,onClick:()=>r(!n),children:[(0,T.jsx)(Hl,{className:`h-4 w-4 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`text-sm font-medium`,children:o||`Data Output`}),(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:a}),n?(0,T.jsx)(X,{className:`h-4 w-4 text-muted-foreground`}):(0,T.jsx)(Z,{className:`h-4 w-4 text-muted-foreground`})]}),n&&(0,T.jsx)(`pre`,{className:`mt-2 text-xs overflow-auto max-h-64 bg-background p-2 rounded border font-mono`,children:s})]})}function Sg({content:e,className:t}){let[n,r]=(0,y.useState)(!1);if(e.type!==`function_approval_request`)return null;let{status:i,function_call:a}=e,o={pending:{icon:Nl,label:`Awaiting approval`,iconClass:`text-amber-600 dark:text-amber-400`},approved:{icon:Tl,label:`Approved`,iconClass:`text-green-600 dark:text-green-400`},rejected:{icon:Du,label:`Rejected`,iconClass:`text-red-600 dark:text-red-400`}}[i],s=o.icon,c;try{c=typeof a.arguments==`string`?JSON.parse(a.arguments):a.arguments}catch{c=a.arguments}return(0,T.jsxs)(`div`,{className:t,children:[(0,T.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-2 px-2 py-1 text-xs rounded hover:bg-muted/50 transition-colors w-fit`,children:[(0,T.jsx)(s,{className:`h-3 w-3 ${o.iconClass}`}),(0,T.jsx)(`span`,{className:`text-muted-foreground font-mono`,children:a.name}),(0,T.jsx)(`span`,{className:`text-xs ${o.iconClass}`,children:o.label}),n?(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`▼`}):(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`▶`})]}),n&&(0,T.jsx)(`div`,{className:`ml-5 mt-1 text-xs font-mono text-muted-foreground border-l-2 border-muted pl-3`,children:(0,T.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:JSON.stringify(c,null,2)})})]})}function Cg({content:e,className:t,isStreaming:n}){switch(e.type){case`text`:case`input_text`:case`output_text`:case`refusal`:return(0,T.jsx)(_g,{content:e,className:t,isStreaming:n});case`input_image`:case`output_image`:return(0,T.jsx)(vg,{content:e,className:t});case`input_file`:case`output_file`:return(0,T.jsx)(bg,{content:e,className:t});case`output_data`:return(0,T.jsx)(xg,{content:e,className:t});case`function_approval_request`:return(0,T.jsx)(Sg,{content:e,className:t});default:return null}}function wg({name:e,arguments:t,className:n}){let[r,i]=(0,y.useState)(!1),a;try{a=typeof t==`string`?JSON.parse(t):t}catch{a=t}return(0,T.jsxs)(`div`,{className:`my-2 p-3 border rounded bg-blue-50 dark:bg-blue-950/20 ${n||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 cursor-pointer`,onClick:()=>i(!r),children:[(0,T.jsx)(Fl,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,T.jsxs)(`span`,{className:`text-sm font-medium text-blue-800 dark:text-blue-300`,children:[`Function Call: `,e]}),r?(0,T.jsx)(X,{className:`h-4 w-4 text-blue-600 dark:text-blue-400 ml-auto`}):(0,T.jsx)(Z,{className:`h-4 w-4 text-blue-600 dark:text-blue-400 ml-auto`})]}),r&&(0,T.jsxs)(`div`,{className:`mt-2 text-xs font-mono bg-white dark:bg-gray-900 p-2 rounded border`,children:[(0,T.jsx)(`div`,{className:`text-blue-600 dark:text-blue-400 mb-1`,children:`Arguments:`}),(0,T.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:JSON.stringify(a,null,2)})]})]})}function Tg({output:e,call_id:t,className:n}){let[r,i]=(0,y.useState)(!1),a;try{a=typeof e==`string`?JSON.parse(e):e}catch{a=e}return(0,T.jsxs)(`div`,{className:`my-2 p-3 border rounded bg-green-50 dark:bg-green-950/20 ${n||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 cursor-pointer`,onClick:()=>i(!r),children:[(0,T.jsx)(Fl,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,T.jsx)(`span`,{className:`text-sm font-medium text-green-800 dark:text-green-300`,children:`Function Result`}),r?(0,T.jsx)(X,{className:`h-4 w-4 text-green-600 dark:text-green-400 ml-auto`}):(0,T.jsx)(Z,{className:`h-4 w-4 text-green-600 dark:text-green-400 ml-auto`})]}),r&&(0,T.jsxs)(`div`,{className:`mt-2 text-xs font-mono bg-white dark:bg-gray-900 p-2 rounded border`,children:[(0,T.jsx)(`div`,{className:`text-green-600 dark:text-green-400 mb-1`,children:`Output:`}),(0,T.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:JSON.stringify(a,null,2)}),(0,T.jsxs)(`div`,{className:`text-gray-500 text-[10px] mt-2`,children:[`Call ID: `,t]})]})]})}function Eg({item:e,className:t}){if(e.type===`message`){let n=e.status===`in_progress`,r=e.content.length>0;return(0,T.jsxs)(`div`,{className:t,children:[e.content.map((e,t)=>(0,T.jsx)(Cg,{content:e,className:t>0?`mt-2`:``,isStreaming:n},t)),n&&!r&&(0,T.jsx)(`div`,{className:`flex items-center space-x-1`,children:(0,T.jsxs)(`div`,{className:`flex space-x-1`,children:[(0,T.jsx)(`div`,{className:`h-2 w-2 animate-bounce rounded-full bg-current [animation-delay:-0.3s]`}),(0,T.jsx)(`div`,{className:`h-2 w-2 animate-bounce rounded-full bg-current [animation-delay:-0.15s]`}),(0,T.jsx)(`div`,{className:`h-2 w-2 animate-bounce rounded-full bg-current`})]})})]})}return e.type===`function_call`?(0,T.jsx)(wg,{name:e.name,arguments:e.arguments,className:t}):e.type===`function_call_output`?(0,T.jsx)(Tg,{output:e.output,call_id:e.call_id,className:t}):null}var Dg=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Og=[` `,`Enter`],kg=`Select`,[Ag,jg,Mg]=vt(kg),[Ng,Pg]=lt(kg,[Mg,Oi]),Fg=Oi(),[Ig,Lg]=Ng(kg),[Rg,zg]=Ng(kg),Bg=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Fg(t),[g,_]=y.useState(null),[v,b]=y.useState(null),[x,S]=y.useState(!1),C=bt(l),[w,E]=pt({prop:r,defaultProp:i??!1,onChange:a,caller:kg}),[D,O]=pt({prop:o,defaultProp:s,onChange:c,caller:kg}),k=y.useRef(null),A=g?m||!!g.closest(`form`):!0,[j,M]=y.useState(new Set),N=Array.from(j).map(e=>e.props.value).join(`;`);return(0,T.jsx)(Wi,{...h,children:(0,T.jsxs)(Ig,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:rn(),value:D,onValueChange:O,open:w,onOpenChange:E,dir:C,triggerPointerDownPosRef:k,disabled:f,children:[(0,T.jsx)(Ag.Provider,{scope:t,children:(0,T.jsx)(Rg,{scope:e.__scopeSelect,onNativeOptionAdd:y.useCallback(e=>{M(t=>new Set(t).add(e))},[]),onNativeOptionRemove:y.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),A?(0,T.jsxs)(F_,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:D,onChange:e=>O(e.target.value),disabled:f,form:m,children:[D===void 0?(0,T.jsx)(`option`,{value:``}):null,Array.from(j)]},N):null]})})};Bg.displayName=kg;var Vg=`SelectTrigger`,Hg=y.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Fg(n),o=Lg(Vg,n),s=o.disabled||r,c=C(t,o.onTriggerChange),l=jg(n),u=y.useRef(`touch`),[d,f,p]=L_(e=>{let t=l().filter(e=>!e.disabled),n=R_(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,T.jsx)(Gi,{asChild:!0,...a,children:(0,T.jsx)(J.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":I_(o.value)?``:void 0,...i,ref:c,onClick:q(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:q(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:q(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Dg.includes(e.key)&&(m(),e.preventDefault())})})})});Hg.displayName=Vg;var Ug=`SelectValue`,Wg=y.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Lg(Ug,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=C(t,c.onValueNodeChange);return dt(()=>{l(u)},[l,u]),(0,T.jsx)(J.span,{...s,ref:d,style:{pointerEvents:`none`},children:I_(c.value)?(0,T.jsx)(T.Fragment,{children:o}):a})});Wg.displayName=Ug;var Gg=`SelectIcon`,Kg=y.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,T.jsx)(J.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Kg.displayName=Gg;var qg=`SelectPortal`,Jg=e=>(0,T.jsx)(Yi,{asChild:!0,...e});Jg.displayName=qg;var Yg=`SelectContent`,Xg=y.forwardRef((e,t)=>{let n=Lg(Yg,e.__scopeSelect),[r,i]=y.useState();if(dt(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?gt.createPortal((0,T.jsx)(Qg,{scope:e.__scopeSelect,children:(0,T.jsx)(Ag.Slot,{scope:e.__scopeSelect,children:(0,T.jsx)(`div`,{children:e.children})})}),t):null}return(0,T.jsx)(n_,{...e,ref:t})});Xg.displayName=Yg;var Zg=10,[Qg,$g]=Ng(Yg),e_=`SelectContentImpl`,t_=E(`SelectContent.RemoveScroll`),n_=y.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=Lg(Yg,n),[b,x]=y.useState(null),[S,w]=y.useState(null),E=C(t,e=>x(e)),[D,O]=y.useState(null),[k,A]=y.useState(null),j=jg(n),[M,N]=y.useState(!1),P=y.useRef(!1);y.useEffect(()=>{if(b)return Aa(b)},[b]),Lt();let ee=y.useCallback(e=>{let[t,...n]=j().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[j,S]),F=y.useCallback(()=>ee([D,b]),[ee,D,b]);y.useEffect(()=>{M&&F()},[M,F]);let{onOpenChange:I,triggerPointerDownPosRef:L}=v;y.useEffect(()=>{if(b){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(L.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():b.contains(n.target)||I(!1),document.removeEventListener(`pointermove`,t),L.current=null};return L.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[b,I,L]),y.useEffect(()=>{let e=()=>I(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[I]);let[R,z]=L_(e=>{let t=j().filter(e=>!e.disabled),n=R_(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),B=y.useCallback((e,t,n)=>{let r=!P.current&&!n;(v.value!==void 0&&v.value===t||r)&&(O(e),r&&(P.current=!0))},[v.value]),V=y.useCallback(()=>b?.focus(),[b]),H=y.useCallback((e,t,n)=>{let r=!P.current&&!n;(v.value!==void 0&&v.value===t||r)&&A(e)},[v.value]),U=r===`popper`?o_:i_,te=U===o_?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,T.jsx)(Qg,{scope:n,content:b,viewport:S,onViewportChange:w,itemRefCallback:B,selectedItem:D,onItemLeave:V,itemTextRefCallback:H,focusSelectedItem:F,selectedItemText:k,position:r,isPositioned:M,searchRef:R,children:(0,T.jsx)(Bo,{as:t_,allowPinchZoom:!0,children:(0,T.jsx)(Ut,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:q(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,T.jsx)(kt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,T.jsx)(U,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...te,onPlaced:()=>N(!0),ref:E,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:q(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&z(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=j().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>ee(t)),e.preventDefault()}})})})})})})});n_.displayName=e_;var r_=`SelectItemAlignedPosition`,i_=y.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Lg(Yg,n),o=$g(Yg,n),[s,c]=y.useState(null),[l,u]=y.useState(null),d=C(t,e=>u(e)),f=jg(n),p=y.useRef(!1),m=y.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,b=y.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Zg,d=kd(a,[Zg,Math.max(Zg,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Zg,d=kd(a,[Zg,Math.max(Zg,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Zg*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Zg,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Zg}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);dt(()=>b(),[b]);let[x,S]=y.useState();return dt(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]),(0,T.jsx)(s_,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:y.useCallback(e=>{e&&m.current===!0&&(b(),v?.(),m.current=!1)},[b,v]),children:(0,T.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,T.jsx)(J.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});i_.displayName=r_;var a_=`SelectPopperPosition`,o_=y.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Zg,...a}=e,o=Fg(n);return(0,T.jsx)(Ki,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});o_.displayName=a_;var[s_,c_]=Ng(Yg,{}),l_=`SelectViewport`,u_=y.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=$g(l_,n),o=c_(l_,n),s=C(t,a.onViewportChange),c=y.useRef(0);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,T.jsx)(Ag.Slot,{scope:n,children:(0,T.jsx)(J.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:q(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Zg*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});u_.displayName=l_;var d_=`SelectGroup`,[f_,p_]=Ng(d_),m_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=rn();return(0,T.jsx)(f_,{scope:n,id:i,children:(0,T.jsx)(J.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});m_.displayName=d_;var h_=`SelectLabel`,g_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=p_(h_,n);return(0,T.jsx)(J.div,{id:i.id,...r,ref:t})});g_.displayName=h_;var __=`SelectItem`,[v_,y_]=Ng(__),b_=y.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Lg(__,n),c=$g(__,n),l=s.value===r,[u,d]=y.useState(a??``),[f,p]=y.useState(!1),m=C(t,e=>c.itemRefCallback?.(e,r,i)),h=rn(),g=y.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,T.jsx)(v_,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:y.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,T.jsx)(Ag.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,T.jsx)(J.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:q(o.onFocus,()=>p(!0)),onBlur:q(o.onBlur,()=>p(!1)),onClick:q(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:q(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:q(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:q(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:q(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:q(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Og.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});b_.displayName=__;var x_=`SelectItemText`,S_=y.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Lg(x_,n),s=$g(x_,n),c=y_(x_,n),l=zg(x_,n),[u,d]=y.useState(null),f=C(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=y.useMemo(()=>(0,T.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return dt(()=>(h(m),()=>g(m)),[h,g,m]),(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(J.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?gt.createPortal(a.children,o.valueNode):null]})});S_.displayName=x_;var C_=`SelectItemIndicator`,w_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return y_(C_,n).isSelected?(0,T.jsx)(J.span,{"aria-hidden":!0,...r,ref:t}):null});w_.displayName=C_;var T_=`SelectScrollUpButton`,E_=y.forwardRef((e,t)=>{let n=$g(T_,e.__scopeSelect),r=c_(T_,e.__scopeSelect),[i,a]=y.useState(!1),o=C(t,r.onScrollButtonChange);return dt(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,T.jsx)(k_,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});E_.displayName=T_;var D_=`SelectScrollDownButton`,O_=y.forwardRef((e,t)=>{let n=$g(D_,e.__scopeSelect),r=c_(D_,e.__scopeSelect),[i,a]=y.useState(!1),o=C(t,r.onScrollButtonChange);return dt(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,T.jsx)(k_,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});O_.displayName=D_;var k_=y.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=$g(`SelectScrollButton`,n),o=y.useRef(null),s=jg(n),c=y.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return y.useEffect(()=>()=>c(),[c]),dt(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,T.jsx)(J.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:q(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:q(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:q(i.onPointerLeave,()=>{c()})})}),A_=`SelectSeparator`,j_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,T.jsx)(J.div,{"aria-hidden":!0,...r,ref:t})});j_.displayName=A_;var M_=`SelectArrow`,N_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Fg(n),a=Lg(M_,n),o=$g(M_,n);return a.open&&o.position===`popper`?(0,T.jsx)(qi,{...i,...r,ref:t}):null});N_.displayName=M_;var P_=`SelectBubbleInput`,F_=y.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=y.useRef(null),a=C(r,i),o=Vf(t);return y.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,T.jsx)(J.select,{...n,style:{...ap,...n.style},ref:a,defaultValue:t})});F_.displayName=P_;function I_(e){return e===``||e===void 0}function L_(e){let t=xt(e),n=y.useRef(``),r=y.useRef(0),i=y.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=y.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function R_(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=z_(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function z_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var B_=Bg,V_=Hg,H_=Wg,U_=Kg,W_=Jg,G_=Xg,K_=u_,q_=b_,J_=S_,Y_=w_,X_=E_,Z_=O_;function Q_({...e}){return(0,T.jsx)(B_,{"data-slot":`select`,...e})}function $_({...e}){return(0,T.jsx)(H_,{"data-slot":`select-value`,...e})}function ev({className:e,size:t=`default`,children:n,...r}){return(0,T.jsxs)(V_,{"data-slot":`select-trigger`,"data-size":t,className:at(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,T.jsx)(U_,{asChild:!0,children:(0,T.jsx)(X,{className:`size-4 opacity-50`})})]})}function tv({className:e,children:t,position:n=`popper`,...r}){return(0,T.jsx)(W_,{children:(0,T.jsxs)(G_,{"data-slot":`select-content`,className:at(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,T.jsx)(rv,{}),(0,T.jsx)(K_,{className:at(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,T.jsx)(iv,{})]})})}function nv({className:e,children:t,...n}){return(0,T.jsxs)(q_,{"data-slot":`select-item`,className:at(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,T.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,T.jsx)(Y_,{children:(0,T.jsx)(Tl,{className:`size-4`})})}),(0,T.jsx)(J_,{children:t})]})}function rv({className:e,...t}){return(0,T.jsx)(X_,{"data-slot":`select-scroll-up-button`,className:at(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,T.jsx)(Dl,{className:`size-4`})})}function iv({className:e,...t}){return(0,T.jsx)(Z_,{"data-slot":`select-scroll-down-button`,className:at(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,T.jsx)(X,{className:`size-4`})})}function av({title:e,icon:t,children:n,className:r=``}){return(0,T.jsxs)(`div`,{className:`border rounded-lg p-4 bg-card ${r}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[t,(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e})]}),(0,T.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:n})]})}function ov({agent:e,open:t,onOpenChange:n}){let r=e.source===`directory`?(0,T.jsx)(Ul,{className:`h-4 w-4 text-muted-foreground`}):e.source===`in_memory`?(0,T.jsx)(Rl,{className:`h-4 w-4 text-muted-foreground`}):(0,T.jsx)(Wl,{className:`h-4 w-4 text-muted-foreground`}),i=e.source===`directory`?`Local`:e.source===`in_memory`?`In-Memory`:`Gallery`;return(0,T.jsx)(Im,{open:t,onOpenChange:n,children:(0,T.jsxs)(Lm,{className:`max-w-4xl max-h-[90vh] flex flex-col`,children:[(0,T.jsxs)(Rm,{className:`px-6 pt-6 flex-shrink-0`,children:[(0,T.jsx)(zm,{children:`Agent Details`}),(0,T.jsx)(Vm,{onClose:()=>n(!1)})]}),(0,T.jsxs)(`div`,{className:`px-6 pb-6 overflow-y-auto flex-1`,children:[(0,T.jsxs)(`div`,{className:`mb-6`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,T.jsx)(Sl,{className:`h-6 w-6 text-primary`}),(0,T.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:e.name||e.id})]}),e.description&&(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:e.description})]}),(0,T.jsx)(`div`,{className:`h-px bg-border mb-6`}),(0,T.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-4`,children:[(e.model_id||e.chat_client_type)&&(0,T.jsx)(av,{title:`Model & Client`,icon:(0,T.jsx)(Sl,{className:`h-4 w-4 text-muted-foreground`}),children:(0,T.jsxs)(`div`,{className:`space-y-1`,children:[e.model_id&&(0,T.jsx)(`div`,{className:`font-mono text-foreground`,children:e.model_id}),e.chat_client_type&&(0,T.jsxs)(`div`,{className:`text-xs`,children:[`(`,e.chat_client_type,`)`]})]})}),(0,T.jsx)(av,{title:`Source`,icon:r,children:(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(`div`,{className:`text-foreground`,children:i}),e.module_path&&(0,T.jsx)(`div`,{className:`font-mono text-xs break-all`,children:e.module_path})]})}),(0,T.jsx)(av,{title:`Environment`,icon:e.has_env?(0,T.jsx)(Ml,{className:`h-4 w-4 text-orange-500`}):(0,T.jsx)(kl,{className:`h-4 w-4 text-green-500`}),className:`md:col-span-2`,children:(0,T.jsx)(`div`,{className:e.has_env?`text-orange-600 dark:text-orange-400`:`text-green-600 dark:text-green-400`,children:e.has_env?`Requires environment variables`:`No environment variables required`})})]}),e.instructions&&(0,T.jsx)(av,{title:`Instructions`,icon:(0,T.jsx)(Hl,{className:`h-4 w-4 text-muted-foreground`}),className:`mb-4`,children:(0,T.jsx)(`div`,{className:`text-sm text-foreground leading-relaxed whitespace-pre-wrap`,children:e.instructions})}),(0,T.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e.tools&&e.tools.length>0&&(0,T.jsx)(av,{title:`Tools (${e.tools.length})`,icon:(0,T.jsx)(au,{className:`h-4 w-4 text-muted-foreground`}),children:(0,T.jsx)(`ul`,{className:`space-y-1`,children:e.tools.map((e,t)=>(0,T.jsxs)(`li`,{className:`font-mono text-xs text-foreground`,children:[`• `,e]},t))})}),e.middleware&&e.middleware.length>0&&(0,T.jsx)(av,{title:`Middlewares (${e.middleware.length})`,icon:(0,T.jsx)(au,{className:`h-4 w-4 text-muted-foreground`}),children:(0,T.jsx)(`ul`,{className:`space-y-1`,children:e.middleware.map((e,t)=>(0,T.jsxs)(`li`,{className:`font-mono text-xs text-foreground`,children:[`• `,e]},t))})}),e.context_provider&&(0,T.jsx)(av,{title:`Context Provider`,icon:(0,T.jsx)(Rl,{className:`h-4 w-4 text-muted-foreground`}),className:!e.middleware||e.middleware.length===0?`md:col-start-2`:``,children:(0,T.jsx)(`div`,{className:`font-mono text-xs text-foreground`,children:e.context_provider})})]})]})]})})}Dd();var sv=50,cv=`[Earlier streaming content omitted after refresh] +`),language:a},r.length));continue}let t=e.match(/^(#{1,6})\s+(.+)$/);if(t){let e=t[1].length,n=t[2],a=`${[`text-2xl`,`text-xl`,`text-lg`,`text-base`,`text-sm`,`text-sm`][e-1]} font-semibold mt-4 mb-2 first:mt-0 break-words`,o=e===1?(0,T.jsx)(`h1`,{className:a,children:hg(n)},r.length):e===2?(0,T.jsx)(`h2`,{className:a,children:hg(n)},r.length):e===3?(0,T.jsx)(`h3`,{className:a,children:hg(n)},r.length):e===4?(0,T.jsx)(`h4`,{className:a,children:hg(n)},r.length):e===5?(0,T.jsx)(`h5`,{className:a,children:hg(n)},r.length):(0,T.jsx)(`h6`,{className:a,children:hg(n)},r.length);r.push(o),i++;continue}if(e.match(/^[\s]*[-*+]\s+/)){let e=[];for(;i(0,T.jsx)(`li`,{className:`text-sm break-words`,children:hg(e)},t))},r.length));continue}if(e.match(/^[\s]*\d+\.\s+/)){let e=[];for(;i(0,T.jsx)(`li`,{className:`text-sm break-words`,children:hg(e)},t))},r.length));continue}if(e.trim().startsWith(`|`)&&e.trim().endsWith(`|`)){let e=[];for(;i=2){let t=e[0].split(`|`).slice(1,-1).map(e=>e.trim());if(e[1].match(/^\|[\s\-:|]+\|$/)){let n=e.slice(2).map(e=>e.split(`|`).slice(1,-1).map(e=>e.trim()));r.push((0,T.jsx)(`div`,{className:`my-3 overflow-x-auto`,children:(0,T.jsxs)(`table`,{className:`min-w-full border border-foreground/10 text-sm`,children:[(0,T.jsx)(`thead`,{className:`bg-foreground/5`,children:(0,T.jsx)(`tr`,{children:t.map((e,t)=>(0,T.jsx)(`th`,{className:`border-b border-foreground/10 px-3 py-2 text-left font-semibold break-words`,children:hg(e)},t))})}),(0,T.jsx)(`tbody`,{children:n.map((e,t)=>(0,T.jsx)(`tr`,{className:`border-b border-foreground/5 last:border-b-0`,children:e.map((e,t)=>(0,T.jsx)(`td`,{className:`px-3 py-2 border-r border-foreground/5 last:border-r-0 break-words`,children:hg(e)},t))},t))})]})},r.length));continue}}for(let t of e)r.push((0,T.jsx)(`p`,{className:`my-1`,children:hg(t)},r.length));continue}if(e.trim().startsWith(`>`)){let e=[];for(;i`);)e.push(n[i].replace(/^>\s?/,``)),i++;r.push((0,T.jsx)(`blockquote`,{className:`my-2 pl-4 border-l-4 border-current/30 opacity-80 italic break-words`,children:e.map((e,t)=>(0,T.jsx)(`div`,{className:`break-words`,children:hg(e)},t))},r.length));continue}if(e.match(/^[\s]*[-*_]{3,}[\s]*$/)){r.push((0,T.jsx)(`hr`,{className:`my-4 border-t border-border`},r.length)),i++;continue}if(e.trim()===``){r.push((0,T.jsx)(`div`,{className:`h-2`},r.length)),i++;continue}r.push((0,T.jsx)(`p`,{className:`my-1 break-words`,children:hg(e)},r.length)),i++}return(0,T.jsx)(`div`,{className:`markdown-content break-words ${t}`,children:r})}function hg(e){let t=[],n=e,r=0;for(;n.length>0;){let e=n.match(/`([^`]+)`/);if(e&&e.index!==void 0){e.index>0&&t.push((0,T.jsx)(`span`,{children:gg(n.slice(0,e.index))},r++)),t.push((0,T.jsx)(`code`,{className:`px-1.5 py-0.5 bg-foreground/10 rounded text-xs font-mono border border-foreground/20`,children:e[1]},r++)),n=n.slice(e.index+e[0].length);continue}t.push((0,T.jsx)(`span`,{children:gg(n)},r++));break}return t}function gg(e){let t=[],n=e,r=0;for(;n.length>0;){let e=[{regex:/\*\*\[([^\]]+)\]\(([^)]+)\)\*\*/,component:`strong-link`},{regex:/__\[([^\]]+)\]\(([^)]+)\)__/,component:`strong-link`},{regex:/\*\[([^\]]+)\]\(([^)]+)\)\*/,component:`em-link`},{regex:/_\[([^\]]+)\]\(([^)]+)\)_/,component:`em-link`},{regex:/\[([^\]]+)\]\(([^)]+)\)/,component:`link`},{regex:/\*\*(.+?)\*\*/,component:`strong`},{regex:/__(.+?)__/,component:`strong`},{regex:/\*(.+?)\*/,component:`em`},{regex:/_(.+?)_/,component:`em`}],i=!1;for(let a of e){let e=n.match(a.regex);if(e&&e.index!==void 0){if(e.index>0&&t.push(n.slice(0,e.index)),a.component===`strong`)t.push((0,T.jsx)(`strong`,{className:`font-semibold`,children:e[1]},r++));else if(a.component===`em`)t.push((0,T.jsx)(`em`,{className:`italic`,children:e[1]},r++));else if(a.component===`strong-link`){let n=e[1],i=e[2],a=gg(n);t.push((0,T.jsx)(`strong`,{className:`font-semibold`,children:(0,T.jsx)(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline break-words`,children:a})},r++))}else if(a.component===`em-link`){let n=e[1],i=e[2],a=gg(n);t.push((0,T.jsx)(`em`,{className:`italic`,children:(0,T.jsx)(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline break-words`,children:a})},r++))}else if(a.component===`link`){let n=e[1],i=e[2],a=gg(n);t.push((0,T.jsx)(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline break-words`,children:a},r++))}n=n.slice(e.index+e[0].length),i=!0;break}}if(!i){n.length>0&&t.push(n);break}}return t}function _g({content:e,className:t,isStreaming:n}){if(e.type!==`text`&&e.type!==`input_text`&&e.type!==`output_text`&&e.type!==`refusal`)return null;let r=e.type===`refusal`?e.refusal:e.text;return(0,T.jsxs)(`div`,{className:`break-words ${t||``}`,children:[(0,T.jsx)(mg,{content:r}),n&&r.length>0&&(0,T.jsx)(`span`,{className:`ml-1 inline-block h-2 w-2 animate-pulse rounded-full bg-current`})]})}function vg({content:e,className:t}){let[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(!1);if(e.type!==`input_image`&&e.type!==`output_image`)return null;let o=e.image_url;return n?(0,T.jsx)(`div`,{className:`my-2 p-3 border rounded-lg bg-muted ${t||``}`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,T.jsx)(Hl,{className:`h-4 w-4`}),(0,T.jsx)(`span`,{children:`Image could not be loaded`})]})}):(0,T.jsxs)(`div`,{className:`my-2 ${t||``}`,children:[(0,T.jsx)(`img`,{src:o,alt:`Uploaded image`,className:`rounded-lg border max-w-full transition-all cursor-pointer ${i?`max-h-none`:`max-h-64`}`,onClick:()=>a(!i),onError:()=>r(!0)}),i&&(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Click to collapse`})]})}function yg(e,t){let[n,r]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(!e){r(null);return}try{let n;if(e.startsWith(`data:`)){let t=e.split(`,`);if(t.length!==2){r(null);return}n=t[1]}else n=e;let i=atob(n),a=new Uint8Array(i.length);for(let e=0;e{URL.revokeObjectURL(s)}}catch(e){console.error(`Failed to convert base64 to blob URL:`,e),r(null)}},[e,t]),n}function bg({content:e,className:t}){let[n,r]=(0,y.useState)(!0),i=e.type===`input_file`||e.type===`output_file`,a=i?e.file_url||e.file_data:void 0,o=i?e.filename||`file`:void 0,s=o?.toLowerCase().endsWith(`.pdf`)||a?.includes(`application/pdf`),c=o?.toLowerCase().match(/\.(mp3|wav|m4a|ogg|flac|aac)$/),l=yg(i&&s?e.file_data||e.file_url:void 0,`application/pdf`);if(!i)return null;let u=l||a;return s&&a?(0,T.jsxs)(`div`,{className:`my-2 ${t||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 mb-2 px-1`,children:[(0,T.jsx)(Hl,{className:`h-4 w-4 text-red-500`}),(0,T.jsx)(`span`,{className:`text-sm font-medium truncate flex-1`,children:o}),(0,T.jsx)(`button`,{onClick:()=>r(!n),className:`text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,children:n?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(X,{className:`h-3 w-3`}),`Collapse`]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(Z,{className:`h-3 w-3`}),`Expand`]})})]}),n&&(0,T.jsxs)(`div`,{className:`border rounded-lg p-6 bg-muted/50 flex flex-col items-center justify-center gap-4`,children:[(0,T.jsx)(Hl,{className:`h-16 w-16 text-red-400`}),(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium mb-1`,children:o}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`PDF Document`})]}),(0,T.jsxs)(`div`,{className:`flex gap-3`,children:[(0,T.jsx)(`button`,{onClick:()=>{u&&window.open(u,`_blank`)},className:`text-sm bg-primary text-primary-foreground hover:bg-primary/90 flex items-center gap-2 px-4 py-2 rounded-md transition-colors`,children:`Open in new tab`}),(0,T.jsxs)(`a`,{href:u||a,download:o,className:`text-sm text-foreground hover:bg-accent flex items-center gap-2 px-4 py-2 border rounded-md transition-colors`,children:[(0,T.jsx)(zl,{className:`h-4 w-4`}),`Download`]})]})]})]}):c&&a?(0,T.jsxs)(`div`,{className:`my-2 p-3 border rounded-lg ${t||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,T.jsx)(iu,{className:`h-4 w-4 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`text-sm font-medium`,children:o})]}),(0,T.jsxs)(`audio`,{controls:!0,className:`w-full`,children:[(0,T.jsx)(`source`,{src:a}),`Your browser does not support audio playback.`]})]}):(0,T.jsx)(`div`,{className:`my-2 p-3 border rounded-lg bg-muted ${t||``}`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Hl,{className:`h-4 w-4 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`text-sm`,children:o})]}),a&&(0,T.jsxs)(`a`,{href:a,download:o,className:`text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,T.jsx)(zl,{className:`h-3 w-3`}),`Download`]})]})})}function xg({content:e,className:t}){let[n,r]=(0,y.useState)(!1);if(e.type!==`output_data`)return null;let i=e.data,a=e.mime_type,o=e.description,s=i;try{let e=JSON.parse(i);s=JSON.stringify(e,null,2)}catch{}return(0,T.jsxs)(`div`,{className:`my-2 p-3 border rounded-lg bg-muted ${t||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 cursor-pointer`,onClick:()=>r(!n),children:[(0,T.jsx)(Hl,{className:`h-4 w-4 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`text-sm font-medium`,children:o||`Data Output`}),(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:a}),n?(0,T.jsx)(X,{className:`h-4 w-4 text-muted-foreground`}):(0,T.jsx)(Z,{className:`h-4 w-4 text-muted-foreground`})]}),n&&(0,T.jsx)(`pre`,{className:`mt-2 text-xs overflow-auto max-h-64 bg-background p-2 rounded border font-mono`,children:s})]})}function Sg({content:e,className:t}){let[n,r]=(0,y.useState)(!1);if(e.type!==`function_approval_request`)return null;let{status:i,function_call:a}=e,o={pending:{icon:Nl,label:`Awaiting approval`,iconClass:`text-amber-600 dark:text-amber-400`},approved:{icon:Tl,label:`Approved`,iconClass:`text-green-600 dark:text-green-400`},rejected:{icon:Du,label:`Rejected`,iconClass:`text-red-600 dark:text-red-400`}}[i],s=o.icon,c;try{c=typeof a.arguments==`string`?JSON.parse(a.arguments):a.arguments}catch{c=a.arguments}return(0,T.jsxs)(`div`,{className:t,children:[(0,T.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-2 px-2 py-1 text-xs rounded hover:bg-muted/50 transition-colors w-fit`,children:[(0,T.jsx)(s,{className:`h-3 w-3 ${o.iconClass}`}),(0,T.jsx)(`span`,{className:`text-muted-foreground font-mono`,children:a.name}),(0,T.jsx)(`span`,{className:`text-xs ${o.iconClass}`,children:o.label}),n?(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`▼`}):(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`▶`})]}),n&&(0,T.jsx)(`div`,{className:`ml-5 mt-1 text-xs font-mono text-muted-foreground border-l-2 border-muted pl-3`,children:(0,T.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:JSON.stringify(c,null,2)})})]})}function Cg({content:e,className:t,isStreaming:n}){switch(e.type){case`text`:case`input_text`:case`output_text`:case`refusal`:return(0,T.jsx)(_g,{content:e,className:t,isStreaming:n});case`input_image`:case`output_image`:return(0,T.jsx)(vg,{content:e,className:t});case`input_file`:case`output_file`:return(0,T.jsx)(bg,{content:e,className:t});case`output_data`:return(0,T.jsx)(xg,{content:e,className:t});case`function_approval_request`:return(0,T.jsx)(Sg,{content:e,className:t});default:return null}}function wg({name:e,arguments:t,className:n}){let[r,i]=(0,y.useState)(!1),a;try{a=typeof t==`string`?JSON.parse(t):t}catch{a=t}return(0,T.jsxs)(`div`,{className:`my-2 p-3 border rounded bg-blue-50 dark:bg-blue-950/20 ${n||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 cursor-pointer`,onClick:()=>i(!r),children:[(0,T.jsx)(Fl,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,T.jsxs)(`span`,{className:`text-sm font-medium text-blue-800 dark:text-blue-300`,children:[`Function Call: `,e]}),r?(0,T.jsx)(X,{className:`h-4 w-4 text-blue-600 dark:text-blue-400 ml-auto`}):(0,T.jsx)(Z,{className:`h-4 w-4 text-blue-600 dark:text-blue-400 ml-auto`})]}),r&&(0,T.jsxs)(`div`,{className:`mt-2 text-xs font-mono bg-white dark:bg-gray-900 p-2 rounded border`,children:[(0,T.jsx)(`div`,{className:`text-blue-600 dark:text-blue-400 mb-1`,children:`Arguments:`}),(0,T.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:JSON.stringify(a,null,2)})]})]})}function Tg({output:e,call_id:t,className:n}){let[r,i]=(0,y.useState)(!1),a;try{a=typeof e==`string`?JSON.parse(e):e}catch{a=e}return(0,T.jsxs)(`div`,{className:`my-2 p-3 border rounded bg-green-50 dark:bg-green-950/20 ${n||``}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 cursor-pointer`,onClick:()=>i(!r),children:[(0,T.jsx)(Fl,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,T.jsx)(`span`,{className:`text-sm font-medium text-green-800 dark:text-green-300`,children:`Function Result`}),r?(0,T.jsx)(X,{className:`h-4 w-4 text-green-600 dark:text-green-400 ml-auto`}):(0,T.jsx)(Z,{className:`h-4 w-4 text-green-600 dark:text-green-400 ml-auto`})]}),r&&(0,T.jsxs)(`div`,{className:`mt-2 text-xs font-mono bg-white dark:bg-gray-900 p-2 rounded border`,children:[(0,T.jsx)(`div`,{className:`text-green-600 dark:text-green-400 mb-1`,children:`Output:`}),(0,T.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:JSON.stringify(a,null,2)}),(0,T.jsxs)(`div`,{className:`text-gray-500 text-[10px] mt-2`,children:[`Call ID: `,t]})]})]})}function Eg({item:e,className:t}){if(e.type===`message`){let n=e.status===`in_progress`,r=e.content.length>0;return(0,T.jsxs)(`div`,{className:t,children:[e.content.map((e,t)=>(0,T.jsx)(Cg,{content:e,className:t>0?`mt-2`:``,isStreaming:n},t)),n&&!r&&(0,T.jsx)(`div`,{className:`flex items-center space-x-1`,children:(0,T.jsxs)(`div`,{className:`flex space-x-1`,children:[(0,T.jsx)(`div`,{className:`h-2 w-2 animate-bounce rounded-full bg-current [animation-delay:-0.3s]`}),(0,T.jsx)(`div`,{className:`h-2 w-2 animate-bounce rounded-full bg-current [animation-delay:-0.15s]`}),(0,T.jsx)(`div`,{className:`h-2 w-2 animate-bounce rounded-full bg-current`})]})})]})}return e.type===`function_call`?(0,T.jsx)(wg,{name:e.name,arguments:e.arguments,className:t}):e.type===`function_call_output`?(0,T.jsx)(Tg,{output:e.output,call_id:e.call_id,className:t}):null}var Dg=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Og=[` `,`Enter`],kg=`Select`,[Ag,jg,Mg]=vt(kg),[Ng,Pg]=lt(kg,[Mg,Oi]),Fg=Oi(),[Ig,Lg]=Ng(kg),[Rg,zg]=Ng(kg),Bg=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Fg(t),[g,_]=y.useState(null),[v,b]=y.useState(null),[x,S]=y.useState(!1),C=bt(l),[w,E]=pt({prop:r,defaultProp:i??!1,onChange:a,caller:kg}),[D,O]=pt({prop:o,defaultProp:s,onChange:c,caller:kg}),k=y.useRef(null),A=g?m||!!g.closest(`form`):!0,[j,M]=y.useState(new Set),N=Array.from(j).map(e=>e.props.value).join(`;`);return(0,T.jsx)(Wi,{...h,children:(0,T.jsxs)(Ig,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:rn(),value:D,onValueChange:O,open:w,onOpenChange:E,dir:C,triggerPointerDownPosRef:k,disabled:f,children:[(0,T.jsx)(Ag.Provider,{scope:t,children:(0,T.jsx)(Rg,{scope:e.__scopeSelect,onNativeOptionAdd:y.useCallback(e=>{M(t=>new Set(t).add(e))},[]),onNativeOptionRemove:y.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),A?(0,T.jsxs)(F_,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:D,onChange:e=>O(e.target.value),disabled:f,form:m,children:[D===void 0?(0,T.jsx)(`option`,{value:``}):null,Array.from(j)]},N):null]})})};Bg.displayName=kg;var Vg=`SelectTrigger`,Hg=y.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Fg(n),o=Lg(Vg,n),s=o.disabled||r,c=C(t,o.onTriggerChange),l=jg(n),u=y.useRef(`touch`),[d,f,p]=L_(e=>{let t=l().filter(e=>!e.disabled),n=R_(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,T.jsx)(Gi,{asChild:!0,...a,children:(0,T.jsx)(J.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":I_(o.value)?``:void 0,...i,ref:c,onClick:q(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:q(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:q(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Dg.includes(e.key)&&(m(),e.preventDefault())})})})});Hg.displayName=Vg;var Ug=`SelectValue`,Wg=y.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Lg(Ug,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=C(t,c.onValueNodeChange);return dt(()=>{l(u)},[l,u]),(0,T.jsx)(J.span,{...s,ref:d,style:{pointerEvents:`none`},children:I_(c.value)?(0,T.jsx)(T.Fragment,{children:o}):a})});Wg.displayName=Ug;var Gg=`SelectIcon`,Kg=y.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,T.jsx)(J.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Kg.displayName=Gg;var qg=`SelectPortal`,Jg=e=>(0,T.jsx)(Yi,{asChild:!0,...e});Jg.displayName=qg;var Yg=`SelectContent`,Xg=y.forwardRef((e,t)=>{let n=Lg(Yg,e.__scopeSelect),[r,i]=y.useState();if(dt(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?gt.createPortal((0,T.jsx)(Qg,{scope:e.__scopeSelect,children:(0,T.jsx)(Ag.Slot,{scope:e.__scopeSelect,children:(0,T.jsx)(`div`,{children:e.children})})}),t):null}return(0,T.jsx)(n_,{...e,ref:t})});Xg.displayName=Yg;var Zg=10,[Qg,$g]=Ng(Yg),e_=`SelectContentImpl`,t_=E(`SelectContent.RemoveScroll`),n_=y.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=Lg(Yg,n),[b,x]=y.useState(null),[S,w]=y.useState(null),E=C(t,e=>x(e)),[D,O]=y.useState(null),[k,A]=y.useState(null),j=jg(n),[M,N]=y.useState(!1),P=y.useRef(!1);y.useEffect(()=>{if(b)return Aa(b)},[b]),Lt();let ee=y.useCallback(e=>{let[t,...n]=j().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[j,S]),F=y.useCallback(()=>ee([D,b]),[ee,D,b]);y.useEffect(()=>{M&&F()},[M,F]);let{onOpenChange:I,triggerPointerDownPosRef:L}=v;y.useEffect(()=>{if(b){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(L.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():b.contains(n.target)||I(!1),document.removeEventListener(`pointermove`,t),L.current=null};return L.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[b,I,L]),y.useEffect(()=>{let e=()=>I(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[I]);let[R,z]=L_(e=>{let t=j().filter(e=>!e.disabled),n=R_(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),B=y.useCallback((e,t,n)=>{let r=!P.current&&!n;(v.value!==void 0&&v.value===t||r)&&(O(e),r&&(P.current=!0))},[v.value]),V=y.useCallback(()=>b?.focus(),[b]),H=y.useCallback((e,t,n)=>{let r=!P.current&&!n;(v.value!==void 0&&v.value===t||r)&&A(e)},[v.value]),U=r===`popper`?o_:i_,te=U===o_?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,T.jsx)(Qg,{scope:n,content:b,viewport:S,onViewportChange:w,itemRefCallback:B,selectedItem:D,onItemLeave:V,itemTextRefCallback:H,focusSelectedItem:F,selectedItemText:k,position:r,isPositioned:M,searchRef:R,children:(0,T.jsx)(Bo,{as:t_,allowPinchZoom:!0,children:(0,T.jsx)(Ut,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:q(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,T.jsx)(kt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,T.jsx)(U,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...te,onPlaced:()=>N(!0),ref:E,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:q(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&z(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=j().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>ee(t)),e.preventDefault()}})})})})})})});n_.displayName=e_;var r_=`SelectItemAlignedPosition`,i_=y.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Lg(Yg,n),o=$g(Yg,n),[s,c]=y.useState(null),[l,u]=y.useState(null),d=C(t,e=>u(e)),f=jg(n),p=y.useRef(!1),m=y.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,b=y.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Zg,d=kd(a,[Zg,Math.max(Zg,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Zg,d=kd(a,[Zg,Math.max(Zg,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Zg*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Zg,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Zg}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);dt(()=>b(),[b]);let[x,S]=y.useState();return dt(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]),(0,T.jsx)(s_,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:y.useCallback(e=>{e&&m.current===!0&&(b(),v?.(),m.current=!1)},[b,v]),children:(0,T.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,T.jsx)(J.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});i_.displayName=r_;var a_=`SelectPopperPosition`,o_=y.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Zg,...a}=e,o=Fg(n);return(0,T.jsx)(Ki,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});o_.displayName=a_;var[s_,c_]=Ng(Yg,{}),l_=`SelectViewport`,u_=y.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=$g(l_,n),o=c_(l_,n),s=C(t,a.onViewportChange),c=y.useRef(0);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,T.jsx)(Ag.Slot,{scope:n,children:(0,T.jsx)(J.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:q(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Zg*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});u_.displayName=l_;var d_=`SelectGroup`,[f_,p_]=Ng(d_),m_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=rn();return(0,T.jsx)(f_,{scope:n,id:i,children:(0,T.jsx)(J.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});m_.displayName=d_;var h_=`SelectLabel`,g_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=p_(h_,n);return(0,T.jsx)(J.div,{id:i.id,...r,ref:t})});g_.displayName=h_;var __=`SelectItem`,[v_,y_]=Ng(__),b_=y.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Lg(__,n),c=$g(__,n),l=s.value===r,[u,d]=y.useState(a??``),[f,p]=y.useState(!1),m=C(t,e=>c.itemRefCallback?.(e,r,i)),h=rn(),g=y.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,T.jsx)(v_,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:y.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,T.jsx)(Ag.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,T.jsx)(J.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:q(o.onFocus,()=>p(!0)),onBlur:q(o.onBlur,()=>p(!1)),onClick:q(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:q(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:q(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:q(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:q(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:q(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Og.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});b_.displayName=__;var x_=`SelectItemText`,S_=y.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Lg(x_,n),s=$g(x_,n),c=y_(x_,n),l=zg(x_,n),[u,d]=y.useState(null),f=C(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=y.useMemo(()=>(0,T.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return dt(()=>(h(m),()=>g(m)),[h,g,m]),(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(J.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?gt.createPortal(a.children,o.valueNode):null]})});S_.displayName=x_;var C_=`SelectItemIndicator`,w_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return y_(C_,n).isSelected?(0,T.jsx)(J.span,{"aria-hidden":!0,...r,ref:t}):null});w_.displayName=C_;var T_=`SelectScrollUpButton`,E_=y.forwardRef((e,t)=>{let n=$g(T_,e.__scopeSelect),r=c_(T_,e.__scopeSelect),[i,a]=y.useState(!1),o=C(t,r.onScrollButtonChange);return dt(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,T.jsx)(k_,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});E_.displayName=T_;var D_=`SelectScrollDownButton`,O_=y.forwardRef((e,t)=>{let n=$g(D_,e.__scopeSelect),r=c_(D_,e.__scopeSelect),[i,a]=y.useState(!1),o=C(t,r.onScrollButtonChange);return dt(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,T.jsx)(k_,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});O_.displayName=D_;var k_=y.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=$g(`SelectScrollButton`,n),o=y.useRef(null),s=jg(n),c=y.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return y.useEffect(()=>()=>c(),[c]),dt(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,T.jsx)(J.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:q(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:q(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:q(i.onPointerLeave,()=>{c()})})}),A_=`SelectSeparator`,j_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,T.jsx)(J.div,{"aria-hidden":!0,...r,ref:t})});j_.displayName=A_;var M_=`SelectArrow`,N_=y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Fg(n),a=Lg(M_,n),o=$g(M_,n);return a.open&&o.position===`popper`?(0,T.jsx)(qi,{...i,...r,ref:t}):null});N_.displayName=M_;var P_=`SelectBubbleInput`,F_=y.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=y.useRef(null),a=C(r,i),o=Vf(t);return y.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,T.jsx)(J.select,{...n,style:{...ap,...n.style},ref:a,defaultValue:t})});F_.displayName=P_;function I_(e){return e===``||e===void 0}function L_(e){let t=xt(e),n=y.useRef(``),r=y.useRef(0),i=y.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=y.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function R_(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=z_(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function z_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var B_=Bg,V_=Hg,H_=Wg,U_=Kg,W_=Jg,G_=Xg,K_=u_,q_=b_,J_=S_,Y_=w_,X_=E_,Z_=O_;function Q_({...e}){return(0,T.jsx)(B_,{"data-slot":`select`,...e})}function $_({...e}){return(0,T.jsx)(H_,{"data-slot":`select-value`,...e})}function ev({className:e,size:t=`default`,children:n,...r}){return(0,T.jsxs)(V_,{"data-slot":`select-trigger`,"data-size":t,className:at(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,T.jsx)(U_,{asChild:!0,children:(0,T.jsx)(X,{className:`size-4 opacity-50`})})]})}function tv({className:e,children:t,position:n=`popper`,...r}){return(0,T.jsx)(W_,{children:(0,T.jsxs)(G_,{"data-slot":`select-content`,className:at(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,T.jsx)(rv,{}),(0,T.jsx)(K_,{className:at(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,T.jsx)(iv,{})]})})}function nv({className:e,children:t,...n}){return(0,T.jsxs)(q_,{"data-slot":`select-item`,className:at(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,T.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,T.jsx)(Y_,{children:(0,T.jsx)(Tl,{className:`size-4`})})}),(0,T.jsx)(J_,{children:t})]})}function rv({className:e,...t}){return(0,T.jsx)(X_,{"data-slot":`select-scroll-up-button`,className:at(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,T.jsx)(Dl,{className:`size-4`})})}function iv({className:e,...t}){return(0,T.jsx)(Z_,{"data-slot":`select-scroll-down-button`,className:at(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,T.jsx)(X,{className:`size-4`})})}function av({title:e,icon:t,children:n,className:r=``}){return(0,T.jsxs)(`div`,{className:`border rounded-lg p-4 bg-card ${r}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[t,(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e})]}),(0,T.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:n})]})}function ov({agent:e,open:t,onOpenChange:n}){let r=e.source===`directory`?(0,T.jsx)(Ul,{className:`h-4 w-4 text-muted-foreground`}):e.source===`in_memory`?(0,T.jsx)(Rl,{className:`h-4 w-4 text-muted-foreground`}):(0,T.jsx)(Wl,{className:`h-4 w-4 text-muted-foreground`}),i=e.source===`directory`?`Local`:e.source===`in_memory`?`In-Memory`:`Gallery`;return(0,T.jsx)(Im,{open:t,onOpenChange:n,children:(0,T.jsxs)(Lm,{className:`max-w-4xl max-h-[90vh] flex flex-col`,children:[(0,T.jsxs)(Rm,{className:`px-6 pt-6 flex-shrink-0`,children:[(0,T.jsx)(zm,{children:`Agent Details`}),(0,T.jsx)(Vm,{onClose:()=>n(!1)})]}),(0,T.jsxs)(`div`,{className:`px-6 pb-6 overflow-y-auto flex-1`,children:[(0,T.jsxs)(`div`,{className:`mb-6`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,T.jsx)(Sl,{className:`h-6 w-6 text-primary`}),(0,T.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:e.name||e.id})]}),e.description&&(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:e.description})]}),(0,T.jsx)(`div`,{className:`h-px bg-border mb-6`}),(0,T.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-4`,children:[(e.model_id||e.chat_client_type)&&(0,T.jsx)(av,{title:`Model & Client`,icon:(0,T.jsx)(Sl,{className:`h-4 w-4 text-muted-foreground`}),children:(0,T.jsxs)(`div`,{className:`space-y-1`,children:[e.model_id&&(0,T.jsx)(`div`,{className:`font-mono text-foreground`,children:e.model_id}),e.chat_client_type&&(0,T.jsxs)(`div`,{className:`text-xs`,children:[`(`,e.chat_client_type,`)`]})]})}),(0,T.jsx)(av,{title:`Source`,icon:r,children:(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(`div`,{className:`text-foreground`,children:i}),e.module_path&&(0,T.jsx)(`div`,{className:`font-mono text-xs break-all`,children:e.module_path})]})}),(0,T.jsx)(av,{title:`Environment`,icon:e.has_env?(0,T.jsx)(Ml,{className:`h-4 w-4 text-orange-500`}):(0,T.jsx)(kl,{className:`h-4 w-4 text-green-500`}),className:`md:col-span-2`,children:(0,T.jsx)(`div`,{className:e.has_env?`text-orange-600 dark:text-orange-400`:`text-green-600 dark:text-green-400`,children:e.has_env?`Requires environment variables`:`No environment variables required`})})]}),e.instructions&&(0,T.jsx)(av,{title:`Instructions`,icon:(0,T.jsx)(Hl,{className:`h-4 w-4 text-muted-foreground`}),className:`mb-4`,children:(0,T.jsx)(`div`,{className:`text-sm text-foreground leading-relaxed whitespace-pre-wrap`,children:e.instructions})}),(0,T.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e.tools&&e.tools.length>0&&(0,T.jsx)(av,{title:`Tools (${e.tools.length})`,icon:(0,T.jsx)(au,{className:`h-4 w-4 text-muted-foreground`}),children:(0,T.jsx)(`ul`,{className:`space-y-1`,children:e.tools.map((e,t)=>(0,T.jsxs)(`li`,{className:`font-mono text-xs text-foreground`,children:[`• `,e]},t))})}),e.middleware&&e.middleware.length>0&&(0,T.jsx)(av,{title:`Middlewares (${e.middleware.length})`,icon:(0,T.jsx)(au,{className:`h-4 w-4 text-muted-foreground`}),children:(0,T.jsx)(`ul`,{className:`space-y-1`,children:e.middleware.map((e,t)=>(0,T.jsxs)(`li`,{className:`font-mono text-xs text-foreground`,children:[`• `,e]},t))})}),e.context_provider&&(0,T.jsx)(av,{title:`Context Provider`,icon:(0,T.jsx)(Rl,{className:`h-4 w-4 text-muted-foreground`}),className:!e.middleware||e.middleware.length===0?`md:col-start-2`:``,children:(0,T.jsx)(`div`,{className:`font-mono text-xs text-foreground`,children:e.context_provider.join(`, `)})})]})]})]})})}Dd();var sv=50,cv=`[Earlier streaming content omitted after refresh] `;function lv(e){let t=e.accumulatedParts?.map(e=>({...e}))??(e.accumulatedText?[{itemId:e.lastMessageId,contentIndex:0,type:e.accumulatedTextType??`text`,text:e.accumulatedText}]:[]);return e.accumulatedTextIsPreview&&t.unshift({itemId:e.lastMessageId,contentIndex:-1,type:`text`,text:cv}),t}function uv(e,t){return t===`refusal`?{type:`refusal`,refusal:e}:{type:`text`,text:e}}function dv(e){return e.map(e=>uv(e.text,e.type))}function fv({item:e,toolCalls:t=[],toolResults:n=[]}){let[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),l=Q(e=>e.showToolCalls),u=()=>e.type===`message`?e.content.filter(e=>e.type===`text`||e.type===`output_text`||e.type===`refusal`).map(e=>`refusal`in e?e.refusal:e.text).join(` `):``,d=async()=>{let e=u();if(e)try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}};if(e.type===`message`){let o=e.role===`user`,f=e.status===`incomplete`,p=o?wu:f?Ol:Sl,m=u();return(0,T.jsxs)(`div`,{className:`flex gap-3 ${o?`flex-row-reverse`:``}`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,T.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md border ${o?`bg-primary text-primary-foreground`:f?`bg-orange-100 dark:bg-orange-900 text-orange-600 dark:text-orange-400 border-orange-200 dark:border-orange-800`:`bg-muted`}`,children:(0,T.jsx)(p,{className:`h-4 w-4`})}),(0,T.jsxs)(`div`,{className:`flex flex-col space-y-1 ${o?`items-end`:`items-start`} max-w-[80%]`,children:[(0,T.jsxs)(`div`,{className:`relative group`,children:[(0,T.jsxs)(`div`,{className:`rounded px-3 py-2 text-sm ${o?`bg-primary text-primary-foreground`:f?`bg-orange-50 dark:bg-orange-950/50 text-orange-800 dark:text-orange-200 border border-orange-200 dark:border-orange-800`:`bg-muted`}`,children:[f&&(0,T.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[(0,T.jsx)(Ol,{className:`h-4 w-4 text-orange-500 mt-0.5 flex-shrink-0`}),(0,T.jsx)(`span`,{className:`font-medium text-sm`,children:`Unable to process request`})]}),(0,T.jsx)(`div`,{className:f?`text-xs leading-relaxed break-all`:``,children:(0,T.jsx)(Eg,{item:e})})]}),m&&r&&(0,T.jsx)(`button`,{onClick:d,className:`absolute top-1 right-1 @@ -190,4 +190,4 @@ asyncio.run(main())`})]})]}),(0,T.jsxs)(`div`,{className:`flex gap-2 pt-4 border `+e:e);try{let n=t.type===`output_text`?JSON.parse(e):void 0;typeof n==`object`&&n&&(z.current=n)}catch{}}}}let a={type:`response.completed`,response:i,sequence_number:0};l([a]),t(a),await he()}catch(e){console.error(`Workflow execution error:`,e);let n={type:`response.failed`,response:{error:{message:e instanceof Error?e.message:`Workflow execution failed`}},sequence_number:0};l([n]),t(n)}}},[e,B,t,he]),Ee=(0,y.useCallback)(async(e,t)=>{se?await we(e,t):await Te(e,t)},[se,we,Te]),De=(0,y.useCallback)(()=>{for(let e of P){let t=F[e.request_id]||{};if(!Sv(e.request_schema,t))return!1}return!0},[P,F]),Oe=(0,y.useCallback)(async()=>{if(!e||e.type!==`workflow`)return;if(!De()){console.warn(`Cannot submit: Not all HIL forms are valid`);return}d(!0),ee([]),I({});let n=j();try{let r={input_data:[{type:`message`,content:[{type:`workflow_hil_response`,responses:F}]}],conversation_id:B?.conversation_id||void 0},i=Vh.streamWorkflowExecutionOpenAI(e.id,r,n),a=!1,o=[];for await(let e of i){if((e.type===`response.output_item.added`||e.type===`response.output_item.done`||e.type===`response.created`||e.type===`response.in_progress`||e.type===`response.completed`||e.type===`response.failed`||e.type===`response.workflow_event.completed`)&&l(t=>{let n=xj(e),r=Math.floor(Date.now()/1e3),i=t.length>0&&t[t.length-1]._uiTimestamp||0,a=n===void 0?Math.max(r,i+1):Math.max(n,i);return[...t,{...e,_uiTimestamp:a}]}),t(e),e.type===`response.request_info.requested`){let t=e;a=!0;let n={request_id:t.request_id,request_data:t.request_data,request_schema:t.request_schema};o.push(n);let r=t.request_schema,i={};r.properties&&Object.entries(r.properties).forEach(([e,t])=>{let n=t;n.enum&&n.enum.length>0?i[e]=n.enum[0]:n.default!==void 0&&(i[e]=n.default)}),I(e=>({...e,[t.request_id]:i}))}if(e.type===`response.output_item.added`){let t=e.item;if(t&&t.type===`executor_action`&&t.executor_id&&t.id&&(R.current=t.id,L.current[t.id]||(L.current[t.id]=``)),t&&t.type===`message`&&`content`in t&&Array.isArray(t.content)&&t.metadata?.workflow_output_kind!==`intermediate`)for(let e of t.content){let t=e.type===`output_text`?e.text:e.type===`refusal`?e.refusal:void 0;if(t){D(e=>e&&e.length>0?e+` -`+t:t);try{let n=e.type===`output_text`?JSON.parse(t):void 0;typeof n==`object`&&n&&(z.current=n)}catch{}}}}if((e.type===`response.output_text.delta`||e.type===`response.refusal.delta`)&&`delta`in e&&e.delta){let t=R.current;t&&(L.current[t]||(L.current[t]=``),L.current[t]+=e.delta)}e.type===`response.completed`&&await he(),e.type===`response.failed`&&await he()}a&&ee(o),d(!1),await he()}catch(e){Th(e)?(console.log(`HIL submission cancelled by user`),p(!0)):console.error(`HIL submission error:`,e),d(!1),N(),await he()}},[e,F,t,B,De,j,N,he]);return i?(0,T.jsx)(mv,{message:`Loading workflow...`,description:`Fetching workflow structure and configuration`}):o?(0,T.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,T.jsxs)(`div`,{className:`text-center max-w-md p-6`,children:[(0,T.jsx)(`div`,{className:`text-red-500 mb-4`,children:(0,T.jsx)(`svg`,{className:`w-16 h-16 mx-auto`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,T.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})})}),(0,T.jsx)(`h3`,{className:`text-lg font-semibold mb-2`,children:`Failed to Load Workflow`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:o}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This may not be a valid workflow entity. Check the file contains a workflow export.`})]})}):!n?.workflow_dump&&!Se.length?(0,T.jsx)(mv,{message:`Initializing workflow...`,description:`Setting up workflow execution environment`}):(0,T.jsxs)(`div`,{className:`workflow-view flex flex-col h-full`,children:[(0,T.jsxs)(`div`,{className:`border-b pb-2 p-4 flex-shrink-0`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col lg:flex-row lg:items-center lg:justify-between gap-3 mb-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,T.jsx)(`h2`,{className:`font-semibold text-sm truncate`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Tu,{className:`h-4 w-4 flex-shrink-0`}),(0,T.jsx)(`span`,{className:`truncate`,children:e.name||e.id})]})}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>_(!0),className:`h-6 w-6 p-0 flex-shrink-0`,title:`View workflow details`,children:(0,T.jsx)(Jl,{className:`h-4 w-4`})}),e.source!==`in_memory`&&(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:pe,disabled:x,className:`h-6 w-6 p-0 flex-shrink-0`,title:x?`Reloading...`:`Reload entity code (hot reload)`,children:(0,T.jsx)(uu,{className:`h-4 w-4 ${x?`animate-spin`:``}`})})]}),n&&(0,T.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-stretch sm:items-center gap-2 flex-shrink-0`,children:[(0,T.jsxs)(Q_,{value:B?.conversation_id||``,onValueChange:_e,disabled:H,children:[(0,T.jsx)(ev,{className:`w-full sm:w-64`,children:(0,T.jsx)($_,{placeholder:H?`Loading...`:V.length===0?`No checkpoint storages`:`Select checkpoint storage`,children:B&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:`truncate`,children:B.metadata.name||`Checkpoint Storage ${B.conversation_id.slice(-8)}`}),B.metadata.checkpoint_summary&&B.metadata.checkpoint_summary.count>0&&(0,T.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,T.jsx)(ct,{variant:`secondary`,className:`h-4 px-1.5 text-[10px]`,children:B.metadata.checkpoint_summary.count}),B.metadata.checkpoint_summary.has_pending_hil&&(0,T.jsx)(ct,{variant:`secondary`,className:`h-4 px-1.5 text-[10px]`,children:`HIL`})]})]})})}),(0,T.jsx)(tv,{children:V.map(e=>(0,T.jsx)(nv,{value:e.conversation_id,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between w-full gap-2`,children:[(0,T.jsx)(`span`,{className:`truncate`,children:e.metadata.name||`Checkpoint Storage ${e.conversation_id.slice(-8)}`}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[e.created_at&&(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.created_at*1e3).toLocaleTimeString()}),e.metadata.checkpoint_summary&&e.metadata.checkpoint_summary.count>0&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ct,{variant:`secondary`,className:`h-4 px-1.5 text-[10px]`,children:e.metadata.checkpoint_summary.count}),e.metadata.checkpoint_summary.has_pending_hil&&(0,T.jsx)(ct,{variant:`secondary`,className:`h-4 px-1.5 text-[10px]`,children:`HIL`})]})]})]})},e.conversation_id))})]}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>b(!0),disabled:!B,className:`h-9 w-9 p-0 flex-shrink-0`,title:`View checkpoint details`,children:(0,T.jsx)(Jl,{className:`h-4 w-4`})}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:ye,disabled:!B||H,className:`h-9 w-9 p-0`,title:`Delete current session`,children:(0,T.jsx)(xu,{className:`h-4 w-4 `})}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:ve,disabled:H,className:`h-9 px-3`,title:`New session`,children:(0,T.jsx)(lu,{className:`h-4 w-4`})}),C&&(0,T.jsx)(Bv,{inputSchema:n.input_schema,onRun:Ee,onCancel:M,isSubmitting:u,isCancelling:A,workflowState:u?`running`:Se.length>0?`completed`:`ready`,checkpoints:O,showCheckpoints:!1})]})]}),e.description&&(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description})]}),P.length>0&&(0,T.jsx)(`div`,{className:`bg-orange-100 dark:bg-orange-950/30 border-b border-orange-300 dark:border-orange-800 px-4 py-2`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Ol,{className:`w-4 h-4 text-orange-600 dark:text-orange-400`}),(0,T.jsxs)(`span`,{className:`text-sm font-medium text-orange-900 dark:text-orange-100`,children:[`Workflow is waiting for your input (`,P.length,` `,`request`,P.length>1?`s`:``,`)`]})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P.length>1&&(0,T.jsxs)(K,{size:`sm`,onClick:Oe,disabled:!De()||u,className:`gap-1`,children:[(0,T.jsx)(hu,{className:`w-3.5 h-3.5`}),`Submit All`]}),(0,T.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>{document.querySelector(`[data-hil-form]`)?.scrollIntoView({behavior:`smooth`,block:`center`})},className:`text-orange-700 hover:text-orange-900 dark:text-orange-400 dark:hover:text-orange-200`,children:`Jump to input →`})]})]})}),(0,T.jsxs)(`div`,{className:`flex-1 min-h-0 flex gap-0`,children:[(0,T.jsx)(`div`,{className:`flex-1 min-w-0 transition-all duration-300`,children:n?.workflow_dump&&(0,T.jsx)(dj,{workflowDump:n.workflow_dump,events:xe,isStreaming:u,onNodeSelect:be,className:`h-full`,viewOptions:ce,onToggleViewOption:fe,layoutDirection:ue,onLayoutDirectionChange:de,timelineVisible:!0})}),(0,T.jsx)(`div`,{className:`flex-shrink-0 overflow-hidden transition-all duration-300 ease-out border-l`,style:{width:C?`2.5rem`:`28rem`},children:C?(0,T.jsxs)(`div`,{className:`h-full w-10 bg-background flex flex-col items-center py-2 cursor-pointer hover:bg-accent/50 transition-colors`,onClick:()=>w(!1),title:`Expand timeline`,children:[(0,T.jsx)(`div`,{className:`h-8 w-8 flex items-center justify-center`,children:(0,T.jsx)(El,{className:`h-4 w-4 text-muted-foreground`})}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-2 pointer-events-none`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground select-none`,style:{writingMode:`vertical-rl`,transform:`rotate(180deg)`},children:`Execution Timeline`}),xe.length>0&&(0,T.jsx)(`div`,{className:`bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center ${u?`animate-pulse`:``}`,style:{fontSize:`10px`},children:xe.length})]})]}):(0,T.jsxs)(`div`,{className:`w-[28rem] h-full flex flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between p-2 border-b`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium`,children:`Execution Timeline`}),xe.length>0&&(0,T.jsx)(`div`,{className:`bg-primary text-primary-foreground rounded-full px-2 h-5 flex items-center justify-center ${u?`animate-pulse`:``}`,style:{fontSize:`11px`,minWidth:`20px`},children:xe.length})]}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>w(!0),className:`h-8 w-8 p-0`,title:`Minimize timeline`,children:(0,T.jsx)(Z,{className:`h-4 w-4`})})]}),(0,T.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,T.jsx)(bj,{events:xe,itemOutputs:L.current,currentExecutorId:Ce[Ce.length-1]||null,isStreaming:u,onExecutorClick:be,selectedExecutorId:m,workflowResult:E,pendingHilRequests:P,hilResponses:F,onHilResponseChange:(e,t)=>{I(n=>({...n,[e]:t}))},onHilSubmit:Oe,isSubmittingHil:u,inputSchema:n?.input_schema,onRun:(e,t)=>{Ee(e,t)},onCancel:M,isCancelling:A,workflowState:u?`running`:f?`cancelled`:Se.length>0?`completed`:`ready`,wasCancelled:f,checkpoints:O})})]})})]}),(0,T.jsx)(pj,{workflow:e,open:g,onOpenChange:_}),(0,T.jsx)(mj,{session:B||null,checkpoints:O,open:v,onOpenChange:b})]})}function Cj({message:e,type:t=`info`,duration:n=4e3,onClose:r}){let[i,a]=(0,y.useState)(!0);(0,y.useEffect)(()=>{let e=setTimeout(()=>{a(!1),setTimeout(r,300)},n);return()=>clearTimeout(e)},[n,r]);let o={info:`bg-primary/10 border-primary/20`,success:`bg-green-50 dark:bg-green-950 border-green-200 dark:border-green-800`,warning:`bg-orange-50 dark:bg-orange-950 border-orange-200 dark:border-orange-800`,error:`bg-red-50 dark:bg-red-950 border-red-200 dark:border-red-800`}[t],s={info:`text-primary`,success:`text-green-800 dark:text-green-200`,warning:`text-orange-800 dark:text-orange-200`,error:`text-red-800 dark:text-red-200`}[t];return(0,T.jsxs)(`div`,{className:`fixed top-4 right-4 z-50 flex items-start gap-3 p-4 rounded-lg border shadow-lg max-w-md transition-all duration-300 ${i?`opacity-100 translate-x-0`:`opacity-0 translate-x-4`} ${o}`,children:[(0,T.jsx)(`p`,{className:`text-sm flex-1 ${s}`,children:e}),(0,T.jsx)(`button`,{onClick:()=>{a(!1),setTimeout(r,300)},className:`flex-shrink-0 hover:opacity-70 transition-opacity ${s}`,children:(0,T.jsx)(Du,{className:`h-4 w-4`})})]})}function wj({toasts:e,onRemove:t}){return(0,T.jsx)(`div`,{className:`fixed top-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,T.jsx)(Cj,{message:e.message,type:e.type,duration:e.duration,onClose:()=>t(e.id)},e.id))})}Dd();var Tj=50;function Ej(){let[e,t]=(0,y.useState)(!1),[n,r]=(0,y.useState)(``),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(``),c=(0,y.useRef)(null),l=(0,y.useRef)(0),u=Q(e=>e.agents),d=Q(e=>e.workflows),f=Q(e=>e.entities),p=Q(e=>e.selectedAgent),m=Q(e=>e.azureDeploymentEnabled),h=Q(e=>e.isLoadingEntities),g=Q(e=>e.entityError),_=Q(e=>e.oaiMode),v=Q(e=>e.uiMode),b=Q(e=>e.setAgents),x=Q(e=>e.setWorkflows),S=Q(e=>e.setEntities),C=Q(e=>e.selectEntity),w=Q(e=>e.updateAgent),E=Q(e=>e.updateWorkflow),D=Q(e=>e.setIsLoadingEntities),O=Q(e=>e.setEntityError),k=Q(e=>e.showDebugPanel),A=Q(e=>e.debugPanelMinimized),j=Q(e=>e.debugPanelWidth),M=Q(e=>e.debugEvents),N=Q(e=>e.isResizing),P=Q(e=>e.setShowDebugPanel),ee=Q(e=>e.setDebugPanelMinimized),F=Q(e=>e.setDebugPanelWidth),I=Q(e=>e.addDebugEvent),L=Q(e=>e.clearDebugEvents),R=Q(e=>e.setIsResizing),z=Q(e=>e.showAboutModal),B=Q(e=>e.showGallery),V=Q(e=>e.showDeployModal),H=Q(e=>e.showEntityNotFoundToast),U=Q(e=>e.setShowAboutModal),te=Q(e=>e.setShowGallery),ne=Q(e=>e.setShowDeployModal),re=Q(e=>e.setShowEntityNotFoundToast),ie=Q(e=>e.toasts),ae=Q(e=>e.addToast),oe=Q(e=>e.removeToast);(0,y.useEffect)(()=>{(async()=>{try{let e=await Vh.getMeta();if(e.auth_required&&(t(!0),!Vh.getAuthToken())){O(`UNAUTHORIZED`),D(!1);return}let n={instrumentation:e.capabilities.instrumentation??e.capabilities.tracing??!1,trace_retrieval:e.capabilities.trace_retrieval??!1,openai_proxy:e.capabilities.openai_proxy,deployment:e.capabilities.deployment};Q.getState().setServerMeta({uiMode:e.ui_mode,runtime:e.runtime,capabilities:n,authRequired:e.auth_required,version:e.version});let{entities:r,agents:i,workflows:a}=await Vh.getEntities();S(r),b(i),x(a);let o=new URLSearchParams(window.location.search).get(`entity_id`),s;if(o&&(s=r.find(e=>e.id===o),s||re(!0)),!s)if(s=r.length>0?r[0]:void 0,s){let e=new URL(window.location.href);e.searchParams.set(`entity_id`,s.id),window.history.replaceState({},``,e)}else{let e=new URL(window.location.href);e.searchParams.delete(`entity_id`),window.history.replaceState({},``,e)}if(s&&(C(s),s.metadata?.lazy_loaded===!1))try{s.type===`agent`?w(await Vh.getAgentInfo(s.id)):E(await Vh.getWorkflowInfo(s.id))}catch(e){console.error(`Failed to load full info for first entity ${s.id}:`,e);let t=e instanceof Error?e.message:String(e);ae({type:`error`,message:`Failed to load "${s.id}": ${t}`})}D(!1)}catch(e){console.error(`Failed to load agents/workflows:`,e);let n=e instanceof Error?e.message:`Failed to load data`;n===`UNAUTHORIZED`&&t(!0),O(n),D(!1)}})()},[b,x,C,w,E,D,O,re,ae,S]);let se=(0,y.useCallback)(async()=>{if(n.trim()){a(!0),s(``);try{Vh.setAuthToken(n.trim()),await Vh.getEntities(),window.location.reload()}catch(e){Vh.clearAuthToken(),a(!1);let t=e instanceof Error?e.message:`Unknown error`;s(t===`UNAUTHORIZED`?`Invalid token. Please check and try again.`:`Failed to connect: ${t}`)}}},[n]);(0,y.useEffect)(()=>{if(_.enabled&&p?.type===`workflow`){let e=u[0];e&&C(e)}},[_.enabled,p,u,C]);let ce=(0,y.useCallback)(e=>{e.preventDefault(),R(!0);let t=e.clientX,n=j,r=e=>{let r=t-e.clientX;F(Math.max(200,Math.min(window.innerWidth*.5,n+r)))},i=()=>{R(!1),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[j]),le=(0,y.useCallback)(async e=>{if(C(e),e.metadata?.lazy_loaded===!1)try{e.type===`agent`?w(await Vh.getAgentInfo(e.id)):E(await Vh.getWorkflowInfo(e.id))}catch(t){console.error(`Failed to load full info for ${e.id}:`,t);let n=t instanceof Error?t.message:String(t);ae({type:`error`,message:`Failed to load "${e.id}": ${n}`})}},[C,w,E,ae]),ue=(0,y.useCallback)(()=>{let e=c.current;e&&(c.current=null,l.current=performance.now(),I(e))},[I]),de=(0,y.useCallback)(e=>{if(e===`clear`){c.current=null,L();return}if(e.type===`response.output_text.delta`&&`delta`in e&&typeof e.delta==`string`&&e.delta.length>0){let t=c.current;t!==null&&t.item_id===e.item_id&&t.output_index===e.output_index&&t.content_index===e.content_index&&t?c.current={...t,delta:t.delta+e.delta,sequence_number:e.sequence_number??t.sequence_number}:(ue(),c.current={...e}),performance.now()-l.current>=Tj&&ue();return}ue(),I(e)},[I,L,ue]);if(h)return(0,T.jsxs)(`div`,{className:`h-screen flex flex-col bg-background`,children:[(0,T.jsxs)(`header`,{className:`flex h-14 items-center gap-4 border-b px-4`,children:[(0,T.jsx)(`div`,{className:`w-64 h-9 bg-muted animate-pulse rounded-md`}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[(0,T.jsx)(`div`,{className:`w-8 h-8 bg-muted animate-pulse rounded-md`}),(0,T.jsx)(`div`,{className:`w-8 h-8 bg-muted animate-pulse rounded-md`})]})]}),(0,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`div`,{className:`text-lg font-medium`,children:`Initializing DevUI...`}),(0,T.jsx)(`div`,{className:`text-sm text-muted-foreground mt-2`,children:`Loading agents and workflows from your configuration`})]})})]});if(g){let t=Vh.getBaseUrl(),a=g===`UNAUTHORIZED`||e,s=`8080`;try{if(t){let e=new URL(t);s=e.port||(e.protocol===`https:`?`443`:`80`)}}catch{}return(0,T.jsxs)(`div`,{className:`h-screen flex flex-col bg-background`,children:[(0,T.jsx)(Od,{agents:[],workflows:[],entities:[],selectedItem:void 0,onSelect:()=>{},isLoading:!1,onSettingsClick:()=>U(!0)}),(0,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,T.jsxs)(`div`,{className:`text-center space-y-6 max-w-2xl`,children:[(0,T.jsx)(`div`,{className:`flex justify-center`,children:(0,T.jsx)(`div`,{className:`rounded-full bg-muted p-4 animate-pulse`,children:a?(0,T.jsx)($l,{className:`h-12 w-12 text-muted-foreground`}):(0,T.jsx)(gu,{className:`h-12 w-12 text-muted-foreground`})})}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`h2`,{className:`text-2xl font-semibold text-foreground`,children:a?`Authentication Required`:`Can't Connect to Backend`}),(0,T.jsx)(`p`,{className:`text-muted-foreground text-base`,children:a?`This backend requires a bearer token to access.`:`No worries! Just start the DevUI backend server and you'll be good to go.`})]}),a?(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`text-left bg-muted/50 rounded-lg p-4 space-y-3`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enter Authentication Token`}),(0,T.jsx)(Um,{type:`password`,placeholder:`Paste token from server logs`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!i&&se()},disabled:i,className:`font-mono text-sm`}),(0,T.jsx)(K,{onClick:se,disabled:!n.trim()||i,className:`w-full`,children:i?`Verifying...`:`Connect`}),o&&(0,T.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400 text-center`,children:o})]}),(0,T.jsxs)(`details`,{className:`text-left group`,children:[(0,T.jsxs)(`summary`,{className:`text-sm text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-2 justify-center`,children:[(0,T.jsx)(X,{className:`h-4 w-4 transition-transform group-open:rotate-180`}),`Where do I find the token?`]}),(0,T.jsxs)(`div`,{className:`mt-3 text-left bg-muted/30 rounded-lg p-3 space-y-2`,children:[(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Look for this in your DevUI server startup logs:`}),(0,T.jsxs)(`code`,{className:`block bg-background px-2 py-1 rounded text-xs font-mono text-foreground`,children:[`🔑 DEV TOKEN (localhost only, shown once):`,(0,T.jsx)(`br`,{}),`\xA0\xA0 abc123xyz...`]})]})]})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsxs)(`div`,{className:`text-left bg-muted/50 rounded-lg p-4 space-y-3`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Start the backend:`}),(0,T.jsxs)(`code`,{className:`block bg-background px-3 py-2 rounded border text-sm font-mono text-foreground`,children:[`devui ./agents --port `,s]}),(0,T.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Or launch programmatically with`,` `,(0,T.jsx)(`code`,{className:`text-xs`,children:`serve(entities=[agent])`})]})]}),(0,T.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Default:`,` `,(0,T.jsx)(`span`,{className:`font-mono`,children:t})]})]}),g&&(0,T.jsxs)(`details`,{className:`text-left group`,children:[(0,T.jsxs)(`summary`,{className:`text-sm text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-2`,children:[(0,T.jsx)(X,{className:`h-4 w-4 transition-transform group-open:rotate-180`}),`Error details`]}),(0,T.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground font-mono bg-muted/30 p-3 rounded border`,children:g})]}),(0,T.jsx)(K,{onClick:()=>window.location.reload(),variant:`default`,className:`mt-2`,children:`Retry Connection`})]})]})}),(0,T.jsx)(lh,{open:z,onOpenChange:U})]})}return(0,T.jsxs)(`div`,{className:`h-screen flex flex-col bg-background max-h-screen`,children:[(0,T.jsx)(Od,{agents:u,workflows:d,entities:f,selectedItem:p,onSelect:le,onBrowseGallery:()=>te(!0),isLoading:h,onSettingsClick:()=>U(!0)}),(0,T.jsx)(`div`,{className:`flex flex-1 overflow-hidden`,children:B?(0,T.jsx)(`div`,{className:`flex-1 w-full`,children:(0,T.jsx)(ag,{variant:`route`,onClose:()=>te(!1),hasExistingEntities:u.length>0||d.length>0})}):u.length===0&&d.length===0?(0,T.jsx)(ag,{variant:`inline`}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`flex-1 min-w-0`,children:p?p.type===`agent`?(0,T.jsx)(pv,{selectedAgent:p,onDebugEvent:de}):(0,T.jsx)(Sj,{selectedWorkflow:p,onDebugEvent:de}):(0,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground`,children:`Select an agent or workflow to get started.`})}),v===`developer`&&k?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`w-1 cursor-col-resize flex-shrink-0 relative group transition-colors duration-200 ease-in-out ${N?`bg-primary/40`:`bg-border hover:bg-primary/20`}`,onMouseDown:ce,children:(0,T.jsx)(`div`,{className:`absolute inset-y-0 -left-2 -right-2 flex items-center justify-center`,children:(0,T.jsx)(`div`,{className:`h-12 w-1 rounded-full transition-all duration-200 ease-in-out ${N?`bg-primary shadow-lg shadow-primary/25`:`bg-primary/30 group-hover:bg-primary group-hover:shadow-md group-hover:shadow-primary/20`}`})})}),(0,T.jsx)(`div`,{className:`flex-shrink-0 flex flex-col h-[calc(100vh-3.7rem)]`,style:{width:A?`2.5rem`:`${j}px`},children:A?(0,T.jsxs)(`div`,{className:`h-full w-10 bg-background border-l flex flex-col items-center py-2 cursor-pointer hover:bg-accent/50 transition-colors`,onClick:()=>ee(!1),title:`Expand debug panel`,children:[(0,T.jsx)(`div`,{className:`h-8 w-8 flex items-center justify-center`,children:(0,T.jsx)(El,{className:`h-4 w-4 text-muted-foreground`})}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-2 pointer-events-none`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground select-none`,style:{writingMode:`vertical-rl`,transform:`rotate(180deg)`},children:`Debug Panel`}),M.length>0&&(0,T.jsx)(`div`,{className:`bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center`,style:{fontSize:`10px`},children:M.length})]})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(Fm,{events:M,isStreaming:!1,onMinimize:()=>ee(!0)}),(0,T.jsx)(`div`,{className:`border-t bg-muted/30 px-3 py-2.5 flex-shrink-0`,children:(0,T.jsxs)(K,{onClick:()=>ne(!0),className:`w-full`,variant:`outline`,size:`sm`,children:[(0,T.jsx)(du,{className:`h-3 w-3 mr-2 flex-shrink-0`}),(0,T.jsx)(`span`,{className:`truncate text-xs`,children:m&&p?.deployment_supported?`Deploy to Azure`:`Deployment Guide`})]})})]})})]}):v===`developer`?(0,T.jsx)(`div`,{className:`flex-shrink-0`,children:(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>P(!0),className:`h-full w-10 rounded-none border-l`,title:`Show debug panel`,children:(0,T.jsx)(ou,{className:`h-4 w-4`})})}):null]})}),(0,T.jsx)(lh,{open:z,onOpenChange:U}),(0,T.jsx)(Hh,{open:V,onClose:()=>ne(!1),agentName:p?.name,entity:p}),H&&(0,T.jsx)(Cj,{message:`Entity not found. Showing first available entity instead.`,type:`info`,onClose:()=>re(!1)}),(0,T.jsx)(wj,{toasts:ie,onRemove:oe})]})}function Dj({children:e,attribute:t=`class`,defaultTheme:n=`dark`,enableSystem:r=!0,disableTransitionOnChange:i=!0,...a}){return(0,T.jsx)(Gu,{attribute:t,defaultTheme:n,enableSystem:r,disableTransitionOnChange:i,...a,children:e})}Ch(),(0,b.createRoot)(document.getElementById(`root`)).render((0,T.jsx)(y.StrictMode,{children:(0,T.jsx)(Dj,{attribute:`class`,defaultTheme:`dark`,enableSystem:!0,disableTransitionOnChange:!0,children:(0,T.jsx)(Ej,{})})})); \ No newline at end of file +`+t:t);try{let n=e.type===`output_text`?JSON.parse(t):void 0;typeof n==`object`&&n&&(z.current=n)}catch{}}}}if((e.type===`response.output_text.delta`||e.type===`response.refusal.delta`)&&`delta`in e&&e.delta){let t=R.current;t&&(L.current[t]||(L.current[t]=``),L.current[t]+=e.delta)}e.type===`response.completed`&&await he(),e.type===`response.failed`&&await he()}a&&ee(o),d(!1),await he()}catch(e){Th(e)?(console.log(`HIL submission cancelled by user`),p(!0)):console.error(`HIL submission error:`,e),d(!1),N(),await he()}},[e,F,t,B,De,j,N,he]);return i?(0,T.jsx)(mv,{message:`Loading workflow...`,description:`Fetching workflow structure and configuration`}):o?(0,T.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,T.jsxs)(`div`,{className:`text-center max-w-md p-6`,children:[(0,T.jsx)(`div`,{className:`text-red-500 mb-4`,children:(0,T.jsx)(`svg`,{className:`w-16 h-16 mx-auto`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,T.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})})}),(0,T.jsx)(`h3`,{className:`text-lg font-semibold mb-2`,children:`Failed to Load Workflow`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:o}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This may not be a valid workflow entity. Check the file contains a workflow export.`})]})}):!n?.workflow_dump&&!Se.length?(0,T.jsx)(mv,{message:`Initializing workflow...`,description:`Setting up workflow execution environment`}):(0,T.jsxs)(`div`,{className:`workflow-view flex flex-col h-full`,children:[(0,T.jsxs)(`div`,{className:`border-b pb-2 p-4 flex-shrink-0`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col lg:flex-row lg:items-center lg:justify-between gap-3 mb-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,T.jsx)(`h2`,{className:`font-semibold text-sm truncate`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Tu,{className:`h-4 w-4 flex-shrink-0`}),(0,T.jsx)(`span`,{className:`truncate`,children:e.name||e.id})]})}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>_(!0),className:`h-6 w-6 p-0 flex-shrink-0`,title:`View workflow details`,children:(0,T.jsx)(Jl,{className:`h-4 w-4`})}),e.source!==`in_memory`&&(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:pe,disabled:x,className:`h-6 w-6 p-0 flex-shrink-0`,title:x?`Reloading...`:`Reload entity code (hot reload)`,children:(0,T.jsx)(uu,{className:`h-4 w-4 ${x?`animate-spin`:``}`})})]}),n&&(0,T.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-stretch sm:items-center gap-2 flex-shrink-0`,children:[(0,T.jsxs)(Q_,{value:B?.conversation_id||``,onValueChange:_e,disabled:H,children:[(0,T.jsx)(ev,{className:`w-full sm:w-64`,children:(0,T.jsx)($_,{placeholder:H?`Loading...`:V.length===0?`No checkpoint storages`:`Select checkpoint storage`,children:B&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:`truncate`,children:B.metadata.name||`Checkpoint Storage ${B.conversation_id.slice(-8)}`}),B.metadata.checkpoint_summary&&B.metadata.checkpoint_summary.count>0&&(0,T.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,T.jsx)(ct,{variant:`secondary`,className:`h-4 px-1.5 text-[10px]`,children:B.metadata.checkpoint_summary.count}),B.metadata.checkpoint_summary.has_pending_hil&&(0,T.jsx)(ct,{variant:`secondary`,className:`h-4 px-1.5 text-[10px]`,children:`HIL`})]})]})})}),(0,T.jsx)(tv,{children:V.map(e=>(0,T.jsx)(nv,{value:e.conversation_id,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between w-full gap-2`,children:[(0,T.jsx)(`span`,{className:`truncate`,children:e.metadata.name||`Checkpoint Storage ${e.conversation_id.slice(-8)}`}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[e.created_at&&(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.created_at*1e3).toLocaleTimeString()}),e.metadata.checkpoint_summary&&e.metadata.checkpoint_summary.count>0&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ct,{variant:`secondary`,className:`h-4 px-1.5 text-[10px]`,children:e.metadata.checkpoint_summary.count}),e.metadata.checkpoint_summary.has_pending_hil&&(0,T.jsx)(ct,{variant:`secondary`,className:`h-4 px-1.5 text-[10px]`,children:`HIL`})]})]})]})},e.conversation_id))})]}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>b(!0),disabled:!B,className:`h-9 w-9 p-0 flex-shrink-0`,title:`View checkpoint details`,children:(0,T.jsx)(Jl,{className:`h-4 w-4`})}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:ye,disabled:!B||H,className:`h-9 w-9 p-0`,title:`Delete current session`,children:(0,T.jsx)(xu,{className:`h-4 w-4 `})}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:ve,disabled:H,className:`h-9 px-3`,title:`New session`,children:(0,T.jsx)(lu,{className:`h-4 w-4`})}),C&&(0,T.jsx)(Bv,{inputSchema:n.input_schema,onRun:Ee,onCancel:M,isSubmitting:u,isCancelling:A,workflowState:u?`running`:Se.length>0?`completed`:`ready`,checkpoints:O,showCheckpoints:!1})]})]}),e.description&&(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description})]}),P.length>0&&(0,T.jsx)(`div`,{className:`bg-orange-100 dark:bg-orange-950/30 border-b border-orange-300 dark:border-orange-800 px-4 py-2`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Ol,{className:`w-4 h-4 text-orange-600 dark:text-orange-400`}),(0,T.jsxs)(`span`,{className:`text-sm font-medium text-orange-900 dark:text-orange-100`,children:[`Workflow is waiting for your input (`,P.length,` `,`request`,P.length>1?`s`:``,`)`]})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P.length>1&&(0,T.jsxs)(K,{size:`sm`,onClick:Oe,disabled:!De()||u,className:`gap-1`,children:[(0,T.jsx)(hu,{className:`w-3.5 h-3.5`}),`Submit All`]}),(0,T.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>{document.querySelector(`[data-hil-form]`)?.scrollIntoView({behavior:`smooth`,block:`center`})},className:`text-orange-700 hover:text-orange-900 dark:text-orange-400 dark:hover:text-orange-200`,children:`Jump to input →`})]})]})}),(0,T.jsxs)(`div`,{className:`flex-1 min-h-0 flex gap-0`,children:[(0,T.jsx)(`div`,{className:`flex-1 min-w-0 transition-all duration-300`,children:n?.workflow_dump&&(0,T.jsx)(dj,{workflowDump:n.workflow_dump,events:xe,isStreaming:u,onNodeSelect:be,className:`h-full`,viewOptions:ce,onToggleViewOption:fe,layoutDirection:ue,onLayoutDirectionChange:de,timelineVisible:!0})}),(0,T.jsx)(`div`,{className:`flex-shrink-0 overflow-hidden transition-all duration-300 ease-out border-l`,style:{width:C?`2.5rem`:`28rem`},children:C?(0,T.jsxs)(`div`,{className:`h-full w-10 bg-background flex flex-col items-center py-2 cursor-pointer hover:bg-accent/50 transition-colors`,onClick:()=>w(!1),title:`Expand timeline`,children:[(0,T.jsx)(`div`,{className:`h-8 w-8 flex items-center justify-center`,children:(0,T.jsx)(El,{className:`h-4 w-4 text-muted-foreground`})}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-2 pointer-events-none`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground select-none`,style:{writingMode:`vertical-rl`,transform:`rotate(180deg)`},children:`Execution Timeline`}),xe.length>0&&(0,T.jsx)(`div`,{className:`bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center ${u?`animate-pulse`:``}`,style:{fontSize:`10px`},children:xe.length})]})]}):(0,T.jsxs)(`div`,{className:`w-[28rem] h-full flex flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between p-2 border-b`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium`,children:`Execution Timeline`}),xe.length>0&&(0,T.jsx)(`div`,{className:`bg-primary text-primary-foreground rounded-full px-2 h-5 flex items-center justify-center ${u?`animate-pulse`:``}`,style:{fontSize:`11px`,minWidth:`20px`},children:xe.length})]}),(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>w(!0),className:`h-8 w-8 p-0`,title:`Minimize timeline`,children:(0,T.jsx)(Z,{className:`h-4 w-4`})})]}),(0,T.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,T.jsx)(bj,{events:xe,itemOutputs:L.current,currentExecutorId:Ce[Ce.length-1]||null,isStreaming:u,onExecutorClick:be,selectedExecutorId:m,workflowResult:E,pendingHilRequests:P,hilResponses:F,onHilResponseChange:(e,t)=>{I(n=>({...n,[e]:t}))},onHilSubmit:Oe,isSubmittingHil:u,inputSchema:n?.input_schema,onRun:(e,t)=>{Ee(e,t)},onCancel:M,isCancelling:A,workflowState:u?`running`:f?`cancelled`:Se.length>0?`completed`:`ready`,wasCancelled:f,checkpoints:O})})]})})]}),(0,T.jsx)(pj,{workflow:e,open:g,onOpenChange:_}),(0,T.jsx)(mj,{session:B||null,checkpoints:O,open:v,onOpenChange:b})]})}function Cj({message:e,type:t=`info`,duration:n=4e3,onClose:r}){let[i,a]=(0,y.useState)(!0);(0,y.useEffect)(()=>{let e=setTimeout(()=>{a(!1),setTimeout(r,300)},n);return()=>clearTimeout(e)},[n,r]);let o={info:`bg-primary/10 border-primary/20`,success:`bg-green-50 dark:bg-green-950 border-green-200 dark:border-green-800`,warning:`bg-orange-50 dark:bg-orange-950 border-orange-200 dark:border-orange-800`,error:`bg-red-50 dark:bg-red-950 border-red-200 dark:border-red-800`}[t],s={info:`text-primary`,success:`text-green-800 dark:text-green-200`,warning:`text-orange-800 dark:text-orange-200`,error:`text-red-800 dark:text-red-200`}[t];return(0,T.jsxs)(`div`,{className:`fixed top-4 right-4 z-50 flex items-start gap-3 p-4 rounded-lg border shadow-lg max-w-md transition-all duration-300 ${i?`opacity-100 translate-x-0`:`opacity-0 translate-x-4`} ${o}`,children:[(0,T.jsx)(`p`,{className:`text-sm flex-1 ${s}`,children:e}),(0,T.jsx)(`button`,{onClick:()=>{a(!1),setTimeout(r,300)},className:`flex-shrink-0 hover:opacity-70 transition-opacity ${s}`,children:(0,T.jsx)(Du,{className:`h-4 w-4`})})]})}function wj({toasts:e,onRemove:t}){return(0,T.jsx)(`div`,{className:`fixed top-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,T.jsx)(Cj,{message:e.message,type:e.type,duration:e.duration,onClose:()=>t(e.id)},e.id))})}Dd();var Tj=50;function Ej(){let[e,t]=(0,y.useState)(!1),[n,r]=(0,y.useState)(``),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(``),c=(0,y.useRef)(null),l=(0,y.useRef)(0),u=Q(e=>e.agents),d=Q(e=>e.workflows),f=Q(e=>e.entities),p=Q(e=>e.selectedAgent),m=Q(e=>e.azureDeploymentEnabled),h=Q(e=>e.isLoadingEntities),g=Q(e=>e.entityError),_=Q(e=>e.oaiMode),v=Q(e=>e.uiMode),b=Q(e=>e.setAgents),x=Q(e=>e.setWorkflows),S=Q(e=>e.setEntities),C=Q(e=>e.selectEntity),w=Q(e=>e.updateAgent),E=Q(e=>e.updateWorkflow),D=Q(e=>e.setIsLoadingEntities),O=Q(e=>e.setEntityError),k=Q(e=>e.showDebugPanel),A=Q(e=>e.debugPanelMinimized),j=Q(e=>e.debugPanelWidth),M=Q(e=>e.debugEvents),N=Q(e=>e.isResizing),P=Q(e=>e.setShowDebugPanel),ee=Q(e=>e.setDebugPanelMinimized),F=Q(e=>e.setDebugPanelWidth),I=Q(e=>e.addDebugEvent),L=Q(e=>e.clearDebugEvents),R=Q(e=>e.setIsResizing),z=Q(e=>e.showAboutModal),B=Q(e=>e.showGallery),V=Q(e=>e.showDeployModal),H=Q(e=>e.showEntityNotFoundToast),U=Q(e=>e.setShowAboutModal),te=Q(e=>e.setShowGallery),ne=Q(e=>e.setShowDeployModal),re=Q(e=>e.setShowEntityNotFoundToast),ie=Q(e=>e.toasts),ae=Q(e=>e.addToast),oe=Q(e=>e.removeToast);(0,y.useEffect)(()=>{(async()=>{try{let e=await Vh.getMeta();if(e.auth_required&&(t(!0),!Vh.getAuthToken())){O(`UNAUTHORIZED`),D(!1);return}let n={instrumentation:e.capabilities.instrumentation??e.capabilities.tracing??!1,trace_retrieval:e.capabilities.trace_retrieval??!1,openai_proxy:e.capabilities.openai_proxy,deployment:e.capabilities.deployment};Q.getState().setServerMeta({uiMode:e.ui_mode,runtime:e.runtime,capabilities:n,authRequired:e.auth_required,version:e.version});let{entities:r,agents:i,workflows:a}=await Vh.getEntities();S(r),b(i),x(a);let o=new URLSearchParams(window.location.search).get(`entity_id`),s;if(o&&(s=r.find(e=>e.id===o),s||re(!0)),!s)if(s=r.length>0?r[0]:void 0,s){let e=new URL(window.location.href);e.searchParams.set(`entity_id`,s.id),window.history.replaceState({},``,e)}else{let e=new URL(window.location.href);e.searchParams.delete(`entity_id`),window.history.replaceState({},``,e)}if(s&&(C(s),s.metadata?.lazy_loaded===!1))try{s.type===`agent`?w(await Vh.getAgentInfo(s.id)):E(await Vh.getWorkflowInfo(s.id))}catch(e){console.error(`Failed to load full info for first entity ${s.id}:`,e);let t=e instanceof Error?e.message:String(e);ae({type:`error`,message:`Failed to load "${s.id}": ${t}`})}D(!1)}catch(e){console.error(`Failed to load agents/workflows:`,e);let n=e instanceof Error?e.message:`Failed to load data`;n===`UNAUTHORIZED`&&t(!0),O(n),D(!1)}})()},[b,x,C,w,E,D,O,re,ae,S]);let se=(0,y.useCallback)(async()=>{if(n.trim()){a(!0),s(``);try{Vh.setAuthToken(n.trim()),await Vh.getEntities(),window.location.reload()}catch(e){Vh.clearAuthToken(),a(!1);let t=e instanceof Error?e.message:`Unknown error`;s(t===`UNAUTHORIZED`?`Invalid token. Please check and try again.`:`Failed to connect: ${t}`)}}},[n]);(0,y.useEffect)(()=>{if(_.enabled&&p?.type===`workflow`){let e=u[0];e&&C(e)}},[_.enabled,p,u,C]);let ce=(0,y.useCallback)(e=>{e.preventDefault(),R(!0);let t=e.clientX,n=j,r=e=>{let r=t-e.clientX;F(Math.max(200,Math.min(window.innerWidth*.5,n+r)))},i=()=>{R(!1),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[j]),le=(0,y.useCallback)(async e=>{if(C(e),e.metadata?.lazy_loaded===!1)try{e.type===`agent`?w(await Vh.getAgentInfo(e.id)):E(await Vh.getWorkflowInfo(e.id))}catch(t){console.error(`Failed to load full info for ${e.id}:`,t);let n=t instanceof Error?t.message:String(t);ae({type:`error`,message:`Failed to load "${e.id}": ${n}`})}},[C,w,E,ae]),ue=(0,y.useCallback)(()=>{let e=c.current;e&&(c.current=null,l.current=performance.now(),I(e))},[I]),de=(0,y.useCallback)(e=>{if(e===`clear`){c.current=null,L();return}if(e.type===`response.output_text.delta`&&`delta`in e&&typeof e.delta==`string`&&e.delta.length>0){let t=c.current;t!==null&&t.item_id===e.item_id&&t.output_index===e.output_index&&t.content_index===e.content_index&&t?c.current={...t,delta:t.delta+e.delta,sequence_number:e.sequence_number??t.sequence_number}:(ue(),c.current={...e}),performance.now()-l.current>=Tj&&ue();return}ue(),I(e)},[I,L,ue]);if(h)return(0,T.jsxs)(`div`,{className:`h-screen flex flex-col bg-background`,children:[(0,T.jsxs)(`header`,{className:`flex h-14 items-center gap-4 border-b px-4`,children:[(0,T.jsx)(`div`,{className:`w-64 h-9 bg-muted animate-pulse rounded-md`}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[(0,T.jsx)(`div`,{className:`w-8 h-8 bg-muted animate-pulse rounded-md`}),(0,T.jsx)(`div`,{className:`w-8 h-8 bg-muted animate-pulse rounded-md`})]})]}),(0,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`div`,{className:`text-lg font-medium`,children:`Initializing DevUI...`}),(0,T.jsx)(`div`,{className:`text-sm text-muted-foreground mt-2`,children:`Loading agents and workflows from your configuration`})]})})]});if(g){let t=Vh.getBaseUrl(),a=g===`UNAUTHORIZED`||e,s=`8080`;try{if(t){let e=new URL(t);s=e.port||(e.protocol===`https:`?`443`:`80`)}}catch{}return(0,T.jsxs)(`div`,{className:`h-screen flex flex-col bg-background`,children:[(0,T.jsx)(Od,{agents:[],workflows:[],entities:[],selectedItem:void 0,onSelect:()=>{},isLoading:!1,onSettingsClick:()=>U(!0)}),(0,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,T.jsxs)(`div`,{className:`text-center space-y-6 max-w-2xl`,children:[(0,T.jsx)(`div`,{className:`flex justify-center`,children:(0,T.jsx)(`div`,{className:`rounded-full bg-muted p-4 animate-pulse`,children:a?(0,T.jsx)($l,{className:`h-12 w-12 text-muted-foreground`}):(0,T.jsx)(gu,{className:`h-12 w-12 text-muted-foreground`})})}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`h2`,{className:`text-2xl font-semibold text-foreground`,children:a?`Authentication Required`:`Can't Connect to Backend`}),(0,T.jsx)(`p`,{className:`text-muted-foreground text-base`,children:a?`This backend requires a bearer token to access.`:`No worries! Just start the DevUI backend server and you'll be good to go.`})]}),a?(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`text-left bg-muted/50 rounded-lg p-4 space-y-3`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enter Authentication Token`}),(0,T.jsx)(Um,{type:`password`,placeholder:`Paste token from server logs`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!i&&se()},disabled:i,className:`font-mono text-sm`}),(0,T.jsx)(K,{onClick:se,disabled:!n.trim()||i,className:`w-full`,children:i?`Verifying...`:`Connect`}),o&&(0,T.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400 text-center`,children:o})]}),(0,T.jsxs)(`details`,{className:`text-left group`,children:[(0,T.jsxs)(`summary`,{className:`text-sm text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-2 justify-center`,children:[(0,T.jsx)(X,{className:`h-4 w-4 transition-transform group-open:rotate-180`}),`Where do I find the token?`]}),(0,T.jsxs)(`div`,{className:`mt-3 text-left bg-muted/30 rounded-lg p-3 space-y-2`,children:[(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Look for this in your DevUI server startup logs:`}),(0,T.jsxs)(`code`,{className:`block bg-background px-2 py-1 rounded text-xs font-mono text-foreground`,children:[`🔑 DEV TOKEN (localhost only, shown once):`,(0,T.jsx)(`br`,{}),`\xA0\xA0 abc123xyz...`]})]})]})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsxs)(`div`,{className:`text-left bg-muted/50 rounded-lg p-4 space-y-3`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Start the backend:`}),(0,T.jsxs)(`code`,{className:`block bg-background px-3 py-2 rounded border text-sm font-mono text-foreground`,children:[`devui ./agents --port `,s]}),(0,T.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Or launch programmatically with`,` `,(0,T.jsx)(`code`,{className:`text-xs`,children:`serve(entities=[agent])`})]})]}),(0,T.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Default:`,` `,(0,T.jsx)(`span`,{className:`font-mono`,children:t})]})]}),g&&(0,T.jsxs)(`details`,{className:`text-left group`,children:[(0,T.jsxs)(`summary`,{className:`text-sm text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-2`,children:[(0,T.jsx)(X,{className:`h-4 w-4 transition-transform group-open:rotate-180`}),`Error details`]}),(0,T.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground font-mono bg-muted/30 p-3 rounded border`,children:g})]}),(0,T.jsx)(K,{onClick:()=>window.location.reload(),variant:`default`,className:`mt-2`,children:`Retry Connection`})]})]})}),(0,T.jsx)(lh,{open:z,onOpenChange:U})]})}return(0,T.jsxs)(`div`,{className:`h-screen flex flex-col bg-background max-h-screen`,children:[(0,T.jsx)(Od,{agents:u,workflows:d,entities:f,selectedItem:p,onSelect:le,onBrowseGallery:()=>te(!0),isLoading:h,onSettingsClick:()=>U(!0)}),(0,T.jsx)(`div`,{className:`flex flex-1 overflow-hidden`,children:B?(0,T.jsx)(`div`,{className:`flex-1 w-full`,children:(0,T.jsx)(ag,{variant:`route`,onClose:()=>te(!1),hasExistingEntities:u.length>0||d.length>0})}):u.length===0&&d.length===0?(0,T.jsx)(ag,{variant:`inline`}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`flex-1 min-w-0`,children:p?p.type===`agent`?(0,T.jsx)(pv,{selectedAgent:p,onDebugEvent:de}):(0,T.jsx)(Sj,{selectedWorkflow:p,onDebugEvent:de}):(0,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground`,children:`Select an agent or workflow to get started.`})}),v===`developer`&&k?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`w-1 cursor-col-resize flex-shrink-0 relative group transition-colors duration-200 ease-in-out ${N?`bg-primary/40`:`bg-border hover:bg-primary/20`}`,onMouseDown:ce,children:(0,T.jsx)(`div`,{className:`absolute inset-y-0 -left-2 -right-2 flex items-center justify-center`,children:(0,T.jsx)(`div`,{className:`h-12 w-1 rounded-full transition-all duration-200 ease-in-out ${N?`bg-primary shadow-lg shadow-primary/25`:`bg-primary/30 group-hover:bg-primary group-hover:shadow-md group-hover:shadow-primary/20`}`})})}),(0,T.jsx)(`div`,{className:`flex-shrink-0 flex flex-col h-[calc(100vh-3.7rem)]`,style:{width:A?`2.5rem`:`${j}px`},children:A?(0,T.jsxs)(`div`,{className:`h-full w-10 bg-background border-l flex flex-col items-center py-2 cursor-pointer hover:bg-accent/50 transition-colors`,onClick:()=>ee(!1),title:`Expand debug panel`,children:[(0,T.jsx)(`div`,{className:`h-8 w-8 flex items-center justify-center`,children:(0,T.jsx)(El,{className:`h-4 w-4 text-muted-foreground`})}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-2 pointer-events-none`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground select-none`,style:{writingMode:`vertical-rl`,transform:`rotate(180deg)`},children:`Debug Panel`}),M.length>0&&(0,T.jsx)(`div`,{className:`bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center`,style:{fontSize:`10px`},children:M.length})]})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(Fm,{events:M,isStreaming:!1,onMinimize:()=>ee(!0)}),(0,T.jsx)(`div`,{className:`border-t bg-muted/30 px-3 py-2.5 flex-shrink-0`,children:(0,T.jsxs)(K,{onClick:()=>ne(!0),className:`w-full`,variant:`outline`,size:`sm`,children:[(0,T.jsx)(du,{className:`h-3 w-3 mr-2 flex-shrink-0`}),(0,T.jsx)(`span`,{className:`truncate text-xs`,children:m&&p?.deployment_supported?`Deploy to Azure`:`Deployment Guide`})]})})]})})]}):v===`developer`?(0,T.jsx)(`div`,{className:`flex-shrink-0`,children:(0,T.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>P(!0),className:`h-full w-10 rounded-none border-l`,title:`Show debug panel`,children:(0,T.jsx)(ou,{className:`h-4 w-4`})})}):null]})}),(0,T.jsx)(lh,{open:z,onOpenChange:U}),(0,T.jsx)(Hh,{open:V,onClose:()=>ne(!1),agentName:p?.name,entity:p}),H&&(0,T.jsx)(Cj,{message:`Entity not found. Showing first available entity instead.`,type:`info`,onClose:()=>re(!1)}),(0,T.jsx)(wj,{toasts:ie,onRemove:oe})]})}function Dj({children:e,attribute:t=`class`,defaultTheme:n=`dark`,enableSystem:r=!0,disableTransitionOnChange:i=!0,...a}){return(0,T.jsx)(Gu,{attribute:t,defaultTheme:n,enableSystem:r,disableTransitionOnChange:i,...a,children:e})}Ch(),(0,b.createRoot)(document.getElementById(`root`)).render((0,T.jsx)(y.StrictMode,{children:(0,T.jsx)(Dj,{attribute:`class`,defaultTheme:`dark`,enableSystem:!0,disableTransitionOnChange:!0,children:(0,T.jsx)(Ej,{})})})); From 160783f7d529d082b2c97feeee177d9931f287cd Mon Sep 17 00:00:00 2001 From: dhairya Date: Thu, 8 Oct 2026 13:40:14 +0530 Subject: [PATCH 8/8] test(devui): use protocol-compatible client in discovery regression Use the existing BaseChatClient fixture so the metadata regression satisfies the overloaded response protocol. Assertions and production code are unchanged. --- python/packages/devui/tests/devui/test_discovery.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/packages/devui/tests/devui/test_discovery.py b/python/packages/devui/tests/devui/test_discovery.py index 35e11bca229..7c0ffadc977 100644 --- a/python/packages/devui/tests/devui/test_discovery.py +++ b/python/packages/devui/tests/devui/test_discovery.py @@ -27,9 +27,9 @@ ), ], ) -async def test_context_providers_in_agent_metadata(mock_chat_client, context_providers, expected): +async def test_context_providers_in_agent_metadata(mock_base_chat_client, context_providers, expected): """Discovery includes all configured providers in their configured order.""" - agent = Agent(client=mock_chat_client, name="Example", context_providers=context_providers) + agent = Agent(client=mock_base_chat_client, name="Example", context_providers=context_providers) entity_info = await EntityDiscovery().create_entity_info_from_object(agent)