@astralbeam/sdk 0.23.6 → 0.24.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-BYkm7p8c.js} +15 -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-Vz6aUEaN.js} +305 -152
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/{index-DGfDkU_f.d.ts → index-CXzO4-3C.d.ts} +20 -4
- package/dist/{index-D8X2hDGe.d.ts → index-DF5gqYlY.d.ts} +7 -2
- 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 +1 -1
- package/dist/listings-UNePN1vA.js +0 -1
- package/dist/threads-CZIvwSRC.js +0 -42
- package/dist/widget-D_AwRq1A.js +0 -27
package/dist/client.js
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
import{s as e}from"./constants-C-Yp0Vhg.js";import{t}from"./debug-DLDY8CZb.js";import{t as n}from"./abort-_ZeHSwUG.js";function r(e,t,n,r){let i=n.colorScheme??`system`,a=i===`dark`||i===`system`&&r;e.classList.toggle(`dark`,a);for(let n of t)e.style.removeProperty(n);t.clear();let o={...n.theme?.light,...a?n.theme?.dark:void 0};for(let[n,r]of Object.entries(o))n.startsWith(`--`)&&(e.style.setProperty(n,r),t.add(n));return{colorScheme:i,dark:a}}function i(e){return e}function a(e){return e}function o(e,t){return l(e,t,`tenants`)}function s(e,t){return l(e,t,`users`)}function c(e,t){return l(e,t,`threads`)}function l(t,n,r){let i=t.shadowRoot??t.attachShadow({mode:`open`}),a=document.createElement(`div`);a.className=`${e} bg-transparent`,a.style.height=`100%`,i.append(a);let o=matchMedia(`(prefers-color-scheme: dark)`),s={options:{...n},kind:r,shadow:i,container:a,media:o,variables:/* @__PURE__ */ new Set,disposed:!1},c=()=>u(s);return c(),o.addEventListener(`change`,c),d(s).catch(()=>{}),{update:e=>m(s,e),refresh:()=>p(s,!1),reset:()=>p(s,!0),unmount:()=>h(s,c)}}function u({options:e,media:t,container:n,variables:i}){r(n,i,e,t.matches)}function d(e){return e.loading??=f(e)}async function f(e){e.retryLoad?.remove();try{if(e.runtime=await import(`./listings-
|
|
1
|
+
import{s as e}from"./constants-C-Yp0Vhg.js";import{t}from"./debug-DLDY8CZb.js";import{t as n}from"./abort-_ZeHSwUG.js";function r(e,t,n,r){let i=n.colorScheme??`system`,a=i===`dark`||i===`system`&&r;e.classList.toggle(`dark`,a);for(let n of t)e.style.removeProperty(n);t.clear();let o={...n.theme?.light,...a?n.theme?.dark:void 0};for(let[n,r]of Object.entries(o))n.startsWith(`--`)&&(e.style.setProperty(n,r),t.add(n));return{colorScheme:i,dark:a}}function i(e){return e}function a(e){return e}function o(e,t){return l(e,t,`tenants`)}function s(e,t){return l(e,t,`users`)}function c(e,t){return l(e,t,`threads`)}function l(t,n,r){let i=t.shadowRoot??t.attachShadow({mode:`open`}),a=document.createElement(`div`);a.className=`${e} bg-transparent`,a.style.height=`100%`,i.append(a);let o=matchMedia(`(prefers-color-scheme: dark)`),s={options:{...n},kind:r,shadow:i,container:a,media:o,variables:/* @__PURE__ */ new Set,disposed:!1},c=()=>u(s);return c(),o.addEventListener(`change`,c),d(s).catch(()=>{}),{update:e=>m(s,e),refresh:()=>p(s,!1),reset:()=>p(s,!0),unmount:()=>h(s,c)}}function u({options:e,media:t,container:n,variables:i}){r(n,i,e,t.matches)}function d(e){return e.loading??=f(e)}async function f(e){e.retryLoad?.remove();try{if(e.runtime=await import(`./listings-BMUU5Ssj.js`),e.disposed)return;e.renderer=e.runtime.renderListing(e.shadow,e.container,e.options,e.kind,()=>p(e,!1))}catch(t){throw e.loading=void 0,e.disposed||(e.retryLoad=document.createElement(`button`),e.retryLoad.textContent=`Could not load directory. Retry`,e.retryLoad.onclick=()=>void d(e).catch(()=>{}),e.container.append(e.retryLoad)),t}}async function p(e,t){if(e.disposed)throw new DOMException(`Directory unmounted`,`AbortError`);e.action?.abort();let r=new AbortController;e.action=r;try{e.renderer||await n(d(e),r.signal),r.signal.throwIfAborted(),await e.runtime.refreshListing(e.renderer,r.signal,t)}finally{e.action===r&&(e.action=void 0)}}function m(e,t){if(e.disposed)return;let n={...e.options,...t};(n.apiUrl!==e.options.apiUrl||n.cacheKey!==e.options.cacheKey||n.scope!==e.options.scope||n.tenantId!==e.options.tenantId||n.tenantExternalId!==e.options.tenantExternalId)&&e.action?.abort(),e.options=n,u(e),e.renderer&&e.runtime.updateListing(e.renderer,e.options)}function h(e,t){e.disposed||(e.disposed=!0,e.action?.abort(),e.media.removeEventListener(`change`,t),e.renderer&&e.runtime.disposeListing(e.renderer),e.container.remove())}function g(t,n){let i=t.shadowRoot??t.attachShadow({mode:`open`}),a=document.createElement(`div`);a.className=e,i.append(a);let o=matchMedia(`(prefers-color-scheme: dark)`),s=/* @__PURE__ */ new Set,c=n,l=!1,u,d=()=>r(a,s,c,o.matches);d(),o.addEventListener(`change`,d);let f=async()=>{a.replaceChildren();try{let{renderMcpServers:e}=await import(`./mcp-servers-B4IbhRo_.js`);l||(u=e(a,c))}catch{if(l)return;let e=document.createElement(`button`);e.textContent=`Could not load MCP servers. Retry`,e.onclick=()=>void f(),a.replaceChildren(e)}};return f(),{update(e){l||(c={...c,...e},d(),u?.update(c))},unmount(){l=!0,o.removeEventListener(`change`,d),u?.unmount(),a.remove()}}}function _(e){if(e.chat){for(let t of[`agentId`,`threadId`,`placementKey`,`apiUrl`,`fetchAstralBeamToken`,`tools`,`debug`])if(e[t]!==void 0)throw Error(`Configure ${t} on the supplied chat session`)}}function v(n,i){_(i);let a={...i},o=t(a.debug);o?.(`mount`,`mounting chat widget`,{agentId:a.agentId??`(organization default)`,title:a.title??`AstralBeam`,showHeader:a.showHeader??!0,emptyHeadline:a.emptyHeadline??`Ask the assistant`,emptyDescription:a.emptyDescription??`Ask a question or describe what you want to do in this app.`,apiUrl:a.apiUrl??`https://astralbeam.ai/api`,authentication:`configured`,colorScheme:a.colorScheme??`system`,theme:a.theme,tools:Object.keys(a.tools??{}),widgets:Object.keys(a.widgets??{}),attachments:a.attachments??!0});let s=n.shadowRoot??n.attachShadow({mode:`open`}),c=document.createElement(`div`);c.className=e,c.style.height=`100%`,s.append(c);let l=document.createElement(`div`);l.dataset.slot=`chat-loading`,l.innerHTML=`
|
|
2
|
+
<style>
|
|
3
|
+
[data-slot="chat-loading"] {
|
|
4
|
+
position: relative; display: flex; flex-direction: column; height: 100%; color-scheme: light;
|
|
5
|
+
background: var(--background, light-dark(#fff, #171717));
|
|
6
|
+
color: var(--foreground, light-dark(#171717, #fafafa));
|
|
7
|
+
font: 14px/1.5 var(--font-sans, system-ui, sans-serif);
|
|
8
|
+
}
|
|
9
|
+
.dark [data-slot="chat-loading"] { color-scheme: dark; }
|
|
10
|
+
[data-slot="chat-loading"] header {
|
|
11
|
+
box-sizing: border-box; height: 56px; flex-shrink: 0; padding-inline: 12px 64px;
|
|
12
|
+
border-bottom: 1px solid var(--border, color-mix(in srgb, currentColor 14%, transparent));
|
|
13
|
+
font: 500 16px/56px var(--font-heading, var(--font-sans, system-ui, sans-serif));
|
|
14
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
15
|
+
}
|
|
16
|
+
[data-slot="chat-loading"] button {
|
|
17
|
+
position: absolute; inset-block-start: 14px; inset-inline-end: 12px;
|
|
18
|
+
width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--radius-sm, 4px);
|
|
19
|
+
background: transparent; color: inherit; cursor: pointer; font: 20px/1 system-ui, sans-serif;
|
|
20
|
+
}
|
|
21
|
+
[data-slot="chat-loading"] button:hover { background: var(--accent, color-mix(in srgb, currentColor 8%, transparent)); }
|
|
22
|
+
[data-slot="chat-loading"] button:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }
|
|
23
|
+
[data-slot="chat-loading"] button::after {
|
|
24
|
+
content: attr(aria-label); display: none; position: absolute;
|
|
25
|
+
inset-block-start: calc(100% + 6px); inset-inline-end: 0; padding: 4px 8px;
|
|
26
|
+
background: var(--foreground, light-dark(#171717, #fafafa));
|
|
27
|
+
color: var(--background, light-dark(#fff, #171717));
|
|
28
|
+
font: 12px/1.5 var(--font-sans, system-ui, sans-serif); white-space: nowrap; pointer-events: none;
|
|
29
|
+
}
|
|
30
|
+
[data-slot="chat-loading"] button:is(:hover, :focus-visible)::after { display: block; }
|
|
31
|
+
[data-slot="chat-loading-status"] {
|
|
32
|
+
display: flex; flex: 1; align-items: center; justify-content: center; gap: 8px; padding: 24px;
|
|
33
|
+
color: var(--muted-foreground, inherit);
|
|
34
|
+
}
|
|
35
|
+
[data-slot="chat-loading-status"][data-loading]::before {
|
|
36
|
+
content: ""; box-sizing: border-box; width: 16px; height: 16px; flex-shrink: 0;
|
|
37
|
+
border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
|
|
38
|
+
animation: astralbeam-loading-spin 0.8s linear infinite;
|
|
39
|
+
}
|
|
40
|
+
@keyframes astralbeam-loading-spin { to { transform: rotate(360deg); } }
|
|
41
|
+
@media (any-pointer: coarse) {
|
|
42
|
+
[data-slot="chat-loading"] button { inset-block-start: 6px; width: 44px; height: 44px; }
|
|
43
|
+
}
|
|
44
|
+
@media (prefers-reduced-motion: reduce) {
|
|
45
|
+
[data-slot="chat-loading-status"][data-loading]::before { animation: none; }
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
|
+
<header><span data-slot="chat-loading-title"></span></header>
|
|
49
|
+
<button type="button" aria-label="Close chat">×</button>
|
|
50
|
+
<div data-slot="chat-loading-status" role="status" data-loading>Loading chat…</div>
|
|
51
|
+
`,c.append(l);let u=l.querySelector(`header`),d=l.querySelector(`[data-slot="chat-loading-title"]`),f=l.querySelector(`button`),p=l.querySelector(`[role="status"]`),m=()=>{d.textContent=a.title??`AstralBeam`,u.hidden=a.showHeader===!1,f.hidden=!a.onClose};m(),f.onclick=e=>{e.detail<2&&a.onClose?.()};let h=matchMedia(`(prefers-color-scheme: dark)`),g=/* @__PURE__ */ new Set,v=()=>{let{colorScheme:e,dark:t}=r(c,g,a,h.matches);o?.(`theme`,`color scheme "${e}" resolved to ${t?`dark`:`light`}`,{themeVariables:[...g]})};v(),h.addEventListener(`change`,v);let y=!1,b;return import(`./widget-DxIW_E_U.js`).then(({renderChat:e})=>{o?.(`mount`,`chat chunk loaded`),y||(b=e(s,c,a))}).catch(()=>{y||(delete p.dataset.loading,p.textContent=`Could not load chat. Reload this page to try again.`)}),{update:e=>{let n={...a,...e};if(_(n),!!n.chat!=!!a.chat)throw Error(`Remount chat to change session ownership`);a=n,o=t(a.debug),o?.(`mount`,`options updated`,{changed:Object.keys(e)}),v(),m(),b?.update(a)},unmount:()=>{o?.(`mount`,`unmounting chat widget`),y=!0,h.removeEventListener(`change`,v),b?.dispose(),b=void 0,c.remove()}}}export{i as defineTool,a as defineWidget,v as mountAstralBeamChat,g as mountAstralBeamMcpServers,o as mountAstralBeamTenantList,s as mountAstralBeamTenantUserList,c as mountAstralBeamThreadList};
|