loudmouth-ai 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (593) hide show
  1. package/README.md +148 -77
  2. package/dist/build-info.json +3 -3
  3. package/extensions/package.json +6 -0
  4. package/package.json +1 -1
  5. package/skills/autopilot/SKILL.md +179 -0
  6. package/skills/goals/SKILL.md +189 -0
  7. package/skills/wordpress/SKILL.md +232 -0
  8. package/extensions/bluebubbles/clawdbot.plugin.json +0 -11
  9. package/extensions/bluebubbles/index.ts +0 -20
  10. package/extensions/bluebubbles/package.json +0 -33
  11. package/extensions/bluebubbles/src/accounts.ts +0 -80
  12. package/extensions/bluebubbles/src/actions.test.ts +0 -651
  13. package/extensions/bluebubbles/src/actions.ts +0 -403
  14. package/extensions/bluebubbles/src/attachments.test.ts +0 -346
  15. package/extensions/bluebubbles/src/attachments.ts +0 -282
  16. package/extensions/bluebubbles/src/channel.ts +0 -399
  17. package/extensions/bluebubbles/src/chat.test.ts +0 -462
  18. package/extensions/bluebubbles/src/chat.ts +0 -354
  19. package/extensions/bluebubbles/src/config-schema.ts +0 -51
  20. package/extensions/bluebubbles/src/media-send.ts +0 -168
  21. package/extensions/bluebubbles/src/monitor.test.ts +0 -2140
  22. package/extensions/bluebubbles/src/monitor.ts +0 -2101
  23. package/extensions/bluebubbles/src/onboarding.ts +0 -340
  24. package/extensions/bluebubbles/src/probe.ts +0 -127
  25. package/extensions/bluebubbles/src/reactions.test.ts +0 -393
  26. package/extensions/bluebubbles/src/reactions.ts +0 -183
  27. package/extensions/bluebubbles/src/runtime.ts +0 -14
  28. package/extensions/bluebubbles/src/send.test.ts +0 -809
  29. package/extensions/bluebubbles/src/send.ts +0 -418
  30. package/extensions/bluebubbles/src/targets.test.ts +0 -184
  31. package/extensions/bluebubbles/src/targets.ts +0 -323
  32. package/extensions/bluebubbles/src/types.ts +0 -127
  33. package/extensions/copilot-proxy/README.md +0 -24
  34. package/extensions/copilot-proxy/clawdbot.plugin.json +0 -11
  35. package/extensions/copilot-proxy/index.ts +0 -142
  36. package/extensions/copilot-proxy/package.json +0 -11
  37. package/extensions/google-antigravity-auth/README.md +0 -24
  38. package/extensions/google-antigravity-auth/clawdbot.plugin.json +0 -11
  39. package/extensions/google-antigravity-auth/index.ts +0 -437
  40. package/extensions/google-antigravity-auth/package.json +0 -11
  41. package/extensions/google-gemini-cli-auth/README.md +0 -35
  42. package/extensions/google-gemini-cli-auth/clawdbot.plugin.json +0 -11
  43. package/extensions/google-gemini-cli-auth/index.ts +0 -91
  44. package/extensions/google-gemini-cli-auth/oauth.test.ts +0 -228
  45. package/extensions/google-gemini-cli-auth/oauth.ts +0 -580
  46. package/extensions/google-gemini-cli-auth/package.json +0 -11
  47. package/extensions/googlechat/clawdbot.plugin.json +0 -11
  48. package/extensions/googlechat/index.ts +0 -20
  49. package/extensions/googlechat/package.json +0 -39
  50. package/extensions/googlechat/src/accounts.ts +0 -133
  51. package/extensions/googlechat/src/actions.ts +0 -162
  52. package/extensions/googlechat/src/api.test.ts +0 -62
  53. package/extensions/googlechat/src/api.ts +0 -259
  54. package/extensions/googlechat/src/auth.ts +0 -113
  55. package/extensions/googlechat/src/channel.ts +0 -580
  56. package/extensions/googlechat/src/monitor.test.ts +0 -27
  57. package/extensions/googlechat/src/monitor.ts +0 -900
  58. package/extensions/googlechat/src/onboarding.ts +0 -278
  59. package/extensions/googlechat/src/runtime.ts +0 -14
  60. package/extensions/googlechat/src/targets.test.ts +0 -35
  61. package/extensions/googlechat/src/targets.ts +0 -55
  62. package/extensions/googlechat/src/types.config.ts +0 -3
  63. package/extensions/googlechat/src/types.ts +0 -73
  64. package/extensions/imessage/clawdbot.plugin.json +0 -11
  65. package/extensions/imessage/index.ts +0 -18
  66. package/extensions/imessage/package.json +0 -11
  67. package/extensions/imessage/src/channel.ts +0 -294
  68. package/extensions/imessage/src/runtime.ts +0 -14
  69. package/extensions/line/clawdbot.plugin.json +0 -11
  70. package/extensions/line/index.ts +0 -20
  71. package/extensions/line/package.json +0 -29
  72. package/extensions/line/src/card-command.ts +0 -338
  73. package/extensions/line/src/channel.logout.test.ts +0 -96
  74. package/extensions/line/src/channel.sendPayload.test.ts +0 -308
  75. package/extensions/line/src/channel.ts +0 -773
  76. package/extensions/line/src/runtime.ts +0 -14
  77. package/extensions/matrix/CHANGELOG.md +0 -54
  78. package/extensions/matrix/clawdbot.plugin.json +0 -11
  79. package/extensions/matrix/index.ts +0 -18
  80. package/extensions/matrix/package.json +0 -36
  81. package/extensions/matrix/src/actions.ts +0 -185
  82. package/extensions/matrix/src/channel.directory.test.ts +0 -56
  83. package/extensions/matrix/src/channel.ts +0 -417
  84. package/extensions/matrix/src/config-schema.ts +0 -62
  85. package/extensions/matrix/src/directory-live.ts +0 -175
  86. package/extensions/matrix/src/group-mentions.ts +0 -61
  87. package/extensions/matrix/src/matrix/accounts.test.ts +0 -83
  88. package/extensions/matrix/src/matrix/accounts.ts +0 -63
  89. package/extensions/matrix/src/matrix/actions/client.ts +0 -53
  90. package/extensions/matrix/src/matrix/actions/messages.ts +0 -120
  91. package/extensions/matrix/src/matrix/actions/pins.ts +0 -70
  92. package/extensions/matrix/src/matrix/actions/reactions.ts +0 -84
  93. package/extensions/matrix/src/matrix/actions/room.ts +0 -88
  94. package/extensions/matrix/src/matrix/actions/summary.ts +0 -77
  95. package/extensions/matrix/src/matrix/actions/types.ts +0 -84
  96. package/extensions/matrix/src/matrix/actions.ts +0 -15
  97. package/extensions/matrix/src/matrix/active-client.ts +0 -11
  98. package/extensions/matrix/src/matrix/client/config.ts +0 -165
  99. package/extensions/matrix/src/matrix/client/create-client.ts +0 -127
  100. package/extensions/matrix/src/matrix/client/logging.ts +0 -35
  101. package/extensions/matrix/src/matrix/client/runtime.ts +0 -4
  102. package/extensions/matrix/src/matrix/client/shared.ts +0 -169
  103. package/extensions/matrix/src/matrix/client/storage.ts +0 -131
  104. package/extensions/matrix/src/matrix/client/types.ts +0 -34
  105. package/extensions/matrix/src/matrix/client.test.ts +0 -57
  106. package/extensions/matrix/src/matrix/client.ts +0 -9
  107. package/extensions/matrix/src/matrix/credentials.ts +0 -103
  108. package/extensions/matrix/src/matrix/deps.ts +0 -57
  109. package/extensions/matrix/src/matrix/format.test.ts +0 -34
  110. package/extensions/matrix/src/matrix/format.ts +0 -22
  111. package/extensions/matrix/src/matrix/index.ts +0 -11
  112. package/extensions/matrix/src/matrix/monitor/allowlist.ts +0 -58
  113. package/extensions/matrix/src/matrix/monitor/auto-join.ts +0 -68
  114. package/extensions/matrix/src/matrix/monitor/direct.ts +0 -105
  115. package/extensions/matrix/src/matrix/monitor/events.ts +0 -103
  116. package/extensions/matrix/src/matrix/monitor/handler.ts +0 -645
  117. package/extensions/matrix/src/matrix/monitor/index.ts +0 -279
  118. package/extensions/matrix/src/matrix/monitor/location.ts +0 -83
  119. package/extensions/matrix/src/matrix/monitor/media.test.ts +0 -103
  120. package/extensions/matrix/src/matrix/monitor/media.ts +0 -113
  121. package/extensions/matrix/src/matrix/monitor/mentions.ts +0 -31
  122. package/extensions/matrix/src/matrix/monitor/replies.ts +0 -96
  123. package/extensions/matrix/src/matrix/monitor/room-info.ts +0 -58
  124. package/extensions/matrix/src/matrix/monitor/rooms.ts +0 -43
  125. package/extensions/matrix/src/matrix/monitor/threads.ts +0 -64
  126. package/extensions/matrix/src/matrix/monitor/types.ts +0 -39
  127. package/extensions/matrix/src/matrix/poll-types.test.ts +0 -22
  128. package/extensions/matrix/src/matrix/poll-types.ts +0 -157
  129. package/extensions/matrix/src/matrix/probe.ts +0 -70
  130. package/extensions/matrix/src/matrix/send/client.ts +0 -63
  131. package/extensions/matrix/src/matrix/send/formatting.ts +0 -92
  132. package/extensions/matrix/src/matrix/send/media.ts +0 -220
  133. package/extensions/matrix/src/matrix/send/targets.test.ts +0 -102
  134. package/extensions/matrix/src/matrix/send/targets.ts +0 -144
  135. package/extensions/matrix/src/matrix/send/types.ts +0 -109
  136. package/extensions/matrix/src/matrix/send.test.ts +0 -172
  137. package/extensions/matrix/src/matrix/send.ts +0 -255
  138. package/extensions/matrix/src/onboarding.ts +0 -432
  139. package/extensions/matrix/src/outbound.ts +0 -53
  140. package/extensions/matrix/src/resolve-targets.ts +0 -89
  141. package/extensions/matrix/src/runtime.ts +0 -14
  142. package/extensions/matrix/src/tool-actions.ts +0 -160
  143. package/extensions/matrix/src/types.ts +0 -95
  144. package/extensions/mattermost/clawdbot.plugin.json +0 -11
  145. package/extensions/mattermost/index.ts +0 -18
  146. package/extensions/mattermost/package.json +0 -25
  147. package/extensions/mattermost/src/channel.test.ts +0 -43
  148. package/extensions/mattermost/src/channel.ts +0 -339
  149. package/extensions/mattermost/src/config-schema.ts +0 -56
  150. package/extensions/mattermost/src/group-mentions.ts +0 -14
  151. package/extensions/mattermost/src/mattermost/accounts.ts +0 -115
  152. package/extensions/mattermost/src/mattermost/client.ts +0 -208
  153. package/extensions/mattermost/src/mattermost/index.ts +0 -9
  154. package/extensions/mattermost/src/mattermost/monitor-helpers.ts +0 -150
  155. package/extensions/mattermost/src/mattermost/monitor.ts +0 -921
  156. package/extensions/mattermost/src/mattermost/probe.ts +0 -70
  157. package/extensions/mattermost/src/mattermost/send.ts +0 -217
  158. package/extensions/mattermost/src/normalize.ts +0 -38
  159. package/extensions/mattermost/src/onboarding-helpers.ts +0 -42
  160. package/extensions/mattermost/src/onboarding.ts +0 -187
  161. package/extensions/mattermost/src/runtime.ts +0 -14
  162. package/extensions/mattermost/src/types.ts +0 -50
  163. package/extensions/msteams/CHANGELOG.md +0 -51
  164. package/extensions/msteams/clawdbot.plugin.json +0 -11
  165. package/extensions/msteams/index.ts +0 -18
  166. package/extensions/msteams/package.json +0 -36
  167. package/extensions/msteams/src/attachments/download.ts +0 -206
  168. package/extensions/msteams/src/attachments/graph.ts +0 -319
  169. package/extensions/msteams/src/attachments/html.ts +0 -76
  170. package/extensions/msteams/src/attachments/payload.ts +0 -22
  171. package/extensions/msteams/src/attachments/shared.ts +0 -235
  172. package/extensions/msteams/src/attachments/types.ts +0 -37
  173. package/extensions/msteams/src/attachments.test.ts +0 -424
  174. package/extensions/msteams/src/attachments.ts +0 -18
  175. package/extensions/msteams/src/channel.directory.test.ts +0 -46
  176. package/extensions/msteams/src/channel.ts +0 -436
  177. package/extensions/msteams/src/conversation-store-fs.test.ts +0 -88
  178. package/extensions/msteams/src/conversation-store-fs.ts +0 -155
  179. package/extensions/msteams/src/conversation-store-memory.ts +0 -45
  180. package/extensions/msteams/src/conversation-store.ts +0 -41
  181. package/extensions/msteams/src/directory-live.ts +0 -179
  182. package/extensions/msteams/src/errors.test.ts +0 -46
  183. package/extensions/msteams/src/errors.ts +0 -158
  184. package/extensions/msteams/src/file-consent-helpers.test.ts +0 -234
  185. package/extensions/msteams/src/file-consent-helpers.ts +0 -73
  186. package/extensions/msteams/src/file-consent.ts +0 -122
  187. package/extensions/msteams/src/graph-chat.ts +0 -52
  188. package/extensions/msteams/src/graph-upload.ts +0 -445
  189. package/extensions/msteams/src/inbound.test.ts +0 -67
  190. package/extensions/msteams/src/inbound.ts +0 -38
  191. package/extensions/msteams/src/index.ts +0 -4
  192. package/extensions/msteams/src/media-helpers.test.ts +0 -186
  193. package/extensions/msteams/src/media-helpers.ts +0 -77
  194. package/extensions/msteams/src/messenger.test.ts +0 -245
  195. package/extensions/msteams/src/messenger.ts +0 -460
  196. package/extensions/msteams/src/monitor-handler/inbound-media.ts +0 -123
  197. package/extensions/msteams/src/monitor-handler/message-handler.ts +0 -629
  198. package/extensions/msteams/src/monitor-handler.ts +0 -166
  199. package/extensions/msteams/src/monitor-types.ts +0 -5
  200. package/extensions/msteams/src/monitor.ts +0 -290
  201. package/extensions/msteams/src/onboarding.ts +0 -432
  202. package/extensions/msteams/src/outbound.ts +0 -47
  203. package/extensions/msteams/src/pending-uploads.ts +0 -87
  204. package/extensions/msteams/src/policy.test.ts +0 -210
  205. package/extensions/msteams/src/policy.ts +0 -202
  206. package/extensions/msteams/src/polls-store-memory.ts +0 -30
  207. package/extensions/msteams/src/polls-store.test.ts +0 -40
  208. package/extensions/msteams/src/polls.test.ts +0 -72
  209. package/extensions/msteams/src/polls.ts +0 -299
  210. package/extensions/msteams/src/probe.test.ts +0 -57
  211. package/extensions/msteams/src/probe.ts +0 -99
  212. package/extensions/msteams/src/reply-dispatcher.ts +0 -128
  213. package/extensions/msteams/src/resolve-allowlist.ts +0 -277
  214. package/extensions/msteams/src/runtime.ts +0 -14
  215. package/extensions/msteams/src/sdk-types.ts +0 -19
  216. package/extensions/msteams/src/sdk.ts +0 -33
  217. package/extensions/msteams/src/send-context.ts +0 -156
  218. package/extensions/msteams/src/send.ts +0 -489
  219. package/extensions/msteams/src/sent-message-cache.test.ts +0 -16
  220. package/extensions/msteams/src/sent-message-cache.ts +0 -41
  221. package/extensions/msteams/src/storage.ts +0 -22
  222. package/extensions/msteams/src/store-fs.ts +0 -80
  223. package/extensions/msteams/src/token.ts +0 -19
  224. package/extensions/nextcloud-talk/clawdbot.plugin.json +0 -11
  225. package/extensions/nextcloud-talk/index.ts +0 -18
  226. package/extensions/nextcloud-talk/package.json +0 -30
  227. package/extensions/nextcloud-talk/src/accounts.ts +0 -154
  228. package/extensions/nextcloud-talk/src/channel.ts +0 -404
  229. package/extensions/nextcloud-talk/src/config-schema.ts +0 -78
  230. package/extensions/nextcloud-talk/src/format.ts +0 -79
  231. package/extensions/nextcloud-talk/src/inbound.ts +0 -336
  232. package/extensions/nextcloud-talk/src/monitor.ts +0 -246
  233. package/extensions/nextcloud-talk/src/normalize.ts +0 -31
  234. package/extensions/nextcloud-talk/src/onboarding.ts +0 -341
  235. package/extensions/nextcloud-talk/src/policy.ts +0 -175
  236. package/extensions/nextcloud-talk/src/room-info.ts +0 -111
  237. package/extensions/nextcloud-talk/src/runtime.ts +0 -14
  238. package/extensions/nextcloud-talk/src/send.ts +0 -206
  239. package/extensions/nextcloud-talk/src/signature.ts +0 -67
  240. package/extensions/nextcloud-talk/src/types.ts +0 -179
  241. package/extensions/nostr/CHANGELOG.md +0 -46
  242. package/extensions/nostr/README.md +0 -136
  243. package/extensions/nostr/clawdbot.plugin.json +0 -11
  244. package/extensions/nostr/index.ts +0 -69
  245. package/extensions/nostr/package.json +0 -31
  246. package/extensions/nostr/src/channel.test.ts +0 -141
  247. package/extensions/nostr/src/channel.ts +0 -342
  248. package/extensions/nostr/src/config-schema.ts +0 -90
  249. package/extensions/nostr/src/metrics.ts +0 -464
  250. package/extensions/nostr/src/nostr-bus.fuzz.test.ts +0 -544
  251. package/extensions/nostr/src/nostr-bus.integration.test.ts +0 -452
  252. package/extensions/nostr/src/nostr-bus.test.ts +0 -199
  253. package/extensions/nostr/src/nostr-bus.ts +0 -741
  254. package/extensions/nostr/src/nostr-profile-http.test.ts +0 -378
  255. package/extensions/nostr/src/nostr-profile-http.ts +0 -500
  256. package/extensions/nostr/src/nostr-profile-import.test.ts +0 -120
  257. package/extensions/nostr/src/nostr-profile-import.ts +0 -259
  258. package/extensions/nostr/src/nostr-profile.fuzz.test.ts +0 -479
  259. package/extensions/nostr/src/nostr-profile.test.ts +0 -410
  260. package/extensions/nostr/src/nostr-profile.ts +0 -242
  261. package/extensions/nostr/src/nostr-state-store.test.ts +0 -128
  262. package/extensions/nostr/src/nostr-state-store.ts +0 -226
  263. package/extensions/nostr/src/runtime.ts +0 -14
  264. package/extensions/nostr/src/seen-tracker.ts +0 -271
  265. package/extensions/nostr/src/types.test.ts +0 -161
  266. package/extensions/nostr/src/types.ts +0 -99
  267. package/extensions/nostr/test/setup.ts +0 -5
  268. package/extensions/open-prose/README.md +0 -25
  269. package/extensions/open-prose/clawdbot.plugin.json +0 -11
  270. package/extensions/open-prose/index.ts +0 -5
  271. package/extensions/open-prose/package.json +0 -11
  272. package/extensions/open-prose/skills/prose/LICENSE +0 -21
  273. package/extensions/open-prose/skills/prose/SKILL.md +0 -318
  274. package/extensions/open-prose/skills/prose/alt-borges.md +0 -141
  275. package/extensions/open-prose/skills/prose/alts/arabian-nights.md +0 -358
  276. package/extensions/open-prose/skills/prose/alts/borges.md +0 -360
  277. package/extensions/open-prose/skills/prose/alts/folk.md +0 -322
  278. package/extensions/open-prose/skills/prose/alts/homer.md +0 -346
  279. package/extensions/open-prose/skills/prose/alts/kafka.md +0 -373
  280. package/extensions/open-prose/skills/prose/compiler.md +0 -2967
  281. package/extensions/open-prose/skills/prose/examples/01-hello-world.prose +0 -4
  282. package/extensions/open-prose/skills/prose/examples/02-research-and-summarize.prose +0 -6
  283. package/extensions/open-prose/skills/prose/examples/03-code-review.prose +0 -17
  284. package/extensions/open-prose/skills/prose/examples/04-write-and-refine.prose +0 -14
  285. package/extensions/open-prose/skills/prose/examples/05-debug-issue.prose +0 -20
  286. package/extensions/open-prose/skills/prose/examples/06-explain-codebase.prose +0 -17
  287. package/extensions/open-prose/skills/prose/examples/07-refactor.prose +0 -20
  288. package/extensions/open-prose/skills/prose/examples/08-blog-post.prose +0 -20
  289. package/extensions/open-prose/skills/prose/examples/09-research-with-agents.prose +0 -25
  290. package/extensions/open-prose/skills/prose/examples/10-code-review-agents.prose +0 -32
  291. package/extensions/open-prose/skills/prose/examples/11-skills-and-imports.prose +0 -27
  292. package/extensions/open-prose/skills/prose/examples/12-secure-agent-permissions.prose +0 -43
  293. package/extensions/open-prose/skills/prose/examples/13-variables-and-context.prose +0 -51
  294. package/extensions/open-prose/skills/prose/examples/14-composition-blocks.prose +0 -48
  295. package/extensions/open-prose/skills/prose/examples/15-inline-sequences.prose +0 -23
  296. package/extensions/open-prose/skills/prose/examples/16-parallel-reviews.prose +0 -19
  297. package/extensions/open-prose/skills/prose/examples/17-parallel-research.prose +0 -19
  298. package/extensions/open-prose/skills/prose/examples/18-mixed-parallel-sequential.prose +0 -36
  299. package/extensions/open-prose/skills/prose/examples/19-advanced-parallel.prose +0 -71
  300. package/extensions/open-prose/skills/prose/examples/20-fixed-loops.prose +0 -20
  301. package/extensions/open-prose/skills/prose/examples/21-pipeline-operations.prose +0 -35
  302. package/extensions/open-prose/skills/prose/examples/22-error-handling.prose +0 -51
  303. package/extensions/open-prose/skills/prose/examples/23-retry-with-backoff.prose +0 -63
  304. package/extensions/open-prose/skills/prose/examples/24-choice-blocks.prose +0 -86
  305. package/extensions/open-prose/skills/prose/examples/25-conditionals.prose +0 -114
  306. package/extensions/open-prose/skills/prose/examples/26-parameterized-blocks.prose +0 -100
  307. package/extensions/open-prose/skills/prose/examples/27-string-interpolation.prose +0 -105
  308. package/extensions/open-prose/skills/prose/examples/28-automated-pr-review.prose +0 -37
  309. package/extensions/open-prose/skills/prose/examples/28-gas-town.prose +0 -1572
  310. package/extensions/open-prose/skills/prose/examples/29-captains-chair.prose +0 -218
  311. package/extensions/open-prose/skills/prose/examples/30-captains-chair-simple.prose +0 -42
  312. package/extensions/open-prose/skills/prose/examples/31-captains-chair-with-memory.prose +0 -145
  313. package/extensions/open-prose/skills/prose/examples/33-pr-review-autofix.prose +0 -168
  314. package/extensions/open-prose/skills/prose/examples/34-content-pipeline.prose +0 -204
  315. package/extensions/open-prose/skills/prose/examples/35-feature-factory.prose +0 -296
  316. package/extensions/open-prose/skills/prose/examples/36-bug-hunter.prose +0 -237
  317. package/extensions/open-prose/skills/prose/examples/37-the-forge.prose +0 -1474
  318. package/extensions/open-prose/skills/prose/examples/38-skill-scan.prose +0 -455
  319. package/extensions/open-prose/skills/prose/examples/39-architect-by-simulation.prose +0 -277
  320. package/extensions/open-prose/skills/prose/examples/40-rlm-self-refine.prose +0 -32
  321. package/extensions/open-prose/skills/prose/examples/41-rlm-divide-conquer.prose +0 -38
  322. package/extensions/open-prose/skills/prose/examples/42-rlm-filter-recurse.prose +0 -46
  323. package/extensions/open-prose/skills/prose/examples/43-rlm-pairwise.prose +0 -50
  324. package/extensions/open-prose/skills/prose/examples/44-run-endpoint-ux-test.prose +0 -261
  325. package/extensions/open-prose/skills/prose/examples/45-plugin-release.prose +0 -159
  326. package/extensions/open-prose/skills/prose/examples/45-run-endpoint-ux-test-with-remediation.prose +0 -637
  327. package/extensions/open-prose/skills/prose/examples/46-run-endpoint-ux-test-fast.prose +0 -148
  328. package/extensions/open-prose/skills/prose/examples/46-workflow-crystallizer.prose +0 -225
  329. package/extensions/open-prose/skills/prose/examples/47-language-self-improvement.prose +0 -356
  330. package/extensions/open-prose/skills/prose/examples/48-habit-miner.prose +0 -445
  331. package/extensions/open-prose/skills/prose/examples/49-prose-run-retrospective.prose +0 -210
  332. package/extensions/open-prose/skills/prose/examples/README.md +0 -391
  333. package/extensions/open-prose/skills/prose/examples/roadmap/README.md +0 -22
  334. package/extensions/open-prose/skills/prose/examples/roadmap/iterative-refinement.prose +0 -20
  335. package/extensions/open-prose/skills/prose/examples/roadmap/parallel-review.prose +0 -18
  336. package/extensions/open-prose/skills/prose/examples/roadmap/simple-pipeline.prose +0 -17
  337. package/extensions/open-prose/skills/prose/examples/roadmap/syntax/open-prose-syntax.prose +0 -223
  338. package/extensions/open-prose/skills/prose/guidance/antipatterns.md +0 -951
  339. package/extensions/open-prose/skills/prose/guidance/patterns.md +0 -700
  340. package/extensions/open-prose/skills/prose/guidance/system-prompt.md +0 -180
  341. package/extensions/open-prose/skills/prose/help.md +0 -143
  342. package/extensions/open-prose/skills/prose/lib/README.md +0 -105
  343. package/extensions/open-prose/skills/prose/lib/calibrator.prose +0 -215
  344. package/extensions/open-prose/skills/prose/lib/cost-analyzer.prose +0 -174
  345. package/extensions/open-prose/skills/prose/lib/error-forensics.prose +0 -250
  346. package/extensions/open-prose/skills/prose/lib/inspector.prose +0 -196
  347. package/extensions/open-prose/skills/prose/lib/profiler.prose +0 -460
  348. package/extensions/open-prose/skills/prose/lib/program-improver.prose +0 -275
  349. package/extensions/open-prose/skills/prose/lib/project-memory.prose +0 -118
  350. package/extensions/open-prose/skills/prose/lib/user-memory.prose +0 -93
  351. package/extensions/open-prose/skills/prose/lib/vm-improver.prose +0 -243
  352. package/extensions/open-prose/skills/prose/primitives/session.md +0 -587
  353. package/extensions/open-prose/skills/prose/prose.md +0 -1235
  354. package/extensions/open-prose/skills/prose/state/filesystem.md +0 -478
  355. package/extensions/open-prose/skills/prose/state/in-context.md +0 -380
  356. package/extensions/open-prose/skills/prose/state/postgres.md +0 -875
  357. package/extensions/open-prose/skills/prose/state/sqlite.md +0 -572
  358. package/extensions/qwen-portal-auth/README.md +0 -24
  359. package/extensions/qwen-portal-auth/clawdbot.plugin.json +0 -11
  360. package/extensions/qwen-portal-auth/index.ts +0 -127
  361. package/extensions/qwen-portal-auth/oauth.ts +0 -190
  362. package/extensions/signal/clawdbot.plugin.json +0 -11
  363. package/extensions/signal/index.ts +0 -18
  364. package/extensions/signal/package.json +0 -11
  365. package/extensions/signal/src/channel.ts +0 -312
  366. package/extensions/signal/src/runtime.ts +0 -14
  367. package/extensions/telegram/clawdbot.plugin.json +0 -11
  368. package/extensions/telegram/index.ts +0 -18
  369. package/extensions/telegram/package.json +0 -11
  370. package/extensions/telegram/src/channel.ts +0 -478
  371. package/extensions/telegram/src/runtime.ts +0 -14
  372. package/extensions/tlon/README.md +0 -5
  373. package/extensions/tlon/clawdbot.plugin.json +0 -11
  374. package/extensions/tlon/index.ts +0 -18
  375. package/extensions/tlon/package.json +0 -30
  376. package/extensions/tlon/src/channel.ts +0 -379
  377. package/extensions/tlon/src/config-schema.test.ts +0 -32
  378. package/extensions/tlon/src/config-schema.ts +0 -43
  379. package/extensions/tlon/src/monitor/discovery.ts +0 -71
  380. package/extensions/tlon/src/monitor/history.ts +0 -87
  381. package/extensions/tlon/src/monitor/index.ts +0 -501
  382. package/extensions/tlon/src/monitor/processed-messages.test.ts +0 -24
  383. package/extensions/tlon/src/monitor/processed-messages.ts +0 -38
  384. package/extensions/tlon/src/monitor/utils.ts +0 -83
  385. package/extensions/tlon/src/onboarding.ts +0 -213
  386. package/extensions/tlon/src/runtime.ts +0 -14
  387. package/extensions/tlon/src/targets.ts +0 -79
  388. package/extensions/tlon/src/types.ts +0 -85
  389. package/extensions/tlon/src/urbit/auth.ts +0 -18
  390. package/extensions/tlon/src/urbit/http-api.ts +0 -36
  391. package/extensions/tlon/src/urbit/send.test.ts +0 -38
  392. package/extensions/tlon/src/urbit/send.ts +0 -127
  393. package/extensions/tlon/src/urbit/sse-client.test.ts +0 -41
  394. package/extensions/tlon/src/urbit/sse-client.ts +0 -367
  395. package/extensions/twitch/CHANGELOG.md +0 -21
  396. package/extensions/twitch/README.md +0 -89
  397. package/extensions/twitch/clawdbot.plugin.json +0 -9
  398. package/extensions/twitch/index.ts +0 -20
  399. package/extensions/twitch/package.json +0 -20
  400. package/extensions/twitch/src/access-control.test.ts +0 -489
  401. package/extensions/twitch/src/access-control.ts +0 -154
  402. package/extensions/twitch/src/actions.ts +0 -173
  403. package/extensions/twitch/src/client-manager-registry.ts +0 -115
  404. package/extensions/twitch/src/config-schema.ts +0 -82
  405. package/extensions/twitch/src/config.test.ts +0 -88
  406. package/extensions/twitch/src/config.ts +0 -116
  407. package/extensions/twitch/src/monitor.ts +0 -257
  408. package/extensions/twitch/src/onboarding.test.ts +0 -311
  409. package/extensions/twitch/src/onboarding.ts +0 -411
  410. package/extensions/twitch/src/outbound.test.ts +0 -373
  411. package/extensions/twitch/src/outbound.ts +0 -186
  412. package/extensions/twitch/src/plugin.test.ts +0 -39
  413. package/extensions/twitch/src/plugin.ts +0 -274
  414. package/extensions/twitch/src/probe.test.ts +0 -198
  415. package/extensions/twitch/src/probe.ts +0 -118
  416. package/extensions/twitch/src/resolver.ts +0 -137
  417. package/extensions/twitch/src/runtime.ts +0 -14
  418. package/extensions/twitch/src/send.test.ts +0 -289
  419. package/extensions/twitch/src/send.ts +0 -136
  420. package/extensions/twitch/src/status.test.ts +0 -270
  421. package/extensions/twitch/src/status.ts +0 -176
  422. package/extensions/twitch/src/token.test.ts +0 -171
  423. package/extensions/twitch/src/token.ts +0 -87
  424. package/extensions/twitch/src/twitch-client.test.ts +0 -574
  425. package/extensions/twitch/src/twitch-client.ts +0 -277
  426. package/extensions/twitch/src/types.ts +0 -141
  427. package/extensions/twitch/src/utils/markdown.ts +0 -92
  428. package/extensions/twitch/src/utils/twitch.ts +0 -78
  429. package/extensions/twitch/test/setup.ts +0 -7
  430. package/extensions/voice-call/CHANGELOG.md +0 -72
  431. package/extensions/voice-call/README.md +0 -134
  432. package/extensions/voice-call/clawdbot.plugin.json +0 -601
  433. package/extensions/voice-call/index.ts +0 -497
  434. package/extensions/voice-call/package.json +0 -16
  435. package/extensions/voice-call/src/cli.ts +0 -300
  436. package/extensions/voice-call/src/config.test.ts +0 -204
  437. package/extensions/voice-call/src/config.ts +0 -493
  438. package/extensions/voice-call/src/core-bridge.ts +0 -196
  439. package/extensions/voice-call/src/manager/context.ts +0 -21
  440. package/extensions/voice-call/src/manager/events.ts +0 -177
  441. package/extensions/voice-call/src/manager/lookup.ts +0 -33
  442. package/extensions/voice-call/src/manager/outbound.ts +0 -248
  443. package/extensions/voice-call/src/manager/state.ts +0 -50
  444. package/extensions/voice-call/src/manager/store.ts +0 -88
  445. package/extensions/voice-call/src/manager/timers.ts +0 -86
  446. package/extensions/voice-call/src/manager/twiml.ts +0 -9
  447. package/extensions/voice-call/src/manager.test.ts +0 -108
  448. package/extensions/voice-call/src/manager.ts +0 -876
  449. package/extensions/voice-call/src/media-stream.test.ts +0 -97
  450. package/extensions/voice-call/src/media-stream.ts +0 -393
  451. package/extensions/voice-call/src/providers/base.ts +0 -67
  452. package/extensions/voice-call/src/providers/index.ts +0 -10
  453. package/extensions/voice-call/src/providers/mock.ts +0 -168
  454. package/extensions/voice-call/src/providers/plivo.test.ts +0 -28
  455. package/extensions/voice-call/src/providers/plivo.ts +0 -504
  456. package/extensions/voice-call/src/providers/stt-openai-realtime.ts +0 -311
  457. package/extensions/voice-call/src/providers/telnyx.ts +0 -364
  458. package/extensions/voice-call/src/providers/tts-openai.ts +0 -264
  459. package/extensions/voice-call/src/providers/twilio/api.ts +0 -45
  460. package/extensions/voice-call/src/providers/twilio/webhook.ts +0 -29
  461. package/extensions/voice-call/src/providers/twilio.test.ts +0 -64
  462. package/extensions/voice-call/src/providers/twilio.ts +0 -595
  463. package/extensions/voice-call/src/response-generator.ts +0 -171
  464. package/extensions/voice-call/src/runtime.ts +0 -205
  465. package/extensions/voice-call/src/telephony-audio.ts +0 -88
  466. package/extensions/voice-call/src/telephony-tts.ts +0 -95
  467. package/extensions/voice-call/src/tunnel.ts +0 -331
  468. package/extensions/voice-call/src/types.ts +0 -272
  469. package/extensions/voice-call/src/utils.ts +0 -12
  470. package/extensions/voice-call/src/voice-mapping.ts +0 -65
  471. package/extensions/voice-call/src/webhook-security.test.ts +0 -233
  472. package/extensions/voice-call/src/webhook-security.ts +0 -446
  473. package/extensions/voice-call/src/webhook.ts +0 -490
  474. package/extensions/whatsapp/clawdbot.plugin.json +0 -11
  475. package/extensions/whatsapp/index.ts +0 -18
  476. package/extensions/whatsapp/package.json +0 -11
  477. package/extensions/whatsapp/src/channel.ts +0 -500
  478. package/extensions/whatsapp/src/runtime.ts +0 -14
  479. package/extensions/zalo/CHANGELOG.md +0 -55
  480. package/extensions/zalo/README.md +0 -50
  481. package/extensions/zalo/clawdbot.plugin.json +0 -11
  482. package/extensions/zalo/index.ts +0 -20
  483. package/extensions/zalo/package.json +0 -33
  484. package/extensions/zalo/src/accounts.ts +0 -71
  485. package/extensions/zalo/src/actions.ts +0 -62
  486. package/extensions/zalo/src/api.ts +0 -206
  487. package/extensions/zalo/src/channel.directory.test.ts +0 -35
  488. package/extensions/zalo/src/channel.ts +0 -394
  489. package/extensions/zalo/src/config-schema.ts +0 -24
  490. package/extensions/zalo/src/monitor.ts +0 -760
  491. package/extensions/zalo/src/monitor.webhook.test.ts +0 -70
  492. package/extensions/zalo/src/onboarding.ts +0 -405
  493. package/extensions/zalo/src/probe.ts +0 -46
  494. package/extensions/zalo/src/proxy.ts +0 -18
  495. package/extensions/zalo/src/runtime.ts +0 -14
  496. package/extensions/zalo/src/send.ts +0 -117
  497. package/extensions/zalo/src/status-issues.ts +0 -50
  498. package/extensions/zalo/src/token.ts +0 -55
  499. package/extensions/zalo/src/types.ts +0 -42
  500. package/extensions/zalouser/CHANGELOG.md +0 -33
  501. package/extensions/zalouser/README.md +0 -221
  502. package/extensions/zalouser/clawdbot.plugin.json +0 -11
  503. package/extensions/zalouser/index.ts +0 -32
  504. package/extensions/zalouser/package.json +0 -33
  505. package/extensions/zalouser/src/accounts.ts +0 -117
  506. package/extensions/zalouser/src/channel.test.ts +0 -17
  507. package/extensions/zalouser/src/channel.ts +0 -641
  508. package/extensions/zalouser/src/config-schema.ts +0 -27
  509. package/extensions/zalouser/src/monitor.ts +0 -574
  510. package/extensions/zalouser/src/onboarding.ts +0 -488
  511. package/extensions/zalouser/src/probe.ts +0 -28
  512. package/extensions/zalouser/src/runtime.ts +0 -14
  513. package/extensions/zalouser/src/send.ts +0 -150
  514. package/extensions/zalouser/src/status-issues.test.ts +0 -58
  515. package/extensions/zalouser/src/status-issues.ts +0 -81
  516. package/extensions/zalouser/src/tool.ts +0 -156
  517. package/extensions/zalouser/src/types.ts +0 -102
  518. package/extensions/zalouser/src/zca.ts +0 -208
  519. package/skills/1password/SKILL.md +0 -53
  520. package/skills/1password/references/cli-examples.md +0 -29
  521. package/skills/1password/references/get-started.md +0 -17
  522. package/skills/apple-notes/SKILL.md +0 -50
  523. package/skills/apple-reminders/SKILL.md +0 -67
  524. package/skills/bear-notes/SKILL.md +0 -79
  525. package/skills/bird/SKILL.md +0 -197
  526. package/skills/blogwatcher/SKILL.md +0 -46
  527. package/skills/blucli/SKILL.md +0 -27
  528. package/skills/bluebubbles/SKILL.md +0 -39
  529. package/skills/camsnap/SKILL.md +0 -25
  530. package/skills/canvas/SKILL.md +0 -189
  531. package/skills/clawdhub/SKILL.md +0 -53
  532. package/skills/coding-agent/SKILL.md +0 -278
  533. package/skills/discord/SKILL.md +0 -475
  534. package/skills/eightctl/SKILL.md +0 -29
  535. package/skills/food-order/SKILL.md +0 -41
  536. package/skills/gemini/SKILL.md +0 -23
  537. package/skills/gifgrep/SKILL.md +0 -47
  538. package/skills/github/SKILL.md +0 -48
  539. package/skills/gog/SKILL.md +0 -92
  540. package/skills/goplaces/SKILL.md +0 -30
  541. package/skills/himalaya/SKILL.md +0 -217
  542. package/skills/himalaya/references/configuration.md +0 -174
  543. package/skills/himalaya/references/message-composition.md +0 -182
  544. package/skills/imsg/SKILL.md +0 -25
  545. package/skills/local-places/SERVER_README.md +0 -101
  546. package/skills/local-places/SKILL.md +0 -91
  547. package/skills/local-places/pyproject.toml +0 -27
  548. package/skills/local-places/src/local_places/__init__.py +0 -2
  549. package/skills/local-places/src/local_places/google_places.py +0 -314
  550. package/skills/local-places/src/local_places/main.py +0 -65
  551. package/skills/local-places/src/local_places/schemas.py +0 -107
  552. package/skills/mcporter/SKILL.md +0 -38
  553. package/skills/model-usage/SKILL.md +0 -45
  554. package/skills/model-usage/references/codexbar-cli.md +0 -28
  555. package/skills/model-usage/scripts/model_usage.py +0 -310
  556. package/skills/nano-banana-pro/SKILL.md +0 -30
  557. package/skills/nano-banana-pro/scripts/generate_image.py +0 -169
  558. package/skills/nano-pdf/SKILL.md +0 -20
  559. package/skills/notion/SKILL.md +0 -156
  560. package/skills/obsidian/SKILL.md +0 -55
  561. package/skills/openai-image-gen/SKILL.md +0 -71
  562. package/skills/openai-image-gen/scripts/gen.py +0 -240
  563. package/skills/openai-whisper/SKILL.md +0 -19
  564. package/skills/openai-whisper-api/SKILL.md +0 -43
  565. package/skills/openai-whisper-api/scripts/transcribe.sh +0 -85
  566. package/skills/openhue/SKILL.md +0 -30
  567. package/skills/oracle/SKILL.md +0 -105
  568. package/skills/ordercli/SKILL.md +0 -47
  569. package/skills/peekaboo/SKILL.md +0 -153
  570. package/skills/sag/SKILL.md +0 -62
  571. package/skills/session-logs/SKILL.md +0 -105
  572. package/skills/sherpa-onnx-tts/SKILL.md +0 -49
  573. package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +0 -178
  574. package/skills/skill-creator/SKILL.md +0 -371
  575. package/skills/skill-creator/license.txt +0 -202
  576. package/skills/skill-creator/scripts/init_skill.py +0 -378
  577. package/skills/skill-creator/scripts/package_skill.py +0 -111
  578. package/skills/skill-creator/scripts/quick_validate.py +0 -101
  579. package/skills/slack/SKILL.md +0 -144
  580. package/skills/songsee/SKILL.md +0 -29
  581. package/skills/sonoscli/SKILL.md +0 -26
  582. package/skills/spotify-player/SKILL.md +0 -34
  583. package/skills/summarize/SKILL.md +0 -67
  584. package/skills/things-mac/SKILL.md +0 -61
  585. package/skills/tmux/SKILL.md +0 -121
  586. package/skills/tmux/scripts/find-sessions.sh +0 -112
  587. package/skills/tmux/scripts/wait-for-text.sh +0 -83
  588. package/skills/trello/SKILL.md +0 -84
  589. package/skills/video-frames/SKILL.md +0 -29
  590. package/skills/video-frames/scripts/frame.sh +0 -81
  591. package/skills/voice-call/SKILL.md +0 -35
  592. package/skills/wacli/SKILL.md +0 -42
  593. package/skills/weather/SKILL.md +0 -49
@@ -1,876 +0,0 @@
1
- import crypto from "node:crypto";
2
- import fs from "node:fs";
3
- import fsp from "node:fs/promises";
4
- import os from "node:os";
5
- import path from "node:path";
6
-
7
- import { resolveUserPath } from "./utils.js";
8
- import type { CallMode, VoiceCallConfig } from "./config.js";
9
- import type { VoiceCallProvider } from "./providers/base.js";
10
- import {
11
- type CallId,
12
- type CallRecord,
13
- CallRecordSchema,
14
- type CallState,
15
- type NormalizedEvent,
16
- type OutboundCallOptions,
17
- TerminalStates,
18
- type TranscriptEntry,
19
- } from "./types.js";
20
- import { escapeXml, mapVoiceToPolly } from "./voice-mapping.js";
21
-
22
- /**
23
- * Manages voice calls: state machine, persistence, and provider coordination.
24
- */
25
- export class CallManager {
26
- private activeCalls = new Map<CallId, CallRecord>();
27
- private providerCallIdMap = new Map<string, CallId>(); // providerCallId -> internal callId
28
- private processedEventIds = new Set<string>();
29
- private provider: VoiceCallProvider | null = null;
30
- private config: VoiceCallConfig;
31
- private storePath: string;
32
- private webhookUrl: string | null = null;
33
- private transcriptWaiters = new Map<
34
- CallId,
35
- {
36
- resolve: (text: string) => void;
37
- reject: (err: Error) => void;
38
- timeout: NodeJS.Timeout;
39
- }
40
- >();
41
- /** Max duration timers to auto-hangup calls after configured timeout */
42
- private maxDurationTimers = new Map<CallId, NodeJS.Timeout>();
43
-
44
- constructor(config: VoiceCallConfig, storePath?: string) {
45
- this.config = config;
46
- // Resolve store path with tilde expansion (like other config values)
47
- const rawPath =
48
- storePath ||
49
- config.store ||
50
- path.join(os.homedir(), "clawd", "voice-calls");
51
- this.storePath = resolveUserPath(rawPath);
52
- }
53
-
54
- /**
55
- * Initialize the call manager with a provider.
56
- */
57
- initialize(provider: VoiceCallProvider, webhookUrl: string): void {
58
- this.provider = provider;
59
- this.webhookUrl = webhookUrl;
60
-
61
- // Ensure store directory exists
62
- fs.mkdirSync(this.storePath, { recursive: true });
63
-
64
- // Load any persisted active calls
65
- this.loadActiveCalls();
66
- }
67
-
68
- /**
69
- * Get the current provider.
70
- */
71
- getProvider(): VoiceCallProvider | null {
72
- return this.provider;
73
- }
74
-
75
- /**
76
- * Initiate an outbound call.
77
- * @param to - The phone number to call
78
- * @param sessionKey - Optional session key for context
79
- * @param options - Optional call options (message, mode)
80
- */
81
- async initiateCall(
82
- to: string,
83
- sessionKey?: string,
84
- options?: OutboundCallOptions | string,
85
- ): Promise<{ callId: CallId; success: boolean; error?: string }> {
86
- // Support legacy string argument for initialMessage
87
- const opts: OutboundCallOptions =
88
- typeof options === "string" ? { message: options } : (options ?? {});
89
- const initialMessage = opts.message;
90
- const mode = opts.mode ?? this.config.outbound.defaultMode;
91
- if (!this.provider) {
92
- return { callId: "", success: false, error: "Provider not initialized" };
93
- }
94
-
95
- if (!this.webhookUrl) {
96
- return {
97
- callId: "",
98
- success: false,
99
- error: "Webhook URL not configured",
100
- };
101
- }
102
-
103
- // Check concurrent call limit
104
- const activeCalls = this.getActiveCalls();
105
- if (activeCalls.length >= this.config.maxConcurrentCalls) {
106
- return {
107
- callId: "",
108
- success: false,
109
- error: `Maximum concurrent calls (${this.config.maxConcurrentCalls}) reached`,
110
- };
111
- }
112
-
113
- const callId = crypto.randomUUID();
114
- const from =
115
- this.config.fromNumber ||
116
- (this.provider?.name === "mock" ? "+15550000000" : undefined);
117
- if (!from) {
118
- return { callId: "", success: false, error: "fromNumber not configured" };
119
- }
120
-
121
- // Create call record with mode in metadata
122
- const callRecord: CallRecord = {
123
- callId,
124
- provider: this.provider.name,
125
- direction: "outbound",
126
- state: "initiated",
127
- from,
128
- to,
129
- sessionKey,
130
- startedAt: Date.now(),
131
- transcript: [],
132
- processedEventIds: [],
133
- metadata: {
134
- ...(initialMessage && { initialMessage }),
135
- mode,
136
- },
137
- };
138
-
139
- this.activeCalls.set(callId, callRecord);
140
- this.persistCallRecord(callRecord);
141
-
142
- try {
143
- // For notify mode with a message, use inline TwiML with <Say>
144
- let inlineTwiml: string | undefined;
145
- if (mode === "notify" && initialMessage) {
146
- const pollyVoice = mapVoiceToPolly(this.config.tts?.openai?.voice);
147
- inlineTwiml = this.generateNotifyTwiml(initialMessage, pollyVoice);
148
- console.log(
149
- `[voice-call] Using inline TwiML for notify mode (voice: ${pollyVoice})`,
150
- );
151
- }
152
-
153
- const result = await this.provider.initiateCall({
154
- callId,
155
- from,
156
- to,
157
- webhookUrl: this.webhookUrl,
158
- inlineTwiml,
159
- });
160
-
161
- callRecord.providerCallId = result.providerCallId;
162
- this.providerCallIdMap.set(result.providerCallId, callId); // Map providerCallId to internal callId
163
- this.persistCallRecord(callRecord);
164
-
165
- return { callId, success: true };
166
- } catch (err) {
167
- callRecord.state = "failed";
168
- callRecord.endedAt = Date.now();
169
- callRecord.endReason = "failed";
170
- this.persistCallRecord(callRecord);
171
- this.activeCalls.delete(callId);
172
- if (callRecord.providerCallId) {
173
- this.providerCallIdMap.delete(callRecord.providerCallId);
174
- }
175
-
176
- return {
177
- callId,
178
- success: false,
179
- error: err instanceof Error ? err.message : String(err),
180
- };
181
- }
182
- }
183
-
184
- /**
185
- * Speak to user in an active call.
186
- */
187
- async speak(
188
- callId: CallId,
189
- text: string,
190
- ): Promise<{ success: boolean; error?: string }> {
191
- const call = this.activeCalls.get(callId);
192
- if (!call) {
193
- return { success: false, error: "Call not found" };
194
- }
195
-
196
- if (!this.provider || !call.providerCallId) {
197
- return { success: false, error: "Call not connected" };
198
- }
199
-
200
- if (TerminalStates.has(call.state)) {
201
- return { success: false, error: "Call has ended" };
202
- }
203
-
204
- try {
205
- // Update state
206
- call.state = "speaking";
207
- this.persistCallRecord(call);
208
-
209
- // Add to transcript
210
- this.addTranscriptEntry(call, "bot", text);
211
-
212
- // Play TTS
213
- const voice =
214
- this.provider?.name === "twilio" ? this.config.tts?.openai?.voice : undefined;
215
- await this.provider.playTts({
216
- callId,
217
- providerCallId: call.providerCallId,
218
- text,
219
- voice,
220
- });
221
-
222
- return { success: true };
223
- } catch (err) {
224
- return {
225
- success: false,
226
- error: err instanceof Error ? err.message : String(err),
227
- };
228
- }
229
- }
230
-
231
- /**
232
- * Speak the initial message for a call (called when media stream connects).
233
- * This is used to auto-play the message passed to initiateCall.
234
- * In notify mode, auto-hangup after the message is delivered.
235
- */
236
- async speakInitialMessage(providerCallId: string): Promise<void> {
237
- const call = this.getCallByProviderCallId(providerCallId);
238
- if (!call) {
239
- console.warn(
240
- `[voice-call] speakInitialMessage: no call found for ${providerCallId}`,
241
- );
242
- return;
243
- }
244
-
245
- const initialMessage = call.metadata?.initialMessage as string | undefined;
246
- const mode = (call.metadata?.mode as CallMode) ?? "conversation";
247
-
248
- if (!initialMessage) {
249
- console.log(
250
- `[voice-call] speakInitialMessage: no initial message for ${call.callId}`,
251
- );
252
- return;
253
- }
254
-
255
- // Clear the initial message so we don't speak it again
256
- if (call.metadata) {
257
- delete call.metadata.initialMessage;
258
- this.persistCallRecord(call);
259
- }
260
-
261
- console.log(
262
- `[voice-call] Speaking initial message for call ${call.callId} (mode: ${mode})`,
263
- );
264
- const result = await this.speak(call.callId, initialMessage);
265
- if (!result.success) {
266
- console.warn(
267
- `[voice-call] Failed to speak initial message: ${result.error}`,
268
- );
269
- return;
270
- }
271
-
272
- // In notify mode, auto-hangup after delay
273
- if (mode === "notify") {
274
- const delaySec = this.config.outbound.notifyHangupDelaySec;
275
- console.log(
276
- `[voice-call] Notify mode: auto-hangup in ${delaySec}s for call ${call.callId}`,
277
- );
278
- setTimeout(async () => {
279
- const currentCall = this.getCall(call.callId);
280
- if (currentCall && !TerminalStates.has(currentCall.state)) {
281
- console.log(
282
- `[voice-call] Notify mode: hanging up call ${call.callId}`,
283
- );
284
- await this.endCall(call.callId);
285
- }
286
- }, delaySec * 1000);
287
- }
288
- }
289
-
290
- /**
291
- * Start max duration timer for a call.
292
- * Auto-hangup when maxDurationSeconds is reached.
293
- */
294
- private startMaxDurationTimer(callId: CallId): void {
295
- // Clear any existing timer
296
- this.clearMaxDurationTimer(callId);
297
-
298
- const maxDurationMs = this.config.maxDurationSeconds * 1000;
299
- console.log(
300
- `[voice-call] Starting max duration timer (${this.config.maxDurationSeconds}s) for call ${callId}`,
301
- );
302
-
303
- const timer = setTimeout(async () => {
304
- this.maxDurationTimers.delete(callId);
305
- const call = this.getCall(callId);
306
- if (call && !TerminalStates.has(call.state)) {
307
- console.log(
308
- `[voice-call] Max duration reached (${this.config.maxDurationSeconds}s), ending call ${callId}`,
309
- );
310
- call.endReason = "timeout";
311
- this.persistCallRecord(call);
312
- await this.endCall(callId);
313
- }
314
- }, maxDurationMs);
315
-
316
- this.maxDurationTimers.set(callId, timer);
317
- }
318
-
319
- /**
320
- * Clear max duration timer for a call.
321
- */
322
- private clearMaxDurationTimer(callId: CallId): void {
323
- const timer = this.maxDurationTimers.get(callId);
324
- if (timer) {
325
- clearTimeout(timer);
326
- this.maxDurationTimers.delete(callId);
327
- }
328
- }
329
-
330
- private clearTranscriptWaiter(callId: CallId): void {
331
- const waiter = this.transcriptWaiters.get(callId);
332
- if (!waiter) return;
333
- clearTimeout(waiter.timeout);
334
- this.transcriptWaiters.delete(callId);
335
- }
336
-
337
- private rejectTranscriptWaiter(callId: CallId, reason: string): void {
338
- const waiter = this.transcriptWaiters.get(callId);
339
- if (!waiter) return;
340
- this.clearTranscriptWaiter(callId);
341
- waiter.reject(new Error(reason));
342
- }
343
-
344
- private resolveTranscriptWaiter(callId: CallId, transcript: string): void {
345
- const waiter = this.transcriptWaiters.get(callId);
346
- if (!waiter) return;
347
- this.clearTranscriptWaiter(callId);
348
- waiter.resolve(transcript);
349
- }
350
-
351
- private waitForFinalTranscript(callId: CallId): Promise<string> {
352
- // Only allow one in-flight waiter per call.
353
- this.rejectTranscriptWaiter(callId, "Transcript waiter replaced");
354
-
355
- const timeoutMs = this.config.transcriptTimeoutMs;
356
- return new Promise((resolve, reject) => {
357
- const timeout = setTimeout(() => {
358
- this.transcriptWaiters.delete(callId);
359
- reject(
360
- new Error(`Timed out waiting for transcript after ${timeoutMs}ms`),
361
- );
362
- }, timeoutMs);
363
-
364
- this.transcriptWaiters.set(callId, { resolve, reject, timeout });
365
- });
366
- }
367
-
368
- /**
369
- * Continue call: speak prompt, then wait for user's final transcript.
370
- */
371
- async continueCall(
372
- callId: CallId,
373
- prompt: string,
374
- ): Promise<{ success: boolean; transcript?: string; error?: string }> {
375
- const call = this.activeCalls.get(callId);
376
- if (!call) {
377
- return { success: false, error: "Call not found" };
378
- }
379
-
380
- if (!this.provider || !call.providerCallId) {
381
- return { success: false, error: "Call not connected" };
382
- }
383
-
384
- if (TerminalStates.has(call.state)) {
385
- return { success: false, error: "Call has ended" };
386
- }
387
-
388
- try {
389
- await this.speak(callId, prompt);
390
-
391
- call.state = "listening";
392
- this.persistCallRecord(call);
393
-
394
- await this.provider.startListening({
395
- callId,
396
- providerCallId: call.providerCallId,
397
- });
398
-
399
- const transcript = await this.waitForFinalTranscript(callId);
400
-
401
- // Best-effort: stop listening after final transcript.
402
- await this.provider.stopListening({
403
- callId,
404
- providerCallId: call.providerCallId,
405
- });
406
-
407
- return { success: true, transcript };
408
- } catch (err) {
409
- return {
410
- success: false,
411
- error: err instanceof Error ? err.message : String(err),
412
- };
413
- } finally {
414
- this.clearTranscriptWaiter(callId);
415
- }
416
- }
417
-
418
- /**
419
- * End an active call.
420
- */
421
- async endCall(callId: CallId): Promise<{ success: boolean; error?: string }> {
422
- const call = this.activeCalls.get(callId);
423
- if (!call) {
424
- return { success: false, error: "Call not found" };
425
- }
426
-
427
- if (!this.provider || !call.providerCallId) {
428
- return { success: false, error: "Call not connected" };
429
- }
430
-
431
- if (TerminalStates.has(call.state)) {
432
- return { success: true }; // Already ended
433
- }
434
-
435
- try {
436
- await this.provider.hangupCall({
437
- callId,
438
- providerCallId: call.providerCallId,
439
- reason: "hangup-bot",
440
- });
441
-
442
- call.state = "hangup-bot";
443
- call.endedAt = Date.now();
444
- call.endReason = "hangup-bot";
445
- this.persistCallRecord(call);
446
- this.clearMaxDurationTimer(callId);
447
- this.rejectTranscriptWaiter(callId, "Call ended: hangup-bot");
448
- this.activeCalls.delete(callId);
449
- if (call.providerCallId) {
450
- this.providerCallIdMap.delete(call.providerCallId);
451
- }
452
-
453
- return { success: true };
454
- } catch (err) {
455
- return {
456
- success: false,
457
- error: err instanceof Error ? err.message : String(err),
458
- };
459
- }
460
- }
461
-
462
- /**
463
- * Check if an inbound call should be accepted based on policy.
464
- */
465
- private shouldAcceptInbound(from: string | undefined): boolean {
466
- const { inboundPolicy: policy, allowFrom } = this.config;
467
-
468
- switch (policy) {
469
- case "disabled":
470
- console.log("[voice-call] Inbound call rejected: policy is disabled");
471
- return false;
472
-
473
- case "open":
474
- console.log("[voice-call] Inbound call accepted: policy is open");
475
- return true;
476
-
477
- case "allowlist":
478
- case "pairing": {
479
- const normalized = from?.replace(/\D/g, "") || "";
480
- const allowed = (allowFrom || []).some((num) => {
481
- const normalizedAllow = num.replace(/\D/g, "");
482
- return (
483
- normalized.endsWith(normalizedAllow) ||
484
- normalizedAllow.endsWith(normalized)
485
- );
486
- });
487
- const status = allowed ? "accepted" : "rejected";
488
- console.log(
489
- `[voice-call] Inbound call ${status}: ${from} ${allowed ? "is in" : "not in"} allowlist`,
490
- );
491
- return allowed;
492
- }
493
-
494
- default:
495
- return false;
496
- }
497
- }
498
-
499
- /**
500
- * Create a call record for an inbound call.
501
- */
502
- private createInboundCall(
503
- providerCallId: string,
504
- from: string,
505
- to: string,
506
- ): CallRecord {
507
- const callId = crypto.randomUUID();
508
-
509
- const callRecord: CallRecord = {
510
- callId,
511
- providerCallId,
512
- provider: this.provider?.name || "twilio",
513
- direction: "inbound",
514
- state: "ringing",
515
- from,
516
- to,
517
- startedAt: Date.now(),
518
- transcript: [],
519
- processedEventIds: [],
520
- metadata: {
521
- initialMessage:
522
- this.config.inboundGreeting || "Hello! How can I help you today?",
523
- },
524
- };
525
-
526
- this.activeCalls.set(callId, callRecord);
527
- this.providerCallIdMap.set(providerCallId, callId); // Map providerCallId to internal callId
528
- this.persistCallRecord(callRecord);
529
-
530
- console.log(
531
- `[voice-call] Created inbound call record: ${callId} from ${from}`,
532
- );
533
- return callRecord;
534
- }
535
-
536
- /**
537
- * Look up a call by either internal callId or providerCallId.
538
- */
539
- private findCall(callIdOrProviderCallId: string): CallRecord | undefined {
540
- // Try direct lookup by internal callId
541
- const directCall = this.activeCalls.get(callIdOrProviderCallId);
542
- if (directCall) return directCall;
543
-
544
- // Try lookup by providerCallId
545
- return this.getCallByProviderCallId(callIdOrProviderCallId);
546
- }
547
-
548
- /**
549
- * Process a webhook event.
550
- */
551
- processEvent(event: NormalizedEvent): void {
552
- // Idempotency check
553
- if (this.processedEventIds.has(event.id)) {
554
- return;
555
- }
556
- this.processedEventIds.add(event.id);
557
-
558
- let call = this.findCall(event.callId);
559
-
560
- // Handle inbound calls - create record if it doesn't exist
561
- if (!call && event.direction === "inbound" && event.providerCallId) {
562
- // Check if we should accept this inbound call
563
- if (!this.shouldAcceptInbound(event.from)) {
564
- // TODO: Could hang up the call here
565
- return;
566
- }
567
-
568
- // Create a new call record for this inbound call
569
- call = this.createInboundCall(
570
- event.providerCallId,
571
- event.from || "unknown",
572
- event.to || this.config.fromNumber || "unknown",
573
- );
574
-
575
- // Update the event's callId to use our internal ID
576
- event.callId = call.callId;
577
- }
578
-
579
- if (!call) {
580
- // Still no call record - ignore event
581
- return;
582
- }
583
-
584
- // Update provider call ID if we got it
585
- if (event.providerCallId && event.providerCallId !== call.providerCallId) {
586
- const previousProviderCallId = call.providerCallId;
587
- call.providerCallId = event.providerCallId;
588
- this.providerCallIdMap.set(event.providerCallId, call.callId);
589
- if (previousProviderCallId) {
590
- const mapped = this.providerCallIdMap.get(previousProviderCallId);
591
- if (mapped === call.callId) {
592
- this.providerCallIdMap.delete(previousProviderCallId);
593
- }
594
- }
595
- }
596
-
597
- // Track processed event
598
- call.processedEventIds.push(event.id);
599
-
600
- // Process event based on type
601
- switch (event.type) {
602
- case "call.initiated":
603
- this.transitionState(call, "initiated");
604
- break;
605
-
606
- case "call.ringing":
607
- this.transitionState(call, "ringing");
608
- break;
609
-
610
- case "call.answered":
611
- call.answeredAt = event.timestamp;
612
- this.transitionState(call, "answered");
613
- // Start max duration timer when call is answered
614
- this.startMaxDurationTimer(call.callId);
615
- // Best-effort: speak initial message (for inbound greetings and outbound
616
- // conversation mode) once the call is answered.
617
- this.maybeSpeakInitialMessageOnAnswered(call);
618
- break;
619
-
620
- case "call.active":
621
- this.transitionState(call, "active");
622
- break;
623
-
624
- case "call.speaking":
625
- this.transitionState(call, "speaking");
626
- break;
627
-
628
- case "call.speech":
629
- if (event.isFinal) {
630
- this.addTranscriptEntry(call, "user", event.transcript);
631
- this.resolveTranscriptWaiter(call.callId, event.transcript);
632
- }
633
- this.transitionState(call, "listening");
634
- break;
635
-
636
- case "call.ended":
637
- call.endedAt = event.timestamp;
638
- call.endReason = event.reason;
639
- this.transitionState(call, event.reason as CallState);
640
- this.clearMaxDurationTimer(call.callId);
641
- this.rejectTranscriptWaiter(call.callId, `Call ended: ${event.reason}`);
642
- this.activeCalls.delete(call.callId);
643
- if (call.providerCallId) {
644
- this.providerCallIdMap.delete(call.providerCallId);
645
- }
646
- break;
647
-
648
- case "call.error":
649
- if (!event.retryable) {
650
- call.endedAt = event.timestamp;
651
- call.endReason = "error";
652
- this.transitionState(call, "error");
653
- this.clearMaxDurationTimer(call.callId);
654
- this.rejectTranscriptWaiter(
655
- call.callId,
656
- `Call error: ${event.error}`,
657
- );
658
- this.activeCalls.delete(call.callId);
659
- if (call.providerCallId) {
660
- this.providerCallIdMap.delete(call.providerCallId);
661
- }
662
- }
663
- break;
664
- }
665
-
666
- this.persistCallRecord(call);
667
- }
668
-
669
- private maybeSpeakInitialMessageOnAnswered(call: CallRecord): void {
670
- const initialMessage =
671
- typeof call.metadata?.initialMessage === "string"
672
- ? call.metadata.initialMessage.trim()
673
- : "";
674
-
675
- if (!initialMessage) return;
676
-
677
- if (!this.provider || !call.providerCallId) return;
678
-
679
- // Twilio has provider-specific state for speaking (<Say> fallback) and can
680
- // fail for inbound calls; keep existing Twilio behavior unchanged.
681
- if (this.provider.name === "twilio") return;
682
-
683
- void this.speakInitialMessage(call.providerCallId);
684
- }
685
-
686
- /**
687
- * Get an active call by ID.
688
- */
689
- getCall(callId: CallId): CallRecord | undefined {
690
- return this.activeCalls.get(callId);
691
- }
692
-
693
- /**
694
- * Get an active call by provider call ID (e.g., Twilio CallSid).
695
- */
696
- getCallByProviderCallId(providerCallId: string): CallRecord | undefined {
697
- // Fast path: use the providerCallIdMap for O(1) lookup
698
- const callId = this.providerCallIdMap.get(providerCallId);
699
- if (callId) {
700
- return this.activeCalls.get(callId);
701
- }
702
-
703
- // Fallback: linear search for cases where map wasn't populated
704
- // (e.g., providerCallId set directly on call record)
705
- for (const call of this.activeCalls.values()) {
706
- if (call.providerCallId === providerCallId) {
707
- return call;
708
- }
709
- }
710
- return undefined;
711
- }
712
-
713
- /**
714
- * Get all active calls.
715
- */
716
- getActiveCalls(): CallRecord[] {
717
- return Array.from(this.activeCalls.values());
718
- }
719
-
720
- /**
721
- * Get call history (from persisted logs).
722
- */
723
- async getCallHistory(limit = 50): Promise<CallRecord[]> {
724
- const logPath = path.join(this.storePath, "calls.jsonl");
725
-
726
- try {
727
- await fsp.access(logPath);
728
- } catch {
729
- return [];
730
- }
731
-
732
- const content = await fsp.readFile(logPath, "utf-8");
733
- const lines = content.trim().split("\n").filter(Boolean);
734
- const calls: CallRecord[] = [];
735
-
736
- // Parse last N lines
737
- for (const line of lines.slice(-limit)) {
738
- try {
739
- const parsed = CallRecordSchema.parse(JSON.parse(line));
740
- calls.push(parsed);
741
- } catch {
742
- // Skip invalid lines
743
- }
744
- }
745
-
746
- return calls;
747
- }
748
-
749
- // States that can cycle during multi-turn conversations
750
- private static readonly ConversationStates = new Set<CallState>([
751
- "speaking",
752
- "listening",
753
- ]);
754
-
755
- // Non-terminal state order for monotonic transitions
756
- private static readonly StateOrder: readonly CallState[] = [
757
- "initiated",
758
- "ringing",
759
- "answered",
760
- "active",
761
- "speaking",
762
- "listening",
763
- ];
764
-
765
- /**
766
- * Transition call state with monotonic enforcement.
767
- */
768
- private transitionState(call: CallRecord, newState: CallState): void {
769
- // No-op for same state or already terminal
770
- if (call.state === newState || TerminalStates.has(call.state)) return;
771
-
772
- // Terminal states can always be reached from non-terminal
773
- if (TerminalStates.has(newState)) {
774
- call.state = newState;
775
- return;
776
- }
777
-
778
- // Allow cycling between speaking and listening (multi-turn conversations)
779
- if (
780
- CallManager.ConversationStates.has(call.state) &&
781
- CallManager.ConversationStates.has(newState)
782
- ) {
783
- call.state = newState;
784
- return;
785
- }
786
-
787
- // Only allow forward transitions in state order
788
- const currentIndex = CallManager.StateOrder.indexOf(call.state);
789
- const newIndex = CallManager.StateOrder.indexOf(newState);
790
-
791
- if (newIndex > currentIndex) {
792
- call.state = newState;
793
- }
794
- }
795
-
796
- /**
797
- * Add an entry to the call transcript.
798
- */
799
- private addTranscriptEntry(
800
- call: CallRecord,
801
- speaker: "bot" | "user",
802
- text: string,
803
- ): void {
804
- const entry: TranscriptEntry = {
805
- timestamp: Date.now(),
806
- speaker,
807
- text,
808
- isFinal: true,
809
- };
810
- call.transcript.push(entry);
811
- }
812
-
813
- /**
814
- * Persist a call record to disk (fire-and-forget async).
815
- */
816
- private persistCallRecord(call: CallRecord): void {
817
- const logPath = path.join(this.storePath, "calls.jsonl");
818
- const line = `${JSON.stringify(call)}\n`;
819
- // Fire-and-forget async write to avoid blocking event loop
820
- fsp.appendFile(logPath, line).catch((err) => {
821
- console.error("[voice-call] Failed to persist call record:", err);
822
- });
823
- }
824
-
825
- /**
826
- * Load active calls from persistence (for crash recovery).
827
- * Uses streaming to handle large log files efficiently.
828
- */
829
- private loadActiveCalls(): void {
830
- const logPath = path.join(this.storePath, "calls.jsonl");
831
- if (!fs.existsSync(logPath)) return;
832
-
833
- // Read file synchronously and parse lines
834
- const content = fs.readFileSync(logPath, "utf-8");
835
- const lines = content.split("\n");
836
-
837
- // Build map of latest state per call
838
- const callMap = new Map<CallId, CallRecord>();
839
-
840
- for (const line of lines) {
841
- if (!line.trim()) continue;
842
- try {
843
- const call = CallRecordSchema.parse(JSON.parse(line));
844
- callMap.set(call.callId, call);
845
- } catch {
846
- // Skip invalid lines
847
- }
848
- }
849
-
850
- // Only keep non-terminal calls
851
- for (const [callId, call] of callMap) {
852
- if (!TerminalStates.has(call.state)) {
853
- this.activeCalls.set(callId, call);
854
- // Populate providerCallId mapping for lookups
855
- if (call.providerCallId) {
856
- this.providerCallIdMap.set(call.providerCallId, callId);
857
- }
858
- // Populate processed event IDs
859
- for (const eventId of call.processedEventIds) {
860
- this.processedEventIds.add(eventId);
861
- }
862
- }
863
- }
864
- }
865
-
866
- /**
867
- * Generate TwiML for notify mode (speak message and hang up).
868
- */
869
- private generateNotifyTwiml(message: string, voice: string): string {
870
- return `<?xml version="1.0" encoding="UTF-8"?>
871
- <Response>
872
- <Say voice="${voice}">${escapeXml(message)}</Say>
873
- <Hangup/>
874
- </Response>`;
875
- }
876
- }