@easbot/llm 0.3.43 → 0.3.44

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export{e as DEBUG_AGENT_FILTER,d as DEFAULT_AGENT_FILTER,h as LocalAgent,g as LocalAgentError,c as SdkEventBridge,b as SdkEventBus,a as SdkEventType,f as SdkMessageCollector}from'./chunks/chunk-A6QGPYPS.mjs';import {a as a$3}from'./chunks/chunk-YUX6P6YF.mjs';export{c as SubAgent,b as SubAgentError}from'./chunks/chunk-YUX6P6YF.mjs';import {h,a as a$2,d as d$1}from'./chunks/chunk-3DTBBDPN.mjs';export{b as CUSTOM_PROVIDER_DEFINITIONS,h as Config,a as DEFAULT_ENABLED_PROVIDERS,g as LLMConfig,d as ModelsDev,c as PROVIDER_DISPLAY_NAMES,e as ProviderAuthMethod,f as ProviderConfig}from'./chunks/chunk-3DTBBDPN.mjs';import {f,d,a as a$1,w,A,k,n,g as g$1,h as h$2,o}from'./chunks/chunk-NX2YVB72.mjs';export{a as Flag,c as getAdapterRegistry,k as getGlobal,e as getIConfigProvider,g as getIGlobalPathProvider,h as getIInstallationProvider,f as getIInstanceProvider,d as hasAdapterRegistry,n as readEnvString,l as readFlagBool,m as readFlagNumber,j as resetGlobalAdapter,b as setAdapterRegistry,i as setGlobalAdapter}from'./chunks/chunk-NX2YVB72.mjs';export{a as createOpenaiCompatible,b as openaiCompatible}from'./chunks/chunk-JIETUZVR.mjs';import {a,g,h as h$1}from'./chunks/chunk-QMTIXJ7U.mjs';import p from'zod';import ro from'os';import hn from'path';import bn from'fuzzysort';import {mapValues,pickBy,mergeDeep,omit,sortBy,pipe,unique}from'remeda';import {NoSuchModelError,rerank,streamText,generateText,embed,embedMany,convertToModelMessages,APICallError,LoadAPIKeyError,stepCountIs,streamObject,generateObject,tool,jsonSchema,asSchema,wrapLanguageModel}from'ai';import {Log,State,NamedError,lazyAsync,fn,Auth,Hook,loadTextFile,BusEvent,Identifier,Storage,Preset,Shell,NameErrors,Instance,ParseCommand,TreeSitterParser,PermissionError,Permission,splitCommandSegments,ExternalDirectory,Schema,Filesystem,Lock,Glob,Wildcard,Grep,abortAfterAny,Fetch,iife,formatModelId,Env,errorMeta,parseModelId,BusinessErrors,Token,hookDefine,FunctionExecutor,CommandExecutor,HttpExecutor,HookRegistry,Markdown,Mime,formatLocalISOCompact,TruncateContent,PKG,normalizeToolInput,ACPClientAgent,ACPClientConnectionRegistry,Bus}from'@easbot/utils';export{BusinessErrors}from'@easbot/utils';import {STATUS_CODES}from'http';import {RangeSchema,UsageSchema,FileDiffSchema,TodoSchema,AgentModelSchema,AgentInfoSchema,ScopeEnum,GRAPH_RELATION_TYPE_DEFINITIONS,GRAPH_ENTITY_TYPE_DEFINITIONS}from'@easbot/types';import {HookEvent}from'@easbot/plugin';import*as Cr from'fs/promises';import Cr__default,{stat,mkdir,readFile,writeFile}from'fs/promises';import {fileURLToPath}from'url';import {structuredPatch,diffLines}from'diff';import {createReadStream}from'fs';import {createInterface}from'readline';var ti=8;function ri(e){let t=e?.api?.npm??"",r=e?.providerId??"",n=(e?.api?.id??e?.id??"").toLowerCase();return t==="@ai-sdk/google"||t==="@ai-sdk/google-vertex"||r==="google"||r==="google-vertex"||n.includes("gemini")}function er(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>er(r));let t={};for(let[r,n]of Object.entries(e))t[r]=er(n);return t}function oi(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let t=e;return t.type==="object"||t.properties!==void 0}function gn(e){return e===null||typeof e!="object"||Array.isArray(e)?false:e.type==="null"}function ht(e){let t=e.type;if(typeof t=="string")return t;if(Array.isArray(t)){let r=t.find(n=>typeof n=="string"&&n!=="null");return typeof r=="string"?r:void 0}}function Lt(e){let t=e.enum;return Array.isArray(t)?t:void 0}function ni(e){if(e.const!==void 0)return e.const;let t=Lt(e);if(t&&t.length===1)return t[0]}function si(e){if(typeof e=="string")return "string";if(typeof e=="number")return "number";if(typeof e=="boolean")return "boolean"}function ii(e){if(e.length<2)return;let t=e[0].properties??{};for(let r of Object.keys(t)){let n=[],s=true;for(let u of e){let m=u.properties??{},b=ni(m[r]??{});if(b===void 0){s=false;break}n.push(b);}if(s&&new Set(n.map(u=>JSON.stringify(u))).size===n.length)return {key:r,values:n}}}function ai(e,t){let r=e.const,n=t.const,s=Lt(e),u=Lt(t);if((r!==void 0||s!==void 0)&&(n!==void 0||u!==void 0)){let c=[...s??[r]];for(let E of u??[n])c.includes(E)||c.push(E);let w=c.every(E=>typeof E=="string"),I=c.every(E=>typeof E=="number"),h=c.every(E=>typeof E=="boolean"),g=e.description??t.description;return {...w?{type:"string"}:I?{type:"number"}:h?{type:"boolean"}:{},enum:c,...g!==void 0?{description:g}:{}}}return JSON.stringify(e)===JSON.stringify(t),e}function li(e,t,r="any"){let n={},s=[];for(let R of e){let A=R.properties??{};for(let[l,a]of Object.entries(A)){let v=n[l];n[l]=v===void 0?{...a}:ai(v,a);}let S=R.required;s.push(Array.isArray(S)?S:[]);}let u=Object.keys(n),m=r==="all"?u.filter(R=>s.some(A=>A.includes(R))):u.filter(R=>s.every(A=>A.includes(R))),b=r==="any"?ii(e):void 0;if(b){let{key:R,values:A}=b,S=n[R];if(S){let l=[],a=[],v=new Set;e.forEach((i,d)=>{let P=(i.properties??{})[R]?.description;typeof P!="string"||P.length===0||(v.add(P),a.push(`"${String(A[d])}" \u2192 ${P}`));}),v.size>1?l.push(`${R} values:
1
+ export{e as DEBUG_AGENT_FILTER,d as DEFAULT_AGENT_FILTER,h as LocalAgent,g as LocalAgentError,c as SdkEventBridge,b as SdkEventBus,a as SdkEventType,f as SdkMessageCollector}from'./chunks/chunk-A6QGPYPS.mjs';import {a as a$3}from'./chunks/chunk-KPAMBK5Y.mjs';export{c as SubAgent,b as SubAgentError}from'./chunks/chunk-KPAMBK5Y.mjs';import {h,a as a$2,d as d$1}from'./chunks/chunk-YCTDPTRN.mjs';export{b as CUSTOM_PROVIDER_DEFINITIONS,h as Config,a as DEFAULT_ENABLED_PROVIDERS,g as LLMConfig,d as ModelsDev,c as PROVIDER_DISPLAY_NAMES,e as ProviderAuthMethod,f as ProviderConfig}from'./chunks/chunk-YCTDPTRN.mjs';import {f,d,a as a$1,w,A,k,n,g as g$1,h as h$2,o}from'./chunks/chunk-KQG6755X.mjs';export{a as Flag,c as getAdapterRegistry,k as getGlobal,e as getIConfigProvider,g as getIGlobalPathProvider,h as getIInstallationProvider,f as getIInstanceProvider,d as hasAdapterRegistry,n as readEnvString,l as readFlagBool,m as readFlagNumber,j as resetGlobalAdapter,b as setAdapterRegistry,i as setGlobalAdapter}from'./chunks/chunk-KQG6755X.mjs';export{a as createOpenaiCompatible,b as openaiCompatible}from'./chunks/chunk-JIETUZVR.mjs';import {a,g,h as h$1}from'./chunks/chunk-QMTIXJ7U.mjs';import p from'zod';import ro from'os';import hn from'path';import bn from'fuzzysort';import {mapValues,pickBy,mergeDeep,omit,sortBy,pipe,unique}from'remeda';import {NoSuchModelError,rerank,streamText,generateText,embed,embedMany,convertToModelMessages,APICallError,LoadAPIKeyError,stepCountIs,streamObject,generateObject,tool,jsonSchema,asSchema,wrapLanguageModel}from'ai';import {Log,State,NamedError,lazyAsync,fn,Auth,Hook,loadTextFile,BusEvent,Identifier,Storage,Preset,Shell,NameErrors,Instance,ParseCommand,TreeSitterParser,PermissionError,Permission,splitCommandSegments,ExternalDirectory,Schema,Filesystem,Lock,Glob,Wildcard,Grep,abortAfterAny,Fetch,iife,formatModelId,Env,errorMeta,parseModelId,BusinessErrors,Token,hookDefine,FunctionExecutor,CommandExecutor,HttpExecutor,HookRegistry,Markdown,Mime,formatLocalISOCompact,TruncateContent,PKG,normalizeToolInput,ACPClientAgent,ACPClientConnectionRegistry,Bus}from'@easbot/utils';export{BusinessErrors}from'@easbot/utils';import {STATUS_CODES}from'http';import {RangeSchema,UsageSchema,FileDiffSchema,TodoSchema,AgentModelSchema,AgentInfoSchema,ScopeEnum,GRAPH_RELATION_TYPE_DEFINITIONS,GRAPH_ENTITY_TYPE_DEFINITIONS}from'@easbot/types';import {HookEvent}from'@easbot/plugin';import*as Cr from'fs/promises';import Cr__default,{stat,mkdir,readFile,writeFile}from'fs/promises';import {fileURLToPath}from'url';import {structuredPatch,diffLines}from'diff';import {createReadStream}from'fs';import {createInterface}from'readline';var ti=8;function ri(e){let t=e?.api?.npm??"",r=e?.providerId??"",n=(e?.api?.id??e?.id??"").toLowerCase();return t==="@ai-sdk/google"||t==="@ai-sdk/google-vertex"||r==="google"||r==="google-vertex"||n.includes("gemini")}function er(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>er(r));let t={};for(let[r,n]of Object.entries(e))t[r]=er(n);return t}function oi(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let t=e;return t.type==="object"||t.properties!==void 0}function gn(e){return e===null||typeof e!="object"||Array.isArray(e)?false:e.type==="null"}function ht(e){let t=e.type;if(typeof t=="string")return t;if(Array.isArray(t)){let r=t.find(n=>typeof n=="string"&&n!=="null");return typeof r=="string"?r:void 0}}function Lt(e){let t=e.enum;return Array.isArray(t)?t:void 0}function ni(e){if(e.const!==void 0)return e.const;let t=Lt(e);if(t&&t.length===1)return t[0]}function si(e){if(typeof e=="string")return "string";if(typeof e=="number")return "number";if(typeof e=="boolean")return "boolean"}function ii(e){if(e.length<2)return;let t=e[0].properties??{};for(let r of Object.keys(t)){let n=[],s=true;for(let u of e){let m=u.properties??{},b=ni(m[r]??{});if(b===void 0){s=false;break}n.push(b);}if(s&&new Set(n.map(u=>JSON.stringify(u))).size===n.length)return {key:r,values:n}}}function ai(e,t){let r=e.const,n=t.const,s=Lt(e),u=Lt(t);if((r!==void 0||s!==void 0)&&(n!==void 0||u!==void 0)){let c=[...s??[r]];for(let E of u??[n])c.includes(E)||c.push(E);let w=c.every(E=>typeof E=="string"),I=c.every(E=>typeof E=="number"),h=c.every(E=>typeof E=="boolean"),g=e.description??t.description;return {...w?{type:"string"}:I?{type:"number"}:h?{type:"boolean"}:{},enum:c,...g!==void 0?{description:g}:{}}}return JSON.stringify(e)===JSON.stringify(t),e}function li(e,t,r="any"){let n={},s=[];for(let R of e){let A=R.properties??{};for(let[l,a]of Object.entries(A)){let v=n[l];n[l]=v===void 0?{...a}:ai(v,a);}let S=R.required;s.push(Array.isArray(S)?S:[]);}let u=Object.keys(n),m=r==="all"?u.filter(R=>s.some(A=>A.includes(R))):u.filter(R=>s.every(A=>A.includes(R))),b=r==="any"?ii(e):void 0;if(b){let{key:R,values:A}=b,S=n[R];if(S){let l=[],a=[],v=new Set;e.forEach((i,d)=>{let P=(i.properties??{})[R]?.description;typeof P!="string"||P.length===0||(v.add(P),a.push(`"${String(A[d])}" \u2192 ${P}`));}),v.size>1?l.push(`${R} values:
2
2
  ${a.map(i=>`- ${i}`).join(`
3
3
  `)}`):v.size===1&&l.push([...v][0]);let o=[];e.forEach((i,d)=>{let P=(Array.isArray(i.required)?i.required:[]).filter(T=>T!==R);P.length>0&&o.push(`"${String(A[d])}" \u2192 ${P.join(", ")}`);}),o.length>0&&l.push(`Required fields by ${R}: ${o.join("; ")}.`),l.length>0&&(S.description=l.join(`
4
4
 
@@ -50,7 +50,7 @@ ${w}`}var Tn={\u5C5E\u4E8E:"part_of",\u662F\u5176\u4E2D\u4E00\u90E8\u5206:"part_
50
50
  `)}function m(h){try{return JSON.stringify(h)??""}catch{return ""}}function b(h){let g=0;for(let[E,f]of Object.entries(h??{}))f&&(g+=Token.estimate(E),f.description&&(g+=Token.estimate(f.description)),f.inputSchema&&(g+=Token.estimate(m(f.inputSchema))));return g}function c(h){return Token.estimate((h.system??[]).filter(g=>typeof g=="string").join(`
51
51
 
52
52
  `))+Token.estimate(u(h.messages??[]))+b(h.tools??{})}I.estimateInputTokens=c;function w(h){return c(h)>=r(h.model)}I.isOverflow=w;})(ct||(ct={}));var Ut=hookDefine;var Mn=Log.create({service:"llm.hook.llm"}),lr=Ut("llm.builtin",{async init(){return {isEnabled:()=>true,handlers:[{name:HookEvent.LlmParams,handler:(e,t)=>{let r=e;return Mn.debug("llm.params hook triggered",{sessionId:t?.sessionId,provider:r?.provider,agent:r?.agent}),{modified:false,input:e}}},{name:HookEvent.LlmHeaders,handler:(e,t)=>{let r=e;return Mn.debug("llm.headers hook triggered",{sessionId:t?.sessionId,provider:r?.provider,agent:r?.agent}),{modified:false,input:e}}}]}}});var Fi=Log.create({service:"llm.hook.processor"});function He(e){return (t,r)=>(Fi.debug("processor hook triggered",{event:e,agent:r?.agent,model:r?.model,streamId:t?.streamId}),{modified:false,input:t})}var dr=Ut("processor.builtin",{async init(){return {isEnabled:()=>true,handlers:[{name:HookEvent.ProcessorStart,handler:He(HookEvent.ProcessorStart)},{name:HookEvent.ProcessorFinish,handler:He(HookEvent.ProcessorFinish)},{name:HookEvent.ProcessorError,handler:He(HookEvent.ProcessorError)},{name:HookEvent.ProcessorStepStart,handler:He(HookEvent.ProcessorStepStart)},{name:HookEvent.ProcessorStepFinish,handler:He(HookEvent.ProcessorStepFinish)},{name:HookEvent.ProcessorReasoningStart,handler:He(HookEvent.ProcessorReasoningStart)},{name:HookEvent.ProcessorReasoningDelta,handler:He(HookEvent.ProcessorReasoningDelta)},{name:HookEvent.ProcessorReasoningEnd,handler:He(HookEvent.ProcessorReasoningEnd)},{name:HookEvent.ProcessorToolInputStart,handler:He(HookEvent.ProcessorToolInputStart)},{name:HookEvent.ProcessorToolCall,handler:He(HookEvent.ProcessorToolCall)},{name:HookEvent.ProcessorToolResult,handler:He(HookEvent.ProcessorToolResult)},{name:HookEvent.ProcessorToolError,handler:He(HookEvent.ProcessorToolError)},{name:HookEvent.ProcessorTextStart,handler:He(HookEvent.ProcessorTextStart)},{name:HookEvent.ProcessorTextDelta,handler:He(HookEvent.ProcessorTextDelta)},{name:HookEvent.ProcessorTextEnd,handler:He(HookEvent.ProcessorTextEnd)}]}}});var vt=[lr,dr];var Mt=Log.create({service:"llm.hook.prompt-executor"}),Et=class Et{constructor(){a(this,"type","prompt");}static getInstance(){return Et._instance||(Et._instance=new Et),Et._instance}canExecute(t){return t?.type==="prompt"}async execute(t,r,n){var m=[];try{let s=Date.now();let u=g(m,Mt.time("promptHookExecute",{level:"DEBUG"}));try{Mt.debug("Execute Prompt Hook",{partsCount:t.parts?.length,model:t.model,runMode:t.runMode??"session",context:n?.sessionId});let I=t.model?(()=>{let R=parseModelId(t.model);return {providerId:R.providerId||"default",modelId:R.modelId}})():void 0,h=(t.parts??[]).filter(R=>typeof R=="object"&&R!==null&&R.type==="text"&&typeof R.text=="string"),g=n?.sessionId??"prompt-hook",E=this.extractTitle(t.parts),f=await w(),k={};if(t.onMessage){let R=t.onMessage;k.onMessage=(A=>{Promise.resolve(R(A)).catch(S=>{Mt.error("PromptHook onMessage callback failed",{error:errorMeta(S)});});});}return f.runAsync({source:g,title:E,agent:n?.agent,model:I,system:t.system,parts:h.length>0?h:[{type:"text",text:""}]},async R=>{let A=Date.now()-s;Mt.debug("Prompt Hook completed",{title:E,duration:A,outputLength:typeof R.output=="string"?R.output.length:0});},k).catch(R=>{Mt.error("Prompt Hook async dispatch failed",{title:E,error:errorMeta(R)});}),{success:!0,modified:r.modified,input:r.input,output:`Prompt task started: ${E}`,duration:Date.now()-s,metadata:{sessionId:g}}}catch(I){return Mt.error("Prompt Hook execution failed",{error:errorMeta(I)}),{success:!1,modified:!1,error:errorMeta(I).message,duration:Date.now()-s,metadata:{sessionId:n?.sessionId}}}}catch(b){var c=b,w$1=true;}finally{h$1(m,c,w$1);}}extractTitle(t){if(!t||t.length===0)return "Prompt Task";let r=t.find(n=>typeof n=="object"&&n!==null&&n.type==="text");return r&&typeof r.text=="string"?r.text.slice(0,50):"Prompt Task"}};a(Et,"_instance");var ur=Et;var Pt=Log.create({service:"llm.hook.agent-executor"}),kt=class kt{constructor(){a(this,"type","agent");}static getInstance(){return kt._instance||(kt._instance=new kt),kt._instance}canExecute(t){return !t||typeof t!="object"?false:t.type==="agent"}async execute(t,r,n){var m=[];try{let s=Date.now();let u=g(m,Pt.time("agentHookExecute",{level:"DEBUG"}));try{let I=t.agent??n?.agent??"task_general",h=t.model?(()=>{let k=parseModelId(t.model);return {providerId:k.providerId||"default",modelId:k.modelId}})():void 0,g=this.extractTitle(t.parts);Pt.debug("Execute Agent Hook (async)",{type:t.type,agent:I,model:t.model,timeout:t.timeout,context:n?.sessionId,title:g});let E=await A(),f;if(t.onMessage){let k=t.onMessage;f={onMessage:(R=>{Promise.resolve(k(R)).catch(A=>{Pt.error("AgentHook onMessage callback failed",{error:errorMeta(A)});});})};}return E.run({source:n?.sessionId??"",title:g,agent:I,system:t.system,parts:t.parts??[],model:h,config:{runMode:"ephemeral",transport:"stdio"}},f).then(k=>{let R=Date.now()-s;Pt.debug("Agent Hook completed",{title:g,agent:I,duration:R,outputLength:typeof k?.output=="string"?k.output.length:0});}).catch(k=>{Pt.error("Agent Hook execution failed (async)",{title:g,agent:I,error:errorMeta(k)});}),{success:!0,modified:r.modified,input:r.input,output:`Agent task started: ${g}
53
- Agent: ${I}`,duration:Date.now()-s,metadata:{agent:I,title:g}}}catch(I){return Pt.error("Agent Hook execution failed",{error:errorMeta(I)}),{success:!1,modified:!1,error:errorMeta(I).message,duration:Date.now()-s}}}catch(b){var c=b,w=true;}finally{h$1(m,c,w);}}extractTitle(t){if(!t||t.length===0)return "Agent Task";let r=t.find(n=>typeof n=="object"&&n!==null&&n.type==="text");return r&&typeof r.text=="string"?r.text.slice(0,50):"Agent Task"}};a(kt,"_instance");var mr=kt;var it=class it{constructor(){a(this,"executors",[]);}static getInstance(){return it._instance||(it._instance=new it,it._instance.registerDefaultExecutors()),it._instance}static resetInstance(){it._instance=void 0;}registerDefaultExecutors(){this.register(FunctionExecutor.getInstance()),this.register(CommandExecutor.getInstance()),this.register(ur.getInstance()),this.register(HttpExecutor.getInstance()),this.register(mr.getInstance());}register(t){this.executors.push(t);}getExecutor(t){return this.executors.find(r=>r.canExecute(t))}async execute(t,r,n){let s=this.getExecutor(t);return s?s.execute(t,r,n):{success:false,modified:false,error:`No executor found for hook type: ${t.type}`}}};a(it,"_instance");var Ft=it;var Xi=Log.create({service:"llm.hook.registry"}),Yi=new Set([]),Zi=["agent","prompt"],Qi=Hook.createReentrancyGuard({maxDepth:3,recursiveHookTypes:Zi,service:"llm-hook-registry-reentrancy"});async function Sn(){return Qi}var ea=async(e,t)=>await(await Sn()).skipMatcher(e,t)?true:typeof e.hookName!="string"||e.hookName.length===0?false:Yi.has(e.hookName);async function ta(e){try{let{getSdk:t}=await import('./chunks/interfaces-U2BBKCET.mjs'),s=(await t()).session?.contextMode?.get;if(s){let u=(await s({sessionId:e}))?.data;if(typeof u=="string"&&u.length>0)return u;if(u&&typeof u=="object"){let m=u.contextMode;if(typeof m=="string"&&m.length>0)return m}}}catch{}return ScopeEnum.General}async function ra(e){return e?.contextMode?e.contextMode:e?.sessionId?ta(e.sessionId):ScopeEnum.General}var gr=false;function uo(){gr||(gr=true,HookRegistry.registerHooks([...vt]),Xi.info("hook bridge installed",{builtinCount:vt.length,builtinNames:vt.map(e=>e.name),skipMatcherConfigured:true,executorRegistered:true}));}async function na(e,t,r){gr||uo();let n=await ra(r),s=Ft.getInstance();return (await Sn()).triggerGuard({event:e,context:r,invoke:()=>HookRegistry.triggerEvent(e,t,r,{scope:n,executorRegistry:s,skipMatcher:ea})})}var Qe;(w=>{function e(){gr||uo();}async function t(){return e(),HookRegistry.state()}w.state=t;async function r(){e(),await HookRegistry.init();}w.init=r;async function n(I){return e(),HookRegistry.registerMatcher(I)}w.registerMatcher=n;async function s(I,h,g){return e(),na(I,h,g)}w.triggerEvent=s;function u(){HookRegistry.resetState();}w.resetState=u;async function m(){return e(),HookRegistry.matcherCount()}w.matcherCount=m;function b(){return vt}w.builtinHooks=b;function c(){e();let I=HookRegistry.registeredHooks(),h=new Set,g=[];for(let E of [...vt,...I])h.has(E.name)||(h.add(E.name),g.push(E));return g}w.registeredHooks=c;})(Qe||(Qe={}));globalThis.AI_SDK_LOG_WARNINGS=false;var Ke=Log.create({service:"llm.model.language"}),$e;(v=>{v.OUTPUT_TOKEN_MAX=Se.getOutputTokenMax(),v.DEFAULT_MAX_RETRIES=4;function r(o,i,d){if(o!==void 0){if(!Number.isFinite(o)){Ke.warn("temperature is not a finite number, ignored",{source:i,modelId:d,value:o});return}return o<ee.LIMITS.TEMPERATURE_MIN?(Ke.warn("temperature below safe minimum, clamped",{source:i,modelId:d,requested:o,min:ee.LIMITS.TEMPERATURE_MIN}),ee.LIMITS.TEMPERATURE_MIN):o>ee.LIMITS.TEMPERATURE_MAX?(Ke.warn("temperature above safe maximum, clamped",{source:i,modelId:d,requested:o,max:ee.LIMITS.TEMPERATURE_MAX}),ee.LIMITS.TEMPERATURE_MAX):o}}function n(o){let i=o?.filter(d=>d.length>0);return i&&i.length>0?i:void 0}function s(o){let i=(o??[]).filter(d=>typeof d=="string"&&d.length>0);return i.length===0?[]:[i.join(`
53
+ Agent: ${I}`,duration:Date.now()-s,metadata:{agent:I,title:g}}}catch(I){return Pt.error("Agent Hook execution failed",{error:errorMeta(I)}),{success:!1,modified:!1,error:errorMeta(I).message,duration:Date.now()-s}}}catch(b){var c=b,w=true;}finally{h$1(m,c,w);}}extractTitle(t){if(!t||t.length===0)return "Agent Task";let r=t.find(n=>typeof n=="object"&&n!==null&&n.type==="text");return r&&typeof r.text=="string"?r.text.slice(0,50):"Agent Task"}};a(kt,"_instance");var mr=kt;var it=class it{constructor(){a(this,"executors",[]);}static getInstance(){return it._instance||(it._instance=new it,it._instance.registerDefaultExecutors()),it._instance}static resetInstance(){it._instance=void 0;}registerDefaultExecutors(){this.register(FunctionExecutor.getInstance()),this.register(CommandExecutor.getInstance()),this.register(ur.getInstance()),this.register(HttpExecutor.getInstance()),this.register(mr.getInstance());}register(t){this.executors.push(t);}getExecutor(t){return this.executors.find(r=>r.canExecute(t))}async execute(t,r,n){let s=this.getExecutor(t);return s?s.execute(t,r,n):{success:false,modified:false,error:`No executor found for hook type: ${t.type}`}}};a(it,"_instance");var Ft=it;var Xi=Log.create({service:"llm.hook.registry"}),Yi=new Set([]),Zi=["agent","prompt"],Qi=Hook.createReentrancyGuard({maxDepth:3,recursiveHookTypes:Zi,service:"llm-hook-registry-reentrancy"});async function Sn(){return Qi}var ea=async(e,t)=>await(await Sn()).skipMatcher(e,t)?true:typeof e.hookName!="string"||e.hookName.length===0?false:Yi.has(e.hookName);async function ta(e){try{let{getSdk:t}=await import('./chunks/interfaces-XDWUI5BX.mjs'),s=(await t()).session?.contextMode?.get;if(s){let u=(await s({sessionId:e}))?.data;if(typeof u=="string"&&u.length>0)return u;if(u&&typeof u=="object"){let m=u.contextMode;if(typeof m=="string"&&m.length>0)return m}}}catch{}return ScopeEnum.General}async function ra(e){return e?.contextMode?e.contextMode:e?.sessionId?ta(e.sessionId):ScopeEnum.General}var gr=false;function uo(){gr||(gr=true,HookRegistry.registerHooks([...vt]),Xi.info("hook bridge installed",{builtinCount:vt.length,builtinNames:vt.map(e=>e.name),skipMatcherConfigured:true,executorRegistered:true}));}async function na(e,t,r){gr||uo();let n=await ra(r),s=Ft.getInstance();return (await Sn()).triggerGuard({event:e,context:r,invoke:()=>HookRegistry.triggerEvent(e,t,r,{scope:n,executorRegistry:s,skipMatcher:ea})})}var Qe;(w=>{function e(){gr||uo();}async function t(){return e(),HookRegistry.state()}w.state=t;async function r(){e(),await HookRegistry.init();}w.init=r;async function n(I){return e(),HookRegistry.registerMatcher(I)}w.registerMatcher=n;async function s(I,h,g){return e(),na(I,h,g)}w.triggerEvent=s;function u(){HookRegistry.resetState();}w.resetState=u;async function m(){return e(),HookRegistry.matcherCount()}w.matcherCount=m;function b(){return vt}w.builtinHooks=b;function c(){e();let I=HookRegistry.registeredHooks(),h=new Set,g=[];for(let E of [...vt,...I])h.has(E.name)||(h.add(E.name),g.push(E));return g}w.registeredHooks=c;})(Qe||(Qe={}));globalThis.AI_SDK_LOG_WARNINGS=false;var Ke=Log.create({service:"llm.model.language"}),$e;(v=>{v.OUTPUT_TOKEN_MAX=Se.getOutputTokenMax(),v.DEFAULT_MAX_RETRIES=4;function r(o,i,d){if(o!==void 0){if(!Number.isFinite(o)){Ke.warn("temperature is not a finite number, ignored",{source:i,modelId:d,value:o});return}return o<ee.LIMITS.TEMPERATURE_MIN?(Ke.warn("temperature below safe minimum, clamped",{source:i,modelId:d,requested:o,min:ee.LIMITS.TEMPERATURE_MIN}),ee.LIMITS.TEMPERATURE_MIN):o>ee.LIMITS.TEMPERATURE_MAX?(Ke.warn("temperature above safe maximum, clamped",{source:i,modelId:d,requested:o,max:ee.LIMITS.TEMPERATURE_MAX}),ee.LIMITS.TEMPERATURE_MAX):o}}function n(o){let i=o?.filter(d=>d.length>0);return i&&i.length>0?i:void 0}function s(o){let i=(o??[]).filter(d=>typeof d=="string"&&d.length>0);return i.length===0?[]:[i.join(`
54
54
  `)]}function u(o){if(o!==void 0){if(!Number.isFinite(o)||o<=0){Ke.warn("maxOutputTokens is not a positive finite number, ignored",{value:o});return}return Math.min(Math.floor(o),2147483647)}}function m(o){return typeof o=="object"&&o!==null&&"specificationVersion"in o}async function b(o){let i=o.provider||(await ee.defaultModel()).providerId,d=o.modelId;try{let x=await ee.getModel(i,d);return x.providerId?x:{...x,providerId:i}}catch{return Ke.debug("language model instance not found in catalog, using minimal metadata",{providerId:i,modelId:d}),{id:d,name:d,providerId:i,api:{id:d},capabilities:{temperature:true}}}}async function c(o){if(m(o))return await b(o);if(typeof o=="string"){let{providerId:i,modelId:d}=parseModelId(o),x=i||(await ee.defaultModel()).providerId;return ee.getModel(x,d)}return "api"in o?o:ee.getModel(o.providerId,o.modelId)}v.resolveModel=c;function w(o,i,d){if(o.success&&!o.aborted)return;let x=o.errors.map(P=>`${P.hookName}: ${P.error}`).join("; ");throw Ke.warn("llm hook chain did not complete successfully",{event:i,aborted:o.aborted,errorCount:o.errors.length,sessionId:d.sessionId,agent:d.agent.name,detail:x}),new NameErrors.OperationFailedError({message:`Hook '${i}' ${o.aborted?"aborted":"failed"}${x?`: ${x}`:""}`,operation:`llm-hook-${i}`})}async function I(o){let i=await c(o.model),d=m(o.model)?Promise.resolve(o.model):ee.getLanguage(i),[x,P,T,O]=await Promise.all([d,ee.getProvider(i.providerId),Auth.get(i.providerId),h.get()]),D=P?.id==="openai"&&T?.type==="oauth",Y=s(o.system),Q=!o.small&&i.variants&&o.user.variant?i.variants[o.user.variant]??{}:{},oe=o.small?Se.smallOptions(i):Se.options({model:i,sessionId:o.sessionId,providerOptions:P?.options??{}}),ae=pipe(oe,mergeDeep(i.options??{}),mergeDeep(o.agent.options??{}),mergeDeep(Q??{}));D&&(ae.instructions=Y.join(`
55
55
  `));let ue=await Qe.triggerEvent(HookEvent.LlmParams,{sessionId:o.sessionId,agent:o.agent.name,model:i,provider:P,message:o.user},{sessionId:o.sessionId,agent:o.agent.name,model:ee.formatModel(i)});w(ue,HookEvent.LlmParams,o);let be=ee.formatModel(i),Le=i.capabilities.temperature?r(o.temperature??o.user.temperature??o.agent.temperature??Se.temperature(i),o.temperature!==void 0?"input":o.user.temperature!==void 0?"user":o.agent.temperature!==void 0?"agent":"model",be):void 0,Fe=o.agent.topP??Se.topP(i),xe=Se.topK(i),ke=n(o.stopSequences),Ce=ue.output??{},Ne={temperature:Ce.temperature??Le,topP:Ce.topP??Fe,topK:Ce.topK??xe,options:Ce.options?mergeDeep(ae)(Ce.options):ae};Ce.options&&Ke.debug("llm.params hook overrode provider options",{keys:Object.keys(Ce.options),model:be});let $=await Qe.triggerEvent(HookEvent.LlmHeaders,{sessionId:o.sessionId,agent:o.agent.name,model:i,provider:P,message:o.user},{sessionId:o.sessionId,agent:o.agent.name,model:ee.formatModel(i)});w($,HookEvent.LlmHeaders,o);let J=$.output?.headers??{},pe=u(o.maxOutputTokens),Re=D||i.providerId?.includes("github-copilot"),de=Se.maxOutputTokens(i),C=pe===void 0?Re?void 0:de:Math.min(pe,de),N=h$2(o,i),y=to(i,N),M=o.activeTools?o.activeTools.filter(re=>re!=="invalid"):Object.keys(y).filter(re=>re!=="invalid"),L=ct.estimateInputTokens({system:Y,messages:o.messages,tools:y}),U=ct.getUsableInputWindow(i);if(L>=U)throw Ke.warn("context window exhausted before request",{estimatedTokens:L,usableWindow:U,modelId:i.id,providerId:i.providerId,sessionId:o.sessionId,agent:o.agent.name}),new BusinessErrors.ContextWindowExhaustedError({message:`Context window exhausted: estimated ${L} tokens exceeds usable window ${U}`,remaining:Math.max(U-L,0),contextWindow:U,tokenEstimate:L});let W=g$1(o,i),Z=Y.map(re=>({role:"system",content:re}));return {providerModel:i,language:x,options:Ne.options,temperature:Ne.temperature,topP:Ne.topP,topK:Ne.topK,maxOutputTokens:C,stopSequences:ke,headers:{...W,...J,...o.headers??{}},tools:y,activeTools:M,systemPrompts:Z}}v.resolveCall=I;function h$2(o,i){let d={...o.tools??{}},x=o.messages??[];return o.activeTools&&o.activeTools.length===0||Object.keys(d).length>0||!l(x)||!(i.providerId?.toLowerCase().includes("litellm")||i.api?.id?.toLowerCase().includes("litellm")||i.providerId?.includes("github-copilot"))||(d._noop=tool({description:"Do not call this tool. It exists only for API compatibility and must never be invoked.",inputSchema:jsonSchema({type:"object",properties:{reason:{type:"string",description:"Unused"}}}),execute:async()=>({output:"",title:"",metadata:{}})})),d}function g$1(o$1,i){return {...i.providerId?.startsWith("easbot")?{"x-easbot-project":o$1.projectId??"","x-easbot-session":o$1.sessionId,"x-easbot-request":o$1.user.id,"x-easbot-client":a$1.client()}:i.providerId!=="anthropic"?{"User-Agent":`easbot/${o.getVersion()}`}:{},...i.headers??{}}}function E(o,i,d){return wrapLanguageModel({model:o,middleware:[{specificationVersion:"v3",async transformParams({params:x}){let P=x.prompt;return P&&Array.isArray(P)&&(x.prompt=Se.message(P,i,d)),x}}]})}function f(o,i){return {model:E(i.language,i.providerModel,i.options),system:i.systemPrompts,messages:o.messages??[],tools:i.tools,activeTools:i.activeTools,temperature:i.temperature,topP:i.topP,topK:i.topK,stopSequences:i.stopSequences,maxOutputTokens:i.maxOutputTokens,presencePenalty:o.presencePenalty,frequencyPenalty:o.frequencyPenalty,seed:o.seed,toolChoice:o.toolChoice,providerOptions:Se.providerOptions(i.providerModel,i.options),headers:i.headers,maxRetries:o.retries??v.DEFAULT_MAX_RETRIES,abortSignal:o.abort,timeout:o.timeout,stopWhen:o.stopWhen??stepCountIs(1),experimental_repairToolCall:async d=>k(d,i.tools,i.activeTools),onError(d){let x=d?.error??d;Ke.error("llm stream error",{error:errorMeta(x),modelId:i.providerModel.id,providerId:i.providerModel.providerId});},experimental_telemetry:{isEnabled:o.telemetry??R("EASBOT_OPEN_TELEMETRY"),metadata:{userId:o.userId??process.env.EASBOT_USERNAME??"unknown",sessionId:o.sessionId}}}}function k(o,i,d){let x=o.toolCall.toolName.toLowerCase();return x!==o.toolCall.toolName&&i[x]&&(d===void 0||d.includes(x))?{...o.toolCall,toolName:x}:null}function R(o){let i=process.env[o]?.toLowerCase();return i==="true"||i==="1"}async function A(o){var P=[];try{let i=await I(o);let d=g(P,Ke.time("llm.model.language.stream",{level:"DEBUG",baseUrl:`${i.providerModel.api.url}`}));let x=streamText(f(o,i));Ke.debug("streamText invoked",{modelId:i.providerModel.id,providerId:i.providerModel.providerId,sessionId:o.sessionId,agent:o.agent.name,small:o.small??!1,toolCount:Object.keys(i.tools).length,activeToolCount:i.activeTools?.length??0,stopSequences:i.stopSequences?.length??0});return x}catch(T){var O=T,D=true;}finally{h$1(P,O,D);}}v.stream=A;async function S(o){var T=[];try{let i=await I(o);let d=g(T,Ke.time("llm.model.language.generate",{level:"DEBUG",model:`${i.providerModel.providerId}/${i.providerModel.id}`,baseUrl:`${i.providerModel.api.url}`}));let x=f(o,i);let P=await generateText(x);Ke.debug("generateText completed",{modelId:i.providerModel.id,providerId:i.providerModel.providerId,sessionId:o.sessionId,agent:o.agent.name});return P}catch(O){var D=O,Y=true;}finally{h$1(T,D,Y);}}v.generate=S;function l(o){for(let i of o)if(Array.isArray(i.content)){for(let d of i.content)if(d.type==="tool-call"||d.type==="tool-result")return true}return false}v.hasToolCalls=l;function a(o,i,d){let x=Ne=>typeof Ne=="number"&&Number.isFinite(Ne)?Ne:0,P=x(o?.inputTokens),T=x(o?.outputTokens),O=x(o?.outputTokenDetails?.reasoningTokens??o?.reasoningTokens),D=x(o?.inputTokenDetails?.cacheReadTokens??o?.cachedInputTokens),Y=x(o?.inputTokenDetails?.cacheWriteTokens),Q=i?.anthropic?.cacheCreationInputTokens??i?.bedrock?.usage?.cacheWriteInputTokens??i?.venice?.usage?.cacheCreationInputTokens,oe=x(Y||Q),ae=!!(i?.anthropic||i?.bedrock),ue=Math.max(0,x(ae?P:P-D-oe)),be=d?.api?.npm,Fe=x(be==="@ai-sdk/anthropic"||be==="@ai-sdk/amazon-bedrock"||be==="@ai-sdk/google-vertex/anthropic"?ue+T+D+oe:o?.totalTokens),xe=d?.cost?.experimentalOver200K,ke=xe&&ue+D>2e5?xe:d?.cost,Ce=ue*x(ke?.input)/1e6+T*x(ke?.output)/1e6+D*x(ke?.cache?.read)/1e6+oe*x(ke?.cache?.write)/1e6;return {total:Fe,input:ue,output:T,reasoning:O,cache:{read:D,write:oe},cost:x(Ce)}}v.computeUsage=a;})($e||($e={}));var go;(A=>{let e=Log.create({service:"llm.model.graph"}),t=5,r=2e3,n=32e3,s=3;function m(S,l){let a=[];for(let v of S){if(v.length<=l){v.length>0&&a.push(v);continue}let o=0;for(;o<v.length;){if(v.length-o<=l){let P=v.slice(o);P.length>0&&a.push(P);break}let d=v.slice(o,o+l),x=-1;for(let P=d.length-1;P>=Math.max(0,d.length-200);P--){let T=d[P];if(T===void 0)break;if(T===`
56
56
  `&&d[P-1]===`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easbot/llm",
3
- "version": "0.3.43",
3
+ "version": "0.3.44",
4
4
  "description": "AI model aggregation layer for EASBot ecosystem: multi-vendor SDK dynamic loading, model routing, configuration management, and high-level Model Provider capability wrapping.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -87,12 +87,12 @@
87
87
  "@ai-sdk/xai": "3.0.120",
88
88
  "@aws-sdk/credential-providers": "3.1110.0",
89
89
  "@openrouter/ai-sdk-provider": "^2.9.0",
90
- "@easbot/sdk": "^0.3.43",
91
- "@easbot/types": "^0.3.43",
92
- "@easbot/utils": "^0.3.43",
93
- "@easbot/local-model-sdk": "^0.3.43",
94
- "@easbot/ollama-sdk": "^0.3.43",
95
- "@easbot/plugin": "^0.3.43",
90
+ "@easbot/sdk": "^0.3.44",
91
+ "@easbot/types": "^0.3.44",
92
+ "@easbot/utils": "^0.3.44",
93
+ "@easbot/local-model-sdk": "^0.3.44",
94
+ "@easbot/ollama-sdk": "^0.3.44",
95
+ "@easbot/plugin": "^0.3.44",
96
96
  "ai": "^6.0.253",
97
97
  "ai-gateway-provider": "^3.2.0",
98
98
  "diff": "^9.0.0",
@@ -1,11 +0,0 @@
1
- 'use strict';var chunkGHMRMPMO_cjs=require('./chunk-GHMRMPMO.cjs'),chunk2XQWKCQ4_cjs=require('./chunk-2XQWKCQ4.cjs'),utils=require('@easbot/utils'),H=require('zod');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var H__default=/*#__PURE__*/_interopDefault(H);function M(i,e){let t;if(typeof Buffer<"u")t=Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString("base64");else {let r="";for(let a=0;a<i.length;a+=32768){let o=i.subarray(a,Math.min(a+32768,i.length));r+=String.fromCharCode.apply(null,o);}t=btoa(r);}return `data:${e??"application/octet-stream"};base64,${t}`}function J(i,e){let t=[];if(i)for(let n of i)switch(n.type){case "text":n.text&&t.push(`<text>
2
- ${n.text}
3
- </text>`);break;case "image":{let r="";typeof n.image=="string"?r=n.image:n.image instanceof URL?r=n.image.toString():n.image instanceof Uint8Array&&(r=M(n.image,n.mime)),t.push(`<image mime="${n.mime??"image/png"}">
4
- ${r}
5
- </image>`);break}case "file":{let r="";typeof n.data=="string"?r=n.data:n.data instanceof URL?r=n.data.toString():n.data instanceof Uint8Array&&(r=M(n.data,n.mime)),t.push(`<file mime="${n.mime??"application/octet-stream"}">
6
- ${r}
7
- </file>`);break}case "command":t.push(n.arguments?`/${n.command} ${n.arguments}`:`/${n.command}`);break}return t.join(`
8
- `)}var oe=5*1024*1024;function Q(i,e){let t=e?.maxInlineSize??oe,n=e?.capabilities,r=[];e?.system&&r.push({type:"text",text:`<system-reminder>
9
- ${e.system}
10
- </system-reminder>`});for(let s of i??[])switch(s.type){case "text":s.text&&r.push({type:"text",text:s.text});break;case "image":{if(n&&n.image!==true){r.push({type:"text",text:W("image",s.mime??"image/png")});break}let a=V(s.image,s.mime);a&&r.push(a);break}case "file":{let a=s.mime??"application/octet-stream";if(a.startsWith("audio/")&&n&&n.audio!==true){r.push({type:"text",text:W("audio",a)});break}if(a.startsWith("image/")&&n&&n.image!==true){r.push({type:"text",text:W("image",a)});break}let o=ue(s.data,s.mime,t,n);o&&r.push(o);break}case "memory":break;case "command":if(s.command){let a=s.arguments?`/${s.command} ${s.arguments}`:`/${s.command}`;r.push({type:"text",text:a});}break}return r}function W(i,e){return `<unsupported-media kind="${i}" mime="${e}" /> (note: agent did not declare ${i} prompt capability, attachment dropped at protocol layer)`}function V(i,e,t){let n=e??"image/png";if(i instanceof Uint8Array)return {type:"image",mimeType:n,data:M(i)};let r=i instanceof URL?i.toString():i,s=r.match(/^data:([^;,]+)?(;base64)?,(.*)$/s);if(s){let a=s[1]??n,o=!!s[2],f=s[3]??"",h=o?f:Buffer.from(decodeURIComponent(f)).toString("base64");return {type:"image",mimeType:a,data:h}}return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("file://")?{type:"image",mimeType:n,data:"",uri:r}:{type:"image",mimeType:n,data:r}}function ue(i,e,t,n){let r=e??"application/octet-stream";if(r.startsWith("audio/")){if(n&&n.audio!==true)return null;if(i instanceof Uint8Array)return {type:"audio",mimeType:r,data:M(i)};let o=i instanceof URL?i.toString():i,f=o.match(/^data:[^;,]+(;base64)?,(.*)$/s);return f?.[1]?{type:"audio",mimeType:r,data:f[2]??""}:{type:"resource_link",uri:o,name:"audio",mimeType:r}}if(r.startsWith("image/"))return n&&n.image!==true?null:V(i,r);if(typeof i=="string"||i instanceof URL){let o=i instanceof URL?i.toString():i,f=o.match(/^data:([^;,]+)?(;base64)?,(.*)$/s);if(f){let h=f[1]??r,b=!!f[2],w=Z(h),g=f[3]??"",d=b?Math.floor(g.length*3/4):g.length;if(d>t)return {type:"resource_link",uri:"",name:"large-inline-file",mimeType:h,size:d};let P=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,S=`urn:easbot:inline:${P}`;if(n&&n.embeddedContext!==true)return {type:"resource_link",uri:S,name:P,mimeType:h};if(w){let x=b?Buffer.from(g,"base64").toString("utf-8"):decodeURIComponent(g);return {type:"resource",resource:{uri:S,text:x,mimeType:h}}}return {type:"resource",resource:{uri:S,blob:b?g:Buffer.from(g).toString("base64"),mimeType:h}}}return o.startsWith("http://")||o.startsWith("https://")||o.startsWith("file://")?{type:"resource_link",uri:o,name:le(o),mimeType:r}:null}if(i.length>t)return {type:"resource_link",uri:"",name:"large-inline-file",mimeType:r,size:i.length};if(n&&n.embeddedContext!==true)return {type:"resource_link",uri:"",name:"inline-file",mimeType:r,size:i.length};let a=`urn:easbot:inline:${`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}`;return Z(r)?{type:"resource",resource:{uri:a,text:Buffer.from(i).toString("utf-8"),mimeType:r}}:{type:"resource",resource:{uri:a,blob:M(i),mimeType:r}}}function Z(i){return !!(i.startsWith("text/")||i==="application/json"||i==="application/json5"||i==="application/jsonc"||i==="application/xml"||i==="application/javascript"||i==="application/typescript"||i==="application/yaml"||i==="application/x-yaml"||i==="application/toml")}function le(i){try{return new URL(i).pathname.split("/").pop()||"file"}catch{return "file"}}var u=utils.Log.create({service:"llm.subagent.acp"}),U=class{constructor(e){chunk2XQWKCQ4_cjs.a(this,"subscriber",null);chunk2XQWKCQ4_cjs.a(this,"config");chunk2XQWKCQ4_cjs.a(this,"sessionId",null);chunk2XQWKCQ4_cjs.a(this,"_isRunning",false);chunk2XQWKCQ4_cjs.a(this,"abortExecute",null);this.config=e;}async start(){if(this.subscriber&&this._isRunning){u.debug("ACPAgentHandler.start: already connected, reusing",{name:this.config.name});return}let e=this.config.transport==="websocket"?"websocket":this.config.transport==="http"?"http":"stdio",t=this.config.uri??this.buildUrl(this.config);u.debug("ACPAgentHandler.start",{type:e,url:t,cwd:this.config.cwd??utils.Instance.directory??process.cwd(),name:this.config.name});try{let n=await utils.ACPClientConnection.connect({config:{type:e,url:t,cwd:this.config.cwd??utils.Instance.directory??process.cwd(),timeout:this.config.timeout,env:this.config.env}});this.subscriber=n.subscriber,this.sessionId=n.sessionId,this._isRunning=!0,u.info("ACPAgentHandler started",{name:this.config.name,type:e,url:t});}catch(n){throw u.error("ACPAgentHandler.start failed",{name:this.config.name,error:utils.errorMeta(n)}),n}}async stop(){u.debug("ACPAgentHandler.stop",{sessionId:this.sessionId,name:this.config?.name});let e=this.abortExecute;if(this.abortExecute=null,e)try{e();}catch(r){u.warn("ACPAgentHandler.stop: abort execute failed",{error:utils.errorMeta(r)});}let t=this.subscriber,n=this.sessionId;if(this.subscriber=null,this.sessionId=null,this._isRunning=false,!!t){if(n)try{await utils.ACPClientConnection.releaseSubscription(t,n);}catch(r){u.warn("Error releasing subscription",{error:utils.errorMeta(r)});}try{await t.disconnect(),u.debug("ACPAgentHandler disconnected",{name:this.config?.name});}catch(r){u.warn("Error disconnecting ACP subscriber",{error:utils.errorMeta(r)});}}}async execute(e,t){if(!this.subscriber||!this._isRunning)throw new utils.NameErrors.OperationFailedError({message:"ACP agent not running",operation:"acp-agent-not-running"});u.debug("ACPAgentHandler.execute",{title:e.title,agent:e.agent,partsCount:e.parts?.length??1});let n=this.config?.timeout??1800*1e3,r=this.subscriber.client,s=t?.onMessage,a=await new Promise((o,f)=>{let h="",b,w,g=0,d=false,P=false,S=null,x=null,j=()=>{R("error",new utils.NameErrors.OperationFailedError({message:"ACP agent stopped",operation:"acp-agent-stopped"}));};this.abortExecute=j;let R=(p,C)=>{if(!P){if(P=true,clearTimeout(ie),this.abortExecute===j&&(this.abortExecute=null),S){try{S();}catch(v){u.warn("ACPAgentHandler: unsubscribeStatus failed",{error:utils.errorMeta(v)});}S=null;}if(x){try{x();}catch(v){u.warn("ACPAgentHandler: unsubscribeSession failed",{error:utils.errorMeta(v)});}x=null;}if(C){u.error("ACPAgentHandler.execute failed",{reason:p,error:utils.errorMeta(C)}),f(C);return}u.debug("ACPAgentHandler.execute completed",{reason:p,messageCount:g,lastMessageId:b,lastTextLength:h.length}),o({title:e.title,output:h,metadata:{sessionId:this.sessionId??void 0,agent:e.agent,messageId:b,tokens:w,finishReason:p,messageCount:g}});}},O=(p,C)=>{u.debug("ACPAgentHandler: remote session status update",{source:C,to:p,promptSent:d,messageCount:g}),p==="idle"&&d?R("idle"):p==="error"&&d&&R("error",new Error("Remote session status: error"));},ie=setTimeout(()=>{u.warn("ACPAgentHandler.execute timeout, forcing resolve",{timeout:n,messageCount:g,promptSent:d}),R("timeout");},n);(async()=>{try{let p=this.sessionId;if(!p)throw new utils.NameErrors.OperationFailedError({message:"No session available. Call start() first.",operation:"acp-no-session"});u.debug("ACPAgentHandler: using existing session",{sessionId:p}),typeof r.onSessionStatus=="function"&&(S=r.onSessionStatus(c=>{O(c,"onSessionStatus");})),x=r.subscribeSessionEvents(p,{onMessage:c=>{if(g++,!c.text||c.text.trim().length===0){u.debug("ACPAgentHandler: skipping onMessage for empty-text message",{messageId:c.metadata.messageId,hasThinking:!!c.thinking,hasTools:(c.tools?.length??0)>0});return}b=c.metadata.messageId,c.metadata.tokens&&(w=c.metadata.tokens),c.metadata.sessionStatus&&O(c.metadata.sessionStatus,"onMessage.metadata"),c.text!==void 0&&(h=c.text),u.debug("ACPAgentHandler: message received",{messageId:b,messageCount:g,textLength:c.text?.length??0}),s&&Promise.resolve().then(()=>s(c)).catch(E=>{u.error("ACPAgentHandler.execute: onMessage callback error",{messageId:c.metadata.messageId,error:utils.errorMeta(E)});});},onError:c=>{if(c.message?.includes("NotFoundError")){u.debug("ACPAgentHandler: ignored NotFoundError",{sessionId:p});return}u.error("ACPAgentHandler: subscription error",{error:utils.errorMeta(c)});},onSessionUpdate:c=>{if(c.type==="session_status_update"){let E=c.properties.status,ae=typeof E=="string"?E:E?.type??"idle";O(ae,"onSessionUpdate");}}},{includeThinking:!1,includeToolDetails:!1,includeToolOutput:!1});let C=Q(e.parts,{system:e.system,capabilities:r.getPromptCapabilities?.()??void 0}),v=this.config.agentConfig?.agent,q=this.config.agentConfig?.model,$={};v&&($.agent=v),q&&($.model=q),await r.prompt({sessionId:p,prompt:C,...Object.keys($).length>0?{_meta:$}:{}}),d=!0,u.debug("ACPAgentHandler.execute prompt sent",{title:e.title,sessionId:p});}catch(p){R("error",p instanceof Error?p:new Error(utils.errorMeta(p).message));}})();});return u.debug("ACPAgentHandler.execute completed",{title:e.title,textLength:a.output.length,messageCount:a.metadata.messageCount,finishReason:a.metadata.finishReason}),a}async interrupt(){this.subscriber?.client&&this.sessionId&&(u.debug("ACPAgentHandler.interrupt",{sessionId:this.sessionId}),await utils.ACPClientConnection.interrupt(this.subscriber,this.sessionId));}isRunning(){return this._isRunning}async checkHealth(){if(!this._isRunning||!this.subscriber)return false;try{if(this.sessionId){let t=(await this.subscriber.client.listSessions({cwd:this.config?.cwd??process.cwd()}))?.sessions;return !t||!Array.isArray(t)?!1:t.some(n=>n.sessionId===this.sessionId)}return !0}catch(e){return u.errorDegradable("ACPAgentHandler.checkHealth failed",{error:utils.errorMeta(e)}),false}}buildUrl(e){if(e.uri)return e.uri;let t=e.command??"easbot",n=e.args??["acp","--channel","stdio"];return `${t} ${n.join(" ")}`}};var _=utils.Log.create({service:"llm.subagent.cli"}),te=2*1024*1024,L=class{constructor(e){chunk2XQWKCQ4_cjs.a(this,"process",null);chunk2XQWKCQ4_cjs.a(this,"config");chunk2XQWKCQ4_cjs.a(this,"_isRunning",false);chunk2XQWKCQ4_cjs.a(this,"abortController",null);this.config=e;}async start(){this._isRunning=true,_.debug("CLIAgentHandler.start",{command:this.config.command});}async stop(){this.abortController&&this.abortController.abort(),this._isRunning=false;}async execute(e,t){if(!this.config.command)throw new utils.NameErrors.OperationFailedError({message:"CLI command not configured",operation:"cli-not-configured"});_.debug("CLIAgentHandler.execute",{title:e.title,command:this.config.command});let n=this.buildArgs(e),r=this.config.cwd,a={...await utils.Env.all(),...this.config.env},o=this.config.timeout??3e5,f={...process.env,...a};this.abortController=new AbortController,this._isRunning=true;let h=[this.config.command,...n];this.process=utils.PKG.spawn(h,{cwd:r,env:f,stdout:"pipe",stderr:"pipe",stdin:"null",timeout:o,signal:this.abortController.signal,windowsHide:true});let b="",w="",g=false;this.process.stdout?.on("data",d=>{if(b.length>=te){g=true;return}b+=d.toString("utf-8");}),this.process.stderr?.on("data",d=>{if(w.length>=te){g=true;return}w+=d.toString("utf-8");});try{let d=await this.process.exited;if(d===0)return {title:e.title,output:b.trim(),metadata:{command:this.config.command,args:n,exitCode:d,truncated:g}};throw _.error("CLI exited with error",{code:d}),new utils.NameErrors.OperationFailedError({message:`CLI exited with code ${d}: ${w.trim().slice(0,500)}`,operation:"cli-exit"})}catch(d){throw _.error("CLI process error",{error:utils.errorMeta(d)}),d}finally{this.process=null,this._isRunning=false;}}async interrupt(){this.abortController&&this.abortController.abort();}isRunning(){return this._isRunning}async checkHealth(){return this._isRunning?this.process!==null||this._isRunning:false}buildArgs(e){let t=[...this.config?.args??[]],n=J(e.parts)||e.title;return t.push("--prompt",n),t}};var m=utils.Log.create({service:"llm.subagent.registry"}),B=class{constructor(e){chunk2XQWKCQ4_cjs.a(this,"instances",new Map);chunk2XQWKCQ4_cjs.a(this,"handlers",new Map);chunk2XQWKCQ4_cjs.a(this,"config");chunk2XQWKCQ4_cjs.a(this,"agentCounts",new Map);chunk2XQWKCQ4_cjs.a(this,"idleCleanupTimer",null);chunk2XQWKCQ4_cjs.a(this,"worktreeBindings",new Map);this.config=e,this.startIdleCleanup();}startIdleCleanup(){if(this.idleCleanupTimer)return;let e=this.config.idleCheckInterval??300*1e3,t=this.config.idleTimeout??1800*1e3;this.idleCleanupTimer=setInterval(()=>{this.cleanupIdleInstances(t);},e),m.debug("Idle cleanup timer started",{interval:e,timeout:t});}stopIdleCleanup(){this.idleCleanupTimer&&(clearInterval(this.idleCleanupTimer),this.idleCleanupTimer=null,m.debug("Idle cleanup timer stopped"));}async cleanupIdleInstances(e){let t=Date.now(),n=[];for(let[r,s]of this.instances){if(s.config.runMode!=="persistent"||s.status!=="idle"&&s.status!=="error")continue;t-s.lastActiveAt>e&&n.push(r);}if(n.length>0){m.debug("Cleaning up idle instances",{count:n.length,maxIdleTime:e});for(let r of n)try{await this.terminate(r);}catch(s){m.warn("Failed to cleanup idle instance",{id:r,error:utils.errorMeta(s)});}}}async checkInstanceHealth(e){let t=this.handlers.get(e.id);if(!t)return false;try{return "checkHealth"in t&&typeof t.checkHealth=="function"?await t.checkHealth():t.isRunning()}catch{return false}}async spawn(e){let t=utils.Identifier.ascending("subagent"),n=e;if(e.transport==="stdio"&&chunkGHMRMPMO_cjs.a.EASBOT_ENABLE_WORKTREE){let a=await this.assignWorktreeForInstance(t);a&&(n={...e,cwd:a.worktreePath},m.debug("Agent spawned with worktree",{id:t,name:e.name,worktreePath:a.worktreePath}));}let r={id:t,config:n,status:"starting",createdAt:Date.now(),lastActiveAt:Date.now()},s=this.createHandler(n);this.handlers.set(t,s),this.instances.set(t,r);try{return await s.start(n),r.status="idle",this.agentCounts.set(e.name,(this.agentCounts.get(e.name)??0)+1),m.debug("Agent spawned",{id:t,name:e.name,status:r.status}),r}catch(a){r.status="error",r.error=String(a),this.handlers.delete(t),this.instances.delete(t);let o=this.worktreeBindings.get(t);throw o&&(await this.releaseWorktreeForInstance(o.agentId),this.worktreeBindings.delete(t)),m.error("Failed to spawn agent, cleaned up",{id:t,name:e.name,error:utils.errorMeta(a)}),a}}async assignWorktreeForInstance(e){let t=`subagent-${e}`;try{let{MultiAgentWorktree:n}=await import('@easbot/utils'),r=await n.assign({agentId:t,ephemeral:!0}),s={agentId:t,worktreePath:r.directory};return this.worktreeBindings.set(e,s),s}catch(n){return m.warn("worktree assign failed, spawn will use main checkout",{instanceId:e,error:utils.errorMeta(n)}),null}}async releaseWorktreeForInstance(e){try{let{MultiAgentWorktree:t}=await import('@easbot/utils');await t.release({agentId:e});}catch(t){m.warn("worktree release failed (will be reaped by sweep)",{agentId:e,error:utils.errorMeta(t)});}}createHandler(e){switch(e.transport){case "stdio":case "http":case "websocket":return new U(e);case "cli":return new L(e);default:throw new utils.NameErrors.InvalidArgumentError({message:`Unknown transport type: ${e.transport}`,param:"transport"})}}async acquire(e){let t=await this.findIdleInstance(e.name);if(!t){let r=this.agentCounts.get(e.name)??0,s=e.maxConcurrent??this.config.maxConcurrent;r<s?t=await this.spawn(e):(m.debug("Max concurrent reached, waiting for idle instance",{name:e.name,currentCount:r,maxConcurrent:s}),t=await this.waitForIdleInstance(e.name));}t.status="running",t.lastActiveAt=Date.now();let n=this.handlers.get(t.id);if(!n)throw new utils.NameErrors.NotFoundError({message:`Handler not found for instance: ${t.id}`,location:t.id});return {instance:t,execute:async(r,s)=>{t.status="busy";try{let a=await n.execute(r,s);return t.status="idle",t.lastActiveAt=Date.now(),a}catch(a){throw t.status="error",a}},interrupt:()=>n.interrupt()}}async release(e,t){t==="ephemeral"?await this.terminate(e.id):(e.status="idle",m.debug("Agent released to pool",{id:e.id,name:e.config.name}));}async terminate(e){let t=this.handlers.get(e),n=this.instances.get(e);if(this.handlers.delete(e),t)try{await t.stop();}catch(s){m.warn("Error stopping agent",{id:e,error:utils.errorMeta(s)});}let r=this.worktreeBindings.get(e);if(r&&(await this.releaseWorktreeForInstance(r.agentId),this.worktreeBindings.delete(e)),n){let s=this.agentCounts.get(n.config.name)??0;s>0&&this.agentCounts.set(n.config.name,s-1),n.status="stopped",this.instances.delete(e);}m.debug("Agent terminated",{id:e});}async interrupt(e){let t=this.handlers.get(e);if(t)try{await t.interrupt(),m.debug("Agent interrupted",{id:e});}catch(n){m.warn("Error interrupting agent",{id:e,error:utils.errorMeta(n)});}}async shutdownAll(){this.stopIdleCleanup();let e=Array.from(this.instances.keys());await Promise.all(e.map(t=>this.terminate(t))),m.debug("All agents shut down",{count:e.length});}listWorktreeBindings(){return Array.from(this.worktreeBindings.entries()).map(([e,t])=>({instanceId:e,agentId:t.agentId,worktreePath:t.worktreePath}))}list(){return Array.from(this.instances.values())}get(e){return this.instances.get(e)}async findIdleInstance(e){let t=[];for(let[n,r]of this.instances){if(r.config.name!==e||r.status!=="idle")continue;if(!await this.checkInstanceHealth(r)){m.warn("Found unhealthy idle instance, marking for cleanup",{id:n,name:e,lastActiveAt:r.lastActiveAt}),t.push(n);continue}return r}for(let n of t)try{await this.terminate(n);}catch(r){m.warn("Failed to terminate unhealthy instance",{id:n,error:utils.errorMeta(r)});}}async waitForIdleInstance(e,t=6e4){let n=Date.now();for(;Date.now()-n<t;){let r=await this.findIdleInstance(e);if(r)return r;await new Promise(s=>setTimeout(s,1e3));}throw new utils.NameErrors.TimeoutError({message:`Timeout waiting for idle ${e} agent`,timeoutMs:3e4})}};var k=utils.NamedError.create("SubAgentError",H__default.default.object({message:H__default.default.string(),code:H__default.default.string(),agent:H__default.default.string().optional(),transport:H__default.default.string().optional()}));function Ae(i){let e=i;return {source:e.source??e.sessionId??"gateway",title:e.title??"SubAgent task",agent:e.agent??"gateway",parts:e.parts??[],system:e.system,config:e.config}}function ne(i){return i?.enabled===true}var y=class y{constructor(e){chunk2XQWKCQ4_cjs.a(this,"log");chunk2XQWKCQ4_cjs.a(this,"registry",null);chunk2XQWKCQ4_cjs.a(this,"registryConfig",null);chunk2XQWKCQ4_cjs.a(this,"initError",null);this.log=utils.Log.create({service:"llm.agent.sub-agent"}),this.registryConfig=e;}ensureRegistry(){if(!this.registry&&this.registryConfig)try{this.registry=new B(this.registryConfig);}catch(e){throw this.initError=e,new k({message:`Failed to initialize SubAgentRegistry: ${utils.errorMeta(e).message}`,code:"init-failed"},{cause:e})}if(!this.registry)throw new k({message:"SubAgent registry not initialized (config missing or invalid)",code:"registry-uninit"});return this.registry}resolveAgentConfig(e){if(!this.registryConfig||!ne(this.registryConfig))throw new k({message:"SubAgent system is disabled",code:"disabled"});let t=this.registryConfig.agents.find(r=>r.name===e.agent);if(!t)throw new k({message:`Unknown agent: ${e.agent}`,code:"unknown-agent",agent:e.agent});let n=t.transport;if(n!=="stdio"&&n!=="http"&&n!=="websocket")throw new k({message:`SubAgent.run only supports ACP transport (stdio/http/websocket); got '${n}' for agent '${e.agent}'. Use SubAgentRegistry directly for CLI/Remote transports.`,code:"unsupported-transport",agent:e.agent,transport:n});return {...t,...e.config??{}}}async run(e,t){var f=[];try{let n=chunk2XQWKCQ4_cjs.g(f,this.log.time("llm.agent.subagent.run",{level:"DEBUG"}));let r=Ae(e);let s=this.ensureRegistry();let a=this.resolveAgentConfig(r);this.log.debug("SubAgent.run started",{title:r.title,agent:r.agent,runMode:a.runMode,transport:a.transport,hasOnMessage:!!t?.onMessage});let o=await s.acquire(a);try{return await o.execute(r,t)}catch(g){if(this.log.error("SubAgent.run failed",{title:r.title,agent:r.agent,runMode:a.runMode,error:utils.errorMeta(g)}),a.runMode==="persistent"){this.log.warn("Persistent agent failed, terminating instance",{id:o.instance.id,name:r.agent});try{await s.terminate(o.instance.id);}catch(d){this.log.warn("Failed to terminate persistent agent",{id:o.instance.id,error:utils.errorMeta(d)});}}throw g}finally{if(a.runMode==="ephemeral")try{await s.release(o.instance,"ephemeral");}catch(g){this.log.warn("Failed to release ephemeral agent",{id:o.instance.id,error:utils.errorMeta(g)});}}}catch(h){var b=h,w=true;}finally{chunk2XQWKCQ4_cjs.h(f,b,w);}}async shutdown(){this.registry&&await this.registry.shutdownAll();}isEnabled(){return ne(this.registryConfig)&&this.initError===null}static getDefault(){return y._default}static setDefault(e){return y._default&&y._default.shutdown().catch(()=>{}),y._default=new y(e),y._default}static async run(e){let t=y.getDefault();if(!t)throw new k({message:"SubAgent.run called but no default instance set; call SubAgent.setDefault(config) first",code:"registry-uninit"});return t.run(e)}static clearDefault(){y._default&&(y._default.shutdown().catch(()=>{}),y._default=null);}};chunk2XQWKCQ4_cjs.a(y,"_default",null);var re=y;
11
- exports.a=Q;exports.b=k;exports.c=re;
@@ -1,11 +0,0 @@
1
- import {a as a$1}from'./chunk-NX2YVB72.mjs';import {a,g,h}from'./chunk-QMTIXJ7U.mjs';import {Log,NamedError,errorMeta,Identifier,NameErrors,Env,PKG,Instance,ACPClientConnection}from'@easbot/utils';import $ from'zod';function M(i,e){let t;if(typeof Buffer<"u")t=Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString("base64");else {let r="";for(let a=0;a<i.length;a+=32768){let o=i.subarray(a,Math.min(a+32768,i.length));r+=String.fromCharCode.apply(null,o);}t=btoa(r);}return `data:${e??"application/octet-stream"};base64,${t}`}function Q(i,e){let t=[];if(i)for(let n of i)switch(n.type){case "text":n.text&&t.push(`<text>
2
- ${n.text}
3
- </text>`);break;case "image":{let r="";typeof n.image=="string"?r=n.image:n.image instanceof URL?r=n.image.toString():n.image instanceof Uint8Array&&(r=M(n.image,n.mime)),t.push(`<image mime="${n.mime??"image/png"}">
4
- ${r}
5
- </image>`);break}case "file":{let r="";typeof n.data=="string"?r=n.data:n.data instanceof URL?r=n.data.toString():n.data instanceof Uint8Array&&(r=M(n.data,n.mime)),t.push(`<file mime="${n.mime??"application/octet-stream"}">
6
- ${r}
7
- </file>`);break}case "command":t.push(n.arguments?`/${n.command} ${n.arguments}`:`/${n.command}`);break}return t.join(`
8
- `)}var ue=5*1024*1024;function V(i,e){let t=e?.maxInlineSize??ue,n=e?.capabilities,r=[];e?.system&&r.push({type:"text",text:`<system-reminder>
9
- ${e.system}
10
- </system-reminder>`});for(let s of i??[])switch(s.type){case "text":s.text&&r.push({type:"text",text:s.text});break;case "image":{if(n&&n.image!==true){r.push({type:"text",text:D("image",s.mime??"image/png")});break}let a=Y(s.image,s.mime);a&&r.push(a);break}case "file":{let a=s.mime??"application/octet-stream";if(a.startsWith("audio/")&&n&&n.audio!==true){r.push({type:"text",text:D("audio",a)});break}if(a.startsWith("image/")&&n&&n.image!==true){r.push({type:"text",text:D("image",a)});break}let o=le(s.data,s.mime,t,n);o&&r.push(o);break}case "memory":break;case "command":if(s.command){let a=s.arguments?`/${s.command} ${s.arguments}`:`/${s.command}`;r.push({type:"text",text:a});}break}return r}function D(i,e){return `<unsupported-media kind="${i}" mime="${e}" /> (note: agent did not declare ${i} prompt capability, attachment dropped at protocol layer)`}function Y(i,e,t){let n=e??"image/png";if(i instanceof Uint8Array)return {type:"image",mimeType:n,data:M(i)};let r=i instanceof URL?i.toString():i,s=r.match(/^data:([^;,]+)?(;base64)?,(.*)$/s);if(s){let a=s[1]??n,o=!!s[2],f=s[3]??"",h=o?f:Buffer.from(decodeURIComponent(f)).toString("base64");return {type:"image",mimeType:a,data:h}}return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("file://")?{type:"image",mimeType:n,data:"",uri:r}:{type:"image",mimeType:n,data:r}}function le(i,e,t,n){let r=e??"application/octet-stream";if(r.startsWith("audio/")){if(n&&n.audio!==true)return null;if(i instanceof Uint8Array)return {type:"audio",mimeType:r,data:M(i)};let o=i instanceof URL?i.toString():i,f=o.match(/^data:[^;,]+(;base64)?,(.*)$/s);return f?.[1]?{type:"audio",mimeType:r,data:f[2]??""}:{type:"resource_link",uri:o,name:"audio",mimeType:r}}if(r.startsWith("image/"))return n&&n.image!==true?null:Y(i,r);if(typeof i=="string"||i instanceof URL){let o=i instanceof URL?i.toString():i,f=o.match(/^data:([^;,]+)?(;base64)?,(.*)$/s);if(f){let h=f[1]??r,b=!!f[2],w=J(h),g=f[3]??"",d=b?Math.floor(g.length*3/4):g.length;if(d>t)return {type:"resource_link",uri:"",name:"large-inline-file",mimeType:h,size:d};let P=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,S=`urn:easbot:inline:${P}`;if(n&&n.embeddedContext!==true)return {type:"resource_link",uri:S,name:P,mimeType:h};if(w){let x=b?Buffer.from(g,"base64").toString("utf-8"):decodeURIComponent(g);return {type:"resource",resource:{uri:S,text:x,mimeType:h}}}return {type:"resource",resource:{uri:S,blob:b?g:Buffer.from(g).toString("base64"),mimeType:h}}}return o.startsWith("http://")||o.startsWith("https://")||o.startsWith("file://")?{type:"resource_link",uri:o,name:ce(o),mimeType:r}:null}if(i.length>t)return {type:"resource_link",uri:"",name:"large-inline-file",mimeType:r,size:i.length};if(n&&n.embeddedContext!==true)return {type:"resource_link",uri:"",name:"inline-file",mimeType:r,size:i.length};let a=`urn:easbot:inline:${`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}`;return J(r)?{type:"resource",resource:{uri:a,text:Buffer.from(i).toString("utf-8"),mimeType:r}}:{type:"resource",resource:{uri:a,blob:M(i),mimeType:r}}}function J(i){return !!(i.startsWith("text/")||i==="application/json"||i==="application/json5"||i==="application/jsonc"||i==="application/xml"||i==="application/javascript"||i==="application/typescript"||i==="application/yaml"||i==="application/x-yaml"||i==="application/toml")}function ce(i){try{return new URL(i).pathname.split("/").pop()||"file"}catch{return "file"}}var u=Log.create({service:"llm.subagent.acp"}),_=class{constructor(e){a(this,"subscriber",null);a(this,"config");a(this,"sessionId",null);a(this,"_isRunning",false);a(this,"abortExecute",null);this.config=e;}async start(){if(this.subscriber&&this._isRunning){u.debug("ACPAgentHandler.start: already connected, reusing",{name:this.config.name});return}let e=this.config.transport==="websocket"?"websocket":this.config.transport==="http"?"http":"stdio",t=this.config.uri??this.buildUrl(this.config);u.debug("ACPAgentHandler.start",{type:e,url:t,cwd:this.config.cwd??Instance.directory??process.cwd(),name:this.config.name});try{let n=await ACPClientConnection.connect({config:{type:e,url:t,cwd:this.config.cwd??Instance.directory??process.cwd(),timeout:this.config.timeout,env:this.config.env}});this.subscriber=n.subscriber,this.sessionId=n.sessionId,this._isRunning=!0,u.info("ACPAgentHandler started",{name:this.config.name,type:e,url:t});}catch(n){throw u.error("ACPAgentHandler.start failed",{name:this.config.name,error:errorMeta(n)}),n}}async stop(){u.debug("ACPAgentHandler.stop",{sessionId:this.sessionId,name:this.config?.name});let e=this.abortExecute;if(this.abortExecute=null,e)try{e();}catch(r){u.warn("ACPAgentHandler.stop: abort execute failed",{error:errorMeta(r)});}let t=this.subscriber,n=this.sessionId;if(this.subscriber=null,this.sessionId=null,this._isRunning=false,!!t){if(n)try{await ACPClientConnection.releaseSubscription(t,n);}catch(r){u.warn("Error releasing subscription",{error:errorMeta(r)});}try{await t.disconnect(),u.debug("ACPAgentHandler disconnected",{name:this.config?.name});}catch(r){u.warn("Error disconnecting ACP subscriber",{error:errorMeta(r)});}}}async execute(e,t){if(!this.subscriber||!this._isRunning)throw new NameErrors.OperationFailedError({message:"ACP agent not running",operation:"acp-agent-not-running"});u.debug("ACPAgentHandler.execute",{title:e.title,agent:e.agent,partsCount:e.parts?.length??1});let n=this.config?.timeout??1800*1e3,r=this.subscriber.client,s=t?.onMessage,a=await new Promise((o,f)=>{let h="",b,w,g=0,d=false,P=false,S=null,x=null,q=()=>{R("error",new NameErrors.OperationFailedError({message:"ACP agent stopped",operation:"acp-agent-stopped"}));};this.abortExecute=q;let R=(p,C)=>{if(!P){if(P=true,clearTimeout(se),this.abortExecute===q&&(this.abortExecute=null),S){try{S();}catch(v){u.warn("ACPAgentHandler: unsubscribeStatus failed",{error:errorMeta(v)});}S=null;}if(x){try{x();}catch(v){u.warn("ACPAgentHandler: unsubscribeSession failed",{error:errorMeta(v)});}x=null;}if(C){u.error("ACPAgentHandler.execute failed",{reason:p,error:errorMeta(C)}),f(C);return}u.debug("ACPAgentHandler.execute completed",{reason:p,messageCount:g,lastMessageId:b,lastTextLength:h.length}),o({title:e.title,output:h,metadata:{sessionId:this.sessionId??void 0,agent:e.agent,messageId:b,tokens:w,finishReason:p,messageCount:g}});}},W=(p,C)=>{u.debug("ACPAgentHandler: remote session status update",{source:C,to:p,promptSent:d,messageCount:g}),p==="idle"&&d?R("idle"):p==="error"&&d&&R("error",new Error("Remote session status: error"));},se=setTimeout(()=>{u.warn("ACPAgentHandler.execute timeout, forcing resolve",{timeout:n,messageCount:g,promptSent:d}),R("timeout");},n);(async()=>{try{let p=this.sessionId;if(!p)throw new NameErrors.OperationFailedError({message:"No session available. Call start() first.",operation:"acp-no-session"});u.debug("ACPAgentHandler: using existing session",{sessionId:p}),typeof r.onSessionStatus=="function"&&(S=r.onSessionStatus(c=>{W(c,"onSessionStatus");})),x=r.subscribeSessionEvents(p,{onMessage:c=>{if(g++,!c.text||c.text.trim().length===0){u.debug("ACPAgentHandler: skipping onMessage for empty-text message",{messageId:c.metadata.messageId,hasThinking:!!c.thinking,hasTools:(c.tools?.length??0)>0});return}b=c.metadata.messageId,c.metadata.tokens&&(w=c.metadata.tokens),c.metadata.sessionStatus&&W(c.metadata.sessionStatus,"onMessage.metadata"),c.text!==void 0&&(h=c.text),u.debug("ACPAgentHandler: message received",{messageId:b,messageCount:g,textLength:c.text?.length??0}),s&&Promise.resolve().then(()=>s(c)).catch(E=>{u.error("ACPAgentHandler.execute: onMessage callback error",{messageId:c.metadata.messageId,error:errorMeta(E)});});},onError:c=>{if(c.message?.includes("NotFoundError")){u.debug("ACPAgentHandler: ignored NotFoundError",{sessionId:p});return}u.error("ACPAgentHandler: subscription error",{error:errorMeta(c)});},onSessionUpdate:c=>{if(c.type==="session_status_update"){let E=c.properties.status,oe=typeof E=="string"?E:E?.type??"idle";W(oe,"onSessionUpdate");}}},{includeThinking:!1,includeToolDetails:!1,includeToolOutput:!1});let C=V(e.parts,{system:e.system,capabilities:r.getPromptCapabilities?.()??void 0}),v=this.config.agentConfig?.agent,G=this.config.agentConfig?.model,U={};v&&(U.agent=v),G&&(U.model=G),await r.prompt({sessionId:p,prompt:C,...Object.keys(U).length>0?{_meta:U}:{}}),d=!0,u.debug("ACPAgentHandler.execute prompt sent",{title:e.title,sessionId:p});}catch(p){R("error",p instanceof Error?p:new Error(errorMeta(p).message));}})();});return u.debug("ACPAgentHandler.execute completed",{title:e.title,textLength:a.output.length,messageCount:a.metadata.messageCount,finishReason:a.metadata.finishReason}),a}async interrupt(){this.subscriber?.client&&this.sessionId&&(u.debug("ACPAgentHandler.interrupt",{sessionId:this.sessionId}),await ACPClientConnection.interrupt(this.subscriber,this.sessionId));}isRunning(){return this._isRunning}async checkHealth(){if(!this._isRunning||!this.subscriber)return false;try{if(this.sessionId){let t=(await this.subscriber.client.listSessions({cwd:this.config?.cwd??process.cwd()}))?.sessions;return !t||!Array.isArray(t)?!1:t.some(n=>n.sessionId===this.sessionId)}return !0}catch(e){return u.errorDegradable("ACPAgentHandler.checkHealth failed",{error:errorMeta(e)}),false}}buildUrl(e){if(e.uri)return e.uri;let t=e.command??"easbot",n=e.args??["acp","--channel","stdio"];return `${t} ${n.join(" ")}`}};var L=Log.create({service:"llm.subagent.cli"}),ne=2*1024*1024,B=class{constructor(e){a(this,"process",null);a(this,"config");a(this,"_isRunning",false);a(this,"abortController",null);this.config=e;}async start(){this._isRunning=true,L.debug("CLIAgentHandler.start",{command:this.config.command});}async stop(){this.abortController&&this.abortController.abort(),this._isRunning=false;}async execute(e,t){if(!this.config.command)throw new NameErrors.OperationFailedError({message:"CLI command not configured",operation:"cli-not-configured"});L.debug("CLIAgentHandler.execute",{title:e.title,command:this.config.command});let n=this.buildArgs(e),r=this.config.cwd,a={...await Env.all(),...this.config.env},o=this.config.timeout??3e5,f={...process.env,...a};this.abortController=new AbortController,this._isRunning=true;let h=[this.config.command,...n];this.process=PKG.spawn(h,{cwd:r,env:f,stdout:"pipe",stderr:"pipe",stdin:"null",timeout:o,signal:this.abortController.signal,windowsHide:true});let b="",w="",g=false;this.process.stdout?.on("data",d=>{if(b.length>=ne){g=true;return}b+=d.toString("utf-8");}),this.process.stderr?.on("data",d=>{if(w.length>=ne){g=true;return}w+=d.toString("utf-8");});try{let d=await this.process.exited;if(d===0)return {title:e.title,output:b.trim(),metadata:{command:this.config.command,args:n,exitCode:d,truncated:g}};throw L.error("CLI exited with error",{code:d}),new NameErrors.OperationFailedError({message:`CLI exited with code ${d}: ${w.trim().slice(0,500)}`,operation:"cli-exit"})}catch(d){throw L.error("CLI process error",{error:errorMeta(d)}),d}finally{this.process=null,this._isRunning=false;}}async interrupt(){this.abortController&&this.abortController.abort();}isRunning(){return this._isRunning}async checkHealth(){return this._isRunning?this.process!==null||this._isRunning:false}buildArgs(e){let t=[...this.config?.args??[]],n=Q(e.parts)||e.title;return t.push("--prompt",n),t}};var m=Log.create({service:"llm.subagent.registry"}),F=class{constructor(e){a(this,"instances",new Map);a(this,"handlers",new Map);a(this,"config");a(this,"agentCounts",new Map);a(this,"idleCleanupTimer",null);a(this,"worktreeBindings",new Map);this.config=e,this.startIdleCleanup();}startIdleCleanup(){if(this.idleCleanupTimer)return;let e=this.config.idleCheckInterval??300*1e3,t=this.config.idleTimeout??1800*1e3;this.idleCleanupTimer=setInterval(()=>{this.cleanupIdleInstances(t);},e),m.debug("Idle cleanup timer started",{interval:e,timeout:t});}stopIdleCleanup(){this.idleCleanupTimer&&(clearInterval(this.idleCleanupTimer),this.idleCleanupTimer=null,m.debug("Idle cleanup timer stopped"));}async cleanupIdleInstances(e){let t=Date.now(),n=[];for(let[r,s]of this.instances){if(s.config.runMode!=="persistent"||s.status!=="idle"&&s.status!=="error")continue;t-s.lastActiveAt>e&&n.push(r);}if(n.length>0){m.debug("Cleaning up idle instances",{count:n.length,maxIdleTime:e});for(let r of n)try{await this.terminate(r);}catch(s){m.warn("Failed to cleanup idle instance",{id:r,error:errorMeta(s)});}}}async checkInstanceHealth(e){let t=this.handlers.get(e.id);if(!t)return false;try{return "checkHealth"in t&&typeof t.checkHealth=="function"?await t.checkHealth():t.isRunning()}catch{return false}}async spawn(e){let t=Identifier.ascending("subagent"),n=e;if(e.transport==="stdio"&&a$1.EASBOT_ENABLE_WORKTREE){let a=await this.assignWorktreeForInstance(t);a&&(n={...e,cwd:a.worktreePath},m.debug("Agent spawned with worktree",{id:t,name:e.name,worktreePath:a.worktreePath}));}let r={id:t,config:n,status:"starting",createdAt:Date.now(),lastActiveAt:Date.now()},s=this.createHandler(n);this.handlers.set(t,s),this.instances.set(t,r);try{return await s.start(n),r.status="idle",this.agentCounts.set(e.name,(this.agentCounts.get(e.name)??0)+1),m.debug("Agent spawned",{id:t,name:e.name,status:r.status}),r}catch(a){r.status="error",r.error=String(a),this.handlers.delete(t),this.instances.delete(t);let o=this.worktreeBindings.get(t);throw o&&(await this.releaseWorktreeForInstance(o.agentId),this.worktreeBindings.delete(t)),m.error("Failed to spawn agent, cleaned up",{id:t,name:e.name,error:errorMeta(a)}),a}}async assignWorktreeForInstance(e){let t=`subagent-${e}`;try{let{MultiAgentWorktree:n}=await import('@easbot/utils'),r=await n.assign({agentId:t,ephemeral:!0}),s={agentId:t,worktreePath:r.directory};return this.worktreeBindings.set(e,s),s}catch(n){return m.warn("worktree assign failed, spawn will use main checkout",{instanceId:e,error:errorMeta(n)}),null}}async releaseWorktreeForInstance(e){try{let{MultiAgentWorktree:t}=await import('@easbot/utils');await t.release({agentId:e});}catch(t){m.warn("worktree release failed (will be reaped by sweep)",{agentId:e,error:errorMeta(t)});}}createHandler(e){switch(e.transport){case "stdio":case "http":case "websocket":return new _(e);case "cli":return new B(e);default:throw new NameErrors.InvalidArgumentError({message:`Unknown transport type: ${e.transport}`,param:"transport"})}}async acquire(e){let t=await this.findIdleInstance(e.name);if(!t){let r=this.agentCounts.get(e.name)??0,s=e.maxConcurrent??this.config.maxConcurrent;r<s?t=await this.spawn(e):(m.debug("Max concurrent reached, waiting for idle instance",{name:e.name,currentCount:r,maxConcurrent:s}),t=await this.waitForIdleInstance(e.name));}t.status="running",t.lastActiveAt=Date.now();let n=this.handlers.get(t.id);if(!n)throw new NameErrors.NotFoundError({message:`Handler not found for instance: ${t.id}`,location:t.id});return {instance:t,execute:async(r,s)=>{t.status="busy";try{let a=await n.execute(r,s);return t.status="idle",t.lastActiveAt=Date.now(),a}catch(a){throw t.status="error",a}},interrupt:()=>n.interrupt()}}async release(e,t){t==="ephemeral"?await this.terminate(e.id):(e.status="idle",m.debug("Agent released to pool",{id:e.id,name:e.config.name}));}async terminate(e){let t=this.handlers.get(e),n=this.instances.get(e);if(this.handlers.delete(e),t)try{await t.stop();}catch(s){m.warn("Error stopping agent",{id:e,error:errorMeta(s)});}let r=this.worktreeBindings.get(e);if(r&&(await this.releaseWorktreeForInstance(r.agentId),this.worktreeBindings.delete(e)),n){let s=this.agentCounts.get(n.config.name)??0;s>0&&this.agentCounts.set(n.config.name,s-1),n.status="stopped",this.instances.delete(e);}m.debug("Agent terminated",{id:e});}async interrupt(e){let t=this.handlers.get(e);if(t)try{await t.interrupt(),m.debug("Agent interrupted",{id:e});}catch(n){m.warn("Error interrupting agent",{id:e,error:errorMeta(n)});}}async shutdownAll(){this.stopIdleCleanup();let e=Array.from(this.instances.keys());await Promise.all(e.map(t=>this.terminate(t))),m.debug("All agents shut down",{count:e.length});}listWorktreeBindings(){return Array.from(this.worktreeBindings.entries()).map(([e,t])=>({instanceId:e,agentId:t.agentId,worktreePath:t.worktreePath}))}list(){return Array.from(this.instances.values())}get(e){return this.instances.get(e)}async findIdleInstance(e){let t=[];for(let[n,r]of this.instances){if(r.config.name!==e||r.status!=="idle")continue;if(!await this.checkInstanceHealth(r)){m.warn("Found unhealthy idle instance, marking for cleanup",{id:n,name:e,lastActiveAt:r.lastActiveAt}),t.push(n);continue}return r}for(let n of t)try{await this.terminate(n);}catch(r){m.warn("Failed to terminate unhealthy instance",{id:n,error:errorMeta(r)});}}async waitForIdleInstance(e,t=6e4){let n=Date.now();for(;Date.now()-n<t;){let r=await this.findIdleInstance(e);if(r)return r;await new Promise(s=>setTimeout(s,1e3));}throw new NameErrors.TimeoutError({message:`Timeout waiting for idle ${e} agent`,timeoutMs:3e4})}};var k=NamedError.create("SubAgentError",$.object({message:$.string(),code:$.string(),agent:$.string().optional(),transport:$.string().optional()}));function we(i){let e=i;return {source:e.source??e.sessionId??"gateway",title:e.title??"SubAgent task",agent:e.agent??"gateway",parts:e.parts??[],system:e.system,config:e.config}}function re(i){return i?.enabled===true}var y=class y{constructor(e){a(this,"log");a(this,"registry",null);a(this,"registryConfig",null);a(this,"initError",null);this.log=Log.create({service:"llm.agent.sub-agent"}),this.registryConfig=e;}ensureRegistry(){if(!this.registry&&this.registryConfig)try{this.registry=new F(this.registryConfig);}catch(e){throw this.initError=e,new k({message:`Failed to initialize SubAgentRegistry: ${errorMeta(e).message}`,code:"init-failed"},{cause:e})}if(!this.registry)throw new k({message:"SubAgent registry not initialized (config missing or invalid)",code:"registry-uninit"});return this.registry}resolveAgentConfig(e){if(!this.registryConfig||!re(this.registryConfig))throw new k({message:"SubAgent system is disabled",code:"disabled"});let t=this.registryConfig.agents.find(r=>r.name===e.agent);if(!t)throw new k({message:`Unknown agent: ${e.agent}`,code:"unknown-agent",agent:e.agent});let n=t.transport;if(n!=="stdio"&&n!=="http"&&n!=="websocket")throw new k({message:`SubAgent.run only supports ACP transport (stdio/http/websocket); got '${n}' for agent '${e.agent}'. Use SubAgentRegistry directly for CLI/Remote transports.`,code:"unsupported-transport",agent:e.agent,transport:n});return {...t,...e.config??{}}}async run(e,t){var f=[];try{let n=g(f,this.log.time("llm.agent.subagent.run",{level:"DEBUG"}));let r=we(e);let s=this.ensureRegistry();let a=this.resolveAgentConfig(r);this.log.debug("SubAgent.run started",{title:r.title,agent:r.agent,runMode:a.runMode,transport:a.transport,hasOnMessage:!!t?.onMessage});let o=await s.acquire(a);try{return await o.execute(r,t)}catch(g){if(this.log.error("SubAgent.run failed",{title:r.title,agent:r.agent,runMode:a.runMode,error:errorMeta(g)}),a.runMode==="persistent"){this.log.warn("Persistent agent failed, terminating instance",{id:o.instance.id,name:r.agent});try{await s.terminate(o.instance.id);}catch(d){this.log.warn("Failed to terminate persistent agent",{id:o.instance.id,error:errorMeta(d)});}}throw g}finally{if(a.runMode==="ephemeral")try{await s.release(o.instance,"ephemeral");}catch(g){this.log.warn("Failed to release ephemeral agent",{id:o.instance.id,error:errorMeta(g)});}}}catch(h){var b=h,w=true;}finally{h(f,b,w);}}async shutdown(){this.registry&&await this.registry.shutdownAll();}isEnabled(){return re(this.registryConfig)&&this.initError===null}static getDefault(){return y._default}static setDefault(e){return y._default&&y._default.shutdown().catch(()=>{}),y._default=new y(e),y._default}static async run(e){let t=y.getDefault();if(!t)throw new k({message:"SubAgent.run called but no default instance set; call SubAgent.setDefault(config) first",code:"registry-uninit"});return t.run(e)}static clearDefault(){y._default&&(y._default.shutdown().catch(()=>{}),y._default=null);}};a(y,"_default",null);var ie=y;
11
- export{V as a,k as b,ie as c};
@@ -1 +0,0 @@
1
- 'use strict';var chunkGHMRMPMO_cjs=require('./chunk-GHMRMPMO.cjs');require('./chunk-2XQWKCQ4.cjs');Object.defineProperty(exports,"DEFAULT_SUBAGENT_CONFIG",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.p}});Object.defineProperty(exports,"Flag",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.a}});Object.defineProperty(exports,"Installation",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.o}});Object.defineProperty(exports,"disposeLlmAgents",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.C}});Object.defineProperty(exports,"getAdapterRegistry",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.c}});Object.defineProperty(exports,"getGlobal",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.k}});Object.defineProperty(exports,"getIConfigProvider",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.e}});Object.defineProperty(exports,"getIGlobalPathProvider",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.g}});Object.defineProperty(exports,"getIInstallationProvider",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.h}});Object.defineProperty(exports,"getIInstanceProvider",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.f}});Object.defineProperty(exports,"getLocalAgent",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.w}});Object.defineProperty(exports,"getSdk",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.s}});Object.defineProperty(exports,"getSubAgent",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.A}});Object.defineProperty(exports,"hasAdapterRegistry",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.d}});Object.defineProperty(exports,"hasLocalAgent",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.x}});Object.defineProperty(exports,"hasSdk",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.t}});Object.defineProperty(exports,"hasSubAgent",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.B}});Object.defineProperty(exports,"readEnvString",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.n}});Object.defineProperty(exports,"readFlagBool",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.l}});Object.defineProperty(exports,"readFlagNumber",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.m}});Object.defineProperty(exports,"resetEasbotClientAdapter",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.r}});Object.defineProperty(exports,"resetGlobalAdapter",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.j}});Object.defineProperty(exports,"resetLocalAgentAdapter",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.v}});Object.defineProperty(exports,"resetSubAgentConfig",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.z}});Object.defineProperty(exports,"setAdapterRegistry",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.b}});Object.defineProperty(exports,"setEasbotClientAdapter",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.q}});Object.defineProperty(exports,"setGlobalAdapter",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.i}});Object.defineProperty(exports,"setLocalAgentAdapter",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.u}});Object.defineProperty(exports,"setSubAgentConfig",{enumerable:true,get:function(){return chunkGHMRMPMO_cjs.y}});
@@ -1 +0,0 @@
1
- export{h as Config}from'./chunk-3DTBBDPN.mjs';import'./chunk-NX2YVB72.mjs';import'./chunk-QMTIXJ7U.mjs';
@@ -1 +0,0 @@
1
- 'use strict';var chunkKS3TBDYP_cjs=require('./chunk-KS3TBDYP.cjs');require('./chunk-GHMRMPMO.cjs'),require('./chunk-2XQWKCQ4.cjs');Object.defineProperty(exports,"Config",{enumerable:true,get:function(){return chunkKS3TBDYP_cjs.h}});
@@ -1 +0,0 @@
1
- 'use strict';var chunkLCI45SAN_cjs=require('./chunk-LCI45SAN.cjs');require('./chunk-GHMRMPMO.cjs'),require('./chunk-2XQWKCQ4.cjs');Object.defineProperty(exports,"SubAgent",{enumerable:true,get:function(){return chunkLCI45SAN_cjs.c}});Object.defineProperty(exports,"SubAgentError",{enumerable:true,get:function(){return chunkLCI45SAN_cjs.b}});
@@ -1 +0,0 @@
1
- export{c as SubAgent,b as SubAgentError}from'./chunk-YUX6P6YF.mjs';import'./chunk-NX2YVB72.mjs';import'./chunk-QMTIXJ7U.mjs';