@schlenkr/ragents 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/apps/server/package.json +1 -1
  2. package/apps/server/src/access-projection.ts +6 -36
  3. package/apps/server/src/api/contracts.ts +5 -2
  4. package/apps/server/src/api/core-methods.ts +5 -3
  5. package/apps/server/src/config-file.ts +1 -1
  6. package/apps/server/src/host-api.json +2 -0
  7. package/apps/server/src/plugin-support/process-sandbox.ts +16 -15
  8. package/apps/server/src/provider.ts +2 -2
  9. package/apps/server/src/ragents/engine.ts +2 -1
  10. package/apps/server/src/ragents/global-chat.ts +7 -1
  11. package/apps/server/src/server.ts +3 -1
  12. package/apps/web/dist/assets/{highlighted-body-KPVGNVTW-xXXhTDbh.js → highlighted-body-KPVGNVTW-BO4wLQtE.js} +1 -1
  13. package/apps/web/dist/assets/main-DnnqWHkH.js +11 -0
  14. package/apps/web/dist/assets/mermaid-HWGCJPDP-BLLeth5_.js +568 -0
  15. package/apps/web/dist/assets/{runPanel-ZT6TPDLM.js → runPanel-DPm7s3KM.js} +2 -2
  16. package/apps/web/dist/help/guide-clients.html +17 -7
  17. package/apps/web/dist/help/guide-clients.md +18 -7
  18. package/apps/web/dist/help/index.html +1911 -908
  19. package/apps/web/dist/help/mini-app.css +24 -0
  20. package/apps/web/dist/host-web.json +2 -2
  21. package/apps/web/dist/index.html +2 -2
  22. package/apps/web/dist/run-panel.html +2 -2
  23. package/apps/web/package.json +1 -1
  24. package/apps/web/src/panel/ConnectionsPage.tsx +3 -0
  25. package/apps/web/src/panel/StartPage.tsx +3 -0
  26. package/apps/web/src/panel/contract.ts +7 -0
  27. package/bundles/ragents.activity/ragents-bundle.json +1 -1
  28. package/bundles/ragents.actor-programs/ragents-bundle.json +2 -2
  29. package/bundles/ragents.actor-programs/server/index.js +31 -3
  30. package/bundles/ragents.actor-programs/server/index.js.map +4 -4
  31. package/bundles/ragents.actor-programs/web/index.js.map +1 -1
  32. package/bundles/ragents.ask/ragents-bundle.json +2 -4
  33. package/bundles/ragents.ask/web/chunks/{chunk-V7W3QDVS.js → chunk-MBRPS477.js} +2 -2
  34. package/bundles/ragents.ask/web/chunks/{chunk-V7W3QDVS.js.map → chunk-MBRPS477.js.map} +4 -4
  35. package/bundles/ragents.ask/web/classes.json +1 -1
  36. package/bundles/ragents.ask/web/exports/web/QuestionCard.js +1 -1
  37. package/bundles/ragents.ask/web/index.js +1 -1
  38. package/bundles/ragents.ask/web/index.js.map +4 -4
  39. package/bundles/ragents.browser/ragents-bundle.json +1 -1
  40. package/bundles/ragents.documents/ragents-bundle.json +1 -1
  41. package/bundles/ragents.lsp-fsharp/ragents-bundle.json +1 -1
  42. package/bundles/ragents.lsp-roslyn/ragents-bundle.json +1 -1
  43. package/bundles/ragents.lsp-typescript/ragents-bundle.json +1 -1
  44. package/bundles/ragents.model-relay/ragents-bundle.json +1 -1
  45. package/bundles/ragents.orchestration/ragents-bundle.json +2 -2
  46. package/bundles/ragents.orchestration/web/classes.json +1 -1
  47. package/bundles/ragents.orchestration/web/index.js +6 -6
  48. package/bundles/ragents.orchestration/web/index.js.map +3 -3
  49. package/bundles/ragents.overseer/ragents-bundle.json +2 -2
  50. package/bundles/ragents.overseer/server/index.js +1 -1
  51. package/bundles/ragents.overseer/server/index.js.map +2 -2
  52. package/bundles/ragents.processes/ragents-bundle.json +1 -1
  53. package/bundles/ragents.product/ragents-bundle.json +1 -1
  54. package/bundles/ragents.profile-distribution/ragents-bundle.json +1 -1
  55. package/bundles/ragents.reference/ragents-bundle.json +1 -1
  56. package/bundles/ragents.todo/ragents-bundle.json +1 -1
  57. package/bundles/ragents.transcript/ragents-bundle.json +1 -1
  58. package/bundles/ragents.watch/ragents-bundle.json +1 -1
  59. package/bundles/ragents.workspace/ragents-bundle.json +2 -2
  60. package/bundles/ragents.workspace/server/index.js +4 -2
  61. package/bundles/ragents.workspace/server/index.js.map +2 -2
  62. package/package.json +3 -3
  63. package/packages/agent/dist/core/tools/bash.d.ts +1 -1
  64. package/packages/agent/src/core/tools/bash.ts +1 -1
  65. package/packages/ragents/src/index.ts +1 -0
  66. package/packages/ragents/src/plugin-host.ts +46 -0
  67. package/packages/ragents/src/plugin-types.ts +19 -0
  68. package/packages/workspace-executor/src/managed-process.ts +28 -0
  69. package/packages/workspace-executor/src/sandbox-tools.ts +9 -3
  70. package/plugins/ragents.actor-programs/server/access-projections.ts +31 -0
  71. package/plugins/ragents.actor-programs/server/index.ts +2 -0
  72. package/plugins/ragents.ask/web/index.tsx +0 -6
  73. package/plugins/ragents.orchestration/web/ActorTile.tsx +1 -1
  74. package/plugins/ragents.orchestration/web/run-panel/RunPanel.tsx +8 -7
  75. package/plugins/ragents.orchestration/web/run-panel/sheet-status.ts +3 -3
  76. package/plugins/ragents.overseer/server/api.ts +2 -2
  77. package/plugins/ragents.workspace/client/workspace-client.ts +19 -6
  78. package/plugins/ragents.workspace/server/config.ts +3 -0
  79. package/plugins/ragents.workspace/server/index.ts +3 -2
  80. package/apps/web/dist/assets/main-C7JeZFjs.js +0 -6
  81. package/apps/web/dist/assets/mermaid-HWGCJPDP-DfsU5ofC.js +0 -478
  82. package/plugins/ragents.ask/web/QuestionSection.tsx +0 -48
@@ -1,12 +1,12 @@
1
- import{a as gt,b as Ua}from"/plugins/ragents.orchestration/web/chunks/chunk-OSKPH6SZ.js";import{b as da}from"/plugins/ragents.orchestration/web/chunks/chunk-ODMMQGX2.js";import{a as p,b as Io,c as Ge,d as Ha,e as Co,f as q,g as So,h as O,i as pe,j as We,k as D,l as U,m as w}from"/plugins/ragents.orchestration/web/chunks/chunk-OQYCNYXN.js";import{a as Ae,e as ua,f as wo,g as ft,h as ct,i as pt,j as mt}from"/plugins/ragents.orchestration/web/chunks/chunk-XGPPQCZR.js";var W=p("@ragents/web/AccessContext","useAccess");var na=p("react-dom","createPortal");var xt=p("@ragents/engine/src/http/contracts","handleKey");var me=p("@ragents/engine/src/http/contracts","runContracts");var bo="ragents.orchestration",ys=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),yo=e=>{let a=e.trim();if(a.startsWith("@")){let s=xt(a);if(!s||/\s/.test(s))throw new Error(`Entit\xE4t ${JSON.stringify(e)}: nach dem @ fehlt ein Handle`);return{kind:"actor",handle:s}}let o=/^app:(.+)$/s.exec(a);if(!o)throw new Error(`Entit\xE4t ${JSON.stringify(e)}: erwartet @handle oder app:<id>`);let r=o[1].trim();if(!r)throw new Error(`Entit\xE4t ${JSON.stringify(e)}: die ID nach dem Doppelpunkt ist leer`);return{kind:"app",id:r}},ko=e=>e.kind==="actor"?`@${e.handle}`:`app:${e.id}`,ks=["nodes","shapes","lines","mode"],Ao=e=>{if(!ys(e))throw new Error("Die Anordnung muss ein Objekt mit root sein");let a=ks.filter(o=>o in e);if(a.length>0)throw new Error(`Die Programmanordnung stammt aus der entfernten freien Fl\xE4che (${a.join(", ")}); canvas_layout_replace mit root setzt sie als Kachelaufteilung neu`);if(!("root"in e))throw new Error("root fehlt; erwartet wird eine Kachel, eine Teilung oder null");return{root:e.root===null?null:_e(e.root)}};var vo=16,Po=64,_e=e=>{let a=new Set,o=(r,s,d)=>{if(d>vo)throw new Error(`${s}: h\xF6chstens ${vo} verschachtelte Teilungen sind erlaubt`);if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`${s} muss eine Kachel oder Teilung sein`);let l=r;if(Object.hasOwn(l,"entity")){if(Object.keys(l).some(f=>f!=="entity"&&f!=="chatInput"))throw new Error(`${s}: eine Kachel tr\xE4gt nur entity und chatInput; eine Teilung direction, weights und children`);if(typeof l.entity!="string")throw new Error(`${s}.entity muss @handle oder app:<name>/<view> sein`);let n=yo(l.entity),i=ko(n);if(l.chatInput!==void 0&&(n.kind!=="actor"||typeof l.chatInput!="boolean"))throw new Error(`${s}.chatInput ist nur f\xFCr Actors als Wahrheitswert erlaubt`);if(a.has(i))throw new Error(`${s}: ${i} ist mehr als einmal als Kachel platziert`);if(a.add(i),a.size>Po)throw new Error(`H\xF6chstens ${Po} Kacheln sind erlaubt`);return l.chatInput===void 0?{entity:i}:{entity:i,chatInput:l.chatInput}}if(Object.keys(l).some(n=>!["direction","weights","children"].includes(n)))throw new Error(`${s}: eine Teilung tr\xE4gt nur direction, weights und children`);if(l.direction!=="horizontal"&&l.direction!=="vertical")throw new Error(`${s}.direction muss horizontal oder vertical sein`);if(!Array.isArray(l.weights)||l.weights.length!==2||l.weights.some(n=>typeof n!="number"||!Number.isFinite(n)||n<=0))throw new Error(`${s}.weights muss genau zwei endliche positive Zahlen enthalten`);if(!Array.isArray(l.children)||l.children.length!==2)throw new Error(`${s}.children muss genau zwei Kacheln oder Teilungen enthalten`);return{direction:l.direction,weights:[l.weights[0],l.weights[1]],children:[o(l.children[0],`${s}.children[0]`,d+1),o(l.children[1],`${s}.children[1]`,d+1)]}};return o(e,"root",0)},Va=(e,a)=>e?"entity"in e?e.entity!==a||e.chatInput!==!1:Va(e.children[0],a)&&Va(e.children[1],a):!0,za=e=>e?"entity"in e?[e.entity]:e.children.flatMap(za):[];var ht=p("@ragents/web/ui","Alert");var Lt=p("@ragents/web/ui","AlertDescription");var se=p("@ragents/web/ui","Badge");var z=p("@ragents/web/ui","Button");var Xe=p("@ragents/web/ui","Empty");var ia=p("@ragents/web/ui","EmptyDescription");var Ke=p("@ragents/web/ui","EmptyHeader");var $e=p("@ragents/web/ui","EmptyTitle");var te=p("@ragents/web/ui","Input");var fa=p("@ragents/web/ui","Popover");var ca=p("@ragents/web/ui","PopoverContent");var It=p("@ragents/web/ui","SectionLabel");var Ct=p("@ragents/web/ui","Select");var St=p("@ragents/web/ui","SelectContent");var wt=p("@ragents/web/ui","SelectItem");var bt=p("@ragents/web/ui","SelectTrigger");var yt=p("@ragents/web/ui","SelectValue");var ve=p("@ragents/web/ui","Spinner");var pa=p("@ragents/web/ui","StartupNotice");var kt=p("@ragents/web/ui","StopGlyph");var At=p("@ragents/web/ui","Tabs");var Ga=p("@ragents/web/ui","TabsContent");var vt=p("@ragents/web/ui","TabsList");var Wa=p("@ragents/web/ui","TabsTrigger");var Y=p("@ragents/web/ui","cn");var Pt=p("quassel","ChatInputToolbar");var Rt=p("quassel","ChatMessages");var ma=p("quassel","ChatPanel");var Mt=p("@ragents/web/PluginRegistry","SurfaceControllerProvider");var Tt=p("@ragents/web/PluginRegistry","useActionRenderer");var ga=p("@ragents/web/PluginRegistry","useSurfaceController");var Dt=p("@ragents/web/PluginRegistry","useToolRenderer");var Bt=p("@ragents/web/chat-view-settings","ChatViewSwitches");var xa=p("@ragents/web/chat-view-settings","useChatViewSettings");var Ft=p("@ragents/web/actor-conversation","actorChatMessages");var Nt=p("@ragents/web/actor-conversation","actorInputLabel");var X=p("react/jsx-runtime","Fragment");var t=p("react/jsx-runtime","jsx");var u=p("react/jsx-runtime","jsxs");var As=[];function Ze({actor:e,view:a,presentation:o,display:r=o,primaryMessages:s=As,conversation:d,historyError:l,running:n=!1,className:i,onNavigate:f,scrollerRef:c}){let m=W().can("runs.inspect"),h=xa(a.id,e.id,"agents",r),C=Dt(),x=Tt(),L=h.detailMode,b=m||L==="off"?L:"current",P=D(()=>Ft(a,e,s,d),[a,e,s,d]),y=q(R=>{let N=/^ablauf:(actor|input|turn|subscription|action|artifact)\/(.+)$/.exec(R);return N?(m&&f({type:N[1],id:N[2]}),!0):!1},[m,f]);return u(X,{children:[l&&t("p",{className:"my-1.5 text-[0.72rem] text-destructive",role:"alert",children:l}),t(Rt,{className:i,detailMode:b,emptyState:t(Xe,{children:u(Ke,{children:[t($e,{children:e.kind==="script"?"Noch kein Verlauf":"Noch kein Gespr\xE4ch"}),t(ia,{children:e.kind==="script"?"Hier erscheinen Programmeingaben und ihre Verarbeitung.":"Schreibe eine Nachricht, um das Gespr\xE4ch zu beginnen."})]})}),messages:P,renderAction:x,renderTool:C,owner:e.id,onLinkClick:y,running:n,showTimestamps:h.showTimestamps,stepsExpandable:m&&h.stepsExpandable,scrollerRef:c})]})}var Et=p("@ragents/web/api","interruptActorTurn");var qt=p("@ragents/web/api","sendActorMessage");var Ot=p("@ragents/web/chat/StoppedActorNotice","StoppedActorNotice");var Ht=p("@ragents/web/chat/useAttachmentCapabilities","useAttachmentCapabilities");var Ut=p("@ragents/web/chat/chat-target","programChatNotice");var Vt=p("@ragents/web/chat/chat-target","runIsWorking");var Ro="flex flex-shrink-0 items-center gap-2 border-t border-border-soft px-workspace-inset pt-2 pb-2.5",zt="mt-1.5 text-[0.7rem] text-muted-foreground";function Je({actor:e,view:a,composerVisible:o=!0,presentation:r="inspector",display:s=r,running:d=!1,toolbarLeft:l,toolbarRight:n}){let i=W().can("runs.write"),[f,c]=w(),m=xa(a.id,e.id,"agents",s),h=Ht(a.id,e.id,JSON.stringify(e.execution?.driver.config)),C=i?void 0:"Du hast Lesezugriff auf diesen Run.",x=t(Bt,{collapsible:r==="surface",settings:m});return!o||e.kind==="human"?u("div",{className:Ro,children:[l,x]}):e.kind==="script"?u("div",{className:Ro,children:[t("p",{className:zt,children:Ut}),l,x]}):e.lifecycle?.kind==="stopped"?t("div",{className:r==="inspector"?"flex-shrink-0 px-5 pt-2.5 pb-3.5":void 0,children:t(Ot,{actor:e,runId:a.id,toolbar:u(X,{children:[l,x]})})}):u("div",{className:r==="inspector"?"flex-shrink-0 px-5 pt-2.5 pb-3.5":void 0,children:[t(Pt,{...h,disabled:C!==void 0,layout:r==="surface"?"inline":"card",maxRows:4,onSend:(L,b)=>qt(a.id,e.id,L,b),onStop:i&&e.lifecycle?.kind==="running"?()=>{c(void 0),Et(a.id,e.id).catch(L=>c(L instanceof Error?L.message:String(L)))}:void 0,rows:1,running:d,texts:{placeholder:C??`Nachricht an @${e.handle} ...`},toolbarLeft:u(X,{children:[l,x,r==="inspector"&&u("span",{className:"truncate text-[0.7rem] text-muted-foreground",children:["an @",e.handle]})]}),toolbarRight:n}),f&&t("p",{className:zt,role:"alert",children:f}),C&&r==="inspector"&&t("p",{className:zt,children:C})]})}var Mo=Co(function({actor:a,view:o,primaryMessages:r,conversation:s,historyError:d,chatInput:l=!0,running:n=!1,onNavigate:i}){let f=q(c=>{c&&(c.tabIndex=0,c.setAttribute("role","region"),c.setAttribute("aria-label",`Chatverlauf von @${a.handle}`))},[a.handle]);return t("div",{className:"flex min-h-[106px] w-full min-w-0 flex-1 flex-col overflow-hidden rounded-b-[16px] text-left","data-surface-scroll":"true",children:t(ma,{className:"flex-1",composer:t(Je,{actor:a,view:o,composerVisible:l,presentation:"surface",running:n}),children:t(Ze,{actor:a,view:o,presentation:"surface",primaryMessages:r,conversation:s,historyError:d,running:n,onNavigate:i,scrollerRef:f})})})});var Gt="ragents.orchestration",_a="flex h-full min-w-statusbar items-center justify-center self-stretch whitespace-nowrap px-2.5 text-[0.7rem] text-foreground hover:bg-primary/12 aria-expanded:bg-primary/12 focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",Xa="grid gap-2.5 border-t border-border-soft px-3 pt-2.5 pb-2.5 empty:hidden";function To({actor:e,view:a,cardSections:o,chatInput:r,session:s,navigation:d,onSelect:l}){return u("div",{className:"flex flex-col overflow-hidden has-[>[data-slot=card-sections]:not(:empty)]:min-h-[260px]",children:[t(Mo,{actor:e,view:a,chatInput:r,running:e.lifecycle?.kind==="running",conversation:s.actorConversations?.[e.id],historyError:s.conversationError,onNavigate:l,primaryMessages:e.id===a.primaryActorId?s.messages:void 0}),t("div",{className:`${Xa} max-h-[45%] flex-[0_1_auto] overflow-auto overscroll-contain`,"data-slot":"card-sections",children:o.map(({id:n,Section:i})=>t(i,{actor:e,navigation:d,session:s},n))})]})}var Do=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function Bo(e,a,o=[]){if(a==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:Do(e),size:24,node:a,...o.length>0?{aliases:o}:{}}}var Fo=e=>{let a="",o=!1;for(let r of e){if(r==="-"||r==="_"||r<=" "){o=a.length>0;continue}a.length===0?a+=r.toLowerCase():a+=o?r.toUpperCase():r,o=!1}return a};var No=e=>{let a=Fo(e);return a.charAt(0).toUpperCase()+a.slice(1)};var ha=(...e)=>e.filter((a,o,r)=>!!a&&a.trim()!==""&&r.indexOf(a)===o).join(" ").trim();var Pe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function Wt(e){return e!=null}function Eo(e,a={}){let o=a.attributeNames??{},r=h=>o[h]??h,s=e.size??e.width??Pe.width,d=e.size??e.height??Pe.height,l=e.aliases?.filter(h=>typeof h=="string"&&h.trim()!=="").map(h=>`lucide-${h}`)??[],n=[...e.name?[`lucide-${e.name}`]:[],...l],i=a.className?.split(" ").filter(Boolean)??[],f=a.includeDefaultClasses===!1?ha(...i):ha("lucide",...n,...i),c=a.absoluteStrokeWidth?Number(a.strokeWidth??Pe["stroke-width"])*Number(e.size??e.width??Pe.width)/Number(a.size??a.width??Pe.width):a.strokeWidth??Pe["stroke-width"];return["svg",{...Object.entries(Pe).reduce((h,[C,x])=>(h[r(C)]=x,h),{}),..."color"in a&&a.color&&{[r("stroke")]:a.color},..."size"in a&&Wt(a.size)&&{[r("width")]:a.size,[r("height")]:a.size},..."width"in a&&Wt(a.width)&&{[r("width")]:a.width},..."height"in a&&Wt(a.height)&&{[r("height")]:a.height},[r("stroke-width")]:c,...f&&{[r("class")]:f},[r("viewBox")]:`0 0 ${s} ${d}`,...a.hasA11yProp===!1?{[r("aria-hidden")]:"true"}:{},..."attributes"in a&&a.attributes},e.node.map(h=>{let[C,x,L]=h,b=a.nonScalingStroke?{[r("vector-effect")]:"non-scaling-stroke",...x}:x;return L?[C,b,L]:[C,b]})]}function qo(e,a={}){return Eo(e,{...a,attributeNames:{...a.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var Oo=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var vs=Io({});var Ho=()=>So(vs);var Uo=Ha(({color:e,size:a,width:o,height:r,strokeWidth:s,absoluteStrokeWidth:d,nonScalingStroke:l,className:n="",children:i,iconNode:f=[],icon:c={node:f,aliases:[],size:24},...m},h)=>{let{size:C=24,strokeWidth:x=2,absoluteStrokeWidth:L=!1,nonScalingStroke:b=!1,color:P="currentColor",className:y=""}=Ho()??{},R=!!i||Oo(m),[N,K,V=[]]=qo(c,{color:e??P,width:o??a??C,height:r??a??C,strokeWidth:s??x,absoluteStrokeWidth:d??L,nonScalingStroke:l??b,className:ha(y,n),hasA11yProp:R,attributes:m});return Ge(N,{ref:h,...K},[...V.map(([k,M])=>Ge(k,M)),...Array.isArray(i)?i:[i]])});function E(e,a=[],o=[]){let r=typeof e=="string"?Bo(e,a,o):e,s=Ha(({className:d,...l},n)=>Ge(Uo,{ref:n,icon:r,className:d,...l}));return r.name&&(s.displayName=No(r.name)),s}var Vo={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};Vo.node;var La=E(Vo);var zo={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};zo.node;var Ee=E(zo);var Go={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};Go.node;var Ia=E(Go);var Wo={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};Wo.node;var je=E(Wo);var _o={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};_o.node;var Ca=E(_o);var Xo={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Xo.node;var Qe=E(Xo);var Ko={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Ko.node;var Sa=E(Ko);var $o={name:"code-xml",size:24,node:[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],aliases:["code-2"]};$o.node;var Re=E($o);var Zo={name:"code",size:24,node:[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]};Zo.node;var qe=E(Zo);var Jo={name:"grip-vertical",size:24,node:[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]};Jo.node;var wa=E(Jo);var jo={name:"layout-grid",size:24,node:[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]};jo.node;var Oe=E(jo);var Qo={name:"maximize-2",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]};Qo.node;var ba=E(Qo);var Yo={name:"message-square",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]};Yo.node;var ya=E(Yo);var er={name:"panel-bottom",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]};er.node;var ka=E(er);var ar={name:"panel-right",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]};ar.node;var Aa=E(ar);var tr={name:"sparkles",size:24,node:[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],aliases:["stars"]};tr.node;var ge=E(tr);var or={name:"users",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]};or.node;var Se=E(or);var rr={name:"wrench",size:24,node:[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]};rr.node;var va=E(rr);var sr={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};sr.node;var xe=E(sr);var He=p("@ragents/web/run-view","actorTone");var we=p("@ragents/web/run-view","chatPrimaryId");var Pa=p("@ragents/web/run-view","isPendingRunActorInput");var _t=p("@ragents/web/run-view","runActorFrom");var Ra=p("@ragents/web/run-view","runArtifactContentUrl");var J=p("@ragents/web/run-view","runViewFrom");var he=p("@ragents/web/rpc","rpc");var lr=async(e,a,o,r)=>{await he.call(me.resolveAction,{runId:e,commandId:crypto.randomUUID(),actionId:a,decision:o,result:r})},dr=async(e,a,o)=>{await he.call(me.stopActor,{runId:e,commandId:crypto.randomUUID(),actorId:a,reason:o})},ur=async(e,a)=>{await he.call(me.restartActor,{runId:e,commandId:crypto.randomUUID(),actorId:a})},nr=async(e,a)=>{await he.call(me.stopAll,{runId:e,commandId:crypto.randomUUID(),reason:a})};var Ue=p("@ragents/web/lib/format","formatBytes");var Me=p("@ragents/web/SourceCode","SourceCode");var Xt=p("@ragents/web/lib/labels","thinkingLabel");var oe=e=>{let a=new Date(e);return Number.isNaN(a.getTime())?e:a.toLocaleString("de-DE")};var Ye="flex h-full min-h-0 flex-col bg-card",Jt="flex flex-shrink-0 items-start gap-2.5 border-b border-border-soft px-workspace-inset pt-3 pb-2 [&_h2]:text-[0.95rem] [&_h2]:leading-[1.3]",jt="block truncate text-[0.72rem] text-muted-foreground",Ka="flex flex-shrink-0 flex-wrap items-center gap-x-2.5 gap-y-0.5 border-b border-border-soft px-workspace-inset py-1.5 text-[0.72rem] text-muted-foreground",Da="min-h-0 flex-1 overflow-y-auto px-workspace-inset py-2.5",ee="mb-4 [&>h3]:mb-1.5 [&>h3]:text-[0.72rem] [&>h3]:font-semibold [&>h3]:tracking-[0.05em] [&>h3]:uppercase [&>h3]:text-muted-foreground",Te="flex flex-col gap-1 py-1.5",De="flex cursor-pointer items-center gap-2 rounded-lg border border-border-soft px-2 py-1.5 text-left hover:border-[color-mix(in_srgb,var(--primary)_45%,var(--border))] hover:bg-primary/6 [&_strong]:truncate [&_strong]:text-[0.76rem] [&_small]:text-[0.66rem] [&_small]:text-muted-foreground",Be="flex min-w-0 flex-1 flex-col",be="text-[0.74rem] text-muted-foreground",Qt="my-1.5 text-[0.72rem] text-destructive",Ve="my-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[0.74rem] [&_dt]:text-muted-foreground [&_dd]:[overflow-wrap:anywhere]",Ma="my-1.5 rounded-lg bg-foreground/4 p-2 text-[0.72rem] whitespace-pre-wrap [overflow-wrap:anywhere]",fr="cursor-pointer text-[0.74rem] text-primary underline",Yt="h-auto rounded-full bg-foreground/8 px-2 py-0.5 text-[0.66rem] font-semibold text-muted-foreground",Ps={running:"bg-accent text-primary",active:"bg-success-soft text-success",approved:"bg-success-soft text-success",completed:"bg-success-soft text-success",idle:"bg-success-soft text-success",pending:"bg-success-soft text-success",waiting:"bg-success-soft text-success",queued:"bg-success-soft text-success",failed:"bg-destructive-soft text-destructive",interrupted:"bg-destructive-soft text-destructive"},ir="grid size-[30px] flex-[0_0_30px] place-items-center p-0",Rs={active:"Aktiv",approved:"Best\xE4tigt",completed:"Abgeschlossen",dismissed:"Verworfen",failed:"Fehlgeschlagen",idle:"Bereit",interrupted:"Unterbrochen",pending:"Offen",removed:"Entfernt",running:"L\xE4uft",stopped:"Gestoppt"},cr={human:"Person",agent:"Agent",script:"Logik-Actor"},Ms="Vom Bediener gestoppt",de=e=>e.length>12?`${e.slice(0,12)}...`:e,pr=e=>e.usage,Ts=e=>{let a=e.turns.map(o=>pr(o)?.costUsd).filter(o=>typeof o=="number"&&Number.isFinite(o));return a.length>0?a.reduce((o,r)=>o+r,0):void 0},Ds=e=>`${e.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:e>0&&e<.005?4:2})} USD`,Bs=e=>({view:e,actorById:new Map(e.actors.map(a=>[a.id,a])),inputById:new Map(e.inputs.map(a=>[a.id,a])),turnById:new Map(e.turns.map(a=>[a.id,a])),subscriptionById:new Map(e.subscriptions.map(a=>[a.id,a])),actionById:new Map(e.actions.map(a=>[a.id,a])),artifactById:new Map(e.artifacts.map(a=>[a.id,a]))}),ea=(e,a)=>`@${e.actorById.get(a)?.handle??de(a)}`,mr=(e,a)=>Nt(e.view,a);function $a(e){let a=W().can("runs.inspect"),o=e.view,r=D(()=>o?Bs(o):void 0,[o]);if(!o||!r)return t(Xe,{children:u(Ke,{children:[t($e,{children:"Noch kein Ablauf"}),t(ia,{children:"Sobald Actors gestartet werden, erscheint hier die Detailansicht."})]})});let s=e.selection,d=s?.type==="actor"?r.actorById.get(s.id):void 0,l=s?.type==="input"?r.inputById.get(s.id):void 0,n=s?.type==="turn"?r.turnById.get(s.id):void 0,i=s?.type==="subscription"?r.subscriptionById.get(s.id):void 0,f=s?.type==="action"?r.actionById.get(s.id):void 0,c=s?.type==="artifact"?r.artifactById.get(s.id):void 0,m=r.actorById.get(o.primaryActorId??o.ownerId)??o.actors[0];if(!a){let h=d??m;return h?.kind==="agent"?t(Kt,{actor:h,index:r,...e},h.id):null}return l?t(Us,{index:r,input:l,...e},l.id):n?t(Vs,{index:r,turn:n,...e},n.id):i?t(zs,{index:r,subscription:i,...e},i.id):f?t(Gs,{action:f,index:r,...e},f.id):c?t(Zs,{artifact:c,index:r,...e},c.id):d?t(Kt,{actor:d,index:r,...e},d.id):m?t(Kt,{actor:m,index:r,...e},m.id):t(Xe,{children:t(Ke,{children:t($e,{children:"Keine Actors"})})})}function eo({canGoBack:e,onBack:a}){return e?t(z,{"aria-label":"Zur\xFCck",className:"rounded-full",onClick:a,size:"icon",variant:"outline",children:t(Ee,{})}):null}function Fe({status:e}){return t(se,{className:`${Yt} ${Ps[e]??""}`,children:Rs[e]??e})}var Fs={chat:"M21 11a8 8 0 0 1-8 8H7l-5 3V11a8 8 0 0 1 8-8h3a8 8 0 0 1 8 8ZM7 9h9M7 13h6",info:"M12 11v6M12 7h.01M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0",prompt:"M6 3h12v18H6zM9 7h6M9 11h6M9 15h4",source:"m8 5-6 7 6 7m8-14 6 7-6 7m-3-15-2 16",settings:"M4 6h16M4 12h16M4 18h16M8 3v6M16 9v6M10 15v6",inputs:"M12 3v12m-4-4 4 4 4-4M4 14v7h16v-7",turns:"M20 7v5h-5M4 17v-5h5M6 7a7 7 0 0 1 12-2l2 3M4 16l2 3a7 7 0 0 0 12-2",subscriptions:"M12 3v6M4 15v-3h16v3M12 12v3M2 15h4v6H2zM10 15h4v6h-4zM18 15h4v6h-4z",actions:"m13 2-9 12h7l-1 8 10-13h-7z",artifacts:"M3 6h7l2 3h9v12H3zM3 6V3h7l2 3h7v3",capabilities:"m12 2 9 4v6c0 5-9 10-9 10S3 17 3 12V6zM8 12l3 3 5-6"};function le({kind:e}){return t("svg",{"aria-hidden":"true",fill:"none",height:"15",width:"15",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:Fs[e]})})}function Ns({sections:e,children:a}){let o=pe(),[r,s]=w(null),d=e.find(l=>l.id===r);return e.length===0?t("div",{className:"flex min-h-0 flex-1 flex-col",children:a}):u(At,{className:"contents",onValueChange:l=>s(l==="chat"?null:String(l)),value:d?.id??"chat",children:[u(vt,{"aria-label":"Actor-Ansichten",className:"flex h-auto w-auto max-w-full flex-shrink-0 flex-nowrap justify-start gap-1 overflow-x-auto rounded-none border-b border-border-soft px-workspace-inset py-1.5",variant:"line",children:[t(Wa,{"aria-label":"Chat anzeigen",className:ir,id:`${o}-chat-tab`,title:"Chat anzeigen",value:"chat",children:t(le,{kind:"chat"})}),e.map(l=>t(Wa,{"aria-label":l.count===void 0?l.label:`${l.label} (${l.count})`,className:ir,id:`${o}-${l.id}-tab`,title:l.count===void 0?l.label:`${l.label} (${l.count})`,value:l.id,children:l.icon},l.id))]}),d&&t(Ga,{className:"min-h-0 flex-1 overflow-y-auto border-b border-border-soft px-workspace-inset py-1.5 text-[0.76rem]",id:`${o}-details`,tabIndex:0,value:d.id,children:d.content}),t(Ga,{className:"flex min-h-0 flex-1 flex-col",id:`${o}-chat`,keepMounted:!0,value:"chat",children:a})]})}function Es({grants:e}){return e.length===0?t(se,{className:Yt,children:"Keine Capabilities"}):t("div",{className:"flex flex-wrap gap-1 py-1.5",children:e.map((a,o)=>{let r=a.scope.kind==="workspace"?a.scope.path:"Run",s=[a.delegable?"delegierbar":void 0,a.usable===!1?"nur weitergeben":void 0].filter(Boolean).join(", ");return u("span",{className:"rounded-full border border-border-soft px-2 py-0.5 text-[0.68rem] [&>small]:text-muted-foreground",title:r,children:[a.capability,s&&u("small",{children:[" ",s]})]},`${a.capability}-${o}`)})})}var qs="my-1.5 rounded-lg border border-[color-mix(in_srgb,var(--primary)_35%,var(--border))] bg-primary/5 px-2.5 py-2 [&>p]:my-1 [&>p]:text-[0.72rem] [&>p]:text-muted-foreground";function Os({action:e,runId:a,onError:o}){let r=W().can("runs.write"),[s,d]=w(""),[l,n]=w(!1),i=async(f,c)=>{if(!l){n(!0);try{await lr(a,e.id,f,c)}catch(m){o(m instanceof Error?m.message:String(m))}finally{n(!1)}}};return u("div",{className:qs,children:[t("strong",{children:e.title}),e.description&&t("p",{children:e.description}),e.owner&&u("p",{children:["wartet auf Eingabe - ",e.owner]}),e.input&&t(te,{className:"my-1.5 text-[0.76rem]",disabled:!r,onChange:f=>d(f.target.value),placeholder:e.input.placeholder??e.input.label,type:"text",value:s}),u("div",{className:"mt-1 flex justify-end gap-1.5",children:[t(z,{disabled:!r||l,onClick:()=>{i("dismissed",void 0)},size:"sm",variant:"outline",children:"Verwerfen"}),t(z,{disabled:!r||l||e.input?.required===!0&&s.trim()==="",onClick:()=>{i("approved",s.trim()||void 0)},size:"sm",children:"Quittieren"})]})]})}function Hs({handle:e,source:a}){return t("div",{className:"overflow-x-auto rounded-lg border border-border-soft bg-border-soft/22",children:t(Me,{content:a,language:"typescript",lineNumbers:!0,path:`${e}.ts`})})}function Kt({actor:e,index:a,...o}){let r=W(),s=da(),d=r.can("runs.write"),l=r.can("runs.inspect"),n=a.view,i=l&&s?.runId===n.id?s.source(n,e.id):void 0,[f,c]=w(),m=n.inputs.filter(S=>S.actorId===e.id).sort((S,j)=>S.sequence-j.sequence),h=n.turns.filter(S=>S.actorId===e.id).sort((S,j)=>S.startedAt.localeCompare(j.startedAt)),C=n.subscriptions.filter(S=>S.subscriberId===e.id),x=n.actions.filter(S=>S.askedBy===e.id),L=n.artifacts.filter(S=>S.createdBy===e.id),b=m.filter(Pa).length,P=e.id===n.primaryActorId,y=P?Ts(n):void 0,R=e.kind!=="human"&&e.lifecycle?.kind!=="stopped",N=e.kind==="human"?void 0:e.lifecycle?.kind??"idle",K=Object.entries(e.inputs??{}),V=e.execution?.driver,k=e.kind==="script"?"TypeScript":!V||V.kind==="manual"?"Manuell":[V.kind,V.config.provider].filter(Boolean).join(" - "),M=V&&V.kind!=="manual"?V.config:void 0,G=[{id:"info",label:"Info: Modell und Run-Details",icon:t(le,{kind:"info"}),content:u("div",{className:Ka,children:[N&&t(Fe,{status:N}),t("span",{children:P?"Prim\xE4rer Actor":cr[e.kind]}),t("span",{children:k}),M?.model&&t("span",{className:"max-w-[220px] truncate",title:M.model,children:M.model}),M?.thinking&&u("span",{children:["Denktiefe ",Xt(M.thinking)]}),u("span",{children:[b," offen"]}),u("span",{children:[h.length," Turns"]}),P&&y!==void 0&&t("span",{title:"Gesamtkosten des Runs \xFCber alle Turns",children:Ds(y)})]})},...e.prompt?[{id:"auftrag",label:"Auftrag",icon:t(le,{kind:"prompt"}),content:t("pre",{className:Ma,children:e.prompt})}]:[],...i?[{id:"source",label:"Quelltext",icon:t(le,{kind:"source"}),content:i}]:e.source?[{id:"source",label:"Quelltext",icon:t(le,{kind:"source"}),count:e.source.replace(/\n$/,"").split(`
2
- `).length,content:t(Hs,{handle:e.handle,source:e.source})}]:[],...K.length>0?[{id:"vorgaben",label:"Vorgaben",icon:t(le,{kind:"settings"}),count:K.length,content:t("dl",{className:Ve,children:K.map(([S,j])=>u("span",{children:[t("dt",{children:S}),t("dd",{children:j})]},S))})}]:[],{id:"eingaben",label:"Eingaben",icon:t(le,{kind:"inputs"}),count:m.length,content:t("div",{className:Te,children:m.map(S=>u("button",{className:De,onClick:()=>o.onNavigate({type:"input",id:S.id}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:S.content}),u("small",{children:[mr(a,S)," - ",oe(S.enqueuedAt)]})]}),t(Fe,{status:S.lifecycle.kind==="discarded"?"dismissed":S.lifecycle.kind==="claimed"?a.turnById.get(S.lifecycle.turnId)?.status??"completed":"pending"})]},S.id))})},{id:"turns",label:"Turns",icon:t(le,{kind:"turns"}),count:h.length,content:t("div",{className:Te,children:h.map(S=>u("button",{className:De,onClick:()=>o.onNavigate({type:"turn",id:S.id}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:de(S.id)}),t("small",{children:oe(S.startedAt)})]}),t(Fe,{status:S.status})]},S.id))})},{id:"subscriptions",label:"Subscriptions",icon:t(le,{kind:"subscriptions"}),count:C.length,content:t("div",{className:Te,children:C.map(S=>u("button",{className:De,onClick:()=>o.onNavigate({type:"subscription",id:S.id}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:S.eventTypes.join(", ")}),t("small",{children:de(S.id)})]}),t(Fe,{status:S.status})]},S.id))})},...x.length>0?[{id:"aktionen",label:"Aktionen",icon:t(le,{kind:"actions"}),count:x.length,content:t("div",{className:Te,children:x.map(S=>u("button",{className:De,onClick:()=>o.onNavigate({type:"action",id:S.id}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:S.title}),t("small",{children:oe(S.proposedAt)})]}),t(Fe,{status:S.status})]},S.id))})}]:[],...L.length>0?[{id:"artefakte",label:"Artefakte",icon:t(le,{kind:"artifacts"}),count:L.length,content:t("div",{className:Te,children:L.map(S=>t("button",{className:De,onClick:()=>o.onNavigate({type:"artifact",id:S.id}),type:"button",children:u("span",{className:Be,children:[t("strong",{children:S.title}),u("small",{children:[Ue(S.size)," - ",S.mediaType]})]})},S.id))})}]:[],{id:"capabilities",label:"Capabilities",icon:t(le,{kind:"capabilities"}),count:e.grants.length,content:t(Es,{grants:e.grants})},{id:"werkzeuge",label:"Werkzeuge",icon:t(va,{size:15}),...e.toolNames?{count:e.toolNames.length}:{},content:t("p",{className:be,children:e.toolNames===null?"Alle verf\xFCgbaren Werkzeuge":e.toolNames?.join(", ")||"Keine Werkzeuge"})}];return u("div",{className:Ye,children:[u("header",{className:Jt,children:[t(eo,{canGoBack:o.canGoBack,onBack:o.onBack}),u("div",{className:"flex min-w-0 flex-1 items-baseline gap-2 [&>span]:flex-1",children:[t("h2",{children:e.displayName}),u("span",{className:jt,children:["@",e.handle,l&&e.createdBy?` - erzeugt von ${ea(a,e.createdBy)}`:""]})]}),R&&d&&t(z,{className:"flex-shrink-0",onClick:()=>{dr(n.id,e.id,Ms).catch(S=>c(S.message))},size:"sm",title:`@${e.handle} samt beauftragten Kindern dauerhaft stoppen; die Chat-Eingabe unterbricht dagegen nur den laufenden Turn`,variant:"destructive",children:"Stop"}),l&&d&&e.lifecycle?.kind==="stopped"&&e.kind!=="human"&&t(z,{onClick:()=>{ur(n.id,e.id).catch(S=>c(S.message))},size:"sm",variant:"outline",children:"Neu starten"})]}),f&&t("p",{className:Qt,children:f}),u(Ns,{sections:l?G:[],children:[t(Ze,{actor:e,view:n,presentation:"inspector",display:o.chatDisplay,className:"min-h-0 flex-1",primaryMessages:o.primaryMessages,conversation:o.actorConversations?.[e.id],historyError:o.conversationError,onNavigate:o.onNavigate,running:P?o.primaryRunning:N==="running"}),t(Je,{actor:e,view:n,composerVisible:o.composerVisible,display:o.chatDisplay,running:P?o.primaryRunning:N==="running"})]})]})}function Za({eyebrow:e,title:a,subtitle:o,...r}){return u("header",{className:Jt,children:[t(eo,{canGoBack:r.canGoBack,onBack:r.onBack}),u("div",{className:"min-w-0 flex-1",children:[t("p",{className:"mb-0.5 text-[0.66rem] font-semibold tracking-[0.08em] uppercase text-muted-foreground",children:e}),t("h2",{children:a}),t("span",{className:jt,children:o})]})]})}function Us({index:e,input:a,...o}){let r=a.artifactIds.flatMap(s=>{let d=e.artifactById.get(s);return d?[d]:[]});return u("div",{className:Ye,children:[t(Za,{canGoBack:o.canGoBack,eyebrow:"ActorInput",onBack:o.onBack,subtitle:oe(a.enqueuedAt),title:de(a.id)}),u("div",{className:Da,children:[u("section",{className:ee,children:[t("h3",{children:"Inhalt"}),t("pre",{className:Ma,children:a.content})]}),u("section",{className:ee,children:[t("h3",{children:"Routing"}),u("dl",{className:Ve,children:[t("dt",{children:"Actor"}),t("dd",{children:t(ze,{id:a.actorId,index:e,onNavigate:o.onNavigate})}),t("dt",{children:"Eingereiht von"}),t("dd",{children:t(ze,{id:a.enqueuedBy,index:e,onNavigate:o.onNavigate})}),t("dt",{children:"Turn"}),t("dd",{children:a.lifecycle.kind==="claimed"?t(Ta,{label:de(a.lifecycle.turnId),onNavigate:o.onNavigate,selection:{type:"turn",id:a.lifecycle.turnId}}):a.lifecycle.kind==="discarded"?"verworfen":"wartet"}),t("dt",{children:"Subscription"}),t("dd",{children:a.subscriptionId?t(Ta,{label:de(a.subscriptionId),onNavigate:o.onNavigate,selection:{type:"subscription",id:a.subscriptionId}}):"keine"}),a.lifecycle.kind==="discarded"&&u(X,{children:[t("dt",{children:"Verworfen"}),t("dd",{children:oe(a.lifecycle.at)}),t("dt",{children:"Grund"}),t("dd",{children:a.lifecycle.reason})]})]})]}),a.sourceEventIds.length>0&&u("section",{className:ee,children:[t("h3",{children:"Quell-Events"}),t("p",{className:be,children:a.sourceEventIds.join(", ")})]}),r.length>0&&t(_s,{artifacts:r,onNavigate:o.onNavigate})]})]})}function Vs({index:e,turn:a,...o}){let r=pr(a);return u("div",{className:Ye,children:[t(Za,{canGoBack:o.canGoBack,eyebrow:"Turn",onBack:o.onBack,subtitle:oe(a.startedAt),title:de(a.id)}),t("div",{className:Ka,children:t(Fe,{status:a.status})}),u("div",{className:Da,children:[u("section",{className:ee,children:[t("h3",{children:"Details"}),u("dl",{className:Ve,children:[t("dt",{children:"Actor"}),t("dd",{children:t(ze,{id:a.actorId,index:e,onNavigate:o.onNavigate})}),t("dt",{children:"Eingabe"}),t("dd",{children:t(Ta,{label:de(a.inputId),onNavigate:o.onNavigate,selection:{type:"input",id:a.inputId}})}),t("dt",{children:"Beendet"}),t("dd",{children:a.finishedAt?oe(a.finishedAt):"l\xE4uft"}),a.reason&&u(X,{children:[t("dt",{children:"Grund"}),t("dd",{children:a.reason})]})]})]}),r&&u("section",{className:ee,children:[t("h3",{children:"Nutzung"}),u("dl",{className:Ve,children:[t("dt",{children:"Input-Tokens"}),t("dd",{children:r.inputTokens??0}),t("dt",{children:"Output-Tokens"}),t("dd",{children:r.outputTokens??0}),t("dt",{children:"Cache gelesen"}),t("dd",{children:r.cacheReadTokens??0}),t("dt",{children:"Cache geschrieben"}),t("dd",{children:r.cacheWriteTokens??0}),t("dt",{children:"Kosten"}),u("dd",{children:[(r.costUsd??0).toFixed(6)," USD"]})]})]})]})]})}function zs({index:e,subscription:a,...o}){return u("div",{className:Ye,children:[t(Za,{canGoBack:o.canGoBack,eyebrow:"Subscription",onBack:o.onBack,subtitle:oe(a.createdAt),title:de(a.id)}),t("div",{className:Ka,children:t(Fe,{status:a.status})}),u("div",{className:Da,children:[u("section",{className:ee,children:[t("h3",{children:"Filter"}),u("dl",{className:Ve,children:[t("dt",{children:"Subscriber"}),t("dd",{children:t(ze,{id:a.subscriberId,index:e,onNavigate:o.onNavigate})}),t("dt",{children:"Quell-Actors"}),t("dd",{children:a.sourceActorIds?.map(r=>ea(e,r)).join(", ")??"alle"}),t("dt",{children:"Actor-Arten"}),t("dd",{children:a.sourceActorKinds?.join(", ")??"alle"}),t("dt",{children:"Event-Typen"}),t("dd",{children:a.eventTypes.join(", ")}),t("dt",{children:"Eigene Events"}),t("dd",{children:a.includeSelf?"ja":"nein"}),t("dt",{children:"Angelegt von"}),t("dd",{children:t(ze,{id:a.createdBy,index:e,onNavigate:o.onNavigate})}),a.status!=="active"&&u(X,{children:[t("dt",{children:"Grund"}),t("dd",{children:a.reason})]}),a.status==="failed"&&u(X,{children:[t("dt",{children:"Fehler-Event"}),t("dd",{children:a.sourceEventId})]})]})]}),a.sourceActorIds&&u("section",{className:ee,children:[t("h3",{children:"Quell-Actors"}),t(Ws,{actorIds:a.sourceActorIds,index:e,onNavigate:o.onNavigate})]})]})]})}function Gs({action:e,index:a,...o}){let[r,s]=w();return u("div",{className:Ye,children:[t(Za,{canGoBack:o.canGoBack,eyebrow:"Aktion",onBack:o.onBack,subtitle:ea(a,e.askedBy),title:e.title}),t("div",{className:Ka,children:t(Fe,{status:e.status})}),u("div",{className:Da,children:[e.status==="pending"&&t(Os,{action:e,onError:s,runId:a.view.id}),e.description&&u("section",{className:ee,children:[t("h3",{children:"Beschreibung"}),t("p",{children:e.description})]}),u("section",{className:ee,children:[t("h3",{children:"Details"}),u("dl",{className:Ve,children:[t("dt",{children:"Gefragt von"}),t("dd",{children:t(ze,{id:e.askedBy,index:a,onNavigate:o.onNavigate})}),t("dt",{children:"Vorgeschlagen"}),t("dd",{children:oe(e.proposedAt)}),e.resolvedAt&&u(X,{children:[t("dt",{children:"Aufgel\xF6st"}),t("dd",{children:oe(e.resolvedAt)})]}),e.owner&&u(X,{children:[t("dt",{children:"Eigent\xFCmer"}),t("dd",{children:e.owner})]}),e.result!==null&&e.result!==void 0&&u(X,{children:[t("dt",{children:"Ergebnis"}),t("dd",{children:typeof e.result=="string"?e.result:JSON.stringify(e.result)})]})]})]}),Object.keys(e.parameters).length>0&&u("section",{className:ee,children:[t("h3",{children:"Parameter"}),t("pre",{className:Ma,children:JSON.stringify(e.parameters,null,2)})]}),e.payload!==null&&e.payload!==void 0&&u("section",{className:ee,children:[t("h3",{children:"Nutzdaten"}),t("pre",{className:Ma,children:JSON.stringify(e.payload,null,2)})]}),r&&t("p",{className:Qt,children:r})]})]})}function Ta({label:e,onNavigate:a,selection:o}){return t("button",{className:fr,onClick:()=>a(o),type:"button",children:e})}function ze({id:e,index:a,onNavigate:o}){return t(Ta,{label:ea(a,e),onNavigate:o,selection:{type:"actor",id:e}})}function Ws({actorIds:e,index:a,onNavigate:o}){return t("div",{className:Te,children:e.map(r=>{let s=a.actorById.get(r);return u("button",{className:De,onClick:()=>o({type:"actor",id:r}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:s?.displayName??de(r)}),t("small",{children:ea(a,r)})]}),s&&t(se,{className:Yt,children:cr[s.kind]})]},r)})})}function _s({artifacts:e,onNavigate:a}){return u("section",{className:ee,children:[t("h3",{children:"Artefakte"}),t("div",{className:Te,children:e.map(o=>t("button",{className:De,onClick:()=>a({type:"artifact",id:o.id}),type:"button",children:u("span",{className:Be,children:[t("strong",{children:o.title}),u("small",{children:[Ue(o.size)," - ",o.mediaType]})]})},o.id))})]})}var Xs=e=>{let a=e.toLowerCase();return a.startsWith("text/")||a.includes("json")||a.includes("xml")||a.includes("yaml")};function Zt(e,a){let o=U(new Map),[r,s]=w(0),d=a?.id,l=()=>{d&&o.current.delete(d),s(n=>n+1)};return O(()=>{if(!(!a||o.current.has(a.id))){if(a.mediaType.toLowerCase().startsWith("image/")){o.current.set(a.id,{kind:"image"}),s(n=>n+1);return}if(!Xs(a.mediaType)){o.current.set(a.id,{kind:"download"}),s(n=>n+1);return}o.current.set(a.id,{kind:"loading"}),s(n=>n+1),(async()=>{try{let n=await fetch(Ra(e,a.id),{headers:{Accept:a.mediaType}});if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);let i=await n.text();if(a.mediaType.toLowerCase().includes("json"))try{i=JSON.stringify(JSON.parse(i),null,2)}catch{}o.current.set(a.id,{kind:"text",text:i})}catch(n){o.current.set(a.id,{kind:"error",message:n instanceof Error?n.message:String(n)})}s(n=>n+1)})()}},[a,e,r]),{content:a?o.current.get(a.id):void 0,retry:l}}var $t=5e3,Ks=(e,a)=>{let o=Array.from({length:e.length+1},()=>new Uint32Array(a.length+1));for(let l=e.length-1;l>=0;l-=1)for(let n=a.length-1;n>=0;n-=1)o[l][n]=e[l]===a[n]?o[l+1][n+1]+1:Math.max(o[l+1][n],o[l][n+1]);let r=[],s=0,d=0;for(;s<e.length&&d<a.length;)e[s]===a[d]?(r.push({kind:"same",text:e[s]}),s+=1,d+=1):o[s+1][d]>=o[s][d+1]?(r.push({kind:"removed",text:e[s]}),s+=1):(r.push({kind:"added",text:a[d]}),d+=1);for(;s<e.length;)r.push({kind:"removed",text:e[s++]});for(;d<a.length;)r.push({kind:"added",text:a[d++]});return r};function $s({artifact:e,index:a}){let o=e.previousVersionId?a.artifactById.get(e.previousVersionId):void 0,r=Zt(a.view.id,o).content,s=Zt(a.view.id,e).content,d=r?.kind==="text"?r.text:void 0,l=s?.kind==="text"?s.text:void 0,n=D(()=>{if(d===void 0||l===void 0)return;let f=d.split(`
1
+ import{a as gt,b as Ua}from"/plugins/ragents.orchestration/web/chunks/chunk-OSKPH6SZ.js";import{b as da}from"/plugins/ragents.orchestration/web/chunks/chunk-ODMMQGX2.js";import{a as p,b as Lo,c as Ge,d as Ha,e as Io,f as q,g as Co,h as O,i as pe,j as We,k as B,l as U,m as w}from"/plugins/ragents.orchestration/web/chunks/chunk-OQYCNYXN.js";import{a as Ae,e as ua,f as So,g as ft,h as ct,i as pt,j as mt}from"/plugins/ragents.orchestration/web/chunks/chunk-XGPPQCZR.js";var W=p("@ragents/web/AccessContext","useAccess");var na=p("react-dom","createPortal");var xt=p("@ragents/engine/src/http/contracts","handleKey");var me=p("@ragents/engine/src/http/contracts","runContracts");var wo="ragents.orchestration",ys=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),bo=e=>{let a=e.trim();if(a.startsWith("@")){let s=xt(a);if(!s||/\s/.test(s))throw new Error(`Entit\xE4t ${JSON.stringify(e)}: nach dem @ fehlt ein Handle`);return{kind:"actor",handle:s}}let o=/^app:(.+)$/s.exec(a);if(!o)throw new Error(`Entit\xE4t ${JSON.stringify(e)}: erwartet @handle oder app:<id>`);let r=o[1].trim();if(!r)throw new Error(`Entit\xE4t ${JSON.stringify(e)}: die ID nach dem Doppelpunkt ist leer`);return{kind:"app",id:r}},yo=e=>e.kind==="actor"?`@${e.handle}`:`app:${e.id}`,ks=["nodes","shapes","lines","mode"],ko=e=>{if(!ys(e))throw new Error("Die Anordnung muss ein Objekt mit root sein");let a=ks.filter(o=>o in e);if(a.length>0)throw new Error(`Die Programmanordnung stammt aus der entfernten freien Fl\xE4che (${a.join(", ")}); canvas_layout_replace mit root setzt sie als Kachelaufteilung neu`);if(!("root"in e))throw new Error("root fehlt; erwartet wird eine Kachel, eine Teilung oder null");return{root:e.root===null?null:_e(e.root)}};var Ao=16,vo=64,_e=e=>{let a=new Set,o=(r,s,d)=>{if(d>Ao)throw new Error(`${s}: h\xF6chstens ${Ao} verschachtelte Teilungen sind erlaubt`);if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`${s} muss eine Kachel oder Teilung sein`);let l=r;if(Object.hasOwn(l,"entity")){if(Object.keys(l).some(f=>f!=="entity"&&f!=="chatInput"))throw new Error(`${s}: eine Kachel tr\xE4gt nur entity und chatInput; eine Teilung direction, weights und children`);if(typeof l.entity!="string")throw new Error(`${s}.entity muss @handle oder app:<name>/<view> sein`);let n=bo(l.entity),i=yo(n);if(l.chatInput!==void 0&&(n.kind!=="actor"||typeof l.chatInput!="boolean"))throw new Error(`${s}.chatInput ist nur f\xFCr Actors als Wahrheitswert erlaubt`);if(a.has(i))throw new Error(`${s}: ${i} ist mehr als einmal als Kachel platziert`);if(a.add(i),a.size>vo)throw new Error(`H\xF6chstens ${vo} Kacheln sind erlaubt`);return l.chatInput===void 0?{entity:i}:{entity:i,chatInput:l.chatInput}}if(Object.keys(l).some(n=>!["direction","weights","children"].includes(n)))throw new Error(`${s}: eine Teilung tr\xE4gt nur direction, weights und children`);if(l.direction!=="horizontal"&&l.direction!=="vertical")throw new Error(`${s}.direction muss horizontal oder vertical sein`);if(!Array.isArray(l.weights)||l.weights.length!==2||l.weights.some(n=>typeof n!="number"||!Number.isFinite(n)||n<=0))throw new Error(`${s}.weights muss genau zwei endliche positive Zahlen enthalten`);if(!Array.isArray(l.children)||l.children.length!==2)throw new Error(`${s}.children muss genau zwei Kacheln oder Teilungen enthalten`);return{direction:l.direction,weights:[l.weights[0],l.weights[1]],children:[o(l.children[0],`${s}.children[0]`,d+1),o(l.children[1],`${s}.children[1]`,d+1)]}};return o(e,"root",0)},Va=(e,a)=>e?"entity"in e?e.entity!==a||e.chatInput!==!1:Va(e.children[0],a)&&Va(e.children[1],a):!0,za=e=>e?"entity"in e?[e.entity]:e.children.flatMap(za):[];var ht=p("@ragents/web/ui","Alert");var Lt=p("@ragents/web/ui","AlertDescription");var se=p("@ragents/web/ui","Badge");var z=p("@ragents/web/ui","Button");var Xe=p("@ragents/web/ui","Empty");var ia=p("@ragents/web/ui","EmptyDescription");var Ke=p("@ragents/web/ui","EmptyHeader");var $e=p("@ragents/web/ui","EmptyTitle");var te=p("@ragents/web/ui","Input");var fa=p("@ragents/web/ui","Popover");var ca=p("@ragents/web/ui","PopoverContent");var It=p("@ragents/web/ui","SectionLabel");var Ct=p("@ragents/web/ui","Select");var St=p("@ragents/web/ui","SelectContent");var wt=p("@ragents/web/ui","SelectItem");var bt=p("@ragents/web/ui","SelectTrigger");var yt=p("@ragents/web/ui","SelectValue");var ve=p("@ragents/web/ui","Spinner");var pa=p("@ragents/web/ui","StartupNotice");var kt=p("@ragents/web/ui","StopGlyph");var At=p("@ragents/web/ui","Tabs");var Ga=p("@ragents/web/ui","TabsContent");var vt=p("@ragents/web/ui","TabsList");var Wa=p("@ragents/web/ui","TabsTrigger");var Y=p("@ragents/web/ui","cn");var Pt=p("quassel","ChatInputToolbar");var Rt=p("quassel","ChatMessages");var ma=p("quassel","ChatPanel");var Mt=p("@ragents/web/PluginRegistry","SurfaceControllerProvider");var Tt=p("@ragents/web/PluginRegistry","useActionRenderer");var ga=p("@ragents/web/PluginRegistry","useSurfaceController");var Dt=p("@ragents/web/PluginRegistry","useToolRenderer");var Bt=p("@ragents/web/chat-view-settings","ChatViewSwitches");var xa=p("@ragents/web/chat-view-settings","useChatViewSettings");var Ft=p("@ragents/web/actor-conversation","actorChatMessages");var Nt=p("@ragents/web/actor-conversation","actorInputLabel");var X=p("react/jsx-runtime","Fragment");var t=p("react/jsx-runtime","jsx");var u=p("react/jsx-runtime","jsxs");var As=[];function Ze({actor:e,view:a,presentation:o,display:r=o,primaryMessages:s=As,conversation:d,historyError:l,running:n=!1,className:i,onNavigate:f,scrollerRef:c}){let m=W().can("runs.inspect"),h=xa(a.id,e.id,"agents",r),C=Dt(),x=Tt(),L=h.detailMode,b=m||L==="off"?L:"current",P=B(()=>Ft(a,e,s,d),[a,e,s,d]),y=q(D=>{let R=/^ablauf:(actor|input|turn|subscription|action|artifact)\/(.+)$/.exec(D);return R?(m&&f({type:R[1],id:R[2]}),!0):!1},[m,f]);return u(X,{children:[l&&t("p",{className:"my-1.5 text-[0.72rem] text-destructive",role:"alert",children:l}),t(Rt,{className:i,detailMode:b,emptyState:t(Xe,{children:u(Ke,{children:[t($e,{children:e.kind==="script"?"Noch kein Verlauf":"Noch kein Gespr\xE4ch"}),t(ia,{children:e.kind==="script"?"Hier erscheinen Programmeingaben und ihre Verarbeitung.":"Schreibe eine Nachricht, um das Gespr\xE4ch zu beginnen."})]})}),messages:P,renderAction:x,renderTool:C,owner:e.id,onLinkClick:y,running:n,showTimestamps:h.showTimestamps,stepsExpandable:m&&h.stepsExpandable,scrollerRef:c})]})}var Et=p("@ragents/web/api","interruptActorTurn");var qt=p("@ragents/web/api","sendActorMessage");var Ot=p("@ragents/web/chat/StoppedActorNotice","StoppedActorNotice");var Ht=p("@ragents/web/chat/useAttachmentCapabilities","useAttachmentCapabilities");var Ut=p("@ragents/web/chat/chat-target","programChatNotice");var Vt=p("@ragents/web/chat/chat-target","runIsWorking");var Po="flex flex-shrink-0 items-center gap-2 border-t border-border-soft px-workspace-inset pt-2 pb-2.5",zt="mt-1.5 text-[0.7rem] text-muted-foreground";function Je({actor:e,view:a,composerVisible:o=!0,presentation:r="inspector",display:s=r,running:d=!1,toolbarLeft:l,toolbarRight:n}){let i=W().can("runs.write"),[f,c]=w(),m=xa(a.id,e.id,"agents",s),h=Ht(a.id,e.id,JSON.stringify(e.execution?.driver.config)),C=i?void 0:"Du hast Lesezugriff auf diesen Run.",x=t(Bt,{collapsible:r==="surface",settings:m});return!o||e.kind==="human"?u("div",{className:Po,children:[l,x]}):e.kind==="script"?u("div",{className:Po,children:[t("p",{className:zt,children:Ut}),l,x]}):e.lifecycle?.kind==="stopped"?t("div",{className:r==="inspector"?"flex-shrink-0 px-5 pt-2.5 pb-3.5":void 0,children:t(Ot,{actor:e,runId:a.id,toolbar:u(X,{children:[l,x]})})}):u("div",{className:r==="inspector"?"flex-shrink-0 px-5 pt-2.5 pb-3.5":void 0,children:[t(Pt,{...h,disabled:C!==void 0,layout:r==="surface"?"inline":"card",maxRows:4,onSend:(L,b)=>qt(a.id,e.id,L,b),onStop:i&&e.lifecycle?.kind==="running"?()=>{c(void 0),Et(a.id,e.id).catch(L=>c(L instanceof Error?L.message:String(L)))}:void 0,rows:1,running:d,texts:{placeholder:C??`Nachricht an @${e.handle} ...`},toolbarLeft:u(X,{children:[l,x,r==="inspector"&&u("span",{className:"truncate text-[0.7rem] text-muted-foreground",children:["an @",e.handle]})]}),toolbarRight:n}),f&&t("p",{className:zt,role:"alert",children:f}),C&&r==="inspector"&&t("p",{className:zt,children:C})]})}var Ro=Io(function({actor:a,view:o,primaryMessages:r,conversation:s,historyError:d,chatInput:l=!0,running:n=!1,onNavigate:i}){let f=q(c=>{c&&(c.tabIndex=0,c.setAttribute("role","region"),c.setAttribute("aria-label",`Chatverlauf von @${a.handle}`))},[a.handle]);return t("div",{className:"flex min-h-[106px] w-full min-w-0 flex-1 flex-col overflow-hidden rounded-b-[16px] text-left","data-surface-scroll":"true",children:t(ma,{className:"flex-1",composer:t(Je,{actor:a,view:o,composerVisible:l,presentation:"surface",running:n}),children:t(Ze,{actor:a,view:o,presentation:"surface",primaryMessages:r,conversation:s,historyError:d,running:n,onNavigate:i,scrollerRef:f})})})});var Gt="ragents.orchestration",_a="flex h-full min-w-statusbar items-center justify-center self-stretch whitespace-nowrap px-2.5 text-[0.7rem] text-foreground hover:bg-primary/12 aria-expanded:bg-primary/12 focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",Xa="grid gap-2.5 border-t border-border-soft px-3 pt-2.5 pb-2.5 empty:hidden";function Mo({actor:e,view:a,cardSections:o,chatInput:r,session:s,navigation:d,onSelect:l}){return u("div",{className:"flex flex-col overflow-hidden has-[>[data-slot=card-sections]:not(:empty)]:min-h-[260px] has-[[data-chat=actions]:not(:empty)]:min-h-[260px]",children:[t(Ro,{actor:e,view:a,chatInput:r,running:e.lifecycle?.kind==="running",conversation:s.actorConversations?.[e.id],historyError:s.conversationError,onNavigate:l,primaryMessages:e.id===a.primaryActorId?s.messages:void 0}),t("div",{className:`${Xa} max-h-[45%] flex-[0_1_auto] overflow-auto overscroll-contain`,"data-slot":"card-sections",children:o.map(({id:n,Section:i})=>t(i,{actor:e,navigation:d,session:s},n))})]})}var To=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function Do(e,a,o=[]){if(a==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:To(e),size:24,node:a,...o.length>0?{aliases:o}:{}}}var Bo=e=>{let a="",o=!1;for(let r of e){if(r==="-"||r==="_"||r<=" "){o=a.length>0;continue}a.length===0?a+=r.toLowerCase():a+=o?r.toUpperCase():r,o=!1}return a};var Fo=e=>{let a=Bo(e);return a.charAt(0).toUpperCase()+a.slice(1)};var ha=(...e)=>e.filter((a,o,r)=>!!a&&a.trim()!==""&&r.indexOf(a)===o).join(" ").trim();var Pe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function Wt(e){return e!=null}function No(e,a={}){let o=a.attributeNames??{},r=h=>o[h]??h,s=e.size??e.width??Pe.width,d=e.size??e.height??Pe.height,l=e.aliases?.filter(h=>typeof h=="string"&&h.trim()!=="").map(h=>`lucide-${h}`)??[],n=[...e.name?[`lucide-${e.name}`]:[],...l],i=a.className?.split(" ").filter(Boolean)??[],f=a.includeDefaultClasses===!1?ha(...i):ha("lucide",...n,...i),c=a.absoluteStrokeWidth?Number(a.strokeWidth??Pe["stroke-width"])*Number(e.size??e.width??Pe.width)/Number(a.size??a.width??Pe.width):a.strokeWidth??Pe["stroke-width"];return["svg",{...Object.entries(Pe).reduce((h,[C,x])=>(h[r(C)]=x,h),{}),..."color"in a&&a.color&&{[r("stroke")]:a.color},..."size"in a&&Wt(a.size)&&{[r("width")]:a.size,[r("height")]:a.size},..."width"in a&&Wt(a.width)&&{[r("width")]:a.width},..."height"in a&&Wt(a.height)&&{[r("height")]:a.height},[r("stroke-width")]:c,...f&&{[r("class")]:f},[r("viewBox")]:`0 0 ${s} ${d}`,...a.hasA11yProp===!1?{[r("aria-hidden")]:"true"}:{},..."attributes"in a&&a.attributes},e.node.map(h=>{let[C,x,L]=h,b=a.nonScalingStroke?{[r("vector-effect")]:"non-scaling-stroke",...x}:x;return L?[C,b,L]:[C,b]})]}function Eo(e,a={}){return No(e,{...a,attributeNames:{...a.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var qo=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var vs=Lo({});var Oo=()=>Co(vs);var Ho=Ha(({color:e,size:a,width:o,height:r,strokeWidth:s,absoluteStrokeWidth:d,nonScalingStroke:l,className:n="",children:i,iconNode:f=[],icon:c={node:f,aliases:[],size:24},...m},h)=>{let{size:C=24,strokeWidth:x=2,absoluteStrokeWidth:L=!1,nonScalingStroke:b=!1,color:P="currentColor",className:y=""}=Oo()??{},D=!!i||qo(m),[R,K,V=[]]=Eo(c,{color:e??P,width:o??a??C,height:r??a??C,strokeWidth:s??x,absoluteStrokeWidth:d??L,nonScalingStroke:l??b,className:ha(y,n),hasA11yProp:D,attributes:m});return Ge(R,{ref:h,...K},[...V.map(([k,M])=>Ge(k,M)),...Array.isArray(i)?i:[i]])});function E(e,a=[],o=[]){let r=typeof e=="string"?Do(e,a,o):e,s=Ha(({className:d,...l},n)=>Ge(Ho,{ref:n,icon:r,className:d,...l}));return r.name&&(s.displayName=Fo(r.name)),s}var Uo={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};Uo.node;var La=E(Uo);var Vo={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};Vo.node;var Ee=E(Vo);var zo={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};zo.node;var Ia=E(zo);var Go={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};Go.node;var je=E(Go);var Wo={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Wo.node;var Ca=E(Wo);var _o={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};_o.node;var Qe=E(_o);var Xo={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Xo.node;var Sa=E(Xo);var Ko={name:"code-xml",size:24,node:[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],aliases:["code-2"]};Ko.node;var Re=E(Ko);var $o={name:"code",size:24,node:[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]};$o.node;var qe=E($o);var Zo={name:"grip-vertical",size:24,node:[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]};Zo.node;var wa=E(Zo);var Jo={name:"layout-grid",size:24,node:[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]};Jo.node;var Oe=E(Jo);var jo={name:"maximize-2",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]};jo.node;var ba=E(jo);var Qo={name:"message-square",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]};Qo.node;var ya=E(Qo);var Yo={name:"panel-bottom",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]};Yo.node;var ka=E(Yo);var er={name:"panel-right",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]};er.node;var Aa=E(er);var ar={name:"sparkles",size:24,node:[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],aliases:["stars"]};ar.node;var ge=E(ar);var tr={name:"users",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]};tr.node;var Se=E(tr);var or={name:"wrench",size:24,node:[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]};or.node;var va=E(or);var rr={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};rr.node;var xe=E(rr);var He=p("@ragents/web/run-view","actorTone");var we=p("@ragents/web/run-view","chatPrimaryId");var Pa=p("@ragents/web/run-view","isPendingRunActorInput");var _t=p("@ragents/web/run-view","runActorFrom");var Ra=p("@ragents/web/run-view","runArtifactContentUrl");var J=p("@ragents/web/run-view","runViewFrom");var he=p("@ragents/web/rpc","rpc");var sr=async(e,a,o,r)=>{await he.call(me.resolveAction,{runId:e,commandId:crypto.randomUUID(),actionId:a,decision:o,result:r})},lr=async(e,a,o)=>{await he.call(me.stopActor,{runId:e,commandId:crypto.randomUUID(),actorId:a,reason:o})},dr=async(e,a)=>{await he.call(me.restartActor,{runId:e,commandId:crypto.randomUUID(),actorId:a})},ur=async(e,a)=>{await he.call(me.stopAll,{runId:e,commandId:crypto.randomUUID(),reason:a})};var Ue=p("@ragents/web/lib/format","formatBytes");var Me=p("@ragents/web/SourceCode","SourceCode");var Xt=p("@ragents/web/lib/labels","thinkingLabel");var oe=e=>{let a=new Date(e);return Number.isNaN(a.getTime())?e:a.toLocaleString("de-DE")};var Ye="flex h-full min-h-0 flex-col bg-card",Jt="flex flex-shrink-0 items-start gap-2.5 border-b border-border-soft px-workspace-inset pt-3 pb-2 [&_h2]:text-[0.95rem] [&_h2]:leading-[1.3]",jt="block truncate text-[0.72rem] text-muted-foreground",Ka="flex flex-shrink-0 flex-wrap items-center gap-x-2.5 gap-y-0.5 border-b border-border-soft px-workspace-inset py-1.5 text-[0.72rem] text-muted-foreground",Da="min-h-0 flex-1 overflow-y-auto px-workspace-inset py-2.5",ee="mb-4 [&>h3]:mb-1.5 [&>h3]:text-[0.72rem] [&>h3]:font-semibold [&>h3]:tracking-[0.05em] [&>h3]:uppercase [&>h3]:text-muted-foreground",Te="flex flex-col gap-1 py-1.5",De="flex cursor-pointer items-center gap-2 rounded-lg border border-border-soft px-2 py-1.5 text-left hover:border-[color-mix(in_srgb,var(--primary)_45%,var(--border))] hover:bg-primary/6 [&_strong]:truncate [&_strong]:text-[0.76rem] [&_small]:text-[0.66rem] [&_small]:text-muted-foreground",Be="flex min-w-0 flex-1 flex-col",be="text-[0.74rem] text-muted-foreground",Qt="my-1.5 text-[0.72rem] text-destructive",Ve="my-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[0.74rem] [&_dt]:text-muted-foreground [&_dd]:[overflow-wrap:anywhere]",Ma="my-1.5 rounded-lg bg-foreground/4 p-2 text-[0.72rem] whitespace-pre-wrap [overflow-wrap:anywhere]",ir="cursor-pointer text-[0.74rem] text-primary underline",Yt="h-auto rounded-full bg-foreground/8 px-2 py-0.5 text-[0.66rem] font-semibold text-muted-foreground",Ps={running:"bg-accent text-primary",active:"bg-success-soft text-success",approved:"bg-success-soft text-success",completed:"bg-success-soft text-success",idle:"bg-success-soft text-success",pending:"bg-success-soft text-success",waiting:"bg-success-soft text-success",queued:"bg-success-soft text-success",failed:"bg-destructive-soft text-destructive",interrupted:"bg-destructive-soft text-destructive"},nr="grid size-[30px] flex-[0_0_30px] place-items-center p-0",Rs={active:"Aktiv",approved:"Best\xE4tigt",completed:"Abgeschlossen",dismissed:"Verworfen",failed:"Fehlgeschlagen",idle:"Bereit",interrupted:"Unterbrochen",pending:"Offen",removed:"Entfernt",running:"L\xE4uft",stopped:"Gestoppt"},fr={human:"Person",agent:"Agent",script:"Logik-Actor"},Ms="Vom Bediener gestoppt",de=e=>e.length>12?`${e.slice(0,12)}...`:e,cr=e=>e.usage,Ts=e=>{let a=e.turns.map(o=>cr(o)?.costUsd).filter(o=>typeof o=="number"&&Number.isFinite(o));return a.length>0?a.reduce((o,r)=>o+r,0):void 0},Ds=e=>`${e.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:e>0&&e<.005?4:2})} USD`,Bs=e=>({view:e,actorById:new Map(e.actors.map(a=>[a.id,a])),inputById:new Map(e.inputs.map(a=>[a.id,a])),turnById:new Map(e.turns.map(a=>[a.id,a])),subscriptionById:new Map(e.subscriptions.map(a=>[a.id,a])),actionById:new Map(e.actions.map(a=>[a.id,a])),artifactById:new Map(e.artifacts.map(a=>[a.id,a]))}),ea=(e,a)=>`@${e.actorById.get(a)?.handle??de(a)}`,pr=(e,a)=>Nt(e.view,a);function $a(e){let a=W().can("runs.inspect"),o=e.view,r=B(()=>o?Bs(o):void 0,[o]);if(!o||!r)return t(Xe,{children:u(Ke,{children:[t($e,{children:"Noch kein Ablauf"}),t(ia,{children:"Sobald Actors gestartet werden, erscheint hier die Detailansicht."})]})});let s=e.selection,d=s?.type==="actor"?r.actorById.get(s.id):void 0,l=s?.type==="input"?r.inputById.get(s.id):void 0,n=s?.type==="turn"?r.turnById.get(s.id):void 0,i=s?.type==="subscription"?r.subscriptionById.get(s.id):void 0,f=s?.type==="action"?r.actionById.get(s.id):void 0,c=s?.type==="artifact"?r.artifactById.get(s.id):void 0,m=r.actorById.get(o.primaryActorId??o.ownerId)??o.actors[0];if(!a){let h=d??m;return h?.kind==="agent"?t(Kt,{actor:h,index:r,...e},h.id):null}return l?t(Us,{index:r,input:l,...e},l.id):n?t(Vs,{index:r,turn:n,...e},n.id):i?t(zs,{index:r,subscription:i,...e},i.id):f?t(Gs,{action:f,index:r,...e},f.id):c?t(Zs,{artifact:c,index:r,...e},c.id):d?t(Kt,{actor:d,index:r,...e},d.id):m?t(Kt,{actor:m,index:r,...e},m.id):t(Xe,{children:t(Ke,{children:t($e,{children:"Keine Actors"})})})}function eo({canGoBack:e,onBack:a}){return e?t(z,{"aria-label":"Zur\xFCck",className:"rounded-full",onClick:a,size:"icon",variant:"outline",children:t(Ee,{})}):null}function Fe({status:e}){return t(se,{className:`${Yt} ${Ps[e]??""}`,children:Rs[e]??e})}var Fs={chat:"M21 11a8 8 0 0 1-8 8H7l-5 3V11a8 8 0 0 1 8-8h3a8 8 0 0 1 8 8ZM7 9h9M7 13h6",info:"M12 11v6M12 7h.01M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0",prompt:"M6 3h12v18H6zM9 7h6M9 11h6M9 15h4",source:"m8 5-6 7 6 7m8-14 6 7-6 7m-3-15-2 16",settings:"M4 6h16M4 12h16M4 18h16M8 3v6M16 9v6M10 15v6",inputs:"M12 3v12m-4-4 4 4 4-4M4 14v7h16v-7",turns:"M20 7v5h-5M4 17v-5h5M6 7a7 7 0 0 1 12-2l2 3M4 16l2 3a7 7 0 0 0 12-2",subscriptions:"M12 3v6M4 15v-3h16v3M12 12v3M2 15h4v6H2zM10 15h4v6h-4zM18 15h4v6h-4z",actions:"m13 2-9 12h7l-1 8 10-13h-7z",artifacts:"M3 6h7l2 3h9v12H3zM3 6V3h7l2 3h7v3",capabilities:"m12 2 9 4v6c0 5-9 10-9 10S3 17 3 12V6zM8 12l3 3 5-6"};function le({kind:e}){return t("svg",{"aria-hidden":"true",fill:"none",height:"15",width:"15",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:Fs[e]})})}function Ns({sections:e,children:a}){let o=pe(),[r,s]=w(null),d=e.find(l=>l.id===r);return e.length===0?t("div",{className:"flex min-h-0 flex-1 flex-col",children:a}):u(At,{className:"contents",onValueChange:l=>s(l==="chat"?null:String(l)),value:d?.id??"chat",children:[u(vt,{"aria-label":"Actor-Ansichten",className:"flex h-auto w-auto max-w-full flex-shrink-0 flex-nowrap justify-start gap-1 overflow-x-auto rounded-none border-b border-border-soft px-workspace-inset py-1.5",variant:"line",children:[t(Wa,{"aria-label":"Chat anzeigen",className:nr,id:`${o}-chat-tab`,title:"Chat anzeigen",value:"chat",children:t(le,{kind:"chat"})}),e.map(l=>t(Wa,{"aria-label":l.count===void 0?l.label:`${l.label} (${l.count})`,className:nr,id:`${o}-${l.id}-tab`,title:l.count===void 0?l.label:`${l.label} (${l.count})`,value:l.id,children:l.icon},l.id))]}),d&&t(Ga,{className:"min-h-0 flex-1 overflow-y-auto border-b border-border-soft px-workspace-inset py-1.5 text-[0.76rem]",id:`${o}-details`,tabIndex:0,value:d.id,children:d.content}),t(Ga,{className:"flex min-h-0 flex-1 flex-col",id:`${o}-chat`,keepMounted:!0,value:"chat",children:a})]})}function Es({grants:e}){return e.length===0?t(se,{className:Yt,children:"Keine Capabilities"}):t("div",{className:"flex flex-wrap gap-1 py-1.5",children:e.map((a,o)=>{let r=a.scope.kind==="workspace"?a.scope.path:"Run",s=[a.delegable?"delegierbar":void 0,a.usable===!1?"nur weitergeben":void 0].filter(Boolean).join(", ");return u("span",{className:"rounded-full border border-border-soft px-2 py-0.5 text-[0.68rem] [&>small]:text-muted-foreground",title:r,children:[a.capability,s&&u("small",{children:[" ",s]})]},`${a.capability}-${o}`)})})}var qs="my-1.5 rounded-lg border border-[color-mix(in_srgb,var(--primary)_35%,var(--border))] bg-primary/5 px-2.5 py-2 [&>p]:my-1 [&>p]:text-[0.72rem] [&>p]:text-muted-foreground";function Os({action:e,runId:a,onError:o}){let r=W().can("runs.write"),[s,d]=w(""),[l,n]=w(!1),i=async(f,c)=>{if(!l){n(!0);try{await sr(a,e.id,f,c)}catch(m){o(m instanceof Error?m.message:String(m))}finally{n(!1)}}};return u("div",{className:qs,children:[t("strong",{children:e.title}),e.description&&t("p",{children:e.description}),e.owner&&u("p",{children:["wartet auf Eingabe - ",e.owner]}),e.input&&t(te,{className:"my-1.5 text-[0.76rem]",disabled:!r,onChange:f=>d(f.target.value),placeholder:e.input.placeholder??e.input.label,type:"text",value:s}),u("div",{className:"mt-1 flex justify-end gap-1.5",children:[t(z,{disabled:!r||l,onClick:()=>{i("dismissed",void 0)},size:"sm",variant:"outline",children:"Verwerfen"}),t(z,{disabled:!r||l||e.input?.required===!0&&s.trim()==="",onClick:()=>{i("approved",s.trim()||void 0)},size:"sm",children:"Quittieren"})]})]})}function Hs({handle:e,source:a}){return t("div",{className:"overflow-x-auto rounded-lg border border-border-soft bg-border-soft/22",children:t(Me,{content:a,language:"typescript",lineNumbers:!0,path:`${e}.ts`})})}function Kt({actor:e,index:a,...o}){let r=W(),s=da(),d=r.can("runs.write"),l=r.can("runs.inspect"),n=a.view,i=l&&s?.runId===n.id?s.source(n,e.id):void 0,[f,c]=w(),m=n.inputs.filter(S=>S.actorId===e.id).sort((S,j)=>S.sequence-j.sequence),h=n.turns.filter(S=>S.actorId===e.id).sort((S,j)=>S.startedAt.localeCompare(j.startedAt)),C=n.subscriptions.filter(S=>S.subscriberId===e.id),x=n.actions.filter(S=>S.askedBy===e.id),L=n.artifacts.filter(S=>S.createdBy===e.id),b=m.filter(Pa).length,P=e.id===n.primaryActorId,y=P?Ts(n):void 0,D=e.kind!=="human"&&e.lifecycle?.kind!=="stopped",R=e.kind==="human"?void 0:e.lifecycle?.kind??"idle",K=Object.entries(e.inputs??{}),V=e.execution?.driver,k=e.kind==="script"?"TypeScript":!V||V.kind==="manual"?"Manuell":[V.kind,V.config.provider].filter(Boolean).join(" - "),M=V&&V.kind!=="manual"?V.config:void 0,G=[{id:"info",label:"Info: Modell und Run-Details",icon:t(le,{kind:"info"}),content:u("div",{className:Ka,children:[R&&t(Fe,{status:R}),t("span",{children:P?"Prim\xE4rer Actor":fr[e.kind]}),t("span",{children:k}),M?.model&&t("span",{className:"max-w-[220px] truncate",title:M.model,children:M.model}),M?.thinking&&u("span",{children:["Denktiefe ",Xt(M.thinking)]}),u("span",{children:[b," offen"]}),u("span",{children:[h.length," Turns"]}),P&&y!==void 0&&t("span",{title:"Gesamtkosten des Runs \xFCber alle Turns",children:Ds(y)})]})},...e.prompt?[{id:"auftrag",label:"Auftrag",icon:t(le,{kind:"prompt"}),content:t("pre",{className:Ma,children:e.prompt})}]:[],...i?[{id:"source",label:"Quelltext",icon:t(le,{kind:"source"}),content:i}]:e.source?[{id:"source",label:"Quelltext",icon:t(le,{kind:"source"}),count:e.source.replace(/\n$/,"").split(`
2
+ `).length,content:t(Hs,{handle:e.handle,source:e.source})}]:[],...K.length>0?[{id:"vorgaben",label:"Vorgaben",icon:t(le,{kind:"settings"}),count:K.length,content:t("dl",{className:Ve,children:K.map(([S,j])=>u("span",{children:[t("dt",{children:S}),t("dd",{children:j})]},S))})}]:[],{id:"eingaben",label:"Eingaben",icon:t(le,{kind:"inputs"}),count:m.length,content:t("div",{className:Te,children:m.map(S=>u("button",{className:De,onClick:()=>o.onNavigate({type:"input",id:S.id}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:S.content}),u("small",{children:[pr(a,S)," - ",oe(S.enqueuedAt)]})]}),t(Fe,{status:S.lifecycle.kind==="discarded"?"dismissed":S.lifecycle.kind==="claimed"?a.turnById.get(S.lifecycle.turnId)?.status??"completed":"pending"})]},S.id))})},{id:"turns",label:"Turns",icon:t(le,{kind:"turns"}),count:h.length,content:t("div",{className:Te,children:h.map(S=>u("button",{className:De,onClick:()=>o.onNavigate({type:"turn",id:S.id}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:de(S.id)}),t("small",{children:oe(S.startedAt)})]}),t(Fe,{status:S.status})]},S.id))})},{id:"subscriptions",label:"Subscriptions",icon:t(le,{kind:"subscriptions"}),count:C.length,content:t("div",{className:Te,children:C.map(S=>u("button",{className:De,onClick:()=>o.onNavigate({type:"subscription",id:S.id}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:S.eventTypes.join(", ")}),t("small",{children:de(S.id)})]}),t(Fe,{status:S.status})]},S.id))})},...x.length>0?[{id:"aktionen",label:"Aktionen",icon:t(le,{kind:"actions"}),count:x.length,content:t("div",{className:Te,children:x.map(S=>u("button",{className:De,onClick:()=>o.onNavigate({type:"action",id:S.id}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:S.title}),t("small",{children:oe(S.proposedAt)})]}),t(Fe,{status:S.status})]},S.id))})}]:[],...L.length>0?[{id:"artefakte",label:"Artefakte",icon:t(le,{kind:"artifacts"}),count:L.length,content:t("div",{className:Te,children:L.map(S=>t("button",{className:De,onClick:()=>o.onNavigate({type:"artifact",id:S.id}),type:"button",children:u("span",{className:Be,children:[t("strong",{children:S.title}),u("small",{children:[Ue(S.size)," - ",S.mediaType]})]})},S.id))})}]:[],{id:"capabilities",label:"Capabilities",icon:t(le,{kind:"capabilities"}),count:e.grants.length,content:t(Es,{grants:e.grants})},{id:"werkzeuge",label:"Werkzeuge",icon:t(va,{size:15}),...e.toolNames?{count:e.toolNames.length}:{},content:t("p",{className:be,children:e.toolNames===null?"Alle verf\xFCgbaren Werkzeuge":e.toolNames?.join(", ")||"Keine Werkzeuge"})}];return u("div",{className:Ye,children:[u("header",{className:Jt,children:[t(eo,{canGoBack:o.canGoBack,onBack:o.onBack}),u("div",{className:"flex min-w-0 flex-1 items-baseline gap-2 [&>span]:flex-1",children:[t("h2",{children:e.displayName}),u("span",{className:jt,children:["@",e.handle,l&&e.createdBy?` - erzeugt von ${ea(a,e.createdBy)}`:""]})]}),D&&d&&t(z,{className:"flex-shrink-0",onClick:()=>{lr(n.id,e.id,Ms).catch(S=>c(S.message))},size:"sm",title:`@${e.handle} samt beauftragten Kindern dauerhaft stoppen; die Chat-Eingabe unterbricht dagegen nur den laufenden Turn`,variant:"destructive",children:"Stop"}),l&&d&&e.lifecycle?.kind==="stopped"&&e.kind!=="human"&&t(z,{onClick:()=>{dr(n.id,e.id).catch(S=>c(S.message))},size:"sm",variant:"outline",children:"Neu starten"})]}),f&&t("p",{className:Qt,children:f}),u(Ns,{sections:l?G:[],children:[t(Ze,{actor:e,view:n,presentation:"inspector",display:o.chatDisplay,className:"min-h-0 flex-1",primaryMessages:o.primaryMessages,conversation:o.actorConversations?.[e.id],historyError:o.conversationError,onNavigate:o.onNavigate,running:P?o.primaryRunning:R==="running"}),t(Je,{actor:e,view:n,composerVisible:o.composerVisible,display:o.chatDisplay,running:P?o.primaryRunning:R==="running"})]})]})}function Za({eyebrow:e,title:a,subtitle:o,...r}){return u("header",{className:Jt,children:[t(eo,{canGoBack:r.canGoBack,onBack:r.onBack}),u("div",{className:"min-w-0 flex-1",children:[t("p",{className:"mb-0.5 text-[0.66rem] font-semibold tracking-[0.08em] uppercase text-muted-foreground",children:e}),t("h2",{children:a}),t("span",{className:jt,children:o})]})]})}function Us({index:e,input:a,...o}){let r=a.artifactIds.flatMap(s=>{let d=e.artifactById.get(s);return d?[d]:[]});return u("div",{className:Ye,children:[t(Za,{canGoBack:o.canGoBack,eyebrow:"ActorInput",onBack:o.onBack,subtitle:oe(a.enqueuedAt),title:de(a.id)}),u("div",{className:Da,children:[u("section",{className:ee,children:[t("h3",{children:"Inhalt"}),t("pre",{className:Ma,children:a.content})]}),u("section",{className:ee,children:[t("h3",{children:"Routing"}),u("dl",{className:Ve,children:[t("dt",{children:"Actor"}),t("dd",{children:t(ze,{id:a.actorId,index:e,onNavigate:o.onNavigate})}),t("dt",{children:"Eingereiht von"}),t("dd",{children:t(ze,{id:a.enqueuedBy,index:e,onNavigate:o.onNavigate})}),t("dt",{children:"Turn"}),t("dd",{children:a.lifecycle.kind==="claimed"?t(Ta,{label:de(a.lifecycle.turnId),onNavigate:o.onNavigate,selection:{type:"turn",id:a.lifecycle.turnId}}):a.lifecycle.kind==="discarded"?"verworfen":"wartet"}),t("dt",{children:"Subscription"}),t("dd",{children:a.subscriptionId?t(Ta,{label:de(a.subscriptionId),onNavigate:o.onNavigate,selection:{type:"subscription",id:a.subscriptionId}}):"keine"}),a.lifecycle.kind==="discarded"&&u(X,{children:[t("dt",{children:"Verworfen"}),t("dd",{children:oe(a.lifecycle.at)}),t("dt",{children:"Grund"}),t("dd",{children:a.lifecycle.reason})]})]})]}),a.sourceEventIds.length>0&&u("section",{className:ee,children:[t("h3",{children:"Quell-Events"}),t("p",{className:be,children:a.sourceEventIds.join(", ")})]}),r.length>0&&t(_s,{artifacts:r,onNavigate:o.onNavigate})]})]})}function Vs({index:e,turn:a,...o}){let r=cr(a);return u("div",{className:Ye,children:[t(Za,{canGoBack:o.canGoBack,eyebrow:"Turn",onBack:o.onBack,subtitle:oe(a.startedAt),title:de(a.id)}),t("div",{className:Ka,children:t(Fe,{status:a.status})}),u("div",{className:Da,children:[u("section",{className:ee,children:[t("h3",{children:"Details"}),u("dl",{className:Ve,children:[t("dt",{children:"Actor"}),t("dd",{children:t(ze,{id:a.actorId,index:e,onNavigate:o.onNavigate})}),t("dt",{children:"Eingabe"}),t("dd",{children:t(Ta,{label:de(a.inputId),onNavigate:o.onNavigate,selection:{type:"input",id:a.inputId}})}),t("dt",{children:"Beendet"}),t("dd",{children:a.finishedAt?oe(a.finishedAt):"l\xE4uft"}),a.reason&&u(X,{children:[t("dt",{children:"Grund"}),t("dd",{children:a.reason})]})]})]}),r&&u("section",{className:ee,children:[t("h3",{children:"Nutzung"}),u("dl",{className:Ve,children:[t("dt",{children:"Input-Tokens"}),t("dd",{children:r.inputTokens??0}),t("dt",{children:"Output-Tokens"}),t("dd",{children:r.outputTokens??0}),t("dt",{children:"Cache gelesen"}),t("dd",{children:r.cacheReadTokens??0}),t("dt",{children:"Cache geschrieben"}),t("dd",{children:r.cacheWriteTokens??0}),t("dt",{children:"Kosten"}),u("dd",{children:[(r.costUsd??0).toFixed(6)," USD"]})]})]})]})]})}function zs({index:e,subscription:a,...o}){return u("div",{className:Ye,children:[t(Za,{canGoBack:o.canGoBack,eyebrow:"Subscription",onBack:o.onBack,subtitle:oe(a.createdAt),title:de(a.id)}),t("div",{className:Ka,children:t(Fe,{status:a.status})}),u("div",{className:Da,children:[u("section",{className:ee,children:[t("h3",{children:"Filter"}),u("dl",{className:Ve,children:[t("dt",{children:"Subscriber"}),t("dd",{children:t(ze,{id:a.subscriberId,index:e,onNavigate:o.onNavigate})}),t("dt",{children:"Quell-Actors"}),t("dd",{children:a.sourceActorIds?.map(r=>ea(e,r)).join(", ")??"alle"}),t("dt",{children:"Actor-Arten"}),t("dd",{children:a.sourceActorKinds?.join(", ")??"alle"}),t("dt",{children:"Event-Typen"}),t("dd",{children:a.eventTypes.join(", ")}),t("dt",{children:"Eigene Events"}),t("dd",{children:a.includeSelf?"ja":"nein"}),t("dt",{children:"Angelegt von"}),t("dd",{children:t(ze,{id:a.createdBy,index:e,onNavigate:o.onNavigate})}),a.status!=="active"&&u(X,{children:[t("dt",{children:"Grund"}),t("dd",{children:a.reason})]}),a.status==="failed"&&u(X,{children:[t("dt",{children:"Fehler-Event"}),t("dd",{children:a.sourceEventId})]})]})]}),a.sourceActorIds&&u("section",{className:ee,children:[t("h3",{children:"Quell-Actors"}),t(Ws,{actorIds:a.sourceActorIds,index:e,onNavigate:o.onNavigate})]})]})]})}function Gs({action:e,index:a,...o}){let[r,s]=w();return u("div",{className:Ye,children:[t(Za,{canGoBack:o.canGoBack,eyebrow:"Aktion",onBack:o.onBack,subtitle:ea(a,e.askedBy),title:e.title}),t("div",{className:Ka,children:t(Fe,{status:e.status})}),u("div",{className:Da,children:[e.status==="pending"&&t(Os,{action:e,onError:s,runId:a.view.id}),e.description&&u("section",{className:ee,children:[t("h3",{children:"Beschreibung"}),t("p",{children:e.description})]}),u("section",{className:ee,children:[t("h3",{children:"Details"}),u("dl",{className:Ve,children:[t("dt",{children:"Gefragt von"}),t("dd",{children:t(ze,{id:e.askedBy,index:a,onNavigate:o.onNavigate})}),t("dt",{children:"Vorgeschlagen"}),t("dd",{children:oe(e.proposedAt)}),e.resolvedAt&&u(X,{children:[t("dt",{children:"Aufgel\xF6st"}),t("dd",{children:oe(e.resolvedAt)})]}),e.owner&&u(X,{children:[t("dt",{children:"Eigent\xFCmer"}),t("dd",{children:e.owner})]}),e.result!==null&&e.result!==void 0&&u(X,{children:[t("dt",{children:"Ergebnis"}),t("dd",{children:typeof e.result=="string"?e.result:JSON.stringify(e.result)})]})]})]}),Object.keys(e.parameters).length>0&&u("section",{className:ee,children:[t("h3",{children:"Parameter"}),t("pre",{className:Ma,children:JSON.stringify(e.parameters,null,2)})]}),e.payload!==null&&e.payload!==void 0&&u("section",{className:ee,children:[t("h3",{children:"Nutzdaten"}),t("pre",{className:Ma,children:JSON.stringify(e.payload,null,2)})]}),r&&t("p",{className:Qt,children:r})]})]})}function Ta({label:e,onNavigate:a,selection:o}){return t("button",{className:ir,onClick:()=>a(o),type:"button",children:e})}function ze({id:e,index:a,onNavigate:o}){return t(Ta,{label:ea(a,e),onNavigate:o,selection:{type:"actor",id:e}})}function Ws({actorIds:e,index:a,onNavigate:o}){return t("div",{className:Te,children:e.map(r=>{let s=a.actorById.get(r);return u("button",{className:De,onClick:()=>o({type:"actor",id:r}),type:"button",children:[u("span",{className:Be,children:[t("strong",{children:s?.displayName??de(r)}),t("small",{children:ea(a,r)})]}),s&&t(se,{className:Yt,children:fr[s.kind]})]},r)})})}function _s({artifacts:e,onNavigate:a}){return u("section",{className:ee,children:[t("h3",{children:"Artefakte"}),t("div",{className:Te,children:e.map(o=>t("button",{className:De,onClick:()=>a({type:"artifact",id:o.id}),type:"button",children:u("span",{className:Be,children:[t("strong",{children:o.title}),u("small",{children:[Ue(o.size)," - ",o.mediaType]})]})},o.id))})]})}var Xs=e=>{let a=e.toLowerCase();return a.startsWith("text/")||a.includes("json")||a.includes("xml")||a.includes("yaml")};function Zt(e,a){let o=U(new Map),[r,s]=w(0),d=a?.id,l=()=>{d&&o.current.delete(d),s(n=>n+1)};return O(()=>{if(!(!a||o.current.has(a.id))){if(a.mediaType.toLowerCase().startsWith("image/")){o.current.set(a.id,{kind:"image"}),s(n=>n+1);return}if(!Xs(a.mediaType)){o.current.set(a.id,{kind:"download"}),s(n=>n+1);return}o.current.set(a.id,{kind:"loading"}),s(n=>n+1),(async()=>{try{let n=await fetch(Ra(e,a.id),{headers:{Accept:a.mediaType}});if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);let i=await n.text();if(a.mediaType.toLowerCase().includes("json"))try{i=JSON.stringify(JSON.parse(i),null,2)}catch{}o.current.set(a.id,{kind:"text",text:i})}catch(n){o.current.set(a.id,{kind:"error",message:n instanceof Error?n.message:String(n)})}s(n=>n+1)})()}},[a,e,r]),{content:a?o.current.get(a.id):void 0,retry:l}}var $t=5e3,Ks=(e,a)=>{let o=Array.from({length:e.length+1},()=>new Uint32Array(a.length+1));for(let l=e.length-1;l>=0;l-=1)for(let n=a.length-1;n>=0;n-=1)o[l][n]=e[l]===a[n]?o[l+1][n+1]+1:Math.max(o[l+1][n],o[l][n+1]);let r=[],s=0,d=0;for(;s<e.length&&d<a.length;)e[s]===a[d]?(r.push({kind:"same",text:e[s]}),s+=1,d+=1):o[s+1][d]>=o[s][d+1]?(r.push({kind:"removed",text:e[s]}),s+=1):(r.push({kind:"added",text:a[d]}),d+=1);for(;s<e.length;)r.push({kind:"removed",text:e[s++]});for(;d<a.length;)r.push({kind:"added",text:a[d++]});return r};function $s({artifact:e,index:a}){let o=e.previousVersionId?a.artifactById.get(e.previousVersionId):void 0,r=Zt(a.view.id,o).content,s=Zt(a.view.id,e).content,d=r?.kind==="text"?r.text:void 0,l=s?.kind==="text"?s.text:void 0,n=B(()=>{if(d===void 0||l===void 0)return;let f=d.split(`
3
3
  `),c=l.split(`
4
4
  `);return f.length>$t||c.length>$t?"zu gro\xDF":Ks(f,c)},[d,l]);if(!e.previousVersionId)return null;if(!o)return t("p",{className:be,children:"Vorversion nicht in dieser Projektion."});if(!r||!s||r.kind==="loading"||s.kind==="loading")return t("p",{className:be,children:"Vergleich wird geladen ..."});if(n===void 0)return u("p",{className:be,children:[e.mediaType," wird nicht zeilenweise verglichen."]});if(n==="zu gro\xDF")return u("p",{className:be,children:["Zu gro\xDF f\xFCr den Zeilenvergleich (mehr als ",$t," Zeilen)."]});if(n.every(f=>f.kind==="same"))return t("p",{className:be,children:"Beide Versionen haben denselben Text."});let i={same:" ",added:"+",removed:"-"};return t("pre",{className:"my-1.5 overflow-x-auto rounded-lg bg-foreground/4 p-2 text-[0.7rem] [&>span]:block [&>span]:whitespace-pre [&>span[data-diff=added]]:bg-success-soft [&>span[data-diff=removed]]:bg-destructive-soft",children:n.map((f,c)=>u("span",{"data-diff":f.kind,children:[i[f.kind]," ",f.text,`
5
- `]},c))})}function Zs({artifact:e,index:a,...o}){let r=a.view,{content:s,retry:d}=Zt(r.id,e),l=r.inputs.filter(n=>n.artifactIds.includes(e.id));return u("div",{className:Ye,children:[u("header",{className:Jt,children:[t(eo,{canGoBack:o.canGoBack,onBack:o.onBack}),u("div",{className:"min-w-0 flex-1",children:[t("p",{className:"mb-0.5 text-[0.66rem] font-semibold tracking-[0.08em] uppercase text-muted-foreground",children:"Artefakt"}),t("h2",{children:e.title}),u("span",{className:jt,children:["von ",ea(a,e.createdBy)," - ",Ue(e.size)," - ",e.mediaType]})]}),t(z,{render:t("a",{href:Ra(r.id,e.id)}),size:"sm",variant:"outline",children:"Herunterladen"})]}),u("div",{className:Da,children:[u("section",{className:ee,children:[t("h3",{children:"Inhalt"}),(!s||s.kind==="loading")&&t("p",{className:be,children:"Artefakt wird geladen ..."}),s?.kind==="error"&&u("p",{className:Qt,children:[s.message," ",t("button",{className:fr,onClick:d,type:"button",children:"Erneut laden"})]}),s?.kind==="download"&&u("p",{className:be,children:["Keine Vorschau f\xFCr ",e.mediaType,"."]}),s?.kind==="image"&&t("img",{alt:e.title,className:"max-w-full rounded-lg",src:Ra(r.id,e.id)}),s?.kind==="text"&&t("pre",{className:Ma,children:s.text})]}),e.previousVersionId&&u("section",{className:ee,children:[t("h3",{children:"\xC4nderung zur Vorversion"}),t($s,{artifact:e,index:a})]}),l.length>0&&u("section",{className:ee,children:[t("h3",{children:"Verwendet in Eingaben"}),t("div",{className:Te,children:l.map(n=>t("button",{className:De,onClick:()=>o.onNavigate({type:"input",id:n.id}),type:"button",children:u("span",{className:Be,children:[t("strong",{children:n.content}),u("small",{children:[mr(a,n)," - ",oe(n.enqueuedAt)]})]})},n.id))})]}),u("section",{className:ee,children:[t("h3",{children:"Details"}),u("dl",{className:Ve,children:[t("dt",{children:"Erstellt von"}),t("dd",{children:t(ze,{id:e.createdBy,index:a,onNavigate:o.onNavigate})}),t("dt",{children:"Hash"}),t("dd",{children:de(e.hash)}),t("dt",{children:"Erstellt"}),t("dd",{children:oe(e.createdAt)}),e.previousVersionId&&u(X,{children:[t("dt",{children:"Vorversion"}),t("dd",{children:t(Ta,{label:de(e.previousVersionId),onNavigate:o.onNavigate,selection:{type:"artifact",id:e.previousVersionId}})})]})]})]})]})]})}var Js="relative isolate rounded-panel border-[1.5px] border-(--material-edge) bg-(--material-face) [--material-edge:#514657] dark:[--material-edge:#b7a8bd]",js={agent:"[--material-face:var(--color-glass-agent)]",primary:"[--material-face:var(--color-glass-primary)]",script:"[--material-face:var(--color-glass-script)]",app:"[--material-face:var(--color-glass-app)]"},ao=(e,a)=>Y(Js,js[e],a),gr="relative flex items-center gap-2 rounded-t-[15.5px] bg-[color-mix(in_srgb,var(--material-face)_96%,black)] px-3 py-2",xr="min-w-0 truncate p-0 text-[17px] font-[730] leading-[1.3] tracking-[-.5px]",hr="grid size-8 flex-none place-items-center rounded-[11px] border border-[#5146578a] bg-white/9 text-foreground shadow-glass-icon";var Qs=["left","right","top","bottom"],Ys={left:"Links andocken",right:"Rechts andocken",top:"Oben andocken",bottom:"Unten andocken"},el={left:Ee,right:Ia,top:Ca,bottom:La},Lr=e=>({left:e.left+2,top:e.top+2,width:Math.max(0,e.width-4),height:Math.max(0,e.height-4)}),to=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),al={left:{inner:"left-0 top-[40px]",outer:"left-0 top-[calc(50%_-_18px)]"},right:{inner:"right-0 top-[40px]",outer:"right-0 top-[calc(50%_-_18px)]"},top:{inner:"top-0 left-[40px]",outer:"top-0 left-[calc(50%_-_18px)]"},bottom:{inner:"bottom-0 left-[40px]",outer:"bottom-0 left-[calc(50%_-_18px)]"}},tl="absolute grid size-[36px] place-items-center rounded-[5px] border border-primary bg-surface text-primary shadow-[0_2px_8px_#0002] pointer-events-auto data-[active]:bg-primary data-[active]:text-surface [&>svg]:pointer-events-none",ol="absolute z-3 grid touch-none place-items-center rounded-[4px] focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 data-[direction=horizontal]:cursor-col-resize data-[direction=vertical]:cursor-row-resize [&>span]:pointer-events-none [&>span]:rounded-[4px] [&>span]:bg-border-strong data-[direction=horizontal]:[&>span]:h-8 data-[direction=horizontal]:[&>span]:w-[3px] data-[direction=vertical]:[&>span]:h-[3px] data-[direction=vertical]:[&>span]:w-8 hover:[&>span]:bg-primary focus-visible:[&>span]:bg-primary";function Ir({root:e,onChange:a,items:o,canArrange:r,selectedEntity:s,onSelect:d}){let l=U(null),[n,i]=w({width:0,height:0}),[f,c]=w({width:0,height:0}),[m,h]=w(null),[C,x]=w(null),[L,b]=w(!1),[P,y]=w(null),[R,N]=w(),[K,V]=w(null),k=U(null),M=U(null),G=K??e,S=D(()=>ua(e),[e]),j=D(()=>[...S].sort(),[S]),$=D(()=>new Map(o.map(I=>[I.entity,I])),[o]),ie=e?ct(e):{width:0,height:0},Q=f.width<ie.width||f.height<ie.height,fe=R&&S.includes(R)?R:S[0],v={left:0,top:0,...n},B=D(()=>G?mt(G,{left:0,top:0,...n}):{leaves:new Map,dividers:[]},[G,n]);We(()=>{let I=l.current;if(!I)return;let g=I.parentElement,T=()=>{let ue=I.clientWidth,Z=I.clientHeight;i(Ie=>Ie.width===ue&&Ie.height===Z?Ie:{width:ue,height:Z});let ce=getComputedStyle(g),ke=g.clientWidth-parseFloat(ce.paddingLeft)-parseFloat(ce.paddingRight),la=g.clientHeight-parseFloat(ce.paddingTop)-parseFloat(ce.paddingBottom);c(Ie=>Ie.width===ke&&Ie.height===la?Ie:{width:ke,height:la})},F=new ResizeObserver(T);return F.observe(I),F.observe(g),T(),()=>F.disconnect()},[]),O(()=>{s&&N(s)},[s]),We(()=>{if(!r){h(null),x(null);return}let I=null,g=()=>{I!==null&&cancelAnimationFrame(I),I=null},T=Z=>{if(!Z.dataTransfer?.types.includes(Ae))return;let ce=Z.dataTransfer.getData(Ae);ce&&(g(),I=requestAnimationFrame(()=>{I=null,Z.defaultPrevented||h(ce)}))},F=()=>{g(),h(null),x(null)},ue=Z=>{Z.key==="Escape"&&F()};return window.addEventListener("dragstart",T),window.addEventListener("dragend",F),window.addEventListener("drop",F),window.addEventListener("keydown",ue),()=>{g(),window.removeEventListener("dragstart",T),window.removeEventListener("dragend",F),window.removeEventListener("drop",F),window.removeEventListener("keydown",ue)}},[r]);let _=q(()=>{k.current!==null&&cancelAnimationFrame(k.current),k.current=null;let I=M.current;M.current=null,I?.handle.hasPointerCapture(I.pointerId)&&I.handle.releasePointerCapture(I.pointerId),V(null),b(!1)},[]);We(()=>(_(),_),[e,n,Q,_]),O(()=>{if(!L)return;let I=g=>{g.key==="Escape"&&_()};return window.addEventListener("keydown",I),window.addEventListener("blur",_),()=>{window.removeEventListener("keydown",I),window.removeEventListener("blur",_)}},[L,_]);let H=I=>{let g=M.current;if(!g||g.pointerId!==I.pointerId)return;let T=g.divider.direction==="horizontal"?I.clientX:I.clientY,F=Math.max(g.divider.minimum,Math.min(g.divider.maximum,g.divider.ratio+(T-g.start)/g.divider.span));g.next=T===g.start?g.root:pt(g.root,g.divider.path,F)},Le=I=>{N(I),d?.(I)},ae=r&&C&&m?ft(e,m,C.entity,C.side):null,sa=ae?ct(ae):null,Oa=ae&&ae!==e&&sa&&m?f.width<sa.width||f.height<sa.height?v:mt(ae,v).leaves.get(m):null,ye=I=>Qs.map(g=>{let T=el[g];return t("div",{className:`${tl} ${al[g][I===null?"outer":"inner"]}`,"data-dock-side":g,"data-dock-entity":I??"",title:Ys[g],"data-active":C?.entity===I&&C.side===g||void 0,children:t(T,{size:18,"aria-hidden":"true"})},g)});return u("div",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden p-2 data-[dragging]:[&_iframe]:pointer-events-none data-[resizing]:[&_iframe]:pointer-events-none","data-dragging":r&&m!==null||void 0,"data-resizing":L||void 0,children:[Q&&S.length>1&&u("label",{className:"flex items-center gap-2 pb-2 text-[0.8rem]",children:["Kachel",t("select",{className:"max-w-[60%] min-w-0","aria-label":"Sichtbare Kachel",value:fe,onChange:I=>Le(I.target.value),children:S.map(I=>t("option",{value:I,children:$.get(I)?.title??I},I))}),t("span",{className:"truncate text-muted-foreground",children:"Mehr Platz f\xFCr die geteilte Ansicht ben\xF6tigt"})]}),u("div",{ref:l,className:"relative min-h-0 min-w-0 flex-1 overflow-hidden",onDragOver:I=>{if(!r||m===null||!I.dataTransfer.types.includes(Ae))return;I.preventDefault(),I.dataTransfer.dropEffect="move";let g=I.target instanceof Element?I.target.closest("[data-dock-side]"):null,T=g&&l.current?.contains(g)?{entity:g.dataset.dockEntity||null,side:g.dataset.dockSide}:null;x(F=>F?.entity===T?.entity&&F?.side===T?.side?F:T)},onDragLeave:I=>{I.currentTarget.contains(I.relatedTarget)||x(null)},onDrop:I=>{if(!r||m===null)return;let g=I.dataTransfer.getData(Ae);if(!g||g!==m||(I.preventDefault(),!$.has(g)&&!S.includes(g)))return;let T=I.target instanceof Element?I.target.closest("[data-dock-side]"):null;try{if(!e||T){let F=ft(e,g,T?.dataset.dockEntity||null,T?.dataset.dockSide??"right");F!==e&&a(F===null?null:_e(F)),Le(g),y(null)}}catch(F){y(F instanceof Error?F.message:String(F))}finally{h(null),x(null)}},children:[P&&u("div",{className:"absolute inset-x-2 bottom-2 z-7 flex items-center gap-2 rounded-lg border border-primary bg-surface p-3 text-foreground shadow-[0_2px_8px_#0002]",role:"alert",children:[t("span",{className:"flex-1",children:P}),t("button",{className:"grid cursor-pointer place-items-center bg-transparent p-1",type:"button","aria-label":"Meldung schlie\xDFen",onClick:()=>y(null),children:t(xe,{size:16})})]}),!e&&t("div",{className:"grid h-full place-items-center rounded-lg border border-dashed border-border-strong p-6 text-center text-muted-foreground",children:r?"Ziehe einen Actor oder eine Mini-App aus der Kopfzeile hierher.":"F\xFCr diese Kachelansicht sind noch keine Inhalte angeordnet."}),j.map(I=>{let g=$.get(I),T=Lr(Q?v:B.leaves.get(I));return u("section",{className:ao(g?.tone??(I.startsWith("app:")?"app":"agent"),"absolute z-0 flex min-h-0 min-w-0 flex-col overflow-visible"),"data-tile-entity":I,"data-tone":"material",style:{...to(T),display:Q&&I!==fe?"none":void 0},onFocusCapture:()=>{fe!==I&&N(I)},children:[u("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[15.5px]",children:[u("header",{className:`${gr} flex-[0_0_49px] min-w-0 select-none border-b border-[#51465738] text-foreground [&[draggable=true]]:cursor-grab`,draggable:r,onDragStart:F=>{if(!r){F.preventDefault();return}F.dataTransfer.setData(Ae,I),F.dataTransfer.effectAllowed="move"},children:[r&&t(wa,{size:16,"aria-hidden":"true"}),t("span",{className:hr,children:g?.tone==="app"||I.startsWith("app:")?t(Oe,{size:20,"aria-hidden":"true"}):g?.tone==="script"?t(Re,{size:20,"aria-hidden":"true"}):t(ge,{size:20,"aria-hidden":"true"})}),t("span",{className:`${xr} flex-1`,title:g?.title??I,children:g?.title??I}),r&&t("button",{className:"grid size-[26px] cursor-pointer place-items-center rounded-[4px] bg-transparent p-0 text-muted-foreground hover:bg-glass-group hover:text-foreground",type:"button",draggable:!1,"aria-label":`Kachel ${g?.title??I} entfernen`,onClick:()=>a(wo(e,I)),children:t(xe,{size:16})})]}),t("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-auto [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1",children:g?.content??t("div",{className:"p-4.5 text-muted-foreground",children:r?"Dieser Inhalt ist nicht mehr verf\xFCgbar. Du kannst die Kachel entfernen oder einen anderen Inhalt hier andocken.":"Dieser Inhalt ist nicht mehr verf\xFCgbar."})})]}),r&&m!==null&&m!==I&&t("div",{className:"absolute inset-0 z-4",children:t("div",{className:"pointer-events-none absolute top-1/2 left-1/2 size-[116px] -translate-x-1/2 -translate-y-1/2",children:ye(I)})})]},I)}),!Q&&B.dividers.map(I=>t("div",{className:ol,role:"separator",tabIndex:0,"aria-label":"Kachelgr\xF6\xDFe \xE4ndern","aria-orientation":I.direction==="horizontal"?"vertical":"horizontal","aria-valuemin":Math.round(I.minimum*100),"aria-valuemax":Math.round(I.maximum*100),"aria-valuenow":Math.round(I.ratio*100),"data-direction":I.direction,style:to(I),onPointerDown:g=>{g.button!==0||!g.isPrimary||!e||M.current||(g.preventDefault(),g.currentTarget.setPointerCapture(g.pointerId),M.current={divider:I,start:I.direction==="horizontal"?g.clientX:g.clientY,root:e,next:e,pointerId:g.pointerId,handle:g.currentTarget},b(!0))},onPointerMove:g=>{M.current?.pointerId===g.pointerId&&(H(g),k.current===null&&(k.current=requestAnimationFrame(()=>{k.current=null,M.current&&V(M.current.next)})))},onPointerUp:g=>{let T=M.current;!T||T.pointerId!==g.pointerId||(H(g),_(),T.next!==T.root&&a(T.next))},onLostPointerCapture:g=>{M.current?.pointerId===g.pointerId&&_()},onPointerCancel:g=>{M.current?.pointerId===g.pointerId&&_()},onKeyDown:g=>{if(g.key==="Escape"&&M.current){g.preventDefault(),_();return}if(!e||M.current)return;let T=I.direction==="horizontal"?"ArrowLeft":"ArrowUp",F=I.direction==="horizontal"?"ArrowRight":"ArrowDown";if(g.key!==T&&g.key!==F&&g.key!=="Home"&&g.key!=="End")return;g.preventDefault();let ue=g.key==="Home"?I.minimum:g.key==="End"?I.maximum:I.ratio+(g.key===F?.02:-.02);a(pt(e,I.path,Math.max(I.minimum,Math.min(I.maximum,ue))))},children:t("span",{})},I.path.join("."))),L&&t("div",{className:"absolute inset-0 z-2"}),r&&m!==null&&e&&t("div",{className:"pointer-events-none absolute inset-2 z-6",children:ye(null)}),r&&m!==null&&Oa&&t("div",{className:ao($.get(m)?.tone??(m.startsWith("app:")?"app":"agent"),"pointer-events-none absolute z-5 opacity-80"),style:to(Lr(Oa)),children:t("div",{className:"absolute inset-0 rounded-[15.5px] border-2 border-primary bg-primary/22"})})]})]})}function Cr({root:e,onChange:a,surfaceElements:o,cardSections:r,session:s,view:d,navigation:l,onSelect:n,selected:i}){let f=W().can("runs.inspect"),c=d.actors.filter(C=>C.kind!=="human"&&C.lifecycle?.kind!=="stopped"&&(f||C.kind==="agent")),m=[...c.map(C=>({entity:`@${C.handle}`,title:`${C.displayName||C.handle} (@${C.handle})`,tone:He(d,C),content:C.kind==="agent"?t(To,{actor:C,view:d,cardSections:r,chatInput:Va(e,`@${C.handle}`),session:s,navigation:l,onSelect:n}):t($a,{view:d,selection:{type:"actor",id:C.id},canGoBack:!1,chatDisplay:"surface",composerVisible:!1,onNavigate:n,onBack:()=>{},primaryMessages:s.messages,actorConversations:s.actorConversations,conversationError:s.conversationError,primaryRunning:s.running})})),...o.flatMap(({Element:C,select:x})=>x(s).filter(L=>L.visible!==!1).map(L=>({entity:`app:${L.id}`,title:L.title??L.id,tone:"app",content:t(C,{definition:L,navigation:l,session:s})})))],h=i?.type==="run-app"?`app:${i.id}`:i?.type==="actor"?c.find(C=>C.id===i.id)?.handle:void 0;return t(Ir,{root:e,onChange:a,items:m,canArrange:f,selectedEntity:i?.type==="actor"&&h?`@${h}`:h})}function Sr({state:e}){return t("div",{className:"pointer-events-none absolute inset-y-0 left-0 grid w-[var(--surface-visible-width,100%)] place-items-center p-6",children:t(pa,{state:e})})}function Ja({view:e,startup:a,connected:o,running:r,error:s}){if(a?.status==="failed")return{kind:"error",title:"Der Run konnte nicht vorbereitet werden",detail:a.message};if(s)return{kind:"error",title:"Der Run-Status ist nicht erreichbar",detail:s};if(a?.status==="preparing")return{kind:"working",title:"Run wird vorbereitet",detail:a.message};let d=e?.actors.filter(c=>c.kind!=="human")??[],l=d.filter(c=>c.lifecycle?.kind!=="stopped");if(d.length&&!l.length)return{kind:"stopped",title:"Der Run wurde gestoppt",detail:"Es wird keine weitere Arbeit ausgef\xFChrt."};if(e?.actions.some(c=>c.status==="pending"))return{kind:"waiting",title:"Deine Eingabe wird ben\xF6tigt",detail:"Im Chat wartet eine Aktion auf Deine Eingabe."};let n=new Set(l.map(c=>c.id));if(r||l.some(c=>c.lifecycle?.kind==="running")||e?.turns.some(c=>n.has(c.actorId)&&c.status==="running")||e?.inputs.some(c=>n.has(c.actorId)&&Pa(c)))return{kind:"working",title:"Der Run wird eingerichtet",detail:"Die Oberfl\xE4che wird aufgebaut. Die Elemente erscheinen automatisch."};let f=l.map(c=>e?.turns.filter(m=>m.actorId===c.id).at(-1)).find(c=>c?.status==="failed"||c?.status==="interrupted");if(f)return{kind:"error",title:"Der Aufbau wurde angehalten",detail:f.reason||"Der letzte Arbeitsschritt konnte nicht abgeschlossen werden."};if(!o)return{kind:"working",title:"Run wird geladen",detail:"Die Verbindung zum Run wird hergestellt."}}var ne=p("@ragents/web/lib/local-storage-setting","createLocalStorageSetting");var wr=e=>`ragents.orchestration.tile-presentation:${e}`;function rl(e){if(e===null||e==="null")return null;let a=JSON.parse(e);if(!a||typeof a!="object"||Array.isArray(a)||!("root"in a)||Object.keys(a).some(o=>!["root","programBasis"].includes(o))||"programBasis"in a&&typeof a.programBasis!="string")throw new Error("Die gespeicherte Kachelansicht ist ung\xFCltig.");return{root:a.root===null?null:_e(a.root),..."programBasis"in a?{programBasis:a.programBasis}:{}}}var br=ne({changeEvent:"ragents-tile-presentation-change",matchesKey:e=>e.startsWith("ragents.orchestration.tile-presentation:"),parse:rl,serialize:JSON.stringify}),sl=e=>br.useValue(wr(e)),Qa=(e,a)=>br.save(wr(e),a),yr=e=>JSON.stringify({root:e.root});function ll(e,a){if(!e)return null;if(e.programBasis!==void 0)return e.programBasis===yr(a)?e:null;let o=new Set(za(e.root));return za(a.root).some(r=>!o.has(r))?null:e}function kr(e,a){let o=a?.pluginStates.find(f=>f.pluginId===bo&&f.scope.kind==="run")?.state,r=D(()=>o===void 0?void 0:JSON.stringify(o),[o]),s=D(()=>{try{return{layout:r===void 0?void 0:Ao(JSON.parse(r))}}catch(f){return{error:f instanceof Error?f.message:String(f)}}},[r]),d=D(()=>({root:s.layout?.root??null}),[s]),l=D(()=>yr(d),[d]),n=sl(e),i=a&&!s.error?ll(n,d):n;return O(()=>{n&&!i&&Qa(e,null)},[e,n,i]),{programLayout:s,personalLayout:i,presentation:i??d,programBasis:l}}function ja(e,a="horizontal"){if(e.length===0)return null;if(e.length===1)return{entity:e[0]};let o=Math.ceil(e.length/2),r=a==="horizontal"?"vertical":"horizontal";return{direction:a,weights:[o,e.length-o],children:[ja(e.slice(0,o),r),ja(e.slice(o),r)]}}var oo=p("@ragents/web/StatusGroup","StatusGroup");var Ba=p("@ragents/web/Toolbar","ToolbarCopy");var Ne=p("@ragents/web/Toolbar","ToolbarItem");var Fa=p("@ragents/web/Toolbar","ToolbarLabel");var aa=p("@ragents/web/Toolbar","ToolbarText");var dl=Object.freeze({actorVisibility:Object.freeze({})}),Ar=e=>`ragents.orchestration.actor-visibility:${e}`;function ul(e){if(e===null)return dl;let a=JSON.parse(e);if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(o=>o!=="actorVisibility")||!("actorVisibility"in a)||!a.actorVisibility||typeof a.actorVisibility!="object"||Array.isArray(a.actorVisibility)||Object.values(a.actorVisibility).some(o=>typeof o!="boolean"))throw new Error("Die gespeicherte Actor-Sichtbarkeit ist ung\xFCltig.");return a}var ta=(e,a,o,r)=>e.kind==="human"?!1:(Object.hasOwn(o.actorVisibility,e.id)?o.actorVisibility[e.id]:void 0)??(e.id!==r&&!a.has(e.id)),vr=ne({changeEvent:"ragents-actor-visibility-change",matchesKey:e=>e.startsWith("ragents.orchestration.actor-visibility:"),parse:ul,serialize:JSON.stringify});function Ya(e){return vr.useValue(Ar(e))}function et(e,a){vr.save(Ar(e),a)}function oa({open:e,id:a,label:o,closeLabel:r,buttonRef:s,onClose:d,width:l,height:n,placement:i="bottom",focusInput:f=!1,keepMounted:c=!1,role:m,headerContent:h,children:C}){let x=U(null),L=b=>b.reason==="outside-press"&&b.event.target instanceof Node&&s.current?.contains(b.event.target)===!0;return t(fa,{open:e,onOpenChange:(b,P)=>{!b&&!L(P)&&d()},children:u(ca,{align:"start",anchor:s,"aria-label":o,className:"flex min-h-0 min-w-0 flex-col gap-0 overflow-hidden rounded-b-sm p-0 text-[0.76rem] focus:outline-none data-[placement=top]:rounded-t-sm data-[placement=top]:rounded-b-none [&_input[type=checkbox]]:m-0 [&_input[type=checkbox]]:flex-none [&_input[type=checkbox]]:accent-primary",collisionPadding:8,"data-surface-scroll":"true",dim:!0,"data-placement":i,id:a,initialFocus:f?()=>x.current?.querySelector("input")??!0:!0,keepMounted:c,ref:x,role:m,side:i,style:{width:l==="available"?"var(--available-width)":l,height:n,maxWidth:"var(--available-width)",maxHeight:"var(--available-height)"},children:[u("header",{className:"flex flex-none items-center justify-between gap-2 border-b border-border-soft px-2.5 py-2",children:[t("strong",{className:"shrink-0",children:o}),h,t(z,{"aria-label":r,onClick:()=>d(!0),size:"icon-sm",title:r,variant:"ghost",children:t(xe,{})})]}),C]})})}var nl="grid size-[30px] flex-none place-items-center rounded-lg border border-foreground/15 text-foreground",il={agent:"bg-glass-agent",primary:"bg-glass-primary",script:"bg-glass-script",app:"bg-glass-app"};function Pr({actor:e,view:a,session:o,open:r,onToggle:s,onClose:d,visible:l}){let n=Ua(o.session.id).has(`@${e.handle}`),i=W().can("runs.inspect"),[f,c]=w(!1),m=U(null),h=pe(),C=ga(),x=q((R=!1)=>{d(),R&&m.current?.focus({preventScroll:!0})},[d]),L=R=>{if(!C)throw new Error("Der Actor-Zugang ben\xF6tigt den Fl\xE4chen-Controller.");C.acceptSelection(R),x()},b=He(a,e),P=e.kind==="agent"?`Chat mit @${e.handle}`:`Actor-Ansicht von @${e.handle}`,y=i?e.kind==="agent"?"LLM-Agent":"TypeScript-Actor":"Agent";return u("div",{className:"flex items-stretch [&[hidden]]:hidden",hidden:!l,children:[u(Ne,{as:"button","aria-controls":f?h:void 0,"aria-expanded":r,"aria-haspopup":"dialog","aria-label":`${e.displayName||e.handle}. ${y}: ${P} \xF6ffnen`,className:"font-bold","data-tone":b,"data-staged":n||void 0,onClick:()=>{c(!0),s()},draggable:i,onDragStart:R=>{if(!i){R.preventDefault();return}R.dataTransfer.setData(Ae,`@${e.handle}`),R.dataTransfer.effectAllowed="move",x()},ref:m,title:`${y}: ${P} \xF6ffnen${i?". Zum Andocken auf eine Kachel ziehen.":""}`,type:"button",children:[t("span",{className:Y(nl,n&&il[b]),children:e.kind==="agent"?t(Se,{size:20}):t(qe,{size:20})}),u(Ba,{children:[u(Fa,{children:["@",e.handle]}),t(aa,{children:e.displayName&&e.displayName!==e.handle?e.displayName:y})]})]}),f&&t(oa,{open:r,id:h,label:P,closeLabel:`${P} schlie\xDFen`,buttonRef:m,keepMounted:!0,onClose:x,width:e.kind==="agent"?784:560,height:640,role:"dialog",children:t("div",{className:"min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain",children:t($a,{actorConversations:o.actorConversations,canGoBack:!1,chatDisplay:"popout",composerVisible:!0,conversationError:o.conversationError,onBack:()=>{},onNavigate:L,primaryMessages:o.messages,primaryRunning:o.running,selection:{type:"actor",id:e.id},view:a})})})]})}var ro=["all","active","visible","agent","script"],at={all:"Alle",active:"Aktive",visible:"Sichtbare",agent:"LLM-Agenten",script:"TypeScript"},Rr=e=>`ragents.orchestration.actor-header:v2:${e}`;function fl(e){if(e===null)return"visible";if(ro.some(a=>a===e))return e;throw new Error("Die gespeicherte Actor-Anzeige ist ung\xFCltig. Erlaubt sind all, active, visible, agent und script.")}var Mr=(e,a,o)=>e.id===a||o.has(`@${e.handle}`),tt=(e,a,o)=>e.kind!=="human"&&(a==="all"||(a==="active"?e.lifecycle?.kind!=="stopped":a==="visible"?o:e.kind===a)),Tr=ne({changeEvent:"ragents-actor-header-change",matchesKey:e=>e.startsWith("ragents.orchestration.actor-header:"),parse:fl,serialize:e=>e});function Na(e){return Tr.useValue(Rr(e))}function Dr(e,a){Tr.save(Rr(e),a)}var cl="min-w-0 max-w-full text-left font-semibold [overflow-wrap:anywhere]",Br=e=>e.kind==="human"?"Benutzer":e.kind==="agent"?"LLM-Agent":"TypeScript-Actor",so=e=>e.lifecycle?.kind==="running"?"Arbeitet":e.lifecycle?.kind==="stopped"?"Gestoppt":e.lifecycle?.kind==="idle"?"Bereit":"";function pl(e,a,o){let r=o.trim().toLocaleLowerCase("de-DE").split(/\s+/).filter(Boolean);return e.filter(s=>{let d=[`@${s.handle}`,s.displayName,s.kind,Br(s),s.lifecycle?.kind,so(s),a.has(s.id)?"Mini-App":""].join(" ").toLocaleLowerCase("de-DE");return r.every(l=>d.includes(l))})}function Fr({session:e}){let a=W().can("runs.inspect"),[o,r]=w(),s=q(()=>r(void 0),[]),d=Na(e.session.id),l=Ua(e.session.id),n=J(e.runView),i=D(()=>n?.actors.filter(m=>m.kind!=="human"&&(a||m.kind==="agent"))??[],[a,n]),f=n?we(n):void 0,c=q(m=>tt(m,d,Mr(m,f,l)),[d,l,f]);return O(()=>{o&&!i.some(m=>`${e.session.id}:${m.id}`===o&&c(m))&&s()},[i,s,o,e.session.id,c]),!n||i.length===0?null:t("nav",{"aria-label":"Actors des Runs",className:"flex min-w-0 flex-none items-stretch",children:i.map(m=>{let h=`${e.session.id}:${m.id}`;return t(Pr,{actor:m,onClose:s,onToggle:()=>r(C=>C===h?void 0:h),open:o===h,session:e,view:n,visible:c(m)},h)})})}var ml=["active","visible","all"];function ot({runId:e}){let a=W().can("runs.inspect"),o=Na(e),r=a?ro:ml,s=r[(r.indexOf(o)+1)%r.length],d=`Actor-Anzeige: ${at[o]}. Wechseln zu ${at[s]}`;return t(Ne,{as:"button","aria-label":d,className:"w-[120px] max-w-[120px] min-w-[120px] flex-[0_0_120px]",onClick:()=>Dr(e,s),title:d,type:"button",children:u(Ba,{children:[t(Fa,{children:"Anzeige"}),t(aa,{children:at[o]})]})})}function Nr({session:e,appActorIds:a,preferences:o,onPreferencesChange:r}){let[s,d]=w(!1),[l,n]=w(""),i=U(null),f=pe(),c=J(e.runView),m=c?.actors,h=D(()=>pl(m??[],a,l),[m,a,l]),C=q((L=!1)=>{d(!1),L&&i.current?.focus({preventScroll:!0})},[]);O(()=>{C(),n("")},[e.session.id,C]);let x=`Actors \xB7 ${m?.length??0}`;return u("div",{className:"flex h-full min-w-0 flex-none items-stretch",children:[u(Ne,{as:"button",ref:i,"aria-controls":s?f:void 0,"aria-expanded":s,"aria-label":x,title:x,onClick:()=>d(L=>!L),type:"button",children:[t(Se,{size:20}),t(aa,{children:"Actors"})]}),s&&u(oa,{open:!0,id:f,label:"Actors des Runs",closeLabel:"Actorliste schlie\xDFen",buttonRef:i,onClose:C,width:460,height:460,placement:"bottom",focusInput:!0,role:"region",children:[u("div",{className:"flex flex-none items-center gap-2.5 p-2.5",children:[t(te,{className:"flex-1","aria-label":"Actors durchsuchen",onChange:L=>n(L.target.value),placeholder:"Handle, Typ oder Status suchen ...",type:"search",value:l}),u("span",{className:"flex-none whitespace-nowrap text-[0.68rem] text-muted-foreground",role:"status",children:[h.length," von ",m?.length??0]})]}),t(gl,{actors:h,appActorIds:a,primaryActorId:c?.primaryActorId,onPreferencesChange:r,preferences:o}),t("p",{className:"flex-none border-t border-border-soft px-2.5 py-2.5 text-[0.68rem] text-muted-foreground",children:"Pers\xF6nliche Ansicht dieses Runs"})]})]})}function gl({actors:e,appActorIds:a,primaryActorId:o,onPreferencesChange:r,preferences:s}){return t("div",{className:"min-h-0 flex-1 overflow-auto overscroll-contain px-2.5",children:e.length===0?t("p",{className:"text-muted-foreground",children:"Keine passenden Actors."}):t("ul",{className:"list-none",children:e.map(d=>u("li",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2.5 border-b border-border-soft py-1.5",children:[u("div",{className:"grid min-w-0 gap-0.5 leading-[1.3]",children:[u("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[u("span",{className:cl,children:["@",d.handle]}),d.displayName!==d.handle&&t("span",{className:"min-w-0 max-w-full text-[0.7rem] [overflow-wrap:anywhere]",children:d.displayName})]}),u("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[0.66rem] text-muted-foreground",children:[t("span",{children:Br(d)}),so(d)&&t("span",{children:so(d)}),a.has(d.id)&&t("span",{className:"text-primary",children:"Mini-App"})]})]}),d.kind!=="human"&&u("label",{className:"flex cursor-pointer items-center gap-[5px] whitespace-nowrap text-[0.68rem]",children:[t("input",{"aria-label":`@${d.handle} auf der Fl\xE4che anzeigen`,checked:ta(d,a,s,o),onChange:l=>r({...s,actorVisibility:{...s.actorVisibility,[d.id]:l.target.checked}}),type:"checkbox"}),t("span",{children:"Fl\xE4che"})]})]},d.id))})})}function Er(e){return t(xl,{...e},e.session.session.id)}function xl({cardSections:e,surfaceElements:a,navigation:o,session:r,statusContainer:s,runToolbarContainer:d}){let l=W().can("runs.inspect"),n=ga();if(!n)throw new Error("Die Fl\xE4che braucht den Fl\xE4chen-Controller des Orchestrierungs-Plugins.");let i=U(void 0),f=J(r.runView);f!==void 0&&(i.current=f);let c=f??i.current,{programLayout:m,personalLayout:h,presentation:C,programBasis:x}=kr(r.session.id,c),[L,b]=w(),P=Ya(r.session.id),y=D(()=>new Set(a.flatMap(v=>v.select(r).flatMap(B=>B.anchorActorId?[B.anchorActorId]:[]))),[a,r]),R=D(()=>c?.actors.filter(v=>v.kind!=="human"&&(l?!ta(v,y,P,c.primaryActorId):v.kind==="script")).map(v=>v.id)??[],[l,c,y,P]),N=D(()=>a.flatMap(v=>v.select(r).filter(B=>B.visible!==!1).map(B=>`app:${B.id}`)),[a,r]),K=new Set([...N,...c?.actors.filter(v=>v.kind!=="human"&&v.lifecycle?.kind!=="stopped"&&(l||v.kind==="agent")).map(v=>`@${v.handle}`)??[]]),V=D(()=>h===null&&m.layout?.root===void 0?ja([...N,...c?.actors.filter(v=>v.kind!=="human"&&v.lifecycle?.kind!=="stopped"&&!R.includes(v.id)).map(v=>`@${v.handle}`)??[]]):null,[h,m,N,c,R]),k=C.root??V,M=ua(k).some(v=>K.has(v)),G=D(()=>new Set(ua(k)),[k]);O(()=>gt(r.session.id,G),[r.session.id,G]),O(()=>()=>gt(r.session.id,void 0),[r.session.id]);let S=Ja({view:c,startup:r.startup,connected:r.connected,running:r.running,error:r.conversationError}),j=U(null),$=!M&&S!==void 0,ie=q(()=>{let v=j.current;if(!v)return;let B=v.getBoundingClientRect(),_=document.getElementById("workspace-panel")?.getBoundingClientRect(),H=_?Math.min(B.right,_.right)-Math.max(B.left,_.left):0;return{width:B.width-Math.max(0,H),height:B.height}},[]);O(()=>{let v=j.current;if(!v)return;let B=new ResizeObserver(()=>{let H=ie();H&&v.style.setProperty("--surface-visible-width",`${H.width}px`)});B.observe(v);let _=document.getElementById("workspace-panel");return _&&B.observe(_),()=>B.disconnect()},[ie]);let Q=q(v=>{n.acceptSelection(v)},[n]),fe=v=>{try{Qa(r.session.id,{root:v,programBasis:x}),b(void 0)}catch(B){b(B instanceof Error?B.message:String(B))}};return u("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 overflow-clip","data-view":"tiled",children:[h&&t(oo,{container:s,label:"Fl\xE4che",order:20,children:t("button",{className:_a,onClick:()=>Qa(r.session.id,null),title:"Eigene Anordnung zur\xFCcksetzen und der Programmanordnung folgen",type:"button",children:"Programmvorgabe \xFCbernehmen"})}),d&&na(u(X,{children:[t(ot,{runId:r.session.id}),l&&t(Nr,{session:r,appActorIds:y,preferences:P,onPreferencesChange:v=>et(r.session.id,v)})]}),d),u("div",{"aria-label":"Fl\xE4che",className:"relative min-h-0 min-w-0 flex-[1_1_360px] overflow-clip bg-[image:var(--surface-backdrop)]",ref:j,children:[t(hl,{}),(m.error||L)&&t("p",{className:"absolute inset-x-2 top-2 z-10 bg-secondary p-3 text-destructive",role:"alert",children:m.error||L}),c&&!$&&t("div",{className:"absolute inset-y-0 left-0 w-[var(--surface-visible-width,100%)] overflow-hidden",children:t(Cr,{root:k,onChange:fe,surfaceElements:a,cardSections:e,session:r,view:c,navigation:o,onSelect:Q,selected:n.selection})}),$&&t(Sr,{state:S})]})]})}function hl(){return u("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 size-full opacity-10",preserveAspectRatio:"none",viewBox:"0 0 180 180",children:[t("filter",{id:"surface-grain",children:t("feTurbulence",{baseFrequency:".76",numOctaves:"3",stitchTiles:"stitch",type:"fractalNoise"})}),t("path",{d:"M0 0h180v180H0z",fill:"#887890",filter:"url(#surface-grain)",opacity:".32"})]})}var lo=p("@ragents/web/run-panel/host","useCenterElements");var rt=p("@ragents/web/run-panel/host","useRunPanelHost");var qr=(e,a)=>{let o=e.actors.filter(d=>d.kind!=="human"&&(a||d.kind==="agent")),r=we(e);return[...o.filter(d=>d.id===r),...o.filter(d=>d.id!==r)]},Or=(e,a)=>{let o=[],r=[];for(let s of e)(s.id===a.primaryId||s.id===a.selectedId||tt(s,a.mode,a.onStage(s))?o:r).push(s);return{shown:o,hidden:r}},Ea=(e,a)=>e.inputs.filter(o=>o.actorId===a&&o.lifecycle.kind==="pending").length,Ll=(e,a)=>e.actions.filter(o=>o.status==="pending"&&o.askedBy===a).length,Hr=(e,a,o)=>o||e!==void 0&&a.anchorActorId!==void 0&&Ll(e,a.anchorActorId)>0;var Il=4,Ur=12,uo=90,Cl={running:["arbeitet","arbeiten"],input:["wartet auf Eingabe","warten auf Eingabe"],waiting:["wartet","warten"],stopped:["gestoppt","gestoppt"]},Sl=["running","input","waiting","stopped"],qa=e=>e.toLocaleLowerCase("de-DE"),wl=e=>{let a=e.split(`
6
- `).map(s=>s.replace(/\s+/g," ").trim()).find(s=>s!=="")??"";if(a.length<=uo)return a;let o=a.slice(0,uo-3),r=o.lastIndexOf(" ");return`${(r>uo/2?o.slice(0,r):o).trimEnd()}...`},no=(e,a)=>a.lifecycle?.kind==="stopped"?"stopped":e.actions.some(o=>o.status==="pending"&&o.askedBy===a.id)?"input":a.lifecycle?.kind==="running"?"running":"waiting",lt=(e,a=1)=>Cl[e][a===1?0:1],Vr=(e,a)=>{let o=new Map;for(let r of a.map(s=>no(e,s)))o.set(r,(o.get(r)??0)+1);return Sl.flatMap(r=>{let s=o.get(r)??0;return s>0?[`${s} ${lt(r,s)}`]:[]}).join(", ")},zr=e=>{let a=new Map;for(let o of e.inputs){if(o.subscriptionId!==null||o.presentation==="background"||o.content.trim()==="")continue;let r=a.get(o.actorId);(!r||o.sequence<r.sequence)&&a.set(o.actorId,{sequence:o.sequence,content:o.content})}return o=>{let r=o.description?.trim();if(r)return r;let s=a.get(o.id);if(s)return wl(s.content);let d=o.displayName.trim();return d!==""&&qa(d)!==qa(o.handle)?d:void 0}},Gr=(e,a,o)=>{let r=new Set([o.id]),s=o.createdBy;for(;s!==void 0&&!r.has(s);){if(a.has(s))return s;let d=e.get(s);if(!d||d.kind==="human")return null;r.add(s),s=d.createdBy}return null},bl=e=>qa(e).replace(/-\d+$/,"").split(/[-_.]/)[0]??"",yl=e=>{let a=e[0]??"",o=e.reduce((l,n)=>{let i=0;for(;i<l&&n[i]===a[i];)i+=1;return i},a.length),r=a.slice(0,o),s=r.search(/[-_.][^-_.]*$/);return`@${/[-_.]$/.test(r)||e.includes(r)||s<0?r:r.slice(0,s+1)}*`},io=(e,a)=>{let o=new Map(e.actors.map(i=>[i.id,i])),r=new Set(a.map(i=>i.id)),s=we(e),d=new Map;for(let i of a){let f=Gr(o,r,i);d.set(f,[...d.get(f)??[],i])}let l=i=>({kind:"actor",actor:i,children:n(i.id)}),n=i=>{let f=d.get(i)??[],c=i===null?[...f.filter(x=>x.id===s),...f.filter(x=>x.id!==s)]:f,m=x=>x.id===s?null:`${i??""}/${x.kind}/${bl(x.handle)}`,h=new Map;for(let x of c){let L=m(x);L!==null&&h.set(L,[...h.get(L)??[],x])}let C=new Set;return c.flatMap(x=>{let L=m(x),b=L===null?void 0:h.get(L);return L===null||!b||b.length<Il?[l(x)]:C.has(L)?[]:(C.add(L),[{kind:"group",key:L,label:yl(b.map(P=>P.handle)),members:b.map(l)}])})};return n(null)},fo=(e,a,o,r)=>{let s=qa(o).trim().split(/\s+/).filter(Boolean);if(s.length===0)return[...a];let d=new Map(e.actors.map(i=>[i.id,i])),l=new Set(a.map(i=>i.id)),n=new Set;for(let i of a){let f=qa(`@${i.handle} ${i.displayName} ${r(i)??""}`);if(!s.every(m=>f.includes(m)))continue;let c=i;for(;c&&!n.has(c.id);){n.add(c.id);let m=Gr(d,l,c);c=m===null?void 0:d.get(m)}}return a.filter(i=>n.has(i.id))},st=(e,a)=>e.kind==="actor"?e.actor.id===a||e.children.some(o=>st(o,a)):e.members.some(o=>st(o,a));var Wr="flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-accent aria-current:bg-primary/10 focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-2",_r="ml-[18px] list-none border-l border-border-soft pl-1",kl={agent:"bg-glass-agent",primary:"bg-glass-primary",script:"bg-glass-script",app:"bg-glass-app"},Al={running:"text-primary",input:"text-warning",waiting:"text-muted-foreground",stopped:"text-muted-foreground/70"},vl=(e,a)=>a?e.kind==="agent"?"LLM-Agent":"TypeScript-Actor":"Agent";function co({actor:e,className:a,view:o}){let r=He(o,e);return t("span",{className:Y("grid flex-none place-items-center rounded-full text-foreground [&>svg]:size-3",kl[r],a),children:e.lifecycle?.kind==="running"?t(ve,{"aria-hidden":!0,className:"size-3"}):r==="primary"?t(ge,{}):e.kind==="agent"?t(Se,{}):t(qe,{})})}function dt({className:e,nodes:a,...o}){return t("ul",{className:Y("list-none",e),children:a.map(r=>r.kind==="actor"?t(Xr,{node:r,...o},r.actor.id):t(Rl,{node:r,...o},r.key))})}function Xr({node:e,...a}){return u("li",{children:[t(Pl,{actor:e.actor,...a}),e.children.length>0&&t(dt,{className:_r,nodes:e.children,...a})]})}function Pl({actor:e,onPick:a,selectedId:o,summary:r,technical:s,view:d}){let l=Ea(d,e.id),n=no(d,e),i=r(e),f=e.displayName.trim(),c=f!==""&&f.toLocaleLowerCase("de-DE")!==e.handle.toLocaleLowerCase("de-DE")&&f!==i,m=e.id===o;return u("button",{"aria-current":m||void 0,className:Wr,"data-actor-handle":e.handle,onClick:()=>a(e),title:`@${e.handle}, ${vl(e,s)}, ${lt(n)}. Nachrichten an @${e.handle} richten`,type:"button",children:[t(co,{actor:e,className:"size-5",view:d}),u("span",{className:"grid min-w-0 flex-1",children:[u("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[u("span",{className:"truncate font-semibold",children:["@",e.handle]}),c&&t("span",{className:"min-w-0 truncate text-[0.66rem] text-muted-foreground",children:f})]}),i&&t("span",{className:"truncate text-[0.66rem] text-muted-foreground",children:i})]}),l>0&&t(se,{className:"h-4 min-w-4 px-1 text-[0.6rem]",variant:"secondary",children:l}),t("span",{className:Y("flex-none text-[0.66rem]",Al[n]),"data-addressee-status":n,children:lt(n)})]})}function Rl({node:e,...a}){let{onToggle:o,openByDefault:r,selectedId:s,toggled:d,view:l}=a,n=e.members.map(h=>h.actor),i=(r||st(e,s))!==d.has(e.key),f=Vr(l,n),c=n.some(h=>h.lifecycle?.kind==="running"),m=n.reduce((h,C)=>h+Ea(l,C.id),0);return u("li",{children:[u("button",{"aria-expanded":i,className:Wr,"data-addressee-group":e.label,onClick:()=>o(e.key),title:`${e.label}: ${n.length} gleichartige Actors, ${f}. Klick ${i?"klappt die Gruppe zu":"zeigt alle"}`,type:"button",children:[t("span",{className:"grid size-5 flex-none place-items-center text-muted-foreground",children:t(Sa,{"aria-hidden":!0,className:Y("size-3.5 transition-transform",i&&"rotate-90")})}),u("span",{className:"grid min-w-0 flex-1",children:[u("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[t("span",{className:"truncate font-semibold",children:e.label}),u("span",{className:"flex-none text-[0.66rem] text-muted-foreground",children:[n.length," Actors"]})]}),t("span",{className:"truncate text-[0.66rem] text-muted-foreground",children:f})]}),c&&t(ve,{"aria-hidden":!0,className:"size-3 flex-none text-primary"}),m>0&&t(se,{className:"h-4 min-w-4 px-1 text-[0.6rem]",variant:"secondary",children:m})]}),i&&t("ul",{className:_r,children:e.members.map(h=>t(Xr,{node:h,...a},h.actor.id))})]})}var Ml="flex h-7 min-w-[70px] max-w-[220px] flex-[0_1_auto] cursor-pointer items-center gap-1.5 rounded-full border border-border bg-background pr-2 pl-1 text-[0.72rem] font-semibold text-foreground hover:bg-accent aria-expanded:border-primary focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:outline-offset-1",Tl="flex h-7 min-w-0 flex-[0_1_auto] cursor-pointer items-center gap-1.5 rounded-md px-1.5 text-[0.7rem] text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:outline-offset-1";function Kr({hidden:e,onOpenChange:a,onReveal:o,onSelect:r,runId:s,selected:d,shown:l,technical:n,view:i}){let[f,c]=w(!1),[m,h]=w(""),[C,x]=w(!1),[L,b]=w(()=>new Set),P=U(null),y=pe(),R=q(H=>{c(H),a(H)},[a]),N=q((H=!1)=>{R(!1),h(""),H&&P.current?.focus({preventScroll:!0})},[R]),K=q(H=>{H?.querySelector("[aria-current=true]")?.scrollIntoView({block:"nearest"})},[]),V=D(()=>[...l,...e].filter(H=>H.lifecycle?.kind==="running"&&H.id!==d.id),[e,d.id,l]),k=D(()=>zr(i),[i]),M=m.trim()!=="",G=D(()=>io(i,fo(i,l,m,k)),[m,l,k,i]),S=D(()=>fo(i,e,m,k),[e,m,k,i]),j=D(()=>io(i,S),[S,i]),$=C||M&&S.length>0,ie=q(H=>b(Le=>{let ae=new Set(Le);return ae.delete(H)||ae.add(H),ae}),[]),Q=(H,Le)=>{(Le?o:r)(H),N(!0)},fe=V.map(H=>`@${H.handle} arbeitet`).join(", "),v=V.length>0?Ea(i,V[0].id):0,B={onToggle:ie,openByDefault:M,selectedId:d.id,summary:k,technical:n,toggled:L,view:i},_="px-1.5 py-1";return u(X,{children:[u("button",{"aria-controls":f?y:void 0,"aria-expanded":f,"aria-haspopup":"dialog",className:Ml,onClick:()=>R(!f),ref:P,title:`Adressat: @${d.handle}. Klick w\xE4hlt einen anderen Actor`,type:"button",children:[t(co,{actor:d,className:"size-5",view:i}),u("span",{className:"truncate",children:["@",d.handle]}),t(Qe,{"aria-hidden":!0,className:"size-3 flex-none text-muted-foreground"})]}),V.length>0&&u("button",{className:Tl,onClick:()=>R(!f),title:fe,type:"button",children:[t(ve,{"aria-hidden":!0,className:"size-3 flex-none"}),u("span",{className:"truncate in-data-[compact=true]:hidden",children:["@",V[0].handle]}),v>0&&t(se,{className:"h-4 min-w-4 px-1 text-[0.6rem]",variant:"secondary",children:v}),V.length>1&&u("span",{className:"flex-none",children:["+",V.length-1]})]}),f&&u(oa,{buttonRef:P,closeLabel:"Adressat schlie\xDFen",height:460,id:y,label:"Adressat",onClose:N,open:!0,placement:"top",role:"dialog",width:"available",children:[l.length+e.length>Ur&&t("div",{className:"flex-none border-b border-border-soft px-2.5 py-1.5",children:t(te,{"aria-label":"Actors durchsuchen",className:"h-7",onChange:H=>h(H.target.value),placeholder:"Handle oder Aufgabe suchen ...",type:"search",value:m})}),u("div",{className:"min-h-0 flex-1 overflow-auto overscroll-contain",ref:K,children:[t(dt,{className:_,nodes:G,onPick:H=>Q(H,!1),...B}),M&&G.length===0&&S.length===0&&t("p",{className:"px-3.5 py-2 text-muted-foreground",children:"Kein Actor passt zur Suche."}),e.length>0&&(!M||S.length>0)&&u("div",{className:"border-t border-border-soft",children:[u("button",{"aria-expanded":$,className:"flex w-full cursor-pointer items-center justify-between gap-2 px-3.5 py-2 text-left text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-2",onClick:()=>x(!$),type:"button",children:[u("span",{children:[e.length," ausgeblendete Actors"]}),t(Qe,{"aria-hidden":!0,className:Y("size-3.5 flex-none transition-transform",$&&"rotate-180")})]}),$&&t(dt,{className:_,nodes:j,onPick:H=>Q(H,!0),...B})]})]}),t("div",{className:"flex flex-none items-stretch border-t border-border-soft",children:t(ot,{runId:s})})]})]})}var mo=Object.freeze({sideWidth:900,openDelay:160,closeDelay:150}),go="ragents.orchestration.run-panel-settings",ra=Object.freeze({sideWidth:{min:400,max:4e3},openDelay:{min:0,max:5e3},closeDelay:{min:0,max:1e4}}),po=(e,a)=>typeof e=="number"&&Number.isInteger(e)&&e>=a.min&&e<=a.max;function Dl(e){if(e===null)return mo;let a=JSON.parse(e);if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(o=>!["sideWidth","openDelay","closeDelay"].includes(o))||!("sideWidth"in a)||!po(a.sideWidth,ra.sideWidth)||!("openDelay"in a)||!po(a.openDelay,ra.openDelay)||!("closeDelay"in a)||!po(a.closeDelay,ra.closeDelay))throw new Error("Die Einstellungen des Run-Panels sind ung\xFCltig: Breite 400 bis 4000 Pixel, Verz\xF6gerungen 0 bis 5000 beziehungsweise 10000 Millisekunden, ganze Zahlen.");return a}var $r=ne({changeEvent:"ragents-run-panel-settings-change",matchesKey:e=>e===go,parse:Dl,serialize:JSON.stringify});function ut(){return $r.useValue(go)}function Zr(e){$r.save(go,e)}var Bl=1500,Jr=e=>e.some(a=>a.role==="user"||a.role==="action"||a.role==="assistant"&&(a.text.trim()!==""||(a.attachments?.length??0)>0));function jr(e,a,o){let[r,s]=w(o),[d,l]=w(),n=a&&e?.kind==="working"?e:void 0,i=n?.title,f=n?.detail;return O(()=>{o&&s(!0)},[o]),O(()=>{if(i!==void 0&&f!==void 0){l({kind:"working",title:i,detail:f});return}let c=window.setTimeout(()=>l(void 0),Bl);return()=>window.clearTimeout(c)},[f,i]),o||r?void 0:e??d}var xo=280,es=380,Fl=300,Nl=Object.freeze({element:null,actor:null,chat:"side",chatWidth:es,sheetExpandedHeight:null}),as=e=>`ragents.orchestration.run-panel:${e}`,Qr=e=>e===null||typeof e=="string",Yr=e=>e===void 0||e==="side"||e==="auto"?"side":e==="chat"?"chat":e==="bottom"||e==="floating"||e==="docked"?"bottom":void 0;function El(e){if(e===null)return Nl;let a=JSON.parse(e);if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(r=>!["element","stageHeight","actor","chat","chatWidth","sheetExpandedHeight","sheetPeekExtra"].includes(r))||!("element"in a)||!Qr(a.element)||!("actor"in a)||!Qr(a.actor)||Yr("chat"in a?a.chat:void 0)===void 0||"chatWidth"in a&&(typeof a.chatWidth!="number"||!Number.isFinite(a.chatWidth)||a.chatWidth<xo)||"sheetExpandedHeight"in a&&a.sheetExpandedHeight!==null&&(typeof a.sheetExpandedHeight!="number"||!Number.isFinite(a.sheetExpandedHeight)||a.sheetExpandedHeight<=0)||"sheetPeekExtra"in a&&(typeof a.sheetPeekExtra!="number"||!Number.isFinite(a.sheetPeekExtra)||a.sheetPeekExtra<0))throw new Error("Der gespeicherte Panelzustand ist ung\xFCltig.");let o=a;return{element:o.element,actor:o.actor,chat:Yr(o.chat)??"side",chatWidth:o.chatWidth??es,sheetExpandedHeight:o.sheetExpandedHeight??null}}var ts=({chat:e,hasElement:a,narrow:o})=>!a||e==="chat"?"full":!o&&e==="side"?"side":"floating",ho=(e,a)=>Math.max(xo,Math.min(Math.round(e),Math.max(xo,a-Fl))),os=ne({changeEvent:"ragents-run-panel-change",matchesKey:e=>e.startsWith("ragents.orchestration.run-panel:"),parse:El,serialize:JSON.stringify});function rs(e){return os.useValue(as(e))}function ss(e,a){os.save(as(e),a)}var Lo=(e,a=160)=>{let o=e.trim().split(/\r?\n/).find(r=>r.trim()!=="")??"";return o.length>a?`${o.slice(0,a-1)}\u2026`:o},ls=(e,a)=>e.role==="user"?"Du":e.sender??`@${a}`;function ds(e,a,o){let r=e[e.length-1],s=[...e].reverse().find(l=>l.role==="action"&&l.action?.status===void 0);if(s)return{kind:"waiting",text:`Wartet auf Eingabe: ${Lo(s.text)||"Antwort erwartet"}`};if(a)return r?.role==="thinking"&&!r.closed?{kind:"working",text:`@${o} denkt ...`}:r?.role==="tool"&&r.tool&&r.tool.result===void 0?{kind:"working",text:`@${o} nutzt ${r.tool.name} ...`}:r?.role==="assistant"&&!r.closed&&r.text.trim()!==""?{kind:"working",text:`${ls(r,o)} antwortet: ${Lo(r.text)}`}:{kind:"working",text:`@${o} arbeitet ...`};let d=[...e].reverse().find(l=>(l.role==="user"||l.role==="assistant")&&l.text.trim()!=="");return d?{kind:"idle",text:`${ls(d,o)}: ${Lo(d.text)}`}:{kind:"idle",text:"Noch keine Nachrichten."}}var ql=220,Ol="flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-shell px-2 py-1.5",Hl="flex h-7 max-w-[200px] flex-none cursor-pointer items-center gap-1.5 rounded-full border border-border bg-card pr-2 pl-1 text-[0.72rem] font-semibold text-foreground hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:outline-offset-1 aria-pressed:border-primary aria-pressed:bg-primary/10",Ul={full:"relative flex min-h-0 min-w-0 flex-1 flex-col",side:"relative flex min-h-0 min-w-0 flex-col",floating:"absolute inset-x-2.5 bottom-0 z-20 flex flex-col overflow-hidden rounded-t-2xl border border-b-0 border-border bg-card shadow-[0_-16px_60px_#00000080] transition-[height] duration-300 ease-[cubic-bezier(.32,.72,0,1)] motion-reduce:transition-none"},Vl="rounded-none border-0 bg-transparent",zl="aria-pressed:bg-accent aria-pressed:text-primary",Gl=[{Icon:ya,label:"Nur Chat",mode:"chat",title:"Nur Chat: der Chat f\xFCllt das Run-Panel, die Mini-App tritt zur\xFCck"},{Icon:ka,label:"Chat unten",mode:"bottom",title:"Chat unten: das Sheet \xFCber der Mini-App"},{Icon:Aa,label:"Chat rechts",mode:"side",title:"Chat rechts: neben der Mini-App"}];function us(e){return t(Wl,{...e},e.session.session.id)}function Wl({surfaceElements:e,cardSections:a,navigation:o,renderChat:r,session:s,toolbarContainer:d}){let l=s.session.id,n=W().can("runs.inspect"),i=rt(),f=J(s.runView),c=rs(l),m=lo(l),h=U(null),C=U(null),x=U(null),L=U(null),[b,P]=w(c.chatWidth),[y,R]=w(0),[N,K]=w(!1),V=ut();O(()=>P(c.chatWidth),[c.chatWidth]),O(()=>{let A=h.current;if(!A)return;let re=new ResizeObserver(([Ce])=>R(Ce.contentRect.width));return re.observe(A),()=>re.disconnect()},[]);let k=q(A=>ss(l,{...c,...A}),[l,c]),M=D(()=>e.flatMap(({Element:A,select:re})=>re(s).filter(Ce=>Ce.visible!==!1).map(Ce=>({Element:A,definition:Ce}))),[e,s]),G=M.find(A=>A.definition.id===c.element)??M[0],S=jr(Ja({view:f,startup:s.startup,connected:s.connected,running:s.running,error:s.conversationError}),s.connected,M.length>0||Jr(s.messages)),j=S?t(Yl,{state:S}):void 0,$=D(()=>f?qr(f,n):[],[n,f]),ie=Na(l),Q=Ya(l),fe=D(()=>new Set(M.flatMap(({definition:A})=>A.anchorActorId?[A.anchorActorId]:[])),[M]),v=f?we(f):void 0,B=$.find(A=>A.id===c.actor)??$.find(A=>A.id===v)??$[0],{shown:_,hidden:H}=D(()=>Or($,{mode:ie,primaryId:v,selectedId:B?.id,onStage:A=>A.id===v||ta(A,fe,Q,v)}),[$,fe,ie,Q,v,B?.id]),Le=()=>h.current?.clientWidth??Number.POSITIVE_INFINITY,ae=q(A=>k({actor:A.id}),[k]),sa=q(A=>{et(l,{...Q,actorVisibility:{...Q.actorVisibility,[A.id]:!0}}),k({actor:A.id})},[Q,l,k]),Oa=q(A=>{let re=A.type==="actor"?$.find(Ce=>Ce.id===A.id):void 0;re&&ae(re)},[$,ae]),ye=B===void 0||B.id===v,I=y<V.sideWidth,g=ts({chat:c.chat,hasElement:G!==void 0,narrow:I}),T=Xl(g==="floating",C,x,N,V.openDelay),F=Kl(g==="floating",C,x,L,B?.id),ue=Math.max(F.minimum,Math.min(c.sheetExpandedHeight??F.maximum,F.maximum)),Z=$l(g==="floating",C,x,T,F,ue,A=>k({sheetExpandedHeight:Math.round(A)})),ce=U(null);O(()=>{if(g!=="floating"||!T.expanded)return;let A=ce.current;if(!A)return;let re=()=>{A.scrollTop=A.scrollHeight};re();let Ce=window.setTimeout(re,320);return()=>window.clearTimeout(Ce)},[g,T.expanded]);let ke=D(()=>{if(g!=="floating"||!B)return;let A=ye?s.messages:s.actorConversations?.[B.id]??[],re=ye?s.connected&&(s.running||Vt(s.runView,l)):B.lifecycle?.kind==="running";return ds(A,re,B.handle)},[g,ye,l,B,s.actorConversations,s.connected,s.messages,s.runView,s.running]),la=f&&B&&t(Kr,{hidden:H,onOpenChange:K,onReveal:sa,onSelect:ae,runId:l,selected:B,shown:_,technical:n,view:f}),Ie=G&&d&&na(t(_l,{narrow:I,onChange:A=>k({chat:A}),selected:c.chat,sideWidth:V.sideWidth}),d),bs=ye||!f||!B?r({chatElementClassName:Vl,chatScrollerRef:A=>{ce.current=A},notice:j,toolbarLeft:la}):t(Ql,{actor:B,cardSections:a,navigation:o,notice:j,onNavigate:Oa,session:s,toolbarLeft:la,view:f});return u("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-app","data-run-panel":"run",ref:h,children:[Ie,g!=="full"&&M.length>1&&t("nav",{"aria-label":"Mini-Apps des Runs",className:Ol,children:M.map(({definition:A})=>t(Zl,{centered:m.has(A.id),definition:A,onSelect:()=>m.has(A.id)?i.openInCenter(l,A.id,A.title??A.id):k({element:A.id}),selected:A.id===G?.definition.id,session:s,view:f},A.id))}),u("div",{className:Y("relative min-h-0 min-w-0 flex-1",g==="side"?"grid":"flex flex-col"),"data-chat-layout":g,style:g==="side"?{gridTemplateColumns:`minmax(0,1fr) auto ${b}px`}:void 0,children:[g!=="full"&&G&&t(Jl,{centered:m.has(G.definition.id),element:G,navigation:o,peek:g==="floating"?F.minimum:0,runId:l,session:s}),g==="side"&&t(jl,{onChange:A=>P(ho(A,Le())),onCommit:A=>k({chatWidth:ho(A,Le())}),value:b}),g==="floating"&&t("div",{"aria-hidden":!0,className:"absolute inset-0 z-[15] bg-backdrop opacity-0 transition-opacity duration-300 pointer-events-none data-expanded:pointer-events-auto data-expanded:opacity-100 motion-reduce:transition-none","data-expanded":T.expanded||void 0,onClick:T.close}),u("section",{"aria-label":"Chat",className:Y(Ul[g],g==="floating"&&"[&:not([data-expanded])_[data-slot=card-sections]]:hidden [&[data-sheet-resizing]_[data-slot=card-sections]]:hidden"),"data-expanded":g==="floating"&&T.expanded?!0:void 0,"data-sheet-resizing":Z.height!==void 0||void 0,"data-view":ye?"chat":"actor-chat",onBlurCapture:g==="floating"?()=>T.closeLater(ql):void 0,onFocusCapture:g==="floating"?A=>{A.target!==x.current&&T.open()}:void 0,onPointerEnter:g==="floating"?A=>{A.pointerType==="mouse"&&T.openLater()}:void 0,onPointerLeave:g==="floating"?()=>T.closeLater(V.closeDelay):void 0,ref:C,style:g==="floating"?{height:Z.height??(T.expanded?ue:F.minimum),transition:Z.height!==void 0?"none":void 0}:void 0,children:[g==="floating"&&t("button",{"aria-expanded":T.expanded,"aria-label":"H\xF6he des ausgeklappten Chats","aria-orientation":"horizontal","aria-valuemin":F.minimum,"aria-valuemax":F.maximum,"aria-valuenow":Math.round(Z.height??ue),className:"flex h-3 w-full flex-none cursor-row-resize touch-none items-center justify-center outline-none select-none [&:hover>span]:bg-foreground [&:focus-visible>span]:bg-foreground [&:focus-visible>span]:ring-2 [&:focus-visible>span]:ring-ring/60","data-run-panel":"sheet-grip",onClick:Z.onClick,onKeyDown:Z.onKeyDown,onPointerDown:Z.onPointerDown,onPointerMove:Z.onPointerMove,onPointerUp:Z.onPointerUp,onPointerCancel:Z.onPointerCancel,onLostPointerCapture:Z.onPointerCancel,ref:x,role:"separator",title:`Ziehen: ausgeklappte H\xF6he einstellen. Klicken: ${T.expanded?"Chat absenken":"Chat hochschieben"}.`,type:"button",children:t("span",{"aria-hidden":!0,className:"h-1 w-9 rounded-full bg-border-strong transition-colors"})}),ke&&u("button",{className:Y("flex h-6 w-full flex-none cursor-pointer items-center gap-2 px-[var(--qsl-chat-horizontal-padding,24px)] text-left text-[0.7rem] transition-opacity duration-200 in-data-expanded:pointer-events-none in-data-expanded:opacity-0 motion-reduce:transition-none",ke.kind==="waiting"?"text-warning":"text-muted-foreground"),onClick:T.toggle,ref:L,title:ke.text,type:"button",children:[ke.kind==="working"&&t(ve,{"aria-hidden":!0,className:"size-3 flex-none"}),t("span",{className:"truncate",children:ke.text})]}),bs]})]})]})}function _l({narrow:e,onChange:a,selected:o,sideWidth:r}){return t("div",{"aria-label":"Ansicht des Run-Panels",className:"flex flex-none items-center gap-0.5 self-center rounded-lg border border-border bg-card p-0.5",role:"group",children:Gl.map(({Icon:s,label:d,mode:l,title:n})=>{let i=l==="side"&&e;return t(z,{"aria-label":d,"aria-pressed":o===l,className:zl,disabled:i,onClick:()=>a(l),size:"icon-sm",title:i?`Chat bleibt unten, solange das Panel schmaler als ${r} Pixel ist`:n,variant:"ghost",children:t(s,{})},l)})})}function Xl(e,a,o,r,s){let[d,l]=w(!1),[n,i]=w(!1),f=U({held:n,blocked:r}),c=U(!1),m=U(void 0);O(()=>{f.current={held:n,blocked:r}},[r,n]);let h=q(()=>window.clearTimeout(m.current),[]),C=q(()=>{c.current||(h(),l(!0))},[h]),x=q(()=>{c.current||(h(),m.current=window.setTimeout(()=>{c.current||l(!0)},s))},[h,s]),L=q(N=>{c.current||(h(),m.current=window.setTimeout(()=>{c.current||f.current.held||f.current.blocked||document.activeElement!==o.current&&a.current?.contains(document.activeElement)||l(!1)},N))},[h,o,a]),b=q(()=>{h(),i(!1),l(!1),document.activeElement instanceof HTMLElement&&a.current?.contains(document.activeElement)&&document.activeElement.blur()},[h,a]),P=q(()=>{if(d){b();return}i(!0),C()},[b,d,C]),y=q(()=>{h(),c.current=!0},[h]),R=q(N=>{h(),c.current=!1,l(N?.expanded??!1),i(N?.held??!1)},[h]);return O(()=>{e||b()},[e,b]),O(()=>h,[h]),O(()=>{if(!e||!d)return;let N=K=>{K.key==="Escape"&&!c.current&&!f.current.blocked&&b()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e,b,d]),{expanded:d,held:n,open:C,openLater:x,closeLater:L,close:b,toggle:P,pauseResize:y,finishResize:R}}function Kl(e,a,o,r,s){let[d,l]=w({minimum:0,maximum:0,scale:1});return We(()=>{if(!e)return;let n=a.current,i=o.current,f=r.current,c=n?.querySelector('[data-chat="composer"]'),m=n?.parentElement;if(!n||!i||!c||!m)throw new Error("Das Sheet des Panels findet Griff, Eingabe oder Rahmen nicht.");let h=()=>{let x=getComputedStyle(n),L=n.getBoundingClientRect().width;if(L===0)return;let b=L/Number.parseFloat(x.width),P=Math.ceil((i.getBoundingClientRect().height+(f?.getBoundingClientRect().height??0)+c.getBoundingClientRect().height)/b+Number.parseFloat(x.borderTopWidth)+Number.parseFloat(x.borderBottomWidth)),y=Math.max(P,Math.floor(m.getBoundingClientRect().height/b*.9));l(R=>R.minimum===P&&R.maximum===y&&R.scale===b?R:{minimum:P,maximum:y,scale:b})},C=new ResizeObserver(h);return C.observe(c),C.observe(i),C.observe(m),f&&C.observe(f),h(),()=>C.disconnect()},[e,s,o,a,r]),d}function $l(e,a,o,r,s,d,l){let[n,i]=w(),f=U(void 0),c=U(!1),m=x=>{let L=f.current;if(!L)return;f.current=void 0,c.current=L.moved||!x;let b=o.current;b?.hasPointerCapture(L.pointerId)&&b.releasePointerCapture(L.pointerId),x&&L.moved&&l(L.height),r.finishResize(x&&L.moved?{expanded:!0,held:L.held}:L),i(void 0)},h=r.finishResize;O(()=>{e||(f.current=void 0,i(void 0),h())},[e,h]);let C=x=>Math.max(s.minimum,Math.min(x,s.maximum));return{height:n,onClick:x=>{let L=c.current&&x.detail>0;c.current=!1,!L&&r.toggle()},onPointerDown:x=>{if(x.button!==0||f.current||!a.current)return;x.preventDefault();let L=a.current.getBoundingClientRect().height/s.scale;f.current={pointerId:x.pointerId,startY:x.clientY,startHeight:L,height:L,moved:!1,expanded:r.expanded,held:r.held},c.current=!1,r.pauseResize(),i(L),x.currentTarget.setPointerCapture(x.pointerId),x.currentTarget.focus({preventScroll:!0})},onPointerMove:x=>{let L=f.current;if(!L||L.pointerId!==x.pointerId)return;let b=(L.startY-x.clientY)/s.scale;!L.moved&&Math.abs(b)<3||(L.moved=!0,L.height=C(L.startHeight+b),i(L.height))},onPointerUp:x=>{f.current?.pointerId===x.pointerId&&m(!0)},onPointerCancel:x=>{f.current?.pointerId===x.pointerId&&m(!1)},onKeyDown:x=>{if(x.key==="Escape"&&f.current){x.preventDefault(),x.stopPropagation(),m(!1);return}let L=x.key==="ArrowUp"?d+24:x.key==="ArrowDown"?d-24:x.key==="Home"?s.minimum:x.key==="End"?s.maximum:void 0;L===void 0||f.current||(x.preventDefault(),r.finishResize({expanded:!0,held:r.held}),l(C(L)))}}}function Zl({centered:e,definition:a,onSelect:o,selected:r,session:s,view:d}){let l=da(),n=a.title??a.id,i=Hr(d,a,l?.needsAnswer(s,a.id)??!1);return u("button",{"aria-pressed":r&&!e,className:Hl,"data-tone":"app",onClick:o,title:e?`${n} liegt in der Mitte. Klick holt das Fenster nach vorn.`:`Mini-App ${n} anzeigen`,type:"button",children:[t("span",{className:"grid size-5 flex-none place-items-center rounded-full bg-glass-app text-foreground [&>svg]:size-3",children:t(Oe,{})}),t("span",{className:"truncate",children:n}),i&&t("span",{"aria-label":"Antwort erwartet",className:"grid size-4 flex-none place-items-center rounded-full bg-warning text-[0.62rem] font-bold text-background",role:"img",children:"!"}),e&&t(je,{"aria-hidden":!0,className:"size-3 flex-none text-muted-foreground"})]})}function Jl({centered:e,element:a,navigation:o,peek:r,runId:s,session:d}){let l=rt(),n=da(),{Element:i,definition:f}=a,c=f.title??f.id;return u("section",{"aria-label":`Mini-App ${c}`,className:"group/stage relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-app",style:r>0?{paddingBottom:r}:void 0,children:[t("div",{className:"absolute top-1.5 right-2 z-[5] flex gap-0.5 rounded-lg border border-border bg-card p-0.5 opacity-0 transition-opacity group-hover/stage:opacity-100 group-focus-within/stage:opacity-100 motion-reduce:transition-none",children:l.kind==="vscode"?t(z,{"aria-label":`${c} in die Mitte legen`,onClick:()=>l.openInCenter(s,f.id,c),size:"icon-sm",title:"In die Mitte legen",variant:"ghost",children:t(je,{})}):n&&t(z,{"aria-label":`${c} in Vollansicht \xF6ffnen`,onClick:()=>n.openFullscreen(f.id),size:"icon-sm",title:"Vollansicht",variant:"ghost",children:t(ba,{})})}),t("div",{className:"relative flex min-h-0 flex-1 flex-col","data-run-panel":"stage",children:e?u("div",{className:"m-auto grid gap-3 p-4 text-center text-[0.76rem] text-muted-foreground",role:"status",children:[u("span",{children:[c," liegt in der Mitte."]}),t(z,{onClick:()=>l.returnToRunPanel(s,f.id),size:"sm",variant:"outline",children:"Zur\xFCck ins Panel"})]}):t(i,{definition:f,navigation:o,session:d})})]})}function jl({onChange:e,onCommit:a,value:o}){let r=U(void 0),s=d=>{r.current&&(r.current=void 0,d.currentTarget.releasePointerCapture(d.pointerId),a(o))};return t("div",{"aria-label":"Breite des Chats","aria-orientation":"vertical","aria-valuenow":o,className:"flex w-2.5 flex-none cursor-col-resize touch-none items-center justify-center border-r border-l border-border bg-shell select-none hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-2",onKeyDown:d=>{let l=d.key==="ArrowRight"?-24:d.key==="ArrowLeft"?24:0;l!==0&&(d.preventDefault(),e(o+l),a(o+l))},onPointerCancel:s,onPointerDown:d=>{r.current={startX:d.clientX,startWidth:o},d.currentTarget.setPointerCapture(d.pointerId)},onPointerMove:d=>{r.current&&e(r.current.startWidth+r.current.startX-d.clientX)},onPointerUp:s,role:"separator",tabIndex:0,children:t("span",{"aria-hidden":!0,className:"h-10 w-1 rounded-full bg-border-strong"})})}function Ql({actor:e,cardSections:a,navigation:o,notice:r,onNavigate:s,session:d,toolbarLeft:l,view:n}){let i=e.lifecycle?.kind==="running";return u("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t("div",{className:`${Xa} max-h-[40%] flex-none overflow-auto overscroll-contain border-t-0 border-b`,"data-slot":"card-sections",children:a.map(({id:f,Section:c})=>t(c,{actor:e,navigation:o,session:d},f))}),t(ma,{className:"flex-1",composer:t(Je,{actor:e,presentation:"panel",running:i,display:"panel",toolbarLeft:l,view:n}),children:r??t(Ze,{actor:e,conversation:d.actorConversations?.[e.id],historyError:d.conversationError,onNavigate:s,presentation:"inspector",primaryMessages:d.messages,running:i,display:"panel",view:n})})]})}function Yl({state:e}){return t("div",{className:"grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)_auto_minmax(var(--qsl-composer-height,0px),1fr)] justify-items-center overflow-hidden p-6",children:t(pa,{className:"row-start-2",state:e})})}var ed=(e,a)=>{if(!e.revealEntity({type:"artifact",id:a.id}))throw new Error(`Kein Plugin kann das Dokument ${a.title} anzeigen`)};function ns({actor:e,navigation:a,session:o}){let r=J(o.runView);if(!r)return null;let s=_t(e).id,d=r.artifacts.filter(l=>l.createdBy===s);return d.length===0?null:u("section",{className:"grid gap-1.5",children:[u(It,{children:[t("span",{children:"Dokumente"}),t("small",{children:d.length})]}),t("ul",{className:"grid list-none gap-1",children:d.map(l=>t("li",{children:u("button",{className:"grid w-full cursor-pointer rounded-lg border border-border-soft px-2 py-1.5 text-left hover:border-[color-mix(in_srgb,var(--primary)_45%,var(--border))] hover:bg-primary/6",onClick:()=>ed(a,l),type:"button",children:[t("strong",{className:"truncate text-[0.74rem]",title:l.title,children:l.title}),u("small",{className:"text-[0.64rem] text-muted-foreground",children:[Ue(l.size)," - ",l.mediaType]})]})},l.id))})]})}var is=e=>({sideWidth:String(e.sideWidth),openDelay:String(e.openDelay),closeDelay:String(e.closeDelay)}),ad=[{key:"sideWidth",label:"Chat neben der Mini-App ab",unit:"px"},{key:"openDelay",label:"Hochschieben nach",unit:"ms"},{key:"closeDelay",label:"Zur\xFCck nach Verlassen nach",unit:"ms"}];function fs(){let e=W(),a=ut(),[o,r]=w(()=>is(a)),[s,d]=w(),[l,n]=w();O(()=>{r(is(a))},[a]);let i=e.can("settings.write"),f=c=>{if(i){n(void 0),d(void 0);try{Zr(c),d("Einstellungen des Run-Panels gespeichert.")}catch(m){n(m instanceof Error?m.message:String(m))}}};return u("form",{className:"grid gap-3",onSubmit:c=>{c.preventDefault(),f({sideWidth:Number(o.sideWidth),openDelay:Number(o.openDelay),closeDelay:Number(o.closeDelay)})},children:[t("p",{className:"text-muted-foreground",children:"Ab dieser Breite des Panels liegt der Chat rechts neben der Mini-App statt als Sheet darunter. Die Verz\xF6gerungen bestimmen, wie lange die Maus \xFCber dem Sheet liegen muss, bis es hochgleitet, und wie lange es nach dem Verlassen oben bleibt. Gilt sofort f\xFCr alle Runs in diesem Browser."}),u("div",{className:"flex flex-wrap items-end gap-3",children:[ad.map(({key:c,label:m,unit:h})=>u("label",{className:"grid gap-1.5",children:[u("span",{children:[m," (",h,")"]}),t(te,{className:"w-[130px]",disabled:!i,max:ra[c].max,min:ra[c].min,onChange:C=>{r({...o,[c]:C.target.value}),d(void 0)},required:!0,step:"1",type:"number",value:o[c]})]},c)),t(z,{disabled:!i,type:"submit",children:"Speichern"}),t(z,{disabled:!i,onClick:()=>f(mo),variant:"outline",children:"Zur\xFCcksetzen"})]}),l?t("p",{className:"text-muted-foreground",role:"alert",children:l}):s&&t("p",{className:"text-muted-foreground",role:"status",children:s})]})}function cs({session:e}){let[a,o]=w(!1),[r,s]=w([]),[d,l]=w(),[n,i]=w(!1),[f,c]=w(0),[m,h]=w(""),[C,x]=w(100),L=U(null),b=U(null),P=pe(),y=J(e.runView),R=y?.revision,N=q((k=!1)=>{o(!1),k&&L.current?.focus({preventScroll:!0})},[]);O(()=>{if(!a)return;let k=new AbortController;return i(!0),l(void 0),he.call(me.events,{runId:e.session.id},{signal:k.signal}).then(M=>{k.signal.aborted||s(M)}).catch(M=>{k.signal.aborted||l(M instanceof Error?M.message:String(M))}).finally(()=>{k.signal.aborted||i(!1)}),()=>k.abort()},[a,e.session.id,R,f]);let K=D(()=>{let k=m.trim().toLocaleLowerCase("de-DE"),M=new Map(y?.actors.map(G=>[G.id,G.handle]));return[...r].reverse().filter(G=>!k||`${M.get(G.actorId)??""} ${JSON.stringify(G)}`.toLocaleLowerCase("de-DE").includes(k))},[r,m,y?.actors]),V=new Map(y?.actors.map(k=>[k.id,k.handle]));return u("div",{className:"flex h-full min-w-0 items-stretch",children:[t("button",{"aria-controls":P,"aria-expanded":a,className:_a,onClick:()=>o(k=>!k),ref:L,type:"button",children:"Journal"}),t(fa,{open:a,onOpenChange:k=>{k||N()},children:u(ca,{align:"start",anchor:L,"aria-label":"Journal des Runs",className:"flex min-h-0 min-w-0 flex-col gap-0 overflow-hidden rounded-t-sm rounded-b-none p-0 text-[0.76rem]",collisionPadding:8,id:P,initialFocus:b,role:"region",side:"top",style:{width:"min(900px, var(--available-width))",height:"min(480px, var(--available-height))"},children:[u("header",{className:"flex flex-none items-center gap-2 border-b border-border-soft px-2.5 py-2",children:[u("div",{className:"flex min-w-0 flex-1 items-baseline gap-2.5 [&>span]:truncate",children:[t("strong",{children:"Journal"}),t("span",{className:"text-muted-foreground",children:e.session.title||"Run"})]}),t(z,{onClick:()=>c(k=>k+1),size:"sm",variant:"ghost",children:"Aktualisieren"}),t(z,{"aria-label":"Journal schlie\xDFen",onClick:()=>N(!0),size:"icon-sm",title:"Journal schlie\xDFen",variant:"ghost",children:t(xe,{})})]}),u("div",{className:"flex flex-none items-center gap-3 px-2.5 py-2",children:[t(te,{className:"flex-1","aria-label":"Journal durchsuchen",onChange:k=>{h(k.target.value),x(100)},placeholder:"Ereignistyp, Actor oder Inhalt suchen ...",ref:b,type:"search",value:m}),t("span",{className:"flex-none whitespace-nowrap text-[0.68rem] text-muted-foreground",role:"status",children:n?"L\xE4dt ...":`${K.length} Ereignisse`})]}),d&&t("p",{className:"flex-none px-2.5 pb-2 text-destructive",role:"alert",children:d}),u("div",{"aria-label":"Journalereignisse, neueste zuerst",className:"min-h-0 flex-1 overflow-auto overscroll-contain px-2.5 pb-2.5",children:[!n&&!d&&K.length===0&&t("p",{className:"text-muted-foreground",children:m?"Keine passenden Ereignisse.":"Das Journal enth\xE4lt noch keine Ereignisse."}),K.slice(0,C).map(k=>t(td,{actor:V.get(k.actorId),event:k},k.eventId)),K.length>C&&t(z,{onClick:()=>x(k=>k+100),size:"sm",variant:"outline",children:"Weitere Ereignisse anzeigen"})]})]})})]})}function td({actor:e,event:a}){let[o,r]=w(!1);return u("details",{className:"border-b border-border-soft open:[&>summary]:text-primary",onToggle:s=>r(s.currentTarget.open),children:[u("summary",{className:"grid cursor-pointer grid-cols-[32px_minmax(130px,1fr)_minmax(70px,140px)_auto] items-baseline gap-2 px-0.5 py-2 text-[0.68rem] focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 max-[550px]:grid-cols-[24px_minmax(0,1fr)_auto] max-[550px]:gap-x-2 max-[550px]:gap-y-1",children:[t("span",{className:"text-muted-foreground tabular-nums",children:a.sequence}),t("span",{className:"font-mono [overflow-wrap:anywhere]",children:a.type}),t("span",{className:"truncate max-[550px]:col-start-2 max-[550px]:row-start-2",title:a.actorId,children:e?`@${e}`:a.actorId}),t("time",{className:"text-muted-foreground tabular-nums max-[550px]:col-start-3 max-[550px]:row-start-1",dateTime:a.occurredAt,children:new Date(a.occurredAt).toLocaleTimeString("de-DE")})]}),o&&t(Me,{className:"m-0 mb-2 text-[0.68rem]",content:JSON.stringify(a,null,2),language:"json",path:"event.json"})]})}var od="Not-Aus durch den Bediener";function ps({session:e}){return t(Ne,{className:"max-w-none",children:t(rd,{runId:e.session.id},e.session.id)})}function rd({runId:e}){let a=W().can("runs.write"),[o,r]=w(!1),[s,d]=w(!1),[l,n]=w(),i=async()=>{d(!0),n(void 0);try{await nr(e,od),r(!1)}catch(f){n(f instanceof Error?f.message:String(f))}finally{d(!1)}};return a?o?u("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap",children:[t("span",{className:"text-[0.72rem] font-semibold text-destructive",children:"Wirklich alles stoppen?"}),t(z,{disabled:s,onClick:()=>{i()},size:"sm",variant:"destructive",children:"Ja"}),t(z,{disabled:s,onClick:()=>r(!1),size:"sm",variant:"outline",children:"Abbrechen"}),l&&t("span",{className:"max-w-[260px] truncate text-[0.7rem] text-destructive",title:l,children:l})]}):u(z,{onClick:()=>r(!0),size:"sm",title:"Beendet den ganzen Run: Turns, Agenten und Abl\xE4ufe",variant:"destructive",children:[t(kt,{"data-icon":"inline-start"}),"Run stoppen"]}):null}var nt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),sd=(e,a,o)=>JSON.stringify([e,a,o]),ms=(e,a)=>{if(!Array.isArray(e)||e.some(o=>{if(!nt(o)||o.runId!==a||typeof o.eventId!="string"||typeof o.actorId!="string"||!Number.isSafeInteger(o.sequence)||typeof o.occurredAt!="string"||!Number.isFinite(Date.parse(o.occurredAt))||typeof o.type!="string"||!nt(o.payload))return!0;let r=o.payload;return o.type.startsWith("tool.call.")&&(typeof r.turnId!="string"||typeof r.toolCallId!="string")?!0:o.type==="tool.call.source"?typeof r.code!="string"||r.path!==null&&typeof r.path!="string":o.type==="tool.call.started"?typeof r.name!="string"||!("input"in r):o.type==="tool.call.completed"?typeof r.name!="string"||!("output"in r):o.type==="tool.call.failed"?typeof r.name!="string"||typeof r.error!="string":o.type==="turn.finished"?typeof r.turnId!="string"||!["completed","failed"].includes(String(r.outcome)):o.type==="turn.interrupted"?typeof r.turnId!="string"||typeof r.reason!="string":!1}))throw new Error("Der Server hat kein g\xFCltiges Journal f\xFCr diesen Run geliefert.");return e},gs=(e,a)=>{let o=new Map,r=new Map(a?.actors.map(l=>[l.id,l])),s=new Map;for(let l of[...e].sort((n,i)=>n.sequence-i.sequence)){if(a&&l.runId!==a.id)continue;if(l.type==="turn.finished"||l.type==="turn.interrupted"){s.set(JSON.stringify([l.actorId,l.payload.turnId]),{at:l.occurredAt,reason:"reason"in l.payload?l.payload.reason:null});continue}if(l.type!=="tool.call.started"&&l.type!=="tool.call.completed"&&l.type!=="tool.call.failed"&&l.type!=="tool.call.source")continue;let n=sd(l.actorId,l.payload.turnId,l.payload.toolCallId);if(l.type==="tool.call.started"){if(l.payload.name!=="typescript_eval"||o.has(n))continue;let f=r.get(l.actorId),c=nt(l.payload.input)?l.payload.input:{};o.set(n,{key:n,actorId:l.actorId,actorHandle:f?.handle??l.actorId,actorName:f?.displayName??l.actorId,turnId:l.payload.turnId,toolCallId:l.payload.toolCallId,sequence:l.sequence,startedAt:l.occurredAt,finishedAt:null,status:"running",code:typeof c.code=="string"?c.code:null,path:typeof c.path=="string"?c.path:null,result:void 0,logs:[],error:null});continue}let i=o.get(n);if(i)if(l.type==="tool.call.source")i.code=l.payload.code,i.path=l.payload.path;else if(l.type==="tool.call.completed"){i.status="completed",i.finishedAt=l.occurredAt;let f=l.payload.output,c=nt(f)&&"result"in f&&Array.isArray(f.logs)&&f.logs.every(m=>typeof m=="string");i.result=c?f.result:f,i.logs=c?f.logs:[]}else i.status="failed",i.finishedAt=l.occurredAt,i.error=l.payload.error}let d=new Map(a?.turns.map(l=>[JSON.stringify([l.actorId,l.id]),l]));for(let l of o.values()){if(l.status!=="running")continue;let n=JSON.stringify([l.actorId,l.turnId]),i=d.get(n),f=i?.toolCalls?.find(m=>m.id===l.toolCallId&&m.name==="typescript_eval"),c=s.get(n);f&&f.status!=="running"?(l.status=f.status,l.finishedAt=f.finishedAt??i?.finishedAt??c?.at??null):(c||i&&i.status!=="running")&&(l.status="interrupted",l.finishedAt=c?.at??i?.finishedAt??null),l.status==="interrupted"&&(l.error=c?.reason??i?.reason??"Der Aufruf wurde unterbrochen.")}return[...o.values()].sort((l,n)=>n.sequence-l.sequence)},it=e=>({running:"L\xE4uft",completed:"Fertig",failed:"Fehlgeschlagen",interrupted:"Unterbrochen"})[e],xs=(e,a,o)=>{let r=a.trim().toLocaleLowerCase("de-DE");return e.filter(s=>(o==="all"||s.status===o)&&(!r||[s.actorId,s.actorHandle,s.actorName,s.code,s.path,JSON.stringify(s.result),...s.logs,s.error,it(s.status)].join(`
7
- `).toLocaleLowerCase("de-DE").includes(r)))},hs=(e,a)=>{let o=Math.max(0,(e.finishedAt?Date.parse(e.finishedAt):a)-Date.parse(e.startedAt));if(!Number.isFinite(o))return"Dauer unbekannt";if(o<1e3)return`${o} ms`;let r=Math.floor(o/1e3);return r<60?`${r} s`:`${Math.floor(r/60)} min ${r%60} s`};var Cs="ragents.orchestration.executions";function Ss({active:e,session:a}){let o=J(a.runView),r=a.session.id;return t(ld,{active:e,runId:r,view:o?.id===r?o:void 0},r)}function ld({active:e,runId:a,view:o}){let[r,s]=w({events:[],loaded:!1,loading:!1,error:null}),[d,l]=w(""),[n,i]=w("all"),f=[{value:"all",label:"Alle Status"},...["running","completed","failed","interrupted"].map(y=>({value:y,label:it(y)}))],[c,m]=w(Date.now),[h,C]=w(0),x=o?.revision;O(()=>{if(!e)return;let y=new AbortController;return s(R=>({...R,loading:!0,error:null})),he.call(me.events,{runId:a},{signal:y.signal}).then(R=>{let N=ms(R,a);y.signal.aborted||s({events:N,loaded:!0,loading:!1,error:null})}).catch(R=>{y.signal.aborted||s(N=>({...N,loading:!1,error:R instanceof Error?R.message:String(R)}))}),()=>y.abort()},[e,a,x,h]);let L=D(()=>gs(r.events,o),[r.events,o]),b=D(()=>xs(L,d,n),[L,d,n]),P=L.some(y=>y.status==="running");return O(()=>{if(!e||!P)return;m(Date.now());let y=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(y)},[e,P]),u("section",{"aria-label":"TypeScript-Ausf\xFChrungen",className:"flex h-full min-h-0 min-w-0 flex-col bg-background text-[0.78rem] text-foreground",children:[u("header",{className:"px-3.5 pt-3.5 pb-2.5",children:[t("h2",{className:"mb-1.5 text-[0.92rem]",children:"Executions"}),t("p",{className:"leading-[1.5] text-muted-foreground",children:"TypeScript-Snippets aller Actors in diesem Run."})]}),u("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-2 border-b border-border-soft px-3.5 pb-3",children:[t(te,{className:"col-span-full","aria-label":"Ausf\xFChrungen durchsuchen",onChange:y=>l(y.target.value),placeholder:"Actor, Code oder Ergebnis suchen",type:"search",value:d}),u(Ct,{items:f,value:n,onValueChange:y=>{y!==null&&i(y)},children:[t(bt,{className:"min-w-0","aria-label":"Ausf\xFChrungsstatus",children:t(yt,{})}),t(St,{children:f.map(y=>t(wt,{value:y.value,children:y.label},y.value))})]}),t("span",{className:"self-center text-right text-[0.68rem] text-muted-foreground",role:"status",children:r.loading?r.loaded?"Aktualisiert ...":"L\xE4dt ...":r.loaded?`${b.length} von ${L.length} Ausf\xFChrungen`:"Noch nicht geladen"})]}),r.error&&u(ht,{className:"mx-3.5 my-2 w-auto",variant:"destructive",children:[u(Lt,{className:"whitespace-pre-wrap text-destructive [overflow-wrap:anywhere]",children:[r.error,r.loaded?" Der zuletzt geladene Stand bleibt sichtbar.":""]}),t(z,{disabled:!e||r.loading,onClick:()=>C(y=>y+1),size:"sm",variant:"ghost",children:"Erneut laden"})]}),u("div",{"aria-label":"Ausf\xFChrungen, neueste zuerst",className:"min-h-0 flex-1 overflow-auto overscroll-contain px-3 pb-3",children:[r.loaded&&!r.loading&&b.length===0&&t("p",{className:"mx-0.5 my-4.5 leading-[1.6] text-muted-foreground",children:L.length===0?"In diesem Run wurde noch kein TypeScript-Snippet ausgef\xFChrt.":"Keine Ausf\xFChrungen passen zu dieser Suche."}),b.map(y=>t(id,{execution:y,now:c},y.key))]})]})}var dd={running:"bg-background text-info",completed:"bg-success-soft text-success",failed:"bg-destructive-soft text-destructive",interrupted:"bg-warning-soft text-warning"},ud="relative grid cursor-pointer list-none grid-cols-[minmax(0,1fr)_auto] gap-x-2 gap-y-[7px] pt-3 pr-2.5 pb-2.5 pl-[25px] focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 [&::-webkit-details-marker]:hidden before:absolute before:top-[15px] before:left-2.5 before:size-[5px] before:rotate-[-45deg] before:border-r-[1.5px] before:border-b-[1.5px] before:border-solid before:border-current before:content-['']",nd="min-w-0 border-t border-border-soft px-2.5 pb-2.5 [&>h3]:mt-3 [&>h3]:mb-1.5 [&>h3]:text-[0.72rem] [&>h3]:font-[650]",Ls="m-0 max-h-[28rem] overflow-auto text-[0.68rem]",Is="m-0 max-h-[24rem] overflow-auto rounded-sm bg-background p-2 font-mono text-[0.68rem] leading-[1.5] whitespace-pre-wrap [overflow-wrap:anywhere]";function id({execution:e,now:a}){let[o,r]=w(!1),s=e.code?.trim().split(`
5
+ `]},c))})}function Zs({artifact:e,index:a,...o}){let r=a.view,{content:s,retry:d}=Zt(r.id,e),l=r.inputs.filter(n=>n.artifactIds.includes(e.id));return u("div",{className:Ye,children:[u("header",{className:Jt,children:[t(eo,{canGoBack:o.canGoBack,onBack:o.onBack}),u("div",{className:"min-w-0 flex-1",children:[t("p",{className:"mb-0.5 text-[0.66rem] font-semibold tracking-[0.08em] uppercase text-muted-foreground",children:"Artefakt"}),t("h2",{children:e.title}),u("span",{className:jt,children:["von ",ea(a,e.createdBy)," - ",Ue(e.size)," - ",e.mediaType]})]}),t(z,{render:t("a",{href:Ra(r.id,e.id)}),size:"sm",variant:"outline",children:"Herunterladen"})]}),u("div",{className:Da,children:[u("section",{className:ee,children:[t("h3",{children:"Inhalt"}),(!s||s.kind==="loading")&&t("p",{className:be,children:"Artefakt wird geladen ..."}),s?.kind==="error"&&u("p",{className:Qt,children:[s.message," ",t("button",{className:ir,onClick:d,type:"button",children:"Erneut laden"})]}),s?.kind==="download"&&u("p",{className:be,children:["Keine Vorschau f\xFCr ",e.mediaType,"."]}),s?.kind==="image"&&t("img",{alt:e.title,className:"max-w-full rounded-lg",src:Ra(r.id,e.id)}),s?.kind==="text"&&t("pre",{className:Ma,children:s.text})]}),e.previousVersionId&&u("section",{className:ee,children:[t("h3",{children:"\xC4nderung zur Vorversion"}),t($s,{artifact:e,index:a})]}),l.length>0&&u("section",{className:ee,children:[t("h3",{children:"Verwendet in Eingaben"}),t("div",{className:Te,children:l.map(n=>t("button",{className:De,onClick:()=>o.onNavigate({type:"input",id:n.id}),type:"button",children:u("span",{className:Be,children:[t("strong",{children:n.content}),u("small",{children:[pr(a,n)," - ",oe(n.enqueuedAt)]})]})},n.id))})]}),u("section",{className:ee,children:[t("h3",{children:"Details"}),u("dl",{className:Ve,children:[t("dt",{children:"Erstellt von"}),t("dd",{children:t(ze,{id:e.createdBy,index:a,onNavigate:o.onNavigate})}),t("dt",{children:"Hash"}),t("dd",{children:de(e.hash)}),t("dt",{children:"Erstellt"}),t("dd",{children:oe(e.createdAt)}),e.previousVersionId&&u(X,{children:[t("dt",{children:"Vorversion"}),t("dd",{children:t(Ta,{label:de(e.previousVersionId),onNavigate:o.onNavigate,selection:{type:"artifact",id:e.previousVersionId}})})]})]})]})]})]})}var Js="relative isolate rounded-panel border-[1.5px] border-(--material-edge) bg-(--material-face) [--material-edge:#514657] dark:[--material-edge:#b7a8bd]",js={agent:"[--material-face:var(--color-glass-agent)]",primary:"[--material-face:var(--color-glass-primary)]",script:"[--material-face:var(--color-glass-script)]",app:"[--material-face:var(--color-glass-app)]"},ao=(e,a)=>Y(Js,js[e],a),mr="relative flex items-center gap-2 rounded-t-[15.5px] bg-[color-mix(in_srgb,var(--material-face)_96%,black)] px-3 py-2",gr="min-w-0 truncate p-0 text-[17px] font-[730] leading-[1.3] tracking-[-.5px]",xr="grid size-8 flex-none place-items-center rounded-[11px] border border-[#5146578a] bg-white/9 text-foreground shadow-glass-icon";var Qs=["left","right","top","bottom"],Ys={left:"Links andocken",right:"Rechts andocken",top:"Oben andocken",bottom:"Unten andocken"},el={left:Ee,right:Ia,top:Ca,bottom:La},hr=e=>({left:e.left+2,top:e.top+2,width:Math.max(0,e.width-4),height:Math.max(0,e.height-4)}),to=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),al={left:{inner:"left-0 top-[40px]",outer:"left-0 top-[calc(50%_-_18px)]"},right:{inner:"right-0 top-[40px]",outer:"right-0 top-[calc(50%_-_18px)]"},top:{inner:"top-0 left-[40px]",outer:"top-0 left-[calc(50%_-_18px)]"},bottom:{inner:"bottom-0 left-[40px]",outer:"bottom-0 left-[calc(50%_-_18px)]"}},tl="absolute grid size-[36px] place-items-center rounded-[5px] border border-primary bg-surface text-primary shadow-[0_2px_8px_#0002] pointer-events-auto data-[active]:bg-primary data-[active]:text-surface [&>svg]:pointer-events-none",ol="absolute z-3 grid touch-none place-items-center rounded-[4px] focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 data-[direction=horizontal]:cursor-col-resize data-[direction=vertical]:cursor-row-resize [&>span]:pointer-events-none [&>span]:rounded-[4px] [&>span]:bg-border-strong data-[direction=horizontal]:[&>span]:h-8 data-[direction=horizontal]:[&>span]:w-[3px] data-[direction=vertical]:[&>span]:h-[3px] data-[direction=vertical]:[&>span]:w-8 hover:[&>span]:bg-primary focus-visible:[&>span]:bg-primary";function Lr({root:e,onChange:a,items:o,canArrange:r,selectedEntity:s,onSelect:d}){let l=U(null),[n,i]=w({width:0,height:0}),[f,c]=w({width:0,height:0}),[m,h]=w(null),[C,x]=w(null),[L,b]=w(!1),[P,y]=w(null),[D,R]=w(),[K,V]=w(null),k=U(null),M=U(null),G=K??e,S=B(()=>ua(e),[e]),j=B(()=>[...S].sort(),[S]),$=B(()=>new Map(o.map(I=>[I.entity,I])),[o]),ie=e?ct(e):{width:0,height:0},Q=f.width<ie.width||f.height<ie.height,fe=D&&S.includes(D)?D:S[0],v={left:0,top:0,...n},F=B(()=>G?mt(G,{left:0,top:0,...n}):{leaves:new Map,dividers:[]},[G,n]);We(()=>{let I=l.current;if(!I)return;let g=I.parentElement,T=()=>{let ue=I.clientWidth,Z=I.clientHeight;i(Ie=>Ie.width===ue&&Ie.height===Z?Ie:{width:ue,height:Z});let ce=getComputedStyle(g),ke=g.clientWidth-parseFloat(ce.paddingLeft)-parseFloat(ce.paddingRight),la=g.clientHeight-parseFloat(ce.paddingTop)-parseFloat(ce.paddingBottom);c(Ie=>Ie.width===ke&&Ie.height===la?Ie:{width:ke,height:la})},N=new ResizeObserver(T);return N.observe(I),N.observe(g),T(),()=>N.disconnect()},[]),O(()=>{s&&R(s)},[s]),We(()=>{if(!r){h(null),x(null);return}let I=null,g=()=>{I!==null&&cancelAnimationFrame(I),I=null},T=Z=>{if(!Z.dataTransfer?.types.includes(Ae))return;let ce=Z.dataTransfer.getData(Ae);ce&&(g(),I=requestAnimationFrame(()=>{I=null,Z.defaultPrevented||h(ce)}))},N=()=>{g(),h(null),x(null)},ue=Z=>{Z.key==="Escape"&&N()};return window.addEventListener("dragstart",T),window.addEventListener("dragend",N),window.addEventListener("drop",N),window.addEventListener("keydown",ue),()=>{g(),window.removeEventListener("dragstart",T),window.removeEventListener("dragend",N),window.removeEventListener("drop",N),window.removeEventListener("keydown",ue)}},[r]);let _=q(()=>{k.current!==null&&cancelAnimationFrame(k.current),k.current=null;let I=M.current;M.current=null,I?.handle.hasPointerCapture(I.pointerId)&&I.handle.releasePointerCapture(I.pointerId),V(null),b(!1)},[]);We(()=>(_(),_),[e,n,Q,_]),O(()=>{if(!L)return;let I=g=>{g.key==="Escape"&&_()};return window.addEventListener("keydown",I),window.addEventListener("blur",_),()=>{window.removeEventListener("keydown",I),window.removeEventListener("blur",_)}},[L,_]);let H=I=>{let g=M.current;if(!g||g.pointerId!==I.pointerId)return;let T=g.divider.direction==="horizontal"?I.clientX:I.clientY,N=Math.max(g.divider.minimum,Math.min(g.divider.maximum,g.divider.ratio+(T-g.start)/g.divider.span));g.next=T===g.start?g.root:pt(g.root,g.divider.path,N)},Le=I=>{R(I),d?.(I)},ae=r&&C&&m?ft(e,m,C.entity,C.side):null,sa=ae?ct(ae):null,Oa=ae&&ae!==e&&sa&&m?f.width<sa.width||f.height<sa.height?v:mt(ae,v).leaves.get(m):null,ye=I=>Qs.map(g=>{let T=el[g];return t("div",{className:`${tl} ${al[g][I===null?"outer":"inner"]}`,"data-dock-side":g,"data-dock-entity":I??"",title:Ys[g],"data-active":C?.entity===I&&C.side===g||void 0,children:t(T,{size:18,"aria-hidden":"true"})},g)});return u("div",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden p-2 data-[dragging]:[&_iframe]:pointer-events-none data-[resizing]:[&_iframe]:pointer-events-none","data-dragging":r&&m!==null||void 0,"data-resizing":L||void 0,children:[Q&&S.length>1&&u("label",{className:"flex items-center gap-2 pb-2 text-[0.8rem]",children:["Kachel",t("select",{className:"max-w-[60%] min-w-0","aria-label":"Sichtbare Kachel",value:fe,onChange:I=>Le(I.target.value),children:S.map(I=>t("option",{value:I,children:$.get(I)?.title??I},I))}),t("span",{className:"truncate text-muted-foreground",children:"Mehr Platz f\xFCr die geteilte Ansicht ben\xF6tigt"})]}),u("div",{ref:l,className:"relative min-h-0 min-w-0 flex-1 overflow-hidden",onDragOver:I=>{if(!r||m===null||!I.dataTransfer.types.includes(Ae))return;I.preventDefault(),I.dataTransfer.dropEffect="move";let g=I.target instanceof Element?I.target.closest("[data-dock-side]"):null,T=g&&l.current?.contains(g)?{entity:g.dataset.dockEntity||null,side:g.dataset.dockSide}:null;x(N=>N?.entity===T?.entity&&N?.side===T?.side?N:T)},onDragLeave:I=>{I.currentTarget.contains(I.relatedTarget)||x(null)},onDrop:I=>{if(!r||m===null)return;let g=I.dataTransfer.getData(Ae);if(!g||g!==m||(I.preventDefault(),!$.has(g)&&!S.includes(g)))return;let T=I.target instanceof Element?I.target.closest("[data-dock-side]"):null;try{if(!e||T){let N=ft(e,g,T?.dataset.dockEntity||null,T?.dataset.dockSide??"right");N!==e&&a(N===null?null:_e(N)),Le(g),y(null)}}catch(N){y(N instanceof Error?N.message:String(N))}finally{h(null),x(null)}},children:[P&&u("div",{className:"absolute inset-x-2 bottom-2 z-7 flex items-center gap-2 rounded-lg border border-primary bg-surface p-3 text-foreground shadow-[0_2px_8px_#0002]",role:"alert",children:[t("span",{className:"flex-1",children:P}),t("button",{className:"grid cursor-pointer place-items-center bg-transparent p-1",type:"button","aria-label":"Meldung schlie\xDFen",onClick:()=>y(null),children:t(xe,{size:16})})]}),!e&&t("div",{className:"grid h-full place-items-center rounded-lg border border-dashed border-border-strong p-6 text-center text-muted-foreground",children:r?"Ziehe einen Actor oder eine Mini-App aus der Kopfzeile hierher.":"F\xFCr diese Kachelansicht sind noch keine Inhalte angeordnet."}),j.map(I=>{let g=$.get(I),T=hr(Q?v:F.leaves.get(I));return u("section",{className:ao(g?.tone??(I.startsWith("app:")?"app":"agent"),"absolute z-0 flex min-h-0 min-w-0 flex-col overflow-visible"),"data-tile-entity":I,"data-tone":"material",style:{...to(T),display:Q&&I!==fe?"none":void 0},onFocusCapture:()=>{fe!==I&&R(I)},children:[u("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[15.5px]",children:[u("header",{className:`${mr} flex-[0_0_49px] min-w-0 select-none border-b border-[#51465738] text-foreground [&[draggable=true]]:cursor-grab`,draggable:r,onDragStart:N=>{if(!r){N.preventDefault();return}N.dataTransfer.setData(Ae,I),N.dataTransfer.effectAllowed="move"},children:[r&&t(wa,{size:16,"aria-hidden":"true"}),t("span",{className:xr,children:g?.tone==="app"||I.startsWith("app:")?t(Oe,{size:20,"aria-hidden":"true"}):g?.tone==="script"?t(Re,{size:20,"aria-hidden":"true"}):t(ge,{size:20,"aria-hidden":"true"})}),t("span",{className:`${gr} flex-1`,title:g?.title??I,children:g?.title??I}),r&&t("button",{className:"grid size-[26px] cursor-pointer place-items-center rounded-[4px] bg-transparent p-0 text-muted-foreground hover:bg-glass-group hover:text-foreground",type:"button",draggable:!1,"aria-label":`Kachel ${g?.title??I} entfernen`,onClick:()=>a(So(e,I)),children:t(xe,{size:16})})]}),t("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-auto [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:flex-1",children:g?.content??t("div",{className:"p-4.5 text-muted-foreground",children:r?"Dieser Inhalt ist nicht mehr verf\xFCgbar. Du kannst die Kachel entfernen oder einen anderen Inhalt hier andocken.":"Dieser Inhalt ist nicht mehr verf\xFCgbar."})})]}),r&&m!==null&&m!==I&&t("div",{className:"absolute inset-0 z-4",children:t("div",{className:"pointer-events-none absolute top-1/2 left-1/2 size-[116px] -translate-x-1/2 -translate-y-1/2",children:ye(I)})})]},I)}),!Q&&F.dividers.map(I=>t("div",{className:ol,role:"separator",tabIndex:0,"aria-label":"Kachelgr\xF6\xDFe \xE4ndern","aria-orientation":I.direction==="horizontal"?"vertical":"horizontal","aria-valuemin":Math.round(I.minimum*100),"aria-valuemax":Math.round(I.maximum*100),"aria-valuenow":Math.round(I.ratio*100),"data-direction":I.direction,style:to(I),onPointerDown:g=>{g.button!==0||!g.isPrimary||!e||M.current||(g.preventDefault(),g.currentTarget.setPointerCapture(g.pointerId),M.current={divider:I,start:I.direction==="horizontal"?g.clientX:g.clientY,root:e,next:e,pointerId:g.pointerId,handle:g.currentTarget},b(!0))},onPointerMove:g=>{M.current?.pointerId===g.pointerId&&(H(g),k.current===null&&(k.current=requestAnimationFrame(()=>{k.current=null,M.current&&V(M.current.next)})))},onPointerUp:g=>{let T=M.current;!T||T.pointerId!==g.pointerId||(H(g),_(),T.next!==T.root&&a(T.next))},onLostPointerCapture:g=>{M.current?.pointerId===g.pointerId&&_()},onPointerCancel:g=>{M.current?.pointerId===g.pointerId&&_()},onKeyDown:g=>{if(g.key==="Escape"&&M.current){g.preventDefault(),_();return}if(!e||M.current)return;let T=I.direction==="horizontal"?"ArrowLeft":"ArrowUp",N=I.direction==="horizontal"?"ArrowRight":"ArrowDown";if(g.key!==T&&g.key!==N&&g.key!=="Home"&&g.key!=="End")return;g.preventDefault();let ue=g.key==="Home"?I.minimum:g.key==="End"?I.maximum:I.ratio+(g.key===N?.02:-.02);a(pt(e,I.path,Math.max(I.minimum,Math.min(I.maximum,ue))))},children:t("span",{})},I.path.join("."))),L&&t("div",{className:"absolute inset-0 z-2"}),r&&m!==null&&e&&t("div",{className:"pointer-events-none absolute inset-2 z-6",children:ye(null)}),r&&m!==null&&Oa&&t("div",{className:ao($.get(m)?.tone??(m.startsWith("app:")?"app":"agent"),"pointer-events-none absolute z-5 opacity-80"),style:to(hr(Oa)),children:t("div",{className:"absolute inset-0 rounded-[15.5px] border-2 border-primary bg-primary/22"})})]})]})}function Ir({root:e,onChange:a,surfaceElements:o,cardSections:r,session:s,view:d,navigation:l,onSelect:n,selected:i}){let f=W().can("runs.inspect"),c=d.actors.filter(C=>C.kind!=="human"&&C.lifecycle?.kind!=="stopped"&&(f||C.kind==="agent")),m=[...c.map(C=>({entity:`@${C.handle}`,title:`${C.displayName||C.handle} (@${C.handle})`,tone:He(d,C),content:C.kind==="agent"?t(Mo,{actor:C,view:d,cardSections:r,chatInput:Va(e,`@${C.handle}`),session:s,navigation:l,onSelect:n}):t($a,{view:d,selection:{type:"actor",id:C.id},canGoBack:!1,chatDisplay:"surface",composerVisible:!1,onNavigate:n,onBack:()=>{},primaryMessages:s.messages,actorConversations:s.actorConversations,conversationError:s.conversationError,primaryRunning:s.running})})),...o.flatMap(({Element:C,select:x})=>x(s).filter(L=>L.visible!==!1).map(L=>({entity:`app:${L.id}`,title:L.title??L.id,tone:"app",content:t(C,{definition:L,navigation:l,session:s})})))],h=i?.type==="run-app"?`app:${i.id}`:i?.type==="actor"?c.find(C=>C.id===i.id)?.handle:void 0;return t(Lr,{root:e,onChange:a,items:m,canArrange:f,selectedEntity:i?.type==="actor"&&h?`@${h}`:h})}function Cr({state:e}){return t("div",{className:"pointer-events-none absolute inset-y-0 left-0 grid w-[var(--surface-visible-width,100%)] place-items-center p-6",children:t(pa,{state:e})})}function Ja({view:e,startup:a,connected:o,running:r,error:s}){if(a?.status==="failed")return{kind:"error",title:"Der Run konnte nicht vorbereitet werden",detail:a.message};if(s)return{kind:"error",title:"Der Run-Status ist nicht erreichbar",detail:s};if(a?.status==="preparing")return{kind:"working",title:"Run wird vorbereitet",detail:a.message};let d=e?.actors.filter(c=>c.kind!=="human")??[],l=d.filter(c=>c.lifecycle?.kind!=="stopped");if(d.length&&!l.length)return{kind:"stopped",title:"Der Run wurde gestoppt",detail:"Es wird keine weitere Arbeit ausgef\xFChrt."};if(e?.actions.some(c=>c.status==="pending"))return{kind:"waiting",title:"Deine Eingabe wird ben\xF6tigt",detail:"Im Chat wartet eine Aktion auf Deine Eingabe."};let n=new Set(l.map(c=>c.id));if(r||l.some(c=>c.lifecycle?.kind==="running")||e?.turns.some(c=>n.has(c.actorId)&&c.status==="running")||e?.inputs.some(c=>n.has(c.actorId)&&Pa(c)))return{kind:"working",title:"Der Run wird eingerichtet",detail:"Die Oberfl\xE4che wird aufgebaut. Die Elemente erscheinen automatisch."};let f=l.map(c=>e?.turns.filter(m=>m.actorId===c.id).at(-1)).find(c=>c?.status==="failed"||c?.status==="interrupted");if(f)return{kind:"error",title:"Der Aufbau wurde angehalten",detail:f.reason||"Der letzte Arbeitsschritt konnte nicht abgeschlossen werden."};if(!o)return{kind:"working",title:"Run wird geladen",detail:"Die Verbindung zum Run wird hergestellt."}}var ne=p("@ragents/web/lib/local-storage-setting","createLocalStorageSetting");var Sr=e=>`ragents.orchestration.tile-presentation:${e}`;function rl(e){if(e===null||e==="null")return null;let a=JSON.parse(e);if(!a||typeof a!="object"||Array.isArray(a)||!("root"in a)||Object.keys(a).some(o=>!["root","programBasis"].includes(o))||"programBasis"in a&&typeof a.programBasis!="string")throw new Error("Die gespeicherte Kachelansicht ist ung\xFCltig.");return{root:a.root===null?null:_e(a.root),..."programBasis"in a?{programBasis:a.programBasis}:{}}}var wr=ne({changeEvent:"ragents-tile-presentation-change",matchesKey:e=>e.startsWith("ragents.orchestration.tile-presentation:"),parse:rl,serialize:JSON.stringify}),sl=e=>wr.useValue(Sr(e)),Qa=(e,a)=>wr.save(Sr(e),a),br=e=>JSON.stringify({root:e.root});function ll(e,a){if(!e)return null;if(e.programBasis!==void 0)return e.programBasis===br(a)?e:null;let o=new Set(za(e.root));return za(a.root).some(r=>!o.has(r))?null:e}function yr(e,a){let o=a?.pluginStates.find(f=>f.pluginId===wo&&f.scope.kind==="run")?.state,r=B(()=>o===void 0?void 0:JSON.stringify(o),[o]),s=B(()=>{try{return{layout:r===void 0?void 0:ko(JSON.parse(r))}}catch(f){return{error:f instanceof Error?f.message:String(f)}}},[r]),d=B(()=>({root:s.layout?.root??null}),[s]),l=B(()=>br(d),[d]),n=sl(e),i=a&&!s.error?ll(n,d):n;return O(()=>{n&&!i&&Qa(e,null)},[e,n,i]),{programLayout:s,personalLayout:i,presentation:i??d,programBasis:l}}function ja(e,a="horizontal"){if(e.length===0)return null;if(e.length===1)return{entity:e[0]};let o=Math.ceil(e.length/2),r=a==="horizontal"?"vertical":"horizontal";return{direction:a,weights:[o,e.length-o],children:[ja(e.slice(0,o),r),ja(e.slice(o),r)]}}var oo=p("@ragents/web/StatusGroup","StatusGroup");var Ba=p("@ragents/web/Toolbar","ToolbarCopy");var Ne=p("@ragents/web/Toolbar","ToolbarItem");var Fa=p("@ragents/web/Toolbar","ToolbarLabel");var aa=p("@ragents/web/Toolbar","ToolbarText");var dl=Object.freeze({actorVisibility:Object.freeze({})}),kr=e=>`ragents.orchestration.actor-visibility:${e}`;function ul(e){if(e===null)return dl;let a=JSON.parse(e);if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(o=>o!=="actorVisibility")||!("actorVisibility"in a)||!a.actorVisibility||typeof a.actorVisibility!="object"||Array.isArray(a.actorVisibility)||Object.values(a.actorVisibility).some(o=>typeof o!="boolean"))throw new Error("Die gespeicherte Actor-Sichtbarkeit ist ung\xFCltig.");return a}var ta=(e,a,o,r)=>e.kind==="human"?!1:(Object.hasOwn(o.actorVisibility,e.id)?o.actorVisibility[e.id]:void 0)??(e.id!==r&&!a.has(e.id)),Ar=ne({changeEvent:"ragents-actor-visibility-change",matchesKey:e=>e.startsWith("ragents.orchestration.actor-visibility:"),parse:ul,serialize:JSON.stringify});function Ya(e){return Ar.useValue(kr(e))}function et(e,a){Ar.save(kr(e),a)}function oa({open:e,id:a,label:o,closeLabel:r,buttonRef:s,onClose:d,width:l,height:n,placement:i="bottom",focusInput:f=!1,keepMounted:c=!1,role:m,headerContent:h,children:C}){let x=U(null),L=b=>b.reason==="outside-press"&&b.event.target instanceof Node&&s.current?.contains(b.event.target)===!0;return t(fa,{open:e,onOpenChange:(b,P)=>{!b&&!L(P)&&d()},children:u(ca,{align:"start",anchor:s,"aria-label":o,className:"flex min-h-0 min-w-0 flex-col gap-0 overflow-hidden rounded-b-sm p-0 text-[0.76rem] focus:outline-none data-[placement=top]:rounded-t-sm data-[placement=top]:rounded-b-none [&_input[type=checkbox]]:m-0 [&_input[type=checkbox]]:flex-none [&_input[type=checkbox]]:accent-primary",collisionPadding:8,"data-surface-scroll":"true",dim:!0,"data-placement":i,id:a,initialFocus:f?()=>x.current?.querySelector("input")??!0:!0,keepMounted:c,ref:x,role:m,side:i,style:{width:l==="available"?"var(--available-width)":l,height:n,maxWidth:"var(--available-width)",maxHeight:"var(--available-height)"},children:[u("header",{className:"flex flex-none items-center justify-between gap-2 border-b border-border-soft px-2.5 py-2",children:[t("strong",{className:"shrink-0",children:o}),h,t(z,{"aria-label":r,onClick:()=>d(!0),size:"icon-sm",title:r,variant:"ghost",children:t(xe,{})})]}),C]})})}var nl="grid size-[30px] flex-none place-items-center rounded-lg border border-foreground/15 text-foreground",il={agent:"bg-glass-agent",primary:"bg-glass-primary",script:"bg-glass-script",app:"bg-glass-app"};function vr({actor:e,view:a,session:o,open:r,onToggle:s,onClose:d,visible:l}){let n=Ua(o.session.id).has(`@${e.handle}`),i=W().can("runs.inspect"),[f,c]=w(!1),m=U(null),h=pe(),C=ga(),x=q((D=!1)=>{d(),D&&m.current?.focus({preventScroll:!0})},[d]),L=D=>{if(!C)throw new Error("Der Actor-Zugang ben\xF6tigt den Fl\xE4chen-Controller.");C.acceptSelection(D),x()},b=He(a,e),P=e.kind==="agent"?`Chat mit @${e.handle}`:`Actor-Ansicht von @${e.handle}`,y=i?e.kind==="agent"?"LLM-Agent":"TypeScript-Actor":"Agent";return u("div",{className:"flex items-stretch [&[hidden]]:hidden",hidden:!l,children:[u(Ne,{as:"button","aria-controls":f?h:void 0,"aria-expanded":r,"aria-haspopup":"dialog","aria-label":`${e.displayName||e.handle}. ${y}: ${P} \xF6ffnen`,className:"font-bold","data-tone":b,"data-staged":n||void 0,onClick:()=>{c(!0),s()},draggable:i,onDragStart:D=>{if(!i){D.preventDefault();return}D.dataTransfer.setData(Ae,`@${e.handle}`),D.dataTransfer.effectAllowed="move",x()},ref:m,title:`${y}: ${P} \xF6ffnen${i?". Zum Andocken auf eine Kachel ziehen.":""}`,type:"button",children:[t("span",{className:Y(nl,n&&il[b]),children:e.kind==="agent"?t(Se,{size:20}):t(qe,{size:20})}),u(Ba,{children:[u(Fa,{children:["@",e.handle]}),t(aa,{children:e.displayName&&e.displayName!==e.handle?e.displayName:y})]})]}),f&&t(oa,{open:r,id:h,label:P,closeLabel:`${P} schlie\xDFen`,buttonRef:m,keepMounted:!0,onClose:x,width:e.kind==="agent"?784:560,height:640,role:"dialog",children:t("div",{className:"min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain",children:t($a,{actorConversations:o.actorConversations,canGoBack:!1,chatDisplay:"popout",composerVisible:!0,conversationError:o.conversationError,onBack:()=>{},onNavigate:L,primaryMessages:o.messages,primaryRunning:o.running,selection:{type:"actor",id:e.id},view:a})})})]})}var ro=["all","active","visible","agent","script"],at={all:"Alle",active:"Aktive",visible:"Sichtbare",agent:"LLM-Agenten",script:"TypeScript"},Pr=e=>`ragents.orchestration.actor-header:v2:${e}`;function fl(e){if(e===null)return"visible";if(ro.some(a=>a===e))return e;throw new Error("Die gespeicherte Actor-Anzeige ist ung\xFCltig. Erlaubt sind all, active, visible, agent und script.")}var Rr=(e,a,o)=>e.id===a||o.has(`@${e.handle}`),tt=(e,a,o)=>e.kind!=="human"&&(a==="all"||(a==="active"?e.lifecycle?.kind!=="stopped":a==="visible"?o:e.kind===a)),Mr=ne({changeEvent:"ragents-actor-header-change",matchesKey:e=>e.startsWith("ragents.orchestration.actor-header:"),parse:fl,serialize:e=>e});function Na(e){return Mr.useValue(Pr(e))}function Tr(e,a){Mr.save(Pr(e),a)}var cl="min-w-0 max-w-full text-left font-semibold [overflow-wrap:anywhere]",Dr=e=>e.kind==="human"?"Benutzer":e.kind==="agent"?"LLM-Agent":"TypeScript-Actor",so=e=>e.lifecycle?.kind==="running"?"Arbeitet":e.lifecycle?.kind==="stopped"?"Gestoppt":e.lifecycle?.kind==="idle"?"Bereit":"";function pl(e,a,o){let r=o.trim().toLocaleLowerCase("de-DE").split(/\s+/).filter(Boolean);return e.filter(s=>{let d=[`@${s.handle}`,s.displayName,s.kind,Dr(s),s.lifecycle?.kind,so(s),a.has(s.id)?"Mini-App":""].join(" ").toLocaleLowerCase("de-DE");return r.every(l=>d.includes(l))})}function Br({session:e}){let a=W().can("runs.inspect"),[o,r]=w(),s=q(()=>r(void 0),[]),d=Na(e.session.id),l=Ua(e.session.id),n=J(e.runView),i=B(()=>n?.actors.filter(m=>m.kind!=="human"&&(a||m.kind==="agent"))??[],[a,n]),f=n?we(n):void 0,c=q(m=>tt(m,d,Rr(m,f,l)),[d,l,f]);return O(()=>{o&&!i.some(m=>`${e.session.id}:${m.id}`===o&&c(m))&&s()},[i,s,o,e.session.id,c]),!n||i.length===0?null:t("nav",{"aria-label":"Actors des Runs",className:"flex min-w-0 flex-none items-stretch",children:i.map(m=>{let h=`${e.session.id}:${m.id}`;return t(vr,{actor:m,onClose:s,onToggle:()=>r(C=>C===h?void 0:h),open:o===h,session:e,view:n,visible:c(m)},h)})})}var ml=["active","visible","all"];function ot({runId:e}){let a=W().can("runs.inspect"),o=Na(e),r=a?ro:ml,s=r[(r.indexOf(o)+1)%r.length],d=`Actor-Anzeige: ${at[o]}. Wechseln zu ${at[s]}`;return t(Ne,{as:"button","aria-label":d,className:"w-[120px] max-w-[120px] min-w-[120px] flex-[0_0_120px]",onClick:()=>Tr(e,s),title:d,type:"button",children:u(Ba,{children:[t(Fa,{children:"Anzeige"}),t(aa,{children:at[o]})]})})}function Fr({session:e,appActorIds:a,preferences:o,onPreferencesChange:r}){let[s,d]=w(!1),[l,n]=w(""),i=U(null),f=pe(),c=J(e.runView),m=c?.actors,h=B(()=>pl(m??[],a,l),[m,a,l]),C=q((L=!1)=>{d(!1),L&&i.current?.focus({preventScroll:!0})},[]);O(()=>{C(),n("")},[e.session.id,C]);let x=`Actors \xB7 ${m?.length??0}`;return u("div",{className:"flex h-full min-w-0 flex-none items-stretch",children:[u(Ne,{as:"button",ref:i,"aria-controls":s?f:void 0,"aria-expanded":s,"aria-label":x,title:x,onClick:()=>d(L=>!L),type:"button",children:[t(Se,{size:20}),t(aa,{children:"Actors"})]}),s&&u(oa,{open:!0,id:f,label:"Actors des Runs",closeLabel:"Actorliste schlie\xDFen",buttonRef:i,onClose:C,width:460,height:460,placement:"bottom",focusInput:!0,role:"region",children:[u("div",{className:"flex flex-none items-center gap-2.5 p-2.5",children:[t(te,{className:"flex-1","aria-label":"Actors durchsuchen",onChange:L=>n(L.target.value),placeholder:"Handle, Typ oder Status suchen ...",type:"search",value:l}),u("span",{className:"flex-none whitespace-nowrap text-[0.68rem] text-muted-foreground",role:"status",children:[h.length," von ",m?.length??0]})]}),t(gl,{actors:h,appActorIds:a,primaryActorId:c?.primaryActorId,onPreferencesChange:r,preferences:o}),t("p",{className:"flex-none border-t border-border-soft px-2.5 py-2.5 text-[0.68rem] text-muted-foreground",children:"Pers\xF6nliche Ansicht dieses Runs"})]})]})}function gl({actors:e,appActorIds:a,primaryActorId:o,onPreferencesChange:r,preferences:s}){return t("div",{className:"min-h-0 flex-1 overflow-auto overscroll-contain px-2.5",children:e.length===0?t("p",{className:"text-muted-foreground",children:"Keine passenden Actors."}):t("ul",{className:"list-none",children:e.map(d=>u("li",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2.5 border-b border-border-soft py-1.5",children:[u("div",{className:"grid min-w-0 gap-0.5 leading-[1.3]",children:[u("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[u("span",{className:cl,children:["@",d.handle]}),d.displayName!==d.handle&&t("span",{className:"min-w-0 max-w-full text-[0.7rem] [overflow-wrap:anywhere]",children:d.displayName})]}),u("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[0.66rem] text-muted-foreground",children:[t("span",{children:Dr(d)}),so(d)&&t("span",{children:so(d)}),a.has(d.id)&&t("span",{className:"text-primary",children:"Mini-App"})]})]}),d.kind!=="human"&&u("label",{className:"flex cursor-pointer items-center gap-[5px] whitespace-nowrap text-[0.68rem]",children:[t("input",{"aria-label":`@${d.handle} auf der Fl\xE4che anzeigen`,checked:ta(d,a,s,o),onChange:l=>r({...s,actorVisibility:{...s.actorVisibility,[d.id]:l.target.checked}}),type:"checkbox"}),t("span",{children:"Fl\xE4che"})]})]},d.id))})})}function Nr(e){return t(xl,{...e},e.session.session.id)}function xl({cardSections:e,surfaceElements:a,navigation:o,session:r,statusContainer:s,runToolbarContainer:d}){let l=W().can("runs.inspect"),n=ga();if(!n)throw new Error("Die Fl\xE4che braucht den Fl\xE4chen-Controller des Orchestrierungs-Plugins.");let i=U(void 0),f=J(r.runView);f!==void 0&&(i.current=f);let c=f??i.current,{programLayout:m,personalLayout:h,presentation:C,programBasis:x}=yr(r.session.id,c),[L,b]=w(),P=Ya(r.session.id),y=B(()=>new Set(a.flatMap(v=>v.select(r).flatMap(F=>F.anchorActorId?[F.anchorActorId]:[]))),[a,r]),D=B(()=>c?.actors.filter(v=>v.kind!=="human"&&(l?!ta(v,y,P,c.primaryActorId):v.kind==="script")).map(v=>v.id)??[],[l,c,y,P]),R=B(()=>a.flatMap(v=>v.select(r).filter(F=>F.visible!==!1).map(F=>`app:${F.id}`)),[a,r]),K=new Set([...R,...c?.actors.filter(v=>v.kind!=="human"&&v.lifecycle?.kind!=="stopped"&&(l||v.kind==="agent")).map(v=>`@${v.handle}`)??[]]),V=B(()=>h===null&&m.layout?.root===void 0?ja([...R,...c?.actors.filter(v=>v.kind!=="human"&&v.lifecycle?.kind!=="stopped"&&!D.includes(v.id)).map(v=>`@${v.handle}`)??[]]):null,[h,m,R,c,D]),k=C.root??V,M=ua(k).some(v=>K.has(v)),G=B(()=>new Set(ua(k)),[k]);O(()=>gt(r.session.id,G),[r.session.id,G]),O(()=>()=>gt(r.session.id,void 0),[r.session.id]);let S=Ja({view:c,startup:r.startup,connected:r.connected,running:r.running,error:r.conversationError}),j=U(null),$=!M&&S!==void 0,ie=q(()=>{let v=j.current;if(!v)return;let F=v.getBoundingClientRect(),_=document.getElementById("workspace-panel")?.getBoundingClientRect(),H=_?Math.min(F.right,_.right)-Math.max(F.left,_.left):0;return{width:F.width-Math.max(0,H),height:F.height}},[]);O(()=>{let v=j.current;if(!v)return;let F=new ResizeObserver(()=>{let H=ie();H&&v.style.setProperty("--surface-visible-width",`${H.width}px`)});F.observe(v);let _=document.getElementById("workspace-panel");return _&&F.observe(_),()=>F.disconnect()},[ie]);let Q=q(v=>{n.acceptSelection(v)},[n]),fe=v=>{try{Qa(r.session.id,{root:v,programBasis:x}),b(void 0)}catch(F){b(F instanceof Error?F.message:String(F))}};return u("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 overflow-clip","data-view":"tiled",children:[h&&t(oo,{container:s,label:"Fl\xE4che",order:20,children:t("button",{className:_a,onClick:()=>Qa(r.session.id,null),title:"Eigene Anordnung zur\xFCcksetzen und der Programmanordnung folgen",type:"button",children:"Programmvorgabe \xFCbernehmen"})}),d&&na(u(X,{children:[t(ot,{runId:r.session.id}),l&&t(Fr,{session:r,appActorIds:y,preferences:P,onPreferencesChange:v=>et(r.session.id,v)})]}),d),u("div",{"aria-label":"Fl\xE4che",className:"relative min-h-0 min-w-0 flex-[1_1_360px] overflow-clip bg-[image:var(--surface-backdrop)]",ref:j,children:[t(hl,{}),(m.error||L)&&t("p",{className:"absolute inset-x-2 top-2 z-10 bg-secondary p-3 text-destructive",role:"alert",children:m.error||L}),c&&!$&&t("div",{className:"absolute inset-y-0 left-0 w-[var(--surface-visible-width,100%)] overflow-hidden",children:t(Ir,{root:k,onChange:fe,surfaceElements:a,cardSections:e,session:r,view:c,navigation:o,onSelect:Q,selected:n.selection})}),$&&t(Cr,{state:S})]})]})}function hl(){return u("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 size-full opacity-10",preserveAspectRatio:"none",viewBox:"0 0 180 180",children:[t("filter",{id:"surface-grain",children:t("feTurbulence",{baseFrequency:".76",numOctaves:"3",stitchTiles:"stitch",type:"fractalNoise"})}),t("path",{d:"M0 0h180v180H0z",fill:"#887890",filter:"url(#surface-grain)",opacity:".32"})]})}var lo=p("@ragents/web/run-panel/host","useCenterElements");var rt=p("@ragents/web/run-panel/host","useRunPanelHost");var Er=(e,a)=>{let o=e.actors.filter(d=>d.kind!=="human"&&(a||d.kind==="agent")),r=we(e);return[...o.filter(d=>d.id===r),...o.filter(d=>d.id!==r)]},qr=(e,a)=>{let o=[],r=[];for(let s of e)(s.id===a.primaryId||s.id===a.selectedId||tt(s,a.mode,a.onStage(s))?o:r).push(s);return{shown:o,hidden:r}},Ea=(e,a)=>e.inputs.filter(o=>o.actorId===a&&o.lifecycle.kind==="pending").length,Ll=(e,a)=>e.actions.filter(o=>o.status==="pending"&&o.askedBy===a).length,Or=(e,a,o)=>o||e!==void 0&&a.anchorActorId!==void 0&&Ll(e,a.anchorActorId)>0;var Il=4,Hr=12,uo=90,Cl={running:["arbeitet","arbeiten"],input:["wartet auf Eingabe","warten auf Eingabe"],waiting:["wartet","warten"],stopped:["gestoppt","gestoppt"]},Sl=["running","input","waiting","stopped"],qa=e=>e.toLocaleLowerCase("de-DE"),wl=e=>{let a=e.split(`
6
+ `).map(s=>s.replace(/\s+/g," ").trim()).find(s=>s!=="")??"";if(a.length<=uo)return a;let o=a.slice(0,uo-3),r=o.lastIndexOf(" ");return`${(r>uo/2?o.slice(0,r):o).trimEnd()}...`},no=(e,a)=>a.lifecycle?.kind==="stopped"?"stopped":e.actions.some(o=>o.status==="pending"&&o.askedBy===a.id)?"input":a.lifecycle?.kind==="running"?"running":"waiting",lt=(e,a=1)=>Cl[e][a===1?0:1],Ur=(e,a)=>{let o=new Map;for(let r of a.map(s=>no(e,s)))o.set(r,(o.get(r)??0)+1);return Sl.flatMap(r=>{let s=o.get(r)??0;return s>0?[`${s} ${lt(r,s)}`]:[]}).join(", ")},Vr=e=>{let a=new Map;for(let o of e.inputs){if(o.subscriptionId!==null||o.presentation==="background"||o.content.trim()==="")continue;let r=a.get(o.actorId);(!r||o.sequence<r.sequence)&&a.set(o.actorId,{sequence:o.sequence,content:o.content})}return o=>{let r=o.description?.trim();if(r)return r;let s=a.get(o.id);if(s)return wl(s.content);let d=o.displayName.trim();return d!==""&&qa(d)!==qa(o.handle)?d:void 0}},zr=(e,a,o)=>{let r=new Set([o.id]),s=o.createdBy;for(;s!==void 0&&!r.has(s);){if(a.has(s))return s;let d=e.get(s);if(!d||d.kind==="human")return null;r.add(s),s=d.createdBy}return null},bl=e=>qa(e).replace(/-\d+$/,"").split(/[-_.]/)[0]??"",yl=e=>{let a=e[0]??"",o=e.reduce((l,n)=>{let i=0;for(;i<l&&n[i]===a[i];)i+=1;return i},a.length),r=a.slice(0,o),s=r.search(/[-_.][^-_.]*$/);return`@${/[-_.]$/.test(r)||e.includes(r)||s<0?r:r.slice(0,s+1)}*`},io=(e,a)=>{let o=new Map(e.actors.map(i=>[i.id,i])),r=new Set(a.map(i=>i.id)),s=we(e),d=new Map;for(let i of a){let f=zr(o,r,i);d.set(f,[...d.get(f)??[],i])}let l=i=>({kind:"actor",actor:i,children:n(i.id)}),n=i=>{let f=d.get(i)??[],c=i===null?[...f.filter(x=>x.id===s),...f.filter(x=>x.id!==s)]:f,m=x=>x.id===s?null:`${i??""}/${x.kind}/${bl(x.handle)}`,h=new Map;for(let x of c){let L=m(x);L!==null&&h.set(L,[...h.get(L)??[],x])}let C=new Set;return c.flatMap(x=>{let L=m(x),b=L===null?void 0:h.get(L);return L===null||!b||b.length<Il?[l(x)]:C.has(L)?[]:(C.add(L),[{kind:"group",key:L,label:yl(b.map(P=>P.handle)),members:b.map(l)}])})};return n(null)},fo=(e,a,o,r)=>{let s=qa(o).trim().split(/\s+/).filter(Boolean);if(s.length===0)return[...a];let d=new Map(e.actors.map(i=>[i.id,i])),l=new Set(a.map(i=>i.id)),n=new Set;for(let i of a){let f=qa(`@${i.handle} ${i.displayName} ${r(i)??""}`);if(!s.every(m=>f.includes(m)))continue;let c=i;for(;c&&!n.has(c.id);){n.add(c.id);let m=zr(d,l,c);c=m===null?void 0:d.get(m)}}return a.filter(i=>n.has(i.id))},st=(e,a)=>e.kind==="actor"?e.actor.id===a||e.children.some(o=>st(o,a)):e.members.some(o=>st(o,a));var Gr="flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-accent aria-current:bg-primary/10 focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-2",Wr="ml-[18px] list-none border-l border-border-soft pl-1",kl={agent:"bg-glass-agent",primary:"bg-glass-primary",script:"bg-glass-script",app:"bg-glass-app"},Al={running:"text-primary",input:"text-warning",waiting:"text-muted-foreground",stopped:"text-muted-foreground/70"},vl=(e,a)=>a?e.kind==="agent"?"LLM-Agent":"TypeScript-Actor":"Agent";function co({actor:e,className:a,view:o}){let r=He(o,e);return t("span",{className:Y("grid flex-none place-items-center rounded-full text-foreground [&>svg]:size-3",kl[r],a),children:e.lifecycle?.kind==="running"?t(ve,{"aria-hidden":!0,className:"size-3"}):r==="primary"?t(ge,{}):e.kind==="agent"?t(Se,{}):t(qe,{})})}function dt({className:e,nodes:a,...o}){return t("ul",{className:Y("list-none",e),children:a.map(r=>r.kind==="actor"?t(_r,{node:r,...o},r.actor.id):t(Rl,{node:r,...o},r.key))})}function _r({node:e,...a}){return u("li",{children:[t(Pl,{actor:e.actor,...a}),e.children.length>0&&t(dt,{className:Wr,nodes:e.children,...a})]})}function Pl({actor:e,onPick:a,selectedId:o,summary:r,technical:s,view:d}){let l=Ea(d,e.id),n=no(d,e),i=r(e),f=e.displayName.trim(),c=f!==""&&f.toLocaleLowerCase("de-DE")!==e.handle.toLocaleLowerCase("de-DE")&&f!==i,m=e.id===o;return u("button",{"aria-current":m||void 0,className:Gr,"data-actor-handle":e.handle,onClick:()=>a(e),title:`@${e.handle}, ${vl(e,s)}, ${lt(n)}. Nachrichten an @${e.handle} richten`,type:"button",children:[t(co,{actor:e,className:"size-5",view:d}),u("span",{className:"grid min-w-0 flex-1",children:[u("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[u("span",{className:"truncate font-semibold",children:["@",e.handle]}),c&&t("span",{className:"min-w-0 truncate text-[0.66rem] text-muted-foreground",children:f})]}),i&&t("span",{className:"truncate text-[0.66rem] text-muted-foreground",children:i})]}),l>0&&t(se,{className:"h-4 min-w-4 px-1 text-[0.6rem]",variant:"secondary",children:l}),t("span",{className:Y("flex-none text-[0.66rem]",Al[n]),"data-addressee-status":n,children:lt(n)})]})}function Rl({node:e,...a}){let{onToggle:o,openByDefault:r,selectedId:s,toggled:d,view:l}=a,n=e.members.map(h=>h.actor),i=(r||st(e,s))!==d.has(e.key),f=Ur(l,n),c=n.some(h=>h.lifecycle?.kind==="running"),m=n.reduce((h,C)=>h+Ea(l,C.id),0);return u("li",{children:[u("button",{"aria-expanded":i,className:Gr,"data-addressee-group":e.label,onClick:()=>o(e.key),title:`${e.label}: ${n.length} gleichartige Actors, ${f}. Klick ${i?"klappt die Gruppe zu":"zeigt alle"}`,type:"button",children:[t("span",{className:"grid size-5 flex-none place-items-center text-muted-foreground",children:t(Sa,{"aria-hidden":!0,className:Y("size-3.5 transition-transform",i&&"rotate-90")})}),u("span",{className:"grid min-w-0 flex-1",children:[u("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[t("span",{className:"truncate font-semibold",children:e.label}),u("span",{className:"flex-none text-[0.66rem] text-muted-foreground",children:[n.length," Actors"]})]}),t("span",{className:"truncate text-[0.66rem] text-muted-foreground",children:f})]}),c&&t(ve,{"aria-hidden":!0,className:"size-3 flex-none text-primary"}),m>0&&t(se,{className:"h-4 min-w-4 px-1 text-[0.6rem]",variant:"secondary",children:m})]}),i&&t("ul",{className:Wr,children:e.members.map(h=>t(_r,{node:h,...a},h.actor.id))})]})}var Ml="flex h-7 min-w-[70px] max-w-[220px] flex-[0_1_auto] cursor-pointer items-center gap-1.5 rounded-full border border-border bg-background pr-2 pl-1 text-[0.72rem] font-semibold text-foreground hover:bg-accent aria-expanded:border-primary focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:outline-offset-1",Tl="flex h-7 min-w-0 flex-[0_1_auto] cursor-pointer items-center gap-1.5 rounded-md px-1.5 text-[0.7rem] text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:outline-offset-1";function Xr({hidden:e,onOpenChange:a,onReveal:o,onSelect:r,runId:s,selected:d,shown:l,technical:n,view:i}){let[f,c]=w(!1),[m,h]=w(""),[C,x]=w(!1),[L,b]=w(()=>new Set),P=U(null),y=pe(),D=q(H=>{c(H),a(H)},[a]),R=q((H=!1)=>{D(!1),h(""),H&&P.current?.focus({preventScroll:!0})},[D]),K=q(H=>{H?.querySelector("[aria-current=true]")?.scrollIntoView({block:"nearest"})},[]),V=B(()=>[...l,...e].filter(H=>H.lifecycle?.kind==="running"&&H.id!==d.id),[e,d.id,l]),k=B(()=>Vr(i),[i]),M=m.trim()!=="",G=B(()=>io(i,fo(i,l,m,k)),[m,l,k,i]),S=B(()=>fo(i,e,m,k),[e,m,k,i]),j=B(()=>io(i,S),[S,i]),$=C||M&&S.length>0,ie=q(H=>b(Le=>{let ae=new Set(Le);return ae.delete(H)||ae.add(H),ae}),[]),Q=(H,Le)=>{(Le?o:r)(H),R(!0)},fe=V.map(H=>`@${H.handle} arbeitet`).join(", "),v=V.length>0?Ea(i,V[0].id):0,F={onToggle:ie,openByDefault:M,selectedId:d.id,summary:k,technical:n,toggled:L,view:i},_="px-1.5 py-1";return u(X,{children:[u("button",{"aria-controls":f?y:void 0,"aria-expanded":f,"aria-haspopup":"dialog",className:Ml,onClick:()=>D(!f),ref:P,title:`Adressat: @${d.handle}. Klick w\xE4hlt einen anderen Actor`,type:"button",children:[t(co,{actor:d,className:"size-5",view:i}),u("span",{className:"truncate",children:["@",d.handle]}),t(Qe,{"aria-hidden":!0,className:"size-3 flex-none text-muted-foreground"})]}),V.length>0&&u("button",{className:Tl,onClick:()=>D(!f),title:fe,type:"button",children:[t(ve,{"aria-hidden":!0,className:"size-3 flex-none"}),u("span",{className:"truncate in-data-[compact=true]:hidden",children:["@",V[0].handle]}),v>0&&t(se,{className:"h-4 min-w-4 px-1 text-[0.6rem]",variant:"secondary",children:v}),V.length>1&&u("span",{className:"flex-none",children:["+",V.length-1]})]}),f&&u(oa,{buttonRef:P,closeLabel:"Adressat schlie\xDFen",height:460,id:y,label:"Adressat",onClose:R,open:!0,placement:"top",role:"dialog",width:"available",children:[l.length+e.length>Hr&&t("div",{className:"flex-none border-b border-border-soft px-2.5 py-1.5",children:t(te,{"aria-label":"Actors durchsuchen",className:"h-7",onChange:H=>h(H.target.value),placeholder:"Handle oder Aufgabe suchen ...",type:"search",value:m})}),u("div",{className:"min-h-0 flex-1 overflow-auto overscroll-contain",ref:K,children:[t(dt,{className:_,nodes:G,onPick:H=>Q(H,!1),...F}),M&&G.length===0&&S.length===0&&t("p",{className:"px-3.5 py-2 text-muted-foreground",children:"Kein Actor passt zur Suche."}),e.length>0&&(!M||S.length>0)&&u("div",{className:"border-t border-border-soft",children:[u("button",{"aria-expanded":$,className:"flex w-full cursor-pointer items-center justify-between gap-2 px-3.5 py-2 text-left text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-2",onClick:()=>x(!$),type:"button",children:[u("span",{children:[e.length," ausgeblendete Actors"]}),t(Qe,{"aria-hidden":!0,className:Y("size-3.5 flex-none transition-transform",$&&"rotate-180")})]}),$&&t(dt,{className:_,nodes:j,onPick:H=>Q(H,!0),...F})]})]}),t("div",{className:"flex flex-none items-stretch border-t border-border-soft",children:t(ot,{runId:s})})]})]})}var mo=Object.freeze({sideWidth:900,openDelay:160,closeDelay:150}),go="ragents.orchestration.run-panel-settings",ra=Object.freeze({sideWidth:{min:400,max:4e3},openDelay:{min:0,max:5e3},closeDelay:{min:0,max:1e4}}),po=(e,a)=>typeof e=="number"&&Number.isInteger(e)&&e>=a.min&&e<=a.max;function Dl(e){if(e===null)return mo;let a=JSON.parse(e);if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(o=>!["sideWidth","openDelay","closeDelay"].includes(o))||!("sideWidth"in a)||!po(a.sideWidth,ra.sideWidth)||!("openDelay"in a)||!po(a.openDelay,ra.openDelay)||!("closeDelay"in a)||!po(a.closeDelay,ra.closeDelay))throw new Error("Die Einstellungen des Run-Panels sind ung\xFCltig: Breite 400 bis 4000 Pixel, Verz\xF6gerungen 0 bis 5000 beziehungsweise 10000 Millisekunden, ganze Zahlen.");return a}var Kr=ne({changeEvent:"ragents-run-panel-settings-change",matchesKey:e=>e===go,parse:Dl,serialize:JSON.stringify});function ut(){return Kr.useValue(go)}function $r(e){Kr.save(go,e)}var Bl=1500,Zr=e=>e.some(a=>a.role==="user"||a.role==="action"||a.role==="assistant"&&(a.text.trim()!==""||(a.attachments?.length??0)>0));function Jr(e,a,o){let[r,s]=w(o),[d,l]=w(),n=a&&e?.kind==="working"?e:void 0,i=n?.title,f=n?.detail;return O(()=>{o&&s(!0)},[o]),O(()=>{if(i!==void 0&&f!==void 0){l({kind:"working",title:i,detail:f});return}let c=window.setTimeout(()=>l(void 0),Bl);return()=>window.clearTimeout(c)},[f,i]),o||r?void 0:e??d}var xo=280,Yr=380,Fl=300,Nl=Object.freeze({element:null,actor:null,chat:"side",chatWidth:Yr,sheetExpandedHeight:null}),es=e=>`ragents.orchestration.run-panel:${e}`,jr=e=>e===null||typeof e=="string",Qr=e=>e===void 0||e==="side"||e==="auto"?"side":e==="chat"?"chat":e==="bottom"||e==="floating"||e==="docked"?"bottom":void 0;function El(e){if(e===null)return Nl;let a=JSON.parse(e);if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(r=>!["element","stageHeight","actor","chat","chatWidth","sheetExpandedHeight","sheetPeekExtra"].includes(r))||!("element"in a)||!jr(a.element)||!("actor"in a)||!jr(a.actor)||Qr("chat"in a?a.chat:void 0)===void 0||"chatWidth"in a&&(typeof a.chatWidth!="number"||!Number.isFinite(a.chatWidth)||a.chatWidth<xo)||"sheetExpandedHeight"in a&&a.sheetExpandedHeight!==null&&(typeof a.sheetExpandedHeight!="number"||!Number.isFinite(a.sheetExpandedHeight)||a.sheetExpandedHeight<=0)||"sheetPeekExtra"in a&&(typeof a.sheetPeekExtra!="number"||!Number.isFinite(a.sheetPeekExtra)||a.sheetPeekExtra<0))throw new Error("Der gespeicherte Panelzustand ist ung\xFCltig.");let o=a;return{element:o.element,actor:o.actor,chat:Qr(o.chat)??"side",chatWidth:o.chatWidth??Yr,sheetExpandedHeight:o.sheetExpandedHeight??null}}var as=({chat:e,hasElement:a,narrow:o})=>!a||e==="chat"?"full":!o&&e==="side"?"side":"floating",ho=(e,a)=>Math.max(xo,Math.min(Math.round(e),Math.max(xo,a-Fl))),ts=ne({changeEvent:"ragents-run-panel-change",matchesKey:e=>e.startsWith("ragents.orchestration.run-panel:"),parse:El,serialize:JSON.stringify});function os(e){return ts.useValue(es(e))}function rs(e,a){ts.save(es(e),a)}var ss=(e,a=160)=>{let o=e.trim().split(/\r?\n/).find(r=>r.trim()!=="")??"";return o.length>a?`${o.slice(0,a-1)}\u2026`:o},ls=(e,a)=>e.role==="user"?"Du":e.sender??`@${a}`;function ds(e,a,o){let r=e[e.length-1],s=e.filter(l=>l.role==="action"&&l.action?.status===void 0).length;if(s>0)return{kind:"waiting",text:s===1?"Wartet auf Eingabe":`Wartet auf ${s} Eingaben`};if(a)return r?.role==="thinking"&&!r.closed?{kind:"working",text:`@${o} denkt ...`}:r?.role==="tool"&&r.tool&&r.tool.result===void 0?{kind:"working",text:`@${o} nutzt ${r.tool.name} ...`}:r?.role==="assistant"&&!r.closed&&r.text.trim()!==""?{kind:"working",text:`${ls(r,o)} antwortet: ${ss(r.text)}`}:{kind:"working",text:`@${o} arbeitet ...`};let d=[...e].reverse().find(l=>(l.role==="user"||l.role==="assistant")&&l.text.trim()!=="");return d?{kind:"idle",text:`${ls(d,o)}: ${ss(d.text)}`}:{kind:"idle",text:"Noch keine Nachrichten."}}var ql=220,Ol="flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-shell px-2 py-1.5",Hl="flex h-7 max-w-[200px] flex-none cursor-pointer items-center gap-1.5 rounded-full border border-border bg-card pr-2 pl-1 text-[0.72rem] font-semibold text-foreground hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:outline-offset-1 aria-pressed:border-primary aria-pressed:bg-primary/10",Ul={full:"relative flex min-h-0 min-w-0 flex-1 flex-col",side:"relative flex min-h-0 min-w-0 flex-col",floating:"absolute inset-x-2.5 bottom-0 z-20 flex flex-col overflow-hidden rounded-t-2xl border border-b-0 border-border bg-card shadow-[0_-16px_60px_#00000080] transition-[height] duration-300 ease-[cubic-bezier(.32,.72,0,1)] motion-reduce:transition-none"},Vl="rounded-none border-0 bg-transparent",zl="aria-pressed:bg-accent aria-pressed:text-primary",Gl=[{Icon:ya,label:"Nur Chat",mode:"chat",title:"Nur Chat: der Chat f\xFCllt das Run-Panel, die Mini-App tritt zur\xFCck"},{Icon:ka,label:"Chat unten",mode:"bottom",title:"Chat unten: das Sheet \xFCber der Mini-App"},{Icon:Aa,label:"Chat rechts",mode:"side",title:"Chat rechts: neben der Mini-App"}];function us(e){return t(Wl,{...e},e.session.session.id)}function Wl({surfaceElements:e,cardSections:a,navigation:o,renderChat:r,session:s,toolbarContainer:d}){let l=s.session.id,n=W().can("runs.inspect"),i=rt(),f=J(s.runView),c=os(l),m=lo(l),h=U(null),C=U(null),x=U(null),L=U(null),[b,P]=w(c.chatWidth),[y,D]=w(0),[R,K]=w(!1),V=ut();O(()=>P(c.chatWidth),[c.chatWidth]),O(()=>{let A=h.current;if(!A)return;let re=new ResizeObserver(([Ce])=>D(Ce.contentRect.width));return re.observe(A),()=>re.disconnect()},[]);let k=q(A=>rs(l,{...c,...A}),[l,c]),M=B(()=>e.flatMap(({Element:A,select:re})=>re(s).filter(Ce=>Ce.visible!==!1).map(Ce=>({Element:A,definition:Ce}))),[e,s]),G=M.find(A=>A.definition.id===c.element)??M[0],S=Jr(Ja({view:f,startup:s.startup,connected:s.connected,running:s.running,error:s.conversationError}),s.connected,M.length>0||Zr(s.messages)),j=S?t(Yl,{state:S}):void 0,$=B(()=>f?Er(f,n):[],[n,f]),ie=Na(l),Q=Ya(l),fe=B(()=>new Set(M.flatMap(({definition:A})=>A.anchorActorId?[A.anchorActorId]:[])),[M]),v=f?we(f):void 0,F=$.find(A=>A.id===c.actor)??$.find(A=>A.id===v)??$[0],{shown:_,hidden:H}=B(()=>qr($,{mode:ie,primaryId:v,selectedId:F?.id,onStage:A=>A.id===v||ta(A,fe,Q,v)}),[$,fe,ie,Q,v,F?.id]),Le=()=>h.current?.clientWidth??Number.POSITIVE_INFINITY,ae=q(A=>k({actor:A.id}),[k]),sa=q(A=>{et(l,{...Q,actorVisibility:{...Q.actorVisibility,[A.id]:!0}}),k({actor:A.id})},[Q,l,k]),Oa=q(A=>{let re=A.type==="actor"?$.find(Ce=>Ce.id===A.id):void 0;re&&ae(re)},[$,ae]),ye=F===void 0||F.id===v,I=y<V.sideWidth,g=as({chat:c.chat,hasElement:G!==void 0,narrow:I}),T=Xl(g==="floating",C,x,R,V.openDelay),N=Kl(g==="floating",C,x,L,F?.id),ue=Math.max(N.minimum,Math.min(c.sheetExpandedHeight??N.maximum,N.maximum)),Z=$l(g==="floating",C,x,T,N,ue,A=>k({sheetExpandedHeight:Math.round(A)})),ce=U(null);O(()=>{if(g!=="floating"||!T.expanded)return;let A=ce.current;if(!A)return;let re=()=>{A.scrollTop=A.scrollHeight};re();let Ce=window.setTimeout(re,320);return()=>window.clearTimeout(Ce)},[g,T.expanded]);let ke=B(()=>{if(g!=="floating"||!F)return;let A=ye?s.messages:s.actorConversations?.[F.id]??[],re=ye?s.connected&&(s.running||Vt(s.runView,l)):F.lifecycle?.kind==="running";return ds(A,re,F.handle)},[g,ye,l,F,s.actorConversations,s.connected,s.messages,s.runView,s.running]),la=f&&F&&t(Xr,{hidden:H,onOpenChange:K,onReveal:sa,onSelect:ae,runId:l,selected:F,shown:_,technical:n,view:f}),Ie=G&&d&&na(t(_l,{narrow:I,onChange:A=>k({chat:A}),selected:c.chat,sideWidth:V.sideWidth}),d),bs=ye||!f||!F?r({chatElementClassName:Vl,chatScrollerRef:A=>{ce.current=A},notice:j,toolbarLeft:la}):t(Ql,{actor:F,cardSections:a,navigation:o,notice:j,onNavigate:Oa,session:s,toolbarLeft:la,view:f});return u("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-app","data-run-panel":"run",ref:h,children:[Ie,g!=="full"&&M.length>1&&t("nav",{"aria-label":"Mini-Apps des Runs",className:Ol,children:M.map(({definition:A})=>t(Zl,{centered:m.has(A.id),definition:A,onSelect:()=>m.has(A.id)?i.openInCenter(l,A.id,A.title??A.id):k({element:A.id}),selected:A.id===G?.definition.id,session:s,view:f},A.id))}),u("div",{className:Y("relative min-h-0 min-w-0 flex-1",g==="side"?"grid":"flex flex-col"),"data-chat-layout":g,style:g==="side"?{gridTemplateColumns:`minmax(0,1fr) auto ${b}px`}:void 0,children:[g!=="full"&&G&&t(Jl,{centered:m.has(G.definition.id),element:G,navigation:o,peek:g==="floating"?N.minimum:0,runId:l,session:s}),g==="side"&&t(jl,{onChange:A=>P(ho(A,Le())),onCommit:A=>k({chatWidth:ho(A,Le())}),value:b}),g==="floating"&&t("div",{"aria-hidden":!0,className:"absolute inset-0 z-[15] bg-backdrop opacity-0 transition-opacity duration-300 pointer-events-none data-expanded:pointer-events-auto data-expanded:opacity-100 motion-reduce:transition-none","data-expanded":T.expanded||void 0,onClick:T.close}),u("section",{"aria-label":"Chat",className:Y(Ul[g],g==="floating"&&"[&_[data-chat=composer]]:[--qsl-panel-height:var(--sheet-available-height)] [&:not([data-expanded])_[data-slot=card-sections]]:hidden [&[data-sheet-resizing]_[data-slot=card-sections]]:hidden"),"data-expanded":g==="floating"&&T.expanded?!0:void 0,"data-sheet-resizing":Z.height!==void 0||void 0,"data-view":ye?"chat":"actor-chat",onBlurCapture:g==="floating"?()=>T.closeLater(ql):void 0,onFocusCapture:g==="floating"?A=>{A.target!==x.current&&T.open()}:void 0,onPointerEnter:g==="floating"?A=>{A.pointerType==="mouse"&&T.openLater()}:void 0,onPointerLeave:g==="floating"?()=>T.closeLater(V.closeDelay):void 0,ref:C,style:g==="floating"?{height:Z.height??(T.expanded?ue:N.minimum),transition:Z.height!==void 0?"none":void 0,"--sheet-available-height":`${N.available}px`}:void 0,children:[g==="floating"&&t("button",{"aria-expanded":T.expanded,"aria-label":"H\xF6he des ausgeklappten Chats","aria-orientation":"horizontal","aria-valuemin":N.minimum,"aria-valuemax":N.maximum,"aria-valuenow":Math.round(Z.height??ue),className:"flex h-3 w-full flex-none cursor-row-resize touch-none items-center justify-center outline-none select-none [&:hover>span]:bg-foreground [&:focus-visible>span]:bg-foreground [&:focus-visible>span]:ring-2 [&:focus-visible>span]:ring-ring/60","data-run-panel":"sheet-grip",onClick:Z.onClick,onKeyDown:Z.onKeyDown,onPointerDown:Z.onPointerDown,onPointerMove:Z.onPointerMove,onPointerUp:Z.onPointerUp,onPointerCancel:Z.onPointerCancel,onLostPointerCapture:Z.onPointerCancel,ref:x,role:"separator",title:`Ziehen: ausgeklappte H\xF6he einstellen. Klicken: ${T.expanded?"Chat absenken":"Chat hochschieben"}.`,type:"button",children:t("span",{"aria-hidden":!0,className:"h-1 w-9 rounded-full bg-border-strong transition-colors"})}),ke&&u("button",{className:Y("flex h-6 w-full flex-none cursor-pointer items-center gap-2 px-[var(--qsl-chat-horizontal-padding,24px)] text-left text-[0.7rem] transition-opacity duration-200 in-data-expanded:pointer-events-none in-data-expanded:opacity-0 motion-reduce:transition-none",ke.kind==="waiting"?"text-warning":"text-muted-foreground"),onClick:T.toggle,ref:L,title:ke.text,type:"button",children:[ke.kind==="working"&&t(ve,{"aria-hidden":!0,className:"size-3 flex-none"}),t("span",{className:"truncate",children:ke.text})]}),bs]})]})]})}function _l({narrow:e,onChange:a,selected:o,sideWidth:r}){return t("div",{"aria-label":"Ansicht des Run-Panels",className:"flex flex-none items-center gap-0.5 self-center rounded-lg border border-border bg-card p-0.5",role:"group",children:Gl.map(({Icon:s,label:d,mode:l,title:n})=>{let i=l==="side"&&e;return t(z,{"aria-label":d,"aria-pressed":o===l,className:zl,disabled:i,onClick:()=>a(l),size:"icon-sm",title:i?`Chat bleibt unten, solange das Panel schmaler als ${r} Pixel ist`:n,variant:"ghost",children:t(s,{})},l)})})}function Xl(e,a,o,r,s){let[d,l]=w(!1),[n,i]=w(!1),f=U({held:n,blocked:r}),c=U(!1),m=U(void 0);O(()=>{f.current={held:n,blocked:r}},[r,n]);let h=q(()=>window.clearTimeout(m.current),[]),C=q(()=>{c.current||(h(),l(!0))},[h]),x=q(()=>{c.current||(h(),m.current=window.setTimeout(()=>{c.current||l(!0)},s))},[h,s]),L=q(R=>{c.current||(h(),m.current=window.setTimeout(()=>{c.current||f.current.held||f.current.blocked||document.activeElement!==o.current&&a.current?.contains(document.activeElement)||l(!1)},R))},[h,o,a]),b=q(()=>{h(),i(!1),l(!1),document.activeElement instanceof HTMLElement&&a.current?.contains(document.activeElement)&&document.activeElement.blur()},[h,a]),P=q(()=>{if(d){b();return}i(!0),C()},[b,d,C]),y=q(()=>{h(),c.current=!0},[h]),D=q(R=>{h(),c.current=!1,l(R?.expanded??!1),i(R?.held??!1)},[h]);return O(()=>{e||b()},[e,b]),O(()=>h,[h]),O(()=>{if(!e||!d)return;let R=K=>{K.key==="Escape"&&!c.current&&!f.current.blocked&&b()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[e,b,d]),{expanded:d,held:n,open:C,openLater:x,closeLater:L,close:b,toggle:P,pauseResize:y,finishResize:D}}function Kl(e,a,o,r,s){let[d,l]=w({minimum:0,maximum:0,available:0,scale:1});return We(()=>{if(!e)return;let n=a.current,i=o.current,f=r.current,c=n?.querySelector('[data-chat="composer"]'),m=n?.parentElement;if(!n||!i||!c||!m)throw new Error("Das Sheet des Panels findet Griff, Eingabe oder Rahmen nicht.");let h=()=>{let x=getComputedStyle(n),L=n.getBoundingClientRect().width;if(L===0)return;let b=L/Number.parseFloat(x.width),P=Math.ceil((i.getBoundingClientRect().height+(f?.getBoundingClientRect().height??0)+c.getBoundingClientRect().height)/b+Number.parseFloat(x.borderTopWidth)+Number.parseFloat(x.borderBottomWidth)),y=Math.floor(m.getBoundingClientRect().height/b*.9),D=Math.max(P,y);l(R=>R.minimum===P&&R.maximum===D&&R.available===y&&R.scale===b?R:{minimum:P,maximum:D,available:y,scale:b})},C=new ResizeObserver(h);return C.observe(c),C.observe(i),C.observe(m),f&&C.observe(f),h(),()=>C.disconnect()},[e,s,o,a,r]),d}function $l(e,a,o,r,s,d,l){let[n,i]=w(),f=U(void 0),c=U(!1),m=x=>{let L=f.current;if(!L)return;f.current=void 0,c.current=L.moved||!x;let b=o.current;b?.hasPointerCapture(L.pointerId)&&b.releasePointerCapture(L.pointerId),x&&L.moved&&l(L.height),r.finishResize(x&&L.moved?{expanded:!0,held:L.held}:L),i(void 0)},h=r.finishResize;O(()=>{e||(f.current=void 0,i(void 0),h())},[e,h]);let C=x=>Math.max(s.minimum,Math.min(x,s.maximum));return{height:n,onClick:x=>{let L=c.current&&x.detail>0;c.current=!1,!L&&r.toggle()},onPointerDown:x=>{if(x.button!==0||f.current||!a.current)return;x.preventDefault();let L=a.current.getBoundingClientRect().height/s.scale;f.current={pointerId:x.pointerId,startY:x.clientY,startHeight:L,height:L,moved:!1,expanded:r.expanded,held:r.held},c.current=!1,r.pauseResize(),i(L),x.currentTarget.setPointerCapture(x.pointerId),x.currentTarget.focus({preventScroll:!0})},onPointerMove:x=>{let L=f.current;if(!L||L.pointerId!==x.pointerId)return;let b=(L.startY-x.clientY)/s.scale;!L.moved&&Math.abs(b)<3||(L.moved=!0,L.height=C(L.startHeight+b),i(L.height))},onPointerUp:x=>{f.current?.pointerId===x.pointerId&&m(!0)},onPointerCancel:x=>{f.current?.pointerId===x.pointerId&&m(!1)},onKeyDown:x=>{if(x.key==="Escape"&&f.current){x.preventDefault(),x.stopPropagation(),m(!1);return}let L=x.key==="ArrowUp"?d+24:x.key==="ArrowDown"?d-24:x.key==="Home"?s.minimum:x.key==="End"?s.maximum:void 0;L===void 0||f.current||(x.preventDefault(),r.finishResize({expanded:!0,held:r.held}),l(C(L)))}}}function Zl({centered:e,definition:a,onSelect:o,selected:r,session:s,view:d}){let l=da(),n=a.title??a.id,i=Or(d,a,l?.needsAnswer(s,a.id)??!1);return u("button",{"aria-pressed":r&&!e,className:Hl,"data-tone":"app",onClick:o,title:e?`${n} liegt in der Mitte. Klick holt das Fenster nach vorn.`:`Mini-App ${n} anzeigen`,type:"button",children:[t("span",{className:"grid size-5 flex-none place-items-center rounded-full bg-glass-app text-foreground [&>svg]:size-3",children:t(Oe,{})}),t("span",{className:"truncate",children:n}),i&&t("span",{"aria-label":"Antwort erwartet",className:"grid size-4 flex-none place-items-center rounded-full bg-warning text-[0.62rem] font-bold text-background",role:"img",children:"!"}),e&&t(je,{"aria-hidden":!0,className:"size-3 flex-none text-muted-foreground"})]})}function Jl({centered:e,element:a,navigation:o,peek:r,runId:s,session:d}){let l=rt(),n=da(),{Element:i,definition:f}=a,c=f.title??f.id;return u("section",{"aria-label":`Mini-App ${c}`,className:"group/stage relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-app",style:r>0?{paddingBottom:r}:void 0,children:[t("div",{className:"absolute top-1.5 right-2 z-[5] flex gap-0.5 rounded-lg border border-border bg-card p-0.5 opacity-0 transition-opacity group-hover/stage:opacity-100 group-focus-within/stage:opacity-100 motion-reduce:transition-none",children:l.kind==="vscode"?t(z,{"aria-label":`${c} in die Mitte legen`,onClick:()=>l.openInCenter(s,f.id,c),size:"icon-sm",title:"In die Mitte legen",variant:"ghost",children:t(je,{})}):n&&t(z,{"aria-label":`${c} in Vollansicht \xF6ffnen`,onClick:()=>n.openFullscreen(f.id),size:"icon-sm",title:"Vollansicht",variant:"ghost",children:t(ba,{})})}),t("div",{className:"relative flex min-h-0 flex-1 flex-col","data-run-panel":"stage",children:e?u("div",{className:"m-auto grid gap-3 p-4 text-center text-[0.76rem] text-muted-foreground",role:"status",children:[u("span",{children:[c," liegt in der Mitte."]}),t(z,{onClick:()=>l.returnToRunPanel(s,f.id),size:"sm",variant:"outline",children:"Zur\xFCck ins Panel"})]}):t(i,{definition:f,navigation:o,session:d})})]})}function jl({onChange:e,onCommit:a,value:o}){let r=U(void 0),s=d=>{r.current&&(r.current=void 0,d.currentTarget.releasePointerCapture(d.pointerId),a(o))};return t("div",{"aria-label":"Breite des Chats","aria-orientation":"vertical","aria-valuenow":o,className:"flex w-2.5 flex-none cursor-col-resize touch-none items-center justify-center border-r border-l border-border bg-shell select-none hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-2",onKeyDown:d=>{let l=d.key==="ArrowRight"?-24:d.key==="ArrowLeft"?24:0;l!==0&&(d.preventDefault(),e(o+l),a(o+l))},onPointerCancel:s,onPointerDown:d=>{r.current={startX:d.clientX,startWidth:o},d.currentTarget.setPointerCapture(d.pointerId)},onPointerMove:d=>{r.current&&e(r.current.startWidth+r.current.startX-d.clientX)},onPointerUp:s,role:"separator",tabIndex:0,children:t("span",{"aria-hidden":!0,className:"h-10 w-1 rounded-full bg-border-strong"})})}function Ql({actor:e,cardSections:a,navigation:o,notice:r,onNavigate:s,session:d,toolbarLeft:l,view:n}){let i=e.lifecycle?.kind==="running";return u("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t("div",{className:`${Xa} max-h-[40%] flex-none overflow-auto overscroll-contain border-t-0 border-b`,"data-slot":"card-sections",children:a.map(({id:f,Section:c})=>t(c,{actor:e,navigation:o,session:d},f))}),t(ma,{className:"flex-1",composer:t(Je,{actor:e,presentation:"panel",running:i,display:"panel",toolbarLeft:l,view:n}),children:r??t(Ze,{actor:e,conversation:d.actorConversations?.[e.id],historyError:d.conversationError,onNavigate:s,presentation:"inspector",primaryMessages:d.messages,running:i,display:"panel",view:n})})]})}function Yl({state:e}){return t("div",{className:"grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)_auto_minmax(var(--qsl-composer-height,0px),1fr)] justify-items-center overflow-hidden p-6",children:t(pa,{className:"row-start-2",state:e})})}var ed=(e,a)=>{if(!e.revealEntity({type:"artifact",id:a.id}))throw new Error(`Kein Plugin kann das Dokument ${a.title} anzeigen`)};function ns({actor:e,navigation:a,session:o}){let r=J(o.runView);if(!r)return null;let s=_t(e).id,d=r.artifacts.filter(l=>l.createdBy===s);return d.length===0?null:u("section",{className:"grid gap-1.5",children:[u(It,{children:[t("span",{children:"Dokumente"}),t("small",{children:d.length})]}),t("ul",{className:"grid list-none gap-1",children:d.map(l=>t("li",{children:u("button",{className:"grid w-full cursor-pointer rounded-lg border border-border-soft px-2 py-1.5 text-left hover:border-[color-mix(in_srgb,var(--primary)_45%,var(--border))] hover:bg-primary/6",onClick:()=>ed(a,l),type:"button",children:[t("strong",{className:"truncate text-[0.74rem]",title:l.title,children:l.title}),u("small",{className:"text-[0.64rem] text-muted-foreground",children:[Ue(l.size)," - ",l.mediaType]})]})},l.id))})]})}var is=e=>({sideWidth:String(e.sideWidth),openDelay:String(e.openDelay),closeDelay:String(e.closeDelay)}),ad=[{key:"sideWidth",label:"Chat neben der Mini-App ab",unit:"px"},{key:"openDelay",label:"Hochschieben nach",unit:"ms"},{key:"closeDelay",label:"Zur\xFCck nach Verlassen nach",unit:"ms"}];function fs(){let e=W(),a=ut(),[o,r]=w(()=>is(a)),[s,d]=w(),[l,n]=w();O(()=>{r(is(a))},[a]);let i=e.can("settings.write"),f=c=>{if(i){n(void 0),d(void 0);try{$r(c),d("Einstellungen des Run-Panels gespeichert.")}catch(m){n(m instanceof Error?m.message:String(m))}}};return u("form",{className:"grid gap-3",onSubmit:c=>{c.preventDefault(),f({sideWidth:Number(o.sideWidth),openDelay:Number(o.openDelay),closeDelay:Number(o.closeDelay)})},children:[t("p",{className:"text-muted-foreground",children:"Ab dieser Breite des Panels liegt der Chat rechts neben der Mini-App statt als Sheet darunter. Die Verz\xF6gerungen bestimmen, wie lange die Maus \xFCber dem Sheet liegen muss, bis es hochgleitet, und wie lange es nach dem Verlassen oben bleibt. Gilt sofort f\xFCr alle Runs in diesem Browser."}),u("div",{className:"flex flex-wrap items-end gap-3",children:[ad.map(({key:c,label:m,unit:h})=>u("label",{className:"grid gap-1.5",children:[u("span",{children:[m," (",h,")"]}),t(te,{className:"w-[130px]",disabled:!i,max:ra[c].max,min:ra[c].min,onChange:C=>{r({...o,[c]:C.target.value}),d(void 0)},required:!0,step:"1",type:"number",value:o[c]})]},c)),t(z,{disabled:!i,type:"submit",children:"Speichern"}),t(z,{disabled:!i,onClick:()=>f(mo),variant:"outline",children:"Zur\xFCcksetzen"})]}),l?t("p",{className:"text-muted-foreground",role:"alert",children:l}):s&&t("p",{className:"text-muted-foreground",role:"status",children:s})]})}function cs({session:e}){let[a,o]=w(!1),[r,s]=w([]),[d,l]=w(),[n,i]=w(!1),[f,c]=w(0),[m,h]=w(""),[C,x]=w(100),L=U(null),b=U(null),P=pe(),y=J(e.runView),D=y?.revision,R=q((k=!1)=>{o(!1),k&&L.current?.focus({preventScroll:!0})},[]);O(()=>{if(!a)return;let k=new AbortController;return i(!0),l(void 0),he.call(me.events,{runId:e.session.id},{signal:k.signal}).then(M=>{k.signal.aborted||s(M)}).catch(M=>{k.signal.aborted||l(M instanceof Error?M.message:String(M))}).finally(()=>{k.signal.aborted||i(!1)}),()=>k.abort()},[a,e.session.id,D,f]);let K=B(()=>{let k=m.trim().toLocaleLowerCase("de-DE"),M=new Map(y?.actors.map(G=>[G.id,G.handle]));return[...r].reverse().filter(G=>!k||`${M.get(G.actorId)??""} ${JSON.stringify(G)}`.toLocaleLowerCase("de-DE").includes(k))},[r,m,y?.actors]),V=new Map(y?.actors.map(k=>[k.id,k.handle]));return u("div",{className:"flex h-full min-w-0 items-stretch",children:[t("button",{"aria-controls":P,"aria-expanded":a,className:_a,onClick:()=>o(k=>!k),ref:L,type:"button",children:"Journal"}),t(fa,{open:a,onOpenChange:k=>{k||R()},children:u(ca,{align:"start",anchor:L,"aria-label":"Journal des Runs",className:"flex min-h-0 min-w-0 flex-col gap-0 overflow-hidden rounded-t-sm rounded-b-none p-0 text-[0.76rem]",collisionPadding:8,id:P,initialFocus:b,role:"region",side:"top",style:{width:"min(900px, var(--available-width))",height:"min(480px, var(--available-height))"},children:[u("header",{className:"flex flex-none items-center gap-2 border-b border-border-soft px-2.5 py-2",children:[u("div",{className:"flex min-w-0 flex-1 items-baseline gap-2.5 [&>span]:truncate",children:[t("strong",{children:"Journal"}),t("span",{className:"text-muted-foreground",children:e.session.title||"Run"})]}),t(z,{onClick:()=>c(k=>k+1),size:"sm",variant:"ghost",children:"Aktualisieren"}),t(z,{"aria-label":"Journal schlie\xDFen",onClick:()=>R(!0),size:"icon-sm",title:"Journal schlie\xDFen",variant:"ghost",children:t(xe,{})})]}),u("div",{className:"flex flex-none items-center gap-3 px-2.5 py-2",children:[t(te,{className:"flex-1","aria-label":"Journal durchsuchen",onChange:k=>{h(k.target.value),x(100)},placeholder:"Ereignistyp, Actor oder Inhalt suchen ...",ref:b,type:"search",value:m}),t("span",{className:"flex-none whitespace-nowrap text-[0.68rem] text-muted-foreground",role:"status",children:n?"L\xE4dt ...":`${K.length} Ereignisse`})]}),d&&t("p",{className:"flex-none px-2.5 pb-2 text-destructive",role:"alert",children:d}),u("div",{"aria-label":"Journalereignisse, neueste zuerst",className:"min-h-0 flex-1 overflow-auto overscroll-contain px-2.5 pb-2.5",children:[!n&&!d&&K.length===0&&t("p",{className:"text-muted-foreground",children:m?"Keine passenden Ereignisse.":"Das Journal enth\xE4lt noch keine Ereignisse."}),K.slice(0,C).map(k=>t(td,{actor:V.get(k.actorId),event:k},k.eventId)),K.length>C&&t(z,{onClick:()=>x(k=>k+100),size:"sm",variant:"outline",children:"Weitere Ereignisse anzeigen"})]})]})})]})}function td({actor:e,event:a}){let[o,r]=w(!1);return u("details",{className:"border-b border-border-soft open:[&>summary]:text-primary",onToggle:s=>r(s.currentTarget.open),children:[u("summary",{className:"grid cursor-pointer grid-cols-[32px_minmax(130px,1fr)_minmax(70px,140px)_auto] items-baseline gap-2 px-0.5 py-2 text-[0.68rem] focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 max-[550px]:grid-cols-[24px_minmax(0,1fr)_auto] max-[550px]:gap-x-2 max-[550px]:gap-y-1",children:[t("span",{className:"text-muted-foreground tabular-nums",children:a.sequence}),t("span",{className:"font-mono [overflow-wrap:anywhere]",children:a.type}),t("span",{className:"truncate max-[550px]:col-start-2 max-[550px]:row-start-2",title:a.actorId,children:e?`@${e}`:a.actorId}),t("time",{className:"text-muted-foreground tabular-nums max-[550px]:col-start-3 max-[550px]:row-start-1",dateTime:a.occurredAt,children:new Date(a.occurredAt).toLocaleTimeString("de-DE")})]}),o&&t(Me,{className:"m-0 mb-2 text-[0.68rem]",content:JSON.stringify(a,null,2),language:"json",path:"event.json"})]})}var od="Not-Aus durch den Bediener";function ps({session:e}){return t(Ne,{className:"max-w-none",children:t(rd,{runId:e.session.id},e.session.id)})}function rd({runId:e}){let a=W().can("runs.write"),[o,r]=w(!1),[s,d]=w(!1),[l,n]=w(),i=async()=>{d(!0),n(void 0);try{await ur(e,od),r(!1)}catch(f){n(f instanceof Error?f.message:String(f))}finally{d(!1)}};return a?o?u("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap",children:[t("span",{className:"text-[0.72rem] font-semibold text-destructive",children:"Wirklich alles stoppen?"}),t(z,{disabled:s,onClick:()=>{i()},size:"sm",variant:"destructive",children:"Ja"}),t(z,{disabled:s,onClick:()=>r(!1),size:"sm",variant:"outline",children:"Abbrechen"}),l&&t("span",{className:"max-w-[260px] truncate text-[0.7rem] text-destructive",title:l,children:l})]}):u(z,{onClick:()=>r(!0),size:"sm",title:"Beendet den ganzen Run: Turns, Agenten und Abl\xE4ufe",variant:"destructive",children:[t(kt,{"data-icon":"inline-start"}),"Run stoppen"]}):null}var nt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),sd=(e,a,o)=>JSON.stringify([e,a,o]),ms=(e,a)=>{if(!Array.isArray(e)||e.some(o=>{if(!nt(o)||o.runId!==a||typeof o.eventId!="string"||typeof o.actorId!="string"||!Number.isSafeInteger(o.sequence)||typeof o.occurredAt!="string"||!Number.isFinite(Date.parse(o.occurredAt))||typeof o.type!="string"||!nt(o.payload))return!0;let r=o.payload;return o.type.startsWith("tool.call.")&&(typeof r.turnId!="string"||typeof r.toolCallId!="string")?!0:o.type==="tool.call.source"?typeof r.code!="string"||r.path!==null&&typeof r.path!="string":o.type==="tool.call.started"?typeof r.name!="string"||!("input"in r):o.type==="tool.call.completed"?typeof r.name!="string"||!("output"in r):o.type==="tool.call.failed"?typeof r.name!="string"||typeof r.error!="string":o.type==="turn.finished"?typeof r.turnId!="string"||!["completed","failed"].includes(String(r.outcome)):o.type==="turn.interrupted"?typeof r.turnId!="string"||typeof r.reason!="string":!1}))throw new Error("Der Server hat kein g\xFCltiges Journal f\xFCr diesen Run geliefert.");return e},gs=(e,a)=>{let o=new Map,r=new Map(a?.actors.map(l=>[l.id,l])),s=new Map;for(let l of[...e].sort((n,i)=>n.sequence-i.sequence)){if(a&&l.runId!==a.id)continue;if(l.type==="turn.finished"||l.type==="turn.interrupted"){s.set(JSON.stringify([l.actorId,l.payload.turnId]),{at:l.occurredAt,reason:"reason"in l.payload?l.payload.reason:null});continue}if(l.type!=="tool.call.started"&&l.type!=="tool.call.completed"&&l.type!=="tool.call.failed"&&l.type!=="tool.call.source")continue;let n=sd(l.actorId,l.payload.turnId,l.payload.toolCallId);if(l.type==="tool.call.started"){if(l.payload.name!=="typescript_eval"||o.has(n))continue;let f=r.get(l.actorId),c=nt(l.payload.input)?l.payload.input:{};o.set(n,{key:n,actorId:l.actorId,actorHandle:f?.handle??l.actorId,actorName:f?.displayName??l.actorId,turnId:l.payload.turnId,toolCallId:l.payload.toolCallId,sequence:l.sequence,startedAt:l.occurredAt,finishedAt:null,status:"running",code:typeof c.code=="string"?c.code:null,path:typeof c.path=="string"?c.path:null,result:void 0,logs:[],error:null});continue}let i=o.get(n);if(i)if(l.type==="tool.call.source")i.code=l.payload.code,i.path=l.payload.path;else if(l.type==="tool.call.completed"){i.status="completed",i.finishedAt=l.occurredAt;let f=l.payload.output,c=nt(f)&&"result"in f&&Array.isArray(f.logs)&&f.logs.every(m=>typeof m=="string");i.result=c?f.result:f,i.logs=c?f.logs:[]}else i.status="failed",i.finishedAt=l.occurredAt,i.error=l.payload.error}let d=new Map(a?.turns.map(l=>[JSON.stringify([l.actorId,l.id]),l]));for(let l of o.values()){if(l.status!=="running")continue;let n=JSON.stringify([l.actorId,l.turnId]),i=d.get(n),f=i?.toolCalls?.find(m=>m.id===l.toolCallId&&m.name==="typescript_eval"),c=s.get(n);f&&f.status!=="running"?(l.status=f.status,l.finishedAt=f.finishedAt??i?.finishedAt??c?.at??null):(c||i&&i.status!=="running")&&(l.status="interrupted",l.finishedAt=c?.at??i?.finishedAt??null),l.status==="interrupted"&&(l.error=c?.reason??i?.reason??"Der Aufruf wurde unterbrochen.")}return[...o.values()].sort((l,n)=>n.sequence-l.sequence)},it=e=>({running:"L\xE4uft",completed:"Fertig",failed:"Fehlgeschlagen",interrupted:"Unterbrochen"})[e],xs=(e,a,o)=>{let r=a.trim().toLocaleLowerCase("de-DE");return e.filter(s=>(o==="all"||s.status===o)&&(!r||[s.actorId,s.actorHandle,s.actorName,s.code,s.path,JSON.stringify(s.result),...s.logs,s.error,it(s.status)].join(`
7
+ `).toLocaleLowerCase("de-DE").includes(r)))},hs=(e,a)=>{let o=Math.max(0,(e.finishedAt?Date.parse(e.finishedAt):a)-Date.parse(e.startedAt));if(!Number.isFinite(o))return"Dauer unbekannt";if(o<1e3)return`${o} ms`;let r=Math.floor(o/1e3);return r<60?`${r} s`:`${Math.floor(r/60)} min ${r%60} s`};var Cs="ragents.orchestration.executions";function Ss({active:e,session:a}){let o=J(a.runView),r=a.session.id;return t(ld,{active:e,runId:r,view:o?.id===r?o:void 0},r)}function ld({active:e,runId:a,view:o}){let[r,s]=w({events:[],loaded:!1,loading:!1,error:null}),[d,l]=w(""),[n,i]=w("all"),f=[{value:"all",label:"Alle Status"},...["running","completed","failed","interrupted"].map(y=>({value:y,label:it(y)}))],[c,m]=w(Date.now),[h,C]=w(0),x=o?.revision;O(()=>{if(!e)return;let y=new AbortController;return s(D=>({...D,loading:!0,error:null})),he.call(me.events,{runId:a},{signal:y.signal}).then(D=>{let R=ms(D,a);y.signal.aborted||s({events:R,loaded:!0,loading:!1,error:null})}).catch(D=>{y.signal.aborted||s(R=>({...R,loading:!1,error:D instanceof Error?D.message:String(D)}))}),()=>y.abort()},[e,a,x,h]);let L=B(()=>gs(r.events,o),[r.events,o]),b=B(()=>xs(L,d,n),[L,d,n]),P=L.some(y=>y.status==="running");return O(()=>{if(!e||!P)return;m(Date.now());let y=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(y)},[e,P]),u("section",{"aria-label":"TypeScript-Ausf\xFChrungen",className:"flex h-full min-h-0 min-w-0 flex-col bg-background text-[0.78rem] text-foreground",children:[u("header",{className:"px-3.5 pt-3.5 pb-2.5",children:[t("h2",{className:"mb-1.5 text-[0.92rem]",children:"Executions"}),t("p",{className:"leading-[1.5] text-muted-foreground",children:"TypeScript-Snippets aller Actors in diesem Run."})]}),u("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-2 border-b border-border-soft px-3.5 pb-3",children:[t(te,{className:"col-span-full","aria-label":"Ausf\xFChrungen durchsuchen",onChange:y=>l(y.target.value),placeholder:"Actor, Code oder Ergebnis suchen",type:"search",value:d}),u(Ct,{items:f,value:n,onValueChange:y=>{y!==null&&i(y)},children:[t(bt,{className:"min-w-0","aria-label":"Ausf\xFChrungsstatus",children:t(yt,{})}),t(St,{children:f.map(y=>t(wt,{value:y.value,children:y.label},y.value))})]}),t("span",{className:"self-center text-right text-[0.68rem] text-muted-foreground",role:"status",children:r.loading?r.loaded?"Aktualisiert ...":"L\xE4dt ...":r.loaded?`${b.length} von ${L.length} Ausf\xFChrungen`:"Noch nicht geladen"})]}),r.error&&u(ht,{className:"mx-3.5 my-2 w-auto",variant:"destructive",children:[u(Lt,{className:"whitespace-pre-wrap text-destructive [overflow-wrap:anywhere]",children:[r.error,r.loaded?" Der zuletzt geladene Stand bleibt sichtbar.":""]}),t(z,{disabled:!e||r.loading,onClick:()=>C(y=>y+1),size:"sm",variant:"ghost",children:"Erneut laden"})]}),u("div",{"aria-label":"Ausf\xFChrungen, neueste zuerst",className:"min-h-0 flex-1 overflow-auto overscroll-contain px-3 pb-3",children:[r.loaded&&!r.loading&&b.length===0&&t("p",{className:"mx-0.5 my-4.5 leading-[1.6] text-muted-foreground",children:L.length===0?"In diesem Run wurde noch kein TypeScript-Snippet ausgef\xFChrt.":"Keine Ausf\xFChrungen passen zu dieser Suche."}),b.map(y=>t(id,{execution:y,now:c},y.key))]})]})}var dd={running:"bg-background text-info",completed:"bg-success-soft text-success",failed:"bg-destructive-soft text-destructive",interrupted:"bg-warning-soft text-warning"},ud="relative grid cursor-pointer list-none grid-cols-[minmax(0,1fr)_auto] gap-x-2 gap-y-[7px] pt-3 pr-2.5 pb-2.5 pl-[25px] focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 [&::-webkit-details-marker]:hidden before:absolute before:top-[15px] before:left-2.5 before:size-[5px] before:rotate-[-45deg] before:border-r-[1.5px] before:border-b-[1.5px] before:border-solid before:border-current before:content-['']",nd="min-w-0 border-t border-border-soft px-2.5 pb-2.5 [&>h3]:mt-3 [&>h3]:mb-1.5 [&>h3]:text-[0.72rem] [&>h3]:font-[650]",Ls="m-0 max-h-[28rem] overflow-auto text-[0.68rem]",Is="m-0 max-h-[24rem] overflow-auto rounded-sm bg-background p-2 font-mono text-[0.68rem] leading-[1.5] whitespace-pre-wrap [overflow-wrap:anywhere]";function id({execution:e,now:a}){let[o,r]=w(!1),s=e.code?.trim().split(`
8
8
  `).find(d=>d.trim())??e.path??"TypeScript-Snippet";return u("details",{className:"mt-2.5 overflow-hidden rounded-sm border border-border-soft bg-card open:[&>summary]:before:rotate-45",onToggle:d=>r(d.currentTarget.open),children:[u("summary",{className:ud,children:[u("span",{className:"truncate font-[650]",title:`${e.actorName} (${e.actorId})`,children:["@",e.actorHandle]}),t(se,{className:`h-auto rounded-[5px] px-[5px] py-0.5 text-[0.64rem] ${dd[e.status]??"bg-secondary text-muted-foreground"}`,children:it(e.status)}),t("span",{className:"col-span-full truncate font-mono text-[0.68rem]",title:s,children:s}),u("span",{className:"col-span-full flex flex-wrap justify-between gap-x-3 gap-y-1.5 text-[0.65rem] tabular-nums text-muted-foreground",children:[t("time",{dateTime:e.startedAt,title:new Date(e.startedAt).toLocaleString("de-DE"),children:new Date(e.startedAt).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}),t("span",{children:hs(e,a)})]})]}),o&&u("div",{className:nd,children:[e.path&&u("p",{className:"mt-2.5 grid gap-1 text-[0.68rem] text-muted-foreground",children:[t("span",{children:"Pfad"}),t("code",{className:"[overflow-wrap:anywhere]",children:e.path})]}),t("h3",{children:"Code"}),e.code!==null?t(Me,{className:Ls,content:e.code,language:"typescript",path:e.path??"snippet.ts"}):t("p",{className:"text-[0.72rem] leading-[1.5] text-muted-foreground",children:e.path?"F\xFCr diesen Pfadaufruf ist kein historischer Code gespeichert.":"F\xFCr diesen Aufruf ist kein historischer Code gespeichert."}),e.logs.length>0&&u(X,{children:[t("h3",{children:"Logs"}),t("pre",{className:Is,children:e.logs.join(`
9
- `)})]}),e.result!==void 0&&u(X,{children:[t("h3",{children:"Ergebnis"}),t(Me,{className:Ls,content:JSON.stringify(e.result,null,2),language:"json",path:"result.json"})]}),e.error&&u(X,{children:[t("h3",{children:e.status==="interrupted"?"Unterbrechung":"Fehler"}),t("pre",{className:`${Is} text-destructive`,children:e.error})]})]})]})}function ws(){return t("svg",{"aria-hidden":!0,fill:"none",height:"15",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.7",viewBox:"0 0 24 24",width:"15",children:t("path",{d:"m7 7-4 5 4 5m10-10 4 5-4 5M14 4l-4 16"})})}function fd({children:e,navigation:a,session:o}){let r=J(o.runView),[s,d]=w();return O(()=>{r||d(void 0)},[r]),t(Mt,{value:{acceptSelection:n=>{n?.type==="artifact"&&a.revealEntity(n)||d(n)},selection:s},children:e})}var Ih={id:Gt,needsRunView:!0,sessionStatus:[{id:"ragents.orchestration.journal",readRight:"runs.inspect",order:20,Status:cs}],sessionHeaders:[{id:"ragents.orchestration.stop",readRight:"runs.write",order:100,Header:ps},{id:"ragents.orchestration.actors",order:300,placement:"surface",Header:Fr}],settings:[{id:"ragents.orchestration.runPanel",category:"appearance",label:"Run-Panel",Settings:fs}],surface:{Center:Er,RunPanel:us},cardSections:[{id:"ragents.orchestration.documents",order:300,Section:ns}],SessionProvider:fd,workspaceTabs:[{id:Cs,readRight:"runs.inspect",label:"Executions",order:110,Icon:ws,Panel:Ss,keepMounted:!0,available:e=>J(e.runView)!==void 0}]};export{Gt as ORCHESTRATION_PLUGIN_ID,Ih as webPlugin};
9
+ `)})]}),e.result!==void 0&&u(X,{children:[t("h3",{children:"Ergebnis"}),t(Me,{className:Ls,content:JSON.stringify(e.result,null,2),language:"json",path:"result.json"})]}),e.error&&u(X,{children:[t("h3",{children:e.status==="interrupted"?"Unterbrechung":"Fehler"}),t("pre",{className:`${Is} text-destructive`,children:e.error})]})]})]})}function ws(){return t("svg",{"aria-hidden":!0,fill:"none",height:"15",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.7",viewBox:"0 0 24 24",width:"15",children:t("path",{d:"m7 7-4 5 4 5m10-10 4 5-4 5M14 4l-4 16"})})}function fd({children:e,navigation:a,session:o}){let r=J(o.runView),[s,d]=w();return O(()=>{r||d(void 0)},[r]),t(Mt,{value:{acceptSelection:n=>{n?.type==="artifact"&&a.revealEntity(n)||d(n)},selection:s},children:e})}var Ih={id:Gt,needsRunView:!0,sessionStatus:[{id:"ragents.orchestration.journal",readRight:"runs.inspect",order:20,Status:cs}],sessionHeaders:[{id:"ragents.orchestration.stop",readRight:"runs.write",order:100,Header:ps},{id:"ragents.orchestration.actors",order:300,placement:"surface",Header:Br}],settings:[{id:"ragents.orchestration.runPanel",category:"appearance",label:"Run-Panel",Settings:fs}],surface:{Center:Nr,RunPanel:us},cardSections:[{id:"ragents.orchestration.documents",order:300,Section:ns}],SessionProvider:fd,workspaceTabs:[{id:Cs,readRight:"runs.inspect",label:"Executions",order:110,Icon:ws,Panel:Ss,keepMounted:!0,available:e=>J(e.runView)!==void 0}]};export{Gt as ORCHESTRATION_PLUGIN_ID,Ih as webPlugin};
10
10
  /*! Bundled license information:
11
11
 
12
12
  lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs: