@toolpack-sdk/agents 2.7.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1065,6 +1065,71 @@ console.log(formatEvalReport(report));
1065
1065
  expect(report.regressions).toHaveLength(0); // CI gate
1066
1066
  ```
1067
1067
 
1068
+ ## Stopping Agents
1069
+
1070
+ Every `AgentInput` and `AgentRunOptions` accepts an optional `signal?: AbortSignal`. Passing a signal lets you cancel an in-flight agent run from outside.
1071
+
1072
+ ### Basic pattern
1073
+
1074
+ ```typescript
1075
+ import { BaseAgent } from '@toolpack-sdk/agents';
1076
+
1077
+ const controller = new AbortController();
1078
+
1079
+ // Pass the signal when invoking the agent
1080
+ const resultPromise = agent.invokeAgent({
1081
+ message: 'Do something long-running',
1082
+ signal: controller.signal,
1083
+ });
1084
+
1085
+ // Abort from wherever you need — HTTP stop endpoint, UI button, timeout, etc.
1086
+ controller.abort();
1087
+
1088
+ const result = await resultPromise;
1089
+ // result.output will indicate the run was stopped
1090
+ ```
1091
+
1092
+ ### In a web server (stop endpoint)
1093
+
1094
+ ```typescript
1095
+ const activeRuns = new Map<string, AbortController>();
1096
+
1097
+ app.post('/api/chat', async (req, res) => {
1098
+ const { sessionId, message } = req.body;
1099
+ const controller = new AbortController();
1100
+ activeRuns.set(sessionId, controller);
1101
+
1102
+ const result = await agent.invokeAgent({ message, signal: controller.signal });
1103
+ activeRuns.delete(sessionId);
1104
+
1105
+ res.json(result);
1106
+ });
1107
+
1108
+ app.post('/api/chat/stop', (req, res) => {
1109
+ const controller = activeRuns.get(req.body.sessionId);
1110
+ if (controller) {
1111
+ controller.abort();
1112
+ activeRuns.delete(req.body.sessionId);
1113
+ }
1114
+ res.json({ ok: true });
1115
+ });
1116
+ ```
1117
+
1118
+ ### Signal propagation through delegation
1119
+
1120
+ When you pass `signal` to `invokeAgent()`, it is automatically propagated into any sub-agents spawned via `delegate_to_agent` or `delegate_and_forget`. You do not need to pass the signal manually to delegated agents — the parent agent's abort signal flows through the entire delegation chain.
1121
+
1122
+ ```typescript
1123
+ // Aborting the root agent also stops all delegated sub-agents
1124
+ const controller = new AbortController();
1125
+ await executiveAgent.invokeAgent({ message: '...', signal: controller.signal });
1126
+ controller.abort(); // stops executive + all delegates it spawned
1127
+ ```
1128
+
1129
+ ### Limitation
1130
+
1131
+ The signal fires at **tool-round boundaries**, not mid-tool-execution. A running tool call (including a delegation) finishes its current step before the abort is observed. Sub-agents stop at their own next round boundary once the signal is propagated. This is the standard behavior for cooperative cancellation with `AbortSignal`.
1132
+
1068
1133
  ## Testing
1069
1134
 
1070
1135
  ```bash
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { ModeConfig, ConversationStore, AssemblerOptions, Toolpack } from 'toolpack-sdk';
3
- import { A as AgentInput, W as WorkflowStep, a as AgentResult, b as AgentDelegationConfig, c as AgentSpawnConfig, C as ChannelInterface, I as Interceptor, d as IAgentRegistry, B as BaseAgentOptions, e as AgentRunOptions, P as PendingAsk } from './types-C3EZvpe0.js';
3
+ import { A as AgentInput, W as WorkflowStep, a as AgentResult, b as AgentDelegationConfig, c as AgentSpawnConfig, C as ChannelInterface, I as Interceptor, d as IAgentRegistry, B as BaseAgentOptions, e as AgentRunOptions, P as PendingAsk } from './types-CJinv165.js';
4
4
  import { Embedder, KnowledgeProvider } from '@toolpack-sdk/knowledge';
5
5
 
6
6
  type GoalStatus = 'active' | 'completed';
@@ -145,17 +145,11 @@ declare abstract class BaseAgent<TIntent extends string = string> extends EventE
145
145
  /** Reference to the registry for sendTo() and delegation support */
146
146
  _registry?: IAgentRegistry;
147
147
  /**
148
- * Invocation-scoped context fields set by `_bindChannel` immediately before
149
- * calling `invokeAgent` and read inside `run()`, `ask()`, and `delegate()`.
150
- *
151
- * KNOWN LIMITATION: these are instance-level fields, not async-local storage.
152
- * Two different conversations processed concurrently by the same agent can
153
- * clobber each other's values. The conversation lock serialises within a single
154
- * conversationId, but distinct conversationIds run concurrently.
155
- *
156
- * Fix: replace with `AsyncLocalStorage` in a future release. For now, agents
157
- * that call `this.run()` while processing multiple concurrent conversations
158
- * should pass `conversationId` explicitly to avoid relying on these fields.
148
+ * Legacy fallback fields for code that calls `invokeAgent()` directly (no channel).
149
+ * Channel-driven flows no longer write to these — `_bindChannel` establishes an
150
+ * async-local context (`_channelCtx`) so concurrent conversations on the same
151
+ * agent instance never clobber each other. These remain for backward compatibility
152
+ * with direct callers that set `_conversationId` manually before invoking.
159
153
  */
160
154
  _triggeringChannel?: string;
161
155
  _conversationId?: string;
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { ModeConfig, ConversationStore, AssemblerOptions, Toolpack } from 'toolpack-sdk';
3
- import { A as AgentInput, W as WorkflowStep, a as AgentResult, b as AgentDelegationConfig, c as AgentSpawnConfig, C as ChannelInterface, I as Interceptor, d as IAgentRegistry, B as BaseAgentOptions, e as AgentRunOptions, P as PendingAsk } from './types-C3EZvpe0.cjs';
3
+ import { A as AgentInput, W as WorkflowStep, a as AgentResult, b as AgentDelegationConfig, c as AgentSpawnConfig, C as ChannelInterface, I as Interceptor, d as IAgentRegistry, B as BaseAgentOptions, e as AgentRunOptions, P as PendingAsk } from './types-CJinv165.cjs';
4
4
  import { Embedder, KnowledgeProvider } from '@toolpack-sdk/knowledge';
5
5
 
6
6
  type GoalStatus = 'active' | 'completed';
@@ -145,17 +145,11 @@ declare abstract class BaseAgent<TIntent extends string = string> extends EventE
145
145
  /** Reference to the registry for sendTo() and delegation support */
146
146
  _registry?: IAgentRegistry;
147
147
  /**
148
- * Invocation-scoped context fields set by `_bindChannel` immediately before
149
- * calling `invokeAgent` and read inside `run()`, `ask()`, and `delegate()`.
150
- *
151
- * KNOWN LIMITATION: these are instance-level fields, not async-local storage.
152
- * Two different conversations processed concurrently by the same agent can
153
- * clobber each other's values. The conversation lock serialises within a single
154
- * conversationId, but distinct conversationIds run concurrently.
155
- *
156
- * Fix: replace with `AsyncLocalStorage` in a future release. For now, agents
157
- * that call `this.run()` while processing multiple concurrent conversations
158
- * should pass `conversationId` explicitly to avoid relying on these fields.
148
+ * Legacy fallback fields for code that calls `invokeAgent()` directly (no channel).
149
+ * Channel-driven flows no longer write to these — `_bindChannel` establishes an
150
+ * async-local context (`_channelCtx`) so concurrent conversations on the same
151
+ * agent instance never clobber each other. These remain for backward compatibility
152
+ * with direct callers that set `_conversationId` manually before invoking.
159
153
  */
160
154
  _triggeringChannel?: string;
161
155
  _conversationId?: string;
@@ -3,10 +3,10 @@
3
3
  `);this.delegation.mode==="forget"?c.push({name:"delegate_and_forget",displayName:"Delegate and Forget",description:`Hand off the current task to a peer agent. The agent will handle its own delivery (e.g. posting to Slack or GitHub) \u2014 you do not need to relay its response. Call this ONCE, then output an empty string.
4
4
 
5
5
  Available agents:
6
- ${R}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:v,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let D=String(I.agent),b=String(I.message??"");return this._registry.invoke(D,{message:b,conversationId:n,context:{delegatedBy:this.name}}).catch(C=>{console.error(`[${this.name}] delegate_and_forget to ${D} failed:`,C)}),{status:"delegated",agent:D}}}):c.push({name:"delegate_to_agent",displayName:"Delegate to Agent",description:`Hand off the current task to a peer agent and return its result. Use when the task falls outside your own specialisation.
6
+ ${R}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:v,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let D=String(I.agent),b=String(I.message??"");return this._registry.invoke(D,{message:b,conversationId:n,context:{delegatedBy:this.name},signal:t?.signal}).catch(C=>{console.error(`[${this.name}] delegate_and_forget to ${D} failed:`,C)}),{status:"delegated",agent:D}}}):c.push({name:"delegate_to_agent",displayName:"Delegate to Agent",description:`Hand off the current task to a peer agent and return its result. Use when the task falls outside your own specialisation.
7
7
 
8
8
  Available agents:
9
- ${R}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:v,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let D=String(I.agent),b=String(I.message??""),C=await this._registry.invoke(D,{message:b,conversationId:n,context:{delegatedBy:this.name}});return{...C,output:`[Response from ${D} \u2014 task complete]
9
+ ${R}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:v,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let D=String(I.agent),b=String(I.message??""),C=await this._registry.invoke(D,{message:b,conversationId:n,context:{delegatedBy:this.name},signal:t?.signal});return{...C,output:`[Response from ${D} \u2014 task complete]
10
10
 
11
11
  ${C.output}`}}})}}if(this.spawn?.enabled&&this.spawn.templates.length>0){let y=i?.spawnDepth??0,w=this.spawn,v=w.maxDepth??3;if(y<v){let R=w.templates,I=R.some(k=>k.name==="self"),D=R.some(k=>k.allowPromptAddition),b=R.filter(k=>k.name!=="self").map(k=>`- ${k.name}: ${k.description}`).join(`
12
12
  `),C=I?`Use template name "self" to spawn a replica of the current agent.
@@ -26,7 +26,7 @@ ${b}
26
26
 
27
27
  ${String(P.systemPromptAddition)}`:"",H,q,j,B;if(G==="self"){let W=typeof this.mode=="string"?{...N.AGENT_MODE,name:this.mode}:this.mode,Ae=x.systemPrompt(O);H={...W,name:`${W.name}-replica-${Date.now()}`,systemPrompt:(W.systemPrompt??"")+(Ae?`
28
28
 
29
- ${Ae}`:"")+z},q=`${this.name}-replica`,j=this.description,B=this.model}else H={...N.AGENT_MODE,name:`ephemeral-${x.name}-${Date.now()}`,systemPrompt:x.systemPrompt(O)+z},q=x.name,j=x.description,B=x.model;let F=new $(q,j,H,{toolpack:this.toolpack});B&&(F.model=B),F.spawn={...w};let we=await F.invokeAgent({message:O,conversationId:`spawn-${Date.now()}`,context:{spawnedBy:this.name,spawnDepth:y+1}});return{output:we.output,spawnedTemplate:G,depth:y+1,metadata:we.metadata}}))}}})}}let d={messages:u,model:this.model||"",requestTools:c.length>0?c:void 0,maxToolRounds:t?.maxToolRounds,mode:this.mode},l=null,m,g;if(typeof this.mode!="string"&&this.mode?.streaming){let y="";for await(let w of this.toolpack.stream(d,this.provider))y+=w.delta||"",w.usage&&(m=w.usage);l=y||null,g={content:l,usage:m}}else{let y=await this.toolpack.generate(d,this.provider);l=y.content??null,m=y.usage,g=y}let f={output:l||"",steps:this.extractSteps(g),metadata:m?{usage:m}:void 0};return await this.onComplete(f),s&&await s(!1),this.emit("agent:complete",f),f}catch(u){throw s&&s(!0).catch(c=>{console.error(`[${this.name??"agent"}][AgentMind] Draft buffer flush on error failed:`,c)}),await this.onError(u),this.emit("agent:error",u),u}}getAgentAliases(){let e=[];for(let t of this.channels){let i=t.botUserId;i&&e.push(i)}return e}async sendTo(e,t){if(!this._registry)throw new Error("Agent not registered - _registry not set");await this._registry.sendTo(e,{output:t})}async ask(e,t){if(!this._registry)throw new E("Agent not registered - cannot use ask()");let i=this._ctx()?.conversationId??this._conversationId,n=this._ctx()?.isTriggerChannel??this._isTriggerChannel,s=this._ctx()?.triggeringChannel??this._triggeringChannel;if(!i)throw new E("No conversationId available - ask() requires a conversation channel");if(n)throw new E("this.ask() called from a trigger channel (ScheduledChannel). Trigger channels have no human recipient \u2014 use a conversation channel (Slack, Telegram, Webhook) instead.");if(!s||s.trim()==="")throw new E("Cannot use ask() - no triggering channel available. The channel must have a name registered with AgentRegistry.");let o=this._registry.addPendingAsk({conversationId:i,agentName:this.name,question:e,context:t?.context??{},maxRetries:t?.maxRetries??2,expiresAt:t?.expiresIn?new Date(Date.now()+t.expiresIn):void 0,channelName:s});return await this.sendTo(s,e),{output:e,metadata:{waitingForHuman:!0,askId:o.id}}}getPendingAsk(e){if(!this._registry)return null;let t=e??this._ctx()?.conversationId??this._conversationId;return t?this._registry.getPendingAsk(t)??null:null}async resolvePendingAsk(e,t){if(!this._registry)throw new E("Agent not registered - cannot resolve ask");await this._registry.resolvePendingAsk(e,t)}async evaluateAnswer(e,t,i){if(i?.simpleValidation)return i.simpleValidation(t);let n=this._ctx()?.conversationId??this._conversationId;return(await this.run(`Evaluate if this answer sufficiently addresses the question.
29
+ ${Ae}`:"")+z},q=`${this.name}-replica`,j=this.description,B=this.model}else H={...N.AGENT_MODE,name:`ephemeral-${x.name}-${Date.now()}`,systemPrompt:x.systemPrompt(O)+z},q=x.name,j=x.description,B=x.model;let F=new $(q,j,H,{toolpack:this.toolpack});B&&(F.model=B),F.spawn={...w};let we=await F.invokeAgent({message:O,conversationId:`spawn-${Date.now()}`,context:{spawnedBy:this.name,spawnDepth:y+1}});return{output:we.output,spawnedTemplate:G,depth:y+1,metadata:we.metadata}}))}}})}}let d={messages:u,model:this.model||"",requestTools:c.length>0?c:void 0,maxToolRounds:t?.maxToolRounds,mode:this.mode,signal:t?.signal},l=null,m,g;if(typeof this.mode!="string"&&this.mode?.streaming){let y="";for await(let w of this.toolpack.stream(d,this.provider))y+=w.delta||"",w.usage&&(m=w.usage);l=y||null,g={content:l,usage:m}}else{let y=await this.toolpack.generate(d,this.provider);l=y.content??null,m=y.usage,g=y}let f={output:l||"",steps:this.extractSteps(g),metadata:m?{usage:m}:void 0};return await this.onComplete(f),s&&await s(!1),this.emit("agent:complete",f),f}catch(u){throw s&&s(!0).catch(c=>{console.error(`[${this.name??"agent"}][AgentMind] Draft buffer flush on error failed:`,c)}),await this.onError(u),this.emit("agent:error",u),u}}getAgentAliases(){let e=[];for(let t of this.channels){let i=t.botUserId;i&&e.push(i)}return e}async sendTo(e,t){if(!this._registry)throw new Error("Agent not registered - _registry not set");await this._registry.sendTo(e,{output:t})}async ask(e,t){if(!this._registry)throw new E("Agent not registered - cannot use ask()");let i=this._ctx()?.conversationId??this._conversationId,n=this._ctx()?.isTriggerChannel??this._isTriggerChannel,s=this._ctx()?.triggeringChannel??this._triggeringChannel;if(!i)throw new E("No conversationId available - ask() requires a conversation channel");if(n)throw new E("this.ask() called from a trigger channel (ScheduledChannel). Trigger channels have no human recipient \u2014 use a conversation channel (Slack, Telegram, Webhook) instead.");if(!s||s.trim()==="")throw new E("Cannot use ask() - no triggering channel available. The channel must have a name registered with AgentRegistry.");let o=this._registry.addPendingAsk({conversationId:i,agentName:this.name,question:e,context:t?.context??{},maxRetries:t?.maxRetries??2,expiresAt:t?.expiresIn?new Date(Date.now()+t.expiresIn):void 0,channelName:s});return await this.sendTo(s,e),{output:e,metadata:{waitingForHuman:!0,askId:o.id}}}getPendingAsk(e){if(!this._registry)return null;let t=e??this._ctx()?.conversationId??this._conversationId;return t?this._registry.getPendingAsk(t)??null:null}async resolvePendingAsk(e,t){if(!this._registry)throw new E("Agent not registered - cannot resolve ask");await this._registry.resolvePendingAsk(e,t)}async evaluateAnswer(e,t,i){if(i?.simpleValidation)return i.simpleValidation(t);let n=this._ctx()?.conversationId??this._conversationId;return(await this.run(`Evaluate if this answer sufficiently addresses the question.
30
30
 
31
31
  Question: "${e}"
32
32
  Answer: "${t}"
@@ -1,6 +1,6 @@
1
- export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from '../intent-classifier-agent-DVCbBtdY.cjs';
2
- import { B as BaseAgentOptions, A as AgentInput, a as AgentResult } from '../types-C3EZvpe0.cjs';
3
- import { B as BaseAgent } from '../base-agent-DVwGO20L.cjs';
1
+ export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from '../intent-classifier-agent-CEmRGpUr.cjs';
2
+ import { B as BaseAgentOptions, A as AgentInput, a as AgentResult } from '../types-CJinv165.cjs';
3
+ import { B as BaseAgent } from '../base-agent-iaQiO7jW.cjs';
4
4
  import { Participant, ModeConfig } from 'toolpack-sdk';
5
5
  export { Participant } from 'toolpack-sdk';
6
6
  import 'events';
@@ -1,6 +1,6 @@
1
- export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from '../intent-classifier-agent-BnpchAoZ.js';
2
- import { B as BaseAgentOptions, A as AgentInput, a as AgentResult } from '../types-C3EZvpe0.js';
3
- import { B as BaseAgent } from '../base-agent-BMZWBdkt.js';
1
+ export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from '../intent-classifier-agent-QuB4WIWf.js';
2
+ import { B as BaseAgentOptions, A as AgentInput, a as AgentResult } from '../types-CJinv165.js';
3
+ import { B as BaseAgent } from '../base-agent-CJE2QCjY.js';
4
4
  import { Participant, ModeConfig } from 'toolpack-sdk';
5
5
  export { Participant } from 'toolpack-sdk';
6
6
  import 'events';
@@ -3,10 +3,10 @@ var qe=Object.defineProperty;var D=(r,e)=>()=>(r&&(e=r(r=0)),e);var we=(r,e)=>{f
3
3
  `);this.delegation.mode==="forget"?c.push({name:"delegate_and_forget",displayName:"Delegate and Forget",description:`Hand off the current task to a peer agent. The agent will handle its own delivery (e.g. posting to Slack or GitHub) \u2014 you do not need to relay its response. Call this ONCE, then output an empty string.
4
4
 
5
5
  Available agents:
6
- ${R}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:v,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let P=String(I.agent),b=String(I.message??"");return this._registry.invoke(P,{message:b,conversationId:i,context:{delegatedBy:this.name}}).catch(x=>{console.error(`[${this.name}] delegate_and_forget to ${P} failed:`,x)}),{status:"delegated",agent:P}}}):c.push({name:"delegate_to_agent",displayName:"Delegate to Agent",description:`Hand off the current task to a peer agent and return its result. Use when the task falls outside your own specialisation.
6
+ ${R}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:v,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let P=String(I.agent),b=String(I.message??"");return this._registry.invoke(P,{message:b,conversationId:i,context:{delegatedBy:this.name},signal:t?.signal}).catch(x=>{console.error(`[${this.name}] delegate_and_forget to ${P} failed:`,x)}),{status:"delegated",agent:P}}}):c.push({name:"delegate_to_agent",displayName:"Delegate to Agent",description:`Hand off the current task to a peer agent and return its result. Use when the task falls outside your own specialisation.
7
7
 
8
8
  Available agents:
9
- ${R}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:v,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let P=String(I.agent),b=String(I.message??""),x=await this._registry.invoke(P,{message:b,conversationId:i,context:{delegatedBy:this.name}});return{...x,output:`[Response from ${P} \u2014 task complete]
9
+ ${R}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:v,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let P=String(I.agent),b=String(I.message??""),x=await this._registry.invoke(P,{message:b,conversationId:i,context:{delegatedBy:this.name},signal:t?.signal});return{...x,output:`[Response from ${P} \u2014 task complete]
10
10
 
11
11
  ${x.output}`}}})}}if(this.spawn?.enabled&&this.spawn.templates.length>0){let y=n?.spawnDepth??0,w=this.spawn,v=w.maxDepth??3;if(y<v){let R=w.templates,I=R.some(k=>k.name==="self"),P=R.some(k=>k.allowPromptAddition),b=R.filter(k=>k.name!=="self").map(k=>`- ${k.name}: ${k.description}`).join(`
12
12
  `),x=I?`Use template name "self" to spawn a replica of the current agent.
@@ -26,7 +26,7 @@ ${b}
26
26
 
27
27
  ${String(B.systemPromptAddition)}`:"",H,q,j,E;if(G==="self"){let W=typeof this.mode=="string"?{...X,name:this.mode}:this.mode,ye=C.systemPrompt(O);H={...W,name:`${W.name}-replica-${Date.now()}`,systemPrompt:(W.systemPrompt??"")+(ye?`
28
28
 
29
- ${ye}`:"")+z},q=`${this.name}-replica`,j=this.description,E=this.model}else H={...X,name:`ephemeral-${C.name}-${Date.now()}`,systemPrompt:C.systemPrompt(O)+z},q=C.name,j=C.description,E=C.model;let F=new $(q,j,H,{toolpack:this.toolpack});E&&(F.model=E),F.spawn={...w};let he=await F.invokeAgent({message:O,conversationId:`spawn-${Date.now()}`,context:{spawnedBy:this.name,spawnDepth:y+1}});return{output:he.output,spawnedTemplate:G,depth:y+1,metadata:he.metadata}}))}}})}}let d={messages:u,model:this.model||"",requestTools:c.length>0?c:void 0,maxToolRounds:t?.maxToolRounds,mode:this.mode},l=null,m,g;if(typeof this.mode!="string"&&this.mode?.streaming){let y="";for await(let w of this.toolpack.stream(d,this.provider))y+=w.delta||"",w.usage&&(m=w.usage);l=y||null,g={content:l,usage:m}}else{let y=await this.toolpack.generate(d,this.provider);l=y.content??null,m=y.usage,g=y}let f={output:l||"",steps:this.extractSteps(g),metadata:m?{usage:m}:void 0};return await this.onComplete(f),s&&await s(!1),this.emit("agent:complete",f),f}catch(u){throw s&&s(!0).catch(c=>{console.error(`[${this.name??"agent"}][AgentMind] Draft buffer flush on error failed:`,c)}),await this.onError(u),this.emit("agent:error",u),u}}getAgentAliases(){let e=[];for(let t of this.channels){let n=t.botUserId;n&&e.push(n)}return e}async sendTo(e,t){if(!this._registry)throw new Error("Agent not registered - _registry not set");await this._registry.sendTo(e,{output:t})}async ask(e,t){if(!this._registry)throw new N("Agent not registered - cannot use ask()");let n=this._ctx()?.conversationId??this._conversationId,i=this._ctx()?.isTriggerChannel??this._isTriggerChannel,s=this._ctx()?.triggeringChannel??this._triggeringChannel;if(!n)throw new N("No conversationId available - ask() requires a conversation channel");if(i)throw new N("this.ask() called from a trigger channel (ScheduledChannel). Trigger channels have no human recipient \u2014 use a conversation channel (Slack, Telegram, Webhook) instead.");if(!s||s.trim()==="")throw new N("Cannot use ask() - no triggering channel available. The channel must have a name registered with AgentRegistry.");let o=this._registry.addPendingAsk({conversationId:n,agentName:this.name,question:e,context:t?.context??{},maxRetries:t?.maxRetries??2,expiresAt:t?.expiresIn?new Date(Date.now()+t.expiresIn):void 0,channelName:s});return await this.sendTo(s,e),{output:e,metadata:{waitingForHuman:!0,askId:o.id}}}getPendingAsk(e){if(!this._registry)return null;let t=e??this._ctx()?.conversationId??this._conversationId;return t?this._registry.getPendingAsk(t)??null:null}async resolvePendingAsk(e,t){if(!this._registry)throw new N("Agent not registered - cannot resolve ask");await this._registry.resolvePendingAsk(e,t)}async evaluateAnswer(e,t,n){if(n?.simpleValidation)return n.simpleValidation(t);let i=this._ctx()?.conversationId??this._conversationId;return(await this.run(`Evaluate if this answer sufficiently addresses the question.
29
+ ${ye}`:"")+z},q=`${this.name}-replica`,j=this.description,E=this.model}else H={...X,name:`ephemeral-${C.name}-${Date.now()}`,systemPrompt:C.systemPrompt(O)+z},q=C.name,j=C.description,E=C.model;let F=new $(q,j,H,{toolpack:this.toolpack});E&&(F.model=E),F.spawn={...w};let he=await F.invokeAgent({message:O,conversationId:`spawn-${Date.now()}`,context:{spawnedBy:this.name,spawnDepth:y+1}});return{output:he.output,spawnedTemplate:G,depth:y+1,metadata:he.metadata}}))}}})}}let d={messages:u,model:this.model||"",requestTools:c.length>0?c:void 0,maxToolRounds:t?.maxToolRounds,mode:this.mode,signal:t?.signal},l=null,m,g;if(typeof this.mode!="string"&&this.mode?.streaming){let y="";for await(let w of this.toolpack.stream(d,this.provider))y+=w.delta||"",w.usage&&(m=w.usage);l=y||null,g={content:l,usage:m}}else{let y=await this.toolpack.generate(d,this.provider);l=y.content??null,m=y.usage,g=y}let f={output:l||"",steps:this.extractSteps(g),metadata:m?{usage:m}:void 0};return await this.onComplete(f),s&&await s(!1),this.emit("agent:complete",f),f}catch(u){throw s&&s(!0).catch(c=>{console.error(`[${this.name??"agent"}][AgentMind] Draft buffer flush on error failed:`,c)}),await this.onError(u),this.emit("agent:error",u),u}}getAgentAliases(){let e=[];for(let t of this.channels){let n=t.botUserId;n&&e.push(n)}return e}async sendTo(e,t){if(!this._registry)throw new Error("Agent not registered - _registry not set");await this._registry.sendTo(e,{output:t})}async ask(e,t){if(!this._registry)throw new N("Agent not registered - cannot use ask()");let n=this._ctx()?.conversationId??this._conversationId,i=this._ctx()?.isTriggerChannel??this._isTriggerChannel,s=this._ctx()?.triggeringChannel??this._triggeringChannel;if(!n)throw new N("No conversationId available - ask() requires a conversation channel");if(i)throw new N("this.ask() called from a trigger channel (ScheduledChannel). Trigger channels have no human recipient \u2014 use a conversation channel (Slack, Telegram, Webhook) instead.");if(!s||s.trim()==="")throw new N("Cannot use ask() - no triggering channel available. The channel must have a name registered with AgentRegistry.");let o=this._registry.addPendingAsk({conversationId:n,agentName:this.name,question:e,context:t?.context??{},maxRetries:t?.maxRetries??2,expiresAt:t?.expiresIn?new Date(Date.now()+t.expiresIn):void 0,channelName:s});return await this.sendTo(s,e),{output:e,metadata:{waitingForHuman:!0,askId:o.id}}}getPendingAsk(e){if(!this._registry)return null;let t=e??this._ctx()?.conversationId??this._conversationId;return t?this._registry.getPendingAsk(t)??null:null}async resolvePendingAsk(e,t){if(!this._registry)throw new N("Agent not registered - cannot resolve ask");await this._registry.resolvePendingAsk(e,t)}async evaluateAnswer(e,t,n){if(n?.simpleValidation)return n.simpleValidation(t);let i=this._ctx()?.conversationId??this._conversationId;return(await this.run(`Evaluate if this answer sufficiently addresses the question.
30
30
 
31
31
  Question: "${e}"
32
32
  Answer: "${t}"
@@ -1,4 +1,4 @@
1
- export { B as BaseChannel, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from '../index-BWrYFJtb.cjs';
2
- import '../types-C3EZvpe0.cjs';
1
+ export { B as BaseChannel, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from '../index-a2wZU6Eu.cjs';
2
+ import '../types-CJinv165.cjs';
3
3
  import 'toolpack-sdk';
4
4
  import 'events';
@@ -1,4 +1,4 @@
1
- export { B as BaseChannel, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from '../index-BU2BchV0.js';
2
- import '../types-C3EZvpe0.js';
1
+ export { B as BaseChannel, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from '../index-DQuf4mxT.js';
2
+ import '../types-CJinv165.js';
3
3
  import 'toolpack-sdk';
4
4
  import 'events';
@@ -1,4 +1,4 @@
1
- import { B as BaseAgent } from './base-agent-BMZWBdkt.js';
1
+ import { B as BaseAgent } from './base-agent-CJE2QCjY.js';
2
2
 
3
3
  /**
4
4
  * Eval primitives — shared types across EvalDataset, EvalRunner, EvalScorer, and EvalReport.
@@ -1,4 +1,4 @@
1
- import { B as BaseAgent } from './base-agent-DVwGO20L.cjs';
1
+ import { B as BaseAgent } from './base-agent-iaQiO7jW.cjs';
2
2
 
3
3
  /**
4
4
  * Eval primitives — shared types across EvalDataset, EvalRunner, EvalScorer, and EvalReport.
@@ -1,4 +1,4 @@
1
- import { A as AgentInput, f as AgentOutput } from './types-C3EZvpe0.js';
1
+ import { A as AgentInput, f as AgentOutput } from './types-CJinv165.js';
2
2
  import { Participant } from 'toolpack-sdk';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { A as AgentInput, f as AgentOutput } from './types-C3EZvpe0.cjs';
1
+ import { A as AgentInput, f as AgentOutput } from './types-CJinv165.cjs';
2
2
  import { Participant } from 'toolpack-sdk';
3
3
 
4
4
  /**
package/dist/index.cjs CHANGED
@@ -3,10 +3,10 @@
3
3
  `);this.delegation.mode==="forget"?d.push({name:"delegate_and_forget",displayName:"Delegate and Forget",description:`Hand off the current task to a peer agent. The agent will handle its own delivery (e.g. posting to Slack or GitHub) \u2014 you do not need to relay its response. Call this ONCE, then output an empty string.
4
4
 
5
5
  Available agents:
6
- ${S}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:b,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let P=String(I.agent),k=String(I.message??"");return this._registry.invoke(P,{message:k,conversationId:r,context:{delegatedBy:this.name}}).catch(_=>{console.error(`[${this.name}] delegate_and_forget to ${P} failed:`,_)}),{status:"delegated",agent:P}}}):d.push({name:"delegate_to_agent",displayName:"Delegate to Agent",description:`Hand off the current task to a peer agent and return its result. Use when the task falls outside your own specialisation.
6
+ ${S}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:b,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let P=String(I.agent),k=String(I.message??"");return this._registry.invoke(P,{message:k,conversationId:r,context:{delegatedBy:this.name},signal:t?.signal}).catch(_=>{console.error(`[${this.name}] delegate_and_forget to ${P} failed:`,_)}),{status:"delegated",agent:P}}}):d.push({name:"delegate_to_agent",displayName:"Delegate to Agent",description:`Hand off the current task to a peer agent and return its result. Use when the task falls outside your own specialisation.
7
7
 
8
8
  Available agents:
9
- ${S}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:b,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let P=String(I.agent),k=String(I.message??""),_=await this._registry.invoke(P,{message:k,conversationId:r,context:{delegatedBy:this.name}});return{..._,output:`[Response from ${P} \u2014 task complete]
9
+ ${S}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:b,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async I=>{let P=String(I.agent),k=String(I.message??""),_=await this._registry.invoke(P,{message:k,conversationId:r,context:{delegatedBy:this.name},signal:t?.signal});return{..._,output:`[Response from ${P} \u2014 task complete]
10
10
 
11
11
  ${_.output}`}}})}}if(this.spawn?.enabled&&this.spawn.templates.length>0){let v=n?.spawnDepth??0,A=this.spawn,b=A.maxDepth??3;if(v<b){let S=A.templates,I=S.some(C=>C.name==="self"),P=S.some(C=>C.allowPromptAddition),k=S.filter(C=>C.name!=="self").map(C=>`- ${C.name}: ${C.description}`).join(`
12
12
  `),_=I?`Use template name "self" to spawn a replica of the current agent.
@@ -26,7 +26,7 @@ ${k}
26
26
 
27
27
  ${String(O.systemPromptAddition)}`:"",re,W,Y,$;if(J==="self"){let se=typeof this.mode=="string"?{...U.AGENT_MODE,name:this.mode}:this.mode,Pt=E.systemPrompt(q);re={...se,name:`${se.name}-replica-${Date.now()}`,systemPrompt:(se.systemPrompt??"")+(Pt?`
28
28
 
29
- ${Pt}`:"")+ne},W=`${this.name}-replica`,Y=this.description,$=this.model}else re={...U.AGENT_MODE,name:`ephemeral-${E.name}-${Date.now()}`,systemPrompt:E.systemPrompt(q)+ne},W=E.name,Y=E.description,$=E.model;let X=new G(W,Y,re,{toolpack:this.toolpack});$&&(X.model=$),X.spawn={...A};let Et=await X.invokeAgent({message:q,conversationId:`spawn-${Date.now()}`,context:{spawnedBy:this.name,spawnDepth:v+1}});return{output:Et.output,spawnedTemplate:J,depth:v+1,metadata:Et.metadata}}))}}})}}let p={messages:l,model:this.model||"",requestTools:d.length>0?d:void 0,maxToolRounds:t?.maxToolRounds,mode:this.mode},g=null,u,m;if(typeof this.mode!="string"&&this.mode?.streaming){let v="";for await(let A of this.toolpack.stream(p,this.provider))v+=A.delta||"",A.usage&&(u=A.usage);g=v||null,m={content:g,usage:u}}else{let v=await this.toolpack.generate(p,this.provider);g=v.content??null,u=v.usage,m=v}let y={output:g||"",steps:this.extractSteps(m),metadata:u?{usage:u}:void 0};return await this.onComplete(y),s&&await s(!1),this.emit("agent:complete",y),y}catch(l){throw s&&s(!0).catch(d=>{console.error(`[${this.name??"agent"}][AgentMind] Draft buffer flush on error failed:`,d)}),await this.onError(l),this.emit("agent:error",l),l}}getAgentAliases(){let e=[];for(let t of this.channels){let n=t.botUserId;n&&e.push(n)}return e}async sendTo(e,t){if(!this._registry)throw new Error("Agent not registered - _registry not set");await this._registry.sendTo(e,{output:t})}async ask(e,t){if(!this._registry)throw new R("Agent not registered - cannot use ask()");let n=this._ctx()?.conversationId??this._conversationId,r=this._ctx()?.isTriggerChannel??this._isTriggerChannel,s=this._ctx()?.triggeringChannel??this._triggeringChannel;if(!n)throw new R("No conversationId available - ask() requires a conversation channel");if(r)throw new R("this.ask() called from a trigger channel (ScheduledChannel). Trigger channels have no human recipient \u2014 use a conversation channel (Slack, Telegram, Webhook) instead.");if(!s||s.trim()==="")throw new R("Cannot use ask() - no triggering channel available. The channel must have a name registered with AgentRegistry.");let i=this._registry.addPendingAsk({conversationId:n,agentName:this.name,question:e,context:t?.context??{},maxRetries:t?.maxRetries??2,expiresAt:t?.expiresIn?new Date(Date.now()+t.expiresIn):void 0,channelName:s});return await this.sendTo(s,e),{output:e,metadata:{waitingForHuman:!0,askId:i.id}}}getPendingAsk(e){if(!this._registry)return null;let t=e??this._ctx()?.conversationId??this._conversationId;return t?this._registry.getPendingAsk(t)??null:null}async resolvePendingAsk(e,t){if(!this._registry)throw new R("Agent not registered - cannot resolve ask");await this._registry.resolvePendingAsk(e,t)}async evaluateAnswer(e,t,n){if(n?.simpleValidation)return n.simpleValidation(t);let r=this._ctx()?.conversationId??this._conversationId;return(await this.run(`Evaluate if this answer sufficiently addresses the question.
29
+ ${Pt}`:"")+ne},W=`${this.name}-replica`,Y=this.description,$=this.model}else re={...U.AGENT_MODE,name:`ephemeral-${E.name}-${Date.now()}`,systemPrompt:E.systemPrompt(q)+ne},W=E.name,Y=E.description,$=E.model;let X=new G(W,Y,re,{toolpack:this.toolpack});$&&(X.model=$),X.spawn={...A};let Et=await X.invokeAgent({message:q,conversationId:`spawn-${Date.now()}`,context:{spawnedBy:this.name,spawnDepth:v+1}});return{output:Et.output,spawnedTemplate:J,depth:v+1,metadata:Et.metadata}}))}}})}}let p={messages:l,model:this.model||"",requestTools:d.length>0?d:void 0,maxToolRounds:t?.maxToolRounds,mode:this.mode,signal:t?.signal},g=null,u,m;if(typeof this.mode!="string"&&this.mode?.streaming){let v="";for await(let A of this.toolpack.stream(p,this.provider))v+=A.delta||"",A.usage&&(u=A.usage);g=v||null,m={content:g,usage:u}}else{let v=await this.toolpack.generate(p,this.provider);g=v.content??null,u=v.usage,m=v}let y={output:g||"",steps:this.extractSteps(m),metadata:u?{usage:u}:void 0};return await this.onComplete(y),s&&await s(!1),this.emit("agent:complete",y),y}catch(l){throw s&&s(!0).catch(d=>{console.error(`[${this.name??"agent"}][AgentMind] Draft buffer flush on error failed:`,d)}),await this.onError(l),this.emit("agent:error",l),l}}getAgentAliases(){let e=[];for(let t of this.channels){let n=t.botUserId;n&&e.push(n)}return e}async sendTo(e,t){if(!this._registry)throw new Error("Agent not registered - _registry not set");await this._registry.sendTo(e,{output:t})}async ask(e,t){if(!this._registry)throw new R("Agent not registered - cannot use ask()");let n=this._ctx()?.conversationId??this._conversationId,r=this._ctx()?.isTriggerChannel??this._isTriggerChannel,s=this._ctx()?.triggeringChannel??this._triggeringChannel;if(!n)throw new R("No conversationId available - ask() requires a conversation channel");if(r)throw new R("this.ask() called from a trigger channel (ScheduledChannel). Trigger channels have no human recipient \u2014 use a conversation channel (Slack, Telegram, Webhook) instead.");if(!s||s.trim()==="")throw new R("Cannot use ask() - no triggering channel available. The channel must have a name registered with AgentRegistry.");let i=this._registry.addPendingAsk({conversationId:n,agentName:this.name,question:e,context:t?.context??{},maxRetries:t?.maxRetries??2,expiresAt:t?.expiresIn?new Date(Date.now()+t.expiresIn):void 0,channelName:s});return await this.sendTo(s,e),{output:e,metadata:{waitingForHuman:!0,askId:i.id}}}getPendingAsk(e){if(!this._registry)return null;let t=e??this._ctx()?.conversationId??this._conversationId;return t?this._registry.getPendingAsk(t)??null:null}async resolvePendingAsk(e,t){if(!this._registry)throw new R("Agent not registered - cannot resolve ask");await this._registry.resolvePendingAsk(e,t)}async evaluateAnswer(e,t,n){if(n?.simpleValidation)return n.simpleValidation(t);let r=this._ctx()?.conversationId??this._conversationId;return(await this.run(`Evaluate if this answer sufficiently addresses the question.
30
30
 
31
31
  Question: "${e}"
32
32
  Answer: "${t}"
package/dist/index.d.cts CHANGED
@@ -1,16 +1,16 @@
1
- import { B as BaseAgentOptions, A as AgentInput, a as AgentResult, d as IAgentRegistry, f as AgentOutput, g as AgentInstance, C as ChannelInterface, P as PendingAsk } from './types-C3EZvpe0.cjs';
2
- export { b as AgentDelegationConfig, e as AgentRunOptions, c as AgentSpawnConfig, h as AgentSpawnTemplate, I as Interceptor, i as InterceptorChainConfig, j as InterceptorContext, k as InterceptorResult, N as NextFunction, S as SKIP_SENTINEL, W as WorkflowStep, l as isSkipSentinel, s as skip } from './types-C3EZvpe0.cjs';
3
- import { B as BaseAgent, A as AgentMindConfig } from './base-agent-DVwGO20L.cjs';
4
- export { a as AgentEvents, C as ConfidenceLevel, G as GoalPriority, b as GoalStatus, M as MindBelief, c as MindEntry, d as MindEntryType, e as MindGoal, f as MindRecallResult, g as MindReflection, h as MindTtlDefaults } from './base-agent-DVwGO20L.cjs';
1
+ import { B as BaseAgentOptions, A as AgentInput, a as AgentResult, d as IAgentRegistry, f as AgentOutput, g as AgentInstance, C as ChannelInterface, P as PendingAsk } from './types-CJinv165.cjs';
2
+ export { b as AgentDelegationConfig, e as AgentRunOptions, c as AgentSpawnConfig, h as AgentSpawnTemplate, I as Interceptor, i as InterceptorChainConfig, j as InterceptorContext, k as InterceptorResult, N as NextFunction, S as SKIP_SENTINEL, W as WorkflowStep, l as isSkipSentinel, s as skip } from './types-CJinv165.cjs';
3
+ import { B as BaseAgent, A as AgentMindConfig } from './base-agent-iaQiO7jW.cjs';
4
+ export { a as AgentEvents, C as ConfidenceLevel, G as GoalPriority, b as GoalStatus, M as MindBelief, c as MindEntry, d as MindEntryType, e as MindGoal, f as MindRecallResult, g as MindReflection, h as MindTtlDefaults } from './base-agent-iaQiO7jW.cjs';
5
5
  import { ModeConfig, ConversationStore, AssemblerOptions, AssembledPrompt, RequestToolDefinition, ToolProject } from 'toolpack-sdk';
6
6
  export { AssembledPrompt, AssemblerOptions, ConversationScope, ConversationStore, GetOptions, InMemoryConversationStore, InMemoryConversationStoreConfig, Participant, PromptMessage, ConversationSearchOptions as SearchOptions, StoredMessage } from 'toolpack-sdk';
7
- import { S as SchedulerStore } from './index-BWrYFJtb.cjs';
8
- export { B as BaseChannel, C as CreateJobOptions, a as CreateJobResult, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, J as JobStatus, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, i as ScheduledJob, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from './index-BWrYFJtb.cjs';
9
- export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from './intent-classifier-agent-DVCbBtdY.cjs';
7
+ import { S as SchedulerStore } from './index-a2wZU6Eu.cjs';
8
+ export { B as BaseChannel, C as CreateJobOptions, a as CreateJobResult, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, J as JobStatus, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, i as ScheduledJob, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from './index-a2wZU6Eu.cjs';
9
+ export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from './intent-classifier-agent-CEmRGpUr.cjs';
10
10
  import { SummarizerAgent } from './capabilities/index.cjs';
11
11
  export { HistoryTurn, SummarizerInput, SummarizerOutput } from './capabilities/index.cjs';
12
12
  export { AddressCheckConfig, AddressCheckResult, CaptureHistoryConfig, ComposedChain, DepthExceededError, DepthGuardConfig, EventDedupConfig, IntentClassifierInterceptorConfig, InvocationDepthExceededError, NoiseFilterConfig, OTelSpan, OTelSpanOptions, OTelSpanStatus, OTelSpanStatusCode, OTelTracer, OTelTracerConfig, OTelTracerProvider, ParticipantResolverConfig, RateLimitConfig, SelfFilterConfig, TracerConfig, composeChain, createAddressCheckInterceptor, createCaptureInterceptor, createDepthGuardInterceptor, createEventDedupInterceptor, createIntentClassifierInterceptor, createNoiseFilterInterceptor, createOTelTracerInterceptor, createParticipantResolverInterceptor, createRateLimitInterceptor, createSelfFilterInterceptor, createTracerInterceptor, executeChain } from './interceptors/index.cjs';
13
- export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from './eval-report-DH2tt6Ad.cjs';
13
+ export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from './eval-report-DUlkrBuJ.cjs';
14
14
  import 'events';
15
15
  import '@toolpack-sdk/knowledge';
16
16
 
package/dist/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- import { B as BaseAgentOptions, A as AgentInput, a as AgentResult, d as IAgentRegistry, f as AgentOutput, g as AgentInstance, C as ChannelInterface, P as PendingAsk } from './types-C3EZvpe0.js';
2
- export { b as AgentDelegationConfig, e as AgentRunOptions, c as AgentSpawnConfig, h as AgentSpawnTemplate, I as Interceptor, i as InterceptorChainConfig, j as InterceptorContext, k as InterceptorResult, N as NextFunction, S as SKIP_SENTINEL, W as WorkflowStep, l as isSkipSentinel, s as skip } from './types-C3EZvpe0.js';
3
- import { B as BaseAgent, A as AgentMindConfig } from './base-agent-BMZWBdkt.js';
4
- export { a as AgentEvents, C as ConfidenceLevel, G as GoalPriority, b as GoalStatus, M as MindBelief, c as MindEntry, d as MindEntryType, e as MindGoal, f as MindRecallResult, g as MindReflection, h as MindTtlDefaults } from './base-agent-BMZWBdkt.js';
1
+ import { B as BaseAgentOptions, A as AgentInput, a as AgentResult, d as IAgentRegistry, f as AgentOutput, g as AgentInstance, C as ChannelInterface, P as PendingAsk } from './types-CJinv165.js';
2
+ export { b as AgentDelegationConfig, e as AgentRunOptions, c as AgentSpawnConfig, h as AgentSpawnTemplate, I as Interceptor, i as InterceptorChainConfig, j as InterceptorContext, k as InterceptorResult, N as NextFunction, S as SKIP_SENTINEL, W as WorkflowStep, l as isSkipSentinel, s as skip } from './types-CJinv165.js';
3
+ import { B as BaseAgent, A as AgentMindConfig } from './base-agent-CJE2QCjY.js';
4
+ export { a as AgentEvents, C as ConfidenceLevel, G as GoalPriority, b as GoalStatus, M as MindBelief, c as MindEntry, d as MindEntryType, e as MindGoal, f as MindRecallResult, g as MindReflection, h as MindTtlDefaults } from './base-agent-CJE2QCjY.js';
5
5
  import { ModeConfig, ConversationStore, AssemblerOptions, AssembledPrompt, RequestToolDefinition, ToolProject } from 'toolpack-sdk';
6
6
  export { AssembledPrompt, AssemblerOptions, ConversationScope, ConversationStore, GetOptions, InMemoryConversationStore, InMemoryConversationStoreConfig, Participant, PromptMessage, ConversationSearchOptions as SearchOptions, StoredMessage } from 'toolpack-sdk';
7
- import { S as SchedulerStore } from './index-BU2BchV0.js';
8
- export { B as BaseChannel, C as CreateJobOptions, a as CreateJobResult, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, J as JobStatus, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, i as ScheduledJob, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from './index-BU2BchV0.js';
9
- export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from './intent-classifier-agent-BnpchAoZ.js';
7
+ import { S as SchedulerStore } from './index-DQuf4mxT.js';
8
+ export { B as BaseChannel, C as CreateJobOptions, a as CreateJobResult, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, J as JobStatus, M as McpChannel, d as McpChannelConfig, e as SMSChannel, f as SMSChannelConfig, g as ScheduledChannel, h as ScheduledChannelConfig, i as ScheduledJob, j as SlackChannel, k as SlackChannelConfig, T as TelegramChannel, l as TelegramChannelConfig, W as WebhookChannel, m as WebhookChannelConfig } from './index-DQuf4mxT.js';
9
+ export { I as IntentClassification, a as IntentClassifierAgent, b as IntentClassifierInput } from './intent-classifier-agent-QuB4WIWf.js';
10
10
  import { SummarizerAgent } from './capabilities/index.js';
11
11
  export { HistoryTurn, SummarizerInput, SummarizerOutput } from './capabilities/index.js';
12
12
  export { AddressCheckConfig, AddressCheckResult, CaptureHistoryConfig, ComposedChain, DepthExceededError, DepthGuardConfig, EventDedupConfig, IntentClassifierInterceptorConfig, InvocationDepthExceededError, NoiseFilterConfig, OTelSpan, OTelSpanOptions, OTelSpanStatus, OTelSpanStatusCode, OTelTracer, OTelTracerConfig, OTelTracerProvider, ParticipantResolverConfig, RateLimitConfig, SelfFilterConfig, TracerConfig, composeChain, createAddressCheckInterceptor, createCaptureInterceptor, createDepthGuardInterceptor, createEventDedupInterceptor, createIntentClassifierInterceptor, createNoiseFilterInterceptor, createOTelTracerInterceptor, createParticipantResolverInterceptor, createRateLimitInterceptor, createSelfFilterInterceptor, createTracerInterceptor, executeChain } from './interceptors/index.js';
13
- export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from './eval-report-BJEzzuSk.js';
13
+ export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from './eval-report-0O9AlW7u.js';
14
14
  import 'events';
15
15
  import '@toolpack-sdk/knowledge';
16
16
 
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@ var Ft=Object.defineProperty;var O=(o,e)=>()=>(o&&(e=o(o=0)),e);var At=(o,e)=>{f
3
3
  `);this.delegation.mode==="forget"?d.push({name:"delegate_and_forget",displayName:"Delegate and Forget",description:`Hand off the current task to a peer agent. The agent will handle its own delivery (e.g. posting to Slack or GitHub) \u2014 you do not need to relay its response. Call this ONCE, then output an empty string.
4
4
 
5
5
  Available agents:
6
- ${T}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:I,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async C=>{let M=String(C.agent),R=String(C.message??"");return this._registry.invoke(M,{message:R,conversationId:r,context:{delegatedBy:this.name}}).catch(_=>{console.error(`[${this.name}] delegate_and_forget to ${M} failed:`,_)}),{status:"delegated",agent:M}}}):d.push({name:"delegate_to_agent",displayName:"Delegate to Agent",description:`Hand off the current task to a peer agent and return its result. Use when the task falls outside your own specialisation.
6
+ ${T}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:I,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async C=>{let M=String(C.agent),R=String(C.message??"");return this._registry.invoke(M,{message:R,conversationId:r,context:{delegatedBy:this.name},signal:t?.signal}).catch(_=>{console.error(`[${this.name}] delegate_and_forget to ${M} failed:`,_)}),{status:"delegated",agent:M}}}):d.push({name:"delegate_to_agent",displayName:"Delegate to Agent",description:`Hand off the current task to a peer agent and return its result. Use when the task falls outside your own specialisation.
7
7
 
8
8
  Available agents:
9
- ${T}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:I,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async C=>{let M=String(C.agent),R=String(C.message??""),_=await this._registry.invoke(M,{message:R,conversationId:r,context:{delegatedBy:this.name}});return{..._,output:`[Response from ${M} \u2014 task complete]
9
+ ${T}`,category:"agent",parameters:{type:"object",properties:{agent:{type:"string",enum:I,description:"Name of the agent to delegate to."},message:{type:"string",description:"The task or message to pass to the agent."}},required:["agent","message"]},execute:async C=>{let M=String(C.agent),R=String(C.message??""),_=await this._registry.invoke(M,{message:R,conversationId:r,context:{delegatedBy:this.name},signal:t?.signal});return{..._,output:`[Response from ${M} \u2014 task complete]
10
10
 
11
11
  ${_.output}`}}})}}if(this.spawn?.enabled&&this.spawn.templates.length>0){let w=n?.spawnDepth??0,b=this.spawn,I=b.maxDepth??3;if(w<I){let T=b.templates,C=T.some(k=>k.name==="self"),M=T.some(k=>k.allowPromptAddition),R=T.filter(k=>k.name!=="self").map(k=>`- ${k.name}: ${k.description}`).join(`
12
12
  `),_=C?`Use template name "self" to spawn a replica of the current agent.
@@ -26,7 +26,7 @@ ${R}
26
26
 
27
27
  ${String($.systemPromptAddition)}`:"",Z,z,W,j;if(U==="self"){let ee=typeof this.mode=="string"?{...fe,name:this.mode}:this.mode,wt=E.systemPrompt(G);Z={...ee,name:`${ee.name}-replica-${Date.now()}`,systemPrompt:(ee.systemPrompt??"")+(wt?`
28
28
 
29
- ${wt}`:"")+Q},z=`${this.name}-replica`,W=this.description,j=this.model}else Z={...fe,name:`ephemeral-${E.name}-${Date.now()}`,systemPrompt:E.systemPrompt(G)+Q},z=E.name,W=E.description,j=E.model;let H=new F(z,W,Z,{toolpack:this.toolpack});j&&(H.model=j),H.spawn={...b};let vt=await H.invokeAgent({message:G,conversationId:`spawn-${Date.now()}`,context:{spawnedBy:this.name,spawnDepth:w+1}});return{output:vt.output,spawnedTemplate:U,depth:w+1,metadata:vt.metadata}}))}}})}}let p={messages:l,model:this.model||"",requestTools:d.length>0?d:void 0,maxToolRounds:t?.maxToolRounds,mode:this.mode},g=null,u,m;if(typeof this.mode!="string"&&this.mode?.streaming){let w="";for await(let b of this.toolpack.stream(p,this.provider))w+=b.delta||"",b.usage&&(u=b.usage);g=w||null,m={content:g,usage:u}}else{let w=await this.toolpack.generate(p,this.provider);g=w.content??null,u=w.usage,m=w}let v={output:g||"",steps:this.extractSteps(m),metadata:u?{usage:u}:void 0};return await this.onComplete(v),s&&await s(!1),this.emit("agent:complete",v),v}catch(l){throw s&&s(!0).catch(d=>{console.error(`[${this.name??"agent"}][AgentMind] Draft buffer flush on error failed:`,d)}),await this.onError(l),this.emit("agent:error",l),l}}getAgentAliases(){let e=[];for(let t of this.channels){let n=t.botUserId;n&&e.push(n)}return e}async sendTo(e,t){if(!this._registry)throw new Error("Agent not registered - _registry not set");await this._registry.sendTo(e,{output:t})}async ask(e,t){if(!this._registry)throw new x("Agent not registered - cannot use ask()");let n=this._ctx()?.conversationId??this._conversationId,r=this._ctx()?.isTriggerChannel??this._isTriggerChannel,s=this._ctx()?.triggeringChannel??this._triggeringChannel;if(!n)throw new x("No conversationId available - ask() requires a conversation channel");if(r)throw new x("this.ask() called from a trigger channel (ScheduledChannel). Trigger channels have no human recipient \u2014 use a conversation channel (Slack, Telegram, Webhook) instead.");if(!s||s.trim()==="")throw new x("Cannot use ask() - no triggering channel available. The channel must have a name registered with AgentRegistry.");let i=this._registry.addPendingAsk({conversationId:n,agentName:this.name,question:e,context:t?.context??{},maxRetries:t?.maxRetries??2,expiresAt:t?.expiresIn?new Date(Date.now()+t.expiresIn):void 0,channelName:s});return await this.sendTo(s,e),{output:e,metadata:{waitingForHuman:!0,askId:i.id}}}getPendingAsk(e){if(!this._registry)return null;let t=e??this._ctx()?.conversationId??this._conversationId;return t?this._registry.getPendingAsk(t)??null:null}async resolvePendingAsk(e,t){if(!this._registry)throw new x("Agent not registered - cannot resolve ask");await this._registry.resolvePendingAsk(e,t)}async evaluateAnswer(e,t,n){if(n?.simpleValidation)return n.simpleValidation(t);let r=this._ctx()?.conversationId??this._conversationId;return(await this.run(`Evaluate if this answer sufficiently addresses the question.
29
+ ${wt}`:"")+Q},z=`${this.name}-replica`,W=this.description,j=this.model}else Z={...fe,name:`ephemeral-${E.name}-${Date.now()}`,systemPrompt:E.systemPrompt(G)+Q},z=E.name,W=E.description,j=E.model;let H=new F(z,W,Z,{toolpack:this.toolpack});j&&(H.model=j),H.spawn={...b};let vt=await H.invokeAgent({message:G,conversationId:`spawn-${Date.now()}`,context:{spawnedBy:this.name,spawnDepth:w+1}});return{output:vt.output,spawnedTemplate:U,depth:w+1,metadata:vt.metadata}}))}}})}}let p={messages:l,model:this.model||"",requestTools:d.length>0?d:void 0,maxToolRounds:t?.maxToolRounds,mode:this.mode,signal:t?.signal},g=null,u,m;if(typeof this.mode!="string"&&this.mode?.streaming){let w="";for await(let b of this.toolpack.stream(p,this.provider))w+=b.delta||"",b.usage&&(u=b.usage);g=w||null,m={content:g,usage:u}}else{let w=await this.toolpack.generate(p,this.provider);g=w.content??null,u=w.usage,m=w}let v={output:g||"",steps:this.extractSteps(m),metadata:u?{usage:u}:void 0};return await this.onComplete(v),s&&await s(!1),this.emit("agent:complete",v),v}catch(l){throw s&&s(!0).catch(d=>{console.error(`[${this.name??"agent"}][AgentMind] Draft buffer flush on error failed:`,d)}),await this.onError(l),this.emit("agent:error",l),l}}getAgentAliases(){let e=[];for(let t of this.channels){let n=t.botUserId;n&&e.push(n)}return e}async sendTo(e,t){if(!this._registry)throw new Error("Agent not registered - _registry not set");await this._registry.sendTo(e,{output:t})}async ask(e,t){if(!this._registry)throw new x("Agent not registered - cannot use ask()");let n=this._ctx()?.conversationId??this._conversationId,r=this._ctx()?.isTriggerChannel??this._isTriggerChannel,s=this._ctx()?.triggeringChannel??this._triggeringChannel;if(!n)throw new x("No conversationId available - ask() requires a conversation channel");if(r)throw new x("this.ask() called from a trigger channel (ScheduledChannel). Trigger channels have no human recipient \u2014 use a conversation channel (Slack, Telegram, Webhook) instead.");if(!s||s.trim()==="")throw new x("Cannot use ask() - no triggering channel available. The channel must have a name registered with AgentRegistry.");let i=this._registry.addPendingAsk({conversationId:n,agentName:this.name,question:e,context:t?.context??{},maxRetries:t?.maxRetries??2,expiresAt:t?.expiresIn?new Date(Date.now()+t.expiresIn):void 0,channelName:s});return await this.sendTo(s,e),{output:e,metadata:{waitingForHuman:!0,askId:i.id}}}getPendingAsk(e){if(!this._registry)return null;let t=e??this._ctx()?.conversationId??this._conversationId;return t?this._registry.getPendingAsk(t)??null:null}async resolvePendingAsk(e,t){if(!this._registry)throw new x("Agent not registered - cannot resolve ask");await this._registry.resolvePendingAsk(e,t)}async evaluateAnswer(e,t,n){if(n?.simpleValidation)return n.simpleValidation(t);let r=this._ctx()?.conversationId??this._conversationId;return(await this.run(`Evaluate if this answer sufficiently addresses the question.
30
30
 
31
31
  Question: "${e}"
32
32
  Answer: "${t}"
@@ -1,5 +1,5 @@
1
- import { B as BaseAgentOptions, A as AgentInput, a as AgentResult } from './types-C3EZvpe0.cjs';
2
- import { B as BaseAgent } from './base-agent-DVwGO20L.cjs';
1
+ import { B as BaseAgentOptions, A as AgentInput, a as AgentResult } from './types-CJinv165.cjs';
2
+ import { B as BaseAgent } from './base-agent-iaQiO7jW.cjs';
3
3
  import { ModeConfig } from 'toolpack-sdk';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { B as BaseAgentOptions, A as AgentInput, a as AgentResult } from './types-C3EZvpe0.js';
2
- import { B as BaseAgent } from './base-agent-BMZWBdkt.js';
1
+ import { B as BaseAgentOptions, A as AgentInput, a as AgentResult } from './types-CJinv165.js';
2
+ import { B as BaseAgent } from './base-agent-CJE2QCjY.js';
3
3
  import { ModeConfig } from 'toolpack-sdk';
4
4
 
5
5
  /**
@@ -1,9 +1,9 @@
1
- import { A as AgentInput, k as InterceptorResult, I as Interceptor, g as AgentInstance, C as ChannelInterface, d as IAgentRegistry, i as InterceptorChainConfig, a as AgentResult } from '../types-C3EZvpe0.cjs';
2
- export { j as InterceptorContext, N as NextFunction, S as SKIP_SENTINEL, l as isSkipSentinel, s as skip } from '../types-C3EZvpe0.cjs';
1
+ import { A as AgentInput, k as InterceptorResult, I as Interceptor, g as AgentInstance, C as ChannelInterface, d as IAgentRegistry, i as InterceptorChainConfig, a as AgentResult } from '../types-CJinv165.cjs';
2
+ export { j as InterceptorContext, N as NextFunction, S as SKIP_SENTINEL, l as isSkipSentinel, s as skip } from '../types-CJinv165.cjs';
3
3
  import { Participant, ConversationStore, ConversationScope, StoredMessage } from 'toolpack-sdk';
4
- import { I as IntentClassification } from '../intent-classifier-agent-DVCbBtdY.cjs';
4
+ import { I as IntentClassification } from '../intent-classifier-agent-CEmRGpUr.cjs';
5
5
  import 'events';
6
- import '../base-agent-DVwGO20L.cjs';
6
+ import '../base-agent-iaQiO7jW.cjs';
7
7
  import '@toolpack-sdk/knowledge';
8
8
 
9
9
  /**
@@ -1,9 +1,9 @@
1
- import { A as AgentInput, k as InterceptorResult, I as Interceptor, g as AgentInstance, C as ChannelInterface, d as IAgentRegistry, i as InterceptorChainConfig, a as AgentResult } from '../types-C3EZvpe0.js';
2
- export { j as InterceptorContext, N as NextFunction, S as SKIP_SENTINEL, l as isSkipSentinel, s as skip } from '../types-C3EZvpe0.js';
1
+ import { A as AgentInput, k as InterceptorResult, I as Interceptor, g as AgentInstance, C as ChannelInterface, d as IAgentRegistry, i as InterceptorChainConfig, a as AgentResult } from '../types-CJinv165.js';
2
+ export { j as InterceptorContext, N as NextFunction, S as SKIP_SENTINEL, l as isSkipSentinel, s as skip } from '../types-CJinv165.js';
3
3
  import { Participant, ConversationStore, ConversationScope, StoredMessage } from 'toolpack-sdk';
4
- import { I as IntentClassification } from '../intent-classifier-agent-BnpchAoZ.js';
4
+ import { I as IntentClassification } from '../intent-classifier-agent-QuB4WIWf.js';
5
5
  import 'events';
6
- import '../base-agent-BMZWBdkt.js';
6
+ import '../base-agent-CJE2QCjY.js';
7
7
  import '@toolpack-sdk/knowledge';
8
8
 
9
9
  /**
@@ -1,8 +1,8 @@
1
- import { C as ChannelInterface, f as AgentOutput, A as AgentInput, B as BaseAgentOptions } from '../types-C3EZvpe0.cjs';
1
+ import { C as ChannelInterface, f as AgentOutput, A as AgentInput, B as BaseAgentOptions } from '../types-CJinv165.cjs';
2
2
  import { Chunk, QueryOptions, QueryResult, Knowledge } from '@toolpack-sdk/knowledge';
3
3
  import { Toolpack } from 'toolpack-sdk';
4
- import { B as BaseAgent } from '../base-agent-DVwGO20L.cjs';
5
- export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from '../eval-report-DH2tt6Ad.cjs';
4
+ import { B as BaseAgent } from '../base-agent-iaQiO7jW.cjs';
5
+ export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from '../eval-report-DUlkrBuJ.cjs';
6
6
  import 'events';
7
7
 
8
8
  /**
@@ -1,8 +1,8 @@
1
- import { C as ChannelInterface, f as AgentOutput, A as AgentInput, B as BaseAgentOptions } from '../types-C3EZvpe0.js';
1
+ import { C as ChannelInterface, f as AgentOutput, A as AgentInput, B as BaseAgentOptions } from '../types-CJinv165.js';
2
2
  import { Chunk, QueryOptions, QueryResult, Knowledge } from '@toolpack-sdk/knowledge';
3
3
  import { Toolpack } from 'toolpack-sdk';
4
- import { B as BaseAgent } from '../base-agent-BMZWBdkt.js';
5
- export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from '../eval-report-BJEzzuSk.js';
4
+ import { B as BaseAgent } from '../base-agent-CJE2QCjY.js';
5
+ export { C as ContainsScorer, a as CustomScorer, E as EvalCase, b as EvalCaseResult, c as EvalDataset, d as EvalImprovement, e as EvalRegression, f as EvalReport, g as EvalRun, h as EvalRunner, i as EvalRunnerOptions, j as EvalScoredResult, k as EvalScoredRun, l as EvalScorer, m as EvalVerdict, n as ExactMatchScorer, L as LLMJudgeScorer, o as LLMJudgeScorerOptions, p as compareEvalRuns, q as formatEvalReport } from '../eval-report-0O9AlW7u.js';
6
6
  import 'events';
7
7
 
8
8
  /**
@@ -218,6 +218,8 @@ interface AgentInput<TIntent extends string = string> {
218
218
  * Interceptors such as `participant-resolver` read and/or enrich this.
219
219
  */
220
220
  participant?: Participant;
221
+ /** Optional abort signal — when aborted, the running LLM stream stops at the next round boundary. */
222
+ signal?: AbortSignal;
221
223
  }
222
224
  /**
223
225
  * Represents a step in a workflow execution.
@@ -270,6 +272,8 @@ interface AgentRunOptions {
270
272
  * per invocation (e.g. single-shot routers using delegate_to_agent).
271
273
  */
272
274
  maxToolRounds?: number;
275
+ /** Optional abort signal — propagated to the underlying AIClient stream/generate call. */
276
+ signal?: AbortSignal;
273
277
  }
274
278
  /**
275
279
  * Agent instance interface - shape of a BaseAgent instance.
@@ -218,6 +218,8 @@ interface AgentInput<TIntent extends string = string> {
218
218
  * Interceptors such as `participant-resolver` read and/or enrich this.
219
219
  */
220
220
  participant?: Participant;
221
+ /** Optional abort signal — when aborted, the running LLM stream stops at the next round boundary. */
222
+ signal?: AbortSignal;
221
223
  }
222
224
  /**
223
225
  * Represents a step in a workflow execution.
@@ -270,6 +272,8 @@ interface AgentRunOptions {
270
272
  * per invocation (e.g. single-shot routers using delegate_to_agent).
271
273
  */
272
274
  maxToolRounds?: number;
275
+ /** Optional abort signal — propagated to the underlying AIClient stream/generate call. */
276
+ signal?: AbortSignal;
273
277
  }
274
278
  /**
275
279
  * Agent instance interface - shape of a BaseAgent instance.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolpack-sdk/agents",
3
- "version": "2.7.0",
3
+ "version": "3.0.0",
4
4
  "description": "Production AI agents for Toolpack SDK — 8 channel integrations (Slack, Discord, Telegram, SMS, Email, Webhook, Scheduled, MCP), AgentMind persistent cognitive layer (goals, beliefs, reflections), interceptors, evals, and multi-agent coordination",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -89,11 +89,11 @@
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@opentelemetry/api": "^1.x",
92
- "@toolpack-sdk/knowledge": "^2.7.0",
92
+ "@toolpack-sdk/knowledge": "^3.0.0",
93
93
  "better-sqlite3": "^12.6.2",
94
94
  "discord.js": "^14.x",
95
95
  "nodemailer": "^6.x",
96
- "toolpack-sdk": "^2.7.0",
96
+ "toolpack-sdk": "^3.0.0",
97
97
  "twilio": "^5.x"
98
98
  },
99
99
  "peerDependenciesMeta": {