@falai/agent 1.2.8 → 2.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.
Files changed (499) hide show
  1. package/README.md +40 -886
  2. package/dist/adapters/MemoryAdapter.js +2 -2
  3. package/dist/adapters/MemoryAdapter.js.map +1 -1
  4. package/dist/adapters/MongoAdapter.js +2 -2
  5. package/dist/adapters/MongoAdapter.js.map +1 -1
  6. package/dist/adapters/OpenSearchAdapter.d.ts.map +1 -1
  7. package/dist/adapters/OpenSearchAdapter.js +9 -7
  8. package/dist/adapters/OpenSearchAdapter.js.map +1 -1
  9. package/dist/adapters/PostgreSQLAdapter.d.ts +14 -0
  10. package/dist/adapters/PostgreSQLAdapter.d.ts.map +1 -1
  11. package/dist/adapters/PostgreSQLAdapter.js +25 -9
  12. package/dist/adapters/PostgreSQLAdapter.js.map +1 -1
  13. package/dist/adapters/PrismaAdapter.js +5 -5
  14. package/dist/adapters/PrismaAdapter.js.map +1 -1
  15. package/dist/adapters/RedisAdapter.js +2 -2
  16. package/dist/adapters/RedisAdapter.js.map +1 -1
  17. package/dist/adapters/SQLiteAdapter.d.ts +17 -0
  18. package/dist/adapters/SQLiteAdapter.d.ts.map +1 -1
  19. package/dist/adapters/SQLiteAdapter.js +30 -11
  20. package/dist/adapters/SQLiteAdapter.js.map +1 -1
  21. package/dist/cjs/adapters/MemoryAdapter.js +2 -2
  22. package/dist/cjs/adapters/MemoryAdapter.js.map +1 -1
  23. package/dist/cjs/adapters/MongoAdapter.js +2 -2
  24. package/dist/cjs/adapters/MongoAdapter.js.map +1 -1
  25. package/dist/cjs/adapters/OpenSearchAdapter.d.ts.map +1 -1
  26. package/dist/cjs/adapters/OpenSearchAdapter.js +9 -7
  27. package/dist/cjs/adapters/OpenSearchAdapter.js.map +1 -1
  28. package/dist/cjs/adapters/PostgreSQLAdapter.d.ts +14 -0
  29. package/dist/cjs/adapters/PostgreSQLAdapter.d.ts.map +1 -1
  30. package/dist/cjs/adapters/PostgreSQLAdapter.js +25 -9
  31. package/dist/cjs/adapters/PostgreSQLAdapter.js.map +1 -1
  32. package/dist/cjs/adapters/PrismaAdapter.js +5 -5
  33. package/dist/cjs/adapters/PrismaAdapter.js.map +1 -1
  34. package/dist/cjs/adapters/RedisAdapter.js +2 -2
  35. package/dist/cjs/adapters/RedisAdapter.js.map +1 -1
  36. package/dist/cjs/adapters/SQLiteAdapter.d.ts +17 -0
  37. package/dist/cjs/adapters/SQLiteAdapter.d.ts.map +1 -1
  38. package/dist/cjs/adapters/SQLiteAdapter.js +30 -11
  39. package/dist/cjs/adapters/SQLiteAdapter.js.map +1 -1
  40. package/dist/cjs/constants/index.d.ts +0 -9
  41. package/dist/cjs/constants/index.d.ts.map +1 -1
  42. package/dist/cjs/constants/index.js +2 -11
  43. package/dist/cjs/constants/index.js.map +1 -1
  44. package/dist/cjs/core/Agent.d.ts +119 -153
  45. package/dist/cjs/core/Agent.d.ts.map +1 -1
  46. package/dist/cjs/core/Agent.js +471 -324
  47. package/dist/cjs/core/Agent.js.map +1 -1
  48. package/dist/cjs/core/AutoChainExecutor.d.ts +107 -0
  49. package/dist/cjs/core/AutoChainExecutor.d.ts.map +1 -0
  50. package/dist/cjs/core/AutoChainExecutor.js +297 -0
  51. package/dist/cjs/core/AutoChainExecutor.js.map +1 -0
  52. package/dist/cjs/core/BranchEvaluator.d.ts +54 -0
  53. package/dist/cjs/core/BranchEvaluator.d.ts.map +1 -0
  54. package/dist/cjs/core/BranchEvaluator.js +130 -0
  55. package/dist/cjs/core/BranchEvaluator.js.map +1 -0
  56. package/dist/cjs/core/DirectiveBus.d.ts +88 -0
  57. package/dist/cjs/core/DirectiveBus.d.ts.map +1 -0
  58. package/dist/cjs/core/DirectiveBus.js +196 -0
  59. package/dist/cjs/core/DirectiveBus.js.map +1 -0
  60. package/dist/cjs/core/DirectiveChainTracker.d.ts +49 -0
  61. package/dist/cjs/core/DirectiveChainTracker.d.ts.map +1 -0
  62. package/dist/cjs/core/DirectiveChainTracker.js +121 -0
  63. package/dist/cjs/core/DirectiveChainTracker.js.map +1 -0
  64. package/dist/cjs/core/Flow.d.ts +186 -0
  65. package/dist/cjs/core/Flow.d.ts.map +1 -0
  66. package/dist/cjs/core/Flow.js +550 -0
  67. package/dist/cjs/core/Flow.js.map +1 -0
  68. package/dist/cjs/core/FlowRouter.d.ts +182 -0
  69. package/dist/cjs/core/FlowRouter.d.ts.map +1 -0
  70. package/dist/cjs/core/{RoutingEngine.js → FlowRouter.js} +323 -306
  71. package/dist/cjs/core/FlowRouter.js.map +1 -0
  72. package/dist/cjs/core/PersistenceManager.d.ts +2 -2
  73. package/dist/cjs/core/PersistenceManager.d.ts.map +1 -1
  74. package/dist/cjs/core/PersistenceManager.js +7 -7
  75. package/dist/cjs/core/PersistenceManager.js.map +1 -1
  76. package/dist/cjs/core/PromptComposer.d.ts +21 -8
  77. package/dist/cjs/core/PromptComposer.d.ts.map +1 -1
  78. package/dist/cjs/core/PromptComposer.js +182 -105
  79. package/dist/cjs/core/PromptComposer.js.map +1 -1
  80. package/dist/cjs/core/PromptSectionCache.d.ts +1 -1
  81. package/dist/cjs/core/PromptSectionCache.js +1 -1
  82. package/dist/cjs/core/ResponseEngine.d.ts +18 -8
  83. package/dist/cjs/core/ResponseEngine.d.ts.map +1 -1
  84. package/dist/cjs/core/ResponseEngine.js +38 -36
  85. package/dist/cjs/core/ResponseEngine.js.map +1 -1
  86. package/dist/cjs/core/ResponseModal.d.ts +73 -56
  87. package/dist/cjs/core/ResponseModal.d.ts.map +1 -1
  88. package/dist/cjs/core/ResponseModal.js +1191 -1014
  89. package/dist/cjs/core/ResponseModal.js.map +1 -1
  90. package/dist/cjs/core/ResponsePipeline.d.ts +124 -26
  91. package/dist/cjs/core/ResponsePipeline.d.ts.map +1 -1
  92. package/dist/cjs/core/ResponsePipeline.js +509 -136
  93. package/dist/cjs/core/ResponsePipeline.js.map +1 -1
  94. package/dist/cjs/core/SignalEvaluator.d.ts +86 -0
  95. package/dist/cjs/core/SignalEvaluator.d.ts.map +1 -0
  96. package/dist/cjs/core/SignalEvaluator.js +333 -0
  97. package/dist/cjs/core/SignalEvaluator.js.map +1 -0
  98. package/dist/cjs/core/SignalProcessor.d.ts +152 -0
  99. package/dist/cjs/core/SignalProcessor.d.ts.map +1 -0
  100. package/dist/cjs/core/SignalProcessor.js +562 -0
  101. package/dist/cjs/core/SignalProcessor.js.map +1 -0
  102. package/dist/cjs/core/Step.d.ts +43 -32
  103. package/dist/cjs/core/Step.d.ts.map +1 -1
  104. package/dist/cjs/core/Step.js +221 -126
  105. package/dist/cjs/core/Step.js.map +1 -1
  106. package/dist/cjs/core/StreamingToolExecutor.d.ts +2 -2
  107. package/dist/cjs/core/StreamingToolExecutor.d.ts.map +1 -1
  108. package/dist/cjs/core/StreamingToolExecutor.js.map +1 -1
  109. package/dist/cjs/core/ToolManager.d.ts +44 -13
  110. package/dist/cjs/core/ToolManager.d.ts.map +1 -1
  111. package/dist/cjs/core/ToolManager.js +174 -91
  112. package/dist/cjs/core/ToolManager.js.map +1 -1
  113. package/dist/cjs/core/createAgent.d.ts +35 -0
  114. package/dist/cjs/core/createAgent.d.ts.map +1 -0
  115. package/dist/cjs/core/createAgent.js +39 -0
  116. package/dist/cjs/core/createAgent.js.map +1 -0
  117. package/dist/cjs/core/flow-namespace.d.ts +49 -0
  118. package/dist/cjs/core/flow-namespace.d.ts.map +1 -0
  119. package/dist/cjs/core/flow-namespace.js +171 -0
  120. package/dist/cjs/core/flow-namespace.js.map +1 -0
  121. package/dist/cjs/index.d.ts +11 -14
  122. package/dist/cjs/index.d.ts.map +1 -1
  123. package/dist/cjs/index.js +18 -22
  124. package/dist/cjs/index.js.map +1 -1
  125. package/dist/cjs/types/agent.d.ts +183 -54
  126. package/dist/cjs/types/agent.d.ts.map +1 -1
  127. package/dist/cjs/types/agent.js +0 -6
  128. package/dist/cjs/types/agent.js.map +1 -1
  129. package/dist/cjs/types/ai.d.ts +3 -3
  130. package/dist/cjs/types/ai.d.ts.map +1 -1
  131. package/dist/cjs/types/errors.d.ts +15 -0
  132. package/dist/cjs/types/errors.d.ts.map +1 -0
  133. package/dist/cjs/types/errors.js +22 -0
  134. package/dist/cjs/types/errors.js.map +1 -0
  135. package/dist/cjs/types/flow.d.ts +513 -0
  136. package/dist/cjs/types/flow.d.ts.map +1 -0
  137. package/dist/cjs/types/{route.js → flow.js} +2 -2
  138. package/dist/cjs/types/flow.js.map +1 -0
  139. package/dist/cjs/types/index.d.ts +7 -6
  140. package/dist/cjs/types/index.d.ts.map +1 -1
  141. package/dist/cjs/types/index.js +6 -2
  142. package/dist/cjs/types/index.js.map +1 -1
  143. package/dist/cjs/types/persistence.d.ts +11 -7
  144. package/dist/cjs/types/persistence.d.ts.map +1 -1
  145. package/dist/cjs/types/routing.d.ts +1 -1
  146. package/dist/cjs/types/routing.d.ts.map +1 -1
  147. package/dist/cjs/types/session.d.ts +24 -23
  148. package/dist/cjs/types/session.d.ts.map +1 -1
  149. package/dist/cjs/types/signals.d.ts +248 -0
  150. package/dist/cjs/types/signals.d.ts.map +1 -0
  151. package/dist/cjs/types/signals.js +11 -0
  152. package/dist/cjs/types/signals.js.map +1 -0
  153. package/dist/cjs/types/template.d.ts +2 -8
  154. package/dist/cjs/types/template.d.ts.map +1 -1
  155. package/dist/cjs/types/tool.d.ts +36 -29
  156. package/dist/cjs/types/tool.d.ts.map +1 -1
  157. package/dist/cjs/types/tool.js +1 -1
  158. package/dist/cjs/types/tool.js.map +1 -1
  159. package/dist/cjs/utils/condition.d.ts +7 -1
  160. package/dist/cjs/utils/condition.d.ts.map +1 -1
  161. package/dist/cjs/utils/condition.js.map +1 -1
  162. package/dist/cjs/utils/id.d.ts +13 -5
  163. package/dist/cjs/utils/id.d.ts.map +1 -1
  164. package/dist/cjs/utils/id.js +24 -10
  165. package/dist/cjs/utils/id.js.map +1 -1
  166. package/dist/cjs/utils/index.d.ts +2 -2
  167. package/dist/cjs/utils/index.d.ts.map +1 -1
  168. package/dist/cjs/utils/index.js +7 -3
  169. package/dist/cjs/utils/index.js.map +1 -1
  170. package/dist/cjs/utils/session.d.ts +44 -5
  171. package/dist/cjs/utils/session.d.ts.map +1 -1
  172. package/dist/cjs/utils/session.js +197 -38
  173. package/dist/cjs/utils/session.js.map +1 -1
  174. package/dist/constants/index.d.ts +0 -9
  175. package/dist/constants/index.d.ts.map +1 -1
  176. package/dist/constants/index.js +3 -9
  177. package/dist/constants/index.js.map +1 -1
  178. package/dist/core/Agent.d.ts +119 -153
  179. package/dist/core/Agent.d.ts.map +1 -1
  180. package/dist/core/Agent.js +472 -325
  181. package/dist/core/Agent.js.map +1 -1
  182. package/dist/core/AutoChainExecutor.d.ts +107 -0
  183. package/dist/core/AutoChainExecutor.d.ts.map +1 -0
  184. package/dist/core/AutoChainExecutor.js +293 -0
  185. package/dist/core/AutoChainExecutor.js.map +1 -0
  186. package/dist/core/BranchEvaluator.d.ts +54 -0
  187. package/dist/core/BranchEvaluator.d.ts.map +1 -0
  188. package/dist/core/BranchEvaluator.js +126 -0
  189. package/dist/core/BranchEvaluator.js.map +1 -0
  190. package/dist/core/DirectiveBus.d.ts +88 -0
  191. package/dist/core/DirectiveBus.d.ts.map +1 -0
  192. package/dist/core/DirectiveBus.js +192 -0
  193. package/dist/core/DirectiveBus.js.map +1 -0
  194. package/dist/core/DirectiveChainTracker.d.ts +49 -0
  195. package/dist/core/DirectiveChainTracker.d.ts.map +1 -0
  196. package/dist/core/DirectiveChainTracker.js +117 -0
  197. package/dist/core/DirectiveChainTracker.js.map +1 -0
  198. package/dist/core/Flow.d.ts +186 -0
  199. package/dist/core/Flow.d.ts.map +1 -0
  200. package/dist/core/Flow.js +546 -0
  201. package/dist/core/Flow.js.map +1 -0
  202. package/dist/core/FlowRouter.d.ts +182 -0
  203. package/dist/core/FlowRouter.d.ts.map +1 -0
  204. package/dist/core/{RoutingEngine.js → FlowRouter.js} +322 -305
  205. package/dist/core/FlowRouter.js.map +1 -0
  206. package/dist/core/PersistenceManager.d.ts +2 -2
  207. package/dist/core/PersistenceManager.d.ts.map +1 -1
  208. package/dist/core/PersistenceManager.js +7 -7
  209. package/dist/core/PersistenceManager.js.map +1 -1
  210. package/dist/core/PromptComposer.d.ts +21 -8
  211. package/dist/core/PromptComposer.d.ts.map +1 -1
  212. package/dist/core/PromptComposer.js +183 -106
  213. package/dist/core/PromptComposer.js.map +1 -1
  214. package/dist/core/PromptSectionCache.d.ts +1 -1
  215. package/dist/core/PromptSectionCache.js +1 -1
  216. package/dist/core/ResponseEngine.d.ts +18 -8
  217. package/dist/core/ResponseEngine.d.ts.map +1 -1
  218. package/dist/core/ResponseEngine.js +38 -36
  219. package/dist/core/ResponseEngine.js.map +1 -1
  220. package/dist/core/ResponseModal.d.ts +73 -56
  221. package/dist/core/ResponseModal.d.ts.map +1 -1
  222. package/dist/core/ResponseModal.js +1193 -1016
  223. package/dist/core/ResponseModal.js.map +1 -1
  224. package/dist/core/ResponsePipeline.d.ts +124 -26
  225. package/dist/core/ResponsePipeline.d.ts.map +1 -1
  226. package/dist/core/ResponsePipeline.js +509 -137
  227. package/dist/core/ResponsePipeline.js.map +1 -1
  228. package/dist/core/SignalEvaluator.d.ts +86 -0
  229. package/dist/core/SignalEvaluator.d.ts.map +1 -0
  230. package/dist/core/SignalEvaluator.js +326 -0
  231. package/dist/core/SignalEvaluator.js.map +1 -0
  232. package/dist/core/SignalProcessor.d.ts +152 -0
  233. package/dist/core/SignalProcessor.d.ts.map +1 -0
  234. package/dist/core/SignalProcessor.js +555 -0
  235. package/dist/core/SignalProcessor.js.map +1 -0
  236. package/dist/core/Step.d.ts +43 -32
  237. package/dist/core/Step.d.ts.map +1 -1
  238. package/dist/core/Step.js +220 -126
  239. package/dist/core/Step.js.map +1 -1
  240. package/dist/core/StreamingToolExecutor.d.ts +2 -2
  241. package/dist/core/StreamingToolExecutor.d.ts.map +1 -1
  242. package/dist/core/StreamingToolExecutor.js.map +1 -1
  243. package/dist/core/ToolManager.d.ts +44 -13
  244. package/dist/core/ToolManager.d.ts.map +1 -1
  245. package/dist/core/ToolManager.js +174 -91
  246. package/dist/core/ToolManager.js.map +1 -1
  247. package/dist/core/createAgent.d.ts +35 -0
  248. package/dist/core/createAgent.d.ts.map +1 -0
  249. package/dist/core/createAgent.js +36 -0
  250. package/dist/core/createAgent.js.map +1 -0
  251. package/dist/core/flow-namespace.d.ts +49 -0
  252. package/dist/core/flow-namespace.d.ts.map +1 -0
  253. package/dist/core/flow-namespace.js +168 -0
  254. package/dist/core/flow-namespace.js.map +1 -0
  255. package/dist/index.d.ts +11 -14
  256. package/dist/index.d.ts.map +1 -1
  257. package/dist/index.js +9 -12
  258. package/dist/index.js.map +1 -1
  259. package/dist/types/agent.d.ts +183 -54
  260. package/dist/types/agent.d.ts.map +1 -1
  261. package/dist/types/agent.js +0 -6
  262. package/dist/types/agent.js.map +1 -1
  263. package/dist/types/ai.d.ts +3 -3
  264. package/dist/types/ai.d.ts.map +1 -1
  265. package/dist/types/errors.d.ts +15 -0
  266. package/dist/types/errors.d.ts.map +1 -0
  267. package/dist/types/errors.js +18 -0
  268. package/dist/types/errors.js.map +1 -0
  269. package/dist/types/flow.d.ts +513 -0
  270. package/dist/types/flow.d.ts.map +1 -0
  271. package/dist/types/flow.js +5 -0
  272. package/dist/types/flow.js.map +1 -0
  273. package/dist/types/index.d.ts +7 -6
  274. package/dist/types/index.d.ts.map +1 -1
  275. package/dist/types/index.js +4 -1
  276. package/dist/types/index.js.map +1 -1
  277. package/dist/types/persistence.d.ts +11 -7
  278. package/dist/types/persistence.d.ts.map +1 -1
  279. package/dist/types/routing.d.ts +1 -1
  280. package/dist/types/routing.d.ts.map +1 -1
  281. package/dist/types/session.d.ts +24 -23
  282. package/dist/types/session.d.ts.map +1 -1
  283. package/dist/types/signals.d.ts +248 -0
  284. package/dist/types/signals.d.ts.map +1 -0
  285. package/dist/types/signals.js +10 -0
  286. package/dist/types/signals.js.map +1 -0
  287. package/dist/types/template.d.ts +2 -8
  288. package/dist/types/template.d.ts.map +1 -1
  289. package/dist/types/tool.d.ts +36 -29
  290. package/dist/types/tool.d.ts.map +1 -1
  291. package/dist/types/tool.js +1 -1
  292. package/dist/types/tool.js.map +1 -1
  293. package/dist/utils/condition.d.ts +7 -1
  294. package/dist/utils/condition.d.ts.map +1 -1
  295. package/dist/utils/condition.js.map +1 -1
  296. package/dist/utils/id.d.ts +13 -5
  297. package/dist/utils/id.d.ts.map +1 -1
  298. package/dist/utils/id.js +22 -9
  299. package/dist/utils/id.js.map +1 -1
  300. package/dist/utils/index.d.ts +2 -2
  301. package/dist/utils/index.d.ts.map +1 -1
  302. package/dist/utils/index.js +2 -2
  303. package/dist/utils/index.js.map +1 -1
  304. package/dist/utils/session.d.ts +44 -5
  305. package/dist/utils/session.d.ts.map +1 -1
  306. package/dist/utils/session.js +193 -37
  307. package/dist/utils/session.js.map +1 -1
  308. package/docs/README.md +15 -202
  309. package/docs/concepts/architecture.md +281 -0
  310. package/docs/concepts/directives.md +400 -0
  311. package/docs/concepts/pipeline.md +399 -0
  312. package/docs/guides/branching.md +263 -0
  313. package/docs/guides/compaction.md +163 -0
  314. package/docs/guides/conditions.md +167 -0
  315. package/docs/guides/error-handling.md +176 -0
  316. package/docs/guides/flow-control.md +409 -0
  317. package/docs/guides/instructions.md +210 -0
  318. package/docs/guides/persistence.md +182 -0
  319. package/docs/guides/streaming.md +137 -0
  320. package/docs/migration/README.md +15 -0
  321. package/docs/migration/route-to-flow.md +560 -0
  322. package/docs/migration/v1-to-v2.md +909 -0
  323. package/docs/reference/adapters.md +481 -0
  324. package/docs/reference/branches.md +241 -0
  325. package/docs/reference/create-agent.md +186 -0
  326. package/docs/reference/directive.md +243 -0
  327. package/docs/reference/errors.md +122 -0
  328. package/docs/reference/flow.md +238 -0
  329. package/docs/reference/instruction.md +177 -0
  330. package/docs/reference/pre-directive.md +131 -0
  331. package/docs/reference/providers.md +227 -0
  332. package/docs/reference/signals.md +356 -0
  333. package/docs/reference/step.md +339 -0
  334. package/docs/reference/tool.md +269 -0
  335. package/docs/start/01-install.md +81 -0
  336. package/docs/start/02-first-agent.md +196 -0
  337. package/docs/start/03-collect-data.md +222 -0
  338. package/docs/start/04-add-tools.md +276 -0
  339. package/docs/start/05-go-to-production.md +216 -0
  340. package/examples/01-quickstart.ts +20 -0
  341. package/examples/02-data-extraction.ts +90 -0
  342. package/examples/03-tools.ts +136 -0
  343. package/examples/04-instructions.ts +100 -0
  344. package/examples/05-branching.ts +140 -0
  345. package/examples/06-flow-control.ts +103 -0
  346. package/examples/07-streaming.ts +69 -0
  347. package/examples/08-persistence.ts +98 -0
  348. package/examples/09-signals.ts +144 -0
  349. package/examples/tsconfig.json +30 -0
  350. package/package.json +2 -1
  351. package/src/adapters/MemoryAdapter.ts +3 -3
  352. package/src/adapters/MongoAdapter.ts +3 -3
  353. package/src/adapters/OpenSearchAdapter.ts +10 -8
  354. package/src/adapters/PostgreSQLAdapter.ts +26 -10
  355. package/src/adapters/PrismaAdapter.ts +6 -6
  356. package/src/adapters/RedisAdapter.ts +3 -3
  357. package/src/adapters/SQLiteAdapter.ts +31 -12
  358. package/src/constants/index.ts +2 -10
  359. package/src/core/Agent.ts +585 -374
  360. package/src/core/AutoChainExecutor.ts +440 -0
  361. package/src/core/BranchEvaluator.ts +167 -0
  362. package/src/core/DirectiveBus.ts +248 -0
  363. package/src/core/DirectiveChainTracker.ts +144 -0
  364. package/src/core/Flow.ts +666 -0
  365. package/src/core/{RoutingEngine.ts → FlowRouter.ts} +385 -365
  366. package/src/core/PersistenceManager.ts +8 -8
  367. package/src/core/PromptComposer.ts +209 -140
  368. package/src/core/PromptSectionCache.ts +1 -1
  369. package/src/core/ResponseEngine.ts +61 -46
  370. package/src/core/ResponseModal.ts +1453 -1240
  371. package/src/core/ResponsePipeline.ts +655 -175
  372. package/src/core/SignalEvaluator.ts +420 -0
  373. package/src/core/SignalProcessor.ts +723 -0
  374. package/src/core/Step.ts +279 -176
  375. package/src/core/StreamingToolExecutor.ts +4 -4
  376. package/src/core/ToolManager.ts +200 -97
  377. package/src/core/createAgent.ts +40 -0
  378. package/src/core/flow-namespace.ts +219 -0
  379. package/src/index.ts +42 -36
  380. package/src/types/agent.ts +182 -53
  381. package/src/types/ai.ts +3 -3
  382. package/src/types/errors.ts +18 -0
  383. package/src/types/flow.ts +590 -0
  384. package/src/types/index.ts +43 -16
  385. package/src/types/persistence.ts +12 -8
  386. package/src/types/routing.ts +1 -1
  387. package/src/types/session.ts +26 -23
  388. package/src/types/signals.ts +321 -0
  389. package/src/types/template.ts +3 -11
  390. package/src/types/tool.ts +50 -42
  391. package/src/utils/condition.ts +13 -4
  392. package/src/utils/id.ts +27 -9
  393. package/src/utils/index.ts +6 -2
  394. package/src/utils/session.ts +238 -42
  395. package/dist/cjs/core/BatchExecutor.d.ts +0 -359
  396. package/dist/cjs/core/BatchExecutor.d.ts.map +0 -1
  397. package/dist/cjs/core/BatchExecutor.js +0 -861
  398. package/dist/cjs/core/BatchExecutor.js.map +0 -1
  399. package/dist/cjs/core/BatchPromptBuilder.d.ts +0 -89
  400. package/dist/cjs/core/BatchPromptBuilder.d.ts.map +0 -1
  401. package/dist/cjs/core/BatchPromptBuilder.js +0 -223
  402. package/dist/cjs/core/BatchPromptBuilder.js.map +0 -1
  403. package/dist/cjs/core/Route.d.ts +0 -180
  404. package/dist/cjs/core/Route.d.ts.map +0 -1
  405. package/dist/cjs/core/Route.js +0 -542
  406. package/dist/cjs/core/Route.js.map +0 -1
  407. package/dist/cjs/core/RoutingEngine.d.ts +0 -185
  408. package/dist/cjs/core/RoutingEngine.d.ts.map +0 -1
  409. package/dist/cjs/core/RoutingEngine.js.map +0 -1
  410. package/dist/cjs/types/route.d.ts +0 -336
  411. package/dist/cjs/types/route.d.ts.map +0 -1
  412. package/dist/cjs/types/route.js.map +0 -1
  413. package/dist/core/BatchExecutor.d.ts +0 -359
  414. package/dist/core/BatchExecutor.d.ts.map +0 -1
  415. package/dist/core/BatchExecutor.js +0 -856
  416. package/dist/core/BatchExecutor.js.map +0 -1
  417. package/dist/core/BatchPromptBuilder.d.ts +0 -89
  418. package/dist/core/BatchPromptBuilder.d.ts.map +0 -1
  419. package/dist/core/BatchPromptBuilder.js +0 -219
  420. package/dist/core/BatchPromptBuilder.js.map +0 -1
  421. package/dist/core/Route.d.ts +0 -180
  422. package/dist/core/Route.d.ts.map +0 -1
  423. package/dist/core/Route.js +0 -538
  424. package/dist/core/Route.js.map +0 -1
  425. package/dist/core/RoutingEngine.d.ts +0 -185
  426. package/dist/core/RoutingEngine.d.ts.map +0 -1
  427. package/dist/core/RoutingEngine.js.map +0 -1
  428. package/dist/types/route.d.ts +0 -336
  429. package/dist/types/route.d.ts.map +0 -1
  430. package/dist/types/route.js +0 -5
  431. package/dist/types/route.js.map +0 -1
  432. package/docs/CONTRIBUTING.md +0 -521
  433. package/docs/api/README.md +0 -3299
  434. package/docs/api/overview.md +0 -1410
  435. package/docs/architecture/data-extraction-flow.md +0 -360
  436. package/docs/architecture/multi-step-execution.md +0 -277
  437. package/docs/core/agent/README.md +0 -938
  438. package/docs/core/agent/context-management.md +0 -796
  439. package/docs/core/agent/rules-and-prohibitions.md +0 -113
  440. package/docs/core/agent/session-management.md +0 -693
  441. package/docs/core/ai-integration/prompt-composition.md +0 -355
  442. package/docs/core/ai-integration/providers.md +0 -515
  443. package/docs/core/ai-integration/response-processing.md +0 -433
  444. package/docs/core/conversation-flows/data-collection.md +0 -772
  445. package/docs/core/conversation-flows/route-dsl.md +0 -509
  446. package/docs/core/conversation-flows/routes.md +0 -249
  447. package/docs/core/conversation-flows/step-transitions.md +0 -731
  448. package/docs/core/conversation-flows/steps.md +0 -268
  449. package/docs/core/error-handling.md +0 -830
  450. package/docs/core/persistence/adapters.md +0 -255
  451. package/docs/core/persistence/session-storage.md +0 -656
  452. package/docs/core/routing/intelligent-routing.md +0 -470
  453. package/docs/core/tools/enhanced-tool.md +0 -186
  454. package/docs/core/tools/streaming-execution.md +0 -161
  455. package/docs/core/tools/tool-definition.md +0 -970
  456. package/docs/core/tools/tool-scoping.md +0 -819
  457. package/docs/guides/advanced-patterns/publishing.md +0 -186
  458. package/docs/guides/context-compaction.md +0 -96
  459. package/docs/guides/error-handling-patterns.md +0 -578
  460. package/docs/guides/getting-started/README.md +0 -795
  461. package/docs/guides/migration/README.md +0 -101
  462. package/docs/guides/migration/flexible-routing-conditions.md +0 -375
  463. package/docs/guides/migration/multi-step-execution.md +0 -393
  464. package/docs/guides/migration/response-modal-refactor.md +0 -518
  465. package/docs/guides/prompt-optimization.md +0 -164
  466. package/examples/advanced-patterns/context-compaction.ts +0 -223
  467. package/examples/advanced-patterns/knowledge-based-agent.ts +0 -735
  468. package/examples/advanced-patterns/persistent-onboarding.ts +0 -728
  469. package/examples/advanced-patterns/route-lifecycle-hooks.ts +0 -556
  470. package/examples/advanced-patterns/streaming-responses.ts +0 -656
  471. package/examples/ai-providers/anthropic-integration.ts +0 -388
  472. package/examples/ai-providers/openai-integration.ts +0 -228
  473. package/examples/condition-patterns/function-only-conditions.ts +0 -365
  474. package/examples/condition-patterns/mixed-array-conditions.ts +0 -477
  475. package/examples/condition-patterns/route-skipif-patterns.ts +0 -468
  476. package/examples/condition-patterns/step-skipif-patterns.ts +0 -0
  477. package/examples/condition-patterns/string-only-conditions.ts +0 -296
  478. package/examples/conversation-flows/completion-transitions.ts +0 -318
  479. package/examples/core-concepts/basic-agent.ts +0 -503
  480. package/examples/core-concepts/modern-streaming-api.ts +0 -309
  481. package/examples/core-concepts/schema-driven-extraction.ts +0 -332
  482. package/examples/core-concepts/session-management.ts +0 -494
  483. package/examples/integrations/database-integration.ts +0 -631
  484. package/examples/integrations/healthcare-integration.ts +0 -595
  485. package/examples/integrations/search-integration.ts +0 -530
  486. package/examples/integrations/server-session-management.ts +0 -307
  487. package/examples/persistence/custom-adapter.ts +0 -526
  488. package/examples/persistence/database-persistence.ts +0 -583
  489. package/examples/persistence/memory-sessions.ts +0 -495
  490. package/examples/persistence/prisma-schema.example.prisma +0 -74
  491. package/examples/persistence/redis-persistence.ts +0 -488
  492. package/examples/tools/basic-tools.ts +0 -765
  493. package/examples/tools/data-enrichment-tools.ts +0 -593
  494. package/examples/tools/enhanced-tool-metadata.ts +0 -268
  495. package/examples/tools/streaming-tool-execution.ts +0 -283
  496. package/src/core/BatchExecutor.ts +0 -1187
  497. package/src/core/BatchPromptBuilder.ts +0 -299
  498. package/src/core/Route.ts +0 -678
  499. package/src/types/route.ts +0 -392
@@ -0,0 +1,909 @@
1
+ ---
2
+ title: "v1 → v2 migration"
3
+ description: "Every breaking change in v2 with rename tables and before/after."
4
+ type: migration
5
+ order: 1
6
+ ---
7
+
8
+ # v1 → v2 Migration
9
+
10
+ **Version:** 2.0.0 — Clean break (no shims, no aliases)
11
+
12
+ ## Summary
13
+
14
+ v2 is a clean break — no shims, no aliases. The surface is smaller and the primitives are fewer: `Route` becomes `Flow`, three behavioral types collapse into `Instruction`, `EnhancedTool` folds into `Tool`, and all flow control converges on a single `Directive` shape. This guide covers every breaking change with rename tables and before/after code samples.
15
+
16
+ Other notable changes covered below: the `pendingTransition` session field becomes `pendingDirective`, `Tool.name` collapses into `Tool.id`, the `ConditionTemplate` union is replaced by separate `when` (AI) and `if` (code) fields, `FlowOptions.onComplete` is string-only at the top level, `createAgent` becomes the headline API, agent identity collapses from three fields (`description`, `identity`, `personality`) into one (`persona`), multi-step batching is replaced by `auto: true` steps, and `step.branches` is added as an explicit (non-breaking) alternative to implicit fork.
17
+
18
+ ---
19
+
20
+ ## Table of Contents
21
+
22
+ 1. [Persistence: `pendingTransition` → `pendingDirective`](#1-persistence-pendingtransition--pendingdirective)
23
+ 2. [Removed in v2 — Full Surface List](#2-removed-in-v2--full-surface-list)
24
+ 3. [Route → Flow Rename](#3-route--flow-rename)
25
+ 4. [Guideline / Rule / Prohibition → Instruction](#4-guideline--rule--prohibition--instruction)
26
+ 5. [`condition` / `action` → `when` / `prompt`](#5-condition--action--when--prompt)
27
+ 6. [`onComplete` Cleanup](#6-oncomplete-cleanup)
28
+ 7. [Flow Completion: Farewell Removal + Idle-State Release](#7-flow-completion-farewell-removal--idle-state-release)
29
+ 8. [`createAgent` — The New Headline API](#8-createagent--the-new-headline-api)
30
+ 9. [Tool / EnhancedTool Merge](#9-tool--enhancedtool-merge)
31
+ 10. [ConditionTemplate → `when` / `if` Split](#10-conditiontemplate--when--if-split)
32
+ 11. [Dispatch Replaces `transitionTo` / `nextStepFlow`](#11-dispatch-replaces-transitionto--nextstepflow)
33
+ 12. [Agent Identity → `persona`](#12-agent-identity--persona)
34
+ 13. [Multi-Step Batching → Auto-Steps](#13-multi-step-batching--auto-steps)
35
+ 14. [Implicit Fork → Explicit Branches (Non-Breaking)](#14-implicit-fork--explicit-branches-non-breaking)
36
+
37
+ ---
38
+
39
+ ## 1. Persistence: `pendingTransition` → `pendingDirective`
40
+
41
+ The `SessionState.pendingTransition` field is removed. Its replacement is `SessionState.pendingDirective`, a full `Directive` object (not just a flow id + reason).
42
+
43
+ v2 also adds a `signals` column for forward-compat with the v2.x Signals feature. It's unused at runtime but must be present in your schema.
44
+
45
+ **There is no auto-migration.** If a v1 record carries `pendingTransition` but no `pendingDirective`, v2 ignores it — the pending transition is lost. Run the backfill before deploying v2.
46
+
47
+ ### PostgreSQL / SQLite
48
+
49
+ ```sql
50
+ -- Step 1: Backfill pendingDirective from pendingTransition
51
+ UPDATE sessions
52
+ SET pending_directive = jsonb_build_object(
53
+ 'goTo', jsonb_build_object('flow', pending_transition->'targetFlowId')
54
+ )
55
+ WHERE pending_transition IS NOT NULL
56
+ AND pending_directive IS NULL;
57
+
58
+ -- Step 2: Schema migration
59
+ ALTER TABLE sessions DROP COLUMN pending_transition;
60
+ ALTER TABLE sessions ADD COLUMN pending_directive JSONB;
61
+ ALTER TABLE sessions ADD COLUMN signals JSONB;
62
+ ```
63
+
64
+ For SQLite (no JSONB), use TEXT columns and `json_object()`:
65
+
66
+ ```sql
67
+ UPDATE sessions
68
+ SET pending_directive = json_object(
69
+ 'goTo', json_object('flow', json_extract(pending_transition, '$.targetFlowId'))
70
+ )
71
+ WHERE pending_transition IS NOT NULL
72
+ AND pending_directive IS NULL;
73
+
74
+ ALTER TABLE sessions DROP COLUMN pending_transition;
75
+ ALTER TABLE sessions ADD COLUMN pending_directive TEXT;
76
+ ALTER TABLE sessions ADD COLUMN signals TEXT;
77
+ ```
78
+
79
+ ### MongoDB
80
+
81
+ ```javascript
82
+ db.sessions.updateMany(
83
+ { pendingTransition: { $ne: null }, pendingDirective: { $exists: false } },
84
+ [{
85
+ $set: {
86
+ pendingDirective: {
87
+ goTo: { flow: "$pendingTransition.targetFlowId" }
88
+ }
89
+ }
90
+ }]
91
+ );
92
+
93
+ // Drop legacy field
94
+ db.sessions.updateMany({}, { $unset: { pendingTransition: "" } });
95
+ ```
96
+
97
+ ### Redis
98
+
99
+ Extend your migration Lua script (see the [route-to-flow migration](./route-to-flow.md) for the pattern):
100
+
101
+ ```lua
102
+ local cursor = "0"
103
+ repeat
104
+ local result = redis.call("SCAN", cursor, "MATCH", "session:*", "COUNT", 100)
105
+ cursor = result[1]
106
+ for _, key in ipairs(result[2]) do
107
+ local val = redis.call("GET", key)
108
+ if val then
109
+ -- Replace pendingTransition with pendingDirective in JSON
110
+ val = val:gsub('"pendingTransition"', '"pendingDirective"')
111
+ redis.call("SET", key, val)
112
+ end
113
+ end
114
+ until cursor == "0"
115
+ ```
116
+
117
+ > **Note:** Redis stores serialized JSON. The field-name swap is sufficient if your `pendingTransition` shape was `{ targetFlowId: string }`. The v2 runtime expects `{ goTo: { flow: string } }` — adjust the transform if your v1 shape was different.
118
+
119
+ ### OpenSearch
120
+
121
+ Use the `_reindex` API with a painless script:
122
+
123
+ ```json
124
+ POST _reindex
125
+ {
126
+ "source": { "index": "sessions" },
127
+ "dest": { "index": "sessions_v2" },
128
+ "script": {
129
+ "source": """
130
+ if (ctx._source.containsKey('pendingTransition') && ctx._source.pendingTransition != null) {
131
+ def pt = ctx._source.remove('pendingTransition');
132
+ ctx._source.pendingDirective = ['goTo': ['flow': pt.targetFlowId]];
133
+ }
134
+ """,
135
+ "lang": "painless"
136
+ }
137
+ }
138
+ ```
139
+
140
+ Then swap the alias to `sessions_v2`.
141
+
142
+ ### Prisma Schema
143
+
144
+ ```diff
145
+ model Session {
146
+ // ...
147
+ - pendingTransition Json? @map("pending_transition")
148
+ + pendingDirective Json? @map("pending_directive")
149
+ + signals Json?
150
+ }
151
+ ```
152
+
153
+ Run `npx prisma migrate dev --name v2-directive-migration`.
154
+
155
+ ---
156
+
157
+ ## 2. Removed in v2 — Full Surface List
158
+
159
+ v2 is a clean break. These symbols are gone with no aliases:
160
+
161
+ | v1 Element | Replacement | Migration |
162
+ |---|---|---|
163
+ | `END_FLOW` / `END_FLOW_ID` | Implicit terminus + `{ complete: true }` | Remove sentinel references. Last step in `steps[]` auto-terminates. |
164
+ | `ConditionTemplate` | `when` (AI) + `if` (code) | See [§10](#10-conditiontemplate--when--if-split). |
165
+ | `EnhancedTool` | `Tool` (merged) | See [§9](#9-tool--enhancedtool-merge). |
166
+ | `FlowTransitionConfig` | `Directive` | `{ nextStep: 'X', condition: 'Y' }` → `{ goTo: 'X', reason: 'Y' }` |
167
+ | `FlowCompletionHandler` | `hooks.onComplete: (ctx) => Directive \| void` | Inline the signature change. |
168
+ | `FlowOptions.endStep` | Last step's `prompt` | Move closing text to the last step. |
169
+ | `Flow.endStepSpec` | Removed | Internal — gone with `endStep`. |
170
+ | `Step.endFlow()` | Implicit terminus | `.endFlow(opts)` → just make it the last step. |
171
+ | `Agent.nextStepFlow()` | `Agent.dispatch()` | See [§11](#11-dispatch-replaces-transitionto--nextstepflow). |
172
+ | `Agent.transitionTo()` | `Agent.dispatch()` | See [§11](#11-dispatch-replaces-transitionto--nextstepflow). |
173
+ | `PendingTransition` interface | `Directive` | Replace with `pendingDirective: Directive`. |
174
+ | `SessionState.pendingTransition` | `SessionState.pendingDirective` | See [§1](#1-persistence-pendingtransition--pendingdirective). |
175
+ | `StepResult` (export) | Internal only | Chain methods stay; the return type is no longer public. |
176
+ | `BranchResult` / `BranchSpec` | `BranchEntry` / `BranchMap` | Use `step.branches: [{ if?, when?, then, label? }]`. |
177
+ | `ResponseModal` (export) | Internal | Remove any direct imports. |
178
+ | `ResponsePipeline` (export) | Internal | Remove any direct imports. |
179
+ | `BatchExecutor` / `BatchPromptBuilder` | Auto-steps | See [§13](#13-multi-step-batching--auto-steps). |
180
+ | `PromptComposer` (export) | Internal | Remove any direct imports. |
181
+ | `PromptSectionCache` (export) | Internal | Remove any direct imports. |
182
+ | `CompactionEngine` (export) | Internal | Remove any direct imports. |
183
+ | `FlowRouter` (export) | Internal | Remove any direct imports. |
184
+ | `AutoChainExecutor` (export) | Internal | Remove any direct imports. |
185
+ | `Guideline` / `Rule` / `Prohibition` | `Instruction` | See [§4](#4-guideline--rule--prohibition--instruction). |
186
+ | `Tool.name` | `Tool.id` | The LLM sees `tool.id` as the tool name. See [§9](#9-tool--enhancedtool-merge). |
187
+ | `AgentOptions.description` | `AgentOptions.persona` | See [§12](#12-agent-identity--persona). |
188
+ | `AgentOptions.identity` | `AgentOptions.persona` | See [§12](#12-agent-identity--persona). |
189
+ | `AgentOptions.personality` | `AgentOptions.persona` | See [§12](#12-agent-identity--persona). |
190
+ | `AgentOptions.compositionMode` | Removed | Had no runtime effect. Delete any references. |
191
+ | `AgentOptions.maxStepsPerBatch` | `AgentOptions.maxAutoStepsPerTurn` | See [§13](#13-multi-step-batching--auto-steps). |
192
+ | `StepOptions.skipIf` | `StepOptions.skip` | Function-only field. See [§10](#10-conditiontemplate--when--if-split). |
193
+ | `StepOptions.step` | Removed | Dead code since the `END_FLOW` symbol removal. |
194
+ | `FlowOptions.terms` / `FlowOptions.knowledgeBase` | Agent-level only | Move to `AgentOptions`. |
195
+ | `FlowOptions.identity` / `FlowOptions.personality` | `AgentOptions.persona` or flow-level instruction | See [§12](#12-agent-identity--persona). |
196
+ | `appliedGuidelines` (response) | `appliedInstructions` | Rename in response handling code. |
197
+ | `StoppedReason: 'end_flow'` | `'last_step'` | Update assertions. |
198
+ | `StoppedReason: 'flow_complete'` | `'last_step'` or `'completed'` | Update assertions. |
199
+ | `StoppedReason: 'max_steps_reached'` | `'max_auto_steps'` | Update assertions. |
200
+
201
+ ### New `StoppedReason` values
202
+
203
+ ```typescript
204
+ type StoppedReason =
205
+ | 'needs_input' // unchanged
206
+ | 'last_step' // last step ran — no successor
207
+ | 'completed' // explicit { complete: true } directive
208
+ | 'aborted' // { abort: '...' } directive
209
+ | 'goto' // goTo/goToStep directive short-circuited
210
+ | 'reset' // { reset: true } directive
211
+ | 'halt' // PreDirective halt: true
212
+ | 'reply' // Step.reply or directive reply (LLM skipped)
213
+ | 'max_auto_steps' // auto-step chain cap hit
214
+ | 'prepare_error' // unchanged
215
+ | 'llm_error' // unchanged
216
+ | 'validation_error' // unchanged
217
+ | 'finalize_error'; // unchanged
218
+ ```
219
+
220
+ ---
221
+
222
+ ## 3. Route → Flow Rename
223
+
224
+ The `Route` domain noun was renamed to `Flow` in a minor breaking bump that ships before v2. v2 assumes `Flow` naming everywhere — `Route` / `createRoute` / `session.currentRoute` and the corresponding persistence columns no longer exist.
225
+
226
+ If you haven't run that migration yet, start there: see **[Route → Flow rename](./route-to-flow.md)** for the full rename table, schema changes per adapter, and Redis/OpenSearch backfill scripts. Once that lands, return here for the rest of the v2 changes.
227
+
228
+
229
+ ---
230
+
231
+ ## 4. Guideline / Rule / Prohibition → Instruction
232
+
233
+ The three behavioral primitives collapse into a single `Instruction` type with a `kind` discriminator:
234
+
235
+ ### Rename Table
236
+
237
+ | v1 | v2 `Instruction.kind` | Notes |
238
+ |---|---|---|
239
+ | `Rule` (always do) | `kind: 'must'` | Rendered as `[must]` prefix |
240
+ | `Prohibition` (never do) | `kind: 'never'` | Rendered as `[never]` prefix |
241
+ | `Guideline` (should do) | `kind: 'should'` | Default when `kind` omitted |
242
+
243
+ ### Before / After
244
+
245
+ ```typescript
246
+ // ─── v1 ───
247
+ agent.addRule("Always greet the user by name");
248
+ agent.addProhibition("Never discuss competitors");
249
+ agent.addGuideline({
250
+ when: "User is a returning customer",
251
+ action: "Skip the introduction and get to the point",
252
+ });
253
+
254
+ // ─── v2 ───
255
+ agent.addInstruction({ kind: 'must', prompt: "Always greet the user by name" });
256
+ agent.addInstruction({ kind: 'never', prompt: "Never discuss competitors" });
257
+ agent.addInstruction({
258
+ kind: 'should',
259
+ when: "User is a returning customer",
260
+ prompt: "Skip the introduction and get to the point",
261
+ });
262
+ ```
263
+
264
+ ### Top-level options
265
+
266
+ ```typescript
267
+ // Before
268
+ const agent = createAgent({
269
+ rules: ['Always verify email format'],
270
+ prohibitions: ['Never promise delivery dates'],
271
+ guidelines: [{ when: 'User is upset', prompt: 'Use empathetic tone' }],
272
+ });
273
+
274
+ // After
275
+ const agent = createAgent({
276
+ instructions: [
277
+ { kind: 'must', prompt: 'Always verify email format' },
278
+ { kind: 'never', prompt: 'Never promise delivery dates' },
279
+ { kind: 'should', when: 'User is upset', prompt: 'Use empathetic tone' },
280
+ ],
281
+ });
282
+ ```
283
+
284
+ The same applies at flow and step scope. `FlowOptions.rules`, `FlowOptions.prohibitions`, `FlowOptions.guidelines`, and `StepOptions.guidelines` are all removed — use `instructions` at each level.
285
+
286
+ ### Prompt Rendering Change
287
+
288
+ The heading `## Behavioral Guidelines` becomes `## Instructions`. Line format:
289
+
290
+ ```
291
+ [must] [Always] Always greet the user by name
292
+ [never] [Always] Never discuss competitors
293
+ [should] [When: User is a returning customer] Skip the introduction and get to the point
294
+ ```
295
+
296
+ ### Response Field
297
+
298
+ `response.appliedGuidelines` → `response.appliedInstructions`
299
+
300
+ ```typescript
301
+ // v1
302
+ console.log(response.appliedGuidelines);
303
+
304
+ // v2
305
+ console.log(response.appliedInstructions);
306
+ ```
307
+
308
+ ### Deprecated method removal (Instructions)
309
+
310
+ | Old | New |
311
+ |-----|-----|
312
+ | `agent.createGuideline(g)` | `agent.createInstruction(g)` |
313
+ | `agent.getRules()` | `agent.instructions.filter(i => i.kind === 'must')` |
314
+ | `agent.getProhibitions()` | `agent.instructions.filter(i => i.kind === 'never')` |
315
+ | `flow.createGuideline(g)` | `flow.createInstruction(g)` |
316
+ | `flow.getGuidelines()` | `flow.getInstructions()` |
317
+ | `flow.getRules()` | Removed — use flow instructions |
318
+ | `flow.getProhibitions()` | Removed — use flow instructions |
319
+ | `step.addGuideline(g)` | `step.addInstruction(g)` |
320
+ | `step.getGuidelines()` | `step.getInstructions()` |
321
+
322
+ ### Type alias removal
323
+
324
+ | Old type | Use instead |
325
+ |----------|-------------|
326
+ | `Guideline<C, D>` | `Instruction<C, D>` |
327
+ | `ScopedGuidelines<C, D>` | `ScopedInstructions<C, D>` |
328
+ | `AppliedGuideline` | `AppliedInstruction` |
329
+
330
+ ---
331
+
332
+ ## 5. `condition` / `action` → `when` / `prompt`
333
+
334
+ The guideline shape fields were renamed in v2:
335
+
336
+ | v1 Field | v2 Field | Purpose |
337
+ |---|---|---|
338
+ | `condition` | `when` | AI-evaluated activation condition |
339
+ | `action` | `prompt` | The behavioral instruction text |
340
+
341
+ ### Before / After
342
+
343
+ ```typescript
344
+ // ─── v1 ───
345
+ agent.addGuideline({
346
+ condition: "User is frustrated",
347
+ action: "Be extra empathetic and offer to escalate",
348
+ });
349
+
350
+ // ─── v2 ───
351
+ agent.addInstruction({
352
+ when: "User is frustrated",
353
+ prompt: "Be extra empathetic and offer to escalate",
354
+ });
355
+ ```
356
+
357
+ This also applies to flow-scoped and step-scoped guidelines:
358
+
359
+ ```typescript
360
+ // ─── v1 ───
361
+ flow.addGuideline({
362
+ condition: "Discussing pricing",
363
+ action: "Always mention the free tier first",
364
+ });
365
+
366
+ // ─── v2 ───
367
+ flow.addInstruction({
368
+ when: "Discussing pricing",
369
+ prompt: "Always mention the free tier first",
370
+ });
371
+ ```
372
+
373
+ ---
374
+
375
+ ## 6. `onComplete` Cleanup
376
+
377
+ ### What changed
378
+
379
+ - **Top-level** `FlowOptions.onComplete` accepts **only a string** (flow id sugar).
380
+ - **Function** and **Directive** forms move to `hooks.onComplete`.
381
+ - Setting both throws `FlowConfigurationError` at construction.
382
+
383
+ ### Before / After
384
+
385
+ ```typescript
386
+ // ─── v1: function at top level ───
387
+ agent.createFlow({
388
+ title: "Booking",
389
+ onComplete: (session, context) => {
390
+ return { nextRoute: "Confirmation" };
391
+ },
392
+ steps: [/* ... */],
393
+ });
394
+
395
+ // ─── v2: string at top level (sugar) ───
396
+ agent.createFlow({
397
+ title: "Booking",
398
+ onComplete: "Confirmation", // sugar for hooks.onComplete = () => ({ goTo: 'Confirmation' })
399
+ steps: [/* ... */],
400
+ });
401
+
402
+ // ─── v2: function in hooks ───
403
+ agent.createFlow({
404
+ title: "Booking",
405
+ hooks: {
406
+ onComplete: (ctx) => {
407
+ if (ctx.data.isPremium) return { goTo: "PremiumConfirmation" };
408
+ return { goTo: "Confirmation" };
409
+ },
410
+ },
411
+ steps: [/* ... */],
412
+ });
413
+ ```
414
+
415
+ ### ⚠️ Do NOT set both
416
+
417
+ ```typescript
418
+ // THROWS FlowConfigurationError at construction
419
+ agent.createFlow({
420
+ title: "Booking",
421
+ onComplete: "Confirmation", // ← string sugar
422
+ hooks: { onComplete: () => {...} }, // ← function form — conflict!
423
+ });
424
+ ```
425
+
426
+ ---
427
+
428
+ ## 7. Flow Completion: Farewell Removal + Idle-State Release
429
+
430
+ ### Hardcoded farewell removed
431
+
432
+ v1 injected a synthetic `__COMPLETED__` step with a hardcoded prompt (`"Send a brief, natural farewell message…"`) when a flow completed. This is **gone**. No framework-generated farewell message is emitted. Every word the user sees comes from your step prompts.
433
+
434
+ ### Idle-state release
435
+
436
+ When a flow completes and `onComplete` does not produce a transition:
437
+
438
+ - `session.currentFlow` → `undefined`
439
+ - `session.currentStep` → `undefined`
440
+ - The flow is marked `completed: true` in `flowHistory`
441
+ - The router excludes completed flows from future scoring
442
+ - Next turn: routing runs fresh (or the no-flow fallback triggers)
443
+
444
+ ### Migration: Add an explicit closing step
445
+
446
+ ```typescript
447
+ // ─── v1: relied on framework-generated farewell ───
448
+ agent.createFlow({
449
+ title: "Onboarding",
450
+ steps: [
451
+ { id: "name", collect: ["name"] },
452
+ { id: "email", collect: ["email"] },
453
+ ],
454
+ });
455
+ // Framework would auto-generate "Thank you! I've recorded all..."
456
+
457
+ // ─── v2: author your own closing turn ───
458
+ agent.createFlow({
459
+ title: "Onboarding",
460
+ steps: [
461
+ { id: "name", collect: ["name"] },
462
+ { id: "email", collect: ["email"] },
463
+ { id: "thanks", prompt: "Thank the user warmly. Wish them a great day." },
464
+ ],
465
+ });
466
+ ```
467
+
468
+ ### `flow.reentrant` opt-in
469
+
470
+ If your v1 code relied on the router re-entering a completed flow, that loop is gone. To restore it deliberately:
471
+
472
+ ```typescript
473
+ agent.createFlow({
474
+ title: "Search",
475
+ reentrant: true, // allows re-selection after completion
476
+ requiredFields: ["query"],
477
+ steps: [/* ... */],
478
+ });
479
+ ```
480
+
481
+ When `reentrant: true`, the router can re-select this flow after it completes. On re-entry, fields declared in `requiredFields` / `optionalFields` are cleared so the flow starts fresh.
482
+
483
+ `onComplete` always wins over `reentrant` — if `onComplete` returns a target, the session goes there instead.
484
+
485
+ ---
486
+
487
+ ## 8. `createAgent` — The New Headline API
488
+
489
+ `createAgent` is the recommended entry point in v2. It's equivalent to `new Agent(options)` but reads better in examples and enables stronger generic inference.
490
+
491
+ ```typescript
492
+ import { createAgent, GeminiProvider } from "@falai/agent";
493
+
494
+ const agent = createAgent({
495
+ name: "BookingBot",
496
+ provider: new GeminiProvider({
497
+ apiKey: process.env.GEMINI_API_KEY!,
498
+ model: "models/gemini-2.5-flash",
499
+ }),
500
+ schema: {
501
+ type: "object",
502
+ properties: {
503
+ destination: { type: "string" },
504
+ date: { type: "string" },
505
+ guests: { type: "number" },
506
+ },
507
+ required: ["destination", "date", "guests"],
508
+ },
509
+ flows: [
510
+ {
511
+ title: "Book Trip",
512
+ when: ["User wants to book travel"],
513
+ requiredFields: ["destination", "date", "guests"],
514
+ steps: [
515
+ { id: "ask_dest", prompt: "Where to?", collect: ["destination"] },
516
+ { id: "ask_date", prompt: "When?", collect: ["date"] },
517
+ { id: "ask_guests", prompt: "How many?", collect: ["guests"] },
518
+ ],
519
+ },
520
+ ],
521
+ });
522
+
523
+ const response = await agent.respond("Book a trip to Paris for 2 next Friday");
524
+ ```
525
+
526
+ `new Agent(options)` still works — `createAgent` is sugar, not a replacement.
527
+
528
+
529
+ ---
530
+
531
+ ## 9. Tool / EnhancedTool Merge
532
+
533
+ `EnhancedTool` is removed. Its optional metadata fields are now part of the base `Tool` interface. `Tool.name` is also removed — `Tool.id` is the sole identifier and is what the LLM sees as the tool name.
534
+
535
+ ```typescript
536
+ // ─── v1 ───
537
+ import { EnhancedTool } from "@falai/agent";
538
+
539
+ const tool: EnhancedTool = {
540
+ id: "search",
541
+ name: "Search Database",
542
+ description: "Search the database",
543
+ parameters: { type: "object", properties: {} },
544
+ handler: async (ctx, args) => { /* ... */ },
545
+ isConcurrencySafe: true,
546
+ isReadOnly: true,
547
+ checkPermissions: async (ctx) => ({ allowed: true }),
548
+ };
549
+
550
+ // ─── v2 ───
551
+ import { Tool } from "@falai/agent"; // EnhancedTool is gone
552
+
553
+ const tool: Tool = {
554
+ id: "search_database", // Tool.id is the sole identifier
555
+ description: "Search the database",
556
+ parameters: { type: "object", properties: {} },
557
+ handler: async (ctx, args) => { /* ... */ },
558
+ // Optional metadata (formerly EnhancedTool-only):
559
+ isConcurrencySafe: true,
560
+ isReadOnly: true,
561
+ checkPermissions: async (ctx) => ({ allowed: true }),
562
+ };
563
+ ```
564
+
565
+ Choose descriptive IDs — the LLM sees them. The optional fields that moved to `Tool`: `isConcurrencySafe`, `isReadOnly`, `isDestructive`, `interruptBehavior`, `maxResultSizeChars`, `validateInput`, `checkPermissions`.
566
+
567
+ ### New: `ToolContext.dispatch` and `ToolResult.directive`
568
+
569
+ Tools can now control flow directly:
570
+
571
+ ```typescript
572
+ const refundTool: Tool = {
573
+ id: "check_refund",
574
+ description: "Check refund eligibility",
575
+ parameters: { /* ... */ },
576
+ handler: async (ctx, args) => {
577
+ const order = await lookupOrder(args.orderId);
578
+
579
+ if (order.age > 90) {
580
+ // Imperative: redirect mid-handler
581
+ ctx.dispatch({ goTo: "IneligibleRefund" });
582
+ return { data: "Order too old for refund" };
583
+ }
584
+
585
+ // Declarative: return directive alongside result
586
+ return {
587
+ data: "Eligible for refund",
588
+ directive: { goTo: "ProcessRefund" },
589
+ };
590
+ },
591
+ };
592
+ ```
593
+
594
+ ### Deprecated method removal (Tools)
595
+
596
+ | Old | New |
597
+ |-----|-----|
598
+ | `agent.createTool(t)` | `agent.addTool(t)` |
599
+
600
+ ### Type alias removal (Tools)
601
+
602
+ | Old type | Use instead |
603
+ |----------|-------------|
604
+ | `EnhancedTool<C, D, R>` | `Tool<C, D, R>` |
605
+
606
+ ---
607
+
608
+ ## 10. ConditionTemplate → `when` / `if` Split
609
+
610
+ The v1 `ConditionTemplate` type (a union of `string | function | Array<string | function>`) is removed. Conditions are now split into two distinct fields:
611
+
612
+ | Field | Evaluator | Cost | Accepts |
613
+ |---|---|---|---|
614
+ | `when` | AI (LLM call) | Tokens | `string \| string[]` |
615
+ | `if` | Code (function) | Free | `(ctx) => boolean \| Array<(ctx) => boolean>` |
616
+
617
+ ### Rules
618
+
619
+ - `when` accepts **only strings** — passing a function throws `FlowConfigurationError` at construction.
620
+ - `if` accepts **only functions**.
621
+ - When both are set: `if` runs first (free); `when` runs only if `if` passes (saves tokens).
622
+ - Arrays are AND-conjunctions.
623
+
624
+ ### Before / After
625
+
626
+ ```typescript
627
+ // ─── v1: mixed ConditionTemplate ───
628
+ agent.createFlow({
629
+ title: "Premium Support",
630
+ when: [
631
+ "User needs urgent help", // AI condition
632
+ (ctx) => ctx.context.userTier === "premium", // code condition
633
+ ],
634
+ steps: [/* ... */],
635
+ });
636
+
637
+ // ─── v2: split into when + if ───
638
+ agent.createFlow({
639
+ title: "Premium Support",
640
+ when: ["User needs urgent help"], // AI only
641
+ if: [(ctx) => ctx.context.userTier === "premium"], // code only
642
+ steps: [/* ... */],
643
+ });
644
+ ```
645
+
646
+ ### `skipIf` → `skip`
647
+
648
+ On steps, `skipIf` is renamed to `skip` and accepts only `if`-style functions:
649
+
650
+ ```typescript
651
+ // ─── v1 ───
652
+ { id: "ask_name", skipIf: (data) => !!data.name, /* ... */ }
653
+
654
+ // ─── v2 ───
655
+ { id: "ask_name", skip: (data) => !!data.name, /* ... */ }
656
+ ```
657
+
658
+ ---
659
+
660
+ ## 11. Dispatch Replaces `transitionTo` / `nextStepFlow`
661
+
662
+ Both `Agent.transitionTo()` and `Agent.nextStepFlow()` are removed. Use `Agent.dispatch()`:
663
+
664
+ ```typescript
665
+ // ─── v1 ───
666
+ await agent.nextStepFlow("Feedback", session, "user requested feedback");
667
+ await agent.transitionTo("Billing");
668
+
669
+ // ─── v2 ───
670
+ await agent.dispatch({ goTo: "Feedback", reason: "user requested feedback" }, session);
671
+ await agent.dispatch("Billing"); // string sugar for { goTo: "Billing" }
672
+ ```
673
+
674
+ `dispatch` sets `session.pendingDirective` — the directive is applied at the start of the next turn (not immediately). For synchronous in-place application without a `respond()` call, use `agent.applyDirective(directive, session)`.
675
+
676
+ ### Deprecated method removal (Dispatch & session access)
677
+
678
+ | Old | New |
679
+ |-----|-----|
680
+ | `agent.transitionTo(...)` | `agent.dispatch({ goTo: ... }, session)` |
681
+ | `agent.nextStepFlow(...)` | `agent.dispatch({ goTo: ... }, session)` |
682
+ | `agent.getCurrentSession()` | `agent.currentSession` |
683
+ | `agent.setCurrentSession(s)` | `agent.currentSession = s` |
684
+ | `agent.clearCurrentSession()` | `agent.currentSession = undefined` |
685
+ | `agent.getSchema()` | `agent.schema` |
686
+ | `agent.getKnowledgeBase()` | `agent.knowledgeBase` |
687
+
688
+ ### Type alias removal (Dispatch)
689
+
690
+ | Old type | Use instead |
691
+ |----------|-------------|
692
+ | `FlowTransitionConfig` | `Directive` |
693
+ | `FlowCompletionHandler` | `hooks.onComplete` function |
694
+ | `PendingTransition` | `Directive` (assigned to `session.pendingDirective`) |
695
+
696
+ ---
697
+
698
+ ## 12. Agent Identity → `persona`
699
+
700
+ Three v1 agent fields — `description`, `identity`, `personality` — collapse into a single `persona` field. `persona` is a `Template<TContext>` covering role, tone, and self-concept. Merge your old copy into one coherent prompt.
701
+
702
+ ### Before / After
703
+
704
+ ```typescript
705
+ // ─── v1 ───
706
+ const agent = createAgent({
707
+ name: 'Support Bot',
708
+ description: 'A helpful customer support agent',
709
+ identity: 'You are a senior support specialist at Acme Corp.',
710
+ personality: 'Friendly, concise, solution-oriented',
711
+ // ...
712
+ });
713
+
714
+ // ─── v2 ───
715
+ const agent = createAgent({
716
+ name: 'Support Bot',
717
+ goal: 'Help customers resolve issues quickly',
718
+ persona: 'You are a senior support specialist at Acme Corp. Communicate in a friendly, concise, solution-oriented style.',
719
+ // ...
720
+ });
721
+ ```
722
+
723
+ ### Flow-level identity / personality removed
724
+
725
+ `FlowOptions.identity` and `FlowOptions.personality` are removed. Use the agent-level `persona` for global voice, or a flow-level instruction for flow-specific voice:
726
+
727
+ ```typescript
728
+ // Before
729
+ const flow: FlowOptions = {
730
+ title: 'Billing',
731
+ identity: 'You are a billing specialist',
732
+ personality: 'Formal and precise',
733
+ };
734
+
735
+ // After — use a flow-level instruction
736
+ const flow: FlowOptions = {
737
+ title: 'Billing',
738
+ instructions: [
739
+ { kind: 'should', prompt: 'Act as a billing specialist. Use formal, precise language.' },
740
+ ],
741
+ };
742
+ ```
743
+
744
+ ### Flow-level terms / knowledgeBase removed
745
+
746
+ Terms and knowledge base are now agent-level only. Move them up:
747
+
748
+ ```typescript
749
+ // Before
750
+ const flow: FlowOptions = {
751
+ title: 'Booking',
752
+ terms: [{ name: 'PNR', description: 'Passenger Name Record' }],
753
+ knowledgeBase: { policies: { /* ... */ } },
754
+ };
755
+
756
+ // After — move to agent level
757
+ const agent = createAgent({
758
+ terms: [{ name: 'PNR', description: 'Passenger Name Record' }],
759
+ knowledgeBase: { policies: { /* ... */ } },
760
+ flows: [{ title: 'Booking', /* ... */ }],
761
+ });
762
+ ```
763
+
764
+
765
+ ---
766
+
767
+ ## 13. Multi-Step Batching → Auto-Steps
768
+
769
+ Multi-step batching (`maxStepsPerBatch`, `BatchExecutor`, `BatchPromptBuilder`) conflated two different concerns: skipping the LLM for non-interactive nodes, and compressing N user-facing steps into one response. v2 splits them: the first becomes `auto: true`, the second becomes a single step with multi-field `collect`.
770
+
771
+ | Old | New |
772
+ |-----|-----|
773
+ | `AgentOptions.maxStepsPerBatch` | `AgentOptions.maxAutoStepsPerTurn` (default `10`) |
774
+ | `BatchExecutor`, `BatchPromptBuilder`, `needsInput` | Removed |
775
+ | Batch events (`batch_start`, `step_included`, `batch_complete`, …) | Step events (`step_entered`, `step_skipped`, `step_completed`) — `auto: boolean` in payload |
776
+ | `StoppedReason: 'max_steps_reached'` | `'max_auto_steps'` |
777
+
778
+ **Restructure pattern:** N tiny ask-steps batched into one call → one step with `collect: [field1, field2, field3]` and a prompt that asks for whatever is still missing. Pre-extraction handles the "user dumped everything in one message" case.
779
+
780
+ **Auto-step pattern:** Computation between asks → mark the compute step `auto: true`. It runs `onEnter` / `prepare` / `branches` / `onExit` with no LLM call. The pipeline walks consecutive auto-steps until it hits an interactive step or terminating directive.
781
+
782
+ ```typescript
783
+ // v2: enrichment between two asks
784
+ { id: 'ask_email', collect: ['email'], prompt: 'What email?' },
785
+ { id: 'enrich', auto: true, prepare: async ({ data }) => {
786
+ const customer = await crm.findByEmail(data.email);
787
+ return { contextUpdate: { isReturning: !!customer } };
788
+ } },
789
+ { id: 'confirm', prompt: ({ context }) =>
790
+ context.isReturning ? 'Welcome back. Confirm?' : 'Confirm your order?' },
791
+ ```
792
+
793
+ **Validation:** an `auto: true` step throws `FlowConfigurationError` if it sets `prompt`, `collect`, `tools`, or `finalize`. `onEnter`, `prepare`, `onExit`, `branches`, `requires`, `skip` are all allowed. No schema change — auto-steps does not touch `SessionState`, existing persistence adapters need no migration.
794
+
795
+ ---
796
+
797
+ ## 14. Implicit Fork → Explicit Branches (Non-Breaking)
798
+
799
+ This is **optional**. The implicit-fork pattern (multiple successor steps each with their own `step.when`) still works in v2. `step.branches` is a new declarative form for the same routing behavior, recommended when the fork is the point of the step rather than incidental to it.
800
+
801
+ ### When to convert
802
+
803
+ - The source step exists solely to route — it's a decision point, not a conversation node.
804
+ - Three or more successors with `when` conditions where the decision tree is hard to follow.
805
+ - You want code-only routing (`if`) to skip LLM evaluation entirely.
806
+ - You need mixed targets: some branches go to local steps, others jump to other flows or emit full Directives.
807
+
808
+ ### Stay implicit when
809
+
810
+ - The flow reads as a linear chain A → B → C where B is occasionally skipped.
811
+ - Only two successors, with self-explanatory `when` conditions.
812
+
813
+ ### Before / After
814
+
815
+ ```typescript
816
+ // Before — routing scattered across 4 target steps
817
+ {
818
+ steps: [
819
+ { id: 'triage', prompt: 'How can I help?' },
820
+ { id: 'billing', when: 'asking about billing', prompt: '…' },
821
+ { id: 'tech_support', when: 'asking a technical question', prompt: '…' },
822
+ { id: 'cancellation', when: 'wants to cancel', prompt: '…' },
823
+ { id: 'general', prompt: '…' },
824
+ ],
825
+ }
826
+
827
+ // After — routing declared once at the source
828
+ {
829
+ steps: [
830
+ {
831
+ id: 'triage',
832
+ prompt: 'How can I help?',
833
+ branches: [
834
+ { when: 'asking about billing', then: 'billing' },
835
+ { when: 'asking a technical question', then: 'tech_support' },
836
+ { when: 'wants to cancel', then: 'cancellation' },
837
+ { then: 'general' }, // unconditional fallback (must be last)
838
+ ],
839
+ },
840
+ { id: 'billing', prompt: '…' },
841
+ { id: 'tech_support', prompt: '…' },
842
+ { id: 'cancellation', prompt: '…' },
843
+ { id: 'general', prompt: '…' },
844
+ ],
845
+ }
846
+ ```
847
+
848
+ Runtime behavior is identical: AI evaluates entries in declaration order; first match wins; an entry without `when`/`if` is the fallback. The only difference is where the routing logic lives.
849
+
850
+ ### Mixed targets
851
+
852
+ Branches can route to local step ids, flow ids (sugar for `goTo`), or full Directives — implicit forks can only target steps in the same flow:
853
+
854
+ ```typescript
855
+ branches: [
856
+ { if: ({ data }) => data.plan === 'enterprise', then: 'enterprise_path' }, // local step
857
+ { when: 'wants to cancel', then: 'CancellationFlow' }, // flow id
858
+ { when: 'needs a refund', then: { goTo: { flow: 'Refund', data: { source: 'triage' } } } }, // Directive
859
+ { then: 'general' },
860
+ ]
861
+ ```
862
+
863
+ Upgrade an AI condition to a code condition by swapping `when` for `if` — the LLM call goes away:
864
+
865
+ ```typescript
866
+ // Before: AI evaluates this — costs tokens
867
+ { when: 'user is on the enterprise plan', then: 'enterprise_path' }
868
+
869
+ // After: code evaluates this — free
870
+ { if: ({ data }) => data.plan === 'enterprise', then: 'enterprise_path' }
871
+ ```
872
+
873
+ ---
874
+
875
+ ## Verification
876
+
877
+ After migrating, confirm no legacy references remain. Run from your repo root:
878
+
879
+ ```bash
880
+ rg -n '\b(Route|RouteOptions|RoutingEngine|END_FLOW|END_ROUTE|ConditionTemplate|EnhancedTool|FlowTransitionConfig|FlowCompletionHandler|pendingTransition|nextStepFlow|transitionTo|endStep|BranchResult|BranchSpec|StepResult|appliedGuidelines|Guideline|Prohibition|skipIf|maxStepsPerBatch|BatchExecutor)\b' \
881
+ --glob '**/*.ts' \
882
+ --glob '!node_modules/**' \
883
+ --glob '!dist/**'
884
+ ```
885
+
886
+ Confirm v1 agent identity fields are gone:
887
+
888
+ ```bash
889
+ rg -n '\b(description|identity|personality)\s*:' \
890
+ --glob '**/*.ts' \
891
+ --glob '!node_modules/**' \
892
+ --glob '!dist/**' \
893
+ | rg 'createAgent|new Agent\('
894
+ ```
895
+
896
+ Then run the type checker:
897
+
898
+ ```bash
899
+ npx tsc --noEmit
900
+ # or
901
+ bun run typecheck
902
+ ```
903
+
904
+ If both commands return clean (no matches; exit code 0), your migration is complete.
905
+
906
+ ## Cross-References
907
+
908
+ - [Route → Flow rename](./route-to-flow.md) — the rename pass that ships before v2
909
+ - [CHANGELOG](../../CHANGELOG.md) — full v2.0 release notes