@astralbeam/sdk 0.23.7 → 0.25.0
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/README.md +7 -5
- package/dist/{api-SpkUzEv3.js → api-CzXKVU8Z.js} +33 -4
- package/dist/api.d.ts +2 -2
- package/dist/api.js +1 -1
- package/dist/{badge-CN5Cq8Xf.js → badge-Do9jhFNO.js} +1 -1
- package/dist/client.d.ts +6418 -46
- package/dist/client.js +51 -1
- package/dist/combobox-B6w-LeTo.js +42 -0
- package/dist/{core-Bn3w2Q44.js → core-zgz5sorX.js} +347 -194
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/{index-D8X2hDGe.d.ts → index-CI5Jut1h.d.ts} +32 -8
- package/dist/{index-DGfDkU_f.d.ts → index-Cg2qqahU.d.ts} +38 -22
- package/dist/{item-Dl9F5Xpc.js → item-U0ZPJBqA.js} +1 -1
- package/dist/listings-BMUU5Ssj.js +1 -0
- package/dist/{mcp-servers-BIGSawh_.js → mcp-servers-B4IbhRo_.js} +1 -1
- package/dist/react.d.ts +4 -27
- package/dist/react.js +13 -42
- package/dist/{styles.generated-CW6iaZWa.js → styles.generated-BBScqnSk.js} +11 -11
- package/dist/widget-DxIW_E_U.js +27 -0
- package/package.json +5 -6
- package/dist/listings-UNePN1vA.js +0 -1
- package/dist/threads-CZIvwSRC.js +0 -42
- package/dist/widget-D_AwRq1A.js +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Er as e,Gn as t,Or as n,Tr as r,jr as i,n as a,nt as o,qn as s,r as c,t as l}from"./styles.generated-CW6iaZWa.js";import{a as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T}from"./item-Dl9F5Xpc.js";import{n as E,t as D}from"./badge-CN5Cq8Xf.js";var O=/* @__PURE__ */ i(n(),1);const k=/* @__PURE__ */ new Map([[`bold`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z`}))],[`duotone`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),/* @__PURE__ */ O.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`fill`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z`}))],[`regular`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`thin`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z`}))]]),A=O.forwardRef((e,t)=>/* @__PURE__ */ O.createElement(r,{ref:t,...e,weights:k}));A.displayName=`PlusIcon`;var j=e(),M=s();function N(e,t){let n=(0,j.createRoot)(e),r=e=>n.render(/* @__PURE__ */ (0,M.jsxs)(M.Fragment,{children:[/* @__PURE__ */ (0,M.jsx)(`style`,{children:l}),/* @__PURE__ */ (0,M.jsx)(c,{delay:400,children:/* @__PURE__ */ (0,M.jsx)(P,{...e})})]}));return r(t),{update:r,unmount:()=>n.unmount()}}function P(e){let[n,r]=(0,O.useState)(!1),[i,o]=(0,O.useState)(null),[s,c]=(0,O.useState)(!1),[l,d]=(0,O.useState)(``),f=async t=>{c(!0),d(``);try{await e.onRemoveServer?.(t),o(null)}catch(e){d(e instanceof Error?e.message:`Could not remove the server`)}finally{c(!1)}};return/* @__PURE__ */ (0,M.jsxs)(`section`,{className:`grid grid-cols-1 gap-2 bg-background text-foreground`,"data-slot":`mcp-servers`,children:[/* @__PURE__ */ (0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[/* @__PURE__ */ (0,M.jsx)(`h2`,{className:`font-heading text-sm font-medium`,children:`Configured MCP servers`}),e.onCreateServer&&!n&&/* @__PURE__ */ (0,M.jsxs)(t,{size:`sm`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,onClick:()=>r(!0),children:[/* @__PURE__ */ (0,M.jsx)(A,{}),` Add MCP server`]})]}),n&&e.onCreateServer&&/* @__PURE__ */ (0,M.jsx)(F,{oauthRedirectUri:e.oauthRedirectUri,save:e.onCreateServer,close:()=>r(!1)}),l&&/* @__PURE__ */ (0,M.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:l}),e.servers.length===0&&/* @__PURE__ */ (0,M.jsx)(`p`,{className:`rounded-lg border border-dashed px-3 py-2.5 text-sm text-muted-foreground`,children:`No MCP servers are available.`}),/* @__PURE__ */ (0,M.jsx)(`div`,{className:`divide-y rounded-lg border bg-card text-card-foreground empty:hidden`,children:e.servers.map(n=>/* @__PURE__ */ (0,M.jsxs)(w,{render:/* @__PURE__ */ (0,M.jsx)(`article`,{}),size:`xs`,className:`rounded-none border-0 py-1.5`,children:[/* @__PURE__ */ (0,M.jsx)(u,{variant:`icon`,className:`text-muted-foreground`,children:/* @__PURE__ */ (0,M.jsx)(m,{"aria-hidden":!0})}),/* @__PURE__ */ (0,M.jsxs)(S,{className:`min-w-0`,children:[/* @__PURE__ */ (0,M.jsx)(`h3`,{className:`truncate text-sm font-medium`,children:new URL(n.endpointUrl).hostname}),/* @__PURE__ */ (0,M.jsx)(g,{className:`line-clamp-none truncate`,title:n.endpointUrl,children:n.endpointUrl})]}),/* @__PURE__ */ (0,M.jsxs)(y,{children:[/* @__PURE__ */ (0,M.jsx)(D,{variant:`secondary`,children:n.authKind?{none:`Public`,oauth:`OAuth`,static_headers:`API key`}[n.authKind]:`Unavailable`}),e.onRemoveServer&&/* @__PURE__ */ (0,M.jsx)(a,{variant:`ghost`,size:`icon-sm`,disabled:s,"aria-label":`Remove server: ${new URL(n.endpointUrl).hostname}`,tooltip:`Remove server`,onClick:()=>{d(``),o(n.id)},children:/* @__PURE__ */ (0,M.jsx)(h,{})})]}),i===n.id&&e.onRemoveServer&&/* @__PURE__ */ (0,M.jsxs)(`div`,{className:`grid basis-full gap-2 text-sm`,role:`group`,"aria-label":`Remove server?`,children:[/* @__PURE__ */ (0,M.jsx)(`p`,{children:`Remove this server and its connections? People will need to connect again if it is added later.`}),/* @__PURE__ */ (0,M.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[/* @__PURE__ */ (0,M.jsx)(t,{size:`xs`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,variant:`outline`,disabled:s,onClick:()=>o(null),children:`Cancel`}),/* @__PURE__ */ (0,M.jsx)(t,{size:`xs`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,variant:`destructive`,disabled:s,onClick:()=>void f(n.id),children:`Remove server`})]})]})]},n.id))})]})}function F({oauthRedirectUri:e,save:n,close:r}){let i=(0,O.useId)(),[a,s]=(0,O.useState)(`none`),[c,l]=(0,O.useState)(`automatic`),[u,m]=(0,O.useState)([]),[h,g]=(0,O.useState)(``),[y,S]=(0,O.useState)(!1),w=(e,t,{description:n,...r}={})=>{let a=u.filter(t=>t.field===e);return/* @__PURE__ */ (0,M.jsxs)(b,{className:`gap-1`,"data-invalid":a.length>0,children:[/* @__PURE__ */ (0,M.jsx)(_,{htmlFor:`${i}-${e}`,className:`text-xs`,children:t}),/* @__PURE__ */ (0,M.jsx)(o,{id:`${i}-${e}`,name:e,"aria-invalid":a.length>0,"aria-describedby":[n&&`${i}-${e}-help`,a.length>0&&`${i}-${e}-error`].filter(Boolean).join(` `)||void 0,...r}),n&&/* @__PURE__ */ (0,M.jsx)(C,{id:`${i}-${e}-help`,className:`text-xs nth-last-2:mt-0`,children:n}),a.length>0&&/* @__PURE__ */ (0,M.jsx)(d,{id:`${i}-${e}-error`,className:`text-xs`,children:a.map(e=>e.message).join(`. `)})]})},D=async e=>{e.preventDefault();let t=new FormData(e.currentTarget),i=e=>(t.get(e)??``).trim(),o=a===`none`?{kind:`none`}:a===`static_headers`?{kind:`static_headers`,headerNames:i(`headerNames`).split(`,`).map(e=>e.trim()).filter(Boolean)}:{kind:`oauth`,profile:`standard`,requestedScopes:i(`requestedScopes`).split(/\s+/).filter(Boolean),...i(`applicationOrigin`)?{applicationOrigin:i(`applicationOrigin`)}:{},...c===`automatic`?{}:{client:{issuer:i(`issuer`),clientId:i(`clientId`),...t.get(`clientSecret`)?{clientSecret:t.get(`clientSecret`)}:{}}}};S(!0),g(``),m([]);try{let e=await n({endpointUrl:i(`endpointUrl`),authConfig:o});e?.errors.length?m(e.errors):r()}catch(e){g(e instanceof Error?e.message:`Could not add the server`)}finally{S(!1)}};return/* @__PURE__ */ (0,M.jsx)(`form`,{"aria-label":`Add MCP server`,onSubmit:e=>void D(e),onChange:()=>{m([]),g(``)},children:/* @__PURE__ */ (0,M.jsx)(`fieldset`,{className:`min-w-0`,disabled:y,children:/* @__PURE__ */ (0,M.jsxs)(T,{size:`sm`,className:`gap-2.5 text-xs`,children:[/* @__PURE__ */ (0,M.jsx)(x,{children:/* @__PURE__ */ (0,M.jsx)(v,{className:`text-sm`,children:`Add MCP server`})}),/* @__PURE__ */ (0,M.jsxs)(f,{className:`grid grid-cols-1 gap-2.5 [&_[data-slot=input]]:text-xs [&_[data-slot=native-select]]:text-xs any-pointer-coarse:[&_input]:min-h-11 any-pointer-coarse:[&_[data-slot=input]]:text-base any-pointer-coarse:[&_[data-slot=native-select]]:text-base any-pointer-coarse:[&_select]:min-h-11`,children:[w(`endpointUrl`,`Server URL`,{type:`url`,autoFocus:!0,required:!0,maxLength:2048,placeholder:`https://mcp.example.com/mcp`,description:`Public HTTPS endpoint using Streamable HTTP.`}),/* @__PURE__ */ (0,M.jsxs)(b,{className:`gap-1`,children:[/* @__PURE__ */ (0,M.jsx)(_,{className:`text-xs`,htmlFor:`${i}-authentication`,children:`Authentication`}),/* @__PURE__ */ (0,M.jsxs)(E,{id:`${i}-authentication`,value:a,onChange:e=>s(e.currentTarget.value),children:[/* @__PURE__ */ (0,M.jsx)(`option`,{value:`none`,children:`No authentication`}),/* @__PURE__ */ (0,M.jsx)(`option`,{value:`static_headers`,children:`API key / headers`}),/* @__PURE__ */ (0,M.jsx)(`option`,{value:`oauth`,children:`OAuth`})]})]}),a===`static_headers`&&w(`headerNames`,`Header names, comma separated`,{required:!0,placeholder:`Authorization, X-Api-Key`,description:`Values are entered when creating a connection.`}),a===`oauth`&&/* @__PURE__ */ (0,M.jsxs)(M.Fragment,{children:[/* @__PURE__ */ (0,M.jsxs)(b,{className:`gap-1`,children:[/* @__PURE__ */ (0,M.jsx)(_,{className:`text-xs`,htmlFor:`${i}-oauth-setup`,children:`OAuth setup`}),/* @__PURE__ */ (0,M.jsxs)(E,{id:`${i}-oauth-setup`,value:c,onChange:e=>l(e.currentTarget.value),children:[/* @__PURE__ */ (0,M.jsx)(`option`,{value:`automatic`,children:`Automatic discovery`}),/* @__PURE__ */ (0,M.jsx)(`option`,{value:`manual`,children:`Pre-registered application`})]})]}),w(`applicationOrigin`,`Application origin, optional`,{type:`url`,maxLength:2048,placeholder:`https://app.example.com`,description:`Allow OAuth from this embedded application's origin. The dashboard origin is always allowed.`}),w(`requestedScopes`,`Requested scopes, optional`),c!==`automatic`&&/* @__PURE__ */ (0,M.jsxs)(M.Fragment,{children:[w(`redirectUri`,`Redirect URI`,{value:e??`Configure the application URL first`,readOnly:!0,onFocus:e=>e.currentTarget.select()}),w(`issuer`,`Authorization server issuer`,{type:`url`,required:!0,maxLength:2048,placeholder:`https://auth.example.com`,description:`Use the trusted issuer from your application's OAuth provider.`}),w(`clientId`,`Client ID`,{required:!0,maxLength:2048}),w(`clientSecret`,`Client secret`,{type:`password`,autoComplete:`off`,maxLength:8192})]})]}),/* @__PURE__ */ (0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`To change the endpoint or authentication later, remove and add the server again.`}),h&&/* @__PURE__ */ (0,M.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:h})]}),/* @__PURE__ */ (0,M.jsxs)(p,{className:`justify-end gap-2 bg-card py-2`,children:[/* @__PURE__ */ (0,M.jsx)(t,{type:`button`,size:`sm`,variant:`outline`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,onClick:r,children:`Cancel`}),/* @__PURE__ */ (0,M.jsx)(t,{type:`submit`,size:`sm`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,children:y?`Saving…`:`Add MCP server`})]})]})})})}export{N as renderMcpServers};
|
|
1
|
+
import{Er as e,Gn as t,Or as n,Tr as r,jr as i,n as a,nt as o,qn as s,r as c,t as l}from"./styles.generated-BBScqnSk.js";import{a as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T}from"./item-U0ZPJBqA.js";import{n as E,t as D}from"./badge-Do9jhFNO.js";var O=/* @__PURE__ */ i(n(),1);const k=/* @__PURE__ */ new Map([[`bold`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z`}))],[`duotone`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),/* @__PURE__ */ O.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`fill`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z`}))],[`regular`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`thin`,/* @__PURE__ */ O.createElement(O.Fragment,null,/* @__PURE__ */ O.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z`}))]]),A=O.forwardRef((e,t)=>/* @__PURE__ */ O.createElement(r,{ref:t,...e,weights:k}));A.displayName=`PlusIcon`;var j=e(),M=s();function N(e,t){let n=(0,j.createRoot)(e),r=e=>n.render(/* @__PURE__ */ (0,M.jsxs)(M.Fragment,{children:[/* @__PURE__ */ (0,M.jsx)(`style`,{children:l}),/* @__PURE__ */ (0,M.jsx)(c,{delay:400,children:/* @__PURE__ */ (0,M.jsx)(P,{...e})})]}));return r(t),{update:r,unmount:()=>n.unmount()}}function P(e){let[n,r]=(0,O.useState)(!1),[i,o]=(0,O.useState)(null),[s,c]=(0,O.useState)(!1),[l,d]=(0,O.useState)(``),f=async t=>{c(!0),d(``);try{await e.onRemoveServer?.(t),o(null)}catch(e){d(e instanceof Error?e.message:`Could not remove the server`)}finally{c(!1)}};return/* @__PURE__ */ (0,M.jsxs)(`section`,{className:`grid grid-cols-1 gap-2 bg-background text-foreground`,"data-slot":`mcp-servers`,children:[/* @__PURE__ */ (0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[/* @__PURE__ */ (0,M.jsx)(`h2`,{className:`font-heading text-sm font-medium`,children:`Configured MCP servers`}),e.onCreateServer&&!n&&/* @__PURE__ */ (0,M.jsxs)(t,{size:`sm`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,onClick:()=>r(!0),children:[/* @__PURE__ */ (0,M.jsx)(A,{}),` Add MCP server`]})]}),n&&e.onCreateServer&&/* @__PURE__ */ (0,M.jsx)(F,{oauthRedirectUri:e.oauthRedirectUri,save:e.onCreateServer,close:()=>r(!1)}),l&&/* @__PURE__ */ (0,M.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:l}),e.servers.length===0&&/* @__PURE__ */ (0,M.jsx)(`p`,{className:`rounded-lg border border-dashed px-3 py-2.5 text-sm text-muted-foreground`,children:`No MCP servers are available.`}),/* @__PURE__ */ (0,M.jsx)(`div`,{className:`divide-y rounded-lg border bg-card text-card-foreground empty:hidden`,children:e.servers.map(n=>/* @__PURE__ */ (0,M.jsxs)(w,{render:/* @__PURE__ */ (0,M.jsx)(`article`,{}),size:`xs`,className:`rounded-none border-0 py-1.5`,children:[/* @__PURE__ */ (0,M.jsx)(u,{variant:`icon`,className:`text-muted-foreground`,children:/* @__PURE__ */ (0,M.jsx)(m,{"aria-hidden":!0})}),/* @__PURE__ */ (0,M.jsxs)(S,{className:`min-w-0`,children:[/* @__PURE__ */ (0,M.jsx)(`h3`,{className:`truncate text-sm font-medium`,children:new URL(n.endpointUrl).hostname}),/* @__PURE__ */ (0,M.jsx)(g,{className:`line-clamp-none truncate`,title:n.endpointUrl,children:n.endpointUrl})]}),/* @__PURE__ */ (0,M.jsxs)(y,{children:[/* @__PURE__ */ (0,M.jsx)(D,{variant:`secondary`,children:n.authKind?{none:`Public`,oauth:`OAuth`,static_headers:`API key`}[n.authKind]:`Unavailable`}),e.onRemoveServer&&/* @__PURE__ */ (0,M.jsx)(a,{variant:`ghost`,size:`icon-sm`,disabled:s,"aria-label":`Remove server: ${new URL(n.endpointUrl).hostname}`,tooltip:`Remove server`,onClick:()=>{d(``),o(n.id)},children:/* @__PURE__ */ (0,M.jsx)(h,{})})]}),i===n.id&&e.onRemoveServer&&/* @__PURE__ */ (0,M.jsxs)(`div`,{className:`grid basis-full gap-2 text-sm`,role:`group`,"aria-label":`Remove server?`,children:[/* @__PURE__ */ (0,M.jsx)(`p`,{children:`Remove this server and its connections? People will need to connect again if it is added later.`}),/* @__PURE__ */ (0,M.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[/* @__PURE__ */ (0,M.jsx)(t,{size:`xs`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,variant:`outline`,disabled:s,onClick:()=>o(null),children:`Cancel`}),/* @__PURE__ */ (0,M.jsx)(t,{size:`xs`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,variant:`destructive`,disabled:s,onClick:()=>void f(n.id),children:`Remove server`})]})]})]},n.id))})]})}function F({oauthRedirectUri:e,save:n,close:r}){let i=(0,O.useId)(),[a,s]=(0,O.useState)(`none`),[c,l]=(0,O.useState)(`automatic`),[u,m]=(0,O.useState)([]),[h,g]=(0,O.useState)(``),[y,S]=(0,O.useState)(!1),w=(e,t,{description:n,...r}={})=>{let a=u.filter(t=>t.field===e);return/* @__PURE__ */ (0,M.jsxs)(b,{className:`gap-1`,"data-invalid":a.length>0,children:[/* @__PURE__ */ (0,M.jsx)(_,{htmlFor:`${i}-${e}`,className:`text-xs`,children:t}),/* @__PURE__ */ (0,M.jsx)(o,{id:`${i}-${e}`,name:e,"aria-invalid":a.length>0,"aria-describedby":[n&&`${i}-${e}-help`,a.length>0&&`${i}-${e}-error`].filter(Boolean).join(` `)||void 0,...r}),n&&/* @__PURE__ */ (0,M.jsx)(C,{id:`${i}-${e}-help`,className:`text-xs nth-last-2:mt-0`,children:n}),a.length>0&&/* @__PURE__ */ (0,M.jsx)(d,{id:`${i}-${e}-error`,className:`text-xs`,children:a.map(e=>e.message).join(`. `)})]})},D=async e=>{e.preventDefault();let t=new FormData(e.currentTarget),i=e=>(t.get(e)??``).trim(),o=a===`none`?{kind:`none`}:a===`static_headers`?{kind:`static_headers`,headerNames:i(`headerNames`).split(`,`).map(e=>e.trim()).filter(Boolean)}:{kind:`oauth`,profile:`standard`,requestedScopes:i(`requestedScopes`).split(/\s+/).filter(Boolean),...i(`applicationOrigin`)?{applicationOrigin:i(`applicationOrigin`)}:{},...c===`automatic`?{}:{client:{issuer:i(`issuer`),clientId:i(`clientId`),...t.get(`clientSecret`)?{clientSecret:t.get(`clientSecret`)}:{}}}};S(!0),g(``),m([]);try{let e=await n({endpointUrl:i(`endpointUrl`),authConfig:o});e?.errors.length?m(e.errors):r()}catch(e){g(e instanceof Error?e.message:`Could not add the server`)}finally{S(!1)}};return/* @__PURE__ */ (0,M.jsx)(`form`,{"aria-label":`Add MCP server`,onSubmit:e=>void D(e),onChange:()=>{m([]),g(``)},children:/* @__PURE__ */ (0,M.jsx)(`fieldset`,{className:`min-w-0`,disabled:y,children:/* @__PURE__ */ (0,M.jsxs)(T,{size:`sm`,className:`gap-2.5 text-xs`,children:[/* @__PURE__ */ (0,M.jsx)(x,{children:/* @__PURE__ */ (0,M.jsx)(v,{className:`text-sm`,children:`Add MCP server`})}),/* @__PURE__ */ (0,M.jsxs)(f,{className:`grid grid-cols-1 gap-2.5 [&_[data-slot=input]]:text-xs [&_[data-slot=native-select]]:text-xs any-pointer-coarse:[&_input]:min-h-11 any-pointer-coarse:[&_[data-slot=input]]:text-base any-pointer-coarse:[&_[data-slot=native-select]]:text-base any-pointer-coarse:[&_select]:min-h-11`,children:[w(`endpointUrl`,`Server URL`,{type:`url`,autoFocus:!0,required:!0,maxLength:2048,placeholder:`https://mcp.example.com/mcp`,description:`Public HTTPS endpoint using Streamable HTTP.`}),/* @__PURE__ */ (0,M.jsxs)(b,{className:`gap-1`,children:[/* @__PURE__ */ (0,M.jsx)(_,{className:`text-xs`,htmlFor:`${i}-authentication`,children:`Authentication`}),/* @__PURE__ */ (0,M.jsxs)(E,{id:`${i}-authentication`,value:a,onChange:e=>s(e.currentTarget.value),children:[/* @__PURE__ */ (0,M.jsx)(`option`,{value:`none`,children:`No authentication`}),/* @__PURE__ */ (0,M.jsx)(`option`,{value:`static_headers`,children:`API key / headers`}),/* @__PURE__ */ (0,M.jsx)(`option`,{value:`oauth`,children:`OAuth`})]})]}),a===`static_headers`&&w(`headerNames`,`Header names, comma separated`,{required:!0,placeholder:`Authorization, X-Api-Key`,description:`Values are entered when creating a connection.`}),a===`oauth`&&/* @__PURE__ */ (0,M.jsxs)(M.Fragment,{children:[/* @__PURE__ */ (0,M.jsxs)(b,{className:`gap-1`,children:[/* @__PURE__ */ (0,M.jsx)(_,{className:`text-xs`,htmlFor:`${i}-oauth-setup`,children:`OAuth setup`}),/* @__PURE__ */ (0,M.jsxs)(E,{id:`${i}-oauth-setup`,value:c,onChange:e=>l(e.currentTarget.value),children:[/* @__PURE__ */ (0,M.jsx)(`option`,{value:`automatic`,children:`Automatic discovery`}),/* @__PURE__ */ (0,M.jsx)(`option`,{value:`manual`,children:`Pre-registered application`})]})]}),w(`applicationOrigin`,`Application origin, optional`,{type:`url`,maxLength:2048,placeholder:`https://app.example.com`,description:`Allow OAuth from this embedded application's origin. The dashboard origin is always allowed.`}),w(`requestedScopes`,`Requested scopes, optional`),c!==`automatic`&&/* @__PURE__ */ (0,M.jsxs)(M.Fragment,{children:[w(`redirectUri`,`Redirect URI`,{value:e??`Configure the application URL first`,readOnly:!0,onFocus:e=>e.currentTarget.select()}),w(`issuer`,`Authorization server issuer`,{type:`url`,required:!0,maxLength:2048,placeholder:`https://auth.example.com`,description:`Use the trusted issuer from your application's OAuth provider.`}),w(`clientId`,`Client ID`,{required:!0,maxLength:2048}),w(`clientSecret`,`Client secret`,{type:`password`,autoComplete:`off`,maxLength:8192})]})]}),/* @__PURE__ */ (0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`To change the endpoint or authentication later, remove and add the server again.`}),h&&/* @__PURE__ */ (0,M.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:h})]}),/* @__PURE__ */ (0,M.jsxs)(p,{className:`justify-end gap-2 bg-card py-2`,children:[/* @__PURE__ */ (0,M.jsx)(t,{type:`button`,size:`sm`,variant:`outline`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,onClick:r,children:`Cancel`}),/* @__PURE__ */ (0,M.jsx)(t,{type:`submit`,size:`sm`,className:`any-pointer-coarse:min-h-11 any-pointer-coarse:min-w-11`,children:y?`Saving…`:`Add MCP server`})]})]})})})}export{N as renderMcpServers};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as AstralBeamChatState, E as AstralBeamChatCoreOptions, T as AstralBeamChatCore } from "./index-
|
|
1
|
+
import { D as AstralBeamChatState, E as AstralBeamChatCoreOptions, T as AstralBeamChatCore } from "./index-Cg2qqahU.js";
|
|
2
2
|
import { CSSProperties, ReactNode } from "react";
|
|
3
3
|
import { AstralBeamChatAttachmentOptions, AstralBeamChatColorScheme, AstralBeamChatTheme, AstralBeamListingHandle, AstralBeamTokenRequest, AstralBeamTokenSource, InferParameters, JsonSchemaObject, MountAstralBeamChatOptions, MountAstralBeamMcpServersOptions, MountAstralBeamTenantListOptions, MountAstralBeamTenantUserListOptions, MountAstralBeamThreadListOptions, ParametersSchema, ToolDefinition, WidgetDefinition as WidgetDefinition$1, defineTool } from "@astralbeam/sdk/client";
|
|
4
4
|
//#region src/react/listings.d.ts
|
|
@@ -38,31 +38,8 @@ export interface TypedReactWidgetDefinition<S extends ParametersSchema = JsonSch
|
|
|
38
38
|
}
|
|
39
39
|
/** Declares a host widget; a Standard Schema `parameters` types (and validates) `render`'s props. */
|
|
40
40
|
export declare function defineWidget<const S extends ParametersSchema = JsonSchemaObject>(widget: TypedReactWidgetDefinition<S>): WidgetDefinition;
|
|
41
|
-
/**
|
|
42
|
-
export
|
|
43
|
-
sendMessage: AstralBeamChatCore["sendMessage"];
|
|
44
|
-
retry: AstralBeamChatCore["retry"];
|
|
45
|
-
addToolResult: AstralBeamChatCore["addToolResult"];
|
|
46
|
-
stop: () => void;
|
|
47
|
-
reload: () => Promise<void>;
|
|
48
|
-
reset: () => void;
|
|
49
|
-
/** Conversation management and the full headless session. */
|
|
50
|
-
core: AstralBeamChatCore;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The headless chat session as a React hook: authentication, transport, tools, and transcript
|
|
54
|
-
* state with no markup, for hosts that own their whole chat UI. Every option follows the props it
|
|
55
|
-
* is given, keeping the transcript and the chat session, so ordinary closures over props and
|
|
56
|
-
* state stay live and nothing needs a remount.
|
|
57
|
-
*/
|
|
58
|
-
export declare function useAstralBeamChat(options: AstralBeamChatCoreOptions): UseAstralBeamChatResult;
|
|
59
|
-
/** Imperative surface of a mounted `<AstralBeamChat>`, for hosts that draw their own controls. */
|
|
60
|
-
export interface AstralBeamChatRef {
|
|
61
|
-
/** Starts a fresh conversation and clears its draft, preserving saved conversations and their drafts. */
|
|
62
|
-
reset: () => void;
|
|
63
|
-
/** Stops the in-flight generation, if any; the transcript keeps what already streamed. */
|
|
64
|
-
stop: () => void;
|
|
65
|
-
}
|
|
41
|
+
/** Owns one stable session and subscribes React to its state. Options follow props in place. */
|
|
42
|
+
export declare function useAstralBeamChat(options: AstralBeamChatCoreOptions): AstralBeamChatCore;
|
|
66
43
|
/**
|
|
67
44
|
* Every mount option as a prop, with the DOM-rendering fields replaced by React ones: a widget
|
|
68
45
|
* renders JSX, and the chrome slots take nodes instead of renderers. The shared options are
|
|
@@ -82,6 +59,6 @@ export interface AstralBeamChatProps extends Omit<MountAstralBeamChatOptions, "w
|
|
|
82
59
|
/** Extra host controls at the end of the composer's button row, next to send. */
|
|
83
60
|
composerActions?: ReactNode;
|
|
84
61
|
}
|
|
85
|
-
export declare
|
|
62
|
+
export declare function AstralBeamChat({ chat, id, agentId, threadId, placementKey, title, showHeader, resizable, defaultWidth, resizeContainer, onClose, showConversationTitle, header, headerActions, empty, composerActions, emptyHeadline, emptyDescription, apiUrl, fetchAstralBeamToken, tools, widgets, colorScheme, theme, customCss, attachments, sandboxPanel, debug }: AstralBeamChatProps): import("react").JSX.Element;
|
|
86
63
|
//#endregion
|
|
87
64
|
export { type AstralBeamChatAttachmentOptions, type AstralBeamChatColorScheme, type AstralBeamChatCore, type AstralBeamChatCoreOptions, type AstralBeamChatState, type AstralBeamChatTheme, type AstralBeamMcpServersProps, type AstralBeamTenantListProps, type AstralBeamTenantListRef, type AstralBeamTenantUserListProps, type AstralBeamTenantUserListRef, type AstralBeamThreadListProps, type AstralBeamThreadListRef, type AstralBeamTokenRequest, type AstralBeamTokenSource, type InferParameters, type ParametersSchema, type ToolDefinition, defineTool };
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as CORE_OPTION_KEYS, r as createAstralBeamChat } from "./core-
|
|
2
|
-
import {
|
|
1
|
+
import { n as CORE_OPTION_KEYS, r as createAstralBeamChat } from "./core-zgz5sorX.js";
|
|
2
|
+
import { Kt as DEFAULT_COLOR_SCHEME } from "./api-CzXKVU8Z.js";
|
|
3
3
|
import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { defineTool, mountAstralBeamChat, mountAstralBeamMcpServers, mountAstralBeamTenantList, mountAstralBeamTenantUserList, mountAstralBeamThreadList } from "@astralbeam/sdk/client";
|
|
@@ -131,12 +131,7 @@ function AstralBeamMcpServers({ className, style, servers, oauthRedirectUri, onC
|
|
|
131
131
|
function defineWidget(widget) {
|
|
132
132
|
return widget;
|
|
133
133
|
}
|
|
134
|
-
/**
|
|
135
|
-
* The headless chat session as a React hook: authentication, transport, tools, and transcript
|
|
136
|
-
* state with no markup, for hosts that own their whole chat UI. Every option follows the props it
|
|
137
|
-
* is given, keeping the transcript and the chat session, so ordinary closures over props and
|
|
138
|
-
* state stay live and nothing needs a remount.
|
|
139
|
-
*/
|
|
134
|
+
/** Owns one stable session and subscribes React to its state. Options follow props in place. */
|
|
140
135
|
function useAstralBeamChat(options) {
|
|
141
136
|
const [core] = useState(() => createAstralBeamChat(options, true));
|
|
142
137
|
const watched = CORE_OPTION_KEYS.map((key) => options[key]);
|
|
@@ -151,42 +146,14 @@ function useAstralBeamChat(options) {
|
|
|
151
146
|
core.start();
|
|
152
147
|
return () => core.dispose();
|
|
153
148
|
}, [core]);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
sendMessage: core.sendMessage,
|
|
157
|
-
retry: core.retry,
|
|
158
|
-
addToolResult: core.addToolResult,
|
|
159
|
-
stop: core.stop,
|
|
160
|
-
reload: core.reload,
|
|
161
|
-
reset: core.reset,
|
|
162
|
-
core
|
|
163
|
-
};
|
|
149
|
+
useSyncExternalStore(core.subscribe, core.getState, core.getState);
|
|
150
|
+
return core;
|
|
164
151
|
}
|
|
165
|
-
|
|
152
|
+
function AstralBeamChat({ chat, id, agentId, threadId, placementKey, title, showHeader, resizable, defaultWidth, resizeContainer, onClose, showConversationTitle, header, headerActions, empty, composerActions, emptyHeadline, emptyDescription, apiUrl, fetchAstralBeamToken, tools, widgets = {}, colorScheme = DEFAULT_COLOR_SCHEME, theme, customCss, attachments, sandboxPanel, debug }) {
|
|
166
153
|
const targetRef = useRef(null);
|
|
167
154
|
const handleRef = useRef(null);
|
|
168
155
|
const [activeRenders, setActiveRenders] = useState(/* @__PURE__ */ new Map());
|
|
169
|
-
useImperativeHandle(ref, () => ({
|
|
170
|
-
reset: () => handleRef.current?.reset(),
|
|
171
|
-
stop: () => handleRef.current?.stop()
|
|
172
|
-
}), []);
|
|
173
|
-
const toolsRef = useRef(tools);
|
|
174
|
-
useEffect(() => {
|
|
175
|
-
toolsRef.current = tools;
|
|
176
|
-
});
|
|
177
156
|
const nextRenderKey = useRef(0);
|
|
178
|
-
const hostTools = useMemo(() => {
|
|
179
|
-
const adapted = {};
|
|
180
|
-
for (const [name, definition] of Object.entries(tools ?? {})) adapted[name] = {
|
|
181
|
-
...definition,
|
|
182
|
-
execute: (input) => {
|
|
183
|
-
const current = toolsRef.current?.[name];
|
|
184
|
-
if (!current) throw new Error(`Tool "${name}" is no longer registered`);
|
|
185
|
-
return current.execute(input);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
return adapted;
|
|
189
|
-
}, [tools]);
|
|
190
157
|
const hostWidgets = useMemo(() => Object.fromEntries(Object.entries(widgets).map(([name, definition]) => [name, {
|
|
191
158
|
...definition,
|
|
192
159
|
render: (props, container) => {
|
|
@@ -234,8 +201,10 @@ const AstralBeamChat = forwardRef(function AstralBeamChat({ id, agentId, threadI
|
|
|
234
201
|
hasComposerActions
|
|
235
202
|
]);
|
|
236
203
|
const live = useMemo(() => ({
|
|
204
|
+
chat,
|
|
237
205
|
agentId,
|
|
238
206
|
threadId,
|
|
207
|
+
placementKey,
|
|
239
208
|
apiUrl,
|
|
240
209
|
fetchAstralBeamToken,
|
|
241
210
|
title,
|
|
@@ -253,12 +222,14 @@ const AstralBeamChat = forwardRef(function AstralBeamChat({ id, agentId, threadI
|
|
|
253
222
|
attachments,
|
|
254
223
|
sandboxPanel,
|
|
255
224
|
debug,
|
|
256
|
-
tools
|
|
225
|
+
tools,
|
|
257
226
|
widgets: hostWidgets,
|
|
258
227
|
slots: chromeSlots
|
|
259
228
|
}), [
|
|
229
|
+
chat,
|
|
260
230
|
agentId,
|
|
261
231
|
threadId,
|
|
232
|
+
placementKey,
|
|
262
233
|
apiUrl,
|
|
263
234
|
fetchAstralBeamToken,
|
|
264
235
|
title,
|
|
@@ -276,7 +247,7 @@ const AstralBeamChat = forwardRef(function AstralBeamChat({ id, agentId, threadI
|
|
|
276
247
|
attachments,
|
|
277
248
|
sandboxPanel,
|
|
278
249
|
debug,
|
|
279
|
-
|
|
250
|
+
tools,
|
|
280
251
|
hostWidgets,
|
|
281
252
|
chromeSlots
|
|
282
253
|
]);
|
|
@@ -311,6 +282,6 @@ const AstralBeamChat = forwardRef(function AstralBeamChat({ id, agentId, threadI
|
|
|
311
282
|
return definition ? createPortal(definition.render(props), container, key) : null;
|
|
312
283
|
}), [...chromeContainers].map(([name, container]) => createPortal(chromeContent[name], container, `astralbeam-chrome-${name}`))]
|
|
313
284
|
});
|
|
314
|
-
}
|
|
285
|
+
}
|
|
315
286
|
//#endregion
|
|
316
287
|
export { AstralBeamChat, AstralBeamMcpServers, AstralBeamTenantList, AstralBeamTenantUserList, AstralBeamThreadList, defineTool, defineWidget, useAstralBeamChat };
|