@agentica/chat 0.38.0 → 0.40.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.
@@ -1,4 +1,4 @@
1
- import{j as c,o as A,r as g,T as b}from"../client-B3aq8qpT.js";import{n as B,t as U,o as v,p as T,q as $,r as S,s as F,v as R,w as k,x as M,_,d as P,V as j,c as z,F as O,T as E,B as q}from"../VendorConfigurationMovie-B9msVFZE.js";import{D}from"../Divider-DX1xhf0M.js";function L(s){if(s.success!==!0){{if(s.value instanceof Error)throw s.value;if(typeof s.value=="object"&&s.value!==null){const t=new Error("Error from execute failure");throw Object.assign(t,s.value),t}}throw s.value}}class w{constructor(t){this.props=t,this.operations_=B.compose({controllers:t.controllers,config:t.config}),this.histories_=(t.histories??[]).map(a=>U({operations:this.operations_.group,history:a})),this.token_usage_=this.props.tokenUsage!==void 0?this.props.tokenUsage instanceof v?this.props.tokenUsage:new v(this.props.tokenUsage):v.zero(),this.listeners_=new Map,this.semaphore_=t.vendor.semaphore!=null?typeof t.vendor.semaphore=="object"?t.vendor.semaphore:new T(t.vendor.semaphore):null}clone(){var t;return new w({...this.props,histories:(t=this.props.histories)==null?void 0:t.slice()})}async conversate(t,a={}){var n,e,r;const l=[],u=async i=>{try{await this.dispatch(i),"toHistory"in i&&("join"in i?l.push(async()=>(await i.join(),i.toHistory())):l.push(async()=>i.toHistory()))}catch{}},p=$({contents:Array.isArray(t)?t:typeof t=="string"?[{type:"text",text:t}]:[t]});u(p).catch(()=>{});const h=this.getContext({prompt:p,dispatch:u,usage:this.token_usage_,abortSignal:a.abortSignal}),f=await S(h,this.operations_.array);f.length&&((e=(n=this.props.config)==null?void 0:n.executor)!=null&&e.describe)&&await(typeof this.props.config.executor.describe=="function"?this.props.config.executor.describe:F)(h,f);const o=await Promise.all(l.map(async i=>i()));if(this.histories_.push(...o),((r=this.props.config)==null?void 0:r.throw)!==!1)for(const i of f)L(i);return o}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 a=R({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?a:async(l,u)=>{await this.semaphore_.acquire();try{return await a(l,u)}finally{this.semaphore_.release().catch(()=>{})}}}}on(t,a){return k(this.listeners_,t,()=>new Set).add(a),this}off(t,a){const l=this.listeners_.get(t);return l!==void 0&&(l.delete(a),l.size===0&&this.listeners_.delete(t)),this}async dispatch(t){const a=this.listeners_.get(t.type);a!==void 0&&await Promise.all(Array.from(a).map(async l=>{try{await l(t)}catch{}}))}}var x={};Object.defineProperty(x,"__esModule",{value:!0});var m=x._isFormatUri=void 0;const H=s=>K.test(s)&&V.test(s);m=x._isFormatUri=H;const K=/\/|:/,V=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;var I={};Object.defineProperty(I,"__esModule",{value:!0});var y=I._isFormatUuid=void 0;const N=s=>W.test(s);y=I._isFormatUuid=N;const W=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;class G{constructor(){this.articles=[]}index(){return this.articles}create(t){const a={id:M(),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(a),a}update(t){const a=this.articles.find(l=>l.id===t.id);if(a===void 0)throw new Error("Unable to find the matched article.");t.input.title!==void 0&&(a.title=t.input.title),t.input.body!==void 0&&(a.body=t.input.body),t.input.thumbnail!==void 0&&(a.thumbnail=t.input.thumbnail),a.updated_at=new Date().toISOString()}erase(t){const a=this.articles.findIndex(l=>l.id===t.id);if(a===-1)throw new Error("Unable to find the matched article.");this.articles.splice(a,1)}}function J(s){const t=new G,a=new w({vendor:{api:s.api,model:s.vendorModel},controllers:[{protocol:"class",name:"bbs",application:{config:{reference:!0,strict:!1,separate:null,validate:null},functions:[{name:"index",parameters:{type:"object",properties:{},additionalProperties:!1,required:[],$defs:{IBbsArticle:{description:"Article entity.\n\n`IBbsArticle` is an entity representing an article in the BBS (Bulletin Board System).",type:"object",properties:{id:{description:"Primary Key.",type:"string",format:"uuid"},created_at:{description:"Creation time of the article.",type:"string",format:"date-time"},updated_at:{description:"Last updated time of the article.",type:"string",format:"date-time"},title:{description:`Title of the article.
1
+ import{j as c,o as A,r as g,T as b}from"../client-B3aq8qpT.js";import{n as B,t as U,o as v,p as T,q as $,r as S,s as F,v as R,w as k,x as M,_,d as P,V as j,c as z,F as O,T as E,B as q}from"../VendorConfigurationMovie-DKMwMvQB.js";import{D}from"../Divider-DX1xhf0M.js";function L(s){if(s.success!==!0){{if(s.value instanceof Error)throw s.value;if(typeof s.value=="object"&&s.value!==null){const t=new Error("Error from execute failure");throw Object.assign(t,s.value),t}}throw s.value}}class w{constructor(t){this.props=t,this.operations_=B.compose({controllers:t.controllers,config:t.config}),this.histories_=(t.histories??[]).map(a=>U({operations:this.operations_.group,history:a})),this.token_usage_=this.props.tokenUsage!==void 0?this.props.tokenUsage instanceof v?this.props.tokenUsage:new v(this.props.tokenUsage):v.zero(),this.listeners_=new Map,this.semaphore_=t.vendor.semaphore!=null?typeof t.vendor.semaphore=="object"?t.vendor.semaphore:new T(t.vendor.semaphore):null}clone(){var t;return new w({...this.props,histories:(t=this.props.histories)==null?void 0:t.slice()})}async conversate(t,a={}){var n,e,r;const l=[],u=async i=>{try{await this.dispatch(i),"toHistory"in i&&("join"in i?l.push(async()=>(await i.join(),i.toHistory())):l.push(async()=>i.toHistory()))}catch{}},p=$({contents:Array.isArray(t)?t:typeof t=="string"?[{type:"text",text:t}]:[t]});u(p).catch(()=>{});const h=this.getContext({prompt:p,dispatch:u,usage:this.token_usage_,abortSignal:a.abortSignal}),f=await S(h,this.operations_.array);f.length&&((e=(n=this.props.config)==null?void 0:n.executor)!=null&&e.describe)&&await(typeof this.props.config.executor.describe=="function"?this.props.config.executor.describe:F)(h,f);const o=await Promise.all(l.map(async i=>i()));if(this.histories_.push(...o),((r=this.props.config)==null?void 0:r.throw)!==!1)for(const i of f)L(i);return o}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 a=R({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?a:async(l,u)=>{await this.semaphore_.acquire();try{return await a(l,u)}finally{this.semaphore_.release().catch(()=>{})}}}}on(t,a){return k(this.listeners_,t,()=>new Set).add(a),this}off(t,a){const l=this.listeners_.get(t);return l!==void 0&&(l.delete(a),l.size===0&&this.listeners_.delete(t)),this}async dispatch(t){const a=this.listeners_.get(t.type);a!==void 0&&await Promise.all(Array.from(a).map(async l=>{try{await l(t)}catch{}}))}}var x={};Object.defineProperty(x,"__esModule",{value:!0});var m=x._isFormatUri=void 0;const H=s=>K.test(s)&&V.test(s);m=x._isFormatUri=H;const K=/\/|:/,V=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;var I={};Object.defineProperty(I,"__esModule",{value:!0});var y=I._isFormatUuid=void 0;const N=s=>G.test(s);y=I._isFormatUuid=N;const G=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;class W{constructor(){this.articles=[]}index(){return this.articles}create(t){const a={id:M(),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(a),a}update(t){const a=this.articles.find(l=>l.id===t.id);if(a===void 0)throw new Error("Unable to find the matched article.");t.input.title!==void 0&&(a.title=t.input.title),t.input.body!==void 0&&(a.body=t.input.body),t.input.thumbnail!==void 0&&(a.thumbnail=t.input.thumbnail),a.updated_at=new Date().toISOString()}erase(t){const a=this.articles.findIndex(l=>l.id===t.id);if(a===-1)throw new Error("Unable to find the matched article.");this.articles.splice(a,1)}}function J(s){const t=new W,a=new w({vendor:{api:s.api,model:s.vendorModel},controllers:[{protocol:"class",name:"bbs",application:{config:{reference:!0,strict:!1,separate:null,validate:null},functions:[{name:"index",parameters:{type:"object",properties:{},additionalProperties:!1,required:[],$defs:{IBbsArticle:{description:"Article entity.\n\n`IBbsArticle` is an entity representing an article in the BBS (Bulletin Board System).",type:"object",properties:{id:{description:"Primary Key.",type:"string",format:"uuid"},created_at:{description:"Creation time of the article.",type:"string",format:"date-time"},updated_at:{description:"Last updated time of the article.",type:"string",format:"date-time"},title:{description:`Title of the article.
2
2
 
3
3
  Representative title of the article.`,type:"string"},body:{description:`Content body.
4
4