@guidify-ai/vapi-studio 0.1.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 (407) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +129 -0
  3. package/agent/AGENTS.md +42 -0
  4. package/agent/CLAUDE.md +15 -0
  5. package/agent/claude/rules/ui-and-api-identity.md +9 -0
  6. package/agent/claude/rules/vapi-studio-best-practices.md +36 -0
  7. package/agent/cursor/ui-and-api-identity.mdc +16 -0
  8. package/agent/cursor/vapi-studio-best-practices.mdc +43 -0
  9. package/dist/adapters/vapi/vapi-sse.compiler.d.ts +61 -0
  10. package/dist/adapters/vapi/vapi-sse.compiler.d.ts.map +1 -0
  11. package/dist/adapters/vapi/vapi-sse.compiler.js +396 -0
  12. package/dist/adapters/vapi/vapi-sse.compiler.js.map +1 -0
  13. package/dist/analytics/analytics-tags.d.ts +60 -0
  14. package/dist/analytics/analytics-tags.d.ts.map +1 -0
  15. package/dist/analytics/analytics-tags.js +27 -0
  16. package/dist/analytics/analytics-tags.js.map +1 -0
  17. package/dist/brain/adapters/chatgpt-brain.adapter.d.ts +27 -0
  18. package/dist/brain/adapters/chatgpt-brain.adapter.d.ts.map +1 -0
  19. package/dist/brain/adapters/chatgpt-brain.adapter.js +94 -0
  20. package/dist/brain/adapters/chatgpt-brain.adapter.js.map +1 -0
  21. package/dist/brain/adapters/claude-brain.adapter.d.ts +24 -0
  22. package/dist/brain/adapters/claude-brain.adapter.d.ts.map +1 -0
  23. package/dist/brain/adapters/claude-brain.adapter.js +96 -0
  24. package/dist/brain/adapters/claude-brain.adapter.js.map +1 -0
  25. package/dist/brain/adapters/gemini-brain.adapter.d.ts +24 -0
  26. package/dist/brain/adapters/gemini-brain.adapter.d.ts.map +1 -0
  27. package/dist/brain/adapters/gemini-brain.adapter.js +106 -0
  28. package/dist/brain/adapters/gemini-brain.adapter.js.map +1 -0
  29. package/dist/brain/adapters/grok-brain.adapter.d.ts +24 -0
  30. package/dist/brain/adapters/grok-brain.adapter.d.ts.map +1 -0
  31. package/dist/brain/adapters/grok-brain.adapter.js +90 -0
  32. package/dist/brain/adapters/grok-brain.adapter.js.map +1 -0
  33. package/dist/brain/adapters/json-llm-brain.base.d.ts +63 -0
  34. package/dist/brain/adapters/json-llm-brain.base.d.ts.map +1 -0
  35. package/dist/brain/adapters/json-llm-brain.base.js +511 -0
  36. package/dist/brain/adapters/json-llm-brain.base.js.map +1 -0
  37. package/dist/brain/adapters/mock-brain.adapter.d.ts +32 -0
  38. package/dist/brain/adapters/mock-brain.adapter.d.ts.map +1 -0
  39. package/dist/brain/adapters/mock-brain.adapter.js +201 -0
  40. package/dist/brain/adapters/mock-brain.adapter.js.map +1 -0
  41. package/dist/brain/adapters/mock-provider-brains.adapter.d.ts +22 -0
  42. package/dist/brain/adapters/mock-provider-brains.adapter.d.ts.map +1 -0
  43. package/dist/brain/adapters/mock-provider-brains.adapter.js +48 -0
  44. package/dist/brain/adapters/mock-provider-brains.adapter.js.map +1 -0
  45. package/dist/brain/brain-clarify.d.ts +75 -0
  46. package/dist/brain/brain-clarify.d.ts.map +1 -0
  47. package/dist/brain/brain-clarify.js +146 -0
  48. package/dist/brain/brain-clarify.js.map +1 -0
  49. package/dist/brain/brain-config.d.ts +20 -0
  50. package/dist/brain/brain-config.d.ts.map +1 -0
  51. package/dist/brain/brain-config.js +20 -0
  52. package/dist/brain/brain-config.js.map +1 -0
  53. package/dist/brain/brain-judge.d.ts +68 -0
  54. package/dist/brain/brain-judge.d.ts.map +1 -0
  55. package/dist/brain/brain-judge.js +111 -0
  56. package/dist/brain/brain-judge.js.map +1 -0
  57. package/dist/brain/brain-ranking.d.ts +41 -0
  58. package/dist/brain/brain-ranking.d.ts.map +1 -0
  59. package/dist/brain/brain-ranking.js +103 -0
  60. package/dist/brain/brain-ranking.js.map +1 -0
  61. package/dist/brain/brain-usage.tracker.d.ts +48 -0
  62. package/dist/brain/brain-usage.tracker.d.ts.map +1 -0
  63. package/dist/brain/brain-usage.tracker.js +106 -0
  64. package/dist/brain/brain-usage.tracker.js.map +1 -0
  65. package/dist/brain/brain.port.d.ts +63 -0
  66. package/dist/brain/brain.port.d.ts.map +1 -0
  67. package/dist/brain/brain.port.js +7 -0
  68. package/dist/brain/brain.port.js.map +1 -0
  69. package/dist/brain/brain.service.d.ts +14 -0
  70. package/dist/brain/brain.service.d.ts.map +1 -0
  71. package/dist/brain/brain.service.js +27 -0
  72. package/dist/brain/brain.service.js.map +1 -0
  73. package/dist/brain/claude-cheap-models.d.ts +18 -0
  74. package/dist/brain/claude-cheap-models.d.ts.map +1 -0
  75. package/dist/brain/claude-cheap-models.js +53 -0
  76. package/dist/brain/claude-cheap-models.js.map +1 -0
  77. package/dist/brain/gemini-cheap-models.d.ts +18 -0
  78. package/dist/brain/gemini-cheap-models.d.ts.map +1 -0
  79. package/dist/brain/gemini-cheap-models.js +53 -0
  80. package/dist/brain/gemini-cheap-models.js.map +1 -0
  81. package/dist/brain/grok-cheap-models.d.ts +18 -0
  82. package/dist/brain/grok-cheap-models.d.ts.map +1 -0
  83. package/dist/brain/grok-cheap-models.js +53 -0
  84. package/dist/brain/grok-cheap-models.js.map +1 -0
  85. package/dist/brain/llm-model-pricing.d.ts +29 -0
  86. package/dist/brain/llm-model-pricing.d.ts.map +1 -0
  87. package/dist/brain/llm-model-pricing.js +38 -0
  88. package/dist/brain/llm-model-pricing.js.map +1 -0
  89. package/dist/brain/openai-cheap-models.d.ts +34 -0
  90. package/dist/brain/openai-cheap-models.d.ts.map +1 -0
  91. package/dist/brain/openai-cheap-models.js +72 -0
  92. package/dist/brain/openai-cheap-models.js.map +1 -0
  93. package/dist/brain/prompt-injection-guard.d.ts +34 -0
  94. package/dist/brain/prompt-injection-guard.d.ts.map +1 -0
  95. package/dist/brain/prompt-injection-guard.js +109 -0
  96. package/dist/brain/prompt-injection-guard.js.map +1 -0
  97. package/dist/channel/channel-tools.d.ts +72 -0
  98. package/dist/channel/channel-tools.d.ts.map +1 -0
  99. package/dist/channel/channel-tools.js +131 -0
  100. package/dist/channel/channel-tools.js.map +1 -0
  101. package/dist/conversation/call-turn-queue.d.ts +64 -0
  102. package/dist/conversation/call-turn-queue.d.ts.map +1 -0
  103. package/dist/conversation/call-turn-queue.js +156 -0
  104. package/dist/conversation/call-turn-queue.js.map +1 -0
  105. package/dist/conversation/conversation-bootstrap.service.d.ts +60 -0
  106. package/dist/conversation/conversation-bootstrap.service.d.ts.map +1 -0
  107. package/dist/conversation/conversation-bootstrap.service.js +383 -0
  108. package/dist/conversation/conversation-bootstrap.service.js.map +1 -0
  109. package/dist/conversation/conversation-entry.d.ts +38 -0
  110. package/dist/conversation/conversation-entry.d.ts.map +1 -0
  111. package/dist/conversation/conversation-entry.js +17 -0
  112. package/dist/conversation/conversation-entry.js.map +1 -0
  113. package/dist/conversation/conversation-history.d.ts +31 -0
  114. package/dist/conversation/conversation-history.d.ts.map +1 -0
  115. package/dist/conversation/conversation-history.js +53 -0
  116. package/dist/conversation/conversation-history.js.map +1 -0
  117. package/dist/conversation/conversation-limits.d.ts +49 -0
  118. package/dist/conversation/conversation-limits.d.ts.map +1 -0
  119. package/dist/conversation/conversation-limits.js +44 -0
  120. package/dist/conversation/conversation-limits.js.map +1 -0
  121. package/dist/conversation/conversation-resume.service.d.ts +39 -0
  122. package/dist/conversation/conversation-resume.service.d.ts.map +1 -0
  123. package/dist/conversation/conversation-resume.service.js +234 -0
  124. package/dist/conversation/conversation-resume.service.js.map +1 -0
  125. package/dist/conversation/conversation-schema.d.ts +23 -0
  126. package/dist/conversation/conversation-schema.d.ts.map +1 -0
  127. package/dist/conversation/conversation-schema.js +3 -0
  128. package/dist/conversation/conversation-schema.js.map +1 -0
  129. package/dist/conversation/listen-expectation.d.ts +145 -0
  130. package/dist/conversation/listen-expectation.d.ts.map +1 -0
  131. package/dist/conversation/listen-expectation.js +219 -0
  132. package/dist/conversation/listen-expectation.js.map +1 -0
  133. package/dist/conversation/listen-timeout.d.ts +42 -0
  134. package/dist/conversation/listen-timeout.d.ts.map +1 -0
  135. package/dist/conversation/listen-timeout.js +57 -0
  136. package/dist/conversation/listen-timeout.js.map +1 -0
  137. package/dist/conversation/supervised-conversation.d.ts +64 -0
  138. package/dist/conversation/supervised-conversation.d.ts.map +1 -0
  139. package/dist/conversation/supervised-conversation.js +198 -0
  140. package/dist/conversation/supervised-conversation.js.map +1 -0
  141. package/dist/conversation/supervised-conversation.registry.d.ts +14 -0
  142. package/dist/conversation/supervised-conversation.registry.d.ts.map +1 -0
  143. package/dist/conversation/supervised-conversation.registry.js +47 -0
  144. package/dist/conversation/supervised-conversation.registry.js.map +1 -0
  145. package/dist/conversation/types.d.ts +52 -0
  146. package/dist/conversation/types.d.ts.map +1 -0
  147. package/dist/conversation/types.js +3 -0
  148. package/dist/conversation/types.js.map +1 -0
  149. package/dist/events/conversation-console.d.ts +17 -0
  150. package/dist/events/conversation-console.d.ts.map +1 -0
  151. package/dist/events/conversation-console.js +863 -0
  152. package/dist/events/conversation-console.js.map +1 -0
  153. package/dist/events/daily-log.driver.d.ts +35 -0
  154. package/dist/events/daily-log.driver.d.ts.map +1 -0
  155. package/dist/events/daily-log.driver.js +206 -0
  156. package/dist/events/daily-log.driver.js.map +1 -0
  157. package/dist/events/event.service.d.ts +24 -0
  158. package/dist/events/event.service.d.ts.map +1 -0
  159. package/dist/events/event.service.js +141 -0
  160. package/dist/events/event.service.js.map +1 -0
  161. package/dist/events/route-forensics.d.ts +38 -0
  162. package/dist/events/route-forensics.d.ts.map +1 -0
  163. package/dist/events/route-forensics.js +85 -0
  164. package/dist/events/route-forensics.js.map +1 -0
  165. package/dist/events/studio-event-bus.d.ts +17 -0
  166. package/dist/events/studio-event-bus.d.ts.map +1 -0
  167. package/dist/events/studio-event-bus.js +37 -0
  168. package/dist/events/studio-event-bus.js.map +1 -0
  169. package/dist/events/studio-event.d.ts +44 -0
  170. package/dist/events/studio-event.d.ts.map +1 -0
  171. package/dist/events/studio-event.js +27 -0
  172. package/dist/events/studio-event.js.map +1 -0
  173. package/dist/flow/condition.d.ts +35 -0
  174. package/dist/flow/condition.d.ts.map +1 -0
  175. package/dist/flow/condition.js +246 -0
  176. package/dist/flow/condition.js.map +1 -0
  177. package/dist/flow/flow-loader.d.ts +71 -0
  178. package/dist/flow/flow-loader.d.ts.map +1 -0
  179. package/dist/flow/flow-loader.js +182 -0
  180. package/dist/flow/flow-loader.js.map +1 -0
  181. package/dist/forms/form-html.d.ts +30 -0
  182. package/dist/forms/form-html.d.ts.map +1 -0
  183. package/dist/forms/form-html.js +130 -0
  184. package/dist/forms/form-html.js.map +1 -0
  185. package/dist/forms/form.tokens.d.ts +3 -0
  186. package/dist/forms/form.tokens.d.ts.map +1 -0
  187. package/dist/forms/form.tokens.js +6 -0
  188. package/dist/forms/form.tokens.js.map +1 -0
  189. package/dist/forms/form.types.d.ts +81 -0
  190. package/dist/forms/form.types.d.ts.map +1 -0
  191. package/dist/forms/form.types.js +36 -0
  192. package/dist/forms/form.types.js.map +1 -0
  193. package/dist/forms/forms.service.d.ts +52 -0
  194. package/dist/forms/forms.service.d.ts.map +1 -0
  195. package/dist/forms/forms.service.js +434 -0
  196. package/dist/forms/forms.service.js.map +1 -0
  197. package/dist/forms/noop-form-dispose.adapter.d.ts +12 -0
  198. package/dist/forms/noop-form-dispose.adapter.d.ts.map +1 -0
  199. package/dist/forms/noop-form-dispose.adapter.js +27 -0
  200. package/dist/forms/noop-form-dispose.adapter.js.map +1 -0
  201. package/dist/forms/twilio-sms-form-dispose.adapter.d.ts +33 -0
  202. package/dist/forms/twilio-sms-form-dispose.adapter.d.ts.map +1 -0
  203. package/dist/forms/twilio-sms-form-dispose.adapter.js +125 -0
  204. package/dist/forms/twilio-sms-form-dispose.adapter.js.map +1 -0
  205. package/dist/forms/twilio-sms.env.d.ts +62 -0
  206. package/dist/forms/twilio-sms.env.d.ts.map +1 -0
  207. package/dist/forms/twilio-sms.env.js +147 -0
  208. package/dist/forms/twilio-sms.env.js.map +1 -0
  209. package/dist/forms/twilio-sms.sender.d.ts +27 -0
  210. package/dist/forms/twilio-sms.sender.d.ts.map +1 -0
  211. package/dist/forms/twilio-sms.sender.js +75 -0
  212. package/dist/forms/twilio-sms.sender.js.map +1 -0
  213. package/dist/identity/email-parse.d.ts +20 -0
  214. package/dist/identity/email-parse.d.ts.map +1 -0
  215. package/dist/identity/email-parse.js +102 -0
  216. package/dist/identity/email-parse.js.map +1 -0
  217. package/dist/identity/index.d.ts +17 -0
  218. package/dist/identity/index.d.ts.map +1 -0
  219. package/dist/identity/index.js +23 -0
  220. package/dist/identity/index.js.map +1 -0
  221. package/dist/index.d.ts +108 -0
  222. package/dist/index.d.ts.map +1 -0
  223. package/dist/index.js +300 -0
  224. package/dist/index.js.map +1 -0
  225. package/dist/integrations/integration-client.d.ts +41 -0
  226. package/dist/integrations/integration-client.d.ts.map +1 -0
  227. package/dist/integrations/integration-client.js +152 -0
  228. package/dist/integrations/integration-client.js.map +1 -0
  229. package/dist/integrations/jwt-hmac.d.ts +33 -0
  230. package/dist/integrations/jwt-hmac.d.ts.map +1 -0
  231. package/dist/integrations/jwt-hmac.js +108 -0
  232. package/dist/integrations/jwt-hmac.js.map +1 -0
  233. package/dist/intention/code-intention.d.ts +94 -0
  234. package/dist/intention/code-intention.d.ts.map +1 -0
  235. package/dist/intention/code-intention.js +89 -0
  236. package/dist/intention/code-intention.js.map +1 -0
  237. package/dist/intention/intention-constants.d.ts +37 -0
  238. package/dist/intention/intention-constants.d.ts.map +1 -0
  239. package/dist/intention/intention-constants.js +37 -0
  240. package/dist/intention/intention-constants.js.map +1 -0
  241. package/dist/intentions/standard-intentions.d.ts +26 -0
  242. package/dist/intentions/standard-intentions.d.ts.map +1 -0
  243. package/dist/intentions/standard-intentions.js +28 -0
  244. package/dist/intentions/standard-intentions.js.map +1 -0
  245. package/dist/node/agent-node.d.ts +156 -0
  246. package/dist/node/agent-node.d.ts.map +1 -0
  247. package/dist/node/agent-node.js +179 -0
  248. package/dist/node/agent-node.js.map +1 -0
  249. package/dist/node/catch-directive.d.ts +33 -0
  250. package/dist/node/catch-directive.d.ts.map +1 -0
  251. package/dist/node/catch-directive.js +41 -0
  252. package/dist/node/catch-directive.js.map +1 -0
  253. package/dist/output/conversation-output.d.ts +113 -0
  254. package/dist/output/conversation-output.d.ts.map +1 -0
  255. package/dist/output/conversation-output.js +100 -0
  256. package/dist/output/conversation-output.js.map +1 -0
  257. package/dist/persistence/conversation.entity.d.ts +27 -0
  258. package/dist/persistence/conversation.entity.d.ts.map +1 -0
  259. package/dist/persistence/conversation.entity.js +115 -0
  260. package/dist/persistence/conversation.entity.js.map +1 -0
  261. package/dist/persistence/conversation.repository.d.ts +82 -0
  262. package/dist/persistence/conversation.repository.d.ts.map +1 -0
  263. package/dist/persistence/conversation.repository.js +277 -0
  264. package/dist/persistence/conversation.repository.js.map +1 -0
  265. package/dist/persistence/project.entity.d.ts +12 -0
  266. package/dist/persistence/project.entity.d.ts.map +1 -0
  267. package/dist/persistence/project.entity.js +46 -0
  268. package/dist/persistence/project.entity.js.map +1 -0
  269. package/dist/persistence/project.repository.d.ts +17 -0
  270. package/dist/persistence/project.repository.d.ts.map +1 -0
  271. package/dist/persistence/project.repository.js +69 -0
  272. package/dist/persistence/project.repository.js.map +1 -0
  273. package/dist/persistence/provider-ingress.entity.d.ts +18 -0
  274. package/dist/persistence/provider-ingress.entity.d.ts.map +1 -0
  275. package/dist/persistence/provider-ingress.entity.js +91 -0
  276. package/dist/persistence/provider-ingress.entity.js.map +1 -0
  277. package/dist/persistence/provider-ingress.repository.d.ts +21 -0
  278. package/dist/persistence/provider-ingress.repository.d.ts.map +1 -0
  279. package/dist/persistence/provider-ingress.repository.js +76 -0
  280. package/dist/persistence/provider-ingress.repository.js.map +1 -0
  281. package/dist/studio-ui/assets/index-BGd2OhLv.js +84 -0
  282. package/dist/studio-ui/assets/index-BGd2OhLv.js.map +1 -0
  283. package/dist/studio-ui/assets/index-DnJos5x2.css +1 -0
  284. package/dist/studio-ui/index.html +13 -0
  285. package/dist/studio-ui-mount/index.d.ts +6 -0
  286. package/dist/studio-ui-mount/index.d.ts.map +1 -0
  287. package/dist/studio-ui-mount/index.js +13 -0
  288. package/dist/studio-ui-mount/index.js.map +1 -0
  289. package/dist/studio-ui-mount/resolve-studio-ui-root.d.ts +6 -0
  290. package/dist/studio-ui-mount/resolve-studio-ui-root.d.ts.map +1 -0
  291. package/dist/studio-ui-mount/resolve-studio-ui-root.js +25 -0
  292. package/dist/studio-ui-mount/resolve-studio-ui-root.js.map +1 -0
  293. package/dist/studio-ui-mount/studio-spa.controller.d.ts +18 -0
  294. package/dist/studio-ui-mount/studio-spa.controller.d.ts.map +1 -0
  295. package/dist/studio-ui-mount/studio-spa.controller.js +57 -0
  296. package/dist/studio-ui-mount/studio-spa.controller.js.map +1 -0
  297. package/dist/studio-ui-mount/studio-ui.module.d.ts +15 -0
  298. package/dist/studio-ui-mount/studio-ui.module.d.ts.map +1 -0
  299. package/dist/studio-ui-mount/studio-ui.module.js +47 -0
  300. package/dist/studio-ui-mount/studio-ui.module.js.map +1 -0
  301. package/dist/studio-ui-mount/studio-ui.tokens.d.ts +2 -0
  302. package/dist/studio-ui-mount/studio-ui.tokens.d.ts.map +1 -0
  303. package/dist/studio-ui-mount/studio-ui.tokens.js +5 -0
  304. package/dist/studio-ui-mount/studio-ui.tokens.js.map +1 -0
  305. package/dist/supervisor/supervisor-cascade.d.ts +55 -0
  306. package/dist/supervisor/supervisor-cascade.d.ts.map +1 -0
  307. package/dist/supervisor/supervisor-cascade.js +261 -0
  308. package/dist/supervisor/supervisor-cascade.js.map +1 -0
  309. package/dist/supervisor/supervisor-engine.d.ts +9 -0
  310. package/dist/supervisor/supervisor-engine.d.ts.map +1 -0
  311. package/dist/supervisor/supervisor-engine.js +64 -0
  312. package/dist/supervisor/supervisor-engine.js.map +1 -0
  313. package/dist/supervisor/supervisor-limits.d.ts +8 -0
  314. package/dist/supervisor/supervisor-limits.d.ts.map +1 -0
  315. package/dist/supervisor/supervisor-limits.js +36 -0
  316. package/dist/supervisor/supervisor-limits.js.map +1 -0
  317. package/dist/supervisor/supervisor-node-exec.d.ts +39 -0
  318. package/dist/supervisor/supervisor-node-exec.d.ts.map +1 -0
  319. package/dist/supervisor/supervisor-node-exec.js +201 -0
  320. package/dist/supervisor/supervisor-node-exec.js.map +1 -0
  321. package/dist/supervisor/supervisor-orchestration.d.ts +24 -0
  322. package/dist/supervisor/supervisor-orchestration.d.ts.map +1 -0
  323. package/dist/supervisor/supervisor-orchestration.js +395 -0
  324. package/dist/supervisor/supervisor-orchestration.js.map +1 -0
  325. package/dist/supervisor/supervisor-portal.d.ts +75 -0
  326. package/dist/supervisor/supervisor-portal.d.ts.map +1 -0
  327. package/dist/supervisor/supervisor-portal.js +320 -0
  328. package/dist/supervisor/supervisor-portal.js.map +1 -0
  329. package/dist/supervisor/supervisor-route.d.ts +53 -0
  330. package/dist/supervisor/supervisor-route.d.ts.map +1 -0
  331. package/dist/supervisor/supervisor-route.js +308 -0
  332. package/dist/supervisor/supervisor-route.js.map +1 -0
  333. package/dist/supervisor/supervisor-special-turns.d.ts +34 -0
  334. package/dist/supervisor/supervisor-special-turns.d.ts.map +1 -0
  335. package/dist/supervisor/supervisor-special-turns.js +308 -0
  336. package/dist/supervisor/supervisor-special-turns.js.map +1 -0
  337. package/dist/supervisor/supervisor.d.ts +44 -0
  338. package/dist/supervisor/supervisor.d.ts.map +1 -0
  339. package/dist/supervisor/supervisor.js +79 -0
  340. package/dist/supervisor/supervisor.js.map +1 -0
  341. package/dist/supervisor/supervisor.types.d.ts +71 -0
  342. package/dist/supervisor/supervisor.types.d.ts.map +1 -0
  343. package/dist/supervisor/supervisor.types.js +8 -0
  344. package/dist/supervisor/supervisor.types.js.map +1 -0
  345. package/dist/tasks/studio-task-queue.d.ts +93 -0
  346. package/dist/tasks/studio-task-queue.d.ts.map +1 -0
  347. package/dist/tasks/studio-task-queue.js +226 -0
  348. package/dist/tasks/studio-task-queue.js.map +1 -0
  349. package/dist/util/studio-env.d.ts +7 -0
  350. package/dist/util/studio-env.d.ts.map +1 -0
  351. package/dist/util/studio-env.js +32 -0
  352. package/dist/util/studio-env.js.map +1 -0
  353. package/dist/vapi-studio.module.d.ts +55 -0
  354. package/dist/vapi-studio.module.d.ts.map +1 -0
  355. package/dist/vapi-studio.module.js +166 -0
  356. package/dist/vapi-studio.module.js.map +1 -0
  357. package/dist/workflow/workflow-handoff.service.d.ts +29 -0
  358. package/dist/workflow/workflow-handoff.service.d.ts.map +1 -0
  359. package/dist/workflow/workflow-handoff.service.js +165 -0
  360. package/dist/workflow/workflow-handoff.service.js.map +1 -0
  361. package/dist/workflow/workflow-loader.d.ts +48 -0
  362. package/dist/workflow/workflow-loader.d.ts.map +1 -0
  363. package/dist/workflow/workflow-loader.js +87 -0
  364. package/dist/workflow/workflow-loader.js.map +1 -0
  365. package/docs/README.md +69 -0
  366. package/docs/assets/deterministic-assistant-flow.svg +128 -0
  367. package/docs/assets/vapi-studio-stack.svg +26 -0
  368. package/docs/best-practices/README.md +37 -0
  369. package/docs/best-practices/brain-and-prompt-injection.md +70 -0
  370. package/docs/best-practices/conversation-design.md +152 -0
  371. package/docs/best-practices/debugging-and-observability.md +49 -0
  372. package/docs/best-practices/documentation-layers.md +31 -0
  373. package/docs/best-practices/identity-and-pii.md +66 -0
  374. package/docs/best-practices/nodes-and-listens.md +116 -0
  375. package/docs/best-practices/ui-and-api-identity.md +51 -0
  376. package/docs/building-apps/creating-an-app.md +59 -0
  377. package/docs/building-apps/example-apps.md +23 -0
  378. package/docs/building-apps/overview.md +27 -0
  379. package/docs/getting-started/installation.md +52 -0
  380. package/docs/getting-started/introduction.md +23 -0
  381. package/docs/getting-started/quick-start.md +23 -0
  382. package/docs/guide/concepts.md +103 -0
  383. package/docs/guide/forms.md +102 -0
  384. package/docs/guide/handbook.md +21 -0
  385. package/docs/guide/introduction.md +56 -0
  386. package/docs/guide/module-setup.md +68 -0
  387. package/docs/guide/vapi-adapter.md +70 -0
  388. package/docs/guide/workflow-squad.md +59 -0
  389. package/docs/guides/agents.md +85 -0
  390. package/docs/guides/docker-compose.events.stub.yaml +27 -0
  391. package/docs/guides/documentation.md +13 -0
  392. package/docs/guides/extending-events.md +155 -0
  393. package/docs/guides/node-conventions.md +59 -0
  394. package/docs/guides/speckit.md +56 -0
  395. package/docs/reference/data-model.md +79 -0
  396. package/docs/reference/environment-variables.md +60 -0
  397. package/docs/reference/events-and-logging.md +137 -0
  398. package/docs/reference/flow-schema.md +79 -0
  399. package/docs/reference/runtime-api.md +708 -0
  400. package/docs/reference/security.md +41 -0
  401. package/docs/reference/standard-intentions.md +49 -0
  402. package/docs/reference/testing.md +15 -0
  403. package/docs/samples/events/nest-listener.example.ts +17 -0
  404. package/docs/samples/events/redis-bridge.example.ts +44 -0
  405. package/package.json +81 -0
  406. package/scripts/fix-access-modifiers.mjs +85 -0
  407. package/scripts/install-agent-refs.cjs +196 -0
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.intentionList = intentionList;
4
+ exports.tryForceIntentions = tryForceIntentions;
5
+ exports.tryMatchIntentions = tryMatchIntentions;
6
+ exports.buildBrainCandidates = buildBrainCandidates;
7
+ const conversation_history_1 = require("../conversation/conversation-history");
8
+ const standard_intentions_1 = require("../intentions/standard-intentions");
9
+ const code_intention_1 = require("../intention/code-intention");
10
+ const conversation_output_1 = require("../output/conversation-output");
11
+ const flow_loader_1 = require("../flow/flow-loader");
12
+ const conversation_console_1 = require("../events/conversation-console");
13
+ function intentionList() {
14
+ return this.intentions ? [...this.intentions.values()] : [];
15
+ }
16
+ /**
17
+ * phase: 'force' — before listen/Brain. First before()===true wins (registry order).
18
+ */
19
+ /**
20
+ * phase: 'force' — before listen/Brain. First before()===true wins (registry order).
21
+ */
22
+ async function tryForceIntentions(input) {
23
+ const forceList = this.intentionList().filter((i) => i.phase === code_intention_1.INTENTION_CASCADE_PHASE.Force);
24
+ if (!forceList.length)
25
+ return null;
26
+ const ctx = (0, code_intention_1.intentionContextFromRuntime)({
27
+ runtime: input.runtime,
28
+ userText: input.userText,
29
+ events: this.events,
30
+ });
31
+ const output = new conversation_output_1.BufferedConversationOutput(input.onSay);
32
+ for (const intention of forceList) {
33
+ const ok = await intention.before(ctx);
34
+ if (!ok)
35
+ continue;
36
+ const confidence = (await intention.match(ctx)) ?? 1;
37
+ const runResult = await intention.run(ctx);
38
+ await intention.after(ctx);
39
+ const gotoNodeId = runResult?.kind === code_intention_1.INTENTION_RUN_KIND.Goto
40
+ ? runResult.nodeId
41
+ : intention.toNodeId ?? null;
42
+ const reason = (runResult && 'reason' in runResult ? runResult.reason : undefined) ??
43
+ intention.reason ??
44
+ null;
45
+ const payload = {
46
+ conversationId: input.runtime.conversationId,
47
+ runtimeInstanceId: input.runtime.runtimeInstanceId,
48
+ providerCallId: input.runtime.providerCallId,
49
+ turnNumber: input.runtime.turn.turnNumber,
50
+ intention: intention.name,
51
+ phase: code_intention_1.INTENTION_CASCADE_PHASE.Force,
52
+ from: input.runtime.currentNodeId,
53
+ to: gotoNodeId,
54
+ confidence,
55
+ priority: intention.priority,
56
+ boost: intention.boost,
57
+ reason,
58
+ userText: input.userText,
59
+ memory: (0, conversation_console_1.snapshotUserMemory)(input.runtime.memory),
60
+ };
61
+ if (input.runtime.conversationId) {
62
+ await this.events.persist(input.runtime.conversationId, 'INTENTION_FORCE', payload);
63
+ }
64
+ else {
65
+ this.events.log('info', 'INTENTION_FORCE', payload);
66
+ }
67
+ const rankedName = gotoNodeId
68
+ ? (0, flow_loader_1.conditionGotoIntention)(gotoNodeId)
69
+ : intention.name;
70
+ const ranked = [
71
+ {
72
+ name: rankedName,
73
+ confidence: Math.min(1, Math.max(0, confidence)),
74
+ priority: intention.priority || 1_000_000,
75
+ rank: 0,
76
+ },
77
+ ];
78
+ const routed = await this.routeIntentions({
79
+ runtime: input.runtime,
80
+ userText: input.userText,
81
+ output,
82
+ ranked,
83
+ forceHop: 0,
84
+ resolvedVia: code_intention_1.ROUTE_RESOLVED_VIA.IntentionForce,
85
+ allowMiss: true,
86
+ });
87
+ if (!routed) {
88
+ this.events.log('warn', 'INTENTION_FORCE_MISSED', {
89
+ ...payload,
90
+ note: 'force intention matched but no node accepted before()',
91
+ });
92
+ continue;
93
+ }
94
+ this.stampPendingToolNode(input.runtime, routed.result, routed.selectedNodeId);
95
+ return {
96
+ runtime: input.runtime,
97
+ intentionNames: [intention.name],
98
+ selectedNodeId: routed.selectedNodeId,
99
+ selectedClass: routed.selectedClass,
100
+ result: routed.result,
101
+ actions: output.actions,
102
+ portalOriginRestored: routed.portalOriginRestored,
103
+ };
104
+ }
105
+ return null;
106
+ }
107
+ /**
108
+ * phase: 'match' — local confidence; may skip Brain. goto from run() routes now.
109
+ */
110
+ /**
111
+ * phase: 'match' — local confidence; may skip Brain. goto from run() routes now.
112
+ */
113
+ async function tryMatchIntentions(input) {
114
+ const matchList = this.intentionList().filter((i) => i.phase === code_intention_1.INTENTION_CASCADE_PHASE.Match);
115
+ if (!matchList.length)
116
+ return null;
117
+ const ctx = (0, code_intention_1.intentionContextFromRuntime)({
118
+ runtime: input.runtime,
119
+ userText: input.userText,
120
+ events: this.events,
121
+ });
122
+ for (const intention of matchList) {
123
+ const ok = await intention.before(ctx);
124
+ if (!ok)
125
+ continue;
126
+ const matched = await intention.match(ctx);
127
+ if (matched == null)
128
+ continue;
129
+ const confidence = Math.min(1, Math.max(0, matched));
130
+ if (confidence < input.confidenceThreshold)
131
+ continue;
132
+ const runResult = await intention.run(ctx);
133
+ await intention.after(ctx);
134
+ this.events.log('info', 'INTENTION_MATCH', {
135
+ conversationId: input.runtime.conversationId,
136
+ runtimeInstanceId: input.runtime.runtimeInstanceId,
137
+ turnNumber: input.runtime.turn.turnNumber,
138
+ intention: intention.name,
139
+ confidence,
140
+ run: runResult,
141
+ userText: input.userText,
142
+ });
143
+ const gotoNodeId = runResult?.kind === code_intention_1.INTENTION_RUN_KIND.Goto
144
+ ? runResult.nodeId
145
+ : intention.toNodeId ?? null;
146
+ if (gotoNodeId) {
147
+ const output = new conversation_output_1.BufferedConversationOutput(input.onSay);
148
+ const routed = await this.routeIntentions({
149
+ runtime: input.runtime,
150
+ userText: input.userText,
151
+ output,
152
+ ranked: [
153
+ {
154
+ name: (0, flow_loader_1.conditionGotoIntention)(gotoNodeId),
155
+ confidence,
156
+ priority: intention.priority || 1_000_000,
157
+ rank: 0,
158
+ },
159
+ ],
160
+ forceHop: 0,
161
+ resolvedVia: code_intention_1.ROUTE_RESOLVED_VIA.IntentionMatch,
162
+ allowMiss: true,
163
+ });
164
+ if (routed) {
165
+ this.stampPendingToolNode(input.runtime, routed.result, routed.selectedNodeId);
166
+ return {
167
+ kind: 'routed',
168
+ result: {
169
+ runtime: input.runtime,
170
+ intentionNames: [intention.name],
171
+ selectedNodeId: routed.selectedNodeId,
172
+ selectedClass: routed.selectedClass,
173
+ result: routed.result,
174
+ actions: output.actions,
175
+ portalOriginRestored: routed.portalOriginRestored,
176
+ },
177
+ };
178
+ }
179
+ }
180
+ return { kind: 'score', name: intention.name, confidence };
181
+ }
182
+ return null;
183
+ }
184
+ /**
185
+ * Limited Brain candidate set for this listen:
186
+ * - listen-prioritized next-node intentions (with boost + priority)
187
+ * - registered CodeIntention boost/priority overlays
188
+ * - all portal intentions (except: while in `mad`, only the mad portal — sticky)
189
+ * - studio.isUnknownTransition (scan-failure global; not while sticky mad)
190
+ * - if no listen yet: all normal-flow intentions + portals
191
+ */
192
+ /**
193
+ * Limited Brain candidate set for this listen:
194
+ * - listen-prioritized next-node intentions (with boost + priority)
195
+ * - registered CodeIntention boost/priority overlays
196
+ * - all portal intentions (except: while in `mad`, only the mad portal — sticky)
197
+ * - studio.isUnknownTransition (scan-failure global; not while sticky mad)
198
+ * - if no listen yet: all normal-flow intentions + portals
199
+ */
200
+ function buildBrainCandidates(listen, runtime) {
201
+ const byName = new Map();
202
+ const upsert = (option) => {
203
+ const existing = byName.get(option.name);
204
+ if (!existing) {
205
+ byName.set(option.name, {
206
+ ...option,
207
+ priority: option.priority ?? conversation_history_1.DEFAULT_INTENTION_PRIORITY,
208
+ });
209
+ return;
210
+ }
211
+ byName.set(option.name, {
212
+ ...existing,
213
+ boost: Math.max(existing.boost ?? 0, option.boost ?? 0),
214
+ priority: Math.max(existing.priority ?? conversation_history_1.DEFAULT_INTENTION_PRIORITY, option.priority ?? conversation_history_1.DEFAULT_INTENTION_PRIORITY),
215
+ source: existing.source === 'listen' ? 'listen' : option.source,
216
+ });
217
+ };
218
+ for (const intent of listen?.intentions ?? []) {
219
+ upsert({
220
+ name: intent.name,
221
+ boost: intent.boost,
222
+ priority: intent.priority,
223
+ source: 'listen',
224
+ });
225
+ }
226
+ for (const intention of this.intentionList()) {
227
+ if (intention.phase === code_intention_1.INTENTION_CASCADE_PHASE.Force)
228
+ continue;
229
+ upsert({
230
+ name: intention.name,
231
+ boost: intention.boost,
232
+ priority: intention.priority,
233
+ source: 'runtime',
234
+ });
235
+ }
236
+ const stickyMad = runtime?.portalState.activePortalId === 'mad';
237
+ const madIntentionNames = stickyMad
238
+ ? new Set(this.flowLoader.getFlow().nodes.mad?.intentions ?? [])
239
+ : null;
240
+ for (const name of this.flowLoader.portalIntentionNames()) {
241
+ if (madIntentionNames && !madIntentionNames.has(name)) {
242
+ continue;
243
+ }
244
+ upsert({ name, source: 'portal' });
245
+ }
246
+ if (!listen?.intentions?.length) {
247
+ for (const name of this.flowLoader.normalIntentionNames()) {
248
+ upsert({ name, source: 'flow' });
249
+ }
250
+ }
251
+ if (!stickyMad) {
252
+ upsert({
253
+ name: standard_intentions_1.STANDARD_INTENTIONS.isUnknownTransition,
254
+ boost: 0,
255
+ priority: 0,
256
+ source: 'runtime',
257
+ });
258
+ }
259
+ return [...byName.values()];
260
+ }
261
+ //# sourceMappingURL=supervisor-cascade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-cascade.js","sourceRoot":"","sources":["../../src/supervisor/sup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oB,EAAE,EAAE,CAAC;YAC1D,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,CAAC;YACL,IAAI,EAAE,yCAAmB,CAAC,mBAAmB;YAC7C,KAAK,EAAE,CAAC;YACR,QAAQ,EAAE,CAAC;YACX,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Assembled Supervisor runtime — Nest `Supervisor` is a thin DI facade over this.
3
+ * Methods live in focused modules and bind onto one engine object so cascade ↔
4
+ * route ↔ portal can call each other without circular Nest providers.
5
+ */
6
+ import type { SupervisorEngine, SupervisorServices } from './supervisor.types';
7
+ export type { SupervisorEngine, SupervisorServices } from './supervisor.types';
8
+ export declare function createSupervisorEngine(services: SupervisorServices): SupervisorEngine;
9
+ //# sourceMappingURL=supervisor-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-engine.d.ts","sourceRoot":"","sources":["../../src/supervisor/supervisor-engine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAU/E,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAY/E,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,kBAAkB,GAC3B,gBAAgB,CAWlB"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createSupervisorEngine = createSupervisorEngine;
37
+ const orchestration = __importStar(require("./supervisor-orchestration"));
38
+ const limits = __importStar(require("./supervisor-limits"));
39
+ const specialTurns = __importStar(require("./supervisor-special-turns"));
40
+ const route = __importStar(require("./supervisor-route"));
41
+ const portal = __importStar(require("./supervisor-portal"));
42
+ const nodeExec = __importStar(require("./supervisor-node-exec"));
43
+ const cascade = __importStar(require("./supervisor-cascade"));
44
+ const methodBags = [
45
+ orchestration,
46
+ limits,
47
+ specialTurns,
48
+ route,
49
+ portal,
50
+ nodeExec,
51
+ cascade,
52
+ ];
53
+ function createSupervisorEngine(services) {
54
+ const engine = { ...services };
55
+ for (const bag of methodBags) {
56
+ for (const [name, fn] of Object.entries(bag)) {
57
+ if (typeof fn !== 'function')
58
+ continue;
59
+ engine[name] = fn.bind(engine);
60
+ }
61
+ }
62
+ return engine;
63
+ }
64
+ //# sourceMappingURL=supervisor-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-engine.js","sourceRoot":"","sources":["../../src/supervisor/supervisor-engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,wDAaC;AAjCD,0EAA4D;AAC5D,4DAA8C;AAC9C,yEAA2D;AAC3D,0DAA4C;AAC5C,4DAA8C;AAC9C,iEAAmD;AACnD,8DAAgD;AAIhD,MAAM,UAAU,GAAG;IACjB,aAAa;IACb,MAAM;IACN,YAAY;IACZ,KAAK;IACL,MAAM;IACN,QAAQ;IACR,OAAO;CACC,CAAC;AAEX,SAAgB,sBAAsB,CACpC,QAA4B;IAE5B,MAAM,MAAM,GAAG,EAAE,GAAG,QAAQ,EAAsB,CAAC;IACnD,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7C,IAAI,OAAO,EAAE,KAAK,UAAU;gBAAE,SAAS;YACtC,MAA6C,CAAC,IAAI,CAAC,GAClD,EACD,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { SupervisedConversation } from '../conversation/supervised-conversation';
2
+ import type { SupervisorEngine } from './supervisor.types';
3
+ import type { TurnExecutionResult } from './supervisor.types';
4
+ export declare function enforceConversationLimits(this: SupervisorEngine, input: {
5
+ runtime: SupervisedConversation;
6
+ onSay?: (text: string) => Promise<void>;
7
+ }): Promise<TurnExecutionResult | null>;
8
+ //# sourceMappingURL=supervisor-limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-limits.d.ts","sourceRoot":"","sources":["../../src/supervisor/supervisor-limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAMtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE;IAC7E,OAAO,EAAE,sBAAsB,CAAC;IAChC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAgCtC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enforceConversationLimits = enforceConversationLimits;
4
+ const conversation_limits_1 = require("../conversation/conversation-limits");
5
+ const conversation_output_1 = require("../output/conversation-output");
6
+ async function enforceConversationLimits(input) {
7
+ const limits = this.conversationLimits ?? (0, conversation_limits_1.resolveConversationLimits)();
8
+ const check = (0, conversation_limits_1.evaluateConversationLimits)({
9
+ turnNumber: input.runtime.turn.turnNumber,
10
+ createdAt: input.runtime.createdAt,
11
+ limits,
12
+ });
13
+ if (!check.exceeded)
14
+ return null;
15
+ const output = new conversation_output_1.BufferedConversationOutput(input.onSay);
16
+ const result = await output.endCall(limits.endMessage);
17
+ this.events.log('warn', 'CONVERSATION_LIMIT_EXCEEDED', {
18
+ conversationId: input.runtime.conversationId,
19
+ providerCallId: input.runtime.providerCallId,
20
+ runtimeInstanceId: input.runtime.runtimeInstanceId,
21
+ turnNumber: input.runtime.turn.turnNumber,
22
+ reason: check.reason,
23
+ elapsedMs: check.elapsedMs,
24
+ maxTurns: limits.maxTurns,
25
+ maxDurationMs: limits.maxDurationMs,
26
+ });
27
+ return {
28
+ runtime: input.runtime,
29
+ intentionNames: [],
30
+ selectedNodeId: input.runtime.currentNodeId ?? 'conversation_limit',
31
+ selectedClass: 'ConversationLimit',
32
+ result,
33
+ actions: output.actions,
34
+ };
35
+ }
36
+ //# sourceMappingURL=supervisor-limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-limits.js","sourceRoot":"","sources":["../../src/supervisor/supervisor-limits.ts"],"names":[],"mappings":";;AAUA,8DAmCC;AA5CD,6EAG6C;AAC7C,uEAA2E;AAKpE,KAAK,UAAU,yBAAyB,CAAyB,KAGvE;IACC,MAAM,MAAM,GACV,IAAI,CAAC,kBAAkB,IAAI,IAAA,+CAAyB,GAAE,CAAC;IACzD,MAAM,KAAK,GAAG,IAAA,gDAA0B,EAAC;QACvC,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU;QACzC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS;QAClC,MAAM;KACP,CAAC,CAAC;IACH,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAEjC,MAAM,MAAM,GAAG,IAAI,gDAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAEvD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,6BAA6B,EAAE;QACrD,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,cAAc;QAC5C,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,cAAc;QAC5C,iBAAiB,EAAE,KAAK,CAAC,OAAO,CAAC,iBAAiB;QAClD,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU;QACzC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,cAAc,EAAE,EAAE;QAClB,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,aAAa,IAAI,oBAAoB;QACnE,aAAa,EAAE,mBAAmB;QAClC,MAAM;QACN,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { SupervisedConversation } from '../conversation/supervised-conversation';
2
+ import { type NodeContext, type AgentNode } from '../node/agent-node';
3
+ import { BufferedConversationOutput, type NodeResult } from '../output/conversation-output';
4
+ import type { FlowNodeDefinition } from '../flow/flow-loader';
5
+ import type { SupervisorEngine } from './supervisor.types';
6
+ export declare function executeNodeWithCatch(this: SupervisorEngine, input: {
7
+ runtime: SupervisedConversation;
8
+ userText: string;
9
+ output: BufferedConversationOutput;
10
+ node: AgentNode;
11
+ candidate: FlowNodeDefinition;
12
+ intentionName: string;
13
+ ctx: NodeContext;
14
+ restarts: number;
15
+ forceHop: number;
16
+ }): Promise<{
17
+ kind: 'done';
18
+ result: NodeResult;
19
+ } | {
20
+ kind: 'forceIntention';
21
+ intention: string;
22
+ }>;
23
+ /**
24
+ * Stamp the resolved listen window onto the active expectation.
25
+ * sayAndListen timeout > listen() timeout > Node.listenTimeoutSeconds > default.
26
+ */
27
+ export declare function stampListenTimeout(this: SupervisorEngine, runtime: SupervisedConversation, node: AgentNode, fromSayAndListen?: number): void;
28
+ export declare function enterPortal(this: SupervisorEngine, runtime: SupervisedConversation, candidate: FlowNodeDefinition): string | null | undefined;
29
+ export declare function enterNormal(this: SupervisorEngine, runtime: SupervisedConversation, candidate: FlowNodeDefinition): string | null | undefined;
30
+ /**
31
+ * After a toolCall terminal action, remember which Node requested it so the
32
+ * next Custom LLM turn with role:tool can re-enter without Brain scan.
33
+ */
34
+ /**
35
+ * After a toolCall terminal action, remember which Node requested it so the
36
+ * next Custom LLM turn with role:tool can re-enter without Brain scan.
37
+ */
38
+ export declare function stampPendingToolNode(this: SupervisorEngine, runtime: SupervisedConversation, result: NodeResult, selectedNodeId: string): void;
39
+ //# sourceMappingURL=supervisor-node-exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-node-exec.d.ts","sourceRoot":"","sources":["../../src/supervisor/supervisor-node-exec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAOtF,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,0BAA0B,EAC1B,KAAK,UAAU,EAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAM9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE;IACxE,OAAO,EAAE,sBAAsB,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,0BAA0B,CAAC;IACnC,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,WAAW,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CACP;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAChD,CA+HA;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EACvD,OAAO,EAAE,sBAAsB,EAC/B,IAAI,EAAE,SAAS,EACf,gBAAgB,CAAC,EAAE,MAAM,GACxB,IAAI,CAkBN;AAID,wBAAgB,WAAW,CAAC,IAAI,EAAE,gBAAgB,EAChD,OAAO,EAAE,sBAAsB,EAC/B,SAAS,EAAE,kBAAkB,GAC5B,MAAM,GAAG,IAAI,GAAG,SAAS,CA4B3B;AAID,wBAAgB,WAAW,CAAC,IAAI,EAAE,gBAAgB,EAChD,OAAO,EAAE,sBAAsB,EAC/B,SAAS,EAAE,kBAAkB,GAC5B,MAAM,GAAG,IAAI,GAAG,SAAS,CAc3B;AAED;;;GAGG;AAIH;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,EACzD,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,UAAU,EAClB,cAAc,EAAE,MAAM,GACrB,IAAI,CAeN"}
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeNodeWithCatch = executeNodeWithCatch;
4
+ exports.stampListenTimeout = stampListenTimeout;
5
+ exports.enterPortal = enterPortal;
6
+ exports.enterNormal = enterNormal;
7
+ exports.stampPendingToolNode = stampPendingToolNode;
8
+ const conversation_history_1 = require("../conversation/conversation-history");
9
+ const listen_expectation_1 = require("../conversation/listen-expectation");
10
+ const listen_timeout_1 = require("../conversation/listen-timeout");
11
+ const channel_tools_1 = require("../channel/channel-tools");
12
+ const conversation_console_1 = require("../events/conversation-console");
13
+ const route_forensics_1 = require("../events/route-forensics");
14
+ const supervisor_types_1 = require("./supervisor.types");
15
+ async function executeNodeWithCatch(input) {
16
+ const { runtime, output, node, candidate, intentionName, ctx, restarts, } = input;
17
+ // Register listen BEFORE speech so mid-talk interrupts still bind here.
18
+ const listenExpectation = await node.listen(ctx);
19
+ runtime.listenExpectation = listenExpectation;
20
+ this.stampListenTimeout(runtime, node);
21
+ if (listenExpectation) {
22
+ this.events.log('info', 'LISTEN_REGISTERED', {
23
+ conversationId: runtime.conversationId,
24
+ runtimeInstanceId: runtime.runtimeInstanceId,
25
+ nodeId: candidate.id,
26
+ class: candidate.class,
27
+ listen: runtime.listenExpectation,
28
+ restart: restarts,
29
+ });
30
+ }
31
+ this.events.log('info', 'NODE_ENTER', {
32
+ conversationId: runtime.conversationId,
33
+ runtimeInstanceId: runtime.runtimeInstanceId,
34
+ nodeId: candidate.id,
35
+ class: candidate.class,
36
+ intention: intentionName,
37
+ portal: Boolean(candidate.portal),
38
+ originNodeId: runtime.portalState.originNodeId,
39
+ normalFlowNodeId: runtime.normalFlowNodeId,
40
+ activePortalId: runtime.portalState.activePortalId,
41
+ restart: restarts,
42
+ turnNumber: runtime.turn.turnNumber,
43
+ memory: (0, conversation_console_1.snapshotUserMemory)(runtime.memory),
44
+ });
45
+ if (restarts === 0) {
46
+ (0, conversation_history_1.appendNodeVisit)(runtime.history, {
47
+ nodeId: candidate.id,
48
+ intention: intentionName,
49
+ turnNumber: runtime.turn.turnNumber,
50
+ at: new Date().toISOString(),
51
+ });
52
+ }
53
+ try {
54
+ const result = await node.run(ctx);
55
+ if (result.kind === 'sayAndListen') {
56
+ runtime.listenExpectation = (0, listen_expectation_1.mergeSayAndListenOptions)(runtime.listenExpectation, result.sayAndListen);
57
+ this.stampListenTimeout(runtime, node, result.sayAndListen?.timeoutSeconds);
58
+ if (result.sayAndListen?.extract?.fields?.length) {
59
+ this.events.log('info', 'LISTEN_EXTRACT_REGISTERED', {
60
+ conversationId: runtime.conversationId,
61
+ runtimeInstanceId: runtime.runtimeInstanceId,
62
+ nodeId: candidate.id,
63
+ fields: result.sayAndListen.extract.fields,
64
+ hasOnExtracted: Boolean(result.sayAndListen.extract.onExtracted),
65
+ });
66
+ }
67
+ }
68
+ await node.after(ctx, result);
69
+ this.events.log('info', 'NODE_AFTER', {
70
+ conversationId: runtime.conversationId,
71
+ runtimeInstanceId: runtime.runtimeInstanceId,
72
+ providerCallId: runtime.providerCallId,
73
+ nodeId: candidate.id,
74
+ class: candidate.class,
75
+ intention: intentionName,
76
+ resultKind: result.kind,
77
+ resultDetail: (0, route_forensics_1.nodeResultForensics)(result),
78
+ turnNumber: runtime.turn.turnNumber,
79
+ memory: (0, conversation_console_1.snapshotUserMemory)(runtime.memory),
80
+ actions: (0, route_forensics_1.actionForensics)(output.actions),
81
+ });
82
+ return { kind: 'done', result };
83
+ }
84
+ catch (error) {
85
+ const directive = await node.catch(ctx, error);
86
+ this.events.log('warn', 'NODE_CATCH', {
87
+ conversationId: runtime.conversationId,
88
+ runtimeInstanceId: runtime.runtimeInstanceId,
89
+ nodeId: candidate.id,
90
+ class: candidate.class,
91
+ error: error instanceof Error
92
+ ? { name: error.name, message: error.message }
93
+ : { message: String(error) },
94
+ directive,
95
+ restart: restarts,
96
+ });
97
+ if (directive.kind === 'restartNode') {
98
+ if (restarts >= supervisor_types_1.MAX_NODE_RESTARTS) {
99
+ throw new Error(`restartNode limit (${supervisor_types_1.MAX_NODE_RESTARTS}) exceeded for ${candidate.id}`);
100
+ }
101
+ // Drop partial speech from the failed attempt before retrying.
102
+ output.actions.length = 0;
103
+ return this.executeNodeWithCatch({
104
+ ...input,
105
+ restarts: restarts + 1,
106
+ });
107
+ }
108
+ if (directive.kind === 'forceIntention') {
109
+ output.actions.length = 0;
110
+ return { kind: 'forceIntention', intention: directive.intention };
111
+ }
112
+ if (directive.kind === 'result') {
113
+ await node.after(ctx, directive.result);
114
+ return { kind: 'done', result: directive.result };
115
+ }
116
+ throw error;
117
+ }
118
+ }
119
+ /**
120
+ * Stamp the resolved listen window onto the active expectation.
121
+ * sayAndListen timeout > listen() timeout > Node.listenTimeoutSeconds > default.
122
+ */
123
+ function stampListenTimeout(runtime, node, fromSayAndListen) {
124
+ const timeoutSeconds = (0, listen_timeout_1.resolveListenTimeoutSeconds)({
125
+ fromSayAndListen,
126
+ fromListen: runtime.listenExpectation?.timeoutSeconds,
127
+ fromNode: node.listenTimeoutSeconds,
128
+ });
129
+ if (!runtime.listenExpectation) {
130
+ runtime.listenExpectation = {
131
+ intentions: [],
132
+ timeoutSeconds,
133
+ interruptible: node.interruptible,
134
+ };
135
+ return;
136
+ }
137
+ runtime.listenExpectation.timeoutSeconds = timeoutSeconds;
138
+ if (runtime.listenExpectation.interruptible === undefined) {
139
+ runtime.listenExpectation.interruptible = node.interruptible;
140
+ }
141
+ }
142
+ function enterPortal(runtime, candidate) {
143
+ const switching = runtime.portalState.activePortalId &&
144
+ runtime.portalState.activePortalId !== candidate.id;
145
+ if (switching) {
146
+ const restored = runtime.exitPortal();
147
+ this.events.log('info', 'PORTAL_EXIT', {
148
+ conversationId: runtime.conversationId,
149
+ runtimeInstanceId: runtime.runtimeInstanceId,
150
+ restoredOriginNodeId: restored,
151
+ reason: 'switch_portal',
152
+ });
153
+ }
154
+ const alreadyInSame = runtime.portalState.activePortalId === candidate.id;
155
+ runtime.enterPortal(candidate.id);
156
+ this.events.log('info', alreadyInSame ? 'PORTAL_REENTER' : 'PORTAL_ENTER', {
157
+ conversationId: runtime.conversationId,
158
+ runtimeInstanceId: runtime.runtimeInstanceId,
159
+ portalId: candidate.id,
160
+ originNodeId: runtime.portalState.originNodeId,
161
+ });
162
+ return undefined;
163
+ }
164
+ function enterNormal(runtime, candidate) {
165
+ let restored;
166
+ if (runtime.portalState.activePortalId) {
167
+ restored = runtime.exitPortal();
168
+ this.events.log('info', 'PORTAL_EXIT', {
169
+ conversationId: runtime.conversationId,
170
+ runtimeInstanceId: runtime.runtimeInstanceId,
171
+ restoredOriginNodeId: restored,
172
+ nextNodeId: candidate.id,
173
+ reason: 'normal_intention',
174
+ });
175
+ }
176
+ runtime.enterNormalNode(candidate.id);
177
+ return restored;
178
+ }
179
+ /**
180
+ * After a toolCall terminal action, remember which Node requested it so the
181
+ * next Custom LLM turn with role:tool can re-enter without Brain scan.
182
+ */
183
+ /**
184
+ * After a toolCall terminal action, remember which Node requested it so the
185
+ * next Custom LLM turn with role:tool can re-enter without Brain scan.
186
+ */
187
+ function stampPendingToolNode(runtime, result, selectedNodeId) {
188
+ if (result.kind === 'toolCall') {
189
+ runtime.metadata[channel_tools_1.CHANNEL_META.pendingToolNodeId] = selectedNodeId;
190
+ return;
191
+ }
192
+ // Non-tool terminals clear the pending marker.
193
+ if (result.kind === 'sayAndListen' ||
194
+ result.kind === 'endCall' ||
195
+ result.kind === 'transferToHuman' ||
196
+ result.kind === 'handoff' ||
197
+ result.kind === 'continueTo') {
198
+ delete runtime.metadata[channel_tools_1.CHANNEL_META.pendingToolNodeId];
199
+ }
200
+ }
201
+ //# sourceMappingURL=supervisor-node-exec.js.map