@ariaflowagents/core 0.7.1 → 0.9.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.
Files changed (338) hide show
  1. package/README.md +90 -1
  2. package/dist/agents/Agent.d.ts +188 -9
  3. package/dist/agents/Agent.d.ts.map +1 -1
  4. package/dist/agents/Agent.js +246 -24
  5. package/dist/agents/Agent.js.map +1 -1
  6. package/dist/agents/CompositeAgent.d.ts +4 -3
  7. package/dist/agents/CompositeAgent.d.ts.map +1 -1
  8. package/dist/agents/CompositeAgent.js +19 -9
  9. package/dist/agents/CompositeAgent.js.map +1 -1
  10. package/dist/agents/FlowAgent.d.ts +3 -2
  11. package/dist/agents/FlowAgent.d.ts.map +1 -1
  12. package/dist/agents/FlowAgent.js +16 -6
  13. package/dist/agents/FlowAgent.js.map +1 -1
  14. package/dist/agents/TriageAgent.d.ts +8 -2
  15. package/dist/agents/TriageAgent.d.ts.map +1 -1
  16. package/dist/agents/TriageAgent.js +39 -6
  17. package/dist/agents/TriageAgent.js.map +1 -1
  18. package/dist/agents/index.d.ts +1 -1
  19. package/dist/agents/index.d.ts.map +1 -1
  20. package/dist/agents/index.js +0 -1
  21. package/dist/agents/index.js.map +1 -1
  22. package/dist/capabilities/AutoRetrieveCapability.d.ts +30 -0
  23. package/dist/capabilities/AutoRetrieveCapability.d.ts.map +1 -0
  24. package/dist/capabilities/AutoRetrieveCapability.js +36 -0
  25. package/dist/capabilities/AutoRetrieveCapability.js.map +1 -0
  26. package/dist/capabilities/ExtractionCapability.d.ts +25 -0
  27. package/dist/capabilities/ExtractionCapability.d.ts.map +1 -0
  28. package/dist/capabilities/ExtractionCapability.js +74 -0
  29. package/dist/capabilities/ExtractionCapability.js.map +1 -0
  30. package/dist/capabilities/FlowCapability.d.ts +81 -0
  31. package/dist/capabilities/FlowCapability.d.ts.map +1 -0
  32. package/dist/capabilities/FlowCapability.js +482 -0
  33. package/dist/capabilities/FlowCapability.js.map +1 -0
  34. package/dist/capabilities/GuardrailCapability.d.ts +30 -0
  35. package/dist/capabilities/GuardrailCapability.d.ts.map +1 -0
  36. package/dist/capabilities/GuardrailCapability.js +38 -0
  37. package/dist/capabilities/GuardrailCapability.js.map +1 -0
  38. package/dist/capabilities/HandoffCapability.d.ts +19 -0
  39. package/dist/capabilities/HandoffCapability.d.ts.map +1 -0
  40. package/dist/capabilities/HandoffCapability.js +58 -0
  41. package/dist/capabilities/HandoffCapability.js.map +1 -0
  42. package/dist/capabilities/LivePromptAssembler.d.ts +108 -0
  43. package/dist/capabilities/LivePromptAssembler.d.ts.map +1 -0
  44. package/dist/capabilities/LivePromptAssembler.js +157 -0
  45. package/dist/capabilities/LivePromptAssembler.js.map +1 -0
  46. package/dist/capabilities/TriageCapability.d.ts +16 -0
  47. package/dist/capabilities/TriageCapability.d.ts.map +1 -0
  48. package/dist/capabilities/TriageCapability.js +61 -0
  49. package/dist/capabilities/TriageCapability.js.map +1 -0
  50. package/dist/capabilities/adapters/ai-sdk.d.ts +14 -0
  51. package/dist/capabilities/adapters/ai-sdk.d.ts.map +1 -0
  52. package/dist/capabilities/adapters/ai-sdk.js +29 -0
  53. package/dist/capabilities/adapters/ai-sdk.js.map +1 -0
  54. package/dist/capabilities/adapters/gemini.d.ts +15 -0
  55. package/dist/capabilities/adapters/gemini.d.ts.map +1 -0
  56. package/dist/capabilities/adapters/gemini.js +40 -0
  57. package/dist/capabilities/adapters/gemini.js.map +1 -0
  58. package/dist/capabilities/index.d.ts +154 -0
  59. package/dist/capabilities/index.d.ts.map +1 -0
  60. package/dist/capabilities/index.js +128 -0
  61. package/dist/capabilities/index.js.map +1 -0
  62. package/dist/eval/EvalRunner.d.ts +12 -0
  63. package/dist/eval/EvalRunner.d.ts.map +1 -0
  64. package/dist/eval/EvalRunner.js +64 -0
  65. package/dist/eval/EvalRunner.js.map +1 -0
  66. package/dist/eval/scoring.d.ts +15 -0
  67. package/dist/eval/scoring.d.ts.map +1 -0
  68. package/dist/eval/scoring.js +152 -0
  69. package/dist/eval/scoring.js.map +1 -0
  70. package/dist/eval/types.d.ts +59 -0
  71. package/dist/eval/types.d.ts.map +1 -0
  72. package/dist/eval/types.js +2 -0
  73. package/dist/eval/types.js.map +1 -0
  74. package/dist/flows/FlowGraph.d.ts +3 -1
  75. package/dist/flows/FlowGraph.d.ts.map +1 -1
  76. package/dist/flows/FlowGraph.js +5 -0
  77. package/dist/flows/FlowGraph.js.map +1 -1
  78. package/dist/flows/FlowManager.d.ts +68 -1
  79. package/dist/flows/FlowManager.d.ts.map +1 -1
  80. package/dist/flows/FlowManager.js +499 -36
  81. package/dist/flows/FlowManager.js.map +1 -1
  82. package/dist/flows/extraction.d.ts +16 -1
  83. package/dist/flows/extraction.d.ts.map +1 -1
  84. package/dist/flows/extraction.js +34 -0
  85. package/dist/flows/extraction.js.map +1 -1
  86. package/dist/flows/index.d.ts +2 -0
  87. package/dist/flows/index.d.ts.map +1 -1
  88. package/dist/flows/index.js +1 -0
  89. package/dist/flows/index.js.map +1 -1
  90. package/dist/flows/validation.d.ts +1 -1
  91. package/dist/flows/validation.d.ts.map +1 -1
  92. package/dist/flows/validation.js +13 -1
  93. package/dist/flows/validation.js.map +1 -1
  94. package/dist/foundation/AgentDefinition.d.ts +18 -0
  95. package/dist/foundation/AgentDefinition.d.ts.map +1 -0
  96. package/dist/foundation/AgentDefinition.js +2 -0
  97. package/dist/foundation/AgentDefinition.js.map +1 -0
  98. package/dist/foundation/AgentStateController.d.ts +26 -0
  99. package/dist/foundation/AgentStateController.d.ts.map +1 -0
  100. package/dist/foundation/AgentStateController.js +2 -0
  101. package/dist/foundation/AgentStateController.js.map +1 -0
  102. package/dist/foundation/ConversationEventLog.d.ts +72 -0
  103. package/dist/foundation/ConversationEventLog.d.ts.map +1 -0
  104. package/dist/foundation/ConversationEventLog.js +2 -0
  105. package/dist/foundation/ConversationEventLog.js.map +1 -0
  106. package/dist/foundation/ConversationState.d.ts +31 -0
  107. package/dist/foundation/ConversationState.d.ts.map +1 -0
  108. package/dist/foundation/ConversationState.js +2 -0
  109. package/dist/foundation/ConversationState.js.map +1 -0
  110. package/dist/foundation/DefaultAgentStateController.d.ts +24 -0
  111. package/dist/foundation/DefaultAgentStateController.d.ts.map +1 -0
  112. package/dist/foundation/DefaultAgentStateController.js +49 -0
  113. package/dist/foundation/DefaultAgentStateController.js.map +1 -0
  114. package/dist/foundation/DefaultConversationEventLog.d.ts +28 -0
  115. package/dist/foundation/DefaultConversationEventLog.d.ts.map +1 -0
  116. package/dist/foundation/DefaultConversationEventLog.js +195 -0
  117. package/dist/foundation/DefaultConversationEventLog.js.map +1 -0
  118. package/dist/foundation/DefaultConversationState.d.ts +34 -0
  119. package/dist/foundation/DefaultConversationState.d.ts.map +1 -0
  120. package/dist/foundation/DefaultConversationState.js +100 -0
  121. package/dist/foundation/DefaultConversationState.js.map +1 -0
  122. package/dist/foundation/DefaultToolExecutor.d.ts +58 -0
  123. package/dist/foundation/DefaultToolExecutor.d.ts.map +1 -0
  124. package/dist/foundation/DefaultToolExecutor.js +128 -0
  125. package/dist/foundation/DefaultToolExecutor.js.map +1 -0
  126. package/dist/foundation/ToolExecutor.d.ts +44 -0
  127. package/dist/foundation/ToolExecutor.d.ts.map +1 -0
  128. package/dist/foundation/ToolExecutor.js +2 -0
  129. package/dist/foundation/ToolExecutor.js.map +1 -0
  130. package/dist/foundation/createFoundation.d.ts +33 -0
  131. package/dist/foundation/createFoundation.d.ts.map +1 -0
  132. package/dist/foundation/createFoundation.js +34 -0
  133. package/dist/foundation/createFoundation.js.map +1 -0
  134. package/dist/foundation/index.d.ts +15 -0
  135. package/dist/foundation/index.d.ts.map +1 -0
  136. package/dist/foundation/index.js +8 -0
  137. package/dist/foundation/index.js.map +1 -0
  138. package/dist/hooks/HookRunner.d.ts +5 -1
  139. package/dist/hooks/HookRunner.d.ts.map +1 -1
  140. package/dist/hooks/HookRunner.js +7 -0
  141. package/dist/hooks/HookRunner.js.map +1 -1
  142. package/dist/hooks/builtin/metrics.d.ts.map +1 -1
  143. package/dist/hooks/builtin/metrics.js +12 -0
  144. package/dist/hooks/builtin/metrics.js.map +1 -1
  145. package/dist/hooks/builtin/observability.d.ts +21 -0
  146. package/dist/hooks/builtin/observability.d.ts.map +1 -0
  147. package/dist/hooks/builtin/observability.js +535 -0
  148. package/dist/hooks/builtin/observability.js.map +1 -0
  149. package/dist/index.d.ts +24 -3
  150. package/dist/index.d.ts.map +1 -1
  151. package/dist/index.js +16 -2
  152. package/dist/index.js.map +1 -1
  153. package/dist/memory/MemoryService.d.ts +40 -0
  154. package/dist/memory/MemoryService.d.ts.map +1 -0
  155. package/dist/memory/MemoryService.js +2 -0
  156. package/dist/memory/MemoryService.js.map +1 -0
  157. package/dist/memory/index.d.ts +5 -0
  158. package/dist/memory/index.d.ts.map +1 -0
  159. package/dist/memory/index.js +3 -0
  160. package/dist/memory/index.js.map +1 -0
  161. package/dist/memory/preloadMemory.d.ts +17 -0
  162. package/dist/memory/preloadMemory.d.ts.map +1 -0
  163. package/dist/memory/preloadMemory.js +62 -0
  164. package/dist/memory/preloadMemory.js.map +1 -0
  165. package/dist/memory/stores/InMemoryMemoryService.d.ts +20 -0
  166. package/dist/memory/stores/InMemoryMemoryService.d.ts.map +1 -0
  167. package/dist/memory/stores/InMemoryMemoryService.js +92 -0
  168. package/dist/memory/stores/InMemoryMemoryService.js.map +1 -0
  169. package/dist/memory/types.d.ts +49 -0
  170. package/dist/memory/types.d.ts.map +1 -0
  171. package/dist/memory/types.js +8 -0
  172. package/dist/memory/types.js.map +1 -0
  173. package/dist/orchestration/DefaultOrchestrationAuthority.d.ts +91 -0
  174. package/dist/orchestration/DefaultOrchestrationAuthority.d.ts.map +1 -0
  175. package/dist/orchestration/DefaultOrchestrationAuthority.js +786 -0
  176. package/dist/orchestration/DefaultOrchestrationAuthority.js.map +1 -0
  177. package/dist/orchestration/OrchestrationAuthority.d.ts +119 -0
  178. package/dist/orchestration/OrchestrationAuthority.d.ts.map +1 -0
  179. package/dist/orchestration/OrchestrationAuthority.js +2 -0
  180. package/dist/orchestration/OrchestrationAuthority.js.map +1 -0
  181. package/dist/orchestration/RealtimeExtractionRunner.d.ts +25 -0
  182. package/dist/orchestration/RealtimeExtractionRunner.d.ts.map +1 -0
  183. package/dist/orchestration/RealtimeExtractionRunner.js +62 -0
  184. package/dist/orchestration/RealtimeExtractionRunner.js.map +1 -0
  185. package/dist/orchestration/index.d.ts +5 -0
  186. package/dist/orchestration/index.d.ts.map +1 -0
  187. package/dist/orchestration/index.js +4 -0
  188. package/dist/orchestration/index.js.map +1 -0
  189. package/dist/orchestration/types.d.ts +134 -0
  190. package/dist/orchestration/types.d.ts.map +1 -0
  191. package/dist/orchestration/types.js +2 -0
  192. package/dist/orchestration/types.js.map +1 -0
  193. package/dist/prompts/AgentPrompt.d.ts +110 -0
  194. package/dist/prompts/AgentPrompt.d.ts.map +1 -0
  195. package/dist/prompts/AgentPrompt.js +373 -0
  196. package/dist/prompts/AgentPrompt.js.map +1 -0
  197. package/dist/prompts/PromptAssembly.d.ts +119 -0
  198. package/dist/prompts/PromptAssembly.d.ts.map +1 -0
  199. package/dist/prompts/PromptAssembly.js +150 -0
  200. package/dist/prompts/PromptAssembly.js.map +1 -0
  201. package/dist/prompts/PromptBuilder.d.ts +22 -3
  202. package/dist/prompts/PromptBuilder.d.ts.map +1 -1
  203. package/dist/prompts/PromptBuilder.js +242 -13
  204. package/dist/prompts/PromptBuilder.js.map +1 -1
  205. package/dist/prompts/PromptRenderer.d.ts +43 -0
  206. package/dist/prompts/PromptRenderer.d.ts.map +1 -0
  207. package/dist/prompts/PromptRenderer.js +114 -0
  208. package/dist/prompts/PromptRenderer.js.map +1 -0
  209. package/dist/prompts/brandVoice.d.ts +10 -0
  210. package/dist/prompts/brandVoice.d.ts.map +1 -0
  211. package/dist/prompts/brandVoice.js +87 -0
  212. package/dist/prompts/brandVoice.js.map +1 -0
  213. package/dist/prompts/index.d.ts +11 -4
  214. package/dist/prompts/index.d.ts.map +1 -1
  215. package/dist/prompts/index.js +7 -2
  216. package/dist/prompts/index.js.map +1 -1
  217. package/dist/prompts/security.d.ts +5 -0
  218. package/dist/prompts/security.d.ts.map +1 -0
  219. package/dist/prompts/security.js +52 -0
  220. package/dist/prompts/security.js.map +1 -0
  221. package/dist/prompts/types.d.ts +65 -1
  222. package/dist/prompts/types.d.ts.map +1 -1
  223. package/dist/prompts/types.js +26 -0
  224. package/dist/prompts/types.js.map +1 -1
  225. package/dist/realtime/RealtimeAudioClient.d.ts +105 -0
  226. package/dist/realtime/RealtimeAudioClient.d.ts.map +1 -0
  227. package/dist/realtime/RealtimeAudioClient.js +15 -0
  228. package/dist/realtime/RealtimeAudioClient.js.map +1 -0
  229. package/dist/realtime/RealtimeRuntime.d.ts +136 -0
  230. package/dist/realtime/RealtimeRuntime.d.ts.map +1 -0
  231. package/dist/realtime/RealtimeRuntime.js +270 -0
  232. package/dist/realtime/RealtimeRuntime.js.map +1 -0
  233. package/dist/realtime/index.d.ts +4 -0
  234. package/dist/realtime/index.d.ts.map +1 -0
  235. package/dist/realtime/index.js +2 -0
  236. package/dist/realtime/index.js.map +1 -0
  237. package/dist/runtime/ContextBudget.d.ts +57 -0
  238. package/dist/runtime/ContextBudget.d.ts.map +1 -0
  239. package/dist/runtime/ContextBudget.js +103 -0
  240. package/dist/runtime/ContextBudget.js.map +1 -0
  241. package/dist/runtime/ContextManager.d.ts +8 -5
  242. package/dist/runtime/ContextManager.d.ts.map +1 -1
  243. package/dist/runtime/ContextManager.js +47 -14
  244. package/dist/runtime/ContextManager.js.map +1 -1
  245. package/dist/runtime/ExtractionEngine.d.ts +2 -1
  246. package/dist/runtime/ExtractionEngine.d.ts.map +1 -1
  247. package/dist/runtime/ExtractionEngine.js +11 -0
  248. package/dist/runtime/ExtractionEngine.js.map +1 -1
  249. package/dist/runtime/FlowExecutor.d.ts +22 -15
  250. package/dist/runtime/FlowExecutor.d.ts.map +1 -1
  251. package/dist/runtime/FlowExecutor.js +102 -149
  252. package/dist/runtime/FlowExecutor.js.map +1 -1
  253. package/dist/runtime/Runtime.d.ts +53 -78
  254. package/dist/runtime/Runtime.d.ts.map +1 -1
  255. package/dist/runtime/Runtime.js +272 -1406
  256. package/dist/runtime/Runtime.js.map +1 -1
  257. package/dist/runtime/SessionCache.d.ts +16 -0
  258. package/dist/runtime/SessionCache.d.ts.map +1 -0
  259. package/dist/runtime/SessionCache.js +49 -0
  260. package/dist/runtime/SessionCache.js.map +1 -0
  261. package/dist/runtime/SessionMutex.d.ts +37 -0
  262. package/dist/runtime/SessionMutex.d.ts.map +1 -0
  263. package/dist/runtime/SessionMutex.js +59 -0
  264. package/dist/runtime/SessionMutex.js.map +1 -0
  265. package/dist/runtime/StreamEmitter.d.ts +34 -0
  266. package/dist/runtime/StreamEmitter.d.ts.map +1 -0
  267. package/dist/runtime/StreamEmitter.js +91 -0
  268. package/dist/runtime/StreamEmitter.js.map +1 -0
  269. package/dist/runtime/handoffFilters.d.ts +60 -0
  270. package/dist/runtime/handoffFilters.d.ts.map +1 -0
  271. package/dist/runtime/handoffFilters.js +95 -0
  272. package/dist/runtime/handoffFilters.js.map +1 -0
  273. package/dist/runtime/pipeline/AgentExecuteStage.d.ts +22 -0
  274. package/dist/runtime/pipeline/AgentExecuteStage.d.ts.map +1 -0
  275. package/dist/runtime/pipeline/AgentExecuteStage.js +958 -0
  276. package/dist/runtime/pipeline/AgentExecuteStage.js.map +1 -0
  277. package/dist/runtime/pipeline/ContextAssembleStage.d.ts +26 -0
  278. package/dist/runtime/pipeline/ContextAssembleStage.d.ts.map +1 -0
  279. package/dist/runtime/pipeline/ContextAssembleStage.js +253 -0
  280. package/dist/runtime/pipeline/ContextAssembleStage.js.map +1 -0
  281. package/dist/runtime/pipeline/ContextGatherStage.d.ts +21 -0
  282. package/dist/runtime/pipeline/ContextGatherStage.d.ts.map +1 -0
  283. package/dist/runtime/pipeline/ContextGatherStage.js +161 -0
  284. package/dist/runtime/pipeline/ContextGatherStage.js.map +1 -0
  285. package/dist/runtime/pipeline/IntakeStage.d.ts +25 -0
  286. package/dist/runtime/pipeline/IntakeStage.d.ts.map +1 -0
  287. package/dist/runtime/pipeline/IntakeStage.js +126 -0
  288. package/dist/runtime/pipeline/IntakeStage.js.map +1 -0
  289. package/dist/runtime/pipeline/PostStreamStage.d.ts +26 -0
  290. package/dist/runtime/pipeline/PostStreamStage.d.ts.map +1 -0
  291. package/dist/runtime/pipeline/PostStreamStage.js +129 -0
  292. package/dist/runtime/pipeline/PostStreamStage.js.map +1 -0
  293. package/dist/runtime/pipeline/TurnPipeline.d.ts +54 -0
  294. package/dist/runtime/pipeline/TurnPipeline.d.ts.map +1 -0
  295. package/dist/runtime/pipeline/TurnPipeline.js +15 -0
  296. package/dist/runtime/pipeline/TurnPipeline.js.map +1 -0
  297. package/dist/runtime/pipeline/TurnServices.d.ts +48 -0
  298. package/dist/runtime/pipeline/TurnServices.d.ts.map +1 -0
  299. package/dist/runtime/pipeline/TurnServices.js +2 -0
  300. package/dist/runtime/pipeline/TurnServices.js.map +1 -0
  301. package/dist/runtime/pipeline/agentTypeGuards.d.ts +4 -0
  302. package/dist/runtime/pipeline/agentTypeGuards.d.ts.map +1 -0
  303. package/dist/runtime/pipeline/agentTypeGuards.js +7 -0
  304. package/dist/runtime/pipeline/agentTypeGuards.js.map +1 -0
  305. package/dist/runtime/pipeline/index.d.ts +11 -0
  306. package/dist/runtime/pipeline/index.d.ts.map +1 -0
  307. package/dist/runtime/pipeline/index.js +13 -0
  308. package/dist/runtime/pipeline/index.js.map +1 -0
  309. package/dist/runtime/pipeline/outputProcessing.d.ts +23 -0
  310. package/dist/runtime/pipeline/outputProcessing.d.ts.map +1 -0
  311. package/dist/runtime/pipeline/outputProcessing.js +63 -0
  312. package/dist/runtime/pipeline/outputProcessing.js.map +1 -0
  313. package/dist/runtime/pipeline/sessionUtils.d.ts +12 -0
  314. package/dist/runtime/pipeline/sessionUtils.d.ts.map +1 -0
  315. package/dist/runtime/pipeline/sessionUtils.js +73 -0
  316. package/dist/runtime/pipeline/sessionUtils.js.map +1 -0
  317. package/dist/tools/Tool.d.ts +7 -0
  318. package/dist/tools/Tool.d.ts.map +1 -1
  319. package/dist/tools/Tool.js +12 -3
  320. package/dist/tools/Tool.js.map +1 -1
  321. package/dist/tools/memory.d.ts +26 -0
  322. package/dist/tools/memory.d.ts.map +1 -0
  323. package/dist/tools/memory.js +51 -0
  324. package/dist/tools/memory.js.map +1 -0
  325. package/dist/types/index.d.ts +238 -9
  326. package/dist/types/index.d.ts.map +1 -1
  327. package/dist/types/index.js +4 -0
  328. package/dist/types/index.js.map +1 -1
  329. package/dist/types/telemetry.d.ts +107 -0
  330. package/dist/types/telemetry.d.ts.map +1 -1
  331. package/guides/AGENTS.md +173 -0
  332. package/guides/README.md +12 -0
  333. package/guides/TOOLS.md +93 -27
  334. package/package.json +25 -4
  335. package/dist/agents/LLMAgent.d.ts +0 -11
  336. package/dist/agents/LLMAgent.d.ts.map +0 -1
  337. package/dist/agents/LLMAgent.js +0 -31
  338. package/dist/agents/LLMAgent.js.map +0 -1
@@ -0,0 +1,482 @@
1
+ import { z } from 'zod';
2
+ import { isExtractionNode } from '../types/index.js';
3
+ import { createFlowTransition, isFlowTransition } from '../flows/transitions.js';
4
+ import { isHandoffResult } from '../tools/handoff.js';
5
+ import { isFinalResult } from '../tools/final.js';
6
+ import { mergeExtractionData, computeMissingFields, toExtractionSubmissionSchema } from '../flows/extraction.js';
7
+ import { validateFlowConfig } from '../flows/validation.js';
8
+ import { renderNodePrompt } from '../flows/template.js';
9
+ // ─── Constants ───────────────────────────────────────────────────────────────
10
+ const DEFAULT_MAX_OSCILLATIONS = 2;
11
+ const transitionToolInputSchema = z.object({
12
+ data: z.record(z.unknown()).optional().describe('Optional data to pass to the next node'),
13
+ message: z.string().optional().describe('Optional message explaining the transition'),
14
+ });
15
+ // ─── FlowCapability ──────────────────────────────────────────────────────────
16
+ /**
17
+ * Headless flow state machine that exposes flow behavior as tools.
18
+ *
19
+ * Owns: node graph, transitions, current node, collectedData,
20
+ * oscillation tracking, extraction node handling, contract validation.
21
+ *
22
+ * Does NOT own: LLM calls, streaming, AI SDK imports. The host
23
+ * (Gemini Live, AI SDK, LiveKit) handles inference.
24
+ */
25
+ export class FlowCapability {
26
+ nodes = new Map();
27
+ transitions = new Map();
28
+ context;
29
+ currentNodeConfig = null;
30
+ initialized = false;
31
+ flowEnded = false;
32
+ _justTransitioned = null;
33
+ maxOscillations;
34
+ defaultRolePrompt;
35
+ /** Tracks transition edges within a single process() call for oscillation detection. */
36
+ turnTransitionCounts = new Map();
37
+ /** Events emitted during transitions (node-enter, node-exit, flow-transition, etc.). */
38
+ pendingEvents = [];
39
+ constructor(config) {
40
+ validateFlowConfig(config.flow, config.initialNode);
41
+ this.maxOscillations = config.flow.maxOscillations ?? DEFAULT_MAX_OSCILLATIONS;
42
+ this.defaultRolePrompt = config.defaultRolePrompt ?? config.flow.defaultRolePrompt;
43
+ for (const node of config.flow.nodes) {
44
+ this.nodes.set(node.id, node);
45
+ }
46
+ for (const transition of config.flow.transitions ?? []) {
47
+ const existing = this.transitions.get(transition.from) ?? [];
48
+ existing.push(transition);
49
+ this.transitions.set(transition.from, existing);
50
+ }
51
+ if (config.state) {
52
+ this.context = config.state.context;
53
+ this.initialized = config.state.initialized;
54
+ this.flowEnded = config.state.flowEnded;
55
+ if (this.initialized) {
56
+ this.currentNodeConfig = this.nodes.get(this.context.currentNode) ?? null;
57
+ }
58
+ }
59
+ else {
60
+ this.context = {
61
+ currentNode: config.initialNode,
62
+ collectedData: {},
63
+ nodeHistory: [],
64
+ nodeTurnCounts: {},
65
+ messages: [],
66
+ };
67
+ }
68
+ }
69
+ // ─── Capability Interface ────────────────────────────────────────────────
70
+ getTools() {
71
+ if (!this.currentNodeConfig || this.flowEnded)
72
+ return [];
73
+ const tools = [];
74
+ // 1. Implicit transition tools from outbound edges
75
+ const nodeTransitions = this.transitions.get(this.currentNodeConfig.id) ?? [];
76
+ const seenNames = new Set();
77
+ for (const t of nodeTransitions) {
78
+ const eventName = typeof t.on === 'string' ? t.on.trim() : '';
79
+ if (!eventName || seenNames.has(eventName))
80
+ continue;
81
+ seenNames.add(eventName);
82
+ const descParts = [
83
+ `Transition from "${this.currentNodeConfig.id}" to "${t.to}".`,
84
+ t.contract?.label ? `Label: ${t.contract.label}.` : '',
85
+ t.contract?.conditionText ? `Condition: ${t.contract.conditionText}.` : '',
86
+ 'Call only when transition criteria are satisfied.',
87
+ ].filter(Boolean);
88
+ const targetNode = t.to;
89
+ tools.push({
90
+ name: eventName,
91
+ description: descParts.join(' '),
92
+ parameters: transitionToolInputSchema,
93
+ execute: async (args) => createFlowTransition(targetNode, args.data, args.message),
94
+ });
95
+ }
96
+ // 2. Extraction tool (if current node is extraction type)
97
+ if (isExtractionNode(this.currentNodeConfig)) {
98
+ const node = this.currentNodeConfig;
99
+ const missing = this.getMissingExtractionFields(node);
100
+ tools.push({
101
+ name: `submit_${node.id}_data`,
102
+ description: [
103
+ `Submit collected information for "${node.name ?? node.id}".`,
104
+ `Extract these fields from the conversation.`,
105
+ missing.length > 0 ? `Still needed: ${missing.join(', ')}.` : 'All fields collected.',
106
+ 'Only submit values explicitly provided by the user.',
107
+ 'Omit fields or use null when the value is still unknown.',
108
+ 'Call this tool every time you learn new field values.',
109
+ 'After submitting: acknowledge what was received in a brief spoken sentence, then ask for only the next missing field.',
110
+ ].join(' '),
111
+ parameters: toExtractionSubmissionSchema(node.extractionSchema),
112
+ execute: async (args) => args, // pass through — processToolResult handles merging
113
+ });
114
+ }
115
+ // 3. Explicit node tools
116
+ const nodeTools = typeof this.currentNodeConfig.tools === 'function'
117
+ ? this.currentNodeConfig.tools(this.context)
118
+ : this.currentNodeConfig.tools;
119
+ if (nodeTools) {
120
+ const hints = this.currentNodeConfig.toolHints;
121
+ for (const [name, toolDef] of Object.entries(nodeTools)) {
122
+ if (seenNames.has(name))
123
+ continue; // explicit tools don't override implicit
124
+ const baseDesc = toolDef.description ?? '';
125
+ const hint = hints?.[name];
126
+ const enhancedDesc = hint
127
+ ? [
128
+ baseDesc,
129
+ hint.invocationCondition ? `INVOCATION: ${hint.invocationCondition}` : '',
130
+ hint.afterResult ? `AFTER RESULT: ${hint.afterResult}` : '',
131
+ ].filter(Boolean).join(' ')
132
+ : baseDesc;
133
+ tools.push({
134
+ name,
135
+ description: enhancedDesc,
136
+ parameters: toolDef.parameters ?? toolDef.inputSchema ?? z.object({}),
137
+ execute: toolDef.execute,
138
+ });
139
+ }
140
+ }
141
+ return tools;
142
+ }
143
+ getPromptSections() {
144
+ const sections = [];
145
+ if (!this.currentNodeConfig)
146
+ return sections;
147
+ // Role prompt (cacheable base)
148
+ if (this.defaultRolePrompt) {
149
+ sections.push({ role: 'role', content: this.defaultRolePrompt });
150
+ }
151
+ // Node task prompt
152
+ const renderedPrompt = renderNodePrompt(this.currentNodeConfig.prompt, this.context);
153
+ sections.push({ role: 'task', content: renderedPrompt });
154
+ // Collected data state (filtered by relevantFields if specified)
155
+ const relevantData = this.getRelevantCollectedData();
156
+ if (Object.keys(relevantData).length > 0) {
157
+ sections.push({
158
+ role: 'state',
159
+ content: `Information collected so far:\n${JSON.stringify(relevantData, null, 2)}`,
160
+ });
161
+ }
162
+ // Missing fields for extraction nodes
163
+ if (isExtractionNode(this.currentNodeConfig)) {
164
+ const missing = this.getMissingExtractionFields(this.currentNodeConfig);
165
+ if (missing.length > 0) {
166
+ const relevantData = this.getRelevantCollectedData();
167
+ sections.push({
168
+ role: 'extraction',
169
+ content: [
170
+ '## Data Collection Status',
171
+ `Collected so far: ${JSON.stringify(relevantData)}`,
172
+ `Still required: ${missing.join(', ')}`,
173
+ '',
174
+ 'Rules:',
175
+ '- Acknowledge what was just provided before asking for more.',
176
+ '- Ask for ONLY the next missing field. Do not list all missing fields at once.',
177
+ '- When all required fields are collected, the system will advance automatically.',
178
+ ].join('\n'),
179
+ });
180
+ }
181
+ }
182
+ // Post-transition context (one-shot: consumed after first prompt assembly)
183
+ if (this._justTransitioned) {
184
+ const { from, to } = this._justTransitioned;
185
+ const dataCtx = Object.keys(this.context.collectedData).length > 0
186
+ ? `\nCollected data: ${JSON.stringify(this.context.collectedData)}`
187
+ : '';
188
+ sections.push({
189
+ role: 'state',
190
+ content: [
191
+ '## Just Transitioned',
192
+ `You just moved from "${from}" to "${to}".`,
193
+ 'Continue the new task now. Use available tools immediately if the task requires it and all inputs are available.',
194
+ dataCtx,
195
+ ].filter(Boolean).join('\n'),
196
+ });
197
+ this._justTransitioned = null;
198
+ }
199
+ // Node history context
200
+ if (this.context.nodeHistory.length > 1) {
201
+ const recent = this.context.nodeHistory.slice(-5);
202
+ sections.push({
203
+ role: 'state',
204
+ content: `Conversation flow so far: ${recent.join(' → ')}`,
205
+ });
206
+ }
207
+ return sections;
208
+ }
209
+ processToolResult(toolName, args, result) {
210
+ // 1. Check: is this a flow transition?
211
+ if (isFlowTransition(result)) {
212
+ const fromNode = this.currentNodeConfig?.id ?? '';
213
+ const outcome = this.executeTransition(result.targetNode, result.data);
214
+ if (outcome.error) {
215
+ // Oscillation or validation blocked — don't transition, treat as regular tool
216
+ return { type: 'continue' };
217
+ }
218
+ return {
219
+ type: 'reconfigure',
220
+ transition: { from: fromNode, to: result.targetNode },
221
+ };
222
+ }
223
+ // 2. Check: is this an extraction submission?
224
+ // Guard with isExtractionNode to avoid false-positives on regular tools
225
+ // whose names happen to match the submit_*_data pattern.
226
+ if (toolName.startsWith('submit_') &&
227
+ toolName.endsWith('_data') &&
228
+ this.currentNodeConfig &&
229
+ isExtractionNode(this.currentNodeConfig)) {
230
+ const extrNode = this.currentNodeConfig;
231
+ const argsRecord = args && typeof args === 'object' && !Array.isArray(args)
232
+ ? args
233
+ : {};
234
+ this.mergeExtractedData(argsRecord);
235
+ const completion = this.checkExtractionComplete();
236
+ if (completion.complete && completion.nextNode) {
237
+ const fromNode = this.currentNodeConfig?.id ?? '';
238
+ const outcome = this.executeTransition(completion.nextNode, this.context.collectedData);
239
+ if (!outcome.error) {
240
+ return {
241
+ type: 'reconfigure',
242
+ transition: { from: fromNode, to: completion.nextNode, triggerTool: toolName },
243
+ };
244
+ }
245
+ }
246
+ if (completion.complete) {
247
+ return { type: 'extraction-complete', data: this.context.collectedData };
248
+ }
249
+ const override = this.buildExtractionContinueEnvelope(extrNode, argsRecord);
250
+ return { type: 'continue', toolResponseOverride: override };
251
+ }
252
+ // 3. Check: is this a handoff?
253
+ if (isHandoffResult(result)) {
254
+ this.flowEnded = true;
255
+ const target = result.targetAgentId ?? result.targetAgent;
256
+ return { type: 'handoff', targetAgent: target, reason: result.reason };
257
+ }
258
+ // 4. Check: is this a final result (flow end)?
259
+ if (isFinalResult(result)) {
260
+ this.flowEnded = true;
261
+ return { type: 'end', reason: result.reason };
262
+ }
263
+ // Not ours
264
+ return null;
265
+ }
266
+ // ─── Public Flow API ─────────────────────────────────────────────────────
267
+ /** Initialize the flow (transition to initial node). */
268
+ initialize() {
269
+ if (this.initialized)
270
+ return [];
271
+ this.pendingEvents = [];
272
+ this.executeTransition(this.context.currentNode);
273
+ this.initialized = true;
274
+ return this.drainEvents();
275
+ }
276
+ /** Call at the start of each user turn to reset oscillation tracking. */
277
+ resetTurnTracking() {
278
+ this.turnTransitionCounts.clear();
279
+ }
280
+ /** Record a user message in the flow context. */
281
+ appendUserMessage(content) {
282
+ this.context.messages.push({ role: 'user', content });
283
+ if (this.currentNodeConfig) {
284
+ const nodeId = this.currentNodeConfig.id;
285
+ this.context.nodeTurnCounts[nodeId] = (this.context.nodeTurnCounts[nodeId] ?? 0) + 1;
286
+ }
287
+ }
288
+ /** Record an assistant message in the flow context. */
289
+ appendAssistantMessage(content) {
290
+ this.context.messages.push({ role: 'assistant', content });
291
+ }
292
+ get currentNode() {
293
+ return this.currentNodeConfig?.id;
294
+ }
295
+ currentNodeIsExtractionNode() {
296
+ return !!this.currentNodeConfig && isExtractionNode(this.currentNodeConfig);
297
+ }
298
+ currentExtractionNode() {
299
+ if (!this.currentNodeConfig || !isExtractionNode(this.currentNodeConfig)) {
300
+ return null;
301
+ }
302
+ return this.currentNodeConfig;
303
+ }
304
+ get collectedData() {
305
+ return this.context.collectedData;
306
+ }
307
+ updateCollectedData(verified) {
308
+ const before = JSON.stringify(this.context.collectedData);
309
+ this.context.collectedData = mergeExtractionData(this.context.collectedData, verified);
310
+ return JSON.stringify(this.context.collectedData) !== before;
311
+ }
312
+ get hasEnded() {
313
+ return this.flowEnded;
314
+ }
315
+ get isInitialized() {
316
+ return this.initialized;
317
+ }
318
+ getState() {
319
+ return {
320
+ context: this.context,
321
+ initialized: this.initialized,
322
+ flowEnded: this.flowEnded,
323
+ };
324
+ }
325
+ /** Drain accumulated flow events (node-enter, node-exit, etc.). */
326
+ drainEvents() {
327
+ const events = [...this.pendingEvents];
328
+ this.pendingEvents = [];
329
+ return events;
330
+ }
331
+ // ─── Private: Transition ─────────────────────────────────────────────────
332
+ executeTransition(nodeId, data) {
333
+ const previousNode = this.currentNodeConfig;
334
+ // Oscillation detection
335
+ if (previousNode) {
336
+ const edgeKey = `${previousNode.id}->${nodeId}`;
337
+ const count = (this.turnTransitionCounts.get(edgeKey) ?? 0) + 1;
338
+ this.turnTransitionCounts.set(edgeKey, count);
339
+ if (count > this.maxOscillations) {
340
+ return { error: `Oscillation detected on ${edgeKey} (${count} times)` };
341
+ }
342
+ }
343
+ // Output contract validation
344
+ if (previousNode?.outputSchema) {
345
+ const valid = previousNode.outputSchema.safeParse(this.context.collectedData);
346
+ if (!valid.success) {
347
+ return { error: `Output contract violation on "${previousNode.id}": ${valid.error.message}` };
348
+ }
349
+ }
350
+ // Emit node-exit
351
+ if (previousNode) {
352
+ this.pendingEvents.push({ type: 'node-exit', nodeName: previousNode.name ?? previousNode.id });
353
+ }
354
+ // Look up target node
355
+ const nextNode = this.nodes.get(nodeId);
356
+ if (!nextNode) {
357
+ return { error: `Node "${nodeId}" not found` };
358
+ }
359
+ // Update state
360
+ this.currentNodeConfig = nextNode;
361
+ this.context.currentNode = nodeId;
362
+ this.context.nodeHistory.push(nodeId);
363
+ if (data) {
364
+ Object.assign(this.context.collectedData, data);
365
+ }
366
+ // Context strategy
367
+ this.applyContextStrategy(nextNode);
368
+ // Input contract validation
369
+ if (nextNode.inputSchema) {
370
+ const valid = nextNode.inputSchema.safeParse(this.context.collectedData);
371
+ if (!valid.success) {
372
+ return { error: `Input contract violation on "${nextNode.id}": ${valid.error.message}` };
373
+ }
374
+ }
375
+ // Track transition for one-shot prompt context
376
+ if (previousNode) {
377
+ this._justTransitioned = { from: previousNode.id, to: nextNode.id };
378
+ }
379
+ // Emit node-enter and flow-transition
380
+ this.pendingEvents.push({ type: 'node-enter', nodeName: nextNode.name ?? nextNode.id });
381
+ if (previousNode) {
382
+ this.pendingEvents.push({ type: 'flow-transition', from: previousNode.id, to: nextNode.id });
383
+ }
384
+ // Handle end nodes
385
+ if (nextNode.nodeType === 'end') {
386
+ this.flowEnded = true;
387
+ this.pendingEvents.push({ type: 'flow-end', reason: 'end node reached' });
388
+ }
389
+ return {};
390
+ }
391
+ // ─── Private: Extraction ─────────────────────────────────────────────────
392
+ mergeExtractedData(data) {
393
+ this.context.collectedData = mergeExtractionData(this.context.collectedData, data);
394
+ }
395
+ checkExtractionComplete() {
396
+ if (!this.currentNodeConfig || !isExtractionNode(this.currentNodeConfig)) {
397
+ return { complete: false };
398
+ }
399
+ const node = this.currentNodeConfig;
400
+ const missing = this.getMissingExtractionFields(node);
401
+ if (missing.length > 0) {
402
+ return { complete: false };
403
+ }
404
+ return {
405
+ complete: true,
406
+ nextNode: node.extractionCompleteTransition,
407
+ };
408
+ }
409
+ getMissingExtractionFields(node) {
410
+ const required = node.extractionRequiredFields ?? [];
411
+ if (required.length === 0) {
412
+ // If no explicit required fields, try safeParse to check completeness
413
+ const result = node.extractionSchema.safeParse(this.context.collectedData);
414
+ if (result.success)
415
+ return [];
416
+ // Extract field names from Zod errors
417
+ const fieldNames = (result.error.issues ?? [])
418
+ .map(issue => issue.path.join('.'))
419
+ .filter(Boolean);
420
+ return [...new Set(fieldNames)];
421
+ }
422
+ return computeMissingFields(this.context.collectedData, required);
423
+ }
424
+ // ─── Private: Context Strategy ───────────────────────────────────────────
425
+ applyContextStrategy(node) {
426
+ const strategy = node.contextStrategy ?? this.nodes.get(this.context.currentNode)?.contextStrategy ?? 'append';
427
+ switch (strategy) {
428
+ case 'reset':
429
+ this.context.messages = [];
430
+ break;
431
+ case 'reset_with_summary':
432
+ // In the headless capability, we can't call an LLM for summarization.
433
+ // Reset messages and add a note about prior context.
434
+ this.context.messages = [];
435
+ break;
436
+ case 'append':
437
+ default:
438
+ // Keep all messages
439
+ break;
440
+ }
441
+ }
442
+ // ─── Private: Helpers ────────────────────────────────────────────────────
443
+ getRelevantCollectedData() {
444
+ const fields = this.currentNodeConfig?.relevantFields;
445
+ if (!fields || fields.length === 0) {
446
+ return this.context.collectedData;
447
+ }
448
+ const filtered = {};
449
+ for (const field of fields) {
450
+ if (field in this.context.collectedData) {
451
+ filtered[field] = this.context.collectedData[field];
452
+ }
453
+ }
454
+ return filtered;
455
+ }
456
+ buildExtractionContinueEnvelope(node, argsRecord) {
457
+ const missingAfter = this.getMissingExtractionFields(node);
458
+ const fieldsReceived = Object.entries(argsRecord)
459
+ .filter(([, v]) => v !== null && v !== undefined && v !== '')
460
+ .map(([k]) => k);
461
+ let instruction;
462
+ if (fieldsReceived.length > 0) {
463
+ instruction = `Acknowledge receipt of ${fieldsReceived.join(', ')}.`;
464
+ if (missingAfter[0]) {
465
+ instruction += ` Ask for the ${missingAfter[0]}.`;
466
+ }
467
+ }
468
+ else if (missingAfter[0]) {
469
+ instruction = `Ask for the ${missingAfter[0]}.`;
470
+ }
471
+ else {
472
+ instruction = 'Continue the conversation naturally.';
473
+ }
474
+ return {
475
+ accepted: true,
476
+ fieldsReceived,
477
+ fieldsStillRequired: missingAfter,
478
+ instruction,
479
+ };
480
+ }
481
+ }
482
+ //# sourceMappingURL=FlowCapability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Fl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jC,WAAW;SACZ,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import type { Capability, ToolDeclaration, PromptSection, CapabilityAction } from './index.js';
2
+ /**
3
+ * Injects policy text into the system prompt as 'policy' sections.
4
+ * Optionally filters input/output text — currently a passthrough placeholder
5
+ * that future processor integration can populate.
6
+ */
7
+ export declare class GuardrailCapability implements Capability {
8
+ private policies;
9
+ constructor(policies: string[]);
10
+ getTools(): ToolDeclaration[];
11
+ getPromptSections(): PromptSection[];
12
+ processToolResult(_toolName: string, _args: unknown, _result: unknown): CapabilityAction | null;
13
+ /**
14
+ * Evaluate whether an input text is permitted by this guardrail.
15
+ * Returns `{ allowed: true }` until a processor is wired in.
16
+ */
17
+ filterInput(_text: string): {
18
+ allowed: boolean;
19
+ reason?: string;
20
+ };
21
+ /**
22
+ * Evaluate whether an output text is permitted and optionally modify it.
23
+ * Returns `{ allowed: true }` until a processor is wired in.
24
+ */
25
+ filterOutput(_text: string): {
26
+ allowed: boolean;
27
+ modified?: string;
28
+ };
29
+ }
30
+ //# sourceMappingURL=GuardrailCapability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardrailCapability.d.ts","sourceRoot":"","sources":["../../src/capabilities/GuardrailCapability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAI/F;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,UAAU;IACpD,OAAO,CAAC,QAAQ,CAAW;gBAEf,QAAQ,EAAE,MAAM,EAAE;IAI9B,QAAQ,IAAI,eAAe,EAAE;IAI7B,iBAAiB,IAAI,aAAa,EAAE;IAMpC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI;IAI/F;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAIjE;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;CAGrE"}
@@ -0,0 +1,38 @@
1
+ // ─── GuardrailCapability ─────────────────────────────────────────────────────
2
+ /**
3
+ * Injects policy text into the system prompt as 'policy' sections.
4
+ * Optionally filters input/output text — currently a passthrough placeholder
5
+ * that future processor integration can populate.
6
+ */
7
+ export class GuardrailCapability {
8
+ policies;
9
+ constructor(policies) {
10
+ this.policies = policies;
11
+ }
12
+ getTools() {
13
+ return [];
14
+ }
15
+ getPromptSections() {
16
+ return this.policies
17
+ .filter(p => p.trim().length > 0)
18
+ .map(policy => ({ role: 'policy', content: policy }));
19
+ }
20
+ processToolResult(_toolName, _args, _result) {
21
+ return null;
22
+ }
23
+ /**
24
+ * Evaluate whether an input text is permitted by this guardrail.
25
+ * Returns `{ allowed: true }` until a processor is wired in.
26
+ */
27
+ filterInput(_text) {
28
+ return { allowed: true };
29
+ }
30
+ /**
31
+ * Evaluate whether an output text is permitted and optionally modify it.
32
+ * Returns `{ allowed: true }` until a processor is wired in.
33
+ */
34
+ filterOutput(_text) {
35
+ return { allowed: true };
36
+ }
37
+ }
38
+ //# sourceMappingURL=GuardrailCapability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardrailCapability.js","sourceRoot":"","sources":["../../src/capabilities/GuardrailCapability.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IACtB,QAAQ,CAAW;IAE3B,YAAY,QAAkB;QAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,QAAQ;aACjB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;aAChC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,iBAAiB,CAAC,SAAiB,EAAE,KAAc,EAAE,OAAgB;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,KAAa;QACvB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,KAAa;QACxB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import type { Capability, ToolDeclaration, PromptSection, CapabilityAction } from './index.js';
2
+ export interface HandoffTarget {
3
+ id: string;
4
+ name: string;
5
+ description?: string;
6
+ }
7
+ /**
8
+ * Exposes a single `transfer_to_agent` tool for agents that have explicit
9
+ * `canHandoffTo` targets. Unlike TriageCapability (one tool per route),
10
+ * this uses a single tool with an enum parameter for the target agent.
11
+ */
12
+ export declare class HandoffCapability implements Capability {
13
+ private targets;
14
+ constructor(targets: HandoffTarget[]);
15
+ getTools(): ToolDeclaration[];
16
+ getPromptSections(): PromptSection[];
17
+ processToolResult(toolName: string, args: unknown, result: unknown): CapabilityAction | null;
18
+ }
19
+ //# sourceMappingURL=HandoffCapability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HandoffCapability.d.ts","sourceRoot":"","sources":["../../src/capabilities/HandoffCapability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK/F,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAID;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,UAAU;IAClD,OAAO,CAAC,OAAO,CAAkB;gBAErB,OAAO,EAAE,aAAa,EAAE;IAIpC,QAAQ,IAAI,eAAe,EAAE;IAgC7B,iBAAiB,IAAI,aAAa,EAAE;IAIpC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI;CAW7F"}