@signalwire/sdk 2.0.0 → 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 (612) 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/dist/index.d.ts +146 -0
  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/{src/rest/index.ts → dist/rest/index.d.ts} +53 -122
  149. package/dist/rest/index.js +195 -0
  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/dist/rest/pagination.d.ts +39 -0
  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 -2489
  416. package/src/AgentServer.ts +0 -415
  417. package/src/AuthHandler.ts +0 -256
  418. package/src/ConfigLoader.ts +0 -447
  419. package/src/ContextBuilder.ts +0 -1150
  420. package/src/DataMap.ts +0 -449
  421. package/src/FunctionResult.ts +0 -866
  422. package/src/Logger.ts +0 -337
  423. package/src/PomBuilder.ts +0 -439
  424. package/src/PromptManager.ts +0 -133
  425. package/src/SWMLHandler.ts +0 -298
  426. package/src/SWMLService.ts +0 -717
  427. package/src/SchemaUtils.ts +0 -361
  428. package/src/ServerlessAdapter.ts +0 -221
  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 -258
  433. package/src/SwmlVerbMethods.generated.ts +0 -234
  434. package/src/TypeInference.ts +0 -181
  435. package/src/WebService.ts +0 -619
  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/index.ts +0 -167
  441. package/src/livewire/index.ts +0 -950
  442. package/src/prefabs/ConciergeAgent.ts +0 -287
  443. package/src/prefabs/FAQBotAgent.ts +0 -384
  444. package/src/prefabs/InfoGathererAgent.ts +0 -339
  445. package/src/prefabs/ReceptionistAgent.ts +0 -366
  446. package/src/prefabs/SurveyAgent.ts +0 -646
  447. package/src/relay/Action.ts +0 -314
  448. package/src/relay/Call.ts +0 -854
  449. package/src/relay/Deferred.ts +0 -71
  450. package/src/relay/Message.ts +0 -148
  451. package/src/relay/RelayClient.ts +0 -1036
  452. package/src/relay/RelayError.ts +0 -14
  453. package/src/relay/RelayEvent.ts +0 -892
  454. package/src/relay/index.ts +0 -123
  455. package/src/relay/types.ts +0 -149
  456. package/src/rest/HttpClient.ts +0 -103
  457. package/src/rest/RestError.ts +0 -31
  458. package/src/rest/base/BaseResource.ts +0 -19
  459. package/src/rest/base/CrudResource.ts +0 -51
  460. package/src/rest/base/CrudWithAddresses.ts +0 -26
  461. package/src/rest/namespaces/addresses.ts +0 -32
  462. package/src/rest/namespaces/calling.ts +0 -187
  463. package/src/rest/namespaces/chat.ts +0 -20
  464. package/src/rest/namespaces/compat.ts +0 -352
  465. package/src/rest/namespaces/datasphere.ts +0 -45
  466. package/src/rest/namespaces/fabric.ts +0 -222
  467. package/src/rest/namespaces/imported-numbers.ts +0 -20
  468. package/src/rest/namespaces/logs.ts +0 -84
  469. package/src/rest/namespaces/lookup.ts +0 -21
  470. package/src/rest/namespaces/mfa.ts +0 -30
  471. package/src/rest/namespaces/number-groups.ts +0 -38
  472. package/src/rest/namespaces/phone-numbers.ts +0 -44
  473. package/src/rest/namespaces/project.ts +0 -36
  474. package/src/rest/namespaces/pubsub.ts +0 -20
  475. package/src/rest/namespaces/queues.ts +0 -33
  476. package/src/rest/namespaces/recordings.ts +0 -28
  477. package/src/rest/namespaces/registry.ts +0 -101
  478. package/src/rest/namespaces/short-codes.ts +0 -28
  479. package/src/rest/namespaces/sip-profile.ts +0 -25
  480. package/src/rest/namespaces/verified-callers.ts +0 -27
  481. package/src/rest/namespaces/video.ts +0 -165
  482. package/src/rest/pagination.ts +0 -84
  483. package/src/rest/types.ts +0 -61
  484. package/src/skills/SkillBase.ts +0 -547
  485. package/src/skills/SkillManager.ts +0 -415
  486. package/src/skills/SkillRegistry.ts +0 -367
  487. package/src/skills/builtin/api_ninjas_trivia.ts +0 -280
  488. package/src/skills/builtin/ask_claude.ts +0 -241
  489. package/src/skills/builtin/claude_skills.ts +0 -978
  490. package/src/skills/builtin/custom_skills.ts +0 -312
  491. package/src/skills/builtin/datasphere.ts +0 -438
  492. package/src/skills/builtin/datasphere_serverless.ts +0 -339
  493. package/src/skills/builtin/datetime.ts +0 -130
  494. package/src/skills/builtin/google_maps.ts +0 -651
  495. package/src/skills/builtin/info_gatherer.ts +0 -405
  496. package/src/skills/builtin/joke.ts +0 -191
  497. package/src/skills/builtin/math.ts +0 -142
  498. package/src/skills/builtin/mcp_gateway.ts +0 -677
  499. package/src/skills/builtin/native_vector_search.ts +0 -901
  500. package/src/skills/builtin/play_background_file.ts +0 -358
  501. package/src/skills/builtin/spider.ts +0 -869
  502. package/src/skills/builtin/swml_transfer.ts +0 -635
  503. package/src/skills/builtin/weather_api.ts +0 -248
  504. package/src/skills/builtin/web_search.ts +0 -1074
  505. package/src/skills/builtin/wikipedia_search.ts +0 -299
  506. package/src/types.ts +0 -132
  507. package/tests/AgentBase.test.ts +0 -1093
  508. package/tests/AgentServer.test.ts +0 -126
  509. package/tests/AuthHandler.test.ts +0 -133
  510. package/tests/ConfigLoader.test.ts +0 -151
  511. package/tests/ContextBuilder.test.ts +0 -108
  512. package/tests/DataMap.test.ts +0 -367
  513. package/tests/EphemeralSkillCopy.test.ts +0 -107
  514. package/tests/FunctionResult.test.ts +0 -298
  515. package/tests/GracefulShutdown.test.ts +0 -46
  516. package/tests/Logger.test.ts +0 -420
  517. package/tests/PomBuilder.test.ts +0 -228
  518. package/tests/ProxyDetection.test.ts +0 -228
  519. package/tests/SWMLService.test.ts +0 -320
  520. package/tests/SWMLVerbHandler.test.ts +0 -523
  521. package/tests/SchemaUtils.test.ts +0 -106
  522. package/tests/SchemaUtils.verb.test.ts +0 -206
  523. package/tests/SecurityUtils.test.ts +0 -192
  524. package/tests/ServerlessAdapter.test.ts +0 -222
  525. package/tests/SessionManager.test.ts +0 -257
  526. package/tests/SkillBaseFeatures.test.ts +0 -130
  527. package/tests/SkillMultiInstance.test.ts +0 -102
  528. package/tests/SkillParameterSchemas.test.ts +0 -134
  529. package/tests/SkillRegistrySchema.test.ts +0 -84
  530. package/tests/SslConfig.test.ts +0 -97
  531. package/tests/SwmlBuilder.test.ts +0 -400
  532. package/tests/TypeInference.test.ts +0 -165
  533. package/tests/VerbHandlerRegistry.test.ts +0 -128
  534. package/tests/cli/mock-data.test.ts +0 -113
  535. package/tests/cli/swaig-test.test.ts +0 -108
  536. package/tests/examples.test.ts +0 -194
  537. package/tests/fixtures/scrape-parity/README.md +0 -53
  538. package/tests/fixtures/scrape-parity/expected/01_simple_article.json +0 -5
  539. package/tests/fixtures/scrape-parity/expected/02_class_based_noise.json +0 -5
  540. package/tests/fixtures/scrape-parity/expected/03_nested_containers.json +0 -5
  541. package/tests/fixtures/scrape-parity/expected/04_bare_body.json +0 -5
  542. package/tests/fixtures/scrape-parity/expected/05_malformed.json +0 -5
  543. package/tests/fixtures/scrape-parity/expected/06_multi_class.json +0 -5
  544. package/tests/fixtures/scrape-parity/expected/07_anchor_pattern.json +0 -5
  545. package/tests/fixtures/scrape-parity/expected/08_inline_script.json +0 -5
  546. package/tests/fixtures/scrape-parity/expected/09_whitespace_nbsp.json +0 -5
  547. package/tests/fixtures/scrape-parity/expected/10_entity_unicode.json +0 -5
  548. package/tests/fixtures/scrape-parity/expected/11_cdata_comments.json +0 -5
  549. package/tests/fixtures/scrape-parity/expected/12_deep_nested_removals.json +0 -5
  550. package/tests/fixtures/scrape-parity/html/01_simple_article.html +0 -18
  551. package/tests/fixtures/scrape-parity/html/02_class_based_noise.html +0 -18
  552. package/tests/fixtures/scrape-parity/html/03_nested_containers.html +0 -13
  553. package/tests/fixtures/scrape-parity/html/04_bare_body.html +0 -9
  554. package/tests/fixtures/scrape-parity/html/05_malformed.html +0 -11
  555. package/tests/fixtures/scrape-parity/html/06_multi_class.html +0 -18
  556. package/tests/fixtures/scrape-parity/html/07_anchor_pattern.html +0 -12
  557. package/tests/fixtures/scrape-parity/html/08_inline_script.html +0 -17
  558. package/tests/fixtures/scrape-parity/html/09_whitespace_nbsp.html +0 -21
  559. package/tests/fixtures/scrape-parity/html/10_entity_unicode.html +0 -10
  560. package/tests/fixtures/scrape-parity/html/11_cdata_comments.html +0 -13
  561. package/tests/fixtures/scrape-parity/html/12_deep_nested_removals.html +0 -24
  562. package/tests/fixtures/scrape-parity/python_extract.py +0 -109
  563. package/tests/livewire/livewire.test.ts +0 -780
  564. package/tests/mcp.test.ts +0 -221
  565. package/tests/prefabs/prefabs.test.ts +0 -1093
  566. package/tests/relay/Action.test.ts +0 -392
  567. package/tests/relay/Call.test.ts +0 -535
  568. package/tests/relay/Deferred.test.ts +0 -71
  569. package/tests/relay/Message.test.ts +0 -164
  570. package/tests/relay/RelayClient.test.ts +0 -779
  571. package/tests/relay/RelayEvent.test.ts +0 -463
  572. package/tests/relay/helpers.ts +0 -79
  573. package/tests/rest/HttpClient.test.ts +0 -274
  574. package/tests/rest/RestError.test.ts +0 -53
  575. package/tests/rest/calling.test.ts +0 -156
  576. package/tests/rest/client.test.ts +0 -197
  577. package/tests/rest/compat.test.ts +0 -335
  578. package/tests/rest/datasphere.test.ts +0 -71
  579. package/tests/rest/fabric.test.ts +0 -186
  580. package/tests/rest/helpers.ts +0 -95
  581. package/tests/rest/logs.test.ts +0 -68
  582. package/tests/rest/pagination.test.ts +0 -133
  583. package/tests/rest/registry.test.ts +0 -94
  584. package/tests/rest/relay-rest.test.ts +0 -290
  585. package/tests/rest/video.test.ts +0 -173
  586. package/tests/setup.ts +0 -6
  587. package/tests/skills/SkillBase.test.ts +0 -108
  588. package/tests/skills/SkillManager.test.ts +0 -268
  589. package/tests/skills/SkillRegistry.test.ts +0 -176
  590. package/tests/skills/builtin.test.ts +0 -1472
  591. package/tests/skills/claude-skills.test.ts +0 -54
  592. package/tests/skills/custom-skills.test.ts +0 -53
  593. package/tests/skills/datasphere-serverless.test.ts +0 -70
  594. package/tests/skills/datasphere.test.ts +0 -107
  595. package/tests/skills/datetime.test.ts +0 -101
  596. package/tests/skills/google-maps.test.ts +0 -78
  597. package/tests/skills/info-gatherer.test.ts +0 -411
  598. package/tests/skills/joke.test.ts +0 -81
  599. package/tests/skills/math.test.ts +0 -68
  600. package/tests/skills/mcp-gateway.test.ts +0 -101
  601. package/tests/skills/play-background.test.ts +0 -54
  602. package/tests/skills/spider.test.ts +0 -108
  603. package/tests/skills/swml-transfer.test.ts +0 -178
  604. package/tests/skills/trivia.test.ts +0 -54
  605. package/tests/skills/vector-search.test.ts +0 -135
  606. package/tests/skills/weather-api.test.ts +0 -77
  607. package/tests/skills/web-search-parity.test.ts +0 -59
  608. package/tests/skills/web-search.test.ts +0 -103
  609. package/tests/skills/wikipedia.test.ts +0 -63
  610. package/tsconfig.json +0 -18
  611. package/vitest.config.ts +0 -9
  612. /package/{src → dist}/schema.json +0 -0
@@ -1,1472 +0,0 @@
1
- /**
2
- * Comprehensive tests for all 19 built-in skills.
3
- *
4
- * Covers instantiation, manifest, tools, prompt sections, and handler execution
5
- * for each skill. API-dependent skills verify error messages when keys are missing.
6
- */
7
-
8
- import { describe, it, expect, beforeAll, afterAll } from 'vitest';
9
- import { mkdtempSync, writeFileSync, mkdirSync, rmSync } from 'node:fs';
10
- import { join } from 'node:path';
11
- import { tmpdir } from 'node:os';
12
- import {
13
- DateTimeSkill,
14
- createDateTimeSkill,
15
- MathSkill,
16
- createMathSkill,
17
- JokeSkill,
18
- createJokeSkill,
19
- WeatherApiSkill,
20
- createWeatherApiSkill,
21
- PlayBackgroundFileSkill,
22
- createPlayBackgroundFileSkill,
23
- SwmlTransferSkill,
24
- createSwmlTransferSkill,
25
- ApiNinjasTriviaSkill,
26
- createApiNinjasTriviaSkill,
27
- InfoGathererSkill,
28
- createInfoGathererSkill,
29
- CustomSkillsSkill,
30
- createCustomSkillsSkill,
31
- WebSearchSkill,
32
- createWebSearchSkill,
33
- WikipediaSearchSkill,
34
- createWikipediaSearchSkill,
35
- GoogleMapsSkill,
36
- createGoogleMapsSkill,
37
- DataSphereSkill,
38
- createDataSphereSkill,
39
- DataSphereServerlessSkill,
40
- createDataSphereServerlessSkill,
41
- NativeVectorSearchSkill,
42
- createNativeVectorSearchSkill,
43
- SpiderSkill,
44
- createSpiderSkill,
45
- ClaudeSkillsSkill,
46
- createClaudeSkillsSkill,
47
- AskClaudeSkill,
48
- createAskClaudeSkill,
49
- McpGatewaySkill,
50
- createMcpGatewaySkill,
51
- } from '../../src/skills/builtin/index.js';
52
- import { SkillBase } from '../../src/skills/SkillBase.js';
53
- import { FunctionResult } from '../../src/FunctionResult.js';
54
- import { suppressAllLogs } from '../../src/Logger.js';
55
-
56
- beforeAll(() => {
57
- suppressAllLogs(true);
58
- });
59
-
60
- // ---------------------------------------------------------------------------
61
- // DateTime Skill
62
- // ---------------------------------------------------------------------------
63
- describe('DateTimeSkill', () => {
64
- it('should instantiate via createSkill factory', () => {
65
- const skill = createDateTimeSkill();
66
- expect(skill).toBeInstanceOf(DateTimeSkill);
67
- expect(skill).toBeInstanceOf(SkillBase);
68
- });
69
-
70
- it('should return correct manifest name and version', () => {
71
- const skill = createDateTimeSkill();
72
- const klass = skill.constructor as typeof SkillBase;
73
- expect(klass.SKILL_NAME).toBe('datetime');
74
- expect(klass.SKILL_VERSION).toBe('1.0.0');
75
- expect(klass.SKILL_DESCRIPTION).toBeTruthy();
76
- });
77
-
78
- it('should return get_current_time and get_current_date tools', () => {
79
- const skill = createDateTimeSkill();
80
- const tools = skill.getTools();
81
- expect(tools).toHaveLength(2);
82
- const names = tools.map((t) => t.name);
83
- expect(names).toContain('get_current_time');
84
- expect(names).toContain('get_current_date');
85
- for (const tool of tools) {
86
- expect(tool.handler).toBeTypeOf('function');
87
- }
88
- });
89
-
90
- it('should return non-empty prompt sections', () => {
91
- const skill = createDateTimeSkill();
92
- const sections = skill.getPromptSections();
93
- expect(sections.length).toBeGreaterThan(0);
94
- expect(sections[0].title).toBe('Date and Time Information');
95
- expect(sections[0].bullets).toBeDefined();
96
- expect(sections[0].bullets!.length).toBeGreaterThan(0);
97
- });
98
-
99
- it('should execute handlers and return time/date for a timezone', () => {
100
- const skill = createDateTimeSkill();
101
- const timeTool = skill.getTools().find((t) => t.name === 'get_current_time')!;
102
- const dateTool = skill.getTools().find((t) => t.name === 'get_current_date')!;
103
-
104
- const timeResult = timeTool.handler({ timezone: 'America/New_York' }, {}) as FunctionResult;
105
- expect(timeResult).toBeInstanceOf(FunctionResult);
106
- expect(timeResult.response).toContain('current time');
107
-
108
- const dateResult = dateTool.handler({ timezone: 'America/New_York' }, {}) as FunctionResult;
109
- expect(dateResult).toBeInstanceOf(FunctionResult);
110
- expect(dateResult.response).toContain("Today's date");
111
- });
112
- });
113
-
114
- // ---------------------------------------------------------------------------
115
- // Math Skill
116
- // ---------------------------------------------------------------------------
117
- describe('MathSkill', () => {
118
- it('should instantiate via createSkill factory', () => {
119
- const skill = createMathSkill();
120
- expect(skill).toBeInstanceOf(MathSkill);
121
- expect(skill).toBeInstanceOf(SkillBase);
122
- });
123
-
124
- it('should return correct manifest name and version', () => {
125
- const skill = createMathSkill();
126
- const klass = skill.constructor as typeof SkillBase;
127
- expect(klass.SKILL_NAME).toBe('math');
128
- expect(klass.SKILL_VERSION).toBe('1.0.0');
129
- });
130
-
131
- it('should return a calculate tool', () => {
132
- const skill = createMathSkill();
133
- const tools = skill.getTools();
134
- expect(tools).toHaveLength(1);
135
- expect(tools[0].name).toBe('calculate');
136
- expect(tools[0].required).toContain('expression');
137
- });
138
-
139
- it('should return non-empty prompt sections', () => {
140
- const skill = createMathSkill();
141
- const sections = skill.getPromptSections();
142
- expect(sections.length).toBeGreaterThan(0);
143
- expect(sections[0].title).toBe('Mathematical Calculations');
144
- expect(sections[0].bullets).toBeDefined();
145
- expect(sections[0].bullets!.length).toBeGreaterThan(0);
146
- });
147
-
148
- it('should evaluate basic math expressions correctly', () => {
149
- const skill = createMathSkill();
150
- const handler = skill.getTools()[0].handler;
151
- const result = handler({ expression: '2 + 3 * 4' }, {}) as FunctionResult;
152
- expect(result).toBeInstanceOf(FunctionResult);
153
- expect(result.response).toContain('14');
154
- });
155
-
156
- it('should reject unsafe expressions', () => {
157
- const skill = createMathSkill();
158
- const handler = skill.getTools()[0].handler;
159
- const result = handler({ expression: 'process.exit(1)' }, {}) as FunctionResult;
160
- expect(result).toBeInstanceOf(FunctionResult);
161
- expect(result.response).toContain('Could not evaluate');
162
- // Must not leak internal error details
163
- expect(result.response).not.toContain('isSafeExpression');
164
- });
165
- });
166
-
167
- // ---------------------------------------------------------------------------
168
- // Joke Skill
169
- // ---------------------------------------------------------------------------
170
- describe('JokeSkill', () => {
171
- it('should instantiate via createSkill factory', () => {
172
- const skill = createJokeSkill();
173
- expect(skill).toBeInstanceOf(JokeSkill);
174
- expect(skill).toBeInstanceOf(SkillBase);
175
- });
176
-
177
- it('should return correct manifest name and version', () => {
178
- const skill = createJokeSkill();
179
- const klass = skill.constructor as typeof SkillBase;
180
- expect(klass.SKILL_NAME).toBe('joke');
181
- expect(klass.SKILL_VERSION).toBe('1.0.0');
182
- });
183
-
184
- it('should return a tell_joke tool', () => {
185
- const skill = createJokeSkill();
186
- const tools = skill.getTools();
187
- expect(tools).toHaveLength(1);
188
- expect(tools[0].name).toBe('tell_joke');
189
- });
190
-
191
- it('should return non-empty prompt sections', () => {
192
- const skill = createJokeSkill();
193
- const sections = skill.getPromptSections();
194
- expect(sections.length).toBeGreaterThan(0);
195
- expect(sections[0].title).toBe('Jokes');
196
- expect(sections[0].bullets).toBeDefined();
197
- });
198
-
199
- it('should execute handler and return a joke', () => {
200
- const skill = createJokeSkill();
201
- const handler = skill.getTools()[0].handler;
202
- const result = handler({}, {}) as FunctionResult;
203
- expect(result).toBeInstanceOf(FunctionResult);
204
- // Jokes contain " ... " between setup and punchline
205
- expect(result.response).toContain('...');
206
- });
207
- });
208
-
209
- // ---------------------------------------------------------------------------
210
- // Weather API Skill
211
- // ---------------------------------------------------------------------------
212
- describe('WeatherApiSkill', () => {
213
- it('should instantiate via createSkill factory', () => {
214
- const skill = createWeatherApiSkill();
215
- expect(skill).toBeInstanceOf(WeatherApiSkill);
216
- expect(skill).toBeInstanceOf(SkillBase);
217
- });
218
-
219
- it('should return correct manifest name and version', () => {
220
- const skill = createWeatherApiSkill();
221
- const klass = skill.constructor as typeof SkillBase;
222
- expect(klass.SKILL_NAME).toBe('weather_api');
223
- expect(klass.SKILL_VERSION).toBe('1.0.0');
224
- expect(klass.REQUIRED_ENV_VARS).toContain('WEATHER_API_KEY');
225
- });
226
-
227
- it('should return a get_weather tool', () => {
228
- const skill = createWeatherApiSkill();
229
- const tools = skill.getTools();
230
- expect(tools).toHaveLength(1);
231
- expect(tools[0].name).toBe('get_weather');
232
- expect(tools[0].required).toContain('location');
233
- });
234
-
235
- it('should report missing env var via validateEnvVars', () => {
236
- const originalKey = process.env['WEATHER_API_KEY'];
237
- delete process.env['WEATHER_API_KEY'];
238
- const skill = createWeatherApiSkill();
239
- const missing = skill.validateEnvVars();
240
- expect(missing).toContain('WEATHER_API_KEY');
241
- if (originalKey !== undefined) process.env['WEATHER_API_KEY'] = originalKey;
242
- });
243
-
244
- it('should return error when API key is not set', async () => {
245
- const originalKey = process.env['WEATHER_API_KEY'];
246
- delete process.env['WEATHER_API_KEY'];
247
- const skill = createWeatherApiSkill();
248
- const handler = skill.getTools()[0].handler;
249
- const result = await handler({ location: 'London' }, {}) as FunctionResult;
250
- expect(result).toBeInstanceOf(FunctionResult);
251
- expect(result.response).toContain('not configured');
252
- if (originalKey !== undefined) process.env['WEATHER_API_KEY'] = originalKey;
253
- });
254
- });
255
-
256
- // ---------------------------------------------------------------------------
257
- // Play Background File Skill
258
- // ---------------------------------------------------------------------------
259
- describe('PlayBackgroundFileSkill', () => {
260
- it('should instantiate via createSkill factory', () => {
261
- const skill = createPlayBackgroundFileSkill();
262
- expect(skill).toBeInstanceOf(PlayBackgroundFileSkill);
263
- expect(skill).toBeInstanceOf(SkillBase);
264
- });
265
-
266
- it('should return correct manifest name and version', () => {
267
- const skill = createPlayBackgroundFileSkill();
268
- const klass = skill.constructor as typeof SkillBase;
269
- expect(klass.SKILL_NAME).toBe('play_background_file');
270
- expect(klass.SKILL_VERSION).toBe('1.0.0');
271
- });
272
-
273
- it('should return play_background and stop_background tools', () => {
274
- const skill = createPlayBackgroundFileSkill();
275
- const tools = skill.getTools();
276
- expect(tools).toHaveLength(2);
277
- const names = tools.map((t) => t.name);
278
- expect(names).toContain('play_background');
279
- expect(names).toContain('stop_background');
280
- });
281
-
282
- it('should execute play_background handler with a valid URL', () => {
283
- const skill = createPlayBackgroundFileSkill();
284
- const playTool = skill.getTools().find((t) => t.name === 'play_background')!;
285
- const result = playTool.handler(
286
- { file_url: 'https://example.com/music.mp3' },
287
- {},
288
- ) as FunctionResult;
289
- expect(result).toBeInstanceOf(FunctionResult);
290
- expect(result.response).toContain('playing background audio');
291
- // Should have a playback_bg action
292
- expect(result.action.length).toBeGreaterThan(0);
293
- expect(result.action[0]).toHaveProperty('playback_bg');
294
- });
295
-
296
- it('should execute stop_background handler', () => {
297
- const skill = createPlayBackgroundFileSkill();
298
- const stopTool = skill.getTools().find((t) => t.name === 'stop_background')!;
299
- const result = stopTool.handler({}, {}) as FunctionResult;
300
- expect(result).toBeInstanceOf(FunctionResult);
301
- expect(result.response).toContain('stopped');
302
- expect(result.action.length).toBeGreaterThan(0);
303
- expect(result.action[0]).toHaveProperty('stop_playback_bg');
304
- });
305
- });
306
-
307
- // ---------------------------------------------------------------------------
308
- // SWML Transfer Skill
309
- // ---------------------------------------------------------------------------
310
- describe('SwmlTransferSkill', () => {
311
- it('should instantiate via createSkill factory', () => {
312
- const skill = createSwmlTransferSkill();
313
- expect(skill).toBeInstanceOf(SwmlTransferSkill);
314
- expect(skill).toBeInstanceOf(SkillBase);
315
- });
316
-
317
- it('should return correct manifest name and version', () => {
318
- const skill = createSwmlTransferSkill();
319
- const klass = skill.constructor as typeof SkillBase;
320
- expect(klass.SKILL_NAME).toBe('swml_transfer');
321
- expect(klass.SKILL_VERSION).toBe('1.0.0');
322
- });
323
-
324
- it('should return a transfer_call tool', () => {
325
- const skill = createSwmlTransferSkill();
326
- const tools = skill.getTools();
327
- expect(tools.length).toBeGreaterThanOrEqual(1);
328
- expect(tools[0].name).toBe('transfer_call');
329
- expect(tools[0].required).toContain('transfer_type');
330
- });
331
-
332
- it('should execute transfer with arbitrary destination', () => {
333
- const skill = createSwmlTransferSkill();
334
- const handler = skill.getTools()[0].handler;
335
- const result = handler({ transfer_type: '+15551234567' }, {}) as FunctionResult;
336
- expect(result).toBeInstanceOf(FunctionResult);
337
- expect(result.response).toBe('Transferring you now...');
338
- // Should have a SWML transfer action
339
- expect(result.action.length).toBeGreaterThan(0);
340
- const swmlAction = result.action[0];
341
- expect(swmlAction).toHaveProperty('SWML');
342
- expect(swmlAction).toHaveProperty('transfer', 'true');
343
- });
344
-
345
- it('should support named transfer patterns', () => {
346
- const skill = createSwmlTransferSkill({
347
- patterns: [
348
- { name: 'sales', destination: 'sip:sales@example.com', description: 'Sales team' },
349
- { name: 'support', destination: 'sip:support@example.com', description: 'Support team' },
350
- ],
351
- });
352
- const tools = skill.getTools();
353
- // Should have transfer_call + list_transfer_destinations
354
- expect(tools.length).toBe(2);
355
- expect(tools[1].name).toBe('list_transfer_destinations');
356
-
357
- // Transfer by name
358
- const handler = tools[0].handler;
359
- const result = handler({ transfer_type: 'sales' }, {}) as FunctionResult;
360
- expect(result).toBeInstanceOf(FunctionResult);
361
- expect(result.action.length).toBeGreaterThan(0);
362
- });
363
-
364
- it('should use default_message when patterns configured and arbitrary disallowed', () => {
365
- const skill = createSwmlTransferSkill({
366
- patterns: [
367
- { name: 'sales', destination: 'sip:sales@example.com' },
368
- ],
369
- allow_arbitrary: false,
370
- default_message: 'Please specify a valid transfer type.',
371
- });
372
- const handler = skill.getTools()[0].handler;
373
- const result = handler({ transfer_type: 'unknown_dept' }, {}) as FunctionResult;
374
- expect(result).toBeInstanceOf(FunctionResult);
375
- expect(result.response).toContain('valid transfer type');
376
- });
377
- });
378
-
379
- // ---------------------------------------------------------------------------
380
- // API Ninjas Trivia Skill
381
- // ---------------------------------------------------------------------------
382
- describe('ApiNinjasTriviaSkill', () => {
383
- it('should instantiate via createSkill factory', () => {
384
- const skill = createApiNinjasTriviaSkill();
385
- expect(skill).toBeInstanceOf(ApiNinjasTriviaSkill);
386
- expect(skill).toBeInstanceOf(SkillBase);
387
- });
388
-
389
- it('should expose correct class metadata', () => {
390
- const skill = createApiNinjasTriviaSkill();
391
- const klass = skill.constructor as typeof SkillBase;
392
- expect(klass.SKILL_NAME).toBe('api_ninjas_trivia');
393
- expect(klass.SKILL_VERSION).toBe('1.0.0');
394
- // Python skill.py:61 — `REQUIRED_ENV_VARS = []` because the api_key can
395
- // be supplied via params. The handler still falls back to the env var.
396
- expect(klass.REQUIRED_ENV_VARS).toEqual([]);
397
- });
398
-
399
- it('should accept api_key via config as a fallback for the env var', async () => {
400
- const originalKey = process.env['API_NINJAS_KEY'];
401
- delete process.env['API_NINJAS_KEY'];
402
- try {
403
- const skill = createApiNinjasTriviaSkill({ api_key: 'config-key' });
404
- const handler = skill.getTools()[0].handler;
405
- // Intercept fetch to avoid a real network call; we only need to assert
406
- // that the handler treats the config value as present (no "not configured").
407
- const originalFetch = globalThis.fetch;
408
- globalThis.fetch = (async () => new Response(
409
- JSON.stringify([
410
- { category: 'general', question: 'q?', answer: 'a' },
411
- ]),
412
- { status: 200, headers: { 'Content-Type': 'application/json' } },
413
- )) as typeof fetch;
414
- try {
415
- const result = await handler({}, {}) as FunctionResult;
416
- expect(result.response).not.toContain('not configured');
417
- } finally {
418
- globalThis.fetch = originalFetch;
419
- }
420
- } finally {
421
- if (originalKey !== undefined) process.env['API_NINJAS_KEY'] = originalKey;
422
- }
423
- });
424
-
425
- it('should return a get_trivia tool', () => {
426
- const skill = createApiNinjasTriviaSkill();
427
- const tools = skill.getTools();
428
- expect(tools).toHaveLength(1);
429
- expect(tools[0].name).toBe('get_trivia');
430
- });
431
-
432
- it('should return hints for speech recognition', () => {
433
- const skill = createApiNinjasTriviaSkill();
434
- const hints = skill.getHints();
435
- expect(hints.length).toBeGreaterThan(0);
436
- expect(hints).toContain('trivia');
437
- });
438
-
439
- it('should return error when API key is not set', async () => {
440
- const originalKey = process.env['API_NINJAS_KEY'];
441
- delete process.env['API_NINJAS_KEY'];
442
- const skill = createApiNinjasTriviaSkill();
443
- const handler = skill.getTools()[0].handler;
444
- const result = await handler({}, {}) as FunctionResult;
445
- expect(result).toBeInstanceOf(FunctionResult);
446
- expect(result.response).toContain('API_NINJAS_KEY');
447
- expect(result.response).toContain('not configured');
448
- if (originalKey !== undefined) process.env['API_NINJAS_KEY'] = originalKey;
449
- });
450
- });
451
-
452
- // ---------------------------------------------------------------------------
453
- // Info Gatherer Skill
454
- // ---------------------------------------------------------------------------
455
- describe('InfoGathererSkill', () => {
456
- it('should instantiate with questions config via createSkill factory', () => {
457
- const skill = createInfoGathererSkill({
458
- questions: [
459
- { key_name: 'full_name', question_text: 'What is your full name?' },
460
- { key_name: 'email', question_text: 'What is your email address?' },
461
- ],
462
- });
463
- expect(skill).toBeInstanceOf(InfoGathererSkill);
464
- expect(skill).toBeInstanceOf(SkillBase);
465
- });
466
-
467
- it('should return correct manifest name and version', () => {
468
- const skill = createInfoGathererSkill();
469
- const klass = skill.constructor as typeof SkillBase;
470
- expect(klass.SKILL_NAME).toBe('info_gatherer');
471
- expect(klass.SKILL_VERSION).toBe('1.0.0');
472
- });
473
- });
474
-
475
- // ---------------------------------------------------------------------------
476
- // Custom Skills Skill
477
- // ---------------------------------------------------------------------------
478
- describe('CustomSkillsSkill', () => {
479
- it('should instantiate with tools config via createSkill factory', () => {
480
- const skill = createCustomSkillsSkill({
481
- tools: [
482
- {
483
- name: 'greet',
484
- description: 'Greet a user',
485
- handler_code: 'return new FunctionResult("Hello, " + args.name + "!");',
486
- parameters: [{ name: 'name', type: 'string', description: 'Name to greet' }],
487
- },
488
- ],
489
- });
490
- expect(skill).toBeInstanceOf(CustomSkillsSkill);
491
- expect(skill).toBeInstanceOf(SkillBase);
492
- });
493
-
494
- it('should return correct manifest name and version', () => {
495
- const skill = createCustomSkillsSkill();
496
- const klass = skill.constructor as typeof SkillBase;
497
- expect(klass.SKILL_NAME).toBe('custom_skills');
498
- expect(klass.SKILL_VERSION).toBe('1.0.0');
499
- });
500
-
501
- it('should register dynamic tools from config', () => {
502
- const skill = createCustomSkillsSkill({
503
- tools: [
504
- {
505
- name: 'greet',
506
- description: 'Greet a user',
507
- handler_code: 'return new FunctionResult("Hello!");',
508
- },
509
- {
510
- name: 'farewell',
511
- description: 'Say goodbye',
512
- handler_code: 'return new FunctionResult("Goodbye!");',
513
- },
514
- ],
515
- });
516
- const tools = skill.getTools();
517
- expect(tools).toHaveLength(2);
518
- expect(tools[0].name).toBe('greet');
519
- expect(tools[1].name).toBe('farewell');
520
- });
521
-
522
- it('should execute custom tool handler', async () => {
523
- const saved = process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
524
- process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'] = 'true';
525
- try {
526
- const skill = createCustomSkillsSkill({
527
- tools: [
528
- {
529
- name: 'greet',
530
- description: 'Greet a user',
531
- handler_code: 'return new FunctionResult("Hello, " + args.name + "!");',
532
- parameters: [{ name: 'name', type: 'string', description: 'Name to greet' }],
533
- },
534
- ],
535
- });
536
- const handler = skill.getTools()[0].handler;
537
- const result = await handler({ name: 'World' }, {}) as FunctionResult;
538
- expect(result).toBeInstanceOf(FunctionResult);
539
- expect(result.response).toBe('Hello, World!');
540
- } finally {
541
- if (saved) process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'] = saved;
542
- else delete process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
543
- }
544
- });
545
- });
546
-
547
- // ---------------------------------------------------------------------------
548
- // Web Search Skill
549
- // ---------------------------------------------------------------------------
550
- describe('WebSearchSkill', () => {
551
- it('should instantiate via createSkill factory', () => {
552
- const skill = createWebSearchSkill();
553
- expect(skill).toBeInstanceOf(WebSearchSkill);
554
- expect(skill).toBeInstanceOf(SkillBase);
555
- });
556
-
557
- it('should return correct manifest name and version', () => {
558
- const skill = createWebSearchSkill();
559
- const klass = skill.constructor as typeof SkillBase;
560
- expect(klass.SKILL_NAME).toBe('web_search');
561
- expect(klass.SKILL_VERSION).toBe('2.0.0');
562
- // Python declares REQUIRED_ENV_VARS = [] because credentials may come from
563
- // either config params or env vars — nothing is strictly required at the
564
- // env-var layer. setup() enforces at least one source is populated.
565
- expect(klass.REQUIRED_ENV_VARS).toEqual([]);
566
- });
567
-
568
- it('should return a web_search tool', () => {
569
- const skill = createWebSearchSkill();
570
- const tools = skill.getTools();
571
- expect(tools).toHaveLength(1);
572
- expect(tools[0].name).toBe('web_search');
573
- expect(tools[0].required).toContain('query');
574
- });
575
-
576
- it('should return non-empty prompt sections', () => {
577
- const skill = createWebSearchSkill();
578
- const sections = skill.getPromptSections();
579
- expect(sections.length).toBeGreaterThan(0);
580
- expect(sections[0].title).toContain('Web Search');
581
- });
582
-
583
- it('should return error when API keys are not set', async () => {
584
- const origKey = process.env['GOOGLE_SEARCH_API_KEY'];
585
- const origEngine = process.env['GOOGLE_SEARCH_ENGINE_ID'];
586
- const origCx = process.env['GOOGLE_SEARCH_CX'];
587
- delete process.env['GOOGLE_SEARCH_API_KEY'];
588
- delete process.env['GOOGLE_SEARCH_ENGINE_ID'];
589
- delete process.env['GOOGLE_SEARCH_CX'];
590
- const skill = createWebSearchSkill();
591
- const handler = skill.getTools()[0].handler;
592
- const result = await handler({ query: 'test' }, {}) as FunctionResult;
593
- expect(result).toBeInstanceOf(FunctionResult);
594
- expect(result.response).toContain('not configured');
595
- if (origKey !== undefined) process.env['GOOGLE_SEARCH_API_KEY'] = origKey;
596
- if (origEngine !== undefined) process.env['GOOGLE_SEARCH_ENGINE_ID'] = origEngine;
597
- if (origCx !== undefined) process.env['GOOGLE_SEARCH_CX'] = origCx;
598
- });
599
- });
600
-
601
- // ---------------------------------------------------------------------------
602
- // Wikipedia Search Skill
603
- // ---------------------------------------------------------------------------
604
- describe('WikipediaSearchSkill', () => {
605
- it('should instantiate via createSkill factory', () => {
606
- const skill = createWikipediaSearchSkill();
607
- expect(skill).toBeInstanceOf(WikipediaSearchSkill);
608
- expect(skill).toBeInstanceOf(SkillBase);
609
- });
610
-
611
- it('should return correct manifest name and version', () => {
612
- const skill = createWikipediaSearchSkill();
613
- const klass = skill.constructor as typeof SkillBase;
614
- expect(klass.SKILL_NAME).toBe('wikipedia_search');
615
- expect(klass.SKILL_VERSION).toBe('1.0.0');
616
- });
617
-
618
- it('should return a search_wiki tool', () => {
619
- const skill = createWikipediaSearchSkill();
620
- const tools = skill.getTools();
621
- expect(tools).toHaveLength(1);
622
- expect(tools[0].name).toBe('search_wiki');
623
- expect(tools[0].required).toContain('query');
624
- });
625
-
626
- it('should return non-empty prompt sections', () => {
627
- const skill = createWikipediaSearchSkill();
628
- const sections = skill.getPromptSections();
629
- expect(sections.length).toBeGreaterThan(0);
630
- expect(sections[0].title).toBe('Wikipedia Search');
631
- expect(sections[0].bullets).toBeDefined();
632
- expect(sections[0].bullets!.length).toBeGreaterThan(0);
633
- });
634
-
635
- it('should declare empty requiredEnvVars (free API, matches Python REQUIRED_ENV_VARS = [])', () => {
636
- const skill = createWikipediaSearchSkill();
637
- const klass = skill.constructor as typeof SkillBase;
638
- expect(klass.REQUIRED_ENV_VARS).toEqual([]);
639
- });
640
- });
641
-
642
- // ---------------------------------------------------------------------------
643
- // Google Maps Skill
644
- // ---------------------------------------------------------------------------
645
- describe('GoogleMapsSkill', () => {
646
- it('should instantiate via createSkill factory', () => {
647
- const skill = createGoogleMapsSkill();
648
- expect(skill).toBeInstanceOf(GoogleMapsSkill);
649
- expect(skill).toBeInstanceOf(SkillBase);
650
- });
651
-
652
- it('should return correct manifest name and version', () => {
653
- const skill = createGoogleMapsSkill();
654
- const klass = skill.constructor as typeof SkillBase;
655
- expect(klass.SKILL_NAME).toBe('google_maps');
656
- expect(klass.SKILL_VERSION).toBe('1.0.0');
657
- expect(klass.REQUIRED_ENV_VARS).toContain('GOOGLE_MAPS_API_KEY');
658
- });
659
-
660
- it('should return compute_route, lookup_address, geocode_address, and compute_route_by_coords tools by default', () => {
661
- const skill = createGoogleMapsSkill();
662
- const tools = skill.getTools();
663
- expect(tools).toHaveLength(4);
664
- const names = tools.map((t) => t.name);
665
- expect(names).toContain('compute_route');
666
- expect(names).toContain('lookup_address');
667
- expect(names).toContain('geocode_address');
668
- expect(names).toContain('compute_route_by_coords');
669
- });
670
-
671
- it('should honor configurable route_tool_name / lookup_tool_name', () => {
672
- const skill = createGoogleMapsSkill({
673
- route_tool_name: 'get_directions',
674
- lookup_tool_name: 'find_place',
675
- });
676
- const names = skill.getTools().map((t) => t.name);
677
- expect(names).toContain('get_directions');
678
- expect(names).toContain('find_place');
679
- });
680
-
681
- it('should return error from the route tool when API key is not set', async () => {
682
- const origKey = process.env['GOOGLE_MAPS_API_KEY'];
683
- delete process.env['GOOGLE_MAPS_API_KEY'];
684
- const skill = createGoogleMapsSkill();
685
- const dirTool = skill.getTools().find((t) => t.name === 'compute_route')!;
686
- const result = await dirTool.handler(
687
- { origin: 'New York', destination: 'Boston' },
688
- {},
689
- ) as FunctionResult;
690
- expect(result).toBeInstanceOf(FunctionResult);
691
- expect(result.response).toContain('not configured');
692
- if (origKey !== undefined) process.env['GOOGLE_MAPS_API_KEY'] = origKey;
693
- });
694
-
695
- it('should return error from the lookup tool when API key is not set', async () => {
696
- const origKey = process.env['GOOGLE_MAPS_API_KEY'];
697
- delete process.env['GOOGLE_MAPS_API_KEY'];
698
- const skill = createGoogleMapsSkill();
699
- const placeTool = skill.getTools().find((t) => t.name === 'lookup_address')!;
700
- const result = await placeTool.handler(
701
- { query: 'pizza near me' },
702
- {},
703
- ) as FunctionResult;
704
- expect(result).toBeInstanceOf(FunctionResult);
705
- expect(result.response).toContain('not configured');
706
- if (origKey !== undefined) process.env['GOOGLE_MAPS_API_KEY'] = origKey;
707
- });
708
- });
709
-
710
- // ---------------------------------------------------------------------------
711
- // DataSphere Skill
712
- // ---------------------------------------------------------------------------
713
- describe('DataSphereSkill', () => {
714
- it('should instantiate via createSkill factory', () => {
715
- const skill = createDataSphereSkill();
716
- expect(skill).toBeInstanceOf(DataSphereSkill);
717
- expect(skill).toBeInstanceOf(SkillBase);
718
- });
719
-
720
- it('should return correct manifest name and version', () => {
721
- const skill = createDataSphereSkill();
722
- const klass = skill.constructor as typeof SkillBase;
723
- expect(klass.SKILL_NAME).toBe('datasphere');
724
- expect(klass.SKILL_VERSION).toBe('1.0.0');
725
- // Credentials come from params by design (matches Python REQUIRED_ENV_VARS = []).
726
- expect(klass.REQUIRED_ENV_VARS).toEqual([]);
727
- });
728
-
729
- it('should return a search_knowledge tool', () => {
730
- const skill = createDataSphereSkill();
731
- const tools = skill.getTools();
732
- expect(tools).toHaveLength(1);
733
- expect(tools[0].name).toBe('search_knowledge');
734
- expect(tools[0].required).toContain('query');
735
- });
736
-
737
- it('should return non-empty prompt sections', () => {
738
- const skill = createDataSphereSkill();
739
- const sections = skill.getPromptSections();
740
- expect(sections.length).toBeGreaterThan(0);
741
- expect(sections[0].title).toContain('Knowledge Search');
742
- });
743
-
744
- it('should return error when env vars are not set', async () => {
745
- const origPid = process.env['SIGNALWIRE_PROJECT_ID'];
746
- const origToken = process.env['SIGNALWIRE_TOKEN'];
747
- const origSpace = process.env['SIGNALWIRE_SPACE'];
748
- delete process.env['SIGNALWIRE_PROJECT_ID'];
749
- delete process.env['SIGNALWIRE_TOKEN'];
750
- delete process.env['SIGNALWIRE_SPACE'];
751
- const skill = createDataSphereSkill();
752
- const handler = skill.getTools()[0].handler;
753
- const result = await handler({ query: 'test' }, {}) as FunctionResult;
754
- expect(result).toBeInstanceOf(FunctionResult);
755
- expect(result.response).toContain('not configured');
756
- expect(result.response).toContain('SIGNALWIRE_PROJECT_ID');
757
- if (origPid !== undefined) process.env['SIGNALWIRE_PROJECT_ID'] = origPid;
758
- if (origToken !== undefined) process.env['SIGNALWIRE_TOKEN'] = origToken;
759
- if (origSpace !== undefined) process.env['SIGNALWIRE_SPACE'] = origSpace;
760
- });
761
- });
762
-
763
- // ---------------------------------------------------------------------------
764
- // DataSphere Serverless Skill
765
- // ---------------------------------------------------------------------------
766
- describe('DataSphereServerlessSkill', () => {
767
- it('should instantiate via createSkill factory', () => {
768
- const skill = createDataSphereServerlessSkill();
769
- expect(skill).toBeInstanceOf(DataSphereServerlessSkill);
770
- expect(skill).toBeInstanceOf(SkillBase);
771
- });
772
-
773
- it('should return correct manifest name and version', () => {
774
- const skill = createDataSphereServerlessSkill();
775
- const klass = skill.constructor as typeof SkillBase;
776
- expect(klass.SKILL_NAME).toBe('datasphere_serverless');
777
- expect(klass.SKILL_VERSION).toBe('1.0.0');
778
- // Credentials come from params by design (matches Python REQUIRED_ENV_VARS = []).
779
- expect(klass.REQUIRED_ENV_VARS ?? []).toEqual([]);
780
- });
781
-
782
- it('should return a search_knowledge tool stub', () => {
783
- const skill = createDataSphereServerlessSkill();
784
- const tools = skill.getTools();
785
- expect(tools).toHaveLength(1);
786
- expect(tools[0].name).toBe('search_knowledge');
787
- });
788
-
789
- it('should return stub handler message indicating DataMap mode', () => {
790
- const skill = createDataSphereServerlessSkill();
791
- const handler = skill.getTools()[0].handler;
792
- const result = handler({}, {}) as FunctionResult;
793
- expect(result).toBeInstanceOf(FunctionResult);
794
- expect(result.response).toContain('serverless DataMap');
795
- });
796
-
797
- it('should expose getDataMapTools returning a data_map function', () => {
798
- const skill = createDataSphereServerlessSkill();
799
- const dataMapTools = skill.getDataMapTools();
800
- expect(dataMapTools).toHaveLength(1);
801
- expect(dataMapTools[0]).toBeDefined();
802
- // The DataMap function should have a 'function' key with name
803
- expect(dataMapTools[0]).toHaveProperty('function');
804
- });
805
- });
806
-
807
- // ---------------------------------------------------------------------------
808
- // Native Vector Search Skill
809
- // ---------------------------------------------------------------------------
810
- describe('NativeVectorSearchSkill', () => {
811
- const testDocuments = [
812
- { id: 'doc1', text: 'TypeScript is a strongly typed programming language that builds on JavaScript.' },
813
- { id: 'doc2', text: 'Python is a versatile programming language used for web development and data science.' },
814
- { id: 'doc3', text: 'Rust focuses on safety and performance, ideal for systems programming.' },
815
- { id: 'doc4', text: 'The weather today is sunny with clear skies and warm temperatures.' },
816
- ];
817
-
818
- it('should instantiate with documents config via createSkill factory', () => {
819
- const skill = createNativeVectorSearchSkill({ documents: testDocuments });
820
- expect(skill).toBeInstanceOf(NativeVectorSearchSkill);
821
- expect(skill).toBeInstanceOf(SkillBase);
822
- });
823
-
824
- it('should return correct manifest name and version', () => {
825
- const skill = createNativeVectorSearchSkill();
826
- const klass = skill.constructor as typeof SkillBase;
827
- expect(klass.SKILL_NAME).toBe('native_vector_search');
828
- expect(klass.SKILL_VERSION).toBe('1.0.0');
829
- });
830
-
831
- it('should return a search_knowledge tool (Python-aligned default name)', async () => {
832
- const skill = createNativeVectorSearchSkill({ documents: testDocuments });
833
- await skill.setup();
834
- const tools = skill.getTools();
835
- expect(tools).toHaveLength(1);
836
- expect(tools[0].name).toBe('search_knowledge');
837
- expect(tools[0].required).toContain('query');
838
- });
839
-
840
- it('should execute search and find relevant documents', async () => {
841
- const skill = createNativeVectorSearchSkill({ documents: testDocuments });
842
- await skill.setup();
843
- const handler = skill.getTools()[0].handler;
844
- const result = (await handler(
845
- { query: 'TypeScript programming language' },
846
- {},
847
- )) as FunctionResult;
848
- expect(result).toBeInstanceOf(FunctionResult);
849
- expect(result.response).toContain('doc1');
850
- expect(result.response).toContain('TypeScript');
851
- });
852
-
853
- it('should rank relevant documents higher (scoring works)', async () => {
854
- const skill = createNativeVectorSearchSkill({ documents: testDocuments });
855
- await skill.setup();
856
- const handler = skill.getTools()[0].handler;
857
- const result = (await handler(
858
- { query: 'programming language', count: 4 },
859
- {},
860
- )) as FunctionResult;
861
- expect(result).toBeInstanceOf(FunctionResult);
862
- // Programming-related docs should appear; weather doc should not (no overlap)
863
- expect(result.response).toContain('programming');
864
- // The response should contain "Result 1" indicating at least one result
865
- expect(result.response).toContain('Result 1');
866
- });
867
- });
868
-
869
- // ---------------------------------------------------------------------------
870
- // Spider Skill
871
- // ---------------------------------------------------------------------------
872
- describe('SpiderSkill', () => {
873
- it('should instantiate via createSkill factory', () => {
874
- const skill = createSpiderSkill();
875
- expect(skill).toBeInstanceOf(SpiderSkill);
876
- expect(skill).toBeInstanceOf(SkillBase);
877
- });
878
-
879
- it('should return correct manifest name and version', () => {
880
- const skill = createSpiderSkill();
881
- const klass = skill.constructor as typeof SkillBase;
882
- expect(klass.SKILL_NAME).toBe('spider');
883
- expect(klass.SKILL_VERSION).toBe('1.0.0');
884
- });
885
-
886
- it('should return the three Python-aligned tools (scrape_url, crawl_site, extract_structured_data)', async () => {
887
- const skill = createSpiderSkill();
888
- await skill.setup();
889
- const tools = skill.getTools();
890
- expect(tools).toHaveLength(3);
891
- const names = tools.map((t) => t.name);
892
- expect(names).toContain('scrape_url');
893
- expect(names).toContain('crawl_site');
894
- expect(names).toContain('extract_structured_data');
895
- const scrape = tools.find((t) => t.name === 'scrape_url')!;
896
- expect(scrape.required).toContain('url');
897
- });
898
-
899
- it('should reject invalid URL in scrape_url handler', async () => {
900
- const skill = createSpiderSkill();
901
- await skill.setup();
902
- const handler = skill.getTools().find((t) => t.name === 'scrape_url')!.handler;
903
- const result = (await handler({ url: 'not-a-url' }, {})) as FunctionResult;
904
- expect(result).toBeInstanceOf(FunctionResult);
905
- expect(result.response).toMatch(/Invalid URL/i);
906
- });
907
- });
908
-
909
- // ---------------------------------------------------------------------------
910
- // Ask Claude Skill (renamed from ClaudeSkill)
911
- // ---------------------------------------------------------------------------
912
- describe('AskClaudeSkill', () => {
913
- it('should instantiate via createSkill factory', () => {
914
- const skill = createAskClaudeSkill();
915
- expect(skill).toBeInstanceOf(AskClaudeSkill);
916
- expect(skill).toBeInstanceOf(SkillBase);
917
- });
918
-
919
- it('should return correct manifest name and version', () => {
920
- const skill = createAskClaudeSkill();
921
- const klass = skill.constructor as typeof SkillBase;
922
- expect(klass.SKILL_NAME).toBe('ask_claude');
923
- expect(klass.SKILL_VERSION).toBe('1.0.0');
924
- expect(klass.REQUIRED_ENV_VARS).toContain('ANTHROPIC_API_KEY');
925
- });
926
-
927
- it('should return an ask_claude tool', () => {
928
- const skill = createAskClaudeSkill();
929
- const tools = skill.getTools();
930
- expect(tools).toHaveLength(1);
931
- expect(tools[0].name).toBe('ask_claude');
932
- expect(tools[0].required).toContain('prompt');
933
- });
934
- });
935
-
936
- // ---------------------------------------------------------------------------
937
- // Claude Skills Skill (SKILL.md loader)
938
- // ---------------------------------------------------------------------------
939
- describe('ClaudeSkillsSkill', () => {
940
- let tmpDir: string;
941
- let skillsDir: string;
942
-
943
- beforeAll(() => {
944
- tmpDir = mkdtempSync(join(tmpdir(), 'claude-skills-test-'));
945
- skillsDir = join(tmpDir, 'skills');
946
- mkdirSync(skillsDir);
947
-
948
- // Create a basic skill
949
- const basicSkillDir = join(skillsDir, 'greeting');
950
- mkdirSync(basicSkillDir);
951
- writeFileSync(
952
- join(basicSkillDir, 'SKILL.md'),
953
- '---\nname: greeting\ndescription: Greet the user\n---\n\nHello $ARGUMENTS! Welcome.',
954
- );
955
-
956
- // Create a skill with sections
957
- const sectionSkillDir = join(skillsDir, 'helper');
958
- mkdirSync(sectionSkillDir);
959
- writeFileSync(
960
- join(sectionSkillDir, 'SKILL.md'),
961
- '---\nname: helper\ndescription: A helper skill\n---\n\nMain helper content.',
962
- );
963
- writeFileSync(
964
- join(sectionSkillDir, 'advanced.md'),
965
- 'Advanced helper content.',
966
- );
967
- writeFileSync(
968
- join(sectionSkillDir, 'basics.md'),
969
- 'Basic helper content.',
970
- );
971
-
972
- // Create a skill with nested section
973
- const nestedDir = join(sectionSkillDir, 'references');
974
- mkdirSync(nestedDir);
975
- writeFileSync(join(nestedDir, 'api.md'), 'API reference content.');
976
-
977
- // Create a skill with no frontmatter
978
- const noFmDir = join(skillsDir, 'raw-skill');
979
- mkdirSync(noFmDir);
980
- writeFileSync(join(noFmDir, 'SKILL.md'), 'Just raw content, no frontmatter.');
981
-
982
- // Create a skill with disable-model-invocation
983
- const disabledDir = join(skillsDir, 'disabled-skill');
984
- mkdirSync(disabledDir);
985
- writeFileSync(
986
- join(disabledDir, 'SKILL.md'),
987
- '---\nname: disabled-skill\ndescription: Should be disabled\ndisable-model-invocation: true\n---\n\nDisabled content.',
988
- );
989
-
990
- // Create a skill with user-invocable: false
991
- const knowledgeDir = join(skillsDir, 'knowledge-only');
992
- mkdirSync(knowledgeDir);
993
- writeFileSync(
994
- join(knowledgeDir, 'SKILL.md'),
995
- '---\nname: knowledge-only\ndescription: Knowledge only skill\nuser-invocable: false\n---\n\nKnowledge content.',
996
- );
997
-
998
- // Create a skill with argument-hint
999
- const hintDir = join(skillsDir, 'with-hint');
1000
- mkdirSync(hintDir);
1001
- writeFileSync(
1002
- join(hintDir, 'SKILL.md'),
1003
- '---\nname: with-hint\ndescription: Skill with hint\nargument-hint: The city name to look up\n---\n\nLooking up $ARGUMENTS.',
1004
- );
1005
-
1006
- // Create a skill with variables
1007
- const varDir = join(skillsDir, 'var-skill');
1008
- mkdirSync(varDir);
1009
- writeFileSync(
1010
- join(varDir, 'SKILL.md'),
1011
- '---\nname: var-skill\ndescription: Variable skill\n---\n\nDir: ${CLAUDE_SKILL_DIR} Session: ${CLAUDE_SESSION_ID}',
1012
- );
1013
-
1014
- // Create a skill with shell injection patterns
1015
- const shellDir = join(skillsDir, 'shell-skill');
1016
- mkdirSync(shellDir);
1017
- writeFileSync(
1018
- join(shellDir, 'SKILL.md'),
1019
- '---\nname: shell-skill\ndescription: Shell skill\n---\n\nResult: !`echo hello`',
1020
- );
1021
-
1022
- // Create a skill with argument placeholders
1023
- const argDir = join(skillsDir, 'arg-skill');
1024
- mkdirSync(argDir);
1025
- writeFileSync(
1026
- join(argDir, 'SKILL.md'),
1027
- '---\nname: arg-skill\ndescription: Argument skill\n---\n\nFirst: $0 Second: $1 Indexed: $ARGUMENTS[0] All: $ARGUMENTS',
1028
- );
1029
-
1030
- // A non-skill directory (no SKILL.md)
1031
- const noSkillDir = join(skillsDir, 'not-a-skill');
1032
- mkdirSync(noSkillDir);
1033
- writeFileSync(join(noSkillDir, 'README.md'), 'Not a skill.');
1034
- });
1035
-
1036
- afterAll(() => {
1037
- rmSync(tmpDir, { recursive: true, force: true });
1038
- });
1039
-
1040
- it('should instantiate via createSkill factory', () => {
1041
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1042
- expect(skill).toBeInstanceOf(ClaudeSkillsSkill);
1043
- expect(skill).toBeInstanceOf(SkillBase);
1044
- });
1045
-
1046
- it('should return correct manifest', () => {
1047
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1048
- const klass = skill.constructor as typeof SkillBase;
1049
- expect(klass.SKILL_NAME).toBe('claude_skills');
1050
- expect(klass.SKILL_VERSION).toBe('1.0.0');
1051
- });
1052
-
1053
- it('should support multiple instances', () => {
1054
- expect(ClaudeSkillsSkill.SUPPORTS_MULTIPLE_INSTANCES).toBe(true);
1055
- });
1056
-
1057
- it('should discover skills from directory after setup', async () => {
1058
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1059
- await skill.setup();
1060
- const tools = skill.getTools();
1061
- // Should find skills with SKILL.md: greeting, helper, raw-skill, disabled-skill,
1062
- // knowledge-only, with-hint, var-skill, shell-skill, arg-skill
1063
- // But disabled-skill should be skipped (_skipTool), knowledge-only should be skipped (_skipTool)
1064
- const toolNames = tools.map((t) => t.name);
1065
- expect(toolNames).toContain('claude_greeting');
1066
- expect(toolNames).toContain('claude_helper');
1067
- expect(toolNames).toContain('claude_raw_skill');
1068
- expect(toolNames).toContain('claude_with_hint');
1069
- expect(toolNames).toContain('claude_var_skill');
1070
- expect(toolNames).toContain('claude_shell_skill');
1071
- expect(toolNames).toContain('claude_arg_skill');
1072
- // disabled-skill and knowledge-only should NOT be registered as tools
1073
- expect(toolNames).not.toContain('claude_disabled_skill');
1074
- expect(toolNames).not.toContain('claude_knowledge_only');
1075
- });
1076
-
1077
- it('should sanitize tool names correctly', async () => {
1078
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1079
- await skill.setup();
1080
- const tools = skill.getTools();
1081
- const toolNames = tools.map((t) => t.name);
1082
- // raw-skill → raw_skill (hyphens replaced)
1083
- expect(toolNames).toContain('claude_raw_skill');
1084
- });
1085
-
1086
- it('should return SKILL.md body content from handler', async () => {
1087
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1088
- await skill.setup();
1089
- const tools = skill.getTools();
1090
- const greetingTool = tools.find((t) => t.name === 'claude_greeting');
1091
- expect(greetingTool).toBeDefined();
1092
- const result = greetingTool!.handler({ arguments: 'World' }, {}) as FunctionResult;
1093
- expect(result).toBeInstanceOf(FunctionResult);
1094
- expect(result.response).toContain('Hello World! Welcome.');
1095
- });
1096
-
1097
- it('should load section content when section is specified', async () => {
1098
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1099
- await skill.setup();
1100
- const tools = skill.getTools();
1101
- const helperTool = tools.find((t) => t.name === 'claude_helper');
1102
- expect(helperTool).toBeDefined();
1103
-
1104
- // Check section enum
1105
- const sectionParam = helperTool!.parameters!['section'] as Record<string, unknown>;
1106
- expect(sectionParam).toBeDefined();
1107
- const enumValues = sectionParam.enum as string[];
1108
- expect(enumValues).toContain('advanced');
1109
- expect(enumValues).toContain('basics');
1110
- expect(enumValues).toContain('references/api');
1111
-
1112
- // Load a section
1113
- const result = helperTool!.handler({ section: 'advanced', arguments: '' }, {}) as FunctionResult;
1114
- expect(result.response).toContain('Advanced helper content.');
1115
- });
1116
-
1117
- it('should substitute $ARGUMENTS in body', async () => {
1118
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1119
- await skill.setup();
1120
- const tools = skill.getTools();
1121
- const argTool = tools.find((t) => t.name === 'claude_arg_skill');
1122
- expect(argTool).toBeDefined();
1123
- const result = argTool!.handler({ arguments: 'foo bar' }, {}) as FunctionResult;
1124
- expect(result.response).toContain('First: foo');
1125
- expect(result.response).toContain('Second: bar');
1126
- expect(result.response).toContain('Indexed: foo');
1127
- expect(result.response).toContain('All: foo bar');
1128
- });
1129
-
1130
- it('should append ARGUMENTS when no bare $ARGUMENTS placeholder', async () => {
1131
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1132
- await skill.setup();
1133
- const tools = skill.getTools();
1134
- const helperTool = tools.find((t) => t.name === 'claude_helper');
1135
- expect(helperTool).toBeDefined();
1136
- const result = helperTool!.handler({ arguments: 'some context' }, {}) as FunctionResult;
1137
- expect(result.response).toContain('Main helper content.');
1138
- expect(result.response).toContain('ARGUMENTS: some context');
1139
- });
1140
-
1141
- it('should substitute ${CLAUDE_SKILL_DIR} and ${CLAUDE_SESSION_ID}', async () => {
1142
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1143
- await skill.setup();
1144
- const tools = skill.getTools();
1145
- const varTool = tools.find((t) => t.name === 'claude_var_skill');
1146
- expect(varTool).toBeDefined();
1147
- const result = varTool!.handler(
1148
- { arguments: '' },
1149
- { call_id: 'test-session-123' },
1150
- ) as FunctionResult;
1151
- expect(result.response).toContain(`Dir: ${join(skillsDir, 'var-skill')}`);
1152
- expect(result.response).toContain('Session: test-session-123');
1153
- });
1154
-
1155
- it('should respect disable-model-invocation (no tool, no prompt)', async () => {
1156
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1157
- await skill.setup();
1158
- const tools = skill.getTools();
1159
- const toolNames = tools.map((t) => t.name);
1160
- expect(toolNames).not.toContain('claude_disabled_skill');
1161
-
1162
- const prompts = skill.getPromptSections();
1163
- const promptTitles = prompts.map((p) => p.title);
1164
- expect(promptTitles).not.toContain('disabled-skill');
1165
- });
1166
-
1167
- it('should respect user-invocable=false (no tool, yes prompt)', async () => {
1168
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir });
1169
- await skill.setup();
1170
- const tools = skill.getTools();
1171
- const toolNames = tools.map((t) => t.name);
1172
- expect(toolNames).not.toContain('claude_knowledge_only');
1173
-
1174
- const prompts = skill.getPromptSections();
1175
- const promptTitles = prompts.map((p) => p.title);
1176
- expect(promptTitles).toContain('knowledge-only');
1177
- });
1178
-
1179
- it('should handle include/exclude patterns', async () => {
1180
- const skill = createClaudeSkillsSkill({
1181
- skills_path: skillsDir,
1182
- include: ['greeting', 'helper'],
1183
- });
1184
- await skill.setup();
1185
- const tools = skill.getTools();
1186
- const toolNames = tools.map((t) => t.name);
1187
- expect(toolNames).toContain('claude_greeting');
1188
- expect(toolNames).toContain('claude_helper');
1189
- expect(toolNames).not.toContain('claude_raw_skill');
1190
- });
1191
-
1192
- it('should handle exclude patterns', async () => {
1193
- const skill = createClaudeSkillsSkill({
1194
- skills_path: skillsDir,
1195
- exclude: ['greeting'],
1196
- });
1197
- await skill.setup();
1198
- const tools = skill.getTools();
1199
- const toolNames = tools.map((t) => t.name);
1200
- expect(toolNames).not.toContain('claude_greeting');
1201
- expect(toolNames).toContain('claude_helper');
1202
- });
1203
-
1204
- it('should use custom tool_prefix', async () => {
1205
- const skill = createClaudeSkillsSkill({
1206
- skills_path: skillsDir,
1207
- tool_prefix: 'sk_',
1208
- include: ['greeting'],
1209
- });
1210
- await skill.setup();
1211
- const tools = skill.getTools();
1212
- expect(tools[0].name).toBe('sk_greeting');
1213
- });
1214
-
1215
- it('should apply response_prefix and response_postfix', async () => {
1216
- const skill = createClaudeSkillsSkill({
1217
- skills_path: skillsDir,
1218
- include: ['greeting'],
1219
- response_prefix: '[PREFIX]',
1220
- response_postfix: '[POSTFIX]',
1221
- });
1222
- await skill.setup();
1223
- const tools = skill.getTools();
1224
- const result = tools[0].handler({ arguments: 'World' }, {}) as FunctionResult;
1225
- expect(result.response).toMatch(/^\[PREFIX\]/);
1226
- expect(result.response).toMatch(/\[POSTFIX\]$/);
1227
- expect(result.response).toContain('Hello World! Welcome.');
1228
- });
1229
-
1230
- it('should use argument-hint as parameter description', async () => {
1231
- const skill = createClaudeSkillsSkill({ skills_path: skillsDir, include: ['with-hint'] });
1232
- await skill.setup();
1233
- const tools = skill.getTools();
1234
- const hintTool = tools.find((t) => t.name === 'claude_with_hint');
1235
- expect(hintTool).toBeDefined();
1236
- const argParam = hintTool!.parameters!['arguments'] as Record<string, unknown>;
1237
- expect(argParam.description).toBe('The city name to look up');
1238
- });
1239
-
1240
- it('should return prompt sections for non-skipped skills', async () => {
1241
- const skill = createClaudeSkillsSkill({
1242
- skills_path: skillsDir,
1243
- include: ['helper'],
1244
- });
1245
- await skill.setup();
1246
- const prompts = skill.getPromptSections();
1247
- expect(prompts.length).toBeGreaterThan(0);
1248
- const helperPrompt = prompts.find((p) => p.title === 'helper');
1249
- expect(helperPrompt).toBeDefined();
1250
- expect(helperPrompt!.body).toContain('Main helper content.');
1251
- expect(helperPrompt!.body).toContain('Available reference sections:');
1252
- });
1253
-
1254
- it('should return hints from skill names', async () => {
1255
- const skill = createClaudeSkillsSkill({
1256
- skills_path: skillsDir,
1257
- include: ['greeting', 'helper'],
1258
- });
1259
- await skill.setup();
1260
- const hints = skill.getHints();
1261
- expect(hints).toContain('greeting');
1262
- expect(hints).toContain('helper');
1263
- });
1264
-
1265
- it('should return empty tools for missing skills_path', async () => {
1266
- const skill = createClaudeSkillsSkill({ skills_path: '/nonexistent/path' });
1267
- await skill.setup();
1268
- const tools = skill.getTools();
1269
- expect(tools).toHaveLength(0);
1270
- });
1271
-
1272
- it('should return empty tools for empty directory', async () => {
1273
- const emptyDir = mkdtempSync(join(tmpdir(), 'empty-skills-'));
1274
- try {
1275
- const skill = createClaudeSkillsSkill({ skills_path: emptyDir });
1276
- await skill.setup();
1277
- const tools = skill.getTools();
1278
- expect(tools).toHaveLength(0);
1279
- } finally {
1280
- rmSync(emptyDir, { recursive: true, force: true });
1281
- }
1282
- });
1283
-
1284
- it('should execute shell injection when enabled', async () => {
1285
- const skill = createClaudeSkillsSkill({
1286
- skills_path: skillsDir,
1287
- include: ['shell-skill'],
1288
- allow_shell_injection: true,
1289
- });
1290
- await skill.setup();
1291
- const tools = skill.getTools();
1292
- const shellTool = tools.find((t) => t.name === 'claude_shell_skill');
1293
- expect(shellTool).toBeDefined();
1294
- const result = shellTool!.handler({ arguments: '' }, {}) as FunctionResult;
1295
- expect(result.response).toContain('Result: hello');
1296
- });
1297
-
1298
- it('should pass through shell patterns when disabled', async () => {
1299
- const skill = createClaudeSkillsSkill({
1300
- skills_path: skillsDir,
1301
- include: ['shell-skill'],
1302
- allow_shell_injection: false,
1303
- });
1304
- await skill.setup();
1305
- const tools = skill.getTools();
1306
- const shellTool = tools.find((t) => t.name === 'claude_shell_skill');
1307
- expect(shellTool).toBeDefined();
1308
- const result = shellTool!.handler({ arguments: '' }, {}) as FunctionResult;
1309
- expect(result.response).toContain('!`echo hello`');
1310
- });
1311
-
1312
- it('should override invocation control when ignore_invocation_control=true', async () => {
1313
- const skill = createClaudeSkillsSkill({
1314
- skills_path: skillsDir,
1315
- ignore_invocation_control: true,
1316
- });
1317
- await skill.setup();
1318
- const tools = skill.getTools();
1319
- const toolNames = tools.map((t) => t.name);
1320
- // Both disabled-skill and knowledge-only should now be registered
1321
- expect(toolNames).toContain('claude_disabled_skill');
1322
- expect(toolNames).toContain('claude_knowledge_only');
1323
- });
1324
-
1325
- it('should override descriptions via skill_descriptions', async () => {
1326
- const skill = createClaudeSkillsSkill({
1327
- skills_path: skillsDir,
1328
- include: ['greeting'],
1329
- skill_descriptions: { greeting: 'Custom description' },
1330
- });
1331
- await skill.setup();
1332
- const tools = skill.getTools();
1333
- expect(tools[0].description).toBe('Custom description');
1334
- });
1335
-
1336
- it('should return unique instance keys for different paths', () => {
1337
- const skill1 = createClaudeSkillsSkill({ skills_path: '/path/a' });
1338
- const skill2 = createClaudeSkillsSkill({ skills_path: '/path/b' });
1339
- expect(skill1.getInstanceKey()).not.toBe(skill2.getInstanceKey());
1340
- });
1341
- });
1342
-
1343
- // ---------------------------------------------------------------------------
1344
- // MCP Gateway Skill
1345
- // ---------------------------------------------------------------------------
1346
- describe('McpGatewaySkill', () => {
1347
- it('should instantiate via createSkill factory', () => {
1348
- const skill = createMcpGatewaySkill();
1349
- expect(skill).toBeInstanceOf(McpGatewaySkill);
1350
- expect(skill).toBeInstanceOf(SkillBase);
1351
- });
1352
-
1353
- it('should return correct manifest name and version', () => {
1354
- const skill = createMcpGatewaySkill();
1355
- const klass = skill.constructor as typeof SkillBase;
1356
- expect(klass.SKILL_NAME).toBe('mcp_gateway');
1357
- expect(klass.SKILL_VERSION).toBe('1.0.0');
1358
- });
1359
-
1360
- it('should return a configuration-prompt message when unconfigured', async () => {
1361
- const skill = createMcpGatewaySkill();
1362
- const handler = skill.getTools()[0].handler;
1363
- const result = (await handler({ server: 'test', method: 'test' }, {})) as FunctionResult;
1364
- expect(result).toBeInstanceOf(FunctionResult);
1365
- expect(result.response).toMatch(/not configured|configure/i);
1366
- });
1367
- });
1368
-
1369
- // ---------------------------------------------------------------------------
1370
- // Security remediation tests
1371
- // ---------------------------------------------------------------------------
1372
- describe('CustomSkillsSkill - code gate', () => {
1373
- it('should block handler compilation when SWML_ALLOW_CUSTOM_HANDLER_CODE is not set', () => {
1374
- const saved = process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
1375
- delete process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
1376
- const skill = createCustomSkillsSkill({
1377
- tools: [{ name: 'test_tool', description: 'Test', handler_code: 'return "hello";' }],
1378
- });
1379
- const errors = skill.getCompilationErrors();
1380
- expect(errors.has('test_tool')).toBe(true);
1381
- expect(errors.get('test_tool')).toContain('disabled');
1382
- if (saved) process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'] = saved;
1383
- });
1384
-
1385
- it('should allow handler compilation when SWML_ALLOW_CUSTOM_HANDLER_CODE=true', () => {
1386
- const saved = process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
1387
- process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'] = 'true';
1388
- const skill = createCustomSkillsSkill({
1389
- tools: [{ name: 'test_tool', description: 'Test', handler_code: 'return "hello";' }],
1390
- });
1391
- const errors = skill.getCompilationErrors();
1392
- expect(errors.has('test_tool')).toBe(false);
1393
- if (saved) process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'] = saved;
1394
- else delete process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
1395
- });
1396
- });
1397
-
1398
- describe('SpiderSkill - SSRF protection', () => {
1399
- it('should reject URLs resolving to private IPs', async () => {
1400
- const saved = process.env['SWML_ALLOW_PRIVATE_URLS'];
1401
- delete process.env['SWML_ALLOW_PRIVATE_URLS'];
1402
- const skill = createSpiderSkill();
1403
- await skill.setup();
1404
- const handler = skill.getTools().find((t) => t.name === 'scrape_url')!.handler;
1405
- const result = (await handler({ url: 'http://127.0.0.1/secret' }, {})) as FunctionResult;
1406
- expect(result).toBeInstanceOf(FunctionResult);
1407
- expect(result.response).toMatch(/private or internal URLs/);
1408
- if (saved) process.env['SWML_ALLOW_PRIVATE_URLS'] = saved;
1409
- });
1410
-
1411
- it('should reject overly long input', async () => {
1412
- const skill = createSpiderSkill();
1413
- await skill.setup();
1414
- const handler = skill.getTools().find((t) => t.name === 'scrape_url')!.handler;
1415
- const longUrl = 'https://example.com/' + 'a'.repeat(2000);
1416
- const result = (await handler({ url: longUrl }, {})) as FunctionResult;
1417
- expect(result).toBeInstanceOf(FunctionResult);
1418
- expect(result.response).toContain('too long');
1419
- });
1420
- });
1421
-
1422
- // ---------------------------------------------------------------------------
1423
- // Security remediation round 2 — error message leak tests
1424
- // ---------------------------------------------------------------------------
1425
- describe('Skill error messages do not leak internal details', () => {
1426
- it('math skill catch returns generic message', () => {
1427
- const skill = createMathSkill();
1428
- const handler = skill.getTools()[0].handler;
1429
- // Intentionally malformed expression that will throw
1430
- const result = handler({ expression: '2 +' }, {}) as FunctionResult;
1431
- expect(result).toBeInstanceOf(FunctionResult);
1432
- expect(result.response).toContain('Could not evaluate');
1433
- // Must not contain stack traces or JS error messages
1434
- expect(result.response).not.toContain('Unexpected');
1435
- expect(result.response).not.toContain('SyntaxError');
1436
- });
1437
-
1438
- it('custom_skills compilation error returns generic message', () => {
1439
- const saved = process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
1440
- process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'] = 'true';
1441
- try {
1442
- const skill = createCustomSkillsSkill({
1443
- tools: [{ name: 'bad_tool', description: 'Bad', handler_code: 'this is not valid javascript {{{{' }],
1444
- });
1445
- const errors = skill.getCompilationErrors();
1446
- expect(errors.has('bad_tool')).toBe(true);
1447
- // The stored error message should be generic, not expose syntax details
1448
- expect(errors.get('bad_tool')).toBe('Handler compilation failed.');
1449
- } finally {
1450
- if (saved) process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'] = saved;
1451
- else delete process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
1452
- }
1453
- });
1454
-
1455
- it('custom_skills runtime error returns generic message', async () => {
1456
- const saved = process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
1457
- process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'] = 'true';
1458
- try {
1459
- const skill = createCustomSkillsSkill({
1460
- tools: [{ name: 'crash_tool', description: 'Crash', handler_code: 'throw new Error("secret internal stack trace info");' }],
1461
- });
1462
- const handler = skill.getTools()[0].handler;
1463
- const result = await handler({}, {}) as FunctionResult;
1464
- expect(result).toBeInstanceOf(FunctionResult);
1465
- expect(result.response).not.toContain('secret internal stack trace info');
1466
- expect(result.response).toContain('encountered an error');
1467
- } finally {
1468
- if (saved) process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'] = saved;
1469
- else delete process.env['SWML_ALLOW_CUSTOM_HANDLER_CODE'];
1470
- }
1471
- });
1472
- });