@agentica/chat 0.45.0-dev.20260426 → 0.45.1

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.
@@ -1,2 +1,2 @@
1
- import{j as o,o as w,r as h,T as u}from"../client-B8OTM7em.js";import{e as x,t as v,f as d,S as j,h as _,i as C,j as S,k as A,l as k,v as E,d as I,V as b,c as U,F as B,T as M,B as O}from"../VendorConfigurationMovie-uQrARutt.js";import{D as T}from"../Divider-Cos-Ru5Z.js";function D(i){if(i.success!==!0){{if(i.value instanceof Error)throw i.value;if(typeof i.value=="object"&&i.value!==null){const t=new Error("Error from execute failure");throw Object.assign(t,i.value),t}}throw i.value}}class p{constructor(t){this.props=t,this.operations_=x.compose({controllers:t.controllers,config:t.config}),this.histories_=(t.histories??[]).map(e=>v({operations:this.operations_.group,history:e})),this.token_usage_=this.props.tokenUsage!==void 0?this.props.tokenUsage instanceof d?this.props.tokenUsage:new d(this.props.tokenUsage):d.zero(),this.listeners_=new Map,this.semaphore_=t.vendor.semaphore!=null?typeof t.vendor.semaphore=="object"?t.vendor.semaphore:new j(t.vendor.semaphore):null}clone(){var t;return new p({...this.props,histories:(t=this.props.histories)==null?void 0:t.slice()})}async conversate(t,e={}){var f,m,y;const s=[],n=async r=>{try{await this.dispatch(r),"toHistory"in r&&("join"in r?s.push(async()=>(await r.join(),r.toHistory())):s.push(async()=>r.toHistory()))}catch{}},a=_({contents:Array.isArray(t)?t:typeof t=="string"?[{type:"text",text:t}]:[t]});n(a).catch(()=>{});const c=this.getContext({prompt:a,dispatch:n,usage:this.token_usage_,abortSignal:e.abortSignal}),l=await C(c,this.operations_.array);l.length&&((m=(f=this.props.config)==null?void 0:f.executor)!=null&&m.describe)&&await(typeof this.props.config.executor.describe=="function"?this.props.config.executor.describe:S)(c,l);const g=await Promise.all(s.map(async r=>r()));if(this.histories_.push(...g),((y=this.props.config)==null?void 0:y.throw)!==!1)for(const r of l)D(r);return g}getConfig(){return this.props.config}getVendor(){return this.props.vendor}getOperations(){return this.operations_.array}getControllers(){return this.props.controllers}getHistories(){return this.histories_}getTokenUsage(){return this.token_usage_}getContext(t){const e=A({vendor:this.props.vendor,config:this.props.config,dispatch:t.dispatch,abortSignal:t.abortSignal,usage:this.token_usage_});return{operations:this.operations_,config:this.props.config,histories:this.histories_,prompt:t.prompt,dispatch:t.dispatch,request:this.semaphore_===null?e:async(s,n)=>{await this.semaphore_.acquire();try{return await e(s,n)}finally{this.semaphore_.release().catch(()=>{})}}}}on(t,e){return k(this.listeners_,t,()=>new Set).add(e),this}off(t,e){const s=this.listeners_.get(t);return s!==void 0&&(s.delete(e),s.size===0&&this.listeners_.delete(t)),this}async dispatch(t){const e=this.listeners_.get(t.type);e!==void 0&&await Promise.all(Array.from(e).map(async s=>{try{await s(t)}catch{}}))}}function R(i){throw new Error([`Error on typia.${i}(): no transform has been configured.`,"","Read and follow https://typia.io/docs/setup please.","",["If you've already completed the setup, it means there's","a bug in your code. Run `tsc` command so that check what","is wrong with your code."].join(" ")].join(`
1
+ import{j as o,o as w,r as h,T as u}from"../client-B8OTM7em.js";import{e as x,t as v,f as d,S as _,h as j,i as C,j as S,k as A,_ as k,v as E,d as I,V as b,c as U,F as B,T as M,B as O}from"../VendorConfigurationMovie-Cq8Q-tWq.js";import{D as T}from"../Divider-Cos-Ru5Z.js";function D(i){if(i.success!==!0){{if(i.value instanceof Error)throw i.value;if(typeof i.value=="object"&&i.value!==null){const t=new Error("Error from execute failure");throw Object.assign(t,i.value),t}}throw i.value}}class p{constructor(t){this.props=t,this.operations_=x.compose({controllers:t.controllers,config:t.config}),this.histories_=(t.histories??[]).map(e=>v({operations:this.operations_.group,history:e})),this.token_usage_=this.props.tokenUsage!==void 0?this.props.tokenUsage instanceof d?this.props.tokenUsage:new d(this.props.tokenUsage):d.zero(),this.listeners_=new Map,this.semaphore_=t.vendor.semaphore!=null?typeof t.vendor.semaphore=="object"?t.vendor.semaphore:new _(t.vendor.semaphore):null}clone(){var t;return new p({...this.props,histories:(t=this.props.histories)==null?void 0:t.slice()})}async conversate(t,e={}){var f,m,y;const s=[],n=async r=>{try{await this.dispatch(r),"toHistory"in r&&("join"in r?s.push(async()=>(await r.join(),r.toHistory())):s.push(async()=>r.toHistory()))}catch{}},a=j({contents:Array.isArray(t)?t:typeof t=="string"?[{type:"text",text:t}]:[t]});n(a).catch(()=>{});const c=this.getContext({prompt:a,dispatch:n,usage:this.token_usage_,abortSignal:e.abortSignal}),l=await C(c,this.operations_.array);l.length&&((m=(f=this.props.config)==null?void 0:f.executor)!=null&&m.describe)&&await(typeof this.props.config.executor.describe=="function"?this.props.config.executor.describe:S)(c,l);const g=await Promise.all(s.map(async r=>r()));if(this.histories_.push(...g),((y=this.props.config)==null?void 0:y.throw)!==!1)for(const r of l)D(r);return g}getConfig(){return this.props.config}getVendor(){return this.props.vendor}getOperations(){return this.operations_.array}getControllers(){return this.props.controllers}getHistories(){return this.histories_}getTokenUsage(){return this.token_usage_}getContext(t){const e=A({vendor:this.props.vendor,config:this.props.config,dispatch:t.dispatch,abortSignal:t.abortSignal,usage:this.token_usage_});return{operations:this.operations_,config:this.props.config,histories:this.histories_,prompt:t.prompt,dispatch:t.dispatch,request:this.semaphore_===null?e:async(s,n)=>{await this.semaphore_.acquire();try{return await e(s,n)}finally{this.semaphore_.release().catch(()=>{})}}}}on(t,e){return k(this.listeners_,t,()=>new Set).add(e),this}off(t,e){const s=this.listeners_.get(t);return s!==void 0&&(s.delete(e),s.size===0&&this.listeners_.delete(t)),this}async dispatch(t){const e=this.listeners_.get(t.type);e!==void 0&&await Promise.all(Array.from(e).map(async s=>{try{await s(t)}catch{}}))}}function R(i){throw new Error([`Error on typia.${i}(): no transform has been configured.`,"","Read and follow https://typia.io/docs/setup please.","",["If you've already completed the setup, it means there's","a bug in your code. Run `tsc` command so that check what","is wrong with your code."].join(" ")].join(`
2
2
  `))}function z(){R("llm.application")}class F{constructor(){this.articles=[]}index(){return this.articles}create(t){const e={id:E(),title:t.input.title,body:t.input.body,thumbnail:t.input.thumbnail,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return this.articles.push(e),e}update(t){const e=this.articles.find(s=>s.id===t.id);if(e===void 0)throw new Error("Unable to find the matched article.");t.input.title!==void 0&&(e.title=t.input.title),t.input.body!==void 0&&(e.body=t.input.body),t.input.thumbnail!==void 0&&(e.thumbnail=t.input.thumbnail),e.updated_at=new Date().toISOString()}erase(t){const e=this.articles.findIndex(s=>s.id===t.id);if(e===-1)throw new Error("Unable to find the matched article.");this.articles.splice(e,1)}}function H(i){const t=new F,e=new p({vendor:{api:i.api,model:i.vendorModel},controllers:[{protocol:"class",name:"bbs",application:z(),execute:t}],config:{locale:i.locale,timezone:i.timezone}});return o.jsx(I,{agent:e})}function L(){const[i,t]=h.useState(b.defaultConfig()),[e,s]=h.useState(window.navigator.language),[n,a]=h.useState(!1);return o.jsx("div",{style:{width:"100%",height:"100%",overflow:n===!0?void 0:"auto"},children:n===!0?o.jsx(H,{api:new U({apiKey:i.apiKey,baseURL:i.baseURL,dangerouslyAllowBrowser:!0}),vendorModel:i.vendorModel,locale:e}):o.jsxs(B,{style:{width:"calc(100% - 60px)",padding:15,margin:15},children:[o.jsx(u,{variant:"h6",children:"BBS AI Chatbot"}),o.jsx("br",{}),o.jsx(T,{}),o.jsx("br",{}),"Demonstration of Agentica with TypeScript Controller Class.",o.jsx("br",{}),o.jsx("br",{}),o.jsx(u,{variant:"h6",children:" OpenAI Configuration "}),o.jsx("br",{}),o.jsx(b,{config:i,onChange:t}),o.jsx("br",{}),o.jsx(u,{variant:"h6",children:" Membership Information "}),o.jsx("br",{}),o.jsx(M,{onChange:c=>s(c.target.value),defaultValue:e,label:"Locale",variant:"outlined",error:e.length===0}),o.jsx("br",{}),o.jsx("br",{}),o.jsx(O,{component:"a",fullWidth:!0,variant:"contained",color:"info",size:"large",disabled:i.apiKey.length===0||i.vendorModel.length===0||e.length===0,onClick:()=>a(!0),children:"Start AI Chatbot"})]})})}w(window.document.getElementById("root")).render(o.jsx(L,{}));