@signalwire/sdk 2.0.1 → 2.0.2

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 (610) hide show
  1. package/dist/AgentBase.d.ts +1045 -0
  2. package/dist/AgentBase.js +2375 -0
  3. package/dist/AgentBase.js.map +1 -0
  4. package/dist/AgentServer.d.ts +146 -0
  5. package/dist/AgentServer.js +388 -0
  6. package/dist/AgentServer.js.map +1 -0
  7. package/dist/AuthHandler.d.ts +127 -0
  8. package/dist/AuthHandler.js +212 -0
  9. package/dist/AuthHandler.js.map +1 -0
  10. package/dist/ConfigLoader.d.ts +170 -0
  11. package/dist/ConfigLoader.js +393 -0
  12. package/dist/ConfigLoader.js.map +1 -0
  13. package/dist/ContextBuilder.d.ts +652 -0
  14. package/dist/ContextBuilder.js +1115 -0
  15. package/dist/ContextBuilder.js.map +1 -0
  16. package/dist/DataMap.d.ts +271 -0
  17. package/dist/DataMap.js +430 -0
  18. package/dist/DataMap.js.map +1 -0
  19. package/dist/FunctionResult.d.ts +481 -0
  20. package/dist/FunctionResult.js +775 -0
  21. package/dist/FunctionResult.js.map +1 -0
  22. package/dist/Logger.d.ts +113 -0
  23. package/dist/Logger.js +320 -0
  24. package/dist/Logger.js.map +1 -0
  25. package/dist/PomBuilder.d.ts +208 -0
  26. package/dist/PomBuilder.js +409 -0
  27. package/dist/PomBuilder.js.map +1 -0
  28. package/dist/PromptManager.d.ts +85 -0
  29. package/dist/PromptManager.js +108 -0
  30. package/dist/PromptManager.js.map +1 -0
  31. package/dist/SWMLHandler.d.ts +159 -0
  32. package/dist/SWMLHandler.js +229 -0
  33. package/dist/SWMLHandler.js.map +1 -0
  34. package/dist/SWMLService.d.ts +326 -0
  35. package/dist/SWMLService.js +610 -0
  36. package/dist/SWMLService.js.map +1 -0
  37. package/dist/SchemaUtils.d.ts +108 -0
  38. package/dist/SchemaUtils.js +317 -0
  39. package/dist/SchemaUtils.js.map +1 -0
  40. package/dist/SecurityUtils.d.ts +60 -0
  41. package/{src/SecurityUtils.ts → dist/SecurityUtils.js} +82 -83
  42. package/dist/SecurityUtils.js.map +1 -0
  43. package/dist/ServerlessAdapter.d.ts +119 -0
  44. package/dist/ServerlessAdapter.js +188 -0
  45. package/dist/ServerlessAdapter.js.map +1 -0
  46. package/dist/SessionManager.d.ts +142 -0
  47. package/dist/SessionManager.js +260 -0
  48. package/dist/SessionManager.js.map +1 -0
  49. package/dist/SslConfig.d.ts +77 -0
  50. package/dist/SslConfig.js +100 -0
  51. package/dist/SslConfig.js.map +1 -0
  52. package/dist/SwaigFunction.d.ts +159 -0
  53. package/dist/SwaigFunction.js +209 -0
  54. package/dist/SwaigFunction.js.map +1 -0
  55. package/dist/SwmlBuilder.d.ts +165 -0
  56. package/dist/SwmlBuilder.js +247 -0
  57. package/dist/SwmlBuilder.js.map +1 -0
  58. package/dist/SwmlVerbMethods.generated.d.ts +254 -0
  59. package/dist/SwmlVerbMethods.generated.js +9 -0
  60. package/dist/SwmlVerbMethods.generated.js.map +1 -0
  61. package/dist/TypeInference.d.ts +71 -0
  62. package/dist/TypeInference.js +164 -0
  63. package/dist/TypeInference.js.map +1 -0
  64. package/dist/WebService.d.ts +148 -0
  65. package/dist/WebService.js +532 -0
  66. package/dist/WebService.js.map +1 -0
  67. package/dist/cli/agent-loader.d.ts +22 -0
  68. package/dist/cli/agent-loader.js +144 -0
  69. package/dist/cli/agent-loader.js.map +1 -0
  70. package/dist/cli/mock-data.d.ts +37 -0
  71. package/dist/cli/mock-data.js +80 -0
  72. package/dist/cli/mock-data.js.map +1 -0
  73. package/dist/cli/swaig-test.d.ts +32 -0
  74. package/dist/cli/swaig-test.js +418 -0
  75. package/dist/cli/swaig-test.js.map +1 -0
  76. package/dist/generateVerbTypes.d.ts +11 -0
  77. package/dist/generateVerbTypes.js +265 -0
  78. package/dist/generateVerbTypes.js.map +1 -0
  79. package/{src/index.ts → dist/index.d.ts} +13 -100
  80. package/dist/index.js +152 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/livewire/index.d.ts +653 -0
  83. package/dist/livewire/index.js +992 -0
  84. package/dist/livewire/index.js.map +1 -0
  85. package/dist/prefabs/ConciergeAgent.d.ts +89 -0
  86. package/dist/prefabs/ConciergeAgent.js +245 -0
  87. package/dist/prefabs/ConciergeAgent.js.map +1 -0
  88. package/dist/prefabs/FAQBotAgent.d.ts +113 -0
  89. package/dist/prefabs/FAQBotAgent.js +329 -0
  90. package/dist/prefabs/FAQBotAgent.js.map +1 -0
  91. package/dist/prefabs/InfoGathererAgent.d.ts +126 -0
  92. package/dist/prefabs/InfoGathererAgent.js +287 -0
  93. package/dist/prefabs/InfoGathererAgent.js.map +1 -0
  94. package/dist/prefabs/ReceptionistAgent.d.ts +104 -0
  95. package/dist/prefabs/ReceptionistAgent.js +303 -0
  96. package/dist/prefabs/ReceptionistAgent.js.map +1 -0
  97. package/dist/prefabs/SurveyAgent.d.ts +148 -0
  98. package/dist/prefabs/SurveyAgent.js +540 -0
  99. package/dist/prefabs/SurveyAgent.js.map +1 -0
  100. package/{src/prefabs/index.ts → dist/prefabs/index.d.ts} +1 -15
  101. package/dist/prefabs/index.js +14 -0
  102. package/dist/prefabs/index.js.map +1 -0
  103. package/dist/relay/Action.d.ts +258 -0
  104. package/dist/relay/Action.js +402 -0
  105. package/dist/relay/Action.js.map +1 -0
  106. package/dist/relay/Call.d.ts +697 -0
  107. package/dist/relay/Call.js +1062 -0
  108. package/dist/relay/Call.js.map +1 -0
  109. package/dist/relay/Deferred.d.ts +44 -0
  110. package/dist/relay/Deferred.js +69 -0
  111. package/dist/relay/Deferred.js.map +1 -0
  112. package/dist/relay/Message.d.ts +103 -0
  113. package/dist/relay/Message.js +169 -0
  114. package/dist/relay/Message.js.map +1 -0
  115. package/dist/relay/RelayClient.d.ts +302 -0
  116. package/dist/relay/RelayClient.js +1019 -0
  117. package/dist/relay/RelayClient.js.map +1 -0
  118. package/dist/relay/RelayError.d.ts +15 -0
  119. package/dist/relay/RelayError.js +20 -0
  120. package/dist/relay/RelayError.js.map +1 -0
  121. package/dist/relay/RelayEvent.d.ts +254 -0
  122. package/dist/relay/RelayEvent.js +509 -0
  123. package/dist/relay/RelayEvent.js.map +1 -0
  124. package/dist/relay/constants.d.ts +90 -0
  125. package/{src/relay/constants.ts → dist/relay/constants.js} +11 -29
  126. package/dist/relay/constants.js.map +1 -0
  127. package/dist/relay/index.d.ts +16 -0
  128. package/dist/relay/index.js +18 -0
  129. package/dist/relay/index.js.map +1 -0
  130. package/dist/relay/types.d.ts +142 -0
  131. package/dist/relay/types.js +5 -0
  132. package/dist/relay/types.js.map +1 -0
  133. package/dist/rest/HttpClient.d.ts +80 -0
  134. package/dist/rest/HttpClient.js +148 -0
  135. package/dist/rest/HttpClient.js.map +1 -0
  136. package/dist/rest/RestError.d.ts +30 -0
  137. package/dist/rest/RestError.js +39 -0
  138. package/dist/rest/RestError.js.map +1 -0
  139. package/dist/rest/base/BaseResource.d.ts +24 -0
  140. package/dist/rest/base/BaseResource.js +29 -0
  141. package/dist/rest/base/BaseResource.js.map +1 -0
  142. package/dist/rest/base/CrudResource.d.ts +68 -0
  143. package/dist/rest/base/CrudResource.js +82 -0
  144. package/dist/rest/base/CrudResource.js.map +1 -0
  145. package/dist/rest/base/CrudWithAddresses.d.ts +22 -0
  146. package/dist/rest/base/CrudWithAddresses.js +25 -0
  147. package/dist/rest/base/CrudWithAddresses.js.map +1 -0
  148. package/dist/rest/index.d.ts +131 -0
  149. package/{src/rest/index.ts → dist/rest/index.js} +101 -136
  150. package/dist/rest/index.js.map +1 -0
  151. package/dist/rest/namespaces/addresses.d.ts +46 -0
  152. package/dist/rest/namespaces/addresses.js +55 -0
  153. package/dist/rest/namespaces/addresses.js.map +1 -0
  154. package/dist/rest/namespaces/calling.d.ts +382 -0
  155. package/dist/rest/namespaces/calling.js +478 -0
  156. package/dist/rest/namespaces/calling.js.map +1 -0
  157. package/dist/rest/namespaces/chat.d.ts +22 -0
  158. package/dist/rest/namespaces/chat.js +26 -0
  159. package/dist/rest/namespaces/chat.js.map +1 -0
  160. package/dist/rest/namespaces/compat.d.ts +585 -0
  161. package/dist/rest/namespaces/compat.js +735 -0
  162. package/dist/rest/namespaces/compat.js.map +1 -0
  163. package/dist/rest/namespaces/datasphere.d.ts +66 -0
  164. package/dist/rest/namespaces/datasphere.js +77 -0
  165. package/dist/rest/namespaces/datasphere.js.map +1 -0
  166. package/dist/rest/namespaces/fabric.d.ts +282 -0
  167. package/dist/rest/namespaces/fabric.js +373 -0
  168. package/dist/rest/namespaces/fabric.js.map +1 -0
  169. package/dist/rest/namespaces/imported-numbers.d.ts +22 -0
  170. package/dist/rest/namespaces/imported-numbers.js +26 -0
  171. package/dist/rest/namespaces/imported-numbers.js.map +1 -0
  172. package/dist/rest/namespaces/logs.d.ts +105 -0
  173. package/dist/rest/namespaces/logs.js +133 -0
  174. package/dist/rest/namespaces/logs.js.map +1 -0
  175. package/dist/rest/namespaces/lookup.d.ts +29 -0
  176. package/dist/rest/namespaces/lookup.js +32 -0
  177. package/dist/rest/namespaces/lookup.js.map +1 -0
  178. package/dist/rest/namespaces/mfa.d.ts +46 -0
  179. package/dist/rest/namespaces/mfa.js +54 -0
  180. package/dist/rest/namespaces/mfa.js.map +1 -0
  181. package/dist/rest/namespaces/number-groups.d.ts +49 -0
  182. package/dist/rest/namespaces/number-groups.js +58 -0
  183. package/dist/rest/namespaces/number-groups.js.map +1 -0
  184. package/dist/rest/namespaces/phone-numbers.d.ts +60 -0
  185. package/dist/rest/namespaces/phone-numbers.js +67 -0
  186. package/dist/rest/namespaces/phone-numbers.js.map +1 -0
  187. package/dist/rest/namespaces/project.d.ts +46 -0
  188. package/dist/rest/namespaces/project.js +56 -0
  189. package/dist/rest/namespaces/project.js.map +1 -0
  190. package/dist/rest/namespaces/pubsub.d.ts +22 -0
  191. package/dist/rest/namespaces/pubsub.js +26 -0
  192. package/dist/rest/namespaces/pubsub.js.map +1 -0
  193. package/dist/rest/namespaces/queues.d.ts +42 -0
  194. package/dist/rest/namespaces/queues.js +49 -0
  195. package/dist/rest/namespaces/queues.js.map +1 -0
  196. package/dist/rest/namespaces/recordings.d.ts +38 -0
  197. package/dist/rest/namespaces/recordings.js +45 -0
  198. package/dist/rest/namespaces/recordings.js.map +1 -0
  199. package/dist/rest/namespaces/registry.d.ts +141 -0
  200. package/dist/rest/namespaces/registry.js +178 -0
  201. package/dist/rest/namespaces/registry.js.map +1 -0
  202. package/dist/rest/namespaces/short-codes.d.ts +39 -0
  203. package/dist/rest/namespaces/short-codes.js +46 -0
  204. package/dist/rest/namespaces/short-codes.js.map +1 -0
  205. package/dist/rest/namespaces/sip-profile.d.ts +28 -0
  206. package/dist/rest/namespaces/sip-profile.js +34 -0
  207. package/dist/rest/namespaces/sip-profile.js.map +1 -0
  208. package/dist/rest/namespaces/verified-callers.d.ts +33 -0
  209. package/dist/rest/namespaces/verified-callers.js +39 -0
  210. package/dist/rest/namespaces/verified-callers.js.map +1 -0
  211. package/dist/rest/namespaces/video.d.ts +235 -0
  212. package/dist/rest/namespaces/video.js +297 -0
  213. package/dist/rest/namespaces/video.js.map +1 -0
  214. package/{src/rest/pagination.ts → dist/rest/pagination.d.ts} +2 -61
  215. package/dist/rest/pagination.js +78 -0
  216. package/dist/rest/pagination.js.map +1 -0
  217. package/dist/rest/types.d.ts +54 -0
  218. package/dist/rest/types.js +5 -0
  219. package/dist/rest/types.js.map +1 -0
  220. package/dist/skills/SkillBase.d.ts +404 -0
  221. package/dist/skills/SkillBase.js +471 -0
  222. package/dist/skills/SkillBase.js.map +1 -0
  223. package/dist/skills/SkillManager.d.ts +195 -0
  224. package/dist/skills/SkillManager.js +378 -0
  225. package/dist/skills/SkillManager.js.map +1 -0
  226. package/dist/skills/SkillRegistry.d.ts +176 -0
  227. package/dist/skills/SkillRegistry.js +310 -0
  228. package/dist/skills/SkillRegistry.js.map +1 -0
  229. package/dist/skills/builtin/api_ninjas_trivia.d.ts +47 -0
  230. package/dist/skills/builtin/api_ninjas_trivia.js +211 -0
  231. package/dist/skills/builtin/api_ninjas_trivia.js.map +1 -0
  232. package/dist/skills/builtin/ask_claude.d.ts +37 -0
  233. package/dist/skills/builtin/ask_claude.js +162 -0
  234. package/dist/skills/builtin/ask_claude.js.map +1 -0
  235. package/dist/skills/builtin/claude_skills.d.ts +75 -0
  236. package/dist/skills/builtin/claude_skills.js +753 -0
  237. package/dist/skills/builtin/claude_skills.js.map +1 -0
  238. package/dist/skills/builtin/custom_skills.d.ts +79 -0
  239. package/dist/skills/builtin/custom_skills.js +227 -0
  240. package/dist/skills/builtin/custom_skills.js.map +1 -0
  241. package/dist/skills/builtin/datasphere.d.ts +73 -0
  242. package/dist/skills/builtin/datasphere.js +350 -0
  243. package/dist/skills/builtin/datasphere.js.map +1 -0
  244. package/dist/skills/builtin/datasphere_serverless.d.ts +89 -0
  245. package/dist/skills/builtin/datasphere_serverless.js +291 -0
  246. package/dist/skills/builtin/datasphere_serverless.js.map +1 -0
  247. package/dist/skills/builtin/datetime.d.ts +40 -0
  248. package/dist/skills/builtin/datetime.js +118 -0
  249. package/dist/skills/builtin/datetime.js.map +1 -0
  250. package/dist/skills/builtin/google_maps.d.ts +48 -0
  251. package/dist/skills/builtin/google_maps.js +470 -0
  252. package/dist/skills/builtin/google_maps.js.map +1 -0
  253. package/dist/skills/builtin/index.d.ts +31 -0
  254. package/{src/skills/builtin/index.ts → dist/skills/builtin/index.js} +30 -36
  255. package/dist/skills/builtin/index.js.map +1 -0
  256. package/dist/skills/builtin/info_gatherer.d.ts +115 -0
  257. package/dist/skills/builtin/info_gatherer.js +328 -0
  258. package/dist/skills/builtin/info_gatherer.js.map +1 -0
  259. package/dist/skills/builtin/joke.d.ts +41 -0
  260. package/dist/skills/builtin/joke.js +156 -0
  261. package/dist/skills/builtin/joke.js.map +1 -0
  262. package/dist/skills/builtin/math.d.ts +39 -0
  263. package/dist/skills/builtin/math.js +119 -0
  264. package/dist/skills/builtin/math.js.map +1 -0
  265. package/dist/skills/builtin/mcp_gateway.d.ts +82 -0
  266. package/dist/skills/builtin/mcp_gateway.js +574 -0
  267. package/dist/skills/builtin/mcp_gateway.js.map +1 -0
  268. package/dist/skills/builtin/native_vector_search.d.ts +128 -0
  269. package/dist/skills/builtin/native_vector_search.js +752 -0
  270. package/dist/skills/builtin/native_vector_search.js.map +1 -0
  271. package/dist/skills/builtin/play_background_file.d.ts +59 -0
  272. package/dist/skills/builtin/play_background_file.js +274 -0
  273. package/dist/skills/builtin/play_background_file.js.map +1 -0
  274. package/dist/skills/builtin/spider.d.ts +91 -0
  275. package/dist/skills/builtin/spider.js +758 -0
  276. package/dist/skills/builtin/spider.js.map +1 -0
  277. package/dist/skills/builtin/swml_transfer.d.ts +66 -0
  278. package/dist/skills/builtin/swml_transfer.js +475 -0
  279. package/dist/skills/builtin/swml_transfer.js.map +1 -0
  280. package/dist/skills/builtin/weather_api.d.ts +59 -0
  281. package/dist/skills/builtin/weather_api.js +196 -0
  282. package/dist/skills/builtin/weather_api.js.map +1 -0
  283. package/dist/skills/builtin/web_search.d.ts +160 -0
  284. package/dist/skills/builtin/web_search.js +894 -0
  285. package/dist/skills/builtin/web_search.js.map +1 -0
  286. package/dist/skills/builtin/wikipedia_search.d.ts +77 -0
  287. package/dist/skills/builtin/wikipedia_search.js +241 -0
  288. package/dist/skills/builtin/wikipedia_search.js.map +1 -0
  289. package/{src/skills/index.ts → dist/skills/index.d.ts} +0 -1
  290. package/dist/skills/index.js +10 -0
  291. package/dist/skills/index.js.map +1 -0
  292. package/dist/types.d.ts +118 -0
  293. package/dist/types.js +5 -0
  294. package/dist/types.js.map +1 -0
  295. package/package.json +7 -1
  296. package/.github/workflows/publish.yml +0 -27
  297. package/.github/workflows/test.yml +0 -17
  298. package/CLAUDE.md +0 -112
  299. package/docs/MIGRATION-2.0.md +0 -81
  300. package/docs/agent-guide.md +0 -869
  301. package/docs/agent_guide.md +0 -1026
  302. package/docs/api-reference.md +0 -2420
  303. package/docs/api_reference.md +0 -1301
  304. package/docs/architecture.md +0 -843
  305. package/docs/cli-guide.md +0 -579
  306. package/docs/cli_guide.md +0 -448
  307. package/docs/cloud_functions_guide.md +0 -474
  308. package/docs/configuration.md +0 -422
  309. package/docs/contexts-guide.md +0 -787
  310. package/docs/contexts_guide.md +0 -511
  311. package/docs/datamap-guide.md +0 -1141
  312. package/docs/datamap_guide.md +0 -595
  313. package/docs/llm_parameters.md +0 -239
  314. package/docs/mcp_gateway_reference.md +0 -648
  315. package/docs/mcp_integration.md +0 -108
  316. package/docs/prefabs-guide.md +0 -800
  317. package/docs/sdk_features.md +0 -477
  318. package/docs/security.md +0 -436
  319. package/docs/serverless-guide.md +0 -513
  320. package/docs/skills-guide.md +0 -857
  321. package/docs/skills-system.md +0 -301
  322. package/docs/skills_parameter_schema.md +0 -392
  323. package/docs/skills_system.md +0 -467
  324. package/docs/swaig-reference.md +0 -1627
  325. package/docs/swaig_reference.md +0 -910
  326. package/docs/swml_service_guide.md +0 -600
  327. package/docs/third_party_skills.md +0 -533
  328. package/docs/web_service.md +0 -677
  329. package/examples/README.md +0 -131
  330. package/examples/advanced-datamap.ts +0 -100
  331. package/examples/advanced-dynamic-config.ts +0 -70
  332. package/examples/auto-vivified.ts +0 -94
  333. package/examples/call-flow.ts +0 -63
  334. package/examples/comprehensive-dynamic.ts +0 -125
  335. package/examples/contexts-steps.ts +0 -65
  336. package/examples/custom-path.ts +0 -45
  337. package/examples/datamap-tools.ts +0 -55
  338. package/examples/datasphere-multi-instance.ts +0 -63
  339. package/examples/datasphere-serverless-env.ts +0 -68
  340. package/examples/datasphere-webhook-env.ts +0 -66
  341. package/examples/datasphere.ts +0 -37
  342. package/examples/declarative.ts +0 -100
  343. package/examples/dynamic-config.ts +0 -54
  344. package/examples/dynamic-info-gatherer.ts +0 -69
  345. package/examples/dynamic-swml-service.ts +0 -67
  346. package/examples/gather-info.ts +0 -71
  347. package/examples/gather-per-question-functions-demo.ts +0 -140
  348. package/examples/joke-agent.ts +0 -34
  349. package/examples/kubernetes-agent.ts +0 -45
  350. package/examples/llm-params.ts +0 -69
  351. package/examples/mcp-agent.ts +0 -84
  352. package/examples/mcp-gateway.ts +0 -35
  353. package/examples/multi-agent.ts +0 -73
  354. package/examples/multi-endpoint.ts +0 -79
  355. package/examples/pom-prompt.ts +0 -71
  356. package/examples/prefab-concierge.ts +0 -47
  357. package/examples/prefab-faq.ts +0 -54
  358. package/examples/prefab-info-gatherer.ts +0 -33
  359. package/examples/prefab-receptionist.ts +0 -36
  360. package/examples/prefab-survey.ts +0 -68
  361. package/examples/record-call.ts +0 -67
  362. package/examples/relay-demo.ts +0 -33
  363. package/examples/room-and-sip.ts +0 -94
  364. package/examples/serverless-lambda.ts +0 -35
  365. package/examples/session-state.ts +0 -83
  366. package/examples/simple-agent.ts +0 -36
  367. package/examples/simple-static.ts +0 -29
  368. package/examples/skills-demo.ts +0 -38
  369. package/examples/step-function-inheritance-demo.ts +0 -124
  370. package/examples/swaig-features.ts +0 -187
  371. package/examples/swml-service-routing.ts +0 -66
  372. package/examples/swml-service.ts +0 -38
  373. package/examples/tap.ts +0 -68
  374. package/examples/verb-methods.ts +0 -45
  375. package/examples/web-search-multi-instance.ts +0 -72
  376. package/examples/web-search.ts +0 -38
  377. package/examples/wikipedia.ts +0 -36
  378. package/livewire/README.md +0 -140
  379. package/livewire/docs/migration-guide.md +0 -228
  380. package/livewire/examples/livewire-basic-agent.ts +0 -74
  381. package/livewire/examples/livewire-handoff.ts +0 -197
  382. package/livewire/examples/livewire-multi-tool.ts +0 -117
  383. package/relay/README.md +0 -70
  384. package/relay/RELAY_IMPLEMENTATION_GUIDE.md +0 -1257
  385. package/relay/docs/call-methods.md +0 -474
  386. package/relay/docs/client-reference.md +0 -142
  387. package/relay/docs/events.md +0 -134
  388. package/relay/docs/getting-started.md +0 -134
  389. package/relay/docs/guide.md +0 -306
  390. package/relay/docs/messaging.md +0 -182
  391. package/relay/examples/relay-inbound.ts +0 -66
  392. package/relay/examples/relay-messaging.ts +0 -71
  393. package/relay/examples/relay-outbound.ts +0 -76
  394. package/rest/README.md +0 -95
  395. package/rest/docs/calling.md +0 -273
  396. package/rest/docs/client-reference.md +0 -107
  397. package/rest/docs/compat.md +0 -204
  398. package/rest/docs/fabric.md +0 -183
  399. package/rest/docs/getting-started.md +0 -110
  400. package/rest/docs/guide.md +0 -351
  401. package/rest/docs/namespaces.md +0 -285
  402. package/rest/examples/rest-10dlc-registration.ts +0 -161
  403. package/rest/examples/rest-calling-ivr-and-ai.ts +0 -102
  404. package/rest/examples/rest-calling-play-and-record.ts +0 -91
  405. package/rest/examples/rest-client.ts +0 -65
  406. package/rest/examples/rest-compat-laml.ts +0 -210
  407. package/rest/examples/rest-datasphere-search.ts +0 -82
  408. package/rest/examples/rest-fabric-conferences-and-routing.ts +0 -144
  409. package/rest/examples/rest-fabric-subscribers-and-sip.ts +0 -108
  410. package/rest/examples/rest-fabric-swml-and-callflows.ts +0 -99
  411. package/rest/examples/rest-manage-resources.ts +0 -65
  412. package/rest/examples/rest-phone-number-management.ts +0 -197
  413. package/rest/examples/rest-queues-mfa-and-recordings.ts +0 -143
  414. package/rest/examples/rest-video-rooms.ts +0 -186
  415. package/src/AgentBase.ts +0 -2598
  416. package/src/AgentServer.ts +0 -442
  417. package/src/AuthHandler.ts +0 -256
  418. package/src/ConfigLoader.ts +0 -447
  419. package/src/ContextBuilder.ts +0 -1181
  420. package/src/DataMap.ts +0 -477
  421. package/src/FunctionResult.ts +0 -903
  422. package/src/Logger.ts +0 -337
  423. package/src/PomBuilder.ts +0 -467
  424. package/src/PromptManager.ts +0 -133
  425. package/src/SWMLHandler.ts +0 -298
  426. package/src/SWMLService.ts +0 -749
  427. package/src/SchemaUtils.ts +0 -361
  428. package/src/ServerlessAdapter.ts +0 -240
  429. package/src/SessionManager.ts +0 -311
  430. package/src/SslConfig.ts +0 -118
  431. package/src/SwaigFunction.ts +0 -276
  432. package/src/SwmlBuilder.ts +0 -283
  433. package/src/SwmlVerbMethods.generated.ts +0 -234
  434. package/src/TypeInference.ts +0 -199
  435. package/src/WebService.ts +0 -641
  436. package/src/cli/agent-loader.ts +0 -166
  437. package/src/cli/mock-data.ts +0 -111
  438. package/src/cli/swaig-test.ts +0 -452
  439. package/src/generateVerbTypes.ts +0 -322
  440. package/src/livewire/index.ts +0 -1252
  441. package/src/prefabs/ConciergeAgent.ts +0 -309
  442. package/src/prefabs/FAQBotAgent.ts +0 -415
  443. package/src/prefabs/InfoGathererAgent.ts +0 -379
  444. package/src/prefabs/ReceptionistAgent.ts +0 -395
  445. package/src/prefabs/SurveyAgent.ts +0 -671
  446. package/src/relay/Action.ts +0 -482
  447. package/src/relay/Call.ts +0 -1270
  448. package/src/relay/Deferred.ts +0 -94
  449. package/src/relay/Message.ts +0 -199
  450. package/src/relay/RelayClient.ts +0 -1185
  451. package/src/relay/RelayError.ts +0 -20
  452. package/src/relay/RelayEvent.ts +0 -944
  453. package/src/relay/index.ts +0 -123
  454. package/src/relay/types.ts +0 -149
  455. package/src/rest/HttpClient.ts +0 -164
  456. package/src/rest/RestError.ts +0 -45
  457. package/src/rest/base/BaseResource.ts +0 -32
  458. package/src/rest/base/CrudResource.ts +0 -98
  459. package/src/rest/base/CrudWithAddresses.ts +0 -37
  460. package/src/rest/namespaces/addresses.ts +0 -64
  461. package/src/rest/namespaces/calling.ts +0 -534
  462. package/src/rest/namespaces/chat.ts +0 -31
  463. package/src/rest/namespaces/compat.ts +0 -812
  464. package/src/rest/namespaces/datasphere.ts +0 -88
  465. package/src/rest/namespaces/fabric.ts +0 -417
  466. package/src/rest/namespaces/imported-numbers.ts +0 -31
  467. package/src/rest/namespaces/logs.ts +0 -151
  468. package/src/rest/namespaces/lookup.ts +0 -38
  469. package/src/rest/namespaces/mfa.ts +0 -61
  470. package/src/rest/namespaces/number-groups.ts +0 -68
  471. package/src/rest/namespaces/phone-numbers.ts +0 -76
  472. package/src/rest/namespaces/project.ts +0 -65
  473. package/src/rest/namespaces/pubsub.ts +0 -31
  474. package/src/rest/namespaces/queues.ts +0 -58
  475. package/src/rest/namespaces/recordings.ts +0 -53
  476. package/src/rest/namespaces/registry.ts +0 -200
  477. package/src/rest/namespaces/short-codes.ts +0 -54
  478. package/src/rest/namespaces/sip-profile.ts +0 -40
  479. package/src/rest/namespaces/verified-callers.ts +0 -46
  480. package/src/rest/namespaces/video.ts +0 -332
  481. package/src/rest/types.ts +0 -61
  482. package/src/skills/SkillBase.ts +0 -582
  483. package/src/skills/SkillManager.ts +0 -419
  484. package/src/skills/SkillRegistry.ts +0 -367
  485. package/src/skills/builtin/api_ninjas_trivia.ts +0 -285
  486. package/src/skills/builtin/ask_claude.ts +0 -246
  487. package/src/skills/builtin/claude_skills.ts +0 -983
  488. package/src/skills/builtin/custom_skills.ts +0 -327
  489. package/src/skills/builtin/datasphere.ts +0 -447
  490. package/src/skills/builtin/datasphere_serverless.ts +0 -347
  491. package/src/skills/builtin/datetime.ts +0 -137
  492. package/src/skills/builtin/google_maps.ts +0 -656
  493. package/src/skills/builtin/info_gatherer.ts +0 -415
  494. package/src/skills/builtin/joke.ts +0 -196
  495. package/src/skills/builtin/math.ts +0 -149
  496. package/src/skills/builtin/mcp_gateway.ts +0 -685
  497. package/src/skills/builtin/native_vector_search.ts +0 -910
  498. package/src/skills/builtin/play_background_file.ts +0 -367
  499. package/src/skills/builtin/spider.ts +0 -874
  500. package/src/skills/builtin/swml_transfer.ts +0 -645
  501. package/src/skills/builtin/weather_api.ts +0 -255
  502. package/src/skills/builtin/web_search.ts +0 -1083
  503. package/src/skills/builtin/wikipedia_search.ts +0 -304
  504. package/src/types.ts +0 -132
  505. package/tests/AgentBase.test.ts +0 -1093
  506. package/tests/AgentServer.test.ts +0 -126
  507. package/tests/AuthHandler.test.ts +0 -133
  508. package/tests/ConfigLoader.test.ts +0 -151
  509. package/tests/ContextBuilder.test.ts +0 -108
  510. package/tests/DataMap.test.ts +0 -367
  511. package/tests/EphemeralSkillCopy.test.ts +0 -107
  512. package/tests/FunctionResult.test.ts +0 -298
  513. package/tests/GracefulShutdown.test.ts +0 -46
  514. package/tests/Logger.test.ts +0 -420
  515. package/tests/PomBuilder.test.ts +0 -228
  516. package/tests/ProxyDetection.test.ts +0 -228
  517. package/tests/SWMLService.test.ts +0 -320
  518. package/tests/SWMLVerbHandler.test.ts +0 -523
  519. package/tests/SchemaUtils.test.ts +0 -106
  520. package/tests/SchemaUtils.verb.test.ts +0 -206
  521. package/tests/SecurityUtils.test.ts +0 -192
  522. package/tests/ServerlessAdapter.test.ts +0 -222
  523. package/tests/SessionManager.test.ts +0 -257
  524. package/tests/SkillBaseFeatures.test.ts +0 -130
  525. package/tests/SkillMultiInstance.test.ts +0 -102
  526. package/tests/SkillParameterSchemas.test.ts +0 -134
  527. package/tests/SkillRegistrySchema.test.ts +0 -84
  528. package/tests/SslConfig.test.ts +0 -97
  529. package/tests/SwmlBuilder.test.ts +0 -400
  530. package/tests/TypeInference.test.ts +0 -165
  531. package/tests/VerbHandlerRegistry.test.ts +0 -128
  532. package/tests/cli/mock-data.test.ts +0 -113
  533. package/tests/cli/swaig-test.test.ts +0 -108
  534. package/tests/examples.test.ts +0 -194
  535. package/tests/fixtures/scrape-parity/README.md +0 -53
  536. package/tests/fixtures/scrape-parity/expected/01_simple_article.json +0 -5
  537. package/tests/fixtures/scrape-parity/expected/02_class_based_noise.json +0 -5
  538. package/tests/fixtures/scrape-parity/expected/03_nested_containers.json +0 -5
  539. package/tests/fixtures/scrape-parity/expected/04_bare_body.json +0 -5
  540. package/tests/fixtures/scrape-parity/expected/05_malformed.json +0 -5
  541. package/tests/fixtures/scrape-parity/expected/06_multi_class.json +0 -5
  542. package/tests/fixtures/scrape-parity/expected/07_anchor_pattern.json +0 -5
  543. package/tests/fixtures/scrape-parity/expected/08_inline_script.json +0 -5
  544. package/tests/fixtures/scrape-parity/expected/09_whitespace_nbsp.json +0 -5
  545. package/tests/fixtures/scrape-parity/expected/10_entity_unicode.json +0 -5
  546. package/tests/fixtures/scrape-parity/expected/11_cdata_comments.json +0 -5
  547. package/tests/fixtures/scrape-parity/expected/12_deep_nested_removals.json +0 -5
  548. package/tests/fixtures/scrape-parity/html/01_simple_article.html +0 -18
  549. package/tests/fixtures/scrape-parity/html/02_class_based_noise.html +0 -18
  550. package/tests/fixtures/scrape-parity/html/03_nested_containers.html +0 -13
  551. package/tests/fixtures/scrape-parity/html/04_bare_body.html +0 -9
  552. package/tests/fixtures/scrape-parity/html/05_malformed.html +0 -11
  553. package/tests/fixtures/scrape-parity/html/06_multi_class.html +0 -18
  554. package/tests/fixtures/scrape-parity/html/07_anchor_pattern.html +0 -12
  555. package/tests/fixtures/scrape-parity/html/08_inline_script.html +0 -17
  556. package/tests/fixtures/scrape-parity/html/09_whitespace_nbsp.html +0 -21
  557. package/tests/fixtures/scrape-parity/html/10_entity_unicode.html +0 -10
  558. package/tests/fixtures/scrape-parity/html/11_cdata_comments.html +0 -13
  559. package/tests/fixtures/scrape-parity/html/12_deep_nested_removals.html +0 -24
  560. package/tests/fixtures/scrape-parity/python_extract.py +0 -109
  561. package/tests/livewire/livewire.test.ts +0 -780
  562. package/tests/mcp.test.ts +0 -221
  563. package/tests/prefabs/prefabs.test.ts +0 -1093
  564. package/tests/relay/Action.test.ts +0 -392
  565. package/tests/relay/Call.test.ts +0 -535
  566. package/tests/relay/Deferred.test.ts +0 -71
  567. package/tests/relay/Message.test.ts +0 -164
  568. package/tests/relay/RelayClient.test.ts +0 -779
  569. package/tests/relay/RelayEvent.test.ts +0 -463
  570. package/tests/relay/helpers.ts +0 -79
  571. package/tests/rest/HttpClient.test.ts +0 -274
  572. package/tests/rest/RestError.test.ts +0 -53
  573. package/tests/rest/calling.test.ts +0 -156
  574. package/tests/rest/client.test.ts +0 -197
  575. package/tests/rest/compat.test.ts +0 -335
  576. package/tests/rest/datasphere.test.ts +0 -71
  577. package/tests/rest/fabric.test.ts +0 -186
  578. package/tests/rest/helpers.ts +0 -95
  579. package/tests/rest/logs.test.ts +0 -68
  580. package/tests/rest/pagination.test.ts +0 -133
  581. package/tests/rest/registry.test.ts +0 -94
  582. package/tests/rest/relay-rest.test.ts +0 -290
  583. package/tests/rest/video.test.ts +0 -173
  584. package/tests/setup.ts +0 -6
  585. package/tests/skills/SkillBase.test.ts +0 -108
  586. package/tests/skills/SkillManager.test.ts +0 -268
  587. package/tests/skills/SkillRegistry.test.ts +0 -176
  588. package/tests/skills/builtin.test.ts +0 -1472
  589. package/tests/skills/claude-skills.test.ts +0 -54
  590. package/tests/skills/custom-skills.test.ts +0 -53
  591. package/tests/skills/datasphere-serverless.test.ts +0 -70
  592. package/tests/skills/datasphere.test.ts +0 -107
  593. package/tests/skills/datetime.test.ts +0 -101
  594. package/tests/skills/google-maps.test.ts +0 -78
  595. package/tests/skills/info-gatherer.test.ts +0 -411
  596. package/tests/skills/joke.test.ts +0 -81
  597. package/tests/skills/math.test.ts +0 -68
  598. package/tests/skills/mcp-gateway.test.ts +0 -101
  599. package/tests/skills/play-background.test.ts +0 -54
  600. package/tests/skills/spider.test.ts +0 -108
  601. package/tests/skills/swml-transfer.test.ts +0 -178
  602. package/tests/skills/trivia.test.ts +0 -54
  603. package/tests/skills/vector-search.test.ts +0 -135
  604. package/tests/skills/weather-api.test.ts +0 -77
  605. package/tests/skills/web-search-parity.test.ts +0 -59
  606. package/tests/skills/web-search.test.ts +0 -103
  607. package/tests/skills/wikipedia.test.ts +0 -63
  608. package/tsconfig.json +0 -18
  609. package/vitest.config.ts +0 -9
  610. /package/{src → dist}/schema.json +0 -0
@@ -1,2420 +0,0 @@
1
- # API Reference
2
-
3
- Complete reference for every exported class, interface, type, and function in the SignalWire AI Agents TypeScript SDK.
4
-
5
- ---
6
-
7
- ## Table of Contents
8
-
9
- - [AgentBase](#agentbase)
10
- - [Constructor](#agentbase-constructor)
11
- - [Static Properties](#agentbase-static-properties)
12
- - [Public Properties](#agentbase-public-properties)
13
- - [Prompt Methods](#prompt-methods)
14
- - [Tool Methods](#tool-methods)
15
- - [Speech and Language Methods](#speech-and-language-methods)
16
- - [AI Configuration Methods](#ai-configuration-methods)
17
- - [Call Flow Methods](#call-flow-methods)
18
- - [Context Methods](#context-methods)
19
- - [Skill Methods](#skill-methods)
20
- - [Dynamic Configuration Methods](#dynamic-configuration-methods)
21
- - [URL and Proxy Methods](#url-and-proxy-methods)
22
- - [Server Methods](#server-methods)
23
- - [Utility Methods](#utility-methods)
24
- - [Protected Hooks](#protected-hooks)
25
- - [AgentServer](#agentserver)
26
- - [FunctionResult](#swaigfunctionresult)
27
- - [Constructor](#swaigfunctionresult-constructor)
28
- - [Core Methods](#swaigfunctionresult-core-methods)
29
- - [Call Control Actions](#call-control-actions)
30
- - [Audio Actions](#audio-actions)
31
- - [Speech Actions](#speech-actions)
32
- - [Data Actions](#data-actions)
33
- - [SWML Actions](#swml-actions)
34
- - [Function Actions](#function-actions)
35
- - [Communication Actions](#communication-actions)
36
- - [Room and Conference Actions](#room-and-conference-actions)
37
- - [RPC Actions](#rpc-actions)
38
- - [Payment Actions](#payment-actions)
39
- - [Static Helpers](#swaigfunctionresult-static-helpers)
40
- - [Serialization](#swaigfunctionresult-serialization)
41
- - [SwaigFunction](#swaigfunction)
42
- - [DataMap](#datamap)
43
- - [Constructor](#datamap-constructor)
44
- - [Configuration Methods](#datamap-configuration-methods)
45
- - [Webhook Methods](#datamap-webhook-methods)
46
- - [Output Methods](#datamap-output-methods)
47
- - [Registration and Serialization](#datamap-registration-and-serialization)
48
- - [Factory Functions](#datamap-factory-functions)
49
- - [ContextBuilder](#contextbuilder)
50
- - [ContextBuilder Class](#contextbuilder-class)
51
- - [Context Class](#context-class)
52
- - [Step Class](#step-class)
53
- - [GatherInfo Class](#gatherinfo-class)
54
- - [GatherQuestion Class](#gatherquestion-class)
55
- - [Helper Functions](#contextbuilder-helper-functions)
56
- - [PomBuilder](#pombuilder)
57
- - [PomSection Class](#pomsection-class)
58
- - [PomBuilder Class](#pombuilder-class)
59
- - [SwmlBuilder](#swmlbuilder)
60
- - [PromptManager](#promptmanager)
61
- - [SessionManager](#sessionmanager)
62
- - [Skills](#skills)
63
- - [SkillBase](#skillbase)
64
- - [SkillManager](#skillmanager)
65
- - [SkillRegistry](#skillregistry)
66
- - [Prefab Agents](#prefab-agents)
67
- - [InfoGathererAgent](#infogathereragent)
68
- - [SurveyAgent](#surveyagent)
69
- - [FAQBotAgent](#faqbotagent)
70
- - [ConciergeAgent](#conciergeagent)
71
- - [ReceptionistAgent](#receptionistagent)
72
- - [Utility Classes](#utility-classes)
73
- - [AuthHandler](#authhandler)
74
- - [ConfigLoader](#configloader)
75
- - [Logger](#logger)
76
- - [SslConfig](#sslconfig)
77
- - [SchemaUtils](#schemautils)
78
- - [ServerlessAdapter](#serverlessadapter)
79
- - [Types and Interfaces](#types-and-interfaces)
80
- - [AgentOptions](#agentoptions)
81
- - [LanguageConfig](#languageconfig)
82
- - [PronunciationRule](#pronunciationrule)
83
- - [FunctionInclude](#functioninclude)
84
- - [DynamicConfigCallback](#dynamicconfigcallback)
85
- - [SummaryCallback](#summarycallback)
86
- - [SwaigHandler](#swaighandler)
87
- - [SwaigFunctionOptions](#swaigfunctionoptions)
88
- - [AuthConfig](#authconfig)
89
- - [SslOptions](#ssloptions)
90
- - [ValidationResult](#validationresult)
91
- - [ServerlessEvent](#serverlessevent)
92
- - [ServerlessResponse](#serverlessresponse)
93
- - [PomSectionData](#pomsectiondata)
94
-
95
- ---
96
-
97
- ## AgentBase
98
-
99
- ```ts
100
- import { AgentBase } from '@anthropic/@signalwire/sdk';
101
- ```
102
-
103
- Core agent class that composes an HTTP server, prompt management, session handling, SWAIG tool registry, and 5-phase SWML rendering into a single deployable unit.
104
-
105
- ### AgentBase Constructor
106
-
107
- ```ts
108
- constructor(opts: AgentOptions)
109
- ```
110
-
111
- Creates a new agent. See [AgentOptions](#agentoptions) for the full options table.
112
-
113
- **Example:**
114
- ```ts
115
- const agent = new AgentBase({ name: 'MyAgent', route: '/agent' });
116
- ```
117
-
118
- ### AgentBase Static Properties
119
-
120
- #### `PROMPT_SECTIONS`
121
-
122
- ```ts
123
- static PROMPT_SECTIONS?: { title: string; body?: string; bullets?: string[]; numbered?: boolean }[]
124
- ```
125
-
126
- Declarative prompt sections applied automatically by the constructor via `promptAddSection()`. Subclasses override this to define default prompt structure.
127
-
128
- **Example:**
129
- ```ts
130
- class MyAgent extends AgentBase {
131
- static override PROMPT_SECTIONS = [
132
- { title: 'Role', body: 'You are a helpful assistant.' },
133
- { title: 'Rules', bullets: ['Be concise.', 'Be polite.'] },
134
- ];
135
- }
136
- ```
137
-
138
- ### AgentBase Public Properties
139
-
140
- | Property | Type | Description |
141
- |----------|------|-------------|
142
- | `name` | `string` | Display name of this agent |
143
- | `route` | `string` | HTTP route path this agent listens on |
144
- | `host` | `string` | Hostname the HTTP server binds to |
145
- | `port` | `number` | Port number the HTTP server listens on |
146
- | `agentId` | `string` | Unique identifier for this agent instance |
147
-
148
- ### Prompt Methods
149
-
150
- #### `setPromptText(text)`
151
-
152
- ```ts
153
- setPromptText(text: string): this
154
- ```
155
-
156
- Set the main system prompt text. Bypasses POM rendering when set.
157
-
158
- #### `setPostPrompt(text)`
159
-
160
- ```ts
161
- setPostPrompt(text: string): this
162
- ```
163
-
164
- Set the post-prompt text evaluated after the call ends. Used for call summarization.
165
-
166
- #### `promptAddSection(title, opts?)`
167
-
168
- ```ts
169
- promptAddSection(title: string, opts?: {
170
- body?: string;
171
- bullets?: string[];
172
- numbered?: boolean;
173
- numberedBullets?: boolean;
174
- subsections?: { title: string; body?: string; bullets?: string[] }[];
175
- }): this
176
- ```
177
-
178
- Add a new section to the POM prompt. Sections render as Markdown headings with body text, bullet points, and nested subsections.
179
-
180
- #### `promptAddToSection(title, opts?)`
181
-
182
- ```ts
183
- promptAddToSection(title: string, opts?: {
184
- body?: string;
185
- bullet?: string;
186
- bullets?: string[];
187
- }): this
188
- ```
189
-
190
- Append content to an existing prompt section. Creates the section if it does not exist.
191
-
192
- #### `promptAddSubsection(parentTitle, title, opts?)`
193
-
194
- ```ts
195
- promptAddSubsection(parentTitle: string, title: string, opts?: {
196
- body?: string;
197
- bullets?: string[];
198
- }): this
199
- ```
200
-
201
- Add a subsection under an existing prompt section.
202
-
203
- #### `promptHasSection(title)`
204
-
205
- ```ts
206
- promptHasSection(title: string): boolean
207
- ```
208
-
209
- Check whether a prompt section with the given title exists.
210
-
211
- #### `getPrompt()`
212
-
213
- ```ts
214
- getPrompt(): string
215
- ```
216
-
217
- Get the fully rendered main prompt text.
218
-
219
- #### `getPostPrompt()`
220
-
221
- ```ts
222
- getPostPrompt(): string | null
223
- ```
224
-
225
- Get the post-prompt text, or `null` if not configured.
226
-
227
- ### Tool Methods
228
-
229
- #### `defineTool(opts)`
230
-
231
- ```ts
232
- defineTool(opts: {
233
- name: string;
234
- description: string;
235
- parameters?: Record<string, unknown>;
236
- handler: SwaigHandler;
237
- secure?: boolean;
238
- fillers?: Record<string, string[]>;
239
- waitFile?: string;
240
- waitFileLoops?: number;
241
- required?: string[];
242
- }): this
243
- ```
244
-
245
- Register a SWAIG tool (function) the AI can invoke during a call.
246
-
247
- | Parameter | Type | Default | Description |
248
- |-----------|------|---------|-------------|
249
- | `name` | `string` | -- | Unique tool name |
250
- | `description` | `string` | -- | Description shown to the AI |
251
- | `parameters` | `Record<string, unknown>` | `{}` | JSON Schema properties for the tool's parameters |
252
- | `handler` | `SwaigHandler` | -- | Callback invoked when the tool is called |
253
- | `secure` | `boolean` | `false` | Require session token authentication |
254
- | `fillers` | `Record<string, string[]>` | -- | Language-keyed filler phrases spoken during execution |
255
- | `waitFile` | `string` | -- | Audio file URL to play while waiting |
256
- | `waitFileLoops` | `number` | -- | Number of times to loop the wait file |
257
- | `required` | `string[]` | `[]` | List of required parameter names |
258
-
259
- **Example:**
260
- ```ts
261
- agent.defineTool({
262
- name: 'get_weather',
263
- description: 'Get current weather for a city',
264
- parameters: { city: { type: 'string', description: 'City name' } },
265
- handler: async (args) => new FunctionResult(`Weather in ${args.city}: sunny`),
266
- });
267
- ```
268
-
269
- #### `getRegisteredTools()`
270
-
271
- ```ts
272
- getRegisteredTools(): { name: string; description: string; parameters: Record<string, unknown> }[]
273
- ```
274
-
275
- Get a summary of all registered tools.
276
-
277
- #### `getTool(name)`
278
-
279
- ```ts
280
- getTool(name: string): SwaigFunction | undefined
281
- ```
282
-
283
- Look up a registered SwaigFunction by name.
284
-
285
- #### `registerSwaigFunction(fn)`
286
-
287
- ```ts
288
- registerSwaigFunction(fn: SwaigFunction | Record<string, unknown>): this
289
- ```
290
-
291
- Register a pre-built SwaigFunction instance or a raw function descriptor (e.g., from DataMap).
292
-
293
- ### Speech and Language Methods
294
-
295
- #### `addHint(hint)`
296
-
297
- ```ts
298
- addHint(hint: string): this
299
- ```
300
-
301
- Add a single speech-recognition hint word or phrase.
302
-
303
- #### `addHints(hints)`
304
-
305
- ```ts
306
- addHints(hints: string[]): this
307
- ```
308
-
309
- Add multiple speech-recognition hints at once.
310
-
311
- #### `addPatternHint(opts)`
312
-
313
- ```ts
314
- addPatternHint(opts: { pattern: string; replace: string; ignoreCase?: boolean }): this
315
- ```
316
-
317
- Add a pattern-based speech-recognition hint with find-and-replace behavior.
318
-
319
- #### `addLanguage(config)`
320
-
321
- ```ts
322
- addLanguage(config: LanguageConfig): this
323
- ```
324
-
325
- Add a supported language to the AI configuration. See [LanguageConfig](#languageconfig).
326
-
327
- #### `setLanguages(languages)`
328
-
329
- ```ts
330
- setLanguages(languages: LanguageConfig[]): this
331
- ```
332
-
333
- Replace all configured languages with a new list.
334
-
335
- #### `addPronunciation(rule)`
336
-
337
- ```ts
338
- addPronunciation(rule: PronunciationRule): this
339
- ```
340
-
341
- Add a pronunciation override rule for the TTS engine. See [PronunciationRule](#pronunciationrule).
342
-
343
- ### AI Configuration Methods
344
-
345
- #### `setParam(key, value)`
346
-
347
- ```ts
348
- setParam(key: string, value: unknown): this
349
- ```
350
-
351
- Set a single AI parameter (e.g., `"temperature"`, `"top_p"`).
352
-
353
- #### `setParams(params)`
354
-
355
- ```ts
356
- setParams(params: Record<string, unknown>): this
357
- ```
358
-
359
- Merge multiple AI parameters into the existing params object.
360
-
361
- #### `setGlobalData(data)`
362
-
363
- ```ts
364
- setGlobalData(data: Record<string, unknown>): this
365
- ```
366
-
367
- Replace the entire `global_data` object passed into the AI configuration.
368
-
369
- #### `updateGlobalData(data)`
370
-
371
- ```ts
372
- updateGlobalData(data: Record<string, unknown>): this
373
- ```
374
-
375
- Merge additional entries into the existing `global_data` object.
376
-
377
- #### `setNativeFunctions(funcs)`
378
-
379
- ```ts
380
- setNativeFunctions(funcs: string[]): this
381
- ```
382
-
383
- Set the list of native SWAIG function names (built-in platform functions).
384
-
385
- #### `addInternalFiller(functionName, languageCode, fillers)`
386
-
387
- ```ts
388
- addInternalFiller(functionName: string, languageCode: string, fillers: string[]): this
389
- ```
390
-
391
- Add filler phrases spoken while a specific function is executing.
392
-
393
- #### `addFunctionInclude(url, functions, metaData?)`
394
-
395
- ```ts
396
- addFunctionInclude(url: string, functions: string[], metaData?: Record<string, unknown>): this
397
- ```
398
-
399
- Add a remote SWAIG function include reference.
400
-
401
- #### `setPromptLlmParams(params)`
402
-
403
- ```ts
404
- setPromptLlmParams(params: Record<string, unknown>): this
405
- ```
406
-
407
- Merge LLM-specific parameters into the main prompt configuration (e.g., `model`, `temperature`).
408
-
409
- #### `setPostPromptLlmParams(params)`
410
-
411
- ```ts
412
- setPostPromptLlmParams(params: Record<string, unknown>): this
413
- ```
414
-
415
- Merge LLM-specific parameters into the post-prompt configuration.
416
-
417
- #### `enableDebugEvents(level?)`
418
-
419
- ```ts
420
- enableDebugEvents(level?: number): this
421
- ```
422
-
423
- Enable debug event webhooks. `level` defaults to `1`.
424
-
425
- ### Call Flow Methods
426
-
427
- The SWML document is rendered in 5 phases:
428
-
429
- 1. **Pre-answer** verbs
430
- 2. **Answer** verb
431
- 3. **Post-answer** verbs (including optional `record_call`)
432
- 4. **AI** verb
433
- 5. **Post-AI** verbs
434
-
435
- #### `addPreAnswerVerb(verbName, config)`
436
-
437
- ```ts
438
- addPreAnswerVerb(verbName: string, config: Record<string, unknown>): this
439
- ```
440
-
441
- Add a SWML verb to execute before the answer phase (phase 1).
442
-
443
- #### `addAnswerVerb(config?)`
444
-
445
- ```ts
446
- addAnswerVerb(config?: Record<string, unknown>): this
447
- ```
448
-
449
- Configure the answer verb (phase 2).
450
-
451
- #### `addPostAnswerVerb(verbName, config)`
452
-
453
- ```ts
454
- addPostAnswerVerb(verbName: string, config: Record<string, unknown>): this
455
- ```
456
-
457
- Add a verb after the answer but before the AI verb (phase 3).
458
-
459
- #### `addPostAiVerb(verbName, config)`
460
-
461
- ```ts
462
- addPostAiVerb(verbName: string, config: Record<string, unknown>): this
463
- ```
464
-
465
- Add a verb after the AI verb (phase 5).
466
-
467
- #### `clearPreAnswerVerbs()`
468
-
469
- ```ts
470
- clearPreAnswerVerbs(): this
471
- ```
472
-
473
- Remove all pre-answer verbs.
474
-
475
- #### `clearPostAnswerVerbs()`
476
-
477
- ```ts
478
- clearPostAnswerVerbs(): this
479
- ```
480
-
481
- Remove all post-answer verbs.
482
-
483
- #### `clearPostAiVerbs()`
484
-
485
- ```ts
486
- clearPostAiVerbs(): this
487
- ```
488
-
489
- Remove all post-AI verbs.
490
-
491
- ### Context Methods
492
-
493
- #### `defineContexts(contexts?)`
494
-
495
- ```ts
496
- defineContexts(contexts?: ContextBuilder | Record<string, unknown>): ContextBuilder
497
- ```
498
-
499
- Define or replace the contexts configuration for the AI verb. Returns the active ContextBuilder. See [ContextBuilder](#contextbuilder).
500
-
501
- ### Skill Methods
502
-
503
- #### `addSkill(skill)`
504
-
505
- ```ts
506
- async addSkill(skill: SkillBase): Promise<this>
507
- ```
508
-
509
- Add a skill to this agent, registering its tools, prompt sections, hints, and global data. See [SkillBase](#skillbase).
510
-
511
- #### `removeSkill(instanceId)`
512
-
513
- ```ts
514
- async removeSkill(instanceId: string): Promise<boolean>
515
- ```
516
-
517
- Remove a previously added skill by its instance ID. Returns `true` if found and removed.
518
-
519
- #### `listSkills()`
520
-
521
- ```ts
522
- listSkills(): { name: string; instanceId: string; initialized: boolean }[]
523
- ```
524
-
525
- List all registered skills.
526
-
527
- #### `hasSkill(skillName)`
528
-
529
- ```ts
530
- hasSkill(skillName: string): boolean
531
- ```
532
-
533
- Check whether a skill with the given name is registered.
534
-
535
- ### Dynamic Configuration Methods
536
-
537
- #### `setDynamicConfigCallback(cb)`
538
-
539
- ```ts
540
- setDynamicConfigCallback(cb: DynamicConfigCallback): this
541
- ```
542
-
543
- Set a callback invoked on each SWML request to dynamically modify an ephemeral agent copy. The original agent is never mutated. See [DynamicConfigCallback](#dynamicconfigcallback).
544
-
545
- #### `addSwaigQueryParams(params)`
546
-
547
- ```ts
548
- addSwaigQueryParams(params: Record<string, string>): this
549
- ```
550
-
551
- Add extra query parameters appended to all SWAIG webhook URLs.
552
-
553
- ### URL and Proxy Methods
554
-
555
- #### `manualSetProxyUrl(url)`
556
-
557
- ```ts
558
- manualSetProxyUrl(url: string): this
559
- ```
560
-
561
- Manually set the external-facing proxy base URL used for webhook URL generation. Overrides auto-detection but not the `SWML_PROXY_URL_BASE` environment variable.
562
-
563
- #### `setWebHookUrl(url)`
564
-
565
- ```ts
566
- setWebHookUrl(url: string): this
567
- ```
568
-
569
- Override the default SWAIG webhook URL.
570
-
571
- #### `setPostPromptUrl(url)`
572
-
573
- ```ts
574
- setPostPromptUrl(url: string): this
575
- ```
576
-
577
- Override the default post-prompt webhook URL.
578
-
579
- #### `getFullUrl(includeAuth?)`
580
-
581
- ```ts
582
- getFullUrl(includeAuth?: boolean): string
583
- ```
584
-
585
- Get the full external URL of this agent. When `includeAuth` is `true`, basic-auth credentials are embedded in the URL.
586
-
587
- ### Server Methods
588
-
589
- #### `getApp()`
590
-
591
- ```ts
592
- getApp(): Hono
593
- ```
594
-
595
- Get or lazily create the Hono HTTP application with all routes, middleware, auth, and CORS. Routes created:
596
-
597
- | Endpoint | Method | Description |
598
- |----------|--------|-------------|
599
- | `{route}` | GET/POST | Returns rendered SWML |
600
- | `{route}/swaig` | GET/POST | SWAIG function dispatcher |
601
- | `{route}/post_prompt` | GET/POST | Post-prompt handler |
602
- | `{route}/debug_events` | POST | Debug event handler |
603
- | `{route}/health` | GET | Health check (`{ status: 'ok' }`) |
604
- | `{route}/ready` | GET | Readiness check (`{ status: 'ready' }`) |
605
-
606
- #### `asRouter()`
607
-
608
- ```ts
609
- asRouter(): Hono
610
- ```
611
-
612
- Return this agent's Hono app for mounting as a sub-router in an AgentServer.
613
-
614
- #### `serve()`
615
-
616
- ```ts
617
- async serve(): Promise<void>
618
- ```
619
-
620
- Start the HTTP server and begin listening for requests.
621
-
622
- #### `run()`
623
-
624
- ```ts
625
- async run(): Promise<void>
626
- ```
627
-
628
- Alias for `serve()`.
629
-
630
- #### `renderSwml(callId?)`
631
-
632
- ```ts
633
- renderSwml(callId?: string): string
634
- ```
635
-
636
- Render the complete SWML document as a JSON string. Assembles all 5 phases.
637
-
638
- ### Utility Methods
639
-
640
- #### `getName()`
641
-
642
- ```ts
643
- getName(): string
644
- ```
645
-
646
- Get the agent's display name.
647
-
648
- #### `getBasicAuthCredentials(includeSource?)`
649
-
650
- ```ts
651
- getBasicAuthCredentials(): [string, string]
652
- getBasicAuthCredentials(includeSource: true): [string, string, 'provided' | 'environment' | 'generated']
653
- ```
654
-
655
- Get the basic-auth credentials. When `includeSource` is `true`, appends the source as a third element.
656
-
657
- ### Protected Hooks
658
-
659
- Override these in subclasses to customize agent behavior.
660
-
661
- #### `defineTools()`
662
-
663
- ```ts
664
- protected defineTools(): void
665
- ```
666
-
667
- Lifecycle method for subclasses to register tools. Called explicitly by subclass constructors (not automatic). Default is a no-op.
668
-
669
- #### `onSummary(summary, rawData)`
670
-
671
- ```ts
672
- onSummary(summary: Record<string, unknown> | null, rawData: Record<string, unknown>): void | Promise<void>
673
- ```
674
-
675
- Called when a post-prompt summary is received at the end of a call.
676
-
677
- #### `onSwmlRequest(rawData)`
678
-
679
- ```ts
680
- onSwmlRequest(rawData: Record<string, unknown>): void | Promise<void>
681
- ```
682
-
683
- Called on every SWML request before rendering.
684
-
685
- #### `onDebugEvent(event)`
686
-
687
- ```ts
688
- onDebugEvent(event: Record<string, unknown>): void | Promise<void>
689
- ```
690
-
691
- Called when a debug event webhook is received.
692
-
693
- #### `validateBasicAuth(username, password)`
694
-
695
- ```ts
696
- validateBasicAuth(username: string, password: string): boolean | Promise<boolean>
697
- ```
698
-
699
- Override to add custom basic-auth validation logic. Return `true` to allow, `false` to reject. Default returns `true`.
700
-
701
- #### `onFunctionCall(name, args, rawData)`
702
-
703
- ```ts
704
- onFunctionCall(name: string, args: Record<string, unknown>, rawData: Record<string, unknown>): void | Promise<void>
705
- ```
706
-
707
- Pre-execution hook called before each SWAIG function.
708
-
709
- ---
710
-
711
- ## AgentServer
712
-
713
- ```ts
714
- import { AgentServer } from '@anthropic/@signalwire/sdk';
715
- ```
716
-
717
- Multi-agent HTTP server that hosts multiple AgentBase instances on distinct route prefixes.
718
-
719
- ### Constructor
720
-
721
- ```ts
722
- constructor(opts?: { host?: string; port?: number })
723
- ```
724
-
725
- | Parameter | Type | Default | Description |
726
- |-----------|------|---------|-------------|
727
- | `host` | `string` | `'0.0.0.0'` | Hostname to bind to |
728
- | `port` | `number` | `PORT` env or `3000` | Port to listen on |
729
-
730
- ### Methods
731
-
732
- #### `register(agent, route?)`
733
-
734
- ```ts
735
- register(agent: AgentBase, route?: string): void
736
- ```
737
-
738
- Register an agent at the given route prefix. Defaults to the agent's own route. Throws if the route is already occupied.
739
-
740
- #### `unregister(route)`
741
-
742
- ```ts
743
- unregister(route: string): void
744
- ```
745
-
746
- Remove an agent registration by route.
747
-
748
- #### `getAgents()`
749
-
750
- ```ts
751
- getAgents(): Map<string, AgentBase>
752
- ```
753
-
754
- Get all registered agents keyed by route prefix.
755
-
756
- #### `getAgent(route)`
757
-
758
- ```ts
759
- getAgent(route: string): AgentBase | undefined
760
- ```
761
-
762
- Look up a registered agent by route prefix.
763
-
764
- #### `getApp()`
765
-
766
- ```ts
767
- getApp(): Hono
768
- ```
769
-
770
- Build and return the Hono application with all registered agents and a root listing endpoint (unless an agent is mounted at `/`).
771
-
772
- #### `run(host?, port?)`
773
-
774
- ```ts
775
- async run(host?: string, port?: number): Promise<void>
776
- ```
777
-
778
- Start the HTTP server. Optional host/port overrides the constructor values.
779
-
780
- **Example:**
781
- ```ts
782
- const server = new AgentServer({ port: 8080 });
783
- server.register(agent1, '/sales');
784
- server.register(agent2, '/support');
785
- await server.run();
786
- ```
787
-
788
- ---
789
-
790
- ## FunctionResult
791
-
792
- ```ts
793
- import { FunctionResult } from '@anthropic/@signalwire/sdk';
794
- ```
795
-
796
- Builder for SWAIG function responses. Carries response text and an ordered list of structured actions. Every mutating method returns `this` for fluent chaining.
797
-
798
- ### FunctionResult Constructor
799
-
800
- ```ts
801
- constructor(response?: string, postProcess?: boolean)
802
- ```
803
-
804
- | Parameter | Type | Default | Description |
805
- |-----------|------|---------|-------------|
806
- | `response` | `string` | `''` | Initial response text |
807
- | `postProcess` | `boolean` | `false` | Whether actions are post-processed after the AI responds |
808
-
809
- ### Public Properties
810
-
811
- | Property | Type | Description |
812
- |----------|------|-------------|
813
- | `response` | `string` | The text response returned to the AI |
814
- | `action` | `Record<string, unknown>[]` | Ordered list of actions |
815
- | `postProcess` | `boolean` | Whether post-processing is enabled |
816
-
817
- ### FunctionResult Core Methods
818
-
819
- | Method | Signature | Description |
820
- |--------|-----------|-------------|
821
- | `setResponse` | `(response: string): this` | Set the response text |
822
- | `setPostProcess` | `(postProcess: boolean): this` | Enable/disable post-processing |
823
- | `addAction` | `(name: string, data: unknown): this` | Append a named action |
824
- | `addActions` | `(actions: Record<string, unknown>[]): this` | Append multiple actions |
825
-
826
- ### Call Control Actions
827
-
828
- | Method | Signature | Description |
829
- |--------|-----------|-------------|
830
- | `connect` | `(destination: string, final?: boolean, fromAddr?: string): this` | Connect to another destination via SWML transfer |
831
- | `swmlTransfer` | `(dest: string, aiResponse: string, final?: boolean): this` | Transfer with a custom AI response |
832
- | `hangup` | `(): this` | Hang up the call |
833
- | `hold` | `(timeout?: number): this` | Place on hold (0-900 seconds, default 300) |
834
- | `waitForUser` | `(opts?: { enabled?: boolean; timeout?: number; answerFirst?: boolean }): this` | Wait for user input |
835
- | `stop` | `(): this` | Stop the AI session |
836
-
837
- ### Audio Actions
838
-
839
- | Method | Signature | Description |
840
- |--------|-----------|-------------|
841
- | `say` | `(text: string): this` | Speak text via TTS |
842
- | `playBackgroundFile` | `(filename: string, wait?: boolean): this` | Play background audio |
843
- | `stopBackgroundFile` | `(): this` | Stop background audio |
844
-
845
- ### Speech Actions
846
-
847
- | Method | Signature | Description |
848
- |--------|-----------|-------------|
849
- | `addDynamicHints` | `(hints: (string \| { pattern: string; replace: string; ignore_case?: boolean })[]): this` | Add dynamic speech hints |
850
- | `clearDynamicHints` | `(): this` | Remove all dynamic hints |
851
- | `setEndOfSpeechTimeout` | `(milliseconds: number): this` | Set silence duration marking end of speech |
852
- | `setSpeechEventTimeout` | `(milliseconds: number): this` | Set speech event detection timeout |
853
-
854
- ### Data Actions
855
-
856
- | Method | Signature | Description |
857
- |--------|-----------|-------------|
858
- | `updateGlobalData` | `(data: Record<string, unknown>): this` | Merge into global data store |
859
- | `removeGlobalData` | `(keys: string \| string[]): this` | Remove keys from global data |
860
- | `setMetadata` | `(data: Record<string, unknown>): this` | Set call metadata |
861
- | `removeMetadata` | `(keys: string \| string[]): this` | Remove call metadata keys |
862
-
863
- ### SWML Actions
864
-
865
- | Method | Signature | Description |
866
- |--------|-----------|-------------|
867
- | `executeSwml` | `(swmlContent: string \| Record<string, unknown>, transfer?: boolean): this` | Execute arbitrary SWML |
868
- | `swmlChangeStep` | `(stepName: string): this` | Change the current SWML step |
869
- | `swmlChangeContext` | `(contextName: string): this` | Change the current SWML context |
870
- | `swmlUserEvent` | `(eventData: Record<string, unknown>): this` | Emit a custom user event |
871
- | `switchContext` | `(opts?: { systemPrompt?: string; userPrompt?: string; consolidate?: boolean; fullReset?: boolean }): this` | Switch AI context with optional new prompts |
872
-
873
- ### Function Actions
874
-
875
- | Method | Signature | Description |
876
- |--------|-----------|-------------|
877
- | `toggleFunctions` | `(toggles: { function: string; active: boolean }[]): this` | Enable/disable functions by name |
878
- | `enableFunctionsOnTimeout` | `(enabled?: boolean): this` | Control function fire on speaker timeout |
879
- | `updateSettings` | `(settings: Record<string, unknown>): this` | Update AI engine settings at runtime |
880
-
881
- ### Communication Actions
882
-
883
- | Method | Signature | Description |
884
- |--------|-----------|-------------|
885
- | `simulateUserInput` | `(text: string): this` | Inject text as if the user had spoken it |
886
- | `enableExtensiveData` | `(enabled?: boolean): this` | Enable extensive data reporting |
887
- | `replaceInHistory` | `(text: string \| boolean): this` | Replace function output in conversation history |
888
- | `sendSms` | `(opts: { toNumber, fromNumber, body?, media?, tags?, region? }): this` | Send an SMS/MMS message |
889
- | `recordCall` | `(opts?): this` | Start recording the call |
890
- | `stopRecordCall` | `(controlId?: string): this` | Stop an active call recording |
891
- | `tap` | `(opts: { uri, controlId?, direction?, codec?, rtpPtime?, statusUrl? }): this` | Start a media tap |
892
- | `stopTap` | `(controlId?: string): this` | Stop a media tap |
893
-
894
- ### Room and Conference Actions
895
-
896
- | Method | Signature | Description |
897
- |--------|-----------|-------------|
898
- | `joinRoom` | `(name: string): this` | Join a SignalWire room |
899
- | `sipRefer` | `(toUri: string): this` | Send a SIP REFER |
900
- | `joinConference` | `(name: string, opts?): this` | Join a conference with optional settings |
901
-
902
- ### RPC Actions
903
-
904
- | Method | Signature | Description |
905
- |--------|-----------|-------------|
906
- | `executeRpc` | `(opts: { method, params?, callId?, nodeId? }): this` | Execute a SignalWire RPC method |
907
- | `rpcDial` | `(toNumber, fromNumber, destSwml, deviceType?): this` | Dial a number via RPC |
908
- | `rpcAiMessage` | `(callId, messageText, role?): this` | Send an AI message to another call |
909
- | `rpcAiUnhold` | `(callId: string): this` | Unhold a call via RPC |
910
-
911
- ### Payment Actions
912
-
913
- #### `pay(opts)`
914
-
915
- ```ts
916
- pay(opts: {
917
- paymentConnectorUrl: string;
918
- inputMethod?: string; // default 'dtmf'
919
- statusUrl?: string;
920
- paymentMethod?: string; // default 'credit-card'
921
- timeout?: number; // default 5
922
- maxAttempts?: number; // default 1
923
- securityCode?: boolean; // default true
924
- postalCode?: boolean | string; // default true
925
- minPostalCodeLength?: number; // default 0
926
- tokenType?: string; // default 'reusable'
927
- chargeAmount?: string;
928
- currency?: string; // default 'usd'
929
- language?: string; // default 'en-US'
930
- voice?: string; // default 'woman'
931
- description?: string;
932
- validCardTypes?: string; // default 'visa mastercard amex'
933
- parameters?: PaymentParameter[];
934
- prompts?: PaymentPrompt[];
935
- aiResponse?: string;
936
- }): this
937
- ```
938
-
939
- Initiate a payment collection flow.
940
-
941
- ### FunctionResult Static Helpers
942
-
943
- | Method | Signature | Returns |
944
- |--------|-----------|---------|
945
- | `createPaymentPrompt` | `(forSituation, actions, cardType?, errorType?)` | `PaymentPrompt` |
946
- | `createPaymentAction` | `(actionType, phrase)` | `PaymentAction` |
947
- | `createPaymentParameter` | `(name, value)` | `PaymentParameter` |
948
-
949
- ### FunctionResult Serialization
950
-
951
- #### `toDict()`
952
-
953
- ```ts
954
- toDict(): Record<string, unknown>
955
- ```
956
-
957
- Serialize to a plain object for the SWAIG response. Returns `{ response, action, post_process }`. Falls back to `{ response: "Action completed." }` when empty.
958
-
959
- ---
960
-
961
- ## SwaigFunction
962
-
963
- ```ts
964
- import { SwaigFunction } from '@anthropic/@signalwire/sdk';
965
- ```
966
-
967
- Wraps a tool handler function with metadata for SWAIG registration.
968
-
969
- ### Constructor
970
-
971
- ```ts
972
- constructor(opts: SwaigFunctionOptions)
973
- ```
974
-
975
- See [SwaigFunctionOptions](#swaigfunctionoptions) for the options table.
976
-
977
- ### Public Properties
978
-
979
- | Property | Type | Description |
980
- |----------|------|-------------|
981
- | `name` | `string` | Unique tool name |
982
- | `handler` | `SwaigHandler` | Handler function |
983
- | `description` | `string` | Description shown to the AI |
984
- | `parameters` | `Record<string, unknown>` | JSON Schema properties |
985
- | `secure` | `boolean` | Whether session token auth is required |
986
- | `fillers` | `Record<string, string[]>` | Language-keyed filler phrases |
987
- | `waitFile` | `string \| undefined` | Audio file URL played while waiting |
988
- | `waitFileLoops` | `number \| undefined` | Wait file loop count |
989
- | `webhookUrl` | `string \| undefined` | External webhook URL |
990
- | `required` | `string[]` | Required parameter names |
991
- | `extraFields` | `Record<string, unknown>` | Additional SWAIG definition fields |
992
- | `isExternal` | `boolean` | Whether this is externally hosted |
993
-
994
- ### Methods
995
-
996
- #### `execute(args, rawData?)`
997
-
998
- ```ts
999
- async execute(args: Record<string, unknown>, rawData?: Record<string, unknown>): Promise<Record<string, unknown>>
1000
- ```
1001
-
1002
- Invoke the handler and return a serialized result dictionary. On error, returns a user-friendly error message.
1003
-
1004
- #### `toSwaig(baseUrl, token?, callId?)`
1005
-
1006
- ```ts
1007
- toSwaig(baseUrl: string, token?: string, callId?: string): Record<string, unknown>
1008
- ```
1009
-
1010
- Serialize to the SWAIG wire format for inclusion in SWML. Returns an object with `function`, `description`, `parameters`, `web_hook_url`, and optional fields.
1011
-
1012
- ---
1013
-
1014
- ## DataMap
1015
-
1016
- ```ts
1017
- import { DataMap, createSimpleApiTool, createExpressionTool } from '@anthropic/@signalwire/sdk';
1018
- ```
1019
-
1020
- Fluent builder for SWAIG `data_map` configurations. Creates server-side tool definitions that execute on SignalWire without requiring webhook endpoints.
1021
-
1022
- ### DataMap Constructor
1023
-
1024
- ```ts
1025
- constructor(functionName: string)
1026
- ```
1027
-
1028
- | Parameter | Type | Description |
1029
- |-----------|------|-------------|
1030
- | `functionName` | `string` | Unique name for this data map tool |
1031
-
1032
- ### DataMap Configuration Methods
1033
-
1034
- #### `enableEnvExpansion(enabled?)`
1035
-
1036
- ```ts
1037
- enableEnvExpansion(enabled?: boolean): this
1038
- ```
1039
-
1040
- Enable `${ENV.*}` variable expansion in URLs, bodies, and outputs. Default `true`.
1041
-
1042
- #### `purpose(description)` / `description(description)`
1043
-
1044
- ```ts
1045
- purpose(description: string): this
1046
- description(description: string): this // alias
1047
- ```
1048
-
1049
- Set the tool description shown to the AI.
1050
-
1051
- #### `parameter(name, paramType, description, opts?)`
1052
-
1053
- ```ts
1054
- parameter(name: string, paramType: string, description: string, opts?: {
1055
- required?: boolean;
1056
- enum?: string[];
1057
- }): this
1058
- ```
1059
-
1060
- Define a parameter for this data map tool.
1061
-
1062
- #### `expression(testValue, pattern, output, nomatchOutput?)`
1063
-
1064
- ```ts
1065
- expression(
1066
- testValue: string,
1067
- pattern: string | RegExp,
1068
- output: FunctionResult,
1069
- nomatchOutput?: FunctionResult,
1070
- ): this
1071
- ```
1072
-
1073
- Add a pattern-matching expression that evaluates a test value against a regex.
1074
-
1075
- ### DataMap Webhook Methods
1076
-
1077
- #### `webhook(method, url, opts?)`
1078
-
1079
- ```ts
1080
- webhook(method: string, url: string, opts?: {
1081
- headers?: Record<string, string>;
1082
- formParam?: string;
1083
- inputArgsAsParams?: boolean;
1084
- requireArgs?: string[];
1085
- }): this
1086
- ```
1087
-
1088
- Add a webhook called when this data map tool is invoked.
1089
-
1090
- #### `webhookExpressions(expressions)`
1091
-
1092
- ```ts
1093
- webhookExpressions(expressions: Record<string, unknown>[]): this
1094
- ```
1095
-
1096
- Set expressions on the most recently added webhook.
1097
-
1098
- #### `body(data)`
1099
-
1100
- ```ts
1101
- body(data: Record<string, unknown>): this
1102
- ```
1103
-
1104
- Set the JSON body for the most recently added webhook.
1105
-
1106
- #### `params(data)`
1107
-
1108
- ```ts
1109
- params(data: Record<string, unknown>): this
1110
- ```
1111
-
1112
- Set query/form parameters for the most recently added webhook.
1113
-
1114
- #### `foreach(config)`
1115
-
1116
- ```ts
1117
- foreach(config: { input_key: string; output_key: string; append: string; max?: number }): this
1118
- ```
1119
-
1120
- Configure iteration over an array in the webhook response.
1121
-
1122
- ### DataMap Output Methods
1123
-
1124
- #### `output(result)`
1125
-
1126
- ```ts
1127
- output(result: FunctionResult): this
1128
- ```
1129
-
1130
- Set the output template for the most recently added webhook.
1131
-
1132
- #### `fallbackOutput(result)`
1133
-
1134
- ```ts
1135
- fallbackOutput(result: FunctionResult): this
1136
- ```
1137
-
1138
- Set a fallback output used when no webhook or expression matches.
1139
-
1140
- #### `errorKeys(keys)`
1141
-
1142
- ```ts
1143
- errorKeys(keys: string[]): this
1144
- ```
1145
-
1146
- Set error keys on the most recently added webhook (or globally if no webhook exists).
1147
-
1148
- #### `globalErrorKeys(keys)`
1149
-
1150
- ```ts
1151
- globalErrorKeys(keys: string[]): this
1152
- ```
1153
-
1154
- Set error keys at the top-level data map scope.
1155
-
1156
- ### DataMap Registration and Serialization
1157
-
1158
- #### `registerWithAgent(agent)`
1159
-
1160
- ```ts
1161
- registerWithAgent(agent: { registerSwaigFunction(fn: Record<string, unknown>): unknown }): this
1162
- ```
1163
-
1164
- Register this DataMap tool with an AgentBase instance.
1165
-
1166
- #### `toSwaigFunction()`
1167
-
1168
- ```ts
1169
- toSwaigFunction(): Record<string, unknown>
1170
- ```
1171
-
1172
- Serialize to a SWAIG function definition object suitable for SWML.
1173
-
1174
- ### DataMap Factory Functions
1175
-
1176
- #### `createSimpleApiTool(opts)`
1177
-
1178
- ```ts
1179
- function createSimpleApiTool(opts: {
1180
- name: string;
1181
- url: string;
1182
- responseTemplate: string;
1183
- parameters?: Record<string, { type?: string; description?: string; required?: boolean }>;
1184
- method?: string; // default 'GET'
1185
- headers?: Record<string, string>;
1186
- body?: Record<string, unknown>;
1187
- errorKeys?: string[];
1188
- }): DataMap
1189
- ```
1190
-
1191
- Create a DataMap tool that calls a single API endpoint and formats the response.
1192
-
1193
- #### `createExpressionTool(opts)`
1194
-
1195
- ```ts
1196
- function createExpressionTool(opts: {
1197
- name: string;
1198
- patterns: Record<string, [string, FunctionResult]>;
1199
- parameters?: Record<string, { type?: string; description?: string; required?: boolean }>;
1200
- }): DataMap
1201
- ```
1202
-
1203
- Create a DataMap tool that evaluates expressions against patterns without making HTTP calls.
1204
-
1205
- ---
1206
-
1207
- ## ContextBuilder
1208
-
1209
- ```ts
1210
- import { ContextBuilder, Context, Step, GatherInfo, GatherQuestion, createSimpleContext } from '@anthropic/@signalwire/sdk';
1211
- ```
1212
-
1213
- Contexts and Steps workflow system. Contexts contain ordered Steps, each with prompt content, completion criteria, function restrictions, and navigation rules.
1214
-
1215
- ### ContextBuilder Class
1216
-
1217
- Builds and validates a collection of named contexts for multi-step AI workflows.
1218
-
1219
- #### `addContext(name)`
1220
-
1221
- ```ts
1222
- addContext(name: string): Context
1223
- ```
1224
-
1225
- Add a new named context. Returns the created Context for further configuration. Throws if the name already exists.
1226
-
1227
- #### `getContext(name)`
1228
-
1229
- ```ts
1230
- getContext(name: string): Context | undefined
1231
- ```
1232
-
1233
- Retrieve a context by name.
1234
-
1235
- #### `validate()`
1236
-
1237
- ```ts
1238
- validate(): void
1239
- ```
1240
-
1241
- Validate all contexts: at least one must exist, single contexts must be named `'default'`, all contexts must have steps, and cross-context references must be valid. Throws on failure.
1242
-
1243
- #### `toDict()`
1244
-
1245
- ```ts
1246
- toDict(): Record<string, unknown>
1247
- ```
1248
-
1249
- Validate and serialize all contexts to a plain object for SWML output.
1250
-
1251
- ### Context Class
1252
-
1253
- A named context containing ordered steps, prompt configuration, and navigation rules.
1254
-
1255
- #### Constructor
1256
-
1257
- ```ts
1258
- constructor(name: string)
1259
- ```
1260
-
1261
- #### Step Management
1262
-
1263
- | Method | Signature | Returns | Description |
1264
- |--------|-----------|---------|-------------|
1265
- | `addStep` | `(name, opts?)` | `Step` | Add a new step with optional shorthand config |
1266
- | `getStep` | `(name: string)` | `Step \| undefined` | Retrieve a step by name |
1267
- | `removeStep` | `(name: string)` | `this` | Remove a step by name |
1268
- | `moveStep` | `(name: string, position: number)` | `this` | Move a step to a new position |
1269
-
1270
- The `addStep` options shorthand:
1271
-
1272
- | Option | Type | Description |
1273
- |--------|------|-------------|
1274
- | `task` | `string` | Shorthand for `addSection('Task', task)` |
1275
- | `bullets` | `string[]` | Shorthand for `addBullets('Process', bullets)` |
1276
- | `criteria` | `string` | Shorthand for `setStepCriteria(criteria)` |
1277
- | `functions` | `string \| string[]` | Shorthand for `setFunctions(functions)` |
1278
- | `validSteps` | `string[]` | Shorthand for `setValidSteps(validSteps)` |
1279
-
1280
- #### Navigation and Configuration
1281
-
1282
- | Method | Signature | Description |
1283
- |--------|-----------|-------------|
1284
- | `setValidContexts` | `(contexts: string[]): this` | Set allowed context navigation targets |
1285
- | `setValidSteps` | `(steps: string[]): this` | Set allowed step navigation targets |
1286
- | `setPostPrompt` | `(postPrompt: string): this` | Set context post-prompt text |
1287
- | `setSystemPrompt` | `(systemPrompt: string): this` | Set raw system prompt (mutually exclusive with POM sections) |
1288
- | `setConsolidate` | `(consolidate: boolean): this` | Consolidate conversation history on entry |
1289
- | `setFullReset` | `(fullReset: boolean): this` | Fully reset conversation history on entry |
1290
- | `setUserPrompt` | `(userPrompt: string): this` | Set user prompt text |
1291
- | `setIsolated` | `(isolated: boolean): this` | Isolate from other contexts' history |
1292
- | `setPrompt` | `(prompt: string): this` | Set raw prompt text (mutually exclusive with POM sections) |
1293
-
1294
- #### POM Sections
1295
-
1296
- | Method | Signature | Description |
1297
- |--------|-----------|-------------|
1298
- | `addSystemSection` | `(title: string, body: string): this` | Add POM section to system prompt |
1299
- | `addSystemBullets` | `(title: string, bullets: string[]): this` | Add POM bullet section to system prompt |
1300
- | `addSection` | `(title: string, body: string): this` | Add POM section to context prompt |
1301
- | `addBullets` | `(title: string, bullets: string[]): this` | Add POM bullet section to context prompt |
1302
-
1303
- #### Fillers
1304
-
1305
- | Method | Signature | Description |
1306
- |--------|-----------|-------------|
1307
- | `setEnterFillers` | `(fillers: Record<string, string[]>): this` | Set all enter fillers by language |
1308
- | `setExitFillers` | `(fillers: Record<string, string[]>): this` | Set all exit fillers by language |
1309
- | `addEnterFiller` | `(languageCode: string, fillers: string[]): this` | Add enter fillers for one language |
1310
- | `addExitFiller` | `(languageCode: string, fillers: string[]): this` | Add exit fillers for one language |
1311
-
1312
- #### `toDict()`
1313
-
1314
- ```ts
1315
- toDict(): Record<string, unknown>
1316
- ```
1317
-
1318
- Serialize this context and all its steps to SWML output. Throws if no steps are defined.
1319
-
1320
- ### Step Class
1321
-
1322
- A single step within a context.
1323
-
1324
- #### Constructor
1325
-
1326
- ```ts
1327
- constructor(name: string)
1328
- ```
1329
-
1330
- #### Content Methods
1331
-
1332
- | Method | Signature | Description |
1333
- |--------|-----------|-------------|
1334
- | `setText` | `(text: string): this` | Set raw text (mutually exclusive with POM sections) |
1335
- | `addSection` | `(title: string, body: string): this` | Add a POM section with body |
1336
- | `addBullets` | `(title: string, bullets: string[]): this` | Add a POM section with bullets |
1337
- | `clearSections` | `(): this` | Remove all sections and raw text |
1338
-
1339
- #### Configuration Methods
1340
-
1341
- | Method | Signature | Description |
1342
- |--------|-----------|-------------|
1343
- | `setStepCriteria` | `(criteria: string): this` | Set completion criteria |
1344
- | `setFunctions` | `(functions: string \| string[]): this` | Restrict available functions |
1345
- | `setValidSteps` | `(steps: string[]): this` | Set allowed step navigation |
1346
- | `setValidContexts` | `(contexts: string[]): this` | Set allowed context navigation |
1347
- | `setEnd` | `(end: boolean): this` | Mark as terminal step |
1348
- | `setSkipUserTurn` | `(skip: boolean): this` | Skip waiting for user input |
1349
- | `setSkipToNextStep` | `(skip: boolean): this` | Auto-advance to next step |
1350
-
1351
- #### Gather Info Methods
1352
-
1353
- | Method | Signature | Description |
1354
- |--------|-----------|-------------|
1355
- | `setGatherInfo` | `(opts?: { outputKey?; completionAction?; prompt? }): this` | Initialize a gather info operation |
1356
- | `addGatherQuestion` | `(opts: { key; question; type?; confirm?; prompt?; functions? }): this` | Add a question to the gather |
1357
-
1358
- #### Reset Methods
1359
-
1360
- | Method | Signature | Description |
1361
- |--------|-----------|-------------|
1362
- | `setResetSystemPrompt` | `(systemPrompt: string): this` | System prompt for context reset |
1363
- | `setResetUserPrompt` | `(userPrompt: string): this` | User prompt for context reset |
1364
- | `setResetConsolidate` | `(consolidate: boolean): this` | Consolidate on reset |
1365
- | `setResetFullReset` | `(fullReset: boolean): this` | Full reset on step entry |
1366
-
1367
- #### `toDict()`
1368
-
1369
- ```ts
1370
- toDict(): Record<string, unknown>
1371
- ```
1372
-
1373
- Serialize this step to SWML output.
1374
-
1375
- ### GatherInfo Class
1376
-
1377
- Collects structured information through a series of questions.
1378
-
1379
- #### Constructor
1380
-
1381
- ```ts
1382
- constructor(opts?: { outputKey?: string; completionAction?: string; prompt?: string })
1383
- ```
1384
-
1385
- #### Methods
1386
-
1387
- | Method | Signature | Description |
1388
- |--------|-----------|-------------|
1389
- | `addQuestion` | `(opts: { key; question; type?; confirm?; prompt?; functions? }): this` | Add a question |
1390
- | `getQuestions` | `(): GatherQuestion[]` | Return all questions |
1391
- | `toDict` | `(): Record<string, unknown>` | Serialize to SWML output |
1392
-
1393
- ### GatherQuestion Class
1394
-
1395
- A single question within a gather operation.
1396
-
1397
- #### Constructor
1398
-
1399
- ```ts
1400
- constructor(opts: {
1401
- key: string;
1402
- question: string;
1403
- type?: string; // default 'string'
1404
- confirm?: boolean; // default false
1405
- prompt?: string;
1406
- functions?: string[];
1407
- })
1408
- ```
1409
-
1410
- #### Properties
1411
-
1412
- | Property | Type | Description |
1413
- |----------|------|-------------|
1414
- | `key` | `string` | Unique answer storage key |
1415
- | `question` | `string` | Question text |
1416
- | `type` | `string` | Expected answer type |
1417
- | `confirm` | `boolean` | Whether confirmation is required |
1418
- | `prompt` | `string \| undefined` | Additional prompt context |
1419
- | `functions` | `string[] \| undefined` | Available functions during this question |
1420
-
1421
- #### `toDict()`
1422
-
1423
- ```ts
1424
- toDict(): Record<string, unknown>
1425
- ```
1426
-
1427
- ### ContextBuilder Helper Functions
1428
-
1429
- #### `createSimpleContext(name?)`
1430
-
1431
- ```ts
1432
- function createSimpleContext(name?: string): Context
1433
- ```
1434
-
1435
- Create a standalone Context without a ContextBuilder. Name defaults to `'default'`.
1436
-
1437
- ---
1438
-
1439
- ## PomBuilder
1440
-
1441
- ```ts
1442
- import { PomBuilder, PomSection } from '@anthropic/@signalwire/sdk';
1443
- ```
1444
-
1445
- Prompt Object Model for structured prompt sections. Sections have a title, body, bullets (optionally numbered), and nested subsections.
1446
-
1447
- ### PomSection Class
1448
-
1449
- A single section in a POM.
1450
-
1451
- #### Constructor
1452
-
1453
- ```ts
1454
- constructor(opts?: {
1455
- title?: string | null;
1456
- body?: string;
1457
- bullets?: string[];
1458
- numbered?: boolean | null;
1459
- numberedBullets?: boolean;
1460
- })
1461
- ```
1462
-
1463
- #### Properties
1464
-
1465
- | Property | Type | Description |
1466
- |----------|------|-------------|
1467
- | `title` | `string \| null` | Section heading |
1468
- | `body` | `string` | Body text |
1469
- | `bullets` | `string[]` | Bullet points |
1470
- | `subsections` | `PomSection[]` | Nested child sections |
1471
- | `numbered` | `boolean \| null` | Whether this section is numbered |
1472
- | `numberedBullets` | `boolean` | Whether bullets are numbered |
1473
-
1474
- #### Methods
1475
-
1476
- | Method | Signature | Returns | Description |
1477
- |--------|-----------|---------|-------------|
1478
- | `addSubsection` | `(opts: { title, body?, bullets?, numbered?, numberedBullets? })` | `PomSection` | Add a nested subsection |
1479
- | `toDict` | `()` | `PomSectionData` | Serialize to plain object |
1480
- | `renderMarkdown` | `(level?, sectionNumber?)` | `string` | Render as Markdown |
1481
-
1482
- ### PomBuilder Class
1483
-
1484
- Builds a structured prompt by composing named POM sections.
1485
-
1486
- #### Methods
1487
-
1488
- | Method | Signature | Returns | Description |
1489
- |--------|-----------|---------|-------------|
1490
- | `addSection` | `(title, opts?)` | `this` | Add a top-level section |
1491
- | `addToSection` | `(title, opts?)` | `this` | Append to an existing section |
1492
- | `addSubsection` | `(parentTitle, title, opts?)` | `this` | Add subsection under a parent |
1493
- | `hasSection` | `(title: string)` | `boolean` | Check if section exists |
1494
- | `getSection` | `(title: string)` | `PomSection \| undefined` | Get section by title |
1495
- | `findSection` | `(title: string)` | `PomSection \| undefined` | Recursive deep search |
1496
- | `toDict` | `()` | `PomSectionData[]` | Serialize all sections |
1497
- | `renderMarkdown` | `()` | `string` | Render all sections as Markdown |
1498
-
1499
- ---
1500
-
1501
- ## SwmlBuilder
1502
-
1503
- ```ts
1504
- import { SwmlBuilder } from '@anthropic/@signalwire/sdk';
1505
- ```
1506
-
1507
- Builds SWML (SignalWire Markup Language) documents: `{ version: "1.0.0", sections: { main: [...verbs] } }`.
1508
-
1509
- ### Methods
1510
-
1511
- | Method | Signature | Returns | Description |
1512
- |--------|-----------|---------|-------------|
1513
- | `reset` | `()` | `void` | Reset to empty document |
1514
- | `addVerb` | `(verbName: string, config: unknown)` | `void` | Append verb to the `main` section |
1515
- | `addVerbToSection` | `(sectionName, verbName, config)` | `void` | Append verb to a named section |
1516
- | `getDocument` | `()` | `Record<string, unknown>` | Get the raw document object |
1517
- | `renderDocument` | `()` | `string` | Serialize to JSON string |
1518
-
1519
- ---
1520
-
1521
- ## PromptManager
1522
-
1523
- ```ts
1524
- import { PromptManager } from '@anthropic/@signalwire/sdk';
1525
- ```
1526
-
1527
- Manages agent prompt text, supporting both raw text and structured POM-based prompts.
1528
-
1529
- ### Constructor
1530
-
1531
- ```ts
1532
- constructor(usePom?: boolean)
1533
- ```
1534
-
1535
- | Parameter | Type | Default | Description |
1536
- |-----------|------|---------|-------------|
1537
- | `usePom` | `boolean` | `true` | Whether to use POM sections |
1538
-
1539
- ### Methods
1540
-
1541
- | Method | Signature | Returns | Description |
1542
- |--------|-----------|---------|-------------|
1543
- | `setPromptText` | `(text: string)` | `void` | Set raw prompt text, bypassing POM |
1544
- | `setPostPrompt` | `(text: string)` | `void` | Set post-prompt text |
1545
- | `addSection` | `(title, opts?)` | `void` | Add a POM section |
1546
- | `addToSection` | `(title, opts?)` | `void` | Append to a POM section |
1547
- | `addSubsection` | `(parentTitle, title, opts?)` | `void` | Add a POM subsection |
1548
- | `hasSection` | `(title: string)` | `boolean` | Check if section exists |
1549
- | `getPrompt` | `()` | `string` | Get rendered prompt text |
1550
- | `getPostPrompt` | `()` | `string \| null` | Get post-prompt text |
1551
- | `getPomBuilder` | `()` | `PomBuilder \| null` | Get underlying PomBuilder |
1552
-
1553
- ---
1554
-
1555
- ## SessionManager
1556
-
1557
- ```ts
1558
- import { SessionManager } from '@anthropic/@signalwire/sdk';
1559
- ```
1560
-
1561
- Stateless HMAC-SHA256 token manager for SWAIG function call authentication and per-session metadata storage. Tokens encode `callId.functionName.expiry.nonce.hmacSignature` in base64url format.
1562
-
1563
- ### Constructor
1564
-
1565
- ```ts
1566
- constructor(tokenExpirySecs?: number, secretKey?: string)
1567
- ```
1568
-
1569
- | Parameter | Type | Default | Description |
1570
- |-----------|------|---------|-------------|
1571
- | `tokenExpirySecs` | `number` | `3600` | Token validity in seconds |
1572
- | `secretKey` | `string` | Random 32 bytes | HMAC signing secret |
1573
-
1574
- ### Methods
1575
-
1576
- #### `createSession(callId?)`
1577
-
1578
- ```ts
1579
- createSession(callId?: string): string
1580
- ```
1581
-
1582
- Return the given callId or generate a new random session identifier.
1583
-
1584
- #### `generateToken(functionName, callId)`
1585
-
1586
- ```ts
1587
- generateToken(functionName: string, callId: string): string
1588
- ```
1589
-
1590
- Generate a signed, base64url-encoded token binding a function name to a call ID.
1591
-
1592
- #### `createToolToken(functionName, callId)`
1593
-
1594
- ```ts
1595
- createToolToken(functionName: string, callId: string): string
1596
- ```
1597
-
1598
- Alias for `generateToken()`.
1599
-
1600
- #### `validateToken(callId, functionName, token)`
1601
-
1602
- ```ts
1603
- validateToken(callId: string, functionName: string, token: string): boolean
1604
- ```
1605
-
1606
- Validate a token against the expected call ID and function name. Returns `true` if valid and not expired.
1607
-
1608
- #### `validateToolToken(functionName, token, callId)`
1609
-
1610
- ```ts
1611
- validateToolToken(functionName: string, token: string, callId: string): boolean
1612
- ```
1613
-
1614
- Alias for `validateToken()` with reordered parameters.
1615
-
1616
- #### `debugToken(token)`
1617
-
1618
- ```ts
1619
- debugToken(token: string): {
1620
- callId: string;
1621
- functionName: string;
1622
- expiry: number;
1623
- nonce: string;
1624
- signature: string;
1625
- expired: boolean;
1626
- } | null
1627
- ```
1628
-
1629
- Decode token components for debugging without validating the signature. Returns `null` if malformed.
1630
-
1631
- #### Metadata Methods
1632
-
1633
- | Method | Signature | Returns | Description |
1634
- |--------|-----------|---------|-------------|
1635
- | `getSessionMetadata` | `(sessionId: string)` | `Record<string, unknown> \| undefined` | Get session metadata |
1636
- | `setSessionMetadata` | `(sessionId, metadata)` | `void` | Merge metadata into session |
1637
- | `deleteSessionMetadata` | `(sessionId: string)` | `boolean` | Delete all session metadata |
1638
-
1639
- ---
1640
-
1641
- ## Skills
1642
-
1643
- ```ts
1644
- import { SkillBase, SkillManager, SkillRegistry } from '@anthropic/@signalwire/sdk';
1645
- ```
1646
-
1647
- ### SkillBase
1648
-
1649
- Abstract base class for agent skills. Skills are modular capabilities that provide tools, prompt sections, hints, and global data.
1650
-
1651
- #### Constructor
1652
-
1653
- ```ts
1654
- constructor(skillName: string, config?: SkillConfig)
1655
- ```
1656
-
1657
- #### Properties
1658
-
1659
- | Property | Type | Description |
1660
- |----------|------|-------------|
1661
- | `skillName` | `string` (readonly) | Registered skill type name |
1662
- | `instanceId` | `string` (readonly) | Unique instance ID (includes timestamp + random bytes) |
1663
- | `config` | `SkillConfig` (protected) | Configuration options |
1664
-
1665
- #### Abstract Methods (must be implemented)
1666
-
1667
- | Method | Signature | Returns | Description |
1668
- |--------|-----------|---------|-------------|
1669
- | `getManifest` | `()` | `SkillManifest` | Return skill metadata and requirements |
1670
- | `getTools` | `()` | `SkillToolDefinition[]` | Return SWAIG tool definitions |
1671
-
1672
- #### Overridable Methods
1673
-
1674
- | Method | Signature | Returns | Description |
1675
- |--------|-----------|---------|-------------|
1676
- | `setup` | `()` | `Promise<void>` | Initialization hook (called when added to agent) |
1677
- | `cleanup` | `()` | `Promise<void>` | Teardown hook (called when removed) |
1678
- | `getPromptSections` | `()` | `SkillPromptSection[]` | Prompt sections to inject |
1679
- | `getHints` | `()` | `string[]` | Speech recognition hints |
1680
- | `getGlobalData` | `()` | `Record<string, unknown>` | Global data to merge |
1681
-
1682
- #### Utility Methods
1683
-
1684
- | Method | Signature | Returns | Description |
1685
- |--------|-----------|---------|-------------|
1686
- | `validateEnvVars` | `()` | `string[]` | List missing required env vars |
1687
- | `isInitialized` | `()` | `boolean` | Check initialization state |
1688
- | `markInitialized` | `()` | `void` | Mark as initialized (called by SkillManager) |
1689
- | `getConfig` | `<T>(key, defaultValue?)` | `T` | Get a config value with fallback |
1690
-
1691
- ### SkillManager
1692
-
1693
- Manages the lifecycle of skills attached to an agent.
1694
-
1695
- #### Methods
1696
-
1697
- | Method | Signature | Returns | Description |
1698
- |--------|-----------|---------|-------------|
1699
- | `addSkill` | `(skill: SkillBase)` | `Promise<void>` | Add, validate, and setup a skill |
1700
- | `removeSkill` | `(instanceId: string)` | `Promise<boolean>` | Remove by instance ID |
1701
- | `removeSkillByName` | `(skillName: string)` | `Promise<number>` | Remove all instances of a skill name |
1702
- | `hasSkill` | `(skillName: string)` | `boolean` | Check if any instance with name exists |
1703
- | `getSkill` | `(instanceId: string)` | `SkillBase \| undefined` | Get by instance ID |
1704
- | `listSkills` | `()` | `{ name, instanceId, initialized }[]` | List all loaded skills |
1705
- | `getAllTools` | `()` | `SkillToolDefinition[]` | Aggregate all skill tools |
1706
- | `getAllPromptSections` | `()` | `SkillPromptSection[]` | Aggregate all prompt sections |
1707
- | `getAllHints` | `()` | `string[]` | Aggregate all hints |
1708
- | `getMergedGlobalData` | `()` | `Record<string, unknown>` | Merge all skill global data |
1709
- | `clear` | `()` | `Promise<void>` | Remove and cleanup all skills |
1710
- | `size` | (getter) | `number` | Count of loaded skills |
1711
-
1712
- ### SkillRegistry
1713
-
1714
- Global singleton registry for discovering and instantiating skills. Supports the `SIGNALWIRE_SKILL_PATHS` environment variable for custom skill directories.
1715
-
1716
- #### Static Methods
1717
-
1718
- | Method | Signature | Returns | Description |
1719
- |--------|-----------|---------|-------------|
1720
- | `getInstance` | `()` | `SkillRegistry` | Get the global singleton |
1721
- | `resetInstance` | `()` | `void` | Reset the singleton (for testing) |
1722
-
1723
- #### Instance Methods
1724
-
1725
- | Method | Signature | Returns | Description |
1726
- |--------|-----------|---------|-------------|
1727
- | `register` | `(name, factory, manifest?)` | `void` | Register a skill factory |
1728
- | `unregister` | `(name: string)` | `boolean` | Remove a registration |
1729
- | `create` | `(name, config?)` | `SkillBase \| null` | Create instance from registry |
1730
- | `has` | `(name: string)` | `boolean` | Check if name is registered |
1731
- | `getManifest` | `(name: string)` | `SkillManifest \| undefined` | Get skill manifest |
1732
- | `listRegistered` | `()` | `string[]` | List registered names |
1733
- | `listRegisteredWithManifests` | `()` | `{ name, manifest? }[]` | List with manifests |
1734
- | `addSearchPath` | `(path: string)` | `void` | Add a discovery directory |
1735
- | `getSearchPaths` | `()` | `string[]` | Get all search paths |
1736
- | `discoverFromDirectory` | `(dirPath: string)` | `Promise<string[]>` | Discover skills from a directory |
1737
- | `discoverAll` | `()` | `Promise<string[]>` | Discover from all search paths |
1738
- | `clear` | `()` | `void` | Clear all registrations |
1739
- | `size` | (getter) | `number` | Count of registered skills |
1740
-
1741
- #### SkillFactory Type
1742
-
1743
- ```ts
1744
- type SkillFactory = (config?: SkillConfig) => SkillBase;
1745
- ```
1746
-
1747
- ---
1748
-
1749
- ## Prefab Agents
1750
-
1751
- Pre-built agent templates with declarative configuration, built-in tools, and prompt sections.
1752
-
1753
- ### InfoGathererAgent
1754
-
1755
- ```ts
1756
- import { InfoGathererAgent, createInfoGathererAgent } from '@anthropic/@signalwire/sdk';
1757
- ```
1758
-
1759
- Asks the caller a sequence of questions one at a time. Supports static mode (questions provided at construction) and dynamic mode (questions resolved per request via a callback).
1760
-
1761
- #### InfoGathererConfig
1762
-
1763
- | Property | Type | Default | Description |
1764
- |----------|------|---------|-------------|
1765
- | `name` | `string` | `'info_gatherer'` | Agent display name |
1766
- | `route` | `string` | `'/info_gatherer'` | HTTP route for this agent |
1767
- | `questions` | `InfoGathererQuestion[]` | -- | Questions to ask (static mode). Omit for dynamic mode. |
1768
- | `questionCallback` | `InfoGathererQuestionCallback` | -- | Resolves questions per request (dynamic mode). |
1769
- | `agentOptions` | `Partial<AgentOptions>` | -- | Passed to `AgentBase` |
1770
-
1771
- #### InfoGathererQuestion
1772
-
1773
- | Property | Type | Description |
1774
- |----------|------|-------------|
1775
- | `key_name` | `string` | Identifier used as the key when storing the caller's answer |
1776
- | `question_text` | `string` | Question text spoken to the caller |
1777
- | `confirm` | `boolean` | When true, the agent insists on confirmation before submitting |
1778
-
1779
- **Built-in tools:** `start_questions`, `submit_answer`
1780
-
1781
- **Dynamic mode:** call `agent.setQuestionCallback(cb)` or pass `questionCallback` in the config. The callback receives `(queryParams, bodyParams, headers)` and returns the list of questions for that request. When no callback is registered, a default two-question fallback is used.
1782
-
1783
- **Factory:** `createInfoGathererAgent(config: InfoGathererConfig): InfoGathererAgent`
1784
-
1785
- ### SurveyAgent
1786
-
1787
- ```ts
1788
- import { SurveyAgent, createSurveyAgent } from '@anthropic/@signalwire/sdk';
1789
- ```
1790
-
1791
- Conducts surveys with branching logic, answer scoring, and conditional question flow.
1792
-
1793
- #### SurveyConfig
1794
-
1795
- | Property | Type | Default | Description |
1796
- |----------|------|---------|-------------|
1797
- | `name` | `string` | `'survey'` | Agent display name |
1798
- | `route` | `string` | `'/survey'` | HTTP route |
1799
- | `surveyName` | `string` | -- | Survey name used in prompts and global data (required) |
1800
- | `questions` | `SurveyQuestion[]` | -- | Ordered list of survey questions (required) |
1801
- | `introduction` | `string` | Welcome message | Opening message (also used as a non-bargeable static greeting) |
1802
- | `conclusion` | `string` | Thank-you message | Closing message |
1803
- | `brandName` | `string` | `'Our Company'` | Brand or company name the agent represents |
1804
- | `maxRetries` | `number` | `2` | Maximum retries for invalid answers |
1805
- | `onComplete` | `(responses, score) => void \| Promise<void>` | -- | Completion callback |
1806
- | `agentOptions` | `Partial<AgentOptions>` | -- | Passed to `AgentBase` |
1807
-
1808
- #### SurveyQuestion
1809
-
1810
- | Property | Type | Description |
1811
- |----------|------|-------------|
1812
- | `id` | `string` | Unique question identifier |
1813
- | `text` | `string` | Question text to ask |
1814
- | `type` | `'multiple_choice' \| 'open_ended' \| 'rating' \| 'yes_no'` | Question type |
1815
- | `options` | `string[]` | Options for `multiple_choice` |
1816
- | `scale` | `number` | For `rating`, upper bound of the 1..scale range (default `5`) |
1817
- | `required` | `boolean` | Whether the question requires an answer (default `true`) |
1818
- | `nextQuestion` | `string \| Record<string, string>` | Branching logic: fixed next or answer-based map |
1819
- | `points` | `number \| Record<string, number>` | Scoring: fixed or per-answer |
1820
-
1821
- **Built-in tools:** `validate_response`, `log_response`, `answer_question`, `get_current_question`, `get_survey_progress`
1822
-
1823
- **Factory:** `createSurveyAgent(config: SurveyConfig): SurveyAgent`
1824
-
1825
- ### FAQBotAgent
1826
-
1827
- ```ts
1828
- import { FAQBotAgent, createFAQBotAgent } from '@anthropic/@signalwire/sdk';
1829
- ```
1830
-
1831
- Answers frequently asked questions using keyword/word-overlap matching with optional escalation.
1832
-
1833
- #### FAQBotConfig
1834
-
1835
- | Property | Type | Default | Description |
1836
- |----------|------|---------|-------------|
1837
- | `name` | `string` | `'FAQBot'` | Agent display name |
1838
- | `faqs` | `FAQEntry[]` | -- | FAQ entries (required) |
1839
- | `threshold` | `number` | `0.5` | Minimum match score (0-1) |
1840
- | `escalationMessage` | `string` | Generic apology | No-match message |
1841
- | `escalationNumber` | `string` | -- | Phone number for escalation transfer |
1842
- | `agentOptions` | `Partial<AgentOptions>` | -- | Passed to `AgentBase` |
1843
-
1844
- #### FAQEntry
1845
-
1846
- | Property | Type | Description |
1847
- |----------|------|-------------|
1848
- | `question` | `string` | Representative question text |
1849
- | `answer` | `string` | Answer to provide |
1850
- | `keywords` | `string[]` | Additional matching keywords |
1851
-
1852
- **Built-in tools:** `search_faq`, `escalate` (if `escalationNumber` is set)
1853
-
1854
- **Factory:** `createFAQBotAgent(config: FAQBotConfig): FAQBotAgent`
1855
-
1856
- ### ConciergeAgent
1857
-
1858
- ```ts
1859
- import { ConciergeAgent, createConciergeAgent } from '@anthropic/@signalwire/sdk';
1860
- ```
1861
-
1862
- Virtual concierge for a venue or business. Provides information about services, amenities, hours of operation, and answers availability and directions questions.
1863
-
1864
- #### ConciergeConfig
1865
-
1866
- | Property | Type | Default | Description |
1867
- |----------|------|---------|-------------|
1868
- | `name` | `string` | `'concierge'` | Agent display name |
1869
- | `route` | `string` | `'/concierge'` | HTTP route |
1870
- | `venueName` | `string` | -- | Name of the venue or business (required) |
1871
- | `services` | `string[]` | -- | List of services offered (required) |
1872
- | `amenities` | `Record<string, Record<string, string>>` | -- | Amenities with per-amenity detail pairs (required) |
1873
- | `hoursOfOperation` | `Record<string, string>` | `{ default: '9 AM - 5 PM' }` | Hours of operation by category |
1874
- | `specialInstructions` | `string[]` | `[]` | Extra instruction bullets to append |
1875
- | `welcomeMessage` | `string` | -- | When set, installed as a non-bargeable static greeting |
1876
- | `agentOptions` | `Partial<AgentOptions>` | -- | Passed to `AgentBase` |
1877
-
1878
- **Built-in tools:** `check_availability`, `get_directions`
1879
-
1880
- **Factory:** `createConciergeAgent(config: ConciergeConfig): ConciergeAgent`
1881
-
1882
- ### ReceptionistAgent
1883
-
1884
- ```ts
1885
- import { ReceptionistAgent, createReceptionistAgent } from '@anthropic/@signalwire/sdk';
1886
- ```
1887
-
1888
- Front-desk agent that greets callers, collects basic info, and transfers them to the appropriate department.
1889
-
1890
- #### ReceptionistConfig
1891
-
1892
- | Property | Type | Default | Description |
1893
- |----------|------|---------|-------------|
1894
- | `name` | `string` | `'receptionist'` | Agent display name |
1895
- | `route` | `string` | `'/receptionist'` | HTTP route |
1896
- | `departments` | `ReceptionistDepartment[]` | -- | Departments (required) |
1897
- | `greeting` | `string` | `'Thank you for calling. How can I help you today?'` | Initial greeting |
1898
- | `voice` | `string` | `'rime.spore'` | Voice identifier passed to `addLanguage` |
1899
- | `companyName` | `string` | -- | Optional company name appended to the greeting |
1900
- | `checkInEnabled` | `boolean` | `false` | Register the optional `check_in_visitor` tool |
1901
- | `onVisitorCheckIn` | `(visitor: Record<string, string>) => void \| Promise<void>` | -- | Check-in callback |
1902
- | `agentOptions` | `Partial<AgentOptions>` | -- | Passed to `AgentBase` |
1903
-
1904
- #### ReceptionistDepartment
1905
-
1906
- | Property | Type | Description |
1907
- |----------|------|-------------|
1908
- | `name` | `string` | Department identifier |
1909
- | `description` | `string` | Description (shown to the AI) |
1910
- | `number` | `string` | Phone number or SIP address dialed on transfer |
1911
-
1912
- **Built-in tools:** `collect_caller_info`, `transfer_call`, `check_in_visitor` (when `checkInEnabled`)
1913
-
1914
- **Factory:** `createReceptionistAgent(config: ReceptionistConfig): ReceptionistAgent`
1915
-
1916
- ---
1917
-
1918
- ## Utility Classes
1919
-
1920
- ### AuthHandler
1921
-
1922
- ```ts
1923
- import { AuthHandler } from '@anthropic/@signalwire/sdk';
1924
- ```
1925
-
1926
- Multi-method authentication handler with timing-safe credential comparison. Supports Bearer token, API key, Basic auth, and custom validators.
1927
-
1928
- #### Constructor
1929
-
1930
- ```ts
1931
- constructor(config: AuthConfig)
1932
- ```
1933
-
1934
- See [AuthConfig](#authconfig).
1935
-
1936
- #### Methods
1937
-
1938
- | Method | Signature | Returns | Description |
1939
- |--------|-----------|---------|-------------|
1940
- | `validate` | `(headers: Record<string, string>)` | `Promise<boolean>` | Validate against all configured methods |
1941
- | `middleware` | `()` | Hono middleware | Create middleware rejecting with 401 |
1942
- | `hasBearerAuth` | `()` | `boolean` | Check if Bearer is configured |
1943
- | `hasApiKeyAuth` | `()` | `boolean` | Check if API key is configured |
1944
- | `hasBasicAuth` | `()` | `boolean` | Check if Basic auth is configured |
1945
-
1946
- ### ConfigLoader
1947
-
1948
- ```ts
1949
- import { ConfigLoader } from '@anthropic/@signalwire/sdk';
1950
- ```
1951
-
1952
- JSON configuration file loader with `${VAR|default}` environment variable interpolation and dot-notation access.
1953
-
1954
- #### Constructor
1955
-
1956
- ```ts
1957
- constructor(filePath?: string)
1958
- ```
1959
-
1960
- Optionally loads a JSON file immediately on construction.
1961
-
1962
- #### Static Methods
1963
-
1964
- | Method | Signature | Returns | Description |
1965
- |--------|-----------|---------|-------------|
1966
- | `search` | `(filename: string)` | `ConfigLoader \| null` | Search CWD, `./config`, `$HOME/.signalwire` |
1967
-
1968
- #### Instance Methods
1969
-
1970
- | Method | Signature | Returns | Description |
1971
- |--------|-----------|---------|-------------|
1972
- | `load` | `(filePath: string)` | `this` | Load from a JSON file with env interpolation |
1973
- | `loadFromObject` | `(obj: Record<string, unknown>)` | `this` | Load from a plain object |
1974
- | `get` | `<T>(path: string, defaultValue?: T)` | `T` | Dot-notation access (e.g., `'server.port'`) |
1975
- | `set` | `(path: string, value: unknown)` | `this` | Set a value at a dot-notation path |
1976
- | `has` | `(path: string)` | `boolean` | Check if a path exists |
1977
- | `getAll` | `()` | `Record<string, unknown>` | Shallow copy of all config |
1978
- | `getFilePath` | `()` | `string \| null` | Path of loaded config file |
1979
-
1980
- ### Logger
1981
-
1982
- ```ts
1983
- import { Logger, getLogger, setGlobalLogLevel, suppressAllLogs, setGlobalLogFormat, setGlobalLogColor, resetLoggingConfiguration } from '@anthropic/@signalwire/sdk';
1984
- ```
1985
-
1986
- Structured logger configurable via environment variables.
1987
-
1988
- #### Environment Variables
1989
-
1990
- | Variable | Values | Default | Description |
1991
- |----------|--------|---------|-------------|
1992
- | `SIGNALWIRE_LOG_LEVEL` | `debug`, `info`, `warn`, `error` | `info` | Minimum log level |
1993
- | `SIGNALWIRE_LOG_MODE` | `off` | -- | Set to `off` to suppress all logging |
1994
- | `SIGNALWIRE_LOG_FORMAT` | `text`, `json` | `text` | Output format |
1995
- | `SIGNALWIRE_LOG_COLOR` | `true`, `false` | auto (TTY) | ANSI color codes in text format |
1996
-
1997
- #### Logger Constructor
1998
-
1999
- ```ts
2000
- constructor(name: string, context?: Record<string, unknown>)
2001
- ```
2002
-
2003
- #### Logger Methods
2004
-
2005
- | Method | Signature | Returns | Description |
2006
- |--------|-----------|---------|-------------|
2007
- | `debug` | `(msg: string, data?)` | `void` | Log at debug level |
2008
- | `info` | `(msg: string, data?)` | `void` | Log at info level |
2009
- | `warn` | `(msg: string, data?)` | `void` | Log at warn level |
2010
- | `error` | `(msg: string, data?)` | `void` | Log at error level |
2011
- | `bind` | `(context: Record<string, unknown>)` | `Logger` | Create child logger with merged context |
2012
-
2013
- #### Module Functions
2014
-
2015
- | Function | Signature | Description |
2016
- |----------|-----------|-------------|
2017
- | `getLogger` | `(name: string): Logger` | Create a new Logger instance |
2018
- | `setGlobalLogLevel` | `(level: LogLevel): void` | Set minimum level for all loggers |
2019
- | `suppressAllLogs` | `(suppress?: boolean): void` | Suppress/unsuppress all output |
2020
- | `setGlobalLogFormat` | `(format: 'text' \| 'json'): void` | Set output format |
2021
- | `setGlobalLogColor` | `(enabled: boolean): void` | Enable/disable ANSI colors |
2022
- | `resetLoggingConfiguration` | `(): void` | Reset to env-var defaults |
2023
-
2024
- ### SslConfig
2025
-
2026
- ```ts
2027
- import { SslConfig } from '@anthropic/@signalwire/sdk';
2028
- ```
2029
-
2030
- SSL/TLS configuration sourced from explicit options or environment variables.
2031
-
2032
- #### Environment Variables
2033
-
2034
- | Variable | Description |
2035
- |----------|-------------|
2036
- | `SWML_SSL_ENABLED` | Set to `true` to enable SSL |
2037
- | `SWML_SSL_CERT_PATH` | Path to PEM certificate |
2038
- | `SWML_SSL_KEY_PATH` | Path to PEM private key |
2039
- | `SWML_SSL_DOMAIN` | Domain for HSTS headers |
2040
-
2041
- #### Constructor
2042
-
2043
- ```ts
2044
- constructor(opts?: SslOptions)
2045
- ```
2046
-
2047
- See [SslOptions](#ssloptions).
2048
-
2049
- #### Properties
2050
-
2051
- | Property | Type | Description |
2052
- |----------|------|-------------|
2053
- | `enabled` | `boolean` | Whether SSL is enabled |
2054
- | `certPath` | `string \| null` | PEM certificate path |
2055
- | `keyPath` | `string \| null` | PEM private key path |
2056
- | `domain` | `string \| null` | HSTS domain |
2057
- | `hsts` | `boolean` | Whether to emit HSTS headers |
2058
- | `hstsMaxAge` | `number` | HSTS max-age in seconds |
2059
-
2060
- #### Methods
2061
-
2062
- | Method | Signature | Returns | Description |
2063
- |--------|-----------|---------|-------------|
2064
- | `isConfigured` | `()` | `boolean` | Check if SSL is fully configured with valid files |
2065
- | `getCert` | `()` | `string \| null` | Read PEM certificate from disk |
2066
- | `getKey` | `()` | `string \| null` | Read PEM private key from disk |
2067
- | `getHstsHeader` | `()` | `string \| null` | Build HSTS header value |
2068
- | `getServerOptions` | `()` | `{ cert, key } \| null` | Options for `https.createServer()` |
2069
- | `hstsMiddleware` | `()` | Hono middleware | Middleware that appends HSTS header |
2070
-
2071
- ### SchemaUtils
2072
-
2073
- ```ts
2074
- import { SchemaUtils } from '@anthropic/@signalwire/sdk';
2075
- ```
2076
-
2077
- Validates SWML documents against structural rules with an LRU-style result cache.
2078
-
2079
- #### Constructor
2080
-
2081
- ```ts
2082
- constructor(opts?: { skipValidation?: boolean; maxCacheSize?: number })
2083
- ```
2084
-
2085
- | Parameter | Type | Default | Description |
2086
- |-----------|------|---------|-------------|
2087
- | `skipValidation` | `boolean` | `SWML_SKIP_SCHEMA_VALIDATION` env | Skip all validation |
2088
- | `maxCacheSize` | `number` | `100` | Maximum cached results |
2089
-
2090
- #### Methods
2091
-
2092
- | Method | Signature | Returns | Description |
2093
- |--------|-----------|---------|-------------|
2094
- | `validate` | `(swml: string \| Record<string, unknown>)` | `ValidationResult` | Validate a SWML document |
2095
- | `clearCache` | `()` | `void` | Clear the validation cache |
2096
- | `getCacheSize` | `()` | `number` | Get current cache entry count |
2097
-
2098
- ### ServerlessAdapter
2099
-
2100
- ```ts
2101
- import { ServerlessAdapter } from '@anthropic/@signalwire/sdk';
2102
- ```
2103
-
2104
- Adapts a Hono application for deployment on serverless platforms. Auto-detects platform from environment variables.
2105
-
2106
- #### Constructor
2107
-
2108
- ```ts
2109
- constructor(platform?: ServerlessPlatform)
2110
- ```
2111
-
2112
- | Parameter | Type | Default | Description |
2113
- |-----------|------|---------|-------------|
2114
- | `platform` | `ServerlessPlatform` | `'auto'` | Target platform or auto-detect |
2115
-
2116
- #### Instance Methods
2117
-
2118
- | Method | Signature | Returns | Description |
2119
- |--------|-----------|---------|-------------|
2120
- | `detectPlatform` | `()` | `ServerlessPlatform` | Detect platform from env vars |
2121
- | `getPlatform` | `()` | `ServerlessPlatform` | Get resolved platform |
2122
- | `handleRequest` | `(app, event)` | `Promise<ServerlessResponse>` | Route event through Hono app |
2123
- | `generateUrl` | `(opts?)` | `string` | Generate platform-specific invocation URL |
2124
-
2125
- #### Static Factory Methods
2126
-
2127
- | Method | Signature | Returns | Description |
2128
- |--------|-----------|---------|-------------|
2129
- | `createLambdaHandler` | `(app)` | `(event) => Promise<ServerlessResponse>` | AWS Lambda handler |
2130
- | `createGcfHandler` | `(app)` | `(req, res) => Promise<void>` | Google Cloud Functions handler |
2131
- | `createAzureHandler` | `(app)` | `(context, req) => Promise<void>` | Azure Functions handler |
2132
-
2133
- **Example (AWS Lambda):**
2134
- ```ts
2135
- const agent = new AgentBase({ name: 'MyAgent' });
2136
- export const handler = ServerlessAdapter.createLambdaHandler(agent.getApp());
2137
- ```
2138
-
2139
- ---
2140
-
2141
- ## Types and Interfaces
2142
-
2143
- ### AgentOptions
2144
-
2145
- ```ts
2146
- interface AgentOptions
2147
- ```
2148
-
2149
- Configuration options for constructing an AgentBase instance.
2150
-
2151
- | Property | Type | Default | Description |
2152
- |----------|------|---------|-------------|
2153
- | `name` | `string` | -- | Display name (required); also used as default basic-auth username |
2154
- | `route` | `string` | `'/'` | HTTP route path |
2155
- | `host` | `string` | `'0.0.0.0'` | Hostname to bind |
2156
- | `port` | `number` | `PORT` env or `3000` | Port number |
2157
- | `basicAuth` | `[string, string]` | Auto-generated | Explicit `[username, password]` credentials |
2158
- | `usePom` | `boolean` | `true` | Use POM-based prompt rendering |
2159
- | `tokenExpirySecs` | `number` | `3600` | Session token expiry in seconds |
2160
- | `autoAnswer` | `boolean` | `true` | Insert an "answer" verb in SWML |
2161
- | `recordCall` | `boolean` | `false` | Record the call |
2162
- | `recordFormat` | `string` | `'mp4'` | Recording format |
2163
- | `recordStereo` | `boolean` | `true` | Stereo recording |
2164
- | `defaultWebhookUrl` | `string` | -- | Default SWAIG webhook URL |
2165
- | `nativeFunctions` | `string[]` | `[]` | Native function names |
2166
- | `agentId` | `string` | Random hex | Unique agent instance ID |
2167
- | `suppressLogs` | `boolean` | `false` | Suppress all log output |
2168
-
2169
- ### LanguageConfig
2170
-
2171
- ```ts
2172
- interface LanguageConfig
2173
- ```
2174
-
2175
- | Property | Type | Description |
2176
- |----------|------|-------------|
2177
- | `name` | `string` | Human-readable name (e.g., `"English"`) |
2178
- | `code` | `string` | BCP-47 code (e.g., `"en-US"`) |
2179
- | `voice` | `string` | Voice identifier |
2180
- | `engine` | `string` | TTS engine identifier |
2181
- | `fillers` | `Record<string, string[]>` | Filler phrases by category |
2182
- | `speechModel` | `string` | Speech recognition model |
2183
- | `functionFillers` | `Record<string, Record<string, string[]>>` | Per-function fillers by language |
2184
-
2185
- ### PronunciationRule
2186
-
2187
- ```ts
2188
- interface PronunciationRule
2189
- ```
2190
-
2191
- | Property | Type | Description |
2192
- |----------|------|-------------|
2193
- | `replace` | `string` | Text pattern to match |
2194
- | `with` | `string` | Replacement pronunciation |
2195
- | `ignoreCase` | `boolean` | Case-insensitive matching |
2196
-
2197
- ### FunctionInclude
2198
-
2199
- ```ts
2200
- interface FunctionInclude
2201
- ```
2202
-
2203
- | Property | Type | Description |
2204
- |----------|------|-------------|
2205
- | `url` | `string` | URL of the remote SWAIG endpoint |
2206
- | `functions` | `string[]` | Function names at the endpoint |
2207
- | `meta_data` | `Record<string, unknown>` | Optional metadata |
2208
-
2209
- ### DynamicConfigCallback
2210
-
2211
- ```ts
2212
- type DynamicConfigCallback = (
2213
- queryParams: Record<string, string>,
2214
- bodyParams: Record<string, unknown>,
2215
- headers: Record<string, string>,
2216
- agent: unknown, // Ephemeral AgentBase copy
2217
- ) => void | Promise<void>;
2218
- ```
2219
-
2220
- Callback invoked on each SWML request to dynamically modify an ephemeral copy of the agent. The original agent is never mutated.
2221
-
2222
- ### SummaryCallback
2223
-
2224
- ```ts
2225
- type SummaryCallback = (
2226
- summary: Record<string, unknown> | null,
2227
- rawData: Record<string, unknown>,
2228
- ) => void | Promise<void>;
2229
- ```
2230
-
2231
- Callback invoked when a post-prompt summary is received.
2232
-
2233
- ### SwaigHandler
2234
-
2235
- ```ts
2236
- type SwaigHandler = (
2237
- args: Record<string, unknown>,
2238
- rawData: Record<string, unknown>,
2239
- ) => FunctionResult | Record<string, unknown> | string | Promise<FunctionResult | Record<string, unknown> | string>;
2240
- ```
2241
-
2242
- Handler function for a SWAIG tool invocation. Can return:
2243
- - A `FunctionResult` instance
2244
- - A plain object with a `response` key
2245
- - A plain string (wrapped into a FunctionResult)
2246
- - A `Promise` of any of the above
2247
-
2248
- ### SwaigFunctionOptions
2249
-
2250
- ```ts
2251
- interface SwaigFunctionOptions
2252
- ```
2253
-
2254
- | Property | Type | Default | Description |
2255
- |----------|------|---------|-------------|
2256
- | `name` | `string` | -- | Unique tool name (required) |
2257
- | `handler` | `SwaigHandler` | -- | Handler function (required) |
2258
- | `description` | `string` | -- | Description shown to AI (required) |
2259
- | `parameters` | `Record<string, unknown>` | `{}` | JSON Schema parameter properties |
2260
- | `secure` | `boolean` | `false` | Require session token auth |
2261
- | `fillers` | `Record<string, string[]>` | -- | Language-keyed filler phrases |
2262
- | `waitFile` | `string` | -- | Audio file URL for waiting |
2263
- | `waitFileLoops` | `number` | -- | Wait file loop count |
2264
- | `webhookUrl` | `string` | -- | External webhook URL |
2265
- | `required` | `string[]` | `[]` | Required parameter names |
2266
- | `extraFields` | `Record<string, unknown>` | `{}` | Additional SWAIG definition fields |
2267
-
2268
- ### AuthConfig
2269
-
2270
- ```ts
2271
- interface AuthConfig
2272
- ```
2273
-
2274
- | Property | Type | Description |
2275
- |----------|------|-------------|
2276
- | `bearerToken` | `string` | Bearer token for Authorization header |
2277
- | `apiKey` | `string` | API key for X-Api-Key header |
2278
- | `basicAuth` | `[string, string]` | Basic auth `[username, password]` |
2279
- | `customValidator` | `(request: { headers, method, url }) => boolean \| Promise<boolean>` | Custom validation function |
2280
-
2281
- ### SslOptions
2282
-
2283
- ```ts
2284
- interface SslOptions
2285
- ```
2286
-
2287
- | Property | Type | Default | Description |
2288
- |----------|------|---------|-------------|
2289
- | `enabled` | `boolean` | `SWML_SSL_ENABLED` env | Whether SSL is enabled |
2290
- | `certPath` | `string` | `SWML_SSL_CERT_PATH` env | Path to PEM certificate |
2291
- | `keyPath` | `string` | `SWML_SSL_KEY_PATH` env | Path to PEM private key |
2292
- | `domain` | `string` | `SWML_SSL_DOMAIN` env | Domain for HSTS |
2293
- | `hsts` | `boolean` | `true` | Send HSTS headers |
2294
- | `hstsMaxAge` | `number` | `31536000` | HSTS max-age in seconds |
2295
-
2296
- ### ValidationResult
2297
-
2298
- ```ts
2299
- interface ValidationResult
2300
- ```
2301
-
2302
- | Property | Type | Description |
2303
- |----------|------|-------------|
2304
- | `valid` | `boolean` | Whether the document passed validation |
2305
- | `errors` | `string[]` | Human-readable error messages (empty when valid) |
2306
-
2307
- ### ServerlessEvent
2308
-
2309
- ```ts
2310
- interface ServerlessEvent
2311
- ```
2312
-
2313
- Normalized incoming event from a serverless platform.
2314
-
2315
- | Property | Type | Description |
2316
- |----------|------|-------------|
2317
- | `httpMethod` | `string` | HTTP method (AWS Lambda style) |
2318
- | `method` | `string` | HTTP method (GCF/Azure style) |
2319
- | `headers` | `Record<string, string>` | Request headers |
2320
- | `body` | `string \| Record<string, unknown>` | Request body |
2321
- | `path` | `string` | Request path |
2322
- | `rawPath` | `string` | Raw request path (API Gateway v2) |
2323
- | `queryStringParameters` | `Record<string, string>` | Query parameters |
2324
- | `requestContext` | `Record<string, unknown>` | Platform-specific context |
2325
-
2326
- ### ServerlessResponse
2327
-
2328
- ```ts
2329
- interface ServerlessResponse
2330
- ```
2331
-
2332
- | Property | Type | Description |
2333
- |----------|------|-------------|
2334
- | `statusCode` | `number` | HTTP status code |
2335
- | `headers` | `Record<string, string>` | Response headers |
2336
- | `body` | `string` | Response body |
2337
-
2338
- ### PomSectionData
2339
-
2340
- ```ts
2341
- interface PomSectionData
2342
- ```
2343
-
2344
- Serializable representation of a POM section for JSON export.
2345
-
2346
- | Property | Type | Description |
2347
- |----------|------|-------------|
2348
- | `title` | `string` | Section heading |
2349
- | `body` | `string` | Body text |
2350
- | `bullets` | `string[]` | Bullet points |
2351
- | `numbered` | `boolean` | Whether subsections are numbered |
2352
- | `numberedBullets` | `boolean` | Whether bullets are rendered as a numbered list |
2353
- | `subsections` | `PomSectionData[]` | Nested child sections |
2354
-
2355
- ### Skill Types
2356
-
2357
- #### SkillConfig
2358
-
2359
- ```ts
2360
- interface SkillConfig { [key: string]: unknown }
2361
- ```
2362
-
2363
- #### SkillToolDefinition
2364
-
2365
- | Property | Type | Description |
2366
- |----------|------|-------------|
2367
- | `name` | `string` | Unique tool name |
2368
- | `description` | `string` | Description shown to AI |
2369
- | `parameters` | `Record<string, unknown>` | Parameter schema |
2370
- | `handler` | `SwaigHandler` | Handler function |
2371
- | `secure` | `boolean` | Require secure invocation |
2372
- | `fillers` | `Record<string, string[]>` | Filler phrases by language |
2373
- | `required` | `string[]` | Required parameter names |
2374
-
2375
- #### SkillPromptSection
2376
-
2377
- | Property | Type | Description |
2378
- |----------|------|-------------|
2379
- | `title` | `string` | Section heading |
2380
- | `body` | `string` | Body text |
2381
- | `bullets` | `string[]` | Bullet points |
2382
- | `numbered` | `boolean` | Render bullets as numbered list |
2383
-
2384
- #### SkillManifest
2385
-
2386
- | Property | Type | Description |
2387
- |----------|------|-------------|
2388
- | `name` | `string` | Unique skill name |
2389
- | `description` | `string` | Human-readable description |
2390
- | `version` | `string` | Semantic version |
2391
- | `author` | `string` | Author or organization |
2392
- | `tags` | `string[]` | Categorization tags |
2393
- | `requiredEnvVars` | `string[]` | Required environment variables |
2394
- | `requiredPackages` | `string[]` | Required npm packages |
2395
- | `configSchema` | `Record<string, unknown>` | JSON-schema config description |
2396
-
2397
- ### Payment Types
2398
-
2399
- #### PaymentPrompt
2400
-
2401
- | Property | Type | Description |
2402
- |----------|------|-------------|
2403
- | `for` | `string` | Situation this prompt applies to |
2404
- | `actions` | `PaymentAction[]` | Actions for this prompt |
2405
- | `card_type` | `string` | Optional card type filter |
2406
- | `error_type` | `string` | Optional error type |
2407
-
2408
- #### PaymentAction
2409
-
2410
- | Property | Type | Description |
2411
- |----------|------|-------------|
2412
- | `type` | `string` | Action type (e.g., `"say"`, `"play"`) |
2413
- | `phrase` | `string` | Phrase or URL |
2414
-
2415
- #### PaymentParameter
2416
-
2417
- | Property | Type | Description |
2418
- |----------|------|-------------|
2419
- | `name` | `string` | Parameter name |
2420
- | `value` | `string` | Parameter value |