aidevops 2.52.1

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 (329) hide show
  1. package/.agent/AGENTS.md +614 -0
  2. package/.agent/accounts.md +65 -0
  3. package/.agent/aidevops/add-new-mcp-to-aidevops.md +456 -0
  4. package/.agent/aidevops/api-integrations.md +335 -0
  5. package/.agent/aidevops/architecture.md +510 -0
  6. package/.agent/aidevops/configs.md +274 -0
  7. package/.agent/aidevops/docs.md +244 -0
  8. package/.agent/aidevops/extension.md +311 -0
  9. package/.agent/aidevops/mcp-integrations.md +340 -0
  10. package/.agent/aidevops/mcp-troubleshooting.md +162 -0
  11. package/.agent/aidevops/memory-patterns.md +172 -0
  12. package/.agent/aidevops/providers.md +217 -0
  13. package/.agent/aidevops/recommendations.md +321 -0
  14. package/.agent/aidevops/requirements.md +301 -0
  15. package/.agent/aidevops/resources.md +214 -0
  16. package/.agent/aidevops/security-requirements.md +174 -0
  17. package/.agent/aidevops/security.md +350 -0
  18. package/.agent/aidevops/service-links.md +400 -0
  19. package/.agent/aidevops/services.md +357 -0
  20. package/.agent/aidevops/setup.md +153 -0
  21. package/.agent/aidevops/troubleshooting.md +389 -0
  22. package/.agent/aidevops.md +124 -0
  23. package/.agent/build-plus.md +244 -0
  24. package/.agent/content/guidelines.md +109 -0
  25. package/.agent/content.md +87 -0
  26. package/.agent/health.md +59 -0
  27. package/.agent/legal.md +59 -0
  28. package/.agent/loop-state/full-loop.local.md +16 -0
  29. package/.agent/loop-state/ralph-loop.local.md +10 -0
  30. package/.agent/marketing.md +440 -0
  31. package/.agent/memory/README.md +260 -0
  32. package/.agent/onboarding.md +796 -0
  33. package/.agent/plan-plus.md +245 -0
  34. package/.agent/research.md +100 -0
  35. package/.agent/sales.md +333 -0
  36. package/.agent/scripts/101domains-helper.sh +701 -0
  37. package/.agent/scripts/add-missing-returns.sh +140 -0
  38. package/.agent/scripts/agent-browser-helper.sh +311 -0
  39. package/.agent/scripts/agno-setup.sh +712 -0
  40. package/.agent/scripts/ahrefs-mcp-wrapper.js +168 -0
  41. package/.agent/scripts/aidevops-update-check.sh +71 -0
  42. package/.agent/scripts/ampcode-cli.sh +522 -0
  43. package/.agent/scripts/auto-version-bump.sh +156 -0
  44. package/.agent/scripts/autogen-helper.sh +512 -0
  45. package/.agent/scripts/beads-sync-helper.sh +596 -0
  46. package/.agent/scripts/closte-helper.sh +5 -0
  47. package/.agent/scripts/cloudron-helper.sh +321 -0
  48. package/.agent/scripts/codacy-cli-chunked.sh +581 -0
  49. package/.agent/scripts/codacy-cli.sh +442 -0
  50. package/.agent/scripts/code-audit-helper.sh +5 -0
  51. package/.agent/scripts/coderabbit-cli.sh +417 -0
  52. package/.agent/scripts/coderabbit-pro-analysis.sh +238 -0
  53. package/.agent/scripts/commands/code-simplifier.md +86 -0
  54. package/.agent/scripts/commands/full-loop.md +246 -0
  55. package/.agent/scripts/commands/postflight-loop.md +103 -0
  56. package/.agent/scripts/commands/recall.md +182 -0
  57. package/.agent/scripts/commands/remember.md +132 -0
  58. package/.agent/scripts/commands/save-todo.md +175 -0
  59. package/.agent/scripts/commands/session-review.md +154 -0
  60. package/.agent/scripts/comprehensive-quality-fix.sh +106 -0
  61. package/.agent/scripts/context-builder-helper.sh +522 -0
  62. package/.agent/scripts/coolify-cli-helper.sh +674 -0
  63. package/.agent/scripts/coolify-helper.sh +380 -0
  64. package/.agent/scripts/crawl4ai-examples.sh +401 -0
  65. package/.agent/scripts/crawl4ai-helper.sh +1078 -0
  66. package/.agent/scripts/crewai-helper.sh +681 -0
  67. package/.agent/scripts/dev-browser-helper.sh +513 -0
  68. package/.agent/scripts/dns-helper.sh +396 -0
  69. package/.agent/scripts/domain-research-helper.sh +917 -0
  70. package/.agent/scripts/dspy-helper.sh +285 -0
  71. package/.agent/scripts/dspyground-helper.sh +291 -0
  72. package/.agent/scripts/eeat-score-helper.sh +1242 -0
  73. package/.agent/scripts/efficient-return-fix.sh +92 -0
  74. package/.agent/scripts/extract-opencode-prompts.sh +128 -0
  75. package/.agent/scripts/find-missing-returns.sh +113 -0
  76. package/.agent/scripts/fix-auth-headers.sh +104 -0
  77. package/.agent/scripts/fix-common-strings.sh +254 -0
  78. package/.agent/scripts/fix-content-type.sh +100 -0
  79. package/.agent/scripts/fix-error-messages.sh +130 -0
  80. package/.agent/scripts/fix-misplaced-returns.sh +74 -0
  81. package/.agent/scripts/fix-remaining-literals.sh +152 -0
  82. package/.agent/scripts/fix-return-statements.sh +41 -0
  83. package/.agent/scripts/fix-s131-default-cases.sh +249 -0
  84. package/.agent/scripts/fix-sc2155-simple.sh +102 -0
  85. package/.agent/scripts/fix-shellcheck-critical.sh +187 -0
  86. package/.agent/scripts/fix-string-literals.sh +273 -0
  87. package/.agent/scripts/full-loop-helper.sh +773 -0
  88. package/.agent/scripts/generate-opencode-agents.sh +497 -0
  89. package/.agent/scripts/generate-opencode-commands.sh +1629 -0
  90. package/.agent/scripts/generate-skills.sh +366 -0
  91. package/.agent/scripts/git-platforms-helper.sh +640 -0
  92. package/.agent/scripts/gitea-cli-helper.sh +743 -0
  93. package/.agent/scripts/github-cli-helper.sh +702 -0
  94. package/.agent/scripts/gitlab-cli-helper.sh +682 -0
  95. package/.agent/scripts/gsc-add-user-helper.sh +325 -0
  96. package/.agent/scripts/gsc-sitemap-helper.sh +678 -0
  97. package/.agent/scripts/hetzner-helper.sh +485 -0
  98. package/.agent/scripts/hostinger-helper.sh +229 -0
  99. package/.agent/scripts/keyword-research-helper.sh +1815 -0
  100. package/.agent/scripts/langflow-helper.sh +544 -0
  101. package/.agent/scripts/linkedin-automation.py +241 -0
  102. package/.agent/scripts/linter-manager.sh +599 -0
  103. package/.agent/scripts/linters-local.sh +434 -0
  104. package/.agent/scripts/list-keys-helper.sh +488 -0
  105. package/.agent/scripts/local-browser-automation.py +339 -0
  106. package/.agent/scripts/localhost-helper.sh +744 -0
  107. package/.agent/scripts/loop-common.sh +806 -0
  108. package/.agent/scripts/mainwp-helper.sh +728 -0
  109. package/.agent/scripts/markdown-formatter.sh +338 -0
  110. package/.agent/scripts/markdown-lint-fix.sh +311 -0
  111. package/.agent/scripts/mass-fix-returns.sh +58 -0
  112. package/.agent/scripts/mcp-diagnose.sh +167 -0
  113. package/.agent/scripts/mcp-inspector-helper.sh +449 -0
  114. package/.agent/scripts/memory-helper.sh +650 -0
  115. package/.agent/scripts/monitor-code-review.sh +255 -0
  116. package/.agent/scripts/onboarding-helper.sh +706 -0
  117. package/.agent/scripts/opencode-github-setup-helper.sh +797 -0
  118. package/.agent/scripts/opencode-test-helper.sh +213 -0
  119. package/.agent/scripts/pagespeed-helper.sh +464 -0
  120. package/.agent/scripts/pandoc-helper.sh +362 -0
  121. package/.agent/scripts/postflight-check.sh +555 -0
  122. package/.agent/scripts/pre-commit-hook.sh +259 -0
  123. package/.agent/scripts/pre-edit-check.sh +169 -0
  124. package/.agent/scripts/qlty-cli.sh +356 -0
  125. package/.agent/scripts/quality-cli-manager.sh +525 -0
  126. package/.agent/scripts/quality-feedback-helper.sh +462 -0
  127. package/.agent/scripts/quality-fix.sh +263 -0
  128. package/.agent/scripts/quality-loop-helper.sh +1108 -0
  129. package/.agent/scripts/ralph-loop-helper.sh +836 -0
  130. package/.agent/scripts/ralph-upstream-check.sh +341 -0
  131. package/.agent/scripts/secretlint-helper.sh +847 -0
  132. package/.agent/scripts/servers-helper.sh +241 -0
  133. package/.agent/scripts/ses-helper.sh +619 -0
  134. package/.agent/scripts/session-review-helper.sh +404 -0
  135. package/.agent/scripts/setup-linters-wizard.sh +379 -0
  136. package/.agent/scripts/setup-local-api-keys.sh +330 -0
  137. package/.agent/scripts/setup-mcp-integrations.sh +472 -0
  138. package/.agent/scripts/shared-constants.sh +246 -0
  139. package/.agent/scripts/site-crawler-helper.sh +1487 -0
  140. package/.agent/scripts/snyk-helper.sh +940 -0
  141. package/.agent/scripts/sonarcloud-autofix.sh +193 -0
  142. package/.agent/scripts/sonarcloud-cli.sh +191 -0
  143. package/.agent/scripts/sonarscanner-cli.sh +455 -0
  144. package/.agent/scripts/spaceship-helper.sh +747 -0
  145. package/.agent/scripts/stagehand-helper.sh +321 -0
  146. package/.agent/scripts/stagehand-python-helper.sh +321 -0
  147. package/.agent/scripts/stagehand-python-setup.sh +441 -0
  148. package/.agent/scripts/stagehand-setup.sh +439 -0
  149. package/.agent/scripts/system-cleanup.sh +340 -0
  150. package/.agent/scripts/terminal-title-helper.sh +388 -0
  151. package/.agent/scripts/terminal-title-setup.sh +549 -0
  152. package/.agent/scripts/test-stagehand-both-integration.sh +317 -0
  153. package/.agent/scripts/test-stagehand-integration.sh +309 -0
  154. package/.agent/scripts/test-stagehand-python-integration.sh +341 -0
  155. package/.agent/scripts/todo-ready.sh +263 -0
  156. package/.agent/scripts/tool-version-check.sh +362 -0
  157. package/.agent/scripts/toon-helper.sh +469 -0
  158. package/.agent/scripts/twilio-helper.sh +917 -0
  159. package/.agent/scripts/updown-helper.sh +279 -0
  160. package/.agent/scripts/validate-mcp-integrations.sh +250 -0
  161. package/.agent/scripts/validate-version-consistency.sh +131 -0
  162. package/.agent/scripts/vaultwarden-helper.sh +597 -0
  163. package/.agent/scripts/vercel-cli-helper.sh +816 -0
  164. package/.agent/scripts/verify-mirrors.sh +169 -0
  165. package/.agent/scripts/version-manager.sh +831 -0
  166. package/.agent/scripts/webhosting-helper.sh +471 -0
  167. package/.agent/scripts/webhosting-verify.sh +238 -0
  168. package/.agent/scripts/wordpress-mcp-helper.sh +508 -0
  169. package/.agent/scripts/worktree-helper.sh +595 -0
  170. package/.agent/scripts/worktree-sessions.sh +577 -0
  171. package/.agent/seo/dataforseo.md +215 -0
  172. package/.agent/seo/domain-research.md +532 -0
  173. package/.agent/seo/eeat-score.md +659 -0
  174. package/.agent/seo/google-search-console.md +366 -0
  175. package/.agent/seo/gsc-sitemaps.md +282 -0
  176. package/.agent/seo/keyword-research.md +521 -0
  177. package/.agent/seo/serper.md +278 -0
  178. package/.agent/seo/site-crawler.md +387 -0
  179. package/.agent/seo.md +236 -0
  180. package/.agent/services/accounting/quickfile.md +159 -0
  181. package/.agent/services/communications/telfon.md +470 -0
  182. package/.agent/services/communications/twilio.md +569 -0
  183. package/.agent/services/crm/fluentcrm.md +449 -0
  184. package/.agent/services/email/ses.md +399 -0
  185. package/.agent/services/hosting/101domains.md +378 -0
  186. package/.agent/services/hosting/closte.md +177 -0
  187. package/.agent/services/hosting/cloudflare.md +251 -0
  188. package/.agent/services/hosting/cloudron.md +478 -0
  189. package/.agent/services/hosting/dns-providers.md +335 -0
  190. package/.agent/services/hosting/domain-purchasing.md +344 -0
  191. package/.agent/services/hosting/hetzner.md +327 -0
  192. package/.agent/services/hosting/hostinger.md +287 -0
  193. package/.agent/services/hosting/localhost.md +419 -0
  194. package/.agent/services/hosting/spaceship.md +353 -0
  195. package/.agent/services/hosting/webhosting.md +330 -0
  196. package/.agent/social-media.md +69 -0
  197. package/.agent/templates/plans-template.md +114 -0
  198. package/.agent/templates/prd-template.md +129 -0
  199. package/.agent/templates/tasks-template.md +108 -0
  200. package/.agent/templates/todo-template.md +89 -0
  201. package/.agent/tools/ai-assistants/agno.md +471 -0
  202. package/.agent/tools/ai-assistants/capsolver.md +326 -0
  203. package/.agent/tools/ai-assistants/configuration.md +221 -0
  204. package/.agent/tools/ai-assistants/overview.md +209 -0
  205. package/.agent/tools/ai-assistants/status.md +171 -0
  206. package/.agent/tools/ai-assistants/windsurf.md +193 -0
  207. package/.agent/tools/ai-orchestration/autogen.md +406 -0
  208. package/.agent/tools/ai-orchestration/crewai.md +445 -0
  209. package/.agent/tools/ai-orchestration/langflow.md +405 -0
  210. package/.agent/tools/ai-orchestration/openprose.md +487 -0
  211. package/.agent/tools/ai-orchestration/overview.md +362 -0
  212. package/.agent/tools/ai-orchestration/packaging.md +647 -0
  213. package/.agent/tools/browser/agent-browser.md +464 -0
  214. package/.agent/tools/browser/browser-automation.md +400 -0
  215. package/.agent/tools/browser/chrome-devtools.md +282 -0
  216. package/.agent/tools/browser/crawl4ai-integration.md +422 -0
  217. package/.agent/tools/browser/crawl4ai-resources.md +277 -0
  218. package/.agent/tools/browser/crawl4ai-usage.md +416 -0
  219. package/.agent/tools/browser/crawl4ai.md +585 -0
  220. package/.agent/tools/browser/dev-browser.md +341 -0
  221. package/.agent/tools/browser/pagespeed.md +260 -0
  222. package/.agent/tools/browser/playwright.md +266 -0
  223. package/.agent/tools/browser/playwriter.md +310 -0
  224. package/.agent/tools/browser/stagehand-examples.md +456 -0
  225. package/.agent/tools/browser/stagehand-python.md +483 -0
  226. package/.agent/tools/browser/stagehand.md +421 -0
  227. package/.agent/tools/build-agent/agent-review.md +224 -0
  228. package/.agent/tools/build-agent/build-agent.md +784 -0
  229. package/.agent/tools/build-mcp/aidevops-plugin.md +476 -0
  230. package/.agent/tools/build-mcp/api-wrapper.md +445 -0
  231. package/.agent/tools/build-mcp/build-mcp.md +240 -0
  232. package/.agent/tools/build-mcp/deployment.md +401 -0
  233. package/.agent/tools/build-mcp/server-patterns.md +632 -0
  234. package/.agent/tools/build-mcp/transports.md +366 -0
  235. package/.agent/tools/code-review/auditing.md +383 -0
  236. package/.agent/tools/code-review/automation.md +219 -0
  237. package/.agent/tools/code-review/best-practices.md +203 -0
  238. package/.agent/tools/code-review/codacy.md +151 -0
  239. package/.agent/tools/code-review/code-simplifier.md +174 -0
  240. package/.agent/tools/code-review/code-standards.md +309 -0
  241. package/.agent/tools/code-review/coderabbit.md +101 -0
  242. package/.agent/tools/code-review/management.md +155 -0
  243. package/.agent/tools/code-review/qlty.md +248 -0
  244. package/.agent/tools/code-review/secretlint.md +565 -0
  245. package/.agent/tools/code-review/setup.md +250 -0
  246. package/.agent/tools/code-review/snyk.md +563 -0
  247. package/.agent/tools/code-review/tools.md +230 -0
  248. package/.agent/tools/content/summarize.md +353 -0
  249. package/.agent/tools/context/augment-context-engine.md +468 -0
  250. package/.agent/tools/context/context-builder-agent.md +76 -0
  251. package/.agent/tools/context/context-builder.md +375 -0
  252. package/.agent/tools/context/context7.md +371 -0
  253. package/.agent/tools/context/dspy.md +302 -0
  254. package/.agent/tools/context/dspyground.md +374 -0
  255. package/.agent/tools/context/llm-tldr.md +219 -0
  256. package/.agent/tools/context/osgrep.md +488 -0
  257. package/.agent/tools/context/prompt-optimization.md +338 -0
  258. package/.agent/tools/context/toon.md +292 -0
  259. package/.agent/tools/conversion/pandoc.md +304 -0
  260. package/.agent/tools/credentials/api-key-management.md +154 -0
  261. package/.agent/tools/credentials/api-key-setup.md +224 -0
  262. package/.agent/tools/credentials/environment-variables.md +180 -0
  263. package/.agent/tools/credentials/vaultwarden.md +382 -0
  264. package/.agent/tools/data-extraction/outscraper.md +974 -0
  265. package/.agent/tools/deployment/coolify-cli.md +388 -0
  266. package/.agent/tools/deployment/coolify-setup.md +353 -0
  267. package/.agent/tools/deployment/coolify.md +345 -0
  268. package/.agent/tools/deployment/vercel.md +390 -0
  269. package/.agent/tools/git/authentication.md +132 -0
  270. package/.agent/tools/git/gitea-cli.md +193 -0
  271. package/.agent/tools/git/github-actions.md +207 -0
  272. package/.agent/tools/git/github-cli.md +223 -0
  273. package/.agent/tools/git/gitlab-cli.md +190 -0
  274. package/.agent/tools/git/opencode-github-security.md +350 -0
  275. package/.agent/tools/git/opencode-github.md +328 -0
  276. package/.agent/tools/git/opencode-gitlab.md +252 -0
  277. package/.agent/tools/git/security.md +196 -0
  278. package/.agent/tools/git.md +207 -0
  279. package/.agent/tools/opencode/oh-my-opencode.md +375 -0
  280. package/.agent/tools/opencode/opencode-anthropic-auth.md +446 -0
  281. package/.agent/tools/opencode/opencode.md +651 -0
  282. package/.agent/tools/social-media/bird.md +437 -0
  283. package/.agent/tools/task-management/beads.md +336 -0
  284. package/.agent/tools/terminal/terminal-title.md +251 -0
  285. package/.agent/tools/ui/shadcn.md +196 -0
  286. package/.agent/tools/ui/ui-skills.md +115 -0
  287. package/.agent/tools/wordpress/localwp.md +311 -0
  288. package/.agent/tools/wordpress/mainwp.md +391 -0
  289. package/.agent/tools/wordpress/scf.md +527 -0
  290. package/.agent/tools/wordpress/wp-admin.md +729 -0
  291. package/.agent/tools/wordpress/wp-dev.md +940 -0
  292. package/.agent/tools/wordpress/wp-preferred.md +398 -0
  293. package/.agent/tools/wordpress.md +95 -0
  294. package/.agent/workflows/branch/bugfix.md +63 -0
  295. package/.agent/workflows/branch/chore.md +95 -0
  296. package/.agent/workflows/branch/experiment.md +115 -0
  297. package/.agent/workflows/branch/feature.md +59 -0
  298. package/.agent/workflows/branch/hotfix.md +98 -0
  299. package/.agent/workflows/branch/refactor.md +92 -0
  300. package/.agent/workflows/branch/release.md +96 -0
  301. package/.agent/workflows/branch.md +347 -0
  302. package/.agent/workflows/bug-fixing.md +267 -0
  303. package/.agent/workflows/changelog.md +129 -0
  304. package/.agent/workflows/code-audit-remote.md +279 -0
  305. package/.agent/workflows/conversation-starter.md +69 -0
  306. package/.agent/workflows/error-feedback.md +578 -0
  307. package/.agent/workflows/feature-development.md +355 -0
  308. package/.agent/workflows/git-workflow.md +702 -0
  309. package/.agent/workflows/multi-repo-workspace.md +268 -0
  310. package/.agent/workflows/plans.md +709 -0
  311. package/.agent/workflows/postflight.md +604 -0
  312. package/.agent/workflows/pr.md +571 -0
  313. package/.agent/workflows/preflight.md +278 -0
  314. package/.agent/workflows/ralph-loop.md +773 -0
  315. package/.agent/workflows/release.md +498 -0
  316. package/.agent/workflows/session-manager.md +254 -0
  317. package/.agent/workflows/session-review.md +311 -0
  318. package/.agent/workflows/sql-migrations.md +631 -0
  319. package/.agent/workflows/version-bump.md +283 -0
  320. package/.agent/workflows/wiki-update.md +333 -0
  321. package/.agent/workflows/worktree.md +477 -0
  322. package/LICENSE +21 -0
  323. package/README.md +1446 -0
  324. package/VERSION +1 -0
  325. package/aidevops.sh +1746 -0
  326. package/bin/aidevops +21 -0
  327. package/package.json +75 -0
  328. package/scripts/npm-postinstall.js +60 -0
  329. package/setup.sh +2366 -0
@@ -0,0 +1,917 @@
1
+ #!/bin/bash
2
+ # shellcheck disable=SC2034,SC2155,SC2317,SC2329,SC2016,SC2181,SC1091,SC2154,SC2015,SC2086,SC2129,SC2030,SC2031,SC2119,SC2120,SC2001,SC2162,SC2088,SC2089,SC2090,SC2029,SC2006,SC2153
3
+
4
+ # Twilio Helper Script
5
+ # Comprehensive Twilio management for AI assistants
6
+ # Supports SMS, Voice, WhatsApp, Verify, Lookup, Recordings, Transcriptions
7
+
8
+ # Colors for output
9
+ GREEN='\033[0;32m'
10
+ BLUE='\033[0;34m'
11
+ YELLOW='\033[1;33m'
12
+ RED='\033[0;31m'
13
+ NC='\033[0m' # No Color
14
+
15
+ # Common message constants
16
+ readonly HELP_SHOW_MESSAGE="Show this help"
17
+ readonly USAGE_COMMAND_OPTIONS="Usage: $0 <command> [account] [options]"
18
+
19
+ print_info() {
20
+ local msg="$1"
21
+ echo -e "${BLUE}[INFO]${NC} $msg"
22
+ return 0
23
+ }
24
+
25
+ print_success() {
26
+ local msg="$1"
27
+ echo -e "${GREEN}[SUCCESS]${NC} $msg"
28
+ return 0
29
+ }
30
+
31
+ print_warning() {
32
+ local msg="$1"
33
+ echo -e "${YELLOW}[WARNING]${NC} $msg"
34
+ return 0
35
+ }
36
+
37
+ print_error() {
38
+ local msg="$1"
39
+ echo -e "${RED}[ERROR]${NC} $msg" >&2
40
+ return 0
41
+ }
42
+
43
+ # Script directory for relative paths
44
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || exit
45
+ # Config can be in repo configs/ or ~/.aidevops/configs/
46
+ if [[ -f "${SCRIPT_DIR}/../../configs/twilio-config.json" ]]; then
47
+ CONFIG_FILE="${SCRIPT_DIR}/../../configs/twilio-config.json"
48
+ elif [[ -f "${HOME}/.aidevops/configs/twilio-config.json" ]]; then
49
+ CONFIG_FILE="${HOME}/.aidevops/configs/twilio-config.json"
50
+ else
51
+ CONFIG_FILE="${SCRIPT_DIR}/../../configs/twilio-config.json"
52
+ fi
53
+
54
+ # Check if Twilio CLI or curl is available
55
+ check_dependencies() {
56
+ if ! command -v curl &> /dev/null; then
57
+ print_error "curl is required but not installed"
58
+ exit 1
59
+ fi
60
+
61
+ if ! command -v jq &> /dev/null; then
62
+ print_error "jq is required but not installed"
63
+ print_info "Install on macOS: brew install jq"
64
+ print_info "Install on Ubuntu: sudo apt-get install jq"
65
+ exit 1
66
+ fi
67
+
68
+ # Twilio CLI is optional but recommended
69
+ if command -v twilio &> /dev/null; then
70
+ TWILIO_CLI_AVAILABLE=true
71
+ else
72
+ TWILIO_CLI_AVAILABLE=false
73
+ fi
74
+
75
+ return 0
76
+ }
77
+
78
+ # Load Twilio configuration
79
+ load_config() {
80
+ if [[ ! -f "$CONFIG_FILE" ]]; then
81
+ print_error "Configuration file not found: $CONFIG_FILE"
82
+ print_info "Copy and customize: cp configs/twilio-config.json.txt configs/twilio-config.json"
83
+ exit 1
84
+ fi
85
+ return 0
86
+ }
87
+
88
+ # Get account configuration
89
+ get_account_config() {
90
+ local account_name="$1"
91
+
92
+ if [[ -z "$account_name" ]]; then
93
+ print_error "Account name is required"
94
+ list_accounts
95
+ exit 1
96
+ fi
97
+
98
+ local account_config
99
+ account_config=$(jq -r ".accounts.\"$account_name\"" "$CONFIG_FILE")
100
+ if [[ "$account_config" == "null" ]]; then
101
+ print_error "Account '$account_name' not found in configuration"
102
+ list_accounts
103
+ exit 1
104
+ fi
105
+
106
+ echo "$account_config"
107
+ return 0
108
+ }
109
+
110
+ # Set Twilio credentials for account
111
+ set_twilio_credentials() {
112
+ local account_name="$1"
113
+ local config
114
+ config=$(get_account_config "$account_name")
115
+
116
+ TWILIO_ACCOUNT_SID=$(echo "$config" | jq -r '.account_sid')
117
+ TWILIO_AUTH_TOKEN=$(echo "$config" | jq -r '.auth_token')
118
+ TWILIO_DEFAULT_FROM=$(echo "$config" | jq -r '.default_from // empty')
119
+
120
+ if [[ "$TWILIO_ACCOUNT_SID" == "null" || "$TWILIO_AUTH_TOKEN" == "null" ]]; then
121
+ print_error "Invalid Twilio credentials for account '$account_name'"
122
+ exit 1
123
+ fi
124
+
125
+ export TWILIO_ACCOUNT_SID
126
+ export TWILIO_AUTH_TOKEN
127
+ return 0
128
+ }
129
+
130
+ # Make Twilio API request
131
+ twilio_api() {
132
+ local method="$1"
133
+ local endpoint="$2"
134
+ shift 2
135
+ local data="$*"
136
+
137
+ local url="https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}${endpoint}"
138
+
139
+ if [[ "$method" == "GET" ]]; then
140
+ curl -s -X GET "$url" \
141
+ -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}"
142
+ else
143
+ curl -s -X "$method" "$url" \
144
+ -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" \
145
+ $data
146
+ fi
147
+ return 0
148
+ }
149
+
150
+ # List all configured accounts
151
+ list_accounts() {
152
+ load_config
153
+ print_info "Available Twilio accounts:"
154
+ jq -r '.accounts | keys[]' "$CONFIG_FILE" | while read -r account; do
155
+ local description
156
+ description=$(jq -r ".accounts.\"$account\".description" "$CONFIG_FILE")
157
+ local default_from
158
+ default_from=$(jq -r ".accounts.\"$account\".default_from // \"not set\"" "$CONFIG_FILE")
159
+ echo " - $account (from: $default_from) - $description"
160
+ done
161
+ return 0
162
+ }
163
+
164
+ # Get account balance
165
+ get_balance() {
166
+ local account_name="$1"
167
+ set_twilio_credentials "$account_name"
168
+
169
+ print_info "Getting balance for account: $account_name"
170
+ local response
171
+ response=$(twilio_api GET "/Balance.json")
172
+
173
+ local balance currency
174
+ balance=$(echo "$response" | jq -r '.balance')
175
+ currency=$(echo "$response" | jq -r '.currency')
176
+
177
+ echo "Balance: $currency $balance"
178
+ return 0
179
+ }
180
+
181
+ # List phone numbers
182
+ list_numbers() {
183
+ local account_name="$1"
184
+ set_twilio_credentials "$account_name"
185
+
186
+ print_info "Phone numbers for account: $account_name"
187
+ local response
188
+ response=$(twilio_api GET "/IncomingPhoneNumbers.json")
189
+
190
+ echo "$response" | jq -r '.incoming_phone_numbers[] | "\(.phone_number) - \(.friendly_name) [\(.capabilities | to_entries | map(select(.value == true) | .key) | join(", "))]"'
191
+ return 0
192
+ }
193
+
194
+ # Search available numbers
195
+ search_numbers() {
196
+ local account_name="$1"
197
+ local country="$2"
198
+ shift 2
199
+
200
+ set_twilio_credentials "$account_name"
201
+
202
+ local params=""
203
+ while [[ $# -gt 0 ]]; do
204
+ case "$1" in
205
+ --area-code)
206
+ params="${params}&AreaCode=$2"
207
+ shift 2
208
+ ;;
209
+ --contains)
210
+ params="${params}&Contains=$2"
211
+ shift 2
212
+ ;;
213
+ --sms)
214
+ params="${params}&SmsEnabled=true"
215
+ shift
216
+ ;;
217
+ --voice)
218
+ params="${params}&VoiceEnabled=true"
219
+ shift
220
+ ;;
221
+ --mms)
222
+ params="${params}&MmsEnabled=true"
223
+ shift
224
+ ;;
225
+ *)
226
+ shift
227
+ ;;
228
+ esac
229
+ done
230
+
231
+ print_info "Searching for available numbers in $country..."
232
+ local url="https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/AvailablePhoneNumbers/${country}/Local.json?${params}"
233
+
234
+ local response
235
+ response=$(curl -s -X GET "$url" -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}")
236
+
237
+ local count
238
+ count=$(echo "$response" | jq -r '.available_phone_numbers | length')
239
+
240
+ if [[ "$count" == "0" ]]; then
241
+ print_warning "No numbers available with those criteria"
242
+ print_info "Try different search parameters or contact Twilio support for special numbers"
243
+ return 1
244
+ fi
245
+
246
+ echo "$response" | jq -r '.available_phone_numbers[] | "\(.phone_number) - \(.locality // "N/A"), \(.region // "N/A") [\(.capabilities | to_entries | map(select(.value == true) | .key) | join(", "))]"'
247
+ return 0
248
+ }
249
+
250
+ # Buy a phone number
251
+ buy_number() {
252
+ local account_name="$1"
253
+ local phone_number="$2"
254
+
255
+ set_twilio_credentials "$account_name"
256
+
257
+ print_warning "About to purchase number: $phone_number"
258
+ read -p "Confirm purchase? (yes/no): " confirm
259
+
260
+ if [[ "$confirm" != "yes" ]]; then
261
+ print_info "Purchase cancelled"
262
+ return 1
263
+ fi
264
+
265
+ local response
266
+ response=$(twilio_api POST "/IncomingPhoneNumbers.json" -d "PhoneNumber=$phone_number")
267
+
268
+ if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
269
+ print_success "Number purchased successfully!"
270
+ echo "$response" | jq -r '"SID: \(.sid)\nNumber: \(.phone_number)\nFriendly Name: \(.friendly_name)"'
271
+ else
272
+ print_error "Failed to purchase number"
273
+ echo "$response" | jq -r '.message // .'
274
+ fi
275
+ return 0
276
+ }
277
+
278
+ # Send SMS
279
+ send_sms() {
280
+ local account_name="$1"
281
+ local to="$2"
282
+ local body="$3"
283
+ local from="${4:-$TWILIO_DEFAULT_FROM}"
284
+
285
+ set_twilio_credentials "$account_name"
286
+
287
+ if [[ -z "$from" ]]; then
288
+ from="$TWILIO_DEFAULT_FROM"
289
+ fi
290
+
291
+ if [[ -z "$from" ]]; then
292
+ print_error "No 'from' number specified and no default configured"
293
+ return 1
294
+ fi
295
+
296
+ # AUP compliance check
297
+ print_info "Sending SMS from $from to $to"
298
+
299
+ local response
300
+ response=$(twilio_api POST "/Messages.json" \
301
+ -d "To=$to" \
302
+ -d "From=$from" \
303
+ -d "Body=$body")
304
+
305
+ if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
306
+ print_success "SMS sent successfully!"
307
+ echo "$response" | jq -r '"SID: \(.sid)\nStatus: \(.status)\nTo: \(.to)\nFrom: \(.from)"'
308
+ else
309
+ print_error "Failed to send SMS"
310
+ echo "$response" | jq -r '.message // .'
311
+ fi
312
+ return 0
313
+ }
314
+
315
+ # List messages
316
+ list_messages() {
317
+ local account_name="$1"
318
+ local limit="${2:-20}"
319
+
320
+ set_twilio_credentials "$account_name"
321
+
322
+ print_info "Recent messages for account: $account_name"
323
+ local response
324
+ response=$(twilio_api GET "/Messages.json?PageSize=$limit")
325
+
326
+ echo "$response" | jq -r '.messages[] | "\(.date_sent) | \(.direction) | \(.from) -> \(.to) | \(.status) | \(.body[0:50])..."'
327
+ return 0
328
+ }
329
+
330
+ # Get message status
331
+ get_message_status() {
332
+ local account_name="$1"
333
+ local message_sid="$2"
334
+
335
+ set_twilio_credentials "$account_name"
336
+
337
+ print_info "Getting status for message: $message_sid"
338
+ local response
339
+ response=$(twilio_api GET "/Messages/${message_sid}.json")
340
+
341
+ echo "$response" | jq -r '"SID: \(.sid)\nStatus: \(.status)\nDirection: \(.direction)\nFrom: \(.from)\nTo: \(.to)\nBody: \(.body)\nDate Sent: \(.date_sent)\nError Code: \(.error_code // "none")\nError Message: \(.error_message // "none")"'
342
+ return 0
343
+ }
344
+
345
+ # Make a call
346
+ make_call() {
347
+ local account_name="$1"
348
+ local to="$2"
349
+ shift 2
350
+
351
+ set_twilio_credentials "$account_name"
352
+
353
+ local from="$TWILIO_DEFAULT_FROM"
354
+ local twiml=""
355
+ local url=""
356
+ local record="false"
357
+
358
+ while [[ $# -gt 0 ]]; do
359
+ case "$1" in
360
+ --from)
361
+ from="$2"
362
+ shift 2
363
+ ;;
364
+ --twiml)
365
+ twiml="$2"
366
+ shift 2
367
+ ;;
368
+ --url)
369
+ url="$2"
370
+ shift 2
371
+ ;;
372
+ --record)
373
+ record="true"
374
+ shift
375
+ ;;
376
+ *)
377
+ shift
378
+ ;;
379
+ esac
380
+ done
381
+
382
+ if [[ -z "$from" ]]; then
383
+ print_error "No 'from' number specified and no default configured"
384
+ return 1
385
+ fi
386
+
387
+ print_info "Initiating call from $from to $to"
388
+
389
+ local data="-d To=$to -d From=$from"
390
+
391
+ if [[ -n "$twiml" ]]; then
392
+ data="$data -d Twiml=$twiml"
393
+ elif [[ -n "$url" ]]; then
394
+ data="$data -d Url=$url"
395
+ else
396
+ # Default TwiML
397
+ data="$data -d Twiml=<Response><Say>Hello from AI DevOps!</Say></Response>"
398
+ fi
399
+
400
+ if [[ "$record" == "true" ]]; then
401
+ data="$data -d Record=true"
402
+ fi
403
+
404
+ local response
405
+ response=$(twilio_api POST "/Calls.json" $data)
406
+
407
+ if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
408
+ print_success "Call initiated successfully!"
409
+ echo "$response" | jq -r '"SID: \(.sid)\nStatus: \(.status)\nTo: \(.to)\nFrom: \(.from)"'
410
+ else
411
+ print_error "Failed to initiate call"
412
+ echo "$response" | jq -r '.message // .'
413
+ fi
414
+ return 0
415
+ }
416
+
417
+ # List calls
418
+ list_calls() {
419
+ local account_name="$1"
420
+ local limit="${2:-20}"
421
+
422
+ set_twilio_credentials "$account_name"
423
+
424
+ print_info "Recent calls for account: $account_name"
425
+ local response
426
+ response=$(twilio_api GET "/Calls.json?PageSize=$limit")
427
+
428
+ echo "$response" | jq -r '.calls[] | "\(.start_time) | \(.direction) | \(.from) -> \(.to) | \(.status) | \(.duration)s"'
429
+ return 0
430
+ }
431
+
432
+ # List recordings
433
+ list_recordings() {
434
+ local account_name="$1"
435
+ local limit="${2:-20}"
436
+
437
+ set_twilio_credentials "$account_name"
438
+
439
+ print_info "Recordings for account: $account_name"
440
+ local response
441
+ response=$(twilio_api GET "/Recordings.json?PageSize=$limit")
442
+
443
+ echo "$response" | jq -r '.recordings[] | "\(.date_created) | \(.sid) | \(.duration)s | \(.call_sid)"'
444
+ return 0
445
+ }
446
+
447
+ # Get recording details
448
+ get_recording() {
449
+ local account_name="$1"
450
+ local recording_sid="$2"
451
+
452
+ set_twilio_credentials "$account_name"
453
+
454
+ print_info "Getting recording: $recording_sid"
455
+ local response
456
+ response=$(twilio_api GET "/Recordings/${recording_sid}.json")
457
+
458
+ echo "$response" | jq -r '"SID: \(.sid)\nCall SID: \(.call_sid)\nDuration: \(.duration)s\nDate: \(.date_created)\nStatus: \(.status)"'
459
+
460
+ echo ""
461
+ echo "Download URL: https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Recordings/${recording_sid}.mp3"
462
+ return 0
463
+ }
464
+
465
+ # Download recording
466
+ download_recording() {
467
+ local account_name="$1"
468
+ local recording_sid="$2"
469
+ local output_dir="${3:-.}"
470
+
471
+ set_twilio_credentials "$account_name"
472
+
473
+ local url="https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Recordings/${recording_sid}.mp3"
474
+ local output_file="${output_dir}/${recording_sid}.mp3"
475
+
476
+ print_info "Downloading recording to: $output_file"
477
+ curl -s -o "$output_file" -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" "$url"
478
+
479
+ if [[ -f "$output_file" ]]; then
480
+ print_success "Recording downloaded: $output_file"
481
+ else
482
+ print_error "Failed to download recording"
483
+ fi
484
+ return 0
485
+ }
486
+
487
+ # List transcriptions
488
+ list_transcriptions() {
489
+ local account_name="$1"
490
+ local limit="${2:-20}"
491
+
492
+ set_twilio_credentials "$account_name"
493
+
494
+ print_info "Transcriptions for account: $account_name"
495
+ local response
496
+ response=$(twilio_api GET "/Transcriptions.json?PageSize=$limit")
497
+
498
+ echo "$response" | jq -r '.transcriptions[] | "\(.date_created) | \(.sid) | \(.status) | \(.recording_sid)"'
499
+ return 0
500
+ }
501
+
502
+ # Get transcription
503
+ get_transcription() {
504
+ local account_name="$1"
505
+ local transcription_sid="$2"
506
+
507
+ set_twilio_credentials "$account_name"
508
+
509
+ print_info "Getting transcription: $transcription_sid"
510
+ local response
511
+ response=$(twilio_api GET "/Transcriptions/${transcription_sid}.json")
512
+
513
+ echo "$response" | jq -r '"SID: \(.sid)\nRecording SID: \(.recording_sid)\nStatus: \(.status)\nDate: \(.date_created)\n\nTranscription:\n\(.transcription_text)"'
514
+ return 0
515
+ }
516
+
517
+ # Send WhatsApp message
518
+ send_whatsapp() {
519
+ local account_name="$1"
520
+ local to="$2"
521
+ local body="$3"
522
+ local from="${4:-}"
523
+
524
+ set_twilio_credentials "$account_name"
525
+
526
+ # WhatsApp numbers need whatsapp: prefix
527
+ if [[ ! "$to" =~ ^whatsapp: ]]; then
528
+ to="whatsapp:$to"
529
+ fi
530
+
531
+ if [[ -z "$from" ]]; then
532
+ # Get WhatsApp sender from config
533
+ from=$(jq -r ".accounts.\"$account_name\".whatsapp_from // empty" "$CONFIG_FILE")
534
+ fi
535
+
536
+ if [[ -z "$from" ]]; then
537
+ print_error "No WhatsApp sender configured for account '$account_name'"
538
+ return 1
539
+ fi
540
+
541
+ if [[ ! "$from" =~ ^whatsapp: ]]; then
542
+ from="whatsapp:$from"
543
+ fi
544
+
545
+ print_info "Sending WhatsApp message from $from to $to"
546
+
547
+ local response
548
+ response=$(twilio_api POST "/Messages.json" \
549
+ -d "To=$to" \
550
+ -d "From=$from" \
551
+ -d "Body=$body")
552
+
553
+ if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
554
+ print_success "WhatsApp message sent successfully!"
555
+ echo "$response" | jq -r '"SID: \(.sid)\nStatus: \(.status)"'
556
+ else
557
+ print_error "Failed to send WhatsApp message"
558
+ echo "$response" | jq -r '.message // .'
559
+ fi
560
+ return 0
561
+ }
562
+
563
+ # Lookup phone number
564
+ lookup_number() {
565
+ local account_name="$1"
566
+ local phone_number="$2"
567
+ local lookup_type="${3:-}"
568
+
569
+ set_twilio_credentials "$account_name"
570
+
571
+ local url="https://lookups.twilio.com/v1/PhoneNumbers/${phone_number}"
572
+
573
+ if [[ -n "$lookup_type" ]]; then
574
+ url="${url}?Type=${lookup_type}"
575
+ fi
576
+
577
+ print_info "Looking up: $phone_number"
578
+ local response
579
+ response=$(curl -s -X GET "$url" -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}")
580
+
581
+ echo "$response" | jq '.'
582
+ return 0
583
+ }
584
+
585
+ # Verify - Create service
586
+ verify_create_service() {
587
+ local account_name="$1"
588
+ local friendly_name="$2"
589
+
590
+ set_twilio_credentials "$account_name"
591
+
592
+ print_info "Creating Verify service: $friendly_name"
593
+
594
+ local response
595
+ response=$(curl -s -X POST "https://verify.twilio.com/v2/Services" \
596
+ -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" \
597
+ -d "FriendlyName=$friendly_name")
598
+
599
+ if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
600
+ print_success "Verify service created!"
601
+ echo "$response" | jq -r '"SID: \(.sid)\nName: \(.friendly_name)"'
602
+ print_info "Save this SID in your config as 'verify_service_sid'"
603
+ else
604
+ print_error "Failed to create Verify service"
605
+ echo "$response" | jq -r '.message // .'
606
+ fi
607
+ return 0
608
+ }
609
+
610
+ # Verify - Send code
611
+ verify_send() {
612
+ local account_name="$1"
613
+ local to="$2"
614
+ local channel="${3:-sms}"
615
+
616
+ set_twilio_credentials "$account_name"
617
+
618
+ local service_sid
619
+ service_sid=$(jq -r ".accounts.\"$account_name\".verify_service_sid // empty" "$CONFIG_FILE")
620
+
621
+ if [[ -z "$service_sid" ]]; then
622
+ print_error "No Verify service SID configured for account '$account_name'"
623
+ print_info "Create one with: $0 verify-create-service $account_name \"Service Name\""
624
+ return 1
625
+ fi
626
+
627
+ print_info "Sending verification code to $to via $channel"
628
+
629
+ local response
630
+ response=$(curl -s -X POST "https://verify.twilio.com/v2/Services/${service_sid}/Verifications" \
631
+ -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" \
632
+ -d "To=$to" \
633
+ -d "Channel=$channel")
634
+
635
+ if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
636
+ print_success "Verification code sent!"
637
+ echo "$response" | jq -r '"Status: \(.status)\nChannel: \(.channel)\nTo: \(.to)"'
638
+ else
639
+ print_error "Failed to send verification code"
640
+ echo "$response" | jq -r '.message // .'
641
+ fi
642
+ return 0
643
+ }
644
+
645
+ # Verify - Check code
646
+ verify_check() {
647
+ local account_name="$1"
648
+ local to="$2"
649
+ local code="$3"
650
+
651
+ set_twilio_credentials "$account_name"
652
+
653
+ local service_sid
654
+ service_sid=$(jq -r ".accounts.\"$account_name\".verify_service_sid // empty" "$CONFIG_FILE")
655
+
656
+ if [[ -z "$service_sid" ]]; then
657
+ print_error "No Verify service SID configured for account '$account_name'"
658
+ return 1
659
+ fi
660
+
661
+ print_info "Checking verification code for $to"
662
+
663
+ local response
664
+ response=$(curl -s -X POST "https://verify.twilio.com/v2/Services/${service_sid}/VerificationCheck" \
665
+ -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" \
666
+ -d "To=$to" \
667
+ -d "Code=$code")
668
+
669
+ local status
670
+ status=$(echo "$response" | jq -r '.status')
671
+
672
+ if [[ "$status" == "approved" ]]; then
673
+ print_success "Verification successful!"
674
+ else
675
+ print_error "Verification failed"
676
+ fi
677
+
678
+ echo "$response" | jq -r '"Status: \(.status)\nTo: \(.to)\nValid: \(.valid)"'
679
+ return 0
680
+ }
681
+
682
+ # Get usage summary
683
+ get_usage() {
684
+ local account_name="$1"
685
+ local period="${2:-today}"
686
+
687
+ set_twilio_credentials "$account_name"
688
+
689
+ local start_date end_date
690
+ case "$period" in
691
+ today)
692
+ start_date=$(date +%Y-%m-%d)
693
+ end_date=$(date +%Y-%m-%d)
694
+ ;;
695
+ week)
696
+ start_date=$(date -v-7d +%Y-%m-%d 2>/dev/null || date -d "7 days ago" +%Y-%m-%d)
697
+ end_date=$(date +%Y-%m-%d)
698
+ ;;
699
+ month)
700
+ start_date=$(date -v-30d +%Y-%m-%d 2>/dev/null || date -d "30 days ago" +%Y-%m-%d)
701
+ end_date=$(date +%Y-%m-%d)
702
+ ;;
703
+ *)
704
+ start_date="$period"
705
+ end_date=$(date +%Y-%m-%d)
706
+ ;;
707
+ esac
708
+
709
+ print_info "Usage for account: $account_name ($start_date to $end_date)"
710
+ local response
711
+ response=$(twilio_api GET "/Usage/Records.json?StartDate=$start_date&EndDate=$end_date")
712
+
713
+ echo "$response" | jq -r '.usage_records[] | select(.count != "0") | "\(.category): \(.count) (\(.price) \(.price_unit))"'
714
+ return 0
715
+ }
716
+
717
+ # Audit account
718
+ audit_account() {
719
+ local account_name="$1"
720
+ set_twilio_credentials "$account_name"
721
+
722
+ print_info "=== Twilio Account Audit: $account_name ==="
723
+ echo ""
724
+
725
+ print_info "Account Balance:"
726
+ get_balance "$account_name"
727
+ echo ""
728
+
729
+ print_info "Phone Numbers:"
730
+ list_numbers "$account_name"
731
+ echo ""
732
+
733
+ print_info "Recent Messages (last 5):"
734
+ list_messages "$account_name" 5
735
+ echo ""
736
+
737
+ print_info "Recent Calls (last 5):"
738
+ list_calls "$account_name" 5
739
+ echo ""
740
+
741
+ print_info "Usage Summary (this month):"
742
+ get_usage "$account_name" month
743
+
744
+ return 0
745
+ }
746
+
747
+ # Show help
748
+ show_help() {
749
+ cat << EOF
750
+ Twilio Helper Script - Comprehensive Twilio management for AI assistants
751
+
752
+ $USAGE_COMMAND_OPTIONS
753
+
754
+ ACCOUNT COMMANDS:
755
+ accounts List all configured accounts
756
+ balance <account> Get account balance
757
+ usage <account> [period] Get usage summary (today|week|month)
758
+ audit <account> Full account audit
759
+ status <account> Check account status
760
+
761
+ PHONE NUMBER COMMANDS:
762
+ numbers <account> List owned phone numbers
763
+ search-numbers <account> <country> [options]
764
+ Search available numbers
765
+ --area-code <code> Filter by area code
766
+ --contains <digits> Filter by containing digits
767
+ --sms Must support SMS
768
+ --voice Must support voice
769
+ --mms Must support MMS
770
+ buy-number <account> <number> Purchase a phone number
771
+ release-number <account> <number> Release a phone number
772
+
773
+ SMS COMMANDS:
774
+ sms <account> <to> <body> [from] Send SMS message
775
+ messages <account> [limit] List recent messages
776
+ message-status <account> <sid> Get message status
777
+
778
+ VOICE COMMANDS:
779
+ call <account> <to> [options] Make outbound call
780
+ --from <number> From number
781
+ --twiml <xml> TwiML instructions
782
+ --url <url> TwiML URL
783
+ --record Record the call
784
+ calls <account> [limit] List recent calls
785
+ call-details <account> <sid> Get call details
786
+
787
+ RECORDING COMMANDS:
788
+ recordings <account> [limit] List recordings
789
+ recording <account> <sid> Get recording details
790
+ download-recording <account> <sid> [dir]
791
+ Download recording MP3
792
+
793
+ TRANSCRIPTION COMMANDS:
794
+ transcriptions <account> [limit] List transcriptions
795
+ transcription <account> <sid> Get transcription text
796
+
797
+ WHATSAPP COMMANDS:
798
+ whatsapp <account> <to> <body> Send WhatsApp message
799
+
800
+ VERIFY (2FA) COMMANDS:
801
+ verify-create-service <account> <name>
802
+ Create Verify service
803
+ verify-send <account> <to> [channel]
804
+ Send verification code (sms|call|email)
805
+ verify-check <account> <to> <code>
806
+ Check verification code
807
+
808
+ LOOKUP COMMANDS:
809
+ lookup <account> <number> [type] Lookup phone number info
810
+ Types: carrier, caller-name
811
+
812
+ EXAMPLES:
813
+ $0 accounts
814
+ $0 sms production "+1234567890" "Hello!"
815
+ $0 search-numbers production US --area-code 415 --sms
816
+ $0 call production "+1234567890" --record
817
+ $0 verify-send production "+1234567890" sms
818
+ $0 audit production
819
+
820
+ CONFIGURATION:
821
+ Config file: configs/twilio-config.json
822
+ Template: configs/twilio-config.json.txt
823
+
824
+ For more information, see: .agent/services/communications/twilio.md
825
+ EOF
826
+ return 0
827
+ }
828
+
829
+ # Main function
830
+ main() {
831
+ local command="${1:-help}"
832
+ local account_name="${2:-}"
833
+ shift 2 2>/dev/null || true
834
+
835
+ check_dependencies
836
+ load_config
837
+
838
+ case "$command" in
839
+ "accounts")
840
+ list_accounts
841
+ ;;
842
+ "balance")
843
+ get_balance "$account_name"
844
+ ;;
845
+ "numbers")
846
+ list_numbers "$account_name"
847
+ ;;
848
+ "search-numbers")
849
+ local country="$1"
850
+ shift
851
+ search_numbers "$account_name" "$country" "$@"
852
+ ;;
853
+ "buy-number")
854
+ buy_number "$account_name" "$1"
855
+ ;;
856
+ "sms")
857
+ send_sms "$account_name" "$1" "$2" "${3:-}"
858
+ ;;
859
+ "messages")
860
+ list_messages "$account_name" "${1:-20}"
861
+ ;;
862
+ "message-status")
863
+ get_message_status "$account_name" "$1"
864
+ ;;
865
+ "call")
866
+ make_call "$account_name" "$1" "${@:2}"
867
+ ;;
868
+ "calls")
869
+ list_calls "$account_name" "${1:-20}"
870
+ ;;
871
+ "recordings")
872
+ list_recordings "$account_name" "${1:-20}"
873
+ ;;
874
+ "recording")
875
+ get_recording "$account_name" "$1"
876
+ ;;
877
+ "download-recording")
878
+ download_recording "$account_name" "$1" "${2:-.}"
879
+ ;;
880
+ "transcriptions")
881
+ list_transcriptions "$account_name" "${1:-20}"
882
+ ;;
883
+ "transcription")
884
+ get_transcription "$account_name" "$1"
885
+ ;;
886
+ "whatsapp")
887
+ send_whatsapp "$account_name" "$1" "$2"
888
+ ;;
889
+ "lookup")
890
+ lookup_number "$account_name" "$1" "${2:-}"
891
+ ;;
892
+ "verify-create-service")
893
+ verify_create_service "$account_name" "$1"
894
+ ;;
895
+ "verify-send")
896
+ verify_send "$account_name" "$1" "${2:-sms}"
897
+ ;;
898
+ "verify-check")
899
+ verify_check "$account_name" "$1" "$2"
900
+ ;;
901
+ "usage")
902
+ get_usage "$account_name" "${1:-today}"
903
+ ;;
904
+ "audit")
905
+ audit_account "$account_name"
906
+ ;;
907
+ "status")
908
+ get_balance "$account_name"
909
+ ;;
910
+ "help"|*)
911
+ show_help
912
+ ;;
913
+ esac
914
+ return 0
915
+ }
916
+
917
+ main "$@"