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