@datalayer/agent-runtimes 1.5.16 → 1.5.18

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 (53) hide show
  1. package/dist-embed/chunks/ChatView-Bz0eyWo6.js +32 -0
  2. package/dist-embed/datalayer-app-main.js +102 -102
  3. package/lib/apps/apps/appspec.d.ts +36 -4
  4. package/lib/apps/apps/appspec.js +104 -11
  5. package/lib/apps/apps/threads.d.ts +20 -0
  6. package/lib/apps/apps/threads.js +31 -0
  7. package/lib/apps/plugins/canvas-blocks/index.d.ts +7 -9
  8. package/lib/apps/plugins/canvas-blocks/index.js +8 -10
  9. package/lib/apps/plugins/canvas-parts/index.d.ts +4 -1
  10. package/lib/apps/plugins/canvas-parts/index.js +7 -3
  11. package/lib/apps/plugins/chat/ChatView.js +32 -7
  12. package/lib/chat/ChatFloating.js +12 -4
  13. package/lib/chat/base/ChatBase.js +31 -5
  14. package/lib/chat/messages/ChatMessageList.js +1 -1
  15. package/lib/config/AgentConfiguration.d.ts +5 -1
  16. package/lib/examples/AgentA2ATeamExample.js +6 -5
  17. package/lib/examples/ChatExample.js +2 -2
  18. package/lib/examples/VoiceChatExample.js +9 -3
  19. package/lib/hooks/useBrowserAgent.d.ts +1 -1
  20. package/lib/hooks/useBrowserAgent.js +1 -1
  21. package/lib/protocols/AGUIAdapter.d.ts +11 -0
  22. package/lib/protocols/AGUIAdapter.js +27 -2
  23. package/lib/specs/agents/agents.js +169 -169
  24. package/lib/specs/apps.d.ts +32 -32
  25. package/lib/specs/apps.js +624 -143
  26. package/lib/specs/appspecSchema.js +30 -2
  27. package/lib/specs/cogs.js +3 -3
  28. package/lib/specs/index.d.ts +1 -0
  29. package/lib/specs/index.js +1 -0
  30. package/lib/specs/protocols.js +2 -2
  31. package/lib/specs/sceneSchema.js +2 -0
  32. package/lib/specs/scenes.js +7 -7
  33. package/lib/specs/teams/teams.js +11 -11
  34. package/lib/specs/ui.d.ts +32 -6
  35. package/lib/specs/ui.js +760 -26
  36. package/lib/specs/uiRenderers.d.ts +17 -0
  37. package/lib/specs/uiRenderers.js +40 -0
  38. package/lib/specs/voices.d.ts +2 -0
  39. package/lib/specs/voices.js +5 -0
  40. package/lib/types/agentspecs.d.ts +63 -12
  41. package/lib/types/chat.d.ts +6 -0
  42. package/lib/types/protocol.d.ts +17 -0
  43. package/lib/utils/utils.js +8 -1
  44. package/lib/voice/ReadAloud.d.ts +35 -0
  45. package/lib/voice/ReadAloud.js +29 -0
  46. package/lib/voice/index.d.ts +7 -2
  47. package/lib/voice/index.js +1 -0
  48. package/package.json +2 -2
  49. package/scripts/codegen/generate_agents.py +60 -11
  50. package/scripts/codegen/generate_ui.py +68 -22
  51. package/scripts/codegen/generate_ui_renderers.py +176 -0
  52. package/scripts/codegen/generate_voices.py +5 -1
  53. package/dist-embed/chunks/ChatView-nnI1-MOR.js +0 -32
@@ -0,0 +1,32 @@
1
+ import{E as N,eN as fo,r as o,j as t,eO as po,eP as mo,b_ as Cn,B as f,H as dt,T as H,c as G,cu as Ot,eu as Nt,eQ as ae,co as ut,e as go,eR as ho,eS as bo,e3 as xo,eT as So,aH as vo,dX as Un,dV as yo,dY as Bt,eU as wo,eV as Co,eW as jo,eX as ko,eY as jn,eZ as Eo,e_ as Io,e$ as To,d3 as Ro,a_ as Ao,f0 as Po,f1 as Mo,f2 as $o,f3 as Oo,f4 as Uo,f5 as Fo,x as Ut,f6 as Lo,f7 as _o,f8 as zo,f9 as No,fa as Bo,fb as Vo,fc as Ho,fd as Wo,fe as Do,ff as Go,fg as Ko,fh as Yo,fi as qo,fj as Jo,fk as Qo,fl as Xo,fm as Zo,fn as es,fo as ts,fp as ns,fq as Ge,fr as os,fs as ss,ft as as,fu as is,fv as kn,fw as rs,fx as Pe,fy as ls,fz as cs,a$ as ft,fA as ds,fB as us,fC as En,fD as fs,fE as ps,eC as ms,fF as Ft,fG as ve,fH as gs,fI as hs,fJ as In,fK as bs,fL as xs,fM as Ss,fN as vs,fO as ys,fP as ws,fQ as Cs,fR as js,fS as ks,fT as pt,fU as Es,fV as Is,I as Ts,fW as Rs,fX as As,fY as Tn,fZ as Ps,f_ as Ms,f$ as $s,g0 as Vt,g1 as Os,g2 as Us,ek as Lt,g3 as Fs,g4 as Ls}from"../datalayer-app-main.js";import{S as _s,E as zs,a as Ns}from"./SignInIcon-4HkE48mS.js";import{F as Bs,a as Vs,b as Hs}from"./LinkedInGreyIcon-BoWXE-HS.js";function Fn(){const n=N(fo);return o.useMemo(()=>n.map(s=>s.value),[n])}const _t={github:{name:"github",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/github/callback"},google:{name:"google",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/google/callback"},linkedin:{name:"linkedin",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/linkedin/callback"}},Rn=()=>{if(typeof document>"u")return"";const n=document.getElementById("datalayer-config-data");if(!n?.textContent)return"";try{const s=JSON.parse(n.textContent);return String(s?.iamUrl||"").replace(/\/$/,"")}catch{return""}},Ws=(n,s="Unable to start social sign-in.")=>{if(n instanceof Error&&n.message)return n.message;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"&&"message"in n){const c=n.message;if(typeof c=="string"&&c.trim())return c}return s},Ds=So`
2
+ .signin-input-theme-scope input:-webkit-autofill,
3
+ .signin-input-theme-scope input:-webkit-autofill:hover,
4
+ .signin-input-theme-scope input:-webkit-autofill:focus,
5
+ .signin-input-theme-scope input:-webkit-autofill:active,
6
+ .signin-input-theme-scope input:-webkit-autofill:disabled,
7
+ .signin-input-theme-scope textarea:-webkit-autofill,
8
+ .signin-input-theme-scope textarea:-webkit-autofill:hover,
9
+ .signin-input-theme-scope textarea:-webkit-autofill:focus,
10
+ .signin-input-theme-scope textarea:-webkit-autofill:active,
11
+ .signin-input-theme-scope textarea:-webkit-autofill:disabled {
12
+ -webkit-text-fill-color: var(--fgColor-default) !important;
13
+ caret-color: var(--fgColor-default) !important;
14
+ -webkit-box-shadow: 0 0 0 1000px var(--bgColor-default) inset !important;
15
+ box-shadow: 0 0 0 1000px var(--bgColor-default) inset !important;
16
+ background-color: var(--bgColor-default) !important;
17
+ transition: background-color 9999s ease-in-out 0s !important;
18
+ }
19
+
20
+ .signin-input-theme-scope input:disabled,
21
+ .signin-input-theme-scope textarea:disabled {
22
+ -webkit-text-fill-color: var(--fgColor-muted) !important;
23
+ -webkit-box-shadow: 0 0 0 1000px var(--bgColor-default) inset !important;
24
+ box-shadow: 0 0 0 1000px var(--bgColor-default) inset !important;
25
+ background-color: var(--bgColor-default) !important;
26
+ opacity: 1 !important;
27
+ }
28
+ `,Gs=({onSignIn:n,onApiKeySignIn:s,loginUrl:c,name:a,title:d="Datalayer OTEL",description:b="Sign in to access the observability dashboard.",icon:S,leadingIcon:w=t.jsx(xo,{size:24}),github:p=!1,google:K=!1,linkedin:B=!1,apiKey:Ke=!1,signUp:F=!0,socialSignInNavigationTarget:Z,asDoc:v=!1,fillHeight:I=!0,hideHero:ee=!1,calloutTitle:Me,calloutDescription:Ye,passwordToggleLabel:ie="Sign in with a password",signUpTitle:Ht="Don't have an account?",signUpDescription:Y="Create a free Datalayer account with your email address.",signUpLabel:mt="Sign up with email",signUpHref:$e="https://datalayer.ai/signup",onSignUp:V,forgotPasswordHref:q="/password",forgotPasswordLabel:Oe="Forgot password?",showForgotPassword:gt=!0,socialButtonMarginTop:x=3,actionButtonMaxWidth:J=320})=>{const te=v&&!ee,qe=a??(v&&d==="Datalayer OTEL"?"Datalayer Sign In":d),ht=S??(v?t.jsx(_s,{size:24}):w),L=o.useMemo(()=>{if(c)return c;const i=Rn();return i?`${i}/api/iam/v1/login`:"/api/iam/v1/login"},[c]),[W,ye]=o.useState(""),[re,bt]=o.useState(""),[Je,le]=o.useState(!1),[ce,Qe]=o.useState(!1),[j,we]=o.useState(!1),[de,Ce]=o.useState(!1),[Ue,Xe]=o.useState(null),[_,je]=o.useState(null),[ne,Ze]=o.useState(""),[ue,et]=o.useState(null),[Fe,M]=o.useState(null),{enqueueToast:fe}=po(),[pe,E]=o.useState(!1),[Q,oe]=o.useState(""),D=o.useRef(null),Le=o.useCallback(i=>mo()?Cn.URLExt.join(Cn.PageConfig.getBaseUrl(),i.oauth2CallbackServerRoute):`${window.location.protocol}//${window.location.hostname}${window.location.port?`:${window.location.port}`:""}${i.oauth2CallbackUIRoute}`,[]),me=o.useMemo(()=>{if(typeof window>"u")return"/";const i=`${window.location.pathname}${window.location.search}${window.location.hash}`;return i.startsWith("/")?i:"/"},[]),ke=o.useCallback(async i=>{if(!de){M(null),Xe(i.name),Ce(!0);try{const g=Rn(),m=new URLSearchParams({provider:i.name,callback_uri:Le(i)}),R=Z===void 0?void 0:String(Z||"").trim(),y=R===void 0?me&&me!=="/"?me:void 0:R&&R.startsWith("/")&&!R.startsWith("//")?R:void 0;y&&m.set("post_auth_redirect",y);const ze=`${g||""}/api/iam/v1/oauth2/authz/url?${m.toString()}`,k=await fetch(ze),se=await k.json(),Ne=se?.autorization_url;if(!k.ok||!Ne)throw new Error(se?.message||"Unable to start social sign-in.");window.location.assign(Ne)}catch(g){const m=Ws(g);M(m),fe(m,{variant:"error"}),Xe(null),Ce(!1)}}},[Le,me,fe,de,Z]);o.useEffect(()=>{pe&&D.current?.focus()},[pe]);const $=o.useCallback(()=>{E(!1),oe("")},[]),xt=o.useCallback(()=>{!Q.trim()||!s||(s(Q.trim()),$())},[Q,s,$]),St=o.useCallback(()=>{if(V){V();return}window.location.assign($e)},[V,$e]),vt=o.useCallback(()=>{if(q){if(q.startsWith("http://")||q.startsWith("https://")){window.open(q,"_blank","noopener,noreferrer");return}window.location.assign(q)}},[q]),_e=o.useCallback(async()=>{if(!(v||!W||!re||j)){we(!0),M(null);try{const i=await fetch(L,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handle:W,password:re})});if(!i.ok)throw new Error(`HTTP ${i.status}`);const g=await i.json();if(g.success&&g.token){const m=String(g?.user?.id||g?.user?.uid||"").trim();if(!!g?.user?.mfaUrl&&m){je(m),et(g.token),M(null);return}n&&n(g.token,W)}else M(g.message||"Invalid username or password.")}catch(i){M(i instanceof Error?i.message:String(i))}finally{we(!1)}}},[v,W,re,j,L,n]),ge=o.useCallback(async()=>{if(!(v||j||!_||!ne.trim()||!ue)){we(!0),M(null);try{const i=new URL(L,window.location.origin),g=i.pathname.endsWith("/api/iam/v1/login")?i.href.replace(/\/api\/iam\/v1\/login$/,""):`${i.origin}`,m=await fetch(`${g}/api/iam/v1/users/${_}/mfa/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userUid:_,code:ne.trim()})}),R=await m.json();if(!m.ok||!R?.success)throw new Error(R?.message||"Failed to validate your MFA code.");n&&n(ue,W)}catch(i){const g=i instanceof Error?i.message:String(i);M(g),fe(g,{variant:"error"})}finally{we(!1)}}},[v,fe,W,j,L,ne,ue,_,n]),Ee=o.useCallback(i=>{i.key==="Enter"&&(_?ge():_e())},[_,_e,ge]),he=de||j||v;return t.jsxs(f,{className:"signin-input-theme-scope",display:"flex",alignItems:ee||te||!I?"flex-start":"center",justifyContent:"center",minHeight:ee||te||!I?"auto":"100vh",bg:ee?"transparent":"canvas.default",color:"fg.default",py:ee?0:te?2:4,children:[t.jsx(Ds,{}),t.jsxs(f,{width:"100%",maxWidth:440,p:0,children:[!ee&&t.jsxs(t.Fragment,{children:[t.jsxs(f,{display:"flex",alignItems:"center",gap:2,mb:te?2:3,justifyContent:"center",children:[ht,t.jsx(dt,{sx:{fontSize:3},children:qe})]}),t.jsx(H,{as:"p",sx:{fontSize:1,color:"fg.muted",mb:te?2:3,textAlign:"center"},children:b})]}),(Me||Ye)&&t.jsxs(f,{mb:3,textAlign:"center",children:[Me&&t.jsx(dt,{as:"h3",sx:{fontSize:2,mb:1},children:Me}),Ye&&t.jsx(H,{sx:{color:"fg.muted",fontSize:1},children:Ye})]}),!_&&(p||K||B)&&t.jsxs(t.Fragment,{children:[p&&t.jsx(G,{block:!0,size:"large",leadingVisual:Ue==="github"?()=>t.jsx(Ot,{size:"small"}):Bs,disabled:he,onClick:()=>ke(_t.github),sx:{mt:x,maxWidth:J,mx:"auto"},children:"Sign in with GitHub"}),K&&t.jsx(G,{block:!0,size:"large",leadingVisual:Ue==="google"?()=>t.jsx(Ot,{size:"small"}):Vs,disabled:he,onClick:()=>ke(_t.google),sx:{mt:x,maxWidth:J,mx:"auto"},children:"Sign in with Google"}),B&&t.jsx(G,{block:!0,size:"large",leadingVisual:Ue==="linkedin"?()=>t.jsx(Ot,{size:"small"}):Hs,disabled:he,onClick:()=>ke(_t.linkedin),sx:{mt:x,maxWidth:J,mx:"auto"},children:"Sign in with LinkedIn"})]}),!_&&!Je&&t.jsx(f,{mt:3,display:"flex",justifyContent:"center",children:t.jsx(G,{leadingVisual:Nt,size:"large",block:!0,disabled:v||j||de,onClick:()=>le(!0),sx:{maxWidth:J,mx:"auto"},children:ie})}),!_&&Je&&t.jsxs(f,{mt:4,children:[t.jsxs(ae,{required:!0,sx:{mb:3},children:[t.jsx(ae.Label,{children:"Username"}),t.jsx(ut,{autoFocus:!0,block:!0,placeholder:"Your username",value:W,disabled:j||v,onChange:i=>ye(i.target.value),onKeyDown:Ee})]}),t.jsxs(ae,{required:!0,sx:{mb:3},children:[t.jsx(ae.Label,{children:"Password"}),t.jsx(ut,{block:!0,placeholder:"Your password",type:ce?"text":"password",value:re,disabled:j||v,onChange:i=>bt(i.target.value),onKeyDown:Ee,trailingAction:t.jsx(ut.Action,{onClick:()=>Qe(!ce),disabled:j||v,icon:ce?zs:Ns,"aria-label":ce?"Hide password":"Show password",sx:{color:"var(--fgColor-muted)"}})})]}),t.jsxs(f,{display:"flex",alignItems:"center",justifyContent:"space-between",mt:3,children:[t.jsx(G,{variant:"primary",disabled:j||v||!W||!re,onClick:_e,children:j?"Signing in…":"Sign In"}),gt&&t.jsx(go,{as:"button",sx:{fontSize:1,cursor:v?"not-allowed":"pointer",background:"none",border:"none",opacity:v?.6:1},onClick:()=>{v||j||vt()},children:Oe})]})]}),_&&t.jsxs(t.Fragment,{children:[t.jsxs(ae,{required:!0,sx:{mb:3,mt:2},children:[t.jsx(ae.Label,{children:"MFA Code"}),t.jsx(ut,{autoFocus:!0,block:!0,placeholder:"Your MFA code",value:ne,disabled:j||v,onChange:i=>Ze(i.target.value),onKeyDown:Ee})]}),t.jsx(G,{variant:"primary",block:!0,disabled:j||v||!ne.trim(),onClick:ge,sx:{maxWidth:J,mx:"auto"},children:j?"Validating…":"Validate MFA Code"})]}),Fe&&t.jsx(H,{sx:{color:"danger.fg",fontSize:1,mt:3,display:"block"},children:Fe}),F&&t.jsxs(f,{mt:4,pt:4,textAlign:"center",borderTop:"1px solid",borderColor:"border.muted",children:[t.jsx(dt,{as:"h3",sx:{fontSize:2,mb:2},children:Ht}),t.jsx(H,{as:"p",sx:{color:"fg.muted",fontSize:1,mb:3},children:Y}),t.jsx(f,{display:"flex",justifyContent:"center",children:t.jsx(G,{variant:"primary",size:"large",leadingVisual:ho,disabled:v||j,onClick:St,children:mt})})]}),Ke&&s&&t.jsxs(t.Fragment,{children:[t.jsxs(f,{display:"flex",alignItems:"center",gap:2,my:3,children:[t.jsx(f,{flex:1,height:"1px",bg:"border.default"}),t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"or"}),t.jsx(f,{flex:1,height:"1px",bg:"border.default"})]}),t.jsx(G,{block:!0,leadingVisual:Nt,disabled:v||j||de,onClick:()=>E(!0),sx:{maxWidth:J,mx:"auto"},children:"Sign in with an API Key"}),pe&&t.jsx(f,{role:"dialog","aria-modal":"true","aria-labelledby":"signin-api-key-title",onKeyDown:i=>{i.key==="Escape"&&$()},onClick:$,position:"fixed",inset:0,zIndex:200,p:3,bg:"canvas.backdrop",display:"flex",alignItems:"center",justifyContent:"center",children:t.jsxs(f,{as:"form",onClick:i=>i.stopPropagation(),onSubmit:i=>{i.preventDefault(),xt()},width:"min(560px, 100%)",p:3,borderRadius:2,border:"1px solid",borderColor:"border.default",bg:"canvas.overlay",color:"fg.default",boxShadow:"shadow.large",children:[t.jsx(dt,{id:"signin-api-key-title",sx:{fontSize:2,mb:2},children:"Enter your API Key"}),t.jsxs(ae,{required:!0,children:[t.jsx(ae.Label,{children:"API Key"}),t.jsx(bo,{block:!0,required:!0,autoFocus:!0,placeholder:"Paste your API key here",value:Q,onInput:i=>oe(i.currentTarget.value),ref:D})]}),t.jsxs(f,{mt:3,display:"flex",justifyContent:"flex-end",gap:2,children:[t.jsx(G,{type:"button",onClick:$,children:"Cancel"}),t.jsx(G,{type:"submit",variant:"primary",disabled:!Q.trim(),children:"Authenticate"})]})]})})]})]})]})};function Ks(n){const{agentId:s,instructions:c,model:a,frontendTools:d,inference:b,subagents:S,sharing:w,onSubagentEvent:p,modeEffect:K}=n;return{type:"browser-vercel-ai",endpoint:"",agentId:s,enableConfigQuery:!1,options:{instructions:c,model:a,frontendTools:d,inference:b,subagents:S,sharing:w,onSubagentEvent:p,modeEffect:K}}}const An=vo((n,s)=>({pending:void 0,suggest:(c,a)=>{const d=c.trim();d&&n({pending:{text:d,submit:a?.submit??!1,nonce:(s().pending?.nonce??0)+1}})},consume:()=>n({pending:void 0})}));function Ys({agentName:n,sandboxStillRuns:s=!1,temporary:c=!0,onSignedIn:a,onSignUp:d}){const{configuration:b}=Un(),S=o.useCallback(w=>{yo.getState().checkIAMToken(w),a?.()},[a]);return t.jsx(f,{height:"100%",minHeight:0,overflowY:"auto",bg:"canvas.default",px:4,py:4,children:t.jsxs(f,{maxWidth:440,mx:"auto",children:[t.jsxs(f,{display:"flex",alignItems:"center",justifyContent:"center",gap:2,color:"attention.fg",mb:2,children:[t.jsx(Nt,{size:20}),t.jsx(H,{sx:{fontSize:2,fontWeight:"semibold",color:"fg.default"},children:c?"This demo runs on a shared key":"Your key has expired"})]}),t.jsxs(H,{as:"p",sx:{fontSize:1,color:"fg.muted",textAlign:"center",mb:3},children:[c?`${n??"The agent"} has used the time this key allows. Sign in to point your own agent at it, use your own data, and drop the time limit.`:`${n??"The agent"} stopped because your session ran out.`,s?" Your notebook is still running in this page.":""]}),t.jsx(Gs,{hideHero:!0,fillHeight:!1,calloutTitle:"Sign in to keep going",github:!0,google:!0,linkedin:!0,socialSignInNavigationTarget:typeof window>"u"?void 0:`${window.location.pathname}${window.location.search}`,loginUrl:b?.iamUrl?`${b.iamUrl}/api/iam/v1/login`:void 0,onSignIn:S,onSignUp:d})]})})}const qs="https://r1.datalayer.run";function Js(n=!0){const{configuration:s}=Un(),c=Bt(w=>w.token),a=s?.aiInferenceUrl||qs,d=wo(a,n&&!c),b=c||d.token,S=o.useMemo(()=>({inferenceUrl:a,token:b||void 0}),[a,b]);return{inference:S,needsSignIn:Co(S),anonymous:d,inferenceUrl:a}}const Qs={name:"general-purpose",description:"A capable generalist for a task none of the specialists covers: research, reasoning, drafting, checking.",instructions:"You are a capable general-purpose assistant. Carry out the task you are given completely and report the result plainly, saying what you could not do."};function Pn(n){const s=n?.subagents;if(!s)return[];const c=(s.subagents??[]).map(a=>{const d=a.ref?jo(a.ref):void 0;return{name:a.name,description:a.description||d?.description||a.name,instructions:a.instructions??d?.systemPrompt,model:a.model??d?.model??s.defaultModel,icon:d?.icon}});return s.includeGeneralPurpose?[...c,Qs]:c}function Xs(n){return n.replace(/^datalayer_/,"").replace(/_lexical$/,"")}function Zs(n){const s=Xs(n);return/^executeCodeIn(Notebook|Document)$/.test(s)||/^(read|list)[A-Z]/.test(s)}function ea(n,s){return n.filter(c=>s?.has(c.name)||Zs(c.name))}function ta(n,s){const c=a=>s&&a.value.id===`${s}-tools`?0:a.value.id==="notebook-tools"?1:2;return n.map((a,d)=>({entry:a,index:d,rank:c(a)})).sort((a,d)=>a.rank-d.rank||a.index-d.index).map(a=>a.entry)}function na(n,s,c){if(!c||!n.endsWith("-tools"))return!1;const a=n.slice(0,-6);return s.has(a)&&a!==c}const oa={type:"object",properties:{}};function sa(n,s){const c=new Set(n.toolset);return n.commands.filter(a=>c.has(a.name)).map(a=>({name:a.name,description:a.description,parameters:a.parameters??oa,location:"frontend",handler:async d=>{if(!s)throw new Error(`${a.name}: the ${n.plugin??n.id} plugin is not mounted on this page.`);const b=Object.keys(d??{}).length>0?d:void 0,S=await s.executeCommand(a.command,b);return S===void 0?{ok:!0,command:a.command,argument:b}:S}}))}function Ln(n,s){return n.flatMap(c=>sa(c,s))}function aa(){const n=ko(),s=Fn();return o.useMemo(()=>Ln(s,n),[s,n])}const Mn={opening:"Opening your conversation…",notOpened:n=>`Your conversation could not be opened, so this is a new one: ${n}`};function ia(n){const s=n?.app_instance;if(!s||typeof s!="object")return"";const c=s.deployment_uid;return typeof c=="string"?c.trim():""}function ra(n,s,c){return n||!s?n:{id:c,messages:[]}}function la(n){let s;for(const c of n.split(/\r?\n\r?\n/)){const a=c.split(/\r?\n/).filter(d=>d.startsWith("data:")).map(d=>d.slice(5).trim()).join("");if(a)try{const d=JSON.parse(a);d.type==="MESSAGES_SNAPSHOT"&&Array.isArray(d.messages)&&(s=d.messages)}catch{}}return s}async function $n(n){try{const s=await n.json();if(typeof s.detail=="string"&&s.detail)return s.detail}catch{}return`${n.status}`}async function ca({agentBaseUrl:n,agentId:s,uid:c,token:a,fetcher:d=fetch}){const b=`${n.replace(/\/+$/,"")}/api/v1/apps/sessions/${encodeURIComponent(c)}`,S=a?{Authorization:`Bearer ${a}`}:{},w=await d(`${b}/messages`,{headers:S});if(w.ok){const B=await w.json();return jn(B.messages)}if(w.status!==404)throw new Error(await $n(w));const p=await d(`${b}/resume`,{method:"POST",headers:{"Content-Type":"application/json",...S},body:JSON.stringify({agent:s})});if(!p.ok)throw new Error(await $n(p));const K=la(await p.text());if(!K)throw new Error(`The runtime said nothing of session ${c}.`);return jn(K)}const da="var(--theme-accent)";function _n({face:n,size:s}){return typeof n=="string"?t.jsx(Eo,{emoji:n,size:s,label:""}):t.jsx(t.Fragment,{children:n})}function ua({face:n,size:s,state:c}){const a=c==="thinking"||c==="working",d=c==="paused";return t.jsxs(f,{as:"span","aria-hidden":!0,"data-presence":c,position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:s+8,height:s+8,flexShrink:0,fontSize:s,lineHeight:1,children:[t.jsx(f,{as:"span",position:"absolute",inset:0,borderRadius:"50%",boxShadow:d?"none":`0 0 0 2px ${da}`,border:d?"2px dashed":"none",borderColor:"border.default",opacity:a||c==="waiting"||d?.9:0,transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",animation:a?"loopPresenceBreath 1.8s ease-in-out infinite":"none",reducedMotion:{animation:"none"},sx:{"@keyframes loopPresenceBreath":{"0%, 100%":{transform:"scale(0.92)",opacity:.35},"50%":{transform:"scale(1.06)",opacity:.9}}}}),t.jsx(f,{as:"span",display:"inline-flex",opacity:d?.55:1,filter:d?"grayscale(0.6)":"none",transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",children:t.jsx(_n,{face:n,size:s})})]})}function fa({state:n}){return t.jsx(H,{role:"status","aria-live":"polite","data-presence-line":n,sx:{fontSize:0,color:n==="waiting"?"fg.default":"fg.muted",fontWeight:n==="waiting"?"semibold":"normal",whiteSpace:"nowrap",flexShrink:0},children:Io[n]})}const pa=Vt(void 0),ma=Vt(""),ga=Vt({}),X="",ha=1400,On=parseInt(Fs["--loop-face-large"],10);function ya({workspace:n}){const s=To(),c=Ro(),a=o.useRef(null),{setViewControls:d}=n,[b,S]=o.useState(null),w=Ao(),p=w.getConfig(Po),K=p?.placeholder||s.placeholder,B=p?.defaultSurface??"notebook",Ke=w.getConfig(Mo),[F,Z]=o.useState(X),v=o.useRef(!1),I=N($o),ee=N(Oo),Me=N(Uo),ie=N(Fo)[0]?.value,Y=Ut(ie?.promptStance??pa)??ie?.prompt,mt=N(Lo),$e=_o(mt[0]?.value),V=o.useRef($e);V.current=$e;const q=o.useRef(""),Oe=N(zo),gt=o.useMemo(()=>No(()=>Oe.reduce((e,r)=>({...e,...r.value.extras.value}),{})),[Oe]),x=Ut(Oe.length>0?gt:ga),J=o.useRef(new Set),te=Bo(Os,n),qe=!te.allowed,ht=qe?te.reason??"Chat is unavailable for this sandbox":void 0,[L,W]=o.useState(!1),[ye,re]=o.useState(!1),[bt,Je]=o.useState({open:!1,pendingApproval:!1}),le=Vo(L,bt,p?.presence?.paused===!0),ce=p?.presence?.onPresence;o.useEffect(()=>{ce?.(le),V.current?.setPresence(le)},[ce,le]);const Qe=o.useRef(p?.presence?.onSaying);Qe.current=p?.presence?.onSaying;const j=o.useRef({answering:!1}),we=o.useCallback(e=>{a.current=e,re(!!e)},[]),de=o.useCallback(e=>{const{open:r,pendingApproval:l}=Ho(e);Je(Se=>Se.open===r&&Se.pendingApproval===l?Se:{open:r,pendingApproval:l});const h={saying:Do(e),answering:Wo(e)},u=j.current;(u.saying?.id!==h.saying?.id||u.saying?.text!==h.saying?.text||u.answering!==h.answering)&&(j.current=h,Qe.current?.(h));const U=V.current;if(!U)return;U.items(e);const P=new Set(["complete","completed","done","error","failed","cancelled","canceled","rejected","denied","stopped"]),A={insertcell:"adding a cell",updatecell:"editing a cell",runcell:"running a cell",deletecells:"removing cells",readallcells:"reading the notebook",readcell:"reading a cell",executecode:"running code",insertblock:"adding a block",updateblock:"editing a block",runblock:"running a block",readdocument:"reading the document"};let C;for(let Se=e.length-1;Se>=0;Se-=1){const ct=e[Se];if(typeof ct.toolName=="string"&&ct.toolCallId){P.has(String(ct.status).toLowerCase())||(C=ct);break}}if(!C){U.activity(void 0);return}const $t=C.toolName.toLowerCase().replace(/^datalayer_/,"").replace(/_lexical$/,"").replace(/[^a-z]/g,""),uo=A[$t]??`using ${C.toolName}`;U.activity(`${q.current||"The agent"} is ${uo}…`)},[]),Ce=o.useRef(x);Ce.current=x;const Ue=o.useCallback(e=>{Yn(e),V.current?.usage(e),Ce.current.onUsage?.(e)},[]),Xe=o.useCallback(e=>{W(e),e||V.current?.end("done")},[]),_=o.useCallback(e=>{const r=V.current;if(!r)return;let l=-1;for(let u=e.length-1;u>=0;u-=1)if(e[u].role==="user"){l=u;break}const h=e.slice(l+1).filter(u=>u.role==="assistant").map(Go).filter(u=>u.trim().length>0).join(`
29
+
30
+ `);r.assistant(h)},[]),je=o.useRef([]),ne=o.useRef(!1),Ze=o.useRef(void 0),ue=o.useRef(void 0),et=N(Ko),Fe=o.useRef(et);Fe.current=et;const M=o.useCallback((e,r)=>{if(ue.current)return ue.current;const l=Yo(Fe.current.map(U=>U.value),r),h=l?.loop;if(ne.current&&h?.files&&h.files.length>0){const U=Ze.current;if(!U)return"A file is given to an application running on a runtime: run it on Datalayer or on your machine to give it one.";let P;try{P=h.files.map(A=>({file:Jo(String(A.name??"")),base64:qo(String(A.data_url??""))}))}catch(A){return A instanceof Error?A.message:String(A)}U.execute(Qo(P)).then(A=>{if(!A.success){S(`The files could not be put in the sandbox: ${A.error??"it failed"}.`);return}M(`${e}
31
+
32
+ ${Xo(P.map(C=>C.file))}`,{...l,loop:Object.fromEntries(Object.entries(h).filter(([C])=>C!=="files"))})});return}V.current?.begin(e,a.current?.thread());const u=a.current?.send;if(!u){je.current.push([e,l]);return}u(e,l)},[]);o.useEffect(()=>{d(ye?{busy:L,stop:a.current?.stop,newChat:a.current?.newChat,send:M}:null)},[L,ye,d,M]),o.useEffect(()=>()=>d(null),[d]),o.useEffect(()=>n.prompts.subscribe(M),[n.prompts,M]),o.useEffect(()=>{if(!ye||je.current.length===0)return;const e=je.current.splice(0,je.current.length);for(const[r,l]of e)a.current?.send(r,l)},[ye]);const fe=o.useRef(!1),pe=o.useCallback(async e=>{S(null);const r=await Zo(Ce.current,e);if(r){r.sent?st(""):S(r.refused);return}fe.current||(fe.current=!0,Ke?.firstPromptHook?.());const l=await n.submit(e);if(!l.handled){S(l.reason??null);return}st(""),l.result?.content&&S(l.result.content)},[n,Ke?.firstPromptHook]),E=o.useMemo(()=>I.find(e=>e.value.surfaceId===F)?.value,[I,F]),Q=o.useCallback(e=>{v.current=!0,Z(e)},[]);o.useEffect(()=>es(Q),[Q]),o.useEffect(()=>{ts(I.map(e=>e.value.surfaceId))},[I]),o.useEffect(()=>{ns(F&&F!==X?F:Ls)},[F]);const oe=o.useMemo(()=>B===X||B==="none"?void 0:I.find(e=>e.value.surfaceId===B),[I,B]);o.useEffect(()=>{v.current||!oe||Ge(oe.value,n)&&Z(B)},[oe,n,B]);const[D,Le]=o.useState(null),me=o.useRef(null),ke=p?.fullScreenTopOffset??0,{fullScreen:$,usingApi:xt,toggle:St,topOffsetPx:vt}=os(me,{forceOverlay:!!ke,topOffset:ke}),[_e,ge]=o.useState(!1),Ee=o.useRef(!1);o.useEffect(()=>{!L||Ee.current||$||(Ee.current=!0,ge(!0))},[L,$]),o.useEffect(()=>{$&&ge(!1)},[$]),o.useEffect(()=>{E&&!Ge(E,n)&&(Le(E.surfaceId),Z(X))},[E,n]);const he=o.useMemo(()=>{if(D)return I.find(e=>e.value.surfaceId===D)?.value;if(!v.current&&F===X)return oe?.value},[I,D,F,oe]);o.useEffect(()=>{if(!D||F!==X)return;const e=I.find(r=>r.value.surfaceId===D);e&&Ge(e.value,n)&&(Le(null),Z(D))},[I,F,D,n]);const i=n.agentId?.trim()||"default",g=ss(n.sandbox.target??"local");ne.current=g;const m=as(),R=Ut(m?.selected??ma),y=m?.members.find(e=>e.id===R),yt=N(is)[0]?.value,ze=yt?.specId,k=kn(y?.specId??i)??(ze?kn(ze):void 0),se=y?void 0:yt,Ne=g&&!y?$s(ze,k):void 0;q.current=y?.name??k?.name??i;const Wt=N(rs),Dt=x.hiddenOpeners,Gt=x.hideOpeners,wt=x.openers,Ct=o.useMemo(()=>{if(Gt)return[];const e=new Set(Dt??[]),r=C=>e.size===0?C:C.filter($t=>!e.has($t.text));if(wt)return r(wt);const l=Wt.flatMap(C=>C.value.suggestions);if(l.length>0)return r(l);const h=r(k?.suggestions??[]),u=r(m?.team.suggestions??[]);if(u.length===0)return h;const U=new Set(u.map(C=>C.text)),P=m?.team.name??"Team",A=y?.name??k?.name??i;return[...u.map(C=>({...C,group:P})),...h.filter(C=>!U.has(C.text)).map(C=>({...C,group:A}))]},[Wt,m,k,y,i,Dt,Gt,wt]),tt=o.useMemo(()=>Ct.map(e=>({title:e.summary??e.text,message:e.message??e.text,group:e.group})),[Ct]),jt=Pe(k?.icon),z=p?.presence,zn=Pe(m?.team.icon),Kt=N(ls),nt=o.useMemo(()=>{const e=[],r=new Map,l=new Set,h=new Set(I.map(u=>u.value.surfaceId));for(const u of ta(Kt,E?.surfaceId)){if(na(u.value.id,h,E?.surfaceId))continue;let U;try{U=u.value.tools(n)}catch(P){console.warn(`[loop] frontend tools from '${u.plugin}' failed:`,P);continue}for(const P of U){const A=r.get(P.name);if(A){console.warn(`[loop] frontend tool '${P.name}' from '${u.plugin}' is shadowed by the one from '${A}'.`);continue}r.set(P.name,u.plugin),e.push(P),u.value.chatView&&l.add(P.name)}}for(const u of x.frontendTools??[])r.has(u.name)||(r.set(u.name,"chat-extras"),e.push(u),l.add(u.name));return E?e:ea(e,l)},[Kt,n.surfaceId,n.agentId,x.frontendTools,E?.surfaceId,I]),kt=aa(),Be=o.useMemo(()=>{if(kt.length===0)return nt;const e=new Set(nt.map(r=>r.name));return[...nt,...kt.filter(r=>!e.has(r.name))]},[nt,kt]),Yt=Fn(),Et=x.agentToolBundles,Nn=o.useMemo(()=>{const e=x.frontendTools??[];if(!Et?.length)return x.frontendTools;const r=Ln(Yt.filter(h=>Et.includes(h.id)),w),l=new Set(e.map(h=>h.name));return[...e,...r.filter(h=>!l.has(h.name))]},[x.frontendTools,Et,Yt,w]);Ze.current=g&&Be.some(e=>e.name===cs)?w.getOutput(ft)?.sandbox:void 0;const T=ds(n.sandbox,n.serverUrl),qt=N(us),Bn=o.useMemo(()=>qt.filter(e=>e.value.composer).map(e=>({name:e.value.name,description:e.value.description})),[qt]),Vn=o.useMemo(()=>{if(!m||!y)return Pn(k).map(l=>({name:l.name,description:l.description,icon:Pe(l.icon)}));const e=m.members.map(l=>({name:l.name,description:l.description,emoji:l.emoji,icon:Pe(l.icon),disabled:l.id===y.id,disabledReason:l.id===y.id?`You are already talking to ${l.name}`:void 0})),r=En(m.team,y.id).filter(l=>!m.members.some(h=>h.name===l.name)).map(l=>({name:l.name,description:l.description,icon:Pe(l.icon)}));return[...e,...r]},[m,y,k]),{inference:Jt,anonymous:Hn}=Js(g),Wn=Bt(e=>e.user),It=g&&Hn.status==="expired",Qt=!Wn,Ve=fs();ue.current=Ve.disabled?Ve.disableReason||"This conversation is closed here.":void 0;const Tt=T===void 0?ps(n.sandbox,s):void 0,ot=qe||It||!!Ne||!!Tt||Ve.disabled,Xt=It?Qt?s.demoKeyExpired:s.keyExpired:Ne??Tt??ht??(Ve.disabled?Ve.disableReason:void 0),[Zt,st]=o.useState(""),[Dn,en]=o.useState(),at=Dn??se?.model??k?.model??n.model??"",Ie=ms(),tn=o.useRef(Ie),nn=o.useRef(R),on=o.useRef(Ie);on.current=Ie,o.useEffect(()=>{nn.current!==R&&(nn.current=R,tn.current=on.current,en(void 0))},[R]);const Gn=Ie&&Ie!==tn.current?Ie:null,[Kn,Yn]=o.useState(),qn=Gn??Kn??null,Jn=Ft(ve.inpromptMenu),Qn=Ft(ve.promptAction),sn=Ft(ve.chatHeader),Xn=o.useMemo(()=>m?.members.map(e=>({id:e.id,name:e.name,description:e.description,icon:Pe(e.icon)}))??[],[m]),be=An(e=>e.pending),[an,Zn]=o.useState(0);o.useEffect(()=>gs(()=>Zn(e=>e+1)),[]),o.useEffect(()=>{be&&(st(be.text),An.getState().consume(),be.submit&&pe(be.text))},[be]);const rn=w.getConfig(ft)?.datalayerCreatePayload,xe=!!(se?.createPayload?.app_spec||rn?.app_spec),Rt=ia(rn),eo=Bt(e=>e.token),At=w.getConfig(ft)?.datalayerVisitors,to=hs(At),no=w.getConfig(ft)?.embedToken,He=At?to.token:no||eo,Te=!!(Rt||At);if(Te&&!xe)throw new Error("A deployment’s page runs its application: its host gave no app_spec.");const[ln]=o.useState(In),O=o.useMemo(()=>ra(p?.thread,Rt,ln),[p?.thread,Rt,ln]),[Re,cn]=o.useState(null),oo=!!(O?.fromRuntime&&Re?.given!==O.id);o.useEffect(()=>{if(!O?.fromRuntime||!xe||!T)return;let e=!0;return(async()=>{let r="";for(let l=0;l<4&&e;l+=1)try{const h=await ca({agentBaseUrl:T,agentId:i,uid:O.id,token:He});e&&cn({given:O.id,thread:{...O,fromRuntime:!1,messages:h}});return}catch(h){r=h instanceof Error?h.message:String(h),await new Promise(u=>setTimeout(u,1500))}e&&cn({given:O.id,thread:{id:In(),messages:[],onStarted:O.onStarted},said:Mn.notOpened(r)})})(),()=>{e=!1}},[O?.id,O?.fromRuntime,xe,T,i,He]);const dn=O?.fromRuntime?Re?.given===O.id?Re.thread:void 0:O,Pt=o.useMemo(()=>g?Ks({agentId:y?.specId??i,instructions:bs(k,se?.instructions),model:at||void 0,inference:Jt,frontendTools:Be,subagents:m&&y?En(m.team,y.id):Pn(k),sharing:m?.sharing,onSubagentEvent:e=>Us.getState().appendSubagentEvent(e),modeEffect:se?.modeEffect}):T!==void 0?{type:"ag-ui",endpoint:xe?`${T}/api/v1/apps/agents/${encodeURIComponent(i)}/ag-ui/`:`${T}/api/v1/ag-ui/${i}/`,...xe&&He?{authToken:He}:{},...xe?{uiSocket:`${T.replace(/^http/,"ws")}/api/v1/apps/ui`,uiFiles:`${T}/api/v1/apps/agents/${encodeURIComponent(i)}/files`,appSessions:`${T}/api/v1/apps/sessions`,...Te?{ownRoutesOnly:!0}:{}}:{},agentId:i,configEndpoint:`${T}/api/v1/configure`,enableConfigQuery:!0}:void 0,[i,g,Jt,y,Be,m,k,se,at,T,xe,He,Te]),it=xs(!g,Pt?.type==="ag-ui"?Pt.configEndpoint:void 0,void 0,i),We=Ss(),rt=vs(i),[un,fn]=o.useState(void 0),[so,ao]=o.useState(void 0);o.useEffect(()=>{if(g||T===void 0)return;let e=!1;return fetch(`${T}/api/v1/configure/models?agent_id=${encodeURIComponent(i)}`).then(r=>r.ok?r.json():null).then(r=>{e||(fn(r?ys(r):[]),ao(r?ws(r):void 0))}).catch(()=>{e||fn([])}),()=>{e=!0}},[T,i,g]);const io=o.useMemo(()=>Cs(un,()=>Object.values(js).filter(e=>e.available&&ks(e)).map(e=>({id:e.id,name:e.name,provider:e.provider}))),[un]),pn=o.useMemo(()=>{const e=it.data?.builtinTools??[],r=new Set(e.map(l=>l.name));return{runtime:e,frontend:Be.filter(l=>!r.has(l.name)).map(l=>({id:l.name,name:l.name}))}},[it.data?.builtinTools,Be]),mn=o.useMemo(()=>new Set((We.data?.skills??[]).filter(e=>e.status==="enabled"||e.status==="loaded").map(e=>e.id)),[We.data]),ro=o.useCallback(async e=>{if(Te)throw new Error("A deployment’s chat does not switch its runtime’s model.");en(e),!(g||T===void 0)&&await fetch(`${T}/api/v1/configure/inference/provider`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({model:e})}).catch(()=>{})},[T,g,Te]),gn=p?.promptPlacement==="bottom-chat",lo=p?.promptPlacement==="floating",Ae=p?.promptPlacement==="top",De=p?.hidePrompt===!0||x.hidePrompt===!0,co={onSend:()=>{pe(Zt)},input:Zt,setInput:st,focusTrigger:be||an?(be?.nonce??0)+an:void 0,placement:lo||Y==="floating"||Y==="floating-top"||Y==="floating-bottom"?"floating":"docked",floatingAnchor:Y==="floating-top"?"top":"bottom",isLoading:L,onStop:()=>n.viewControls.stop?.(),placeholder:Xt??x.sendInstead?.says??K,typingSuggestions:Ct.map(e=>e.text),suggestions:tt,disableInputPrompt:ot,connectionConfirmed:!ot,padding:Ae||Y==="floating-top"||Y==="floating-bottom"||Y==="docked-top"?2:3,promptVariant:"lexical",autoFocus:p?.autoFocusPrompt??!0,mentionableAgents:Vn,promptCommands:Bn,headerContent:Jn.length>0?t.jsx(pt,{slot:ve.inpromptMenu,props:{workspace:n}}):void 0,footerExtras:Qn.length>0?t.jsx(pt,{slot:ve.promptAction,props:{workspace:n}}):void 0,showAgentsMenu:!z,showInlineAgentsMenu:!1,agents:Xn,selectedAgentId:R,onSelectAgent:e=>m?.select(e),showTokenUsage:x.showTokenUsage??p?.showTokenUsage??!0,showContextRing:!0,agentUsage:qn??void 0,showModelSelector:!z&&!Te,models:io,decisions:so,selectedModel:at,onModelSelect:e=>{ro(e)},showToolsMenu:!z,availableTools:pn.runtime,availableFrontendTools:pn.frontend,mcpServers:it.data?.mcpServers??[],mcpStatusData:x.mcpStatusData??void 0,showSkillsMenu:!z,skills:We.data?.skills??[],skillsLoading:We.isLoading,enabledSkills:mn,onToggleSkill:e=>mn.has(e)?rt.disableSkill(e):rt.enableSkill(e),onToggleAllSkills:(e,r)=>e.forEach(l=>r?rt.enableSkill(l):rt.disableSkill(l)),codemodeEnabled:x.codemodeEnabled??!1,onToggleCodemode:x.onToggleCodemode,isA2AProtocol:!1,hasConfigData:!!it.data,hasSkillsData:!!We.data},hn=ee[0]?.value.Component,Mt=Me[0]?.value.Component,bn=!p?.hideHeader&&!!Mt,lt=hn?t.jsx(hn,{workspace:n,composer:co}):null,xn=I.length>0&&p?.showSurfaceSelector!==!1?t.jsx(ba,{surfaces:I.map(e=>e.value),active:E?.surfaceId??he?.surfaceId??X,onChange:Q,workspace:n}):null,Sn=t.jsxs(t.Fragment,{children:[I.map(e=>{const r=e.value,l=E?.surfaceId===r.surfaceId;return l||J.current.has(r.surfaceId)||Ge(r,n)?(J.current.add(r.surfaceId),t.jsx(f,{sx:l?{flex:"1 1 0",minWidth:0,minHeight:0}:{position:"absolute",inset:0,visibility:"hidden",pointerEvents:"none",zIndex:-1},children:t.jsx(Es,{load:r.load,props:{surfaceId:r.surfaceId,workspace:n},fallback:t.jsxs(zt,{children:["Loading ",r.title,"…"]}),errorFallback:u=>t.jsxs(zt,{children:[r.title," failed to load: ",u.message]})})},r.surfaceId)):null}),!E&&he?t.jsx(f,{flex:"1 1 0",minWidth:0,minHeight:0,children:t.jsxs(zt,{children:["Starting ",he.title,"…"]})}):null]}),vn=t.jsx(t.Fragment,{children:t.jsxs(f,{flex:Ae&&E?"0 0 34%":"1 1 0",maxWidth:Ae&&E?460:void 0,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",borderLeft:E?"1px solid":void 0,borderColor:"border.default",position:"relative",children:[x.errorBanner?t.jsx(f,{flexShrink:0,px:3,py:2,fontSize:1,borderBottom:"1px solid",bg:x.errorBanner.variant==="warning"?"attention.subtle":"danger.subtle",color:x.errorBanner.variant==="warning"?"attention.fg":"danger.fg",borderColor:x.errorBanner.variant==="warning"?"attention.muted":"danger.muted",children:x.errorBanner.message}):null,Re?.said&&Re.given===O?.id?t.jsx(H,{as:"p",role:"status",sx:{m:0,px:3,py:2,fontSize:1,color:"fg.muted"},children:Re.said}):null,t.jsx(f,{flex:"1 1 auto",minHeight:0,display:"flex",children:oo?t.jsx(H,{as:"p",role:"status",sx:{m:0,p:3,fontSize:1,color:"fg.muted"},children:Mn.opening}):t.jsx(Is,{themeVariant:p?.themeVariant,themeOverrides:p?.themeOverrides,colorMode:p?.colorMode,thread:dn,disabled:ot,disableReason:Xt,protocol:Pt,frontendTools:g?void 0:Nn,initialModel:at||void 0,title:z?.name??y?.name??k?.name??i,description:z?.welcome??k?.description,brandIcon:z?.face?t.jsx(ua,{face:z.face,size:20,state:le}):t.jsx(jt,{size:20}),headerContent:z&&!Tt?t.jsx(fa,{state:le}):void 0,emptyState:{icon:z?.face?t.jsx("span",{"aria-hidden":!0,style:{fontSize:On,lineHeight:1},children:t.jsx(_n,{face:z.face,size:On})}):t.jsx(jt,{size:48}),title:z?.name??y?.name??k?.name??i,...m&&y?{sections:[{group:m.team.name,icon:t.jsx(zn,{size:48}),title:m.team.name,subtitle:m.team.description},{group:y.name,icon:t.jsx(jt,{size:32}),title:y.name,subtitle:k?.description}]}:null},suggestions:Ae||ie||p?.suggestionLabels===!1?[]:tt,showHeader:bn,headerButtons:{showNewChat:p?.headerButtons?.newChat??!1,showClear:p?.headerButtons?.clear??!1},renderHeader:Mt?e=>t.jsx(Mt,{workspace:n,header:n.chatViewModes?{...e,chatViewMode:n.chatViewModes.value,onChatViewModeChange:n.chatViewModes.onChange,offeredViewModes:n.chatViewModes.offered}:e}):void 0,showInformation:!0,headerActions:t.jsxs(f,{display:"inline-flex",alignItems:"center",gap:2,children:[n.chatHeaderActions,sn.length>0?t.jsx(pt,{slot:ve.chatHeader,props:{workspace:n}}):null,t.jsx(Ts,{icon:$?Rs:As,"aria-label":$?"Exit full screen":"Enter full screen",variant:"invisible",size:"small",onClick:()=>{ge(!1),St()},sx:_e?{"@keyframes dla-fullscreen-hint":{"0%, 100%":{opacity:1},"50%":{opacity:.4}},"&&":{bg:`color-mix(in srgb, ${c.primary} 16%, transparent)`,boxShadow:`inset 0 0 0 1.5px ${c.primary}`,animation:`dla-fullscreen-hint ${ha}ms ease-in-out infinite`},"@media (prefers-reduced-motion: reduce)":{"&&":{animation:"none"}}}:void 0})]}),showInput:!1,onSendReady:we,notebookToolSurfacesId:E?void 0:n.surfaceId,showTurnFooter:x.showTokenUsage??p?.showTokenUsage??!0,onContextSnapshot:Ue,onLoadingChange:Xe,onItemsChange:_,onDisplayItemsChange:de,enableStreaming:!0},dn?.id)}),!bn&&sn.length>0?t.jsx(f,{hidden:!0,children:t.jsx(pt,{slot:ve.chatHeader,props:{workspace:n}})}):null,gn&&!De?lt:null]})}),yn=p?.suggestionLabels!==!1&&tt.length>0?t.jsx(f,{"aria-label":s.suggestedPrompts,display:"flex",flexWrap:"wrap",gap:2,px:2,pb:"6px",children:tt.map(e=>t.jsx(f,{as:"button",type:"button",title:e.message,disabled:L||ot,onClick:()=>{pe(e.message)},appearance:"none",font:"inherit",fontSize:0,fontWeight:"semibold",lineHeight:1.25,px:"10px",py:"5px",width:Tn,flex:`0 0 ${Tn}px`,borderRadius:"999px",border:"1px solid",bg:"canvas.subtle",whiteSpace:"nowrap",sx:{borderColor:"border.default",color:"fg.default",cursor:"pointer","&:hover:not(:disabled)":{borderColor:"accent.fg",color:"accent.fg"},"&:disabled":{opacity:.5,cursor:"default"}},children:t.jsx(Ps,{title:e.title,maxWidth:"100%",sx:{minWidth:0},children:e.title})},e.title))}):null,wn=b?t.jsx(f,{flex:"0 0 auto",px:3,py:2,borderTop:"1px solid",borderColor:"border.default",bg:"canvas.subtle",fontSize:1,maxHeight:"40%",overflowY:"auto",children:b}):null;return t.jsxs(f,{ref:me,sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",position:"relative",...$?{bg:"canvas.default"}:null,...$&&!xt.current?{position:"fixed",top:vt,right:0,bottom:0,left:0,height:"auto",zIndex:1e3}:null},children:[ie?t.jsx(ie.Component,{workspace:n,editors:Sn,hasEditor:!!E,transcript:vn,prompt:De?null:lt,chips:De?null:yn,picker:xn,transient:wn}):t.jsxs(t.Fragment,{children:[Ae&&!De?t.jsxs(f,{flex:"0 0 auto",borderBottom:"1px solid",borderColor:"border.default",children:[lt,yn]}):null,xn,t.jsxs(f,{flex:"1 1 auto",minHeight:0,display:"flex",position:"relative",children:[Sn,vn]}),wn,gn||De||Ae?null:lt]}),It?t.jsx(f,{position:"absolute",inset:0,zIndex:5,bg:"canvas.default",display:"flex",flexDirection:"column",minHeight:0,children:t.jsx(Ys,{agentName:y?.name??k?.name,sandboxStillRuns:g,temporary:Qt,onSignedIn:()=>Ms.getState().clear()})}):null]})}function ba({surfaces:n,active:s,onChange:c,workspace:a}){const d=[...n].sort((b,S)=>(b.order??100)-(S.order??100));return t.jsxs(f,{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",children:[t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"Beside the chat"}),t.jsxs(Lt,{"aria-label":"Editor beside the chat",size:"small",children:[t.jsx(Lt.Button,{selected:s===X,onClick:()=>c(X),children:"Chat"}),d.map(b=>{const S=Ge(b,a),w=S?void 0:b.unavailableReason?.(a)??"Not available right now";return t.jsx(Lt.Button,{selected:s===b.surfaceId,"aria-disabled":!S,title:w??b.title,leadingIcon:b.icon,onClick:()=>{S&&c(b.surfaceId)},children:b.title},b.surfaceId)})]})]})}function zt({children:n}){return t.jsx(f,{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"fg.muted",fontSize:1,px:3,textAlign:"center",children:n})}export{ya as default};