arka-agent 0.1.0__py3-none-any.whl

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 (570) hide show
  1. arka/__init__.py +3 -0
  2. arka/__main__.py +6 -0
  3. arka/_bootstrap.py +183 -0
  4. arka/agent/__init__.py +1 -0
  5. arka/agent/app_check.py +52 -0
  6. arka/agent/ascii_art.py +315 -0
  7. arka/agent/assemblyai_stt.py +210 -0
  8. arka/agent/astronomy.py +182 -0
  9. arka/agent/automation.py +118 -0
  10. arka/agent/background.py +221 -0
  11. arka/agent/background_remove.py +28 -0
  12. arka/agent/batch.py +244 -0
  13. arka/agent/blocks.py +128 -0
  14. arka/agent/bookmarks.py +387 -0
  15. arka/agent/browser_check.py +48 -0
  16. arka/agent/change_guards.py +16 -0
  17. arka/agent/chat.py +2396 -0
  18. arka/agent/code_convert.py +41 -0
  19. arka/agent/coding_tui.py +1396 -0
  20. arka/agent/coding_workflows.py +49 -0
  21. arka/agent/competitions.py +361 -0
  22. arka/agent/cool_build.py +45 -0
  23. arka/agent/core.py +1667 -0
  24. arka/agent/council.py +327 -0
  25. arka/agent/daily_brief.py +737 -0
  26. arka/agent/data_ask.py +1011 -0
  27. arka/agent/data_collect.py +153 -0
  28. arka/agent/deploy.py +60 -0
  29. arka/agent/design_flow.py +51 -0
  30. arka/agent/design_from_screenshot.py +157 -0
  31. arka/agent/design_memory.py +52 -0
  32. arka/agent/design_resources.py +22 -0
  33. arka/agent/dev_tools.py +664 -0
  34. arka/agent/dev_workflows.py +59 -0
  35. arka/agent/env_bridge.py +41 -0
  36. arka/agent/env_setup.py +49 -0
  37. arka/agent/exercise_dataset.py +280 -0
  38. arka/agent/fact_check.py +329 -0
  39. arka/agent/flow.py +336 -0
  40. arka/agent/free_credits.py +240 -0
  41. arka/agent/frontend_loop.py +271 -0
  42. arka/agent/game_control.py +318 -0
  43. arka/agent/game_studio.py +54 -0
  44. arka/agent/generate_data.py +998 -0
  45. arka/agent/geo_seo.py +29 -0
  46. arka/agent/git_changes.py +122 -0
  47. arka/agent/github_actions.py +55 -0
  48. arka/agent/github_dataset.py +466 -0
  49. arka/agent/github_repo.py +609 -0
  50. arka/agent/goal.py +1158 -0
  51. arka/agent/graphify.py +40 -0
  52. arka/agent/hackathon.py +58 -0
  53. arka/agent/hallmark.py +41 -0
  54. arka/agent/ideate.py +19 -0
  55. arka/agent/integration_setup.py +267 -0
  56. arka/agent/interesting_fact.py +56 -0
  57. arka/agent/iterate.py +53 -0
  58. arka/agent/judge_demo.py +32 -0
  59. arka/agent/lint_project.py +147 -0
  60. arka/agent/local_image_gen.py +137 -0
  61. arka/agent/loop_engineering.py +73 -0
  62. arka/agent/media_quiz.py +40 -0
  63. arka/agent/metallurgy.py +153 -0
  64. arka/agent/model_to_image.py +117 -0
  65. arka/agent/move_file.py +63 -0
  66. arka/agent/multi_llm.py +39 -0
  67. arka/agent/optimize.py +42 -0
  68. arka/agent/parallax_2d.py +43 -0
  69. arka/agent/parallel.py +40 -0
  70. arka/agent/pdf_interactive.py +35 -0
  71. arka/agent/personas/__init__.py +12 -0
  72. arka/agent/personas/base.py +320 -0
  73. arka/agent/personas/cli.py +296 -0
  74. arka/agent/personas/elon.py +129 -0
  75. arka/agent/personas/format.py +148 -0
  76. arka/agent/personas/io.py +270 -0
  77. arka/agent/personas/schema.py +111 -0
  78. arka/agent/personas/templates/blank.yaml +17 -0
  79. arka/agent/personas/templates/elon.yaml +27 -0
  80. arka/agent/personas/templates/feynman.yaml +19 -0
  81. arka/agent/personas/templates/socrates.yaml +19 -0
  82. arka/agent/platform_howto.py +62 -0
  83. arka/agent/play.py +151 -0
  84. arka/agent/post_scaffold.py +211 -0
  85. arka/agent/pr_check.py +558 -0
  86. arka/agent/price_sources.py +1274 -0
  87. arka/agent/product_sources.py +153 -0
  88. arka/agent/profession_plugins.py +485 -0
  89. arka/agent/profession_projects.py +311 -0
  90. arka/agent/profession_sources.py +580 -0
  91. arka/agent/professions.py +758 -0
  92. arka/agent/prompt_optimize.py +76 -0
  93. arka/agent/quiz_practice.py +477 -0
  94. arka/agent/race.py +58 -0
  95. arka/agent/repo_context.py +586 -0
  96. arka/agent/repo_graph.py +94 -0
  97. arka/agent/repo_health.py +333 -0
  98. arka/agent/repo_map.py +297 -0
  99. arka/agent/repo_reverse.py +23 -0
  100. arka/agent/research_math.py +34 -0
  101. arka/agent/rig_3d.py +43 -0
  102. arka/agent/route_learn.py +163 -0
  103. arka/agent/sandbox.py +135 -0
  104. arka/agent/scaffold_3d.py +319 -0
  105. arka/agent/scene_3d.py +137 -0
  106. arka/agent/script_understanding.py +56 -0
  107. arka/agent/search_setup.py +75 -0
  108. arka/agent/self_improve.py +1192 -0
  109. arka/agent/semantic_alert.py +32 -0
  110. arka/agent/skill_hints.py +33 -0
  111. arka/agent/skills.py +706 -0
  112. arka/agent/society.py +103 -0
  113. arka/agent/space_visual.py +26 -0
  114. arka/agent/spline_guide.py +65 -0
  115. arka/agent/structure.py +42 -0
  116. arka/agent/stt_install.py +155 -0
  117. arka/agent/stt_map.py +245 -0
  118. arka/agent/super_replica.py +48 -0
  119. arka/agent/surgical_edit.py +57 -0
  120. arka/agent/survival_lang.py +386 -0
  121. arka/agent/symbolic_image.py +78 -0
  122. arka/agent/talents.py +541 -0
  123. arka/agent/teammate_review.py +86 -0
  124. arka/agent/text_edit.py +56 -0
  125. arka/agent/text_to_3d.py +79 -0
  126. arka/agent/three_d.py +12 -0
  127. arka/agent/three_js_model.py +242 -0
  128. arka/agent/ui_copy_audit.py +50 -0
  129. arka/agent/ultra_fast.py +89 -0
  130. arka/agent/url_app_analyzer.py +55 -0
  131. arka/agent/usage_dashboard.py +28 -0
  132. arka/agent/video_evidence.py +176 -0
  133. arka/agent/view_data.py +528 -0
  134. arka/agent/vision_evidence.py +54 -0
  135. arka/agent/visual_diagnose.py +40 -0
  136. arka/agent/voice.py +467 -0
  137. arka/agent/wake.py +1130 -0
  138. arka/agent/web_answer.py +64 -0
  139. arka/agent/web_screenshot.py +95 -0
  140. arka/agent/word_counter.py +32 -0
  141. arka/agent/workflow_templates.py +65 -0
  142. arka/agent/workspace.py +64 -0
  143. arka/aie/__init__.py +1 -0
  144. arka/aie/_common.py +54 -0
  145. arka/aie/auto_click.py +73 -0
  146. arka/aie/auto_copy_selection.py +79 -0
  147. arka/aie/classifier.py +76 -0
  148. arka/aie/cli.py +396 -0
  149. arka/aie/delete_useless.py +53 -0
  150. arka/aie/zip_open.py +55 -0
  151. arka/bundled/_shim_path.py +21 -0
  152. arka/bundled/aie/__init__.py +1 -0
  153. arka/bundled/aie/_common.py +54 -0
  154. arka/bundled/aie/auto_click.py +73 -0
  155. arka/bundled/aie/auto_copy_selection.py +79 -0
  156. arka/bundled/aie/classifier.py +76 -0
  157. arka/bundled/aie/cli.py +396 -0
  158. arka/bundled/aie/delete_useless.py +53 -0
  159. arka/bundled/aie/zip_open.py +55 -0
  160. arka/bundled/arka_agent.py +15 -0
  161. arka/bundled/arka_agent_hub.py +15 -0
  162. arka/bundled/arka_aie.py +15 -0
  163. arka/bundled/arka_ascii_art.py +15 -0
  164. arka/bundled/arka_assemblyai_stt.py +15 -0
  165. arka/bundled/arka_astronomy.py +15 -0
  166. arka/bundled/arka_batch_summarize.py +15 -0
  167. arka/bundled/arka_benchmark.py +15 -0
  168. arka/bundled/arka_bookmarks.py +15 -0
  169. arka/bundled/arka_boot.sh +137 -0
  170. arka/bundled/arka_chart.py +15 -0
  171. arka/bundled/arka_chat.py +15 -0
  172. arka/bundled/arka_chat_requirements.txt +10 -0
  173. arka/bundled/arka_clipboard_history.py +15 -0
  174. arka/bundled/arka_competition_funding.py +15 -0
  175. arka/bundled/arka_competitions.py +15 -0
  176. arka/bundled/arka_compose_3d.py +15 -0
  177. arka/bundled/arka_compose_slides.py +15 -0
  178. arka/bundled/arka_compose_video.py +15 -0
  179. arka/bundled/arka_compute.py +15 -0
  180. arka/bundled/arka_config.py +15 -0
  181. arka/bundled/arka_convert_media.py +15 -0
  182. arka/bundled/arka_council.py +15 -0
  183. arka/bundled/arka_currency.py +15 -0
  184. arka/bundled/arka_daily_brief.py +15 -0
  185. arka/bundled/arka_data_ask.py +15 -0
  186. arka/bundled/arka_describe_image.py +15 -0
  187. arka/bundled/arka_describe_video.py +15 -0
  188. arka/bundled/arka_disk.py +15 -0
  189. arka/bundled/arka_docker_status.py +15 -0
  190. arka/bundled/arka_drawing.py +15 -0
  191. arka/bundled/arka_elon.py +15 -0
  192. arka/bundled/arka_fact_check.py +15 -0
  193. arka/bundled/arka_flow.py +15 -0
  194. arka/bundled/arka_free_credits.py +15 -0
  195. arka/bundled/arka_fugu.py +15 -0
  196. arka/bundled/arka_gemini.py +15 -0
  197. arka/bundled/arka_generate_data.py +15 -0
  198. arka/bundled/arka_generate_image.py +15 -0
  199. arka/bundled/arka_generate_thumbnail.py +15 -0
  200. arka/bundled/arka_generate_video.py +15 -0
  201. arka/bundled/arka_github_repo.py +15 -0
  202. arka/bundled/arka_google.py +15 -0
  203. arka/bundled/arka_harvard_ark.py +15 -0
  204. arka/bundled/arka_heartbeat.py +15 -0
  205. arka/bundled/arka_hf_bridge.py +15 -0
  206. arka/bundled/arka_jsonkit.py +15 -0
  207. arka/bundled/arka_kaggle.py +15 -0
  208. arka/bundled/arka_kalshi.py +15 -0
  209. arka/bundled/arka_llm.py +15 -0
  210. arka/bundled/arka_llm_fallback.py +15 -0
  211. arka/bundled/arka_llm_servers.py +15 -0
  212. arka/bundled/arka_mac_mic.py +15 -0
  213. arka/bundled/arka_macro_events.py +15 -0
  214. arka/bundled/arka_market_emotion.py +15 -0
  215. arka/bundled/arka_mcp.py +15 -0
  216. arka/bundled/arka_mcp_server.py +15 -0
  217. arka/bundled/arka_media.py +15 -0
  218. arka/bundled/arka_media_qa.py +15 -0
  219. arka/bundled/arka_memory.py +15 -0
  220. arka/bundled/arka_memory_detect.py +15 -0
  221. arka/bundled/arka_message_sessions.py +15 -0
  222. arka/bundled/arka_metallurgy.py +15 -0
  223. arka/bundled/arka_model_advisor.py +15 -0
  224. arka/bundled/arka_open_url.py +15 -0
  225. arka/bundled/arka_password_vault.py +15 -0
  226. arka/bundled/arka_paths.py +15 -0
  227. arka/bundled/arka_pdf_rag.py +15 -0
  228. arka/bundled/arka_pdf_tools.py +15 -0
  229. arka/bundled/arka_persona.py +15 -0
  230. arka/bundled/arka_personalize.py +15 -0
  231. arka/bundled/arka_phone.py +15 -0
  232. arka/bundled/arka_platform.py +15 -0
  233. arka/bundled/arka_pr_check.py +15 -0
  234. arka/bundled/arka_predictions.py +15 -0
  235. arka/bundled/arka_profession_plugins.py +15 -0
  236. arka/bundled/arka_profession_projects.py +15 -0
  237. arka/bundled/arka_professions.py +15 -0
  238. arka/bundled/arka_progress.py +15 -0
  239. arka/bundled/arka_qr.py +15 -0
  240. arka/bundled/arka_quiz_practice.py +15 -0
  241. arka/bundled/arka_remind.py +15 -0
  242. arka/bundled/arka_remote_server.py +15 -0
  243. arka/bundled/arka_repo_context.py +15 -0
  244. arka/bundled/arka_repo_health.py +15 -0
  245. arka/bundled/arka_repo_map.py +15 -0
  246. arka/bundled/arka_route_learn.py +15 -0
  247. arka/bundled/arka_routines.py +15 -0
  248. arka/bundled/arka_screen.py +15 -0
  249. arka/bundled/arka_security.py +15 -0
  250. arka/bundled/arka_self_improve.py +15 -0
  251. arka/bundled/arka_session_memory.py +15 -0
  252. arka/bundled/arka_signoz.py +15 -0
  253. arka/bundled/arka_skills.py +15 -0
  254. arka/bundled/arka_sports.py +15 -0
  255. arka/bundled/arka_spotify.py +15 -0
  256. arka/bundled/arka_stock_bridge.py +15 -0
  257. arka/bundled/arka_stock_context_worker.py +15 -0
  258. arka/bundled/arka_stock_fundamentals.py +15 -0
  259. arka/bundled/arka_stock_ui.py +15 -0
  260. arka/bundled/arka_stt_install.py +15 -0
  261. arka/bundled/arka_stt_map.py +15 -0
  262. arka/bundled/arka_subagent.py +15 -0
  263. arka/bundled/arka_summarize.py +15 -0
  264. arka/bundled/arka_supermemory.py +15 -0
  265. arka/bundled/arka_survival_lang.py +15 -0
  266. arka/bundled/arka_talents.py +15 -0
  267. arka/bundled/arka_teams.py +15 -0
  268. arka/bundled/arka_text_to_3d.py +8 -0
  269. arka/bundled/arka_textkit.py +15 -0
  270. arka/bundled/arka_three_d.py +15 -0
  271. arka/bundled/arka_timekit.py +15 -0
  272. arka/bundled/arka_timezone_convert.py +15 -0
  273. arka/bundled/arka_turboquant_install.py +15 -0
  274. arka/bundled/arka_turboquant_rag.py +15 -0
  275. arka/bundled/arka_turboquant_requirements.txt +11 -0
  276. arka/bundled/arka_unified_memory.py +15 -0
  277. arka/bundled/arka_urlkit.py +15 -0
  278. arka/bundled/arka_usage.py +15 -0
  279. arka/bundled/arka_view_data.py +15 -0
  280. arka/bundled/arka_voice.py +15 -0
  281. arka/bundled/arka_voice_hf.sh +172 -0
  282. arka/bundled/arka_wake.py +15 -0
  283. arka/bundled/arka_webhook.py +15 -0
  284. arka/bundled/arka_whatsapp_inbox.py +15 -0
  285. arka/bundled/arka_x_post.py +15 -0
  286. arka/bundled/arka_youtube.py +15 -0
  287. arka/bundled/arka_youtube_bulk.py +15 -0
  288. arka/bundled/arka_youtube_research.py +15 -0
  289. arka/bundled/arka_ytdlp_progress.py +15 -0
  290. arka/bundled/config.fish +20314 -0
  291. arka/bundled/edge_speak.py +15 -0
  292. arka/bundled/indic_tts.py +15 -0
  293. arka/bundled/privategpt/settings.override.yaml +5 -0
  294. arka/bundled/sarvam_speak.py +15 -0
  295. arka/bundled/sarvam_stt.py +15 -0
  296. arka/bundled/spotify_dom.py +15 -0
  297. arka/bundled/termux-boot-arka.sh +16 -0
  298. arka/bundled/web_answer.py +15 -0
  299. arka/charts/__init__.py +1 -0
  300. arka/charts/data.py +1842 -0
  301. arka/charts/defaults.py +217 -0
  302. arka/charts/plot.py +2010 -0
  303. arka/cli.py +1270 -0
  304. arka/core/__init__.py +1 -0
  305. arka/core/auto_refetch.py +143 -0
  306. arka/core/code_project.py +452 -0
  307. arka/core/compute.py +147 -0
  308. arka/core/config_backup.py +544 -0
  309. arka/core/default_config.py +300 -0
  310. arka/core/disk.py +413 -0
  311. arka/core/jsonkit.py +209 -0
  312. arka/core/memory_detect.py +468 -0
  313. arka/core/memory_scope.py +492 -0
  314. arka/core/mode.py +372 -0
  315. arka/core/notifications.py +23 -0
  316. arka/core/object_orientation.py +69 -0
  317. arka/core/output.py +96 -0
  318. arka/core/personalize.py +798 -0
  319. arka/core/platform.py +274 -0
  320. arka/core/progress.py +132 -0
  321. arka/core/project_rules.py +165 -0
  322. arka/core/security.py +425 -0
  323. arka/core/session_memory.py +319 -0
  324. arka/core/skill_settings.py +121 -0
  325. arka/core/skill_usage.py +36 -0
  326. arka/core/textkit.py +115 -0
  327. arka/core/timekit.py +158 -0
  328. arka/core/unified_memory.py +488 -0
  329. arka/core/urlkit.py +162 -0
  330. arka/core/usage.py +845 -0
  331. arka/dispatch.py +660 -0
  332. arka/documents/__init__.py +5 -0
  333. arka/documents/drawing.py +437 -0
  334. arka/env.example +695 -0
  335. arka/env.py +102 -0
  336. arka/fish/config.fish +20314 -0
  337. arka/fish/scripts/arka_boot.sh +137 -0
  338. arka/fish/scripts/arka_voice_hf.sh +172 -0
  339. arka/fish/scripts/termux-boot-arka.sh +16 -0
  340. arka/fish_bridge.py +177 -0
  341. arka/generate/__init__.py +1 -0
  342. arka/generate/image.py +389 -0
  343. arka/generate/video.py +268 -0
  344. arka/integrations/__init__.py +1 -0
  345. arka/integrations/agent_hub.py +1407 -0
  346. arka/integrations/agent_hub_cli.py +281 -0
  347. arka/integrations/backend_client.py +185 -0
  348. arka/integrations/benchmark_cli.py +138 -0
  349. arka/integrations/butterfish.py +129 -0
  350. arka/integrations/clipboard_history.py +497 -0
  351. arka/integrations/context7_mcp.py +341 -0
  352. arka/integrations/currency.py +538 -0
  353. arka/integrations/docker_status.py +293 -0
  354. arka/integrations/fugu.py +216 -0
  355. arka/integrations/gemini_cli.py +200 -0
  356. arka/integrations/google_oauth.py +456 -0
  357. arka/integrations/google_workspace.py +1510 -0
  358. arka/integrations/greeting.py +40 -0
  359. arka/integrations/harvard_ark.py +582 -0
  360. arka/integrations/heartbeat.py +294 -0
  361. arka/integrations/hf_bridge.py +282 -0
  362. arka/integrations/kaggle.py +580 -0
  363. arka/integrations/kalshi.py +433 -0
  364. arka/integrations/mac_mic.py +277 -0
  365. arka/integrations/macos_calendar.py +155 -0
  366. arka/integrations/mcp_autoconfig.py +69 -0
  367. arka/integrations/mcp_cli.py +379 -0
  368. arka/integrations/mcp_client.py +379 -0
  369. arka/integrations/mcp_logs.py +95 -0
  370. arka/integrations/mcp_manager.py +746 -0
  371. arka/integrations/mcp_server.py +2647 -0
  372. arka/integrations/memory_cli.py +59 -0
  373. arka/integrations/message_sessions.py +432 -0
  374. arka/integrations/open_url.py +368 -0
  375. arka/integrations/password_vault.py +304 -0
  376. arka/integrations/phone.py +231 -0
  377. arka/integrations/qr_code.py +88 -0
  378. arka/integrations/remind.py +666 -0
  379. arka/integrations/remote_server.py +1105 -0
  380. arka/integrations/routines.py +692 -0
  381. arka/integrations/signoz_mcp.py +97 -0
  382. arka/integrations/site_summary.py +303 -0
  383. arka/integrations/sports.py +399 -0
  384. arka/integrations/spotify.py +603 -0
  385. arka/integrations/spotify_dom.py +471 -0
  386. arka/integrations/subagent.py +438 -0
  387. arka/integrations/supermemory.py +783 -0
  388. arka/integrations/teams_cli.py +266 -0
  389. arka/integrations/timezone_convert.py +379 -0
  390. arka/integrations/webhook.py +251 -0
  391. arka/integrations/whatsapp_inbox.py +297 -0
  392. arka/integrations/x_post.py +1387 -0
  393. arka/llm/__init__.py +1 -0
  394. arka/llm/api_keys.py +238 -0
  395. arka/llm/backend.py +57 -0
  396. arka/llm/benchmarks.py +470 -0
  397. arka/llm/chunking.py +54 -0
  398. arka/llm/cli.py +764 -0
  399. arka/llm/edge.py +29 -0
  400. arka/llm/fallback.py +2339 -0
  401. arka/llm/free_models.py +83 -0
  402. arka/llm/grounding.py +55 -0
  403. arka/llm/guardrails.py +71 -0
  404. arka/llm/hybrid.py +153 -0
  405. arka/llm/model_advisor.py +759 -0
  406. arka/llm/model_host_setup.py +74 -0
  407. arka/llm/model_optimizer.py +63 -0
  408. arka/llm/prompt_compact.py +134 -0
  409. arka/llm/provider_select.py +571 -0
  410. arka/llm/providers.py +428 -0
  411. arka/llm/quantize.py +32 -0
  412. arka/llm/servers.py +620 -0
  413. arka/llm/skill_models.py +155 -0
  414. arka/llm/skill_profiles.py +188 -0
  415. arka/llm/speculative.py +33 -0
  416. arka/llm/thinking.py +27 -0
  417. arka/llm/train_plan.py +47 -0
  418. arka/media/__init__.py +1 -0
  419. arka/media/batch.py +321 -0
  420. arka/media/chart_slide.py +730 -0
  421. arka/media/compose_3d.py +1456 -0
  422. arka/media/compose_3d_backends.py +560 -0
  423. arka/media/compose_slides.py +2422 -0
  424. arka/media/compose_video.py +2295 -0
  425. arka/media/convert_media.py +842 -0
  426. arka/media/media_transform.py +92 -0
  427. arka/media/qa.py +69 -0
  428. arka/media/slide_design.py +232 -0
  429. arka/media/stock_photos.py +944 -0
  430. arka/media/summarize.py +69 -0
  431. arka/media/thumbnail.py +422 -0
  432. arka/media/transcript.py +1215 -0
  433. arka/media/unsplash.py +129 -0
  434. arka/output.py +87 -0
  435. arka/paths.py +293 -0
  436. arka/pdf/__init__.py +1 -0
  437. arka/pdf/privategpt/settings.override.yaml +5 -0
  438. arka/pdf/rag.py +1243 -0
  439. arka/pdf/tools.py +1385 -0
  440. arka/platform_info.py +89 -0
  441. arka/professions/examples/architect/README.md +18 -0
  442. arka/professions/examples/architect/profession.json +28 -0
  443. arka/professions/life_sciences/profession.json +47 -0
  444. arka/requirements/chat.txt +10 -0
  445. arka/requirements/observability.txt +3 -0
  446. arka/requirements/turboquant.txt +11 -0
  447. arka/router.py +922 -0
  448. arka/routing/__init__.py +5 -0
  449. arka/routing/council.py +60 -0
  450. arka/routing/file_size.py +40 -0
  451. arka/routing/interesting_fact.py +68 -0
  452. arka/routing/learned.py +317 -0
  453. arka/routing/platform_howto.py +91 -0
  454. arka/routing/symbolic.py +1826 -0
  455. arka/setup_runtime.py +128 -0
  456. arka/skills/astronomy/__pycache__/lib.cpython-313.pyc +0 -0
  457. arka/skills/astronomy/lib.py +321 -0
  458. arka/skills/astronomy/objects.json +266 -0
  459. arka/skills/astronomy/run.py +96 -0
  460. arka/skills/astronomy/skill.json +23 -0
  461. arka/skills/describe_video/run.py +4 -0
  462. arka/skills/describe_video/skill.json +18 -0
  463. arka/skills/examples/demo_echo/__pycache__/run.cpython-313.pyc +0 -0
  464. arka/skills/examples/demo_echo/run.py +18 -0
  465. arka/skills/examples/demo_echo/skill.json +24 -0
  466. arka/skills/exercise_dataset/skill.json +17 -0
  467. arka/skills/game_control/run.py +6 -0
  468. arka/skills/game_control/skill.json +18 -0
  469. arka/skills/github_dataset/skill.json +17 -0
  470. arka/skills/life_sciences/__pycache__/lib.cpython-313.pyc +0 -0
  471. arka/skills/life_sciences/__pycache__/protocol_sources.cpython-313.pyc +0 -0
  472. arka/skills/life_sciences/lib.py +627 -0
  473. arka/skills/life_sciences/marketplace.json +181 -0
  474. arka/skills/life_sciences/protocol_sources.py +307 -0
  475. arka/skills/life_sciences/protocols.json +123 -0
  476. arka/skills/life_sciences/run.py +58 -0
  477. arka/skills/life_sciences/skill.json +22 -0
  478. arka/skills/local_image_gen/run.py +4 -0
  479. arka/skills/local_image_gen/skill.json +10 -0
  480. arka/skills/metallurgy/__pycache__/lib.cpython-313.pyc +0 -0
  481. arka/skills/metallurgy/alloys.json +126 -0
  482. arka/skills/metallurgy/heat_treatments.json +139 -0
  483. arka/skills/metallurgy/lib.py +271 -0
  484. arka/skills/metallurgy/metallurgy_sources.py +37 -0
  485. arka/skills/metallurgy/run.py +88 -0
  486. arka/skills/metallurgy/skill.json +21 -0
  487. arka/skills/parallax_2d/run.py +4 -0
  488. arka/skills/parallax_2d/skill.json +10 -0
  489. arka/skills/rig_3d/run.py +4 -0
  490. arka/skills/rig_3d/skill.json +10 -0
  491. arka/skills/scene_3d/run.py +4 -0
  492. arka/skills/scene_3d/skill.json +10 -0
  493. arka/skills/semantic_alert/run.py +4 -0
  494. arka/skills/semantic_alert/skill.json +10 -0
  495. arka/skills/symbolic_image/run.py +4 -0
  496. arka/skills/symbolic_image/skill.json +10 -0
  497. arka/skills/text_to_3d/run.py +3 -0
  498. arka/skills/text_to_3d/skill.json +15 -0
  499. arka/skills/three_d/__pycache__/lib.cpython-313.pyc +0 -0
  500. arka/skills/three_d/lib.py +307 -0
  501. arka/skills/three_d/run.py +216 -0
  502. arka/skills/three_d/skill.json +25 -0
  503. arka/skills/video_evidence/skill.json +19 -0
  504. arka/skills/visual_diagnose/run.py +4 -0
  505. arka/skills/visual_diagnose/skill.json +10 -0
  506. arka/skills/word_counter/run.py +4 -0
  507. arka/skills/word_counter/skill.json +10 -0
  508. arka/skills.py +76 -0
  509. arka/stock/__init__.py +1 -0
  510. arka/stock/analyzer.py +29 -0
  511. arka/stock/bridge.py +200 -0
  512. arka/stock/competition_funding.py +590 -0
  513. arka/stock/context_worker.py +102 -0
  514. arka/stock/emotion.py +511 -0
  515. arka/stock/fundamentals.py +388 -0
  516. arka/stock/macro_events.py +532 -0
  517. arka/stock/predictions.py +1002 -0
  518. arka/stock/turboquant_install.py +190 -0
  519. arka/stock/turboquant_rag.py +677 -0
  520. arka/stock/ui.py +179 -0
  521. arka/teams/__init__.py +19 -0
  522. arka/teams/doctor.py +187 -0
  523. arka/teams/executor.py +710 -0
  524. arka/teams/io.py +252 -0
  525. arka/teams/mcp_context.py +95 -0
  526. arka/teams/resolve.py +104 -0
  527. arka/teams/schema.py +282 -0
  528. arka/teams/templates/team-clawbox-edge.yaml +19 -0
  529. arka/teams/templates/team-code-review.yaml +16 -0
  530. arka/teams/templates/team-research.yaml +22 -0
  531. arka/teams/templates/workflow-brainstorm.yaml +22 -0
  532. arka/teams/templates/workflow-code-review.yaml +16 -0
  533. arka/teams/templates/workflow-review-and-ship.yaml +16 -0
  534. arka/telemetry/__init__.py +41 -0
  535. arka/telemetry/_otlp.py +218 -0
  536. arka/telemetry/codebase_connectors.py +74 -0
  537. arka/telemetry/llm_obs.py +178 -0
  538. arka/telemetry/logs.py +162 -0
  539. arka/telemetry/mcp_obs.py +112 -0
  540. arka/telemetry/metrics.py +275 -0
  541. arka/telemetry/observability_doctor.py +60 -0
  542. arka/telemetry/signoz_alerts.py +191 -0
  543. arka/telemetry/signoz_cli.py +575 -0
  544. arka/telemetry/signoz_cursor_setup.py +92 -0
  545. arka/telemetry/signoz_demo.py +577 -0
  546. arka/telemetry/signoz_setup.py +409 -0
  547. arka/telemetry/supermemory_obs.py +117 -0
  548. arka/telemetry/tracing.py +490 -0
  549. arka/vision/__init__.py +5 -0
  550. arka/vision/chart_visual.py +351 -0
  551. arka/vision/describe.py +1479 -0
  552. arka/vision/ocr.py +393 -0
  553. arka/vision/screen.py +310 -0
  554. arka/vision/video.py +409 -0
  555. arka/voice/__init__.py +1 -0
  556. arka/voice/edge_speak.py +385 -0
  557. arka/voice/indic_tts.py +406 -0
  558. arka/voice/sarvam_speak.py +138 -0
  559. arka/voice/sarvam_stt.py +129 -0
  560. arka/youtube/__init__.py +1 -0
  561. arka/youtube/bulk.py +507 -0
  562. arka/youtube/research.py +502 -0
  563. arka/youtube/transcript.py +877 -0
  564. arka/youtube/ytdlp_progress.py +278 -0
  565. arka_agent-0.1.0.dist-info/METADATA +229 -0
  566. arka_agent-0.1.0.dist-info/RECORD +570 -0
  567. arka_agent-0.1.0.dist-info/WHEEL +5 -0
  568. arka_agent-0.1.0.dist-info/entry_points.txt +2 -0
  569. arka_agent-0.1.0.dist-info/licenses/LICENSE +339 -0
  570. arka_agent-0.1.0.dist-info/top_level.txt +1 -0
arka/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """Arka — cross-platform AI agent."""
2
+
3
+ __version__ = "0.1.0"
arka/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ """Allow: python -m arka"""
2
+
3
+ from arka.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(main())
arka/_bootstrap.py ADDED
@@ -0,0 +1,183 @@
1
+ """Bootstrap legacy flat imports and dev checkout paths."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import inspect
7
+ import sys
8
+ from pathlib import Path
9
+ from types import ModuleType
10
+
11
+ _SRC = Path(__file__).resolve().parent.parent
12
+ _ROOT = _SRC.parent.parent
13
+
14
+ LEGACY_MODULES: dict[str, str] = {
15
+ "arka_paths": "arka.paths",
16
+ "arka_platform": "arka.core.platform",
17
+ "arka_progress": "arka.core.progress",
18
+ "arka_compute": "arka.core.compute",
19
+ "arka_disk": "arka.core.disk",
20
+ "arka_jsonkit": "arka.core.jsonkit",
21
+ "arka_timekit": "arka.core.timekit",
22
+ "arka_urlkit": "arka.core.urlkit",
23
+ "arka_textkit": "arka.core.textkit",
24
+ "arka_security": "arka.core.security",
25
+ "arka_usage": "arka.core.usage",
26
+ "arka_memory_detect": "arka.core.memory_detect",
27
+ "arka_session_memory": "arka.core.session_memory",
28
+ "arka_unified_memory": "arka.core.unified_memory",
29
+ "arka_memory": "arka.integrations.memory_cli",
30
+ "arka_personalize": "arka.core.personalize",
31
+ "arka_config": "arka.core.config_backup",
32
+ "arka_llm": "arka.llm.cli",
33
+ "arka_llm_fallback": "arka.llm.fallback",
34
+ "arka_llm_servers": "arka.llm.servers",
35
+ "arka_youtube": "arka.youtube.transcript",
36
+ "arka_youtube_research": "arka.youtube.research",
37
+ "arka_youtube_bulk": "arka.youtube.bulk",
38
+ "arka_ytdlp_progress": "arka.youtube.ytdlp_progress",
39
+ "arka_batch_summarize": "arka.media.batch",
40
+ "arka_media": "arka.media.transcript",
41
+ "arka_media_qa": "arka.media.qa",
42
+ "arka_summarize": "arka.media.summarize",
43
+ "arka_stock_bridge": "arka.stock.bridge",
44
+ "arka_stock_fundamentals": "arka.stock.fundamentals",
45
+ "arka_stock_ui": "arka.stock.ui",
46
+ "arka_stock_context_worker": "arka.stock.context_worker",
47
+ "arka_macro_events": "arka.stock.macro_events",
48
+ "arka_market_emotion": "arka.stock.emotion",
49
+ "arka_competition_funding": "arka.stock.competition_funding",
50
+ "arka_predictions": "arka.stock.predictions",
51
+ "arka_turboquant_install": "arka.stock.turboquant_install",
52
+ "arka_turboquant_rag": "arka.stock.turboquant_rag",
53
+ "arka_agent": "arka.agent.core",
54
+ "arka_professions": "arka.agent.professions",
55
+ "arka_profession_plugins": "arka.agent.profession_plugins",
56
+ "arka_profession_projects": "arka.agent.profession_projects",
57
+ "arka_chat": "arka.agent.chat",
58
+ "arka_survival_lang": "arka.agent.survival_lang",
59
+ "arka_pr_check": "arka.agent.pr_check",
60
+ "arka_github_repo": "arka.agent.github_repo",
61
+ "arka_competitions": "arka.agent.competitions",
62
+ "arka_bookmarks": "arka.agent.bookmarks",
63
+ "arka_repo_health": "arka.agent.repo_health",
64
+ "arka_free_credits": "arka.agent.free_credits",
65
+ "arka_repo_map": "arka.agent.repo_map",
66
+ "arka_repo_context": "arka.agent.repo_context",
67
+ "arka_self_improve": "arka.agent.self_improve",
68
+ "arka_generate_data": "arka.agent.generate_data",
69
+ "arka_data_ask": "arka.agent.data_ask",
70
+ "arka_view_data": "arka.agent.view_data",
71
+ "arka_docker_status": "arka.integrations.docker_status",
72
+ "arka_clipboard_history": "arka.integrations.clipboard_history",
73
+ "arka_route_learn": "arka.agent.route_learn",
74
+ "arka_skills": "arka.agent.skills",
75
+ "arka_talents": "arka.agent.talents",
76
+ "arka_wake": "arka.agent.wake",
77
+ "arka_voice": "arka.agent.voice",
78
+ "arka_stt_map": "arka.agent.stt_map",
79
+ "arka_assemblyai_stt": "arka.agent.assemblyai_stt",
80
+ "arka_supermemory": "arka.integrations.supermemory",
81
+ "arka_spotify": "arka.integrations.spotify",
82
+ "arka_whatsapp_inbox": "arka.integrations.whatsapp_inbox",
83
+ "arka_hf_bridge": "arka.integrations.hf_bridge",
84
+ "arka_remote_server": "arka.integrations.remote_server",
85
+ "arka_phone": "arka.integrations.phone",
86
+ "arka_remind": "arka.integrations.remind",
87
+ "arka_routines": "arka.integrations.routines",
88
+ "arka_heartbeat": "arka.integrations.heartbeat",
89
+ "arka_message_sessions": "arka.integrations.message_sessions",
90
+ "arka_subagent": "arka.integrations.subagent",
91
+ "arka_teams": "arka.integrations.teams_cli",
92
+ "arka_webhook": "arka.integrations.webhook",
93
+ "arka_sports": "arka.integrations.sports",
94
+ "arka_currency": "arka.integrations.currency",
95
+ "arka_open_url": "arka.integrations.open_url",
96
+ "arka_kalshi": "arka.integrations.kalshi",
97
+ "arka_kaggle": "arka.integrations.kaggle",
98
+ "arka_password_vault": "arka.integrations.password_vault",
99
+ "arka_google": "arka.integrations.google_workspace",
100
+ "arka_gemini": "arka.integrations.gemini_cli",
101
+ "arka_harvard_ark": "arka.integrations.harvard_ark",
102
+ "arka_fugu": "arka.integrations.fugu",
103
+ "arka_benchmark": "arka.integrations.benchmark_cli",
104
+ "arka_qr": "arka.integrations.qr_code",
105
+ "arka_mac_mic": "arka.integrations.mac_mic",
106
+ "arka_pdf_rag": "arka.pdf.rag",
107
+ "arka_pdf_tools": "arka.pdf.tools",
108
+ "arka_generate_image": "arka.generate.image",
109
+ "arka_generate_video": "arka.generate.video",
110
+ "arka_compose_slides": "arka.media.compose_slides",
111
+ "arka_compose_3d": "arka.media.compose_3d",
112
+ "arka_text_to_3d": "arka.agent.text_to_3d",
113
+ "arka_convert_media": "arka.media.convert_media",
114
+ "arka_chart": "arka.charts.plot",
115
+ "arka_ascii_art": "arka.agent.ascii_art",
116
+ "arka_flow": "arka.agent.flow",
117
+ "arka_fact_check": "arka.agent.fact_check",
118
+ "arka_astronomy": "arka.agent.astronomy",
119
+ "arka_metallurgy": "arka.agent.metallurgy",
120
+ "arka_three_d": "arka.media.compose_3d",
121
+ "arka_elon": "arka.agent.personas.elon",
122
+ "arka_persona": "arka.agent.personas.cli",
123
+ "arka_drawing": "arka.documents.drawing",
124
+ "arka_describe_image": "arka.vision.describe",
125
+ "arka_describe_video": "arka.vision.video",
126
+ "arka_aie": "arka.aie.cli",
127
+ "web_answer": "arka.agent.web_answer",
128
+ "edge_speak": "arka.voice.edge_speak",
129
+ "indic_tts": "arka.voice.indic_tts",
130
+ "sarvam_speak": "arka.voice.sarvam_speak",
131
+ "sarvam_stt": "arka.voice.sarvam_stt",
132
+ "spotify_dom": "arka.integrations.spotify_dom",
133
+ }
134
+
135
+ _bootstrapped = False
136
+
137
+
138
+ def _ensure_src_on_path() -> None:
139
+ src_root = str(_ROOT / "src")
140
+ if src_root not in sys.path:
141
+ sys.path.insert(0, src_root)
142
+
143
+
144
+ def install_legacy_aliases() -> None:
145
+ for legacy, qualname in LEGACY_MODULES.items():
146
+ if legacy in sys.modules:
147
+ continue
148
+ try:
149
+ sys.modules[legacy] = importlib.import_module(qualname)
150
+ except ImportError:
151
+ continue
152
+
153
+
154
+ def bootstrap() -> None:
155
+ global _bootstrapped
156
+ if _bootstrapped:
157
+ return
158
+ _ensure_src_on_path()
159
+ _bootstrapped = True
160
+
161
+
162
+ def run_legacy_module(qualname: str) -> int:
163
+ """Run a package module's ``main()`` or ``__main__`` block."""
164
+ bootstrap()
165
+ mod = importlib.import_module(qualname)
166
+ main = getattr(mod, "main", None)
167
+ if callable(main):
168
+ try:
169
+ params = list(inspect.signature(main).parameters)
170
+ except (TypeError, ValueError):
171
+ params = []
172
+ if params and params[0] in ("argv", "args"):
173
+ return int(main(sys.argv[1:]) or 0)
174
+ return int(main() or 0)
175
+ import runpy
176
+
177
+ runpy.run_module(qualname, run_name="__main__", alter_sys=True)
178
+ return 0
179
+
180
+
181
+ def legacy_shim(qualname: str) -> ModuleType:
182
+ bootstrap()
183
+ return importlib.import_module(qualname)
arka/agent/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """Arka agent."""
@@ -0,0 +1,52 @@
1
+ """Detect and validate common app build/test commands."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import json
6
+ import subprocess
7
+ from pathlib import Path
8
+
9
+
10
+ def commands(root: Path) -> list[list[str]]:
11
+ if (root / "package.json").is_file():
12
+ return [["npm", "run", "build"], ["npm", "test", "--", "--runInBand"]]
13
+ if (root / "pyproject.toml").is_file() or (root / "setup.py").is_file():
14
+ return [["python", "-m", "compileall", "-q", "."], ["python", "-m", "pytest", "-q"]]
15
+ if (root / "Cargo.toml").is_file():
16
+ return [["cargo", "check"], ["cargo", "test"]]
17
+ if (root / "go.mod").is_file():
18
+ return [["go", "build", "./..."], ["go", "test", "./..."]]
19
+ return []
20
+
21
+
22
+ def check(root: str = ".", *, run: bool = False) -> dict:
23
+ path = Path(root).expanduser().resolve()
24
+ plan = commands(path)
25
+ results = []
26
+ if run:
27
+ for command in plan:
28
+ proc = subprocess.run(command, cwd=path, text=True, capture_output=True, timeout=900, check=False)
29
+ results.append({"command": command, "exit_code": proc.returncode, "output": (proc.stdout + proc.stderr)[-4000:]})
30
+ if proc.returncode:
31
+ break
32
+ return {"root": str(path), "commands": plan, "results": results, "ok": not results or all(item["exit_code"] == 0 for item in results)}
33
+
34
+
35
+ def main(argv: list[str] | None = None) -> int:
36
+ parser = argparse.ArgumentParser(prog="arka app-check")
37
+ parser.add_argument("path", nargs="?", default=".")
38
+ parser.add_argument("--run", action="store_true", help="Run the detected build and test checks")
39
+ parser.add_argument("--json", action="store_true")
40
+ args = parser.parse_args(argv)
41
+ payload = check(args.path, run=args.run)
42
+ if args.json:
43
+ print(json.dumps(payload, indent=2))
44
+ else:
45
+ print(f"Detected checks for {payload['root']}:")
46
+ for command in payload["commands"]:
47
+ print(" "+" ".join(command))
48
+ for result in payload["results"]:
49
+ print(f" {'PASS' if result['exit_code'] == 0 else 'FAIL'} {' '.join(result['command'])}")
50
+ if result["exit_code"]:
51
+ print(result["output"])
52
+ return 0 if payload["ok"] else 1
@@ -0,0 +1,315 @@
1
+ #!/usr/bin/env python3
2
+ """Render text or images as ASCII art in the terminal."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import re
8
+ import shlex
9
+ import shutil
10
+ import subprocess
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ DEFAULT_FONT = "standard"
15
+ ASCII_CHARS = "@%#*+=-:. "
16
+ _IMAGE_EXT = r"(?:jpg|jpeg|png|gif|webp|bmp|tiff|tif)"
17
+
18
+ # Minimal 5-row block font (A–Z, 0–9, space) when figlet/pyfiglet unavailable.
19
+ _BLOCK_FONT: dict[str, list[str]] = {
20
+ " ": [" ", " ", " ", " ", " "],
21
+ "0": [" ### ", "# #", "# ##", "# # #", " ### "],
22
+ "1": [" # ", " ## ", " # ", " # ", " ### "],
23
+ "2": [" ### ", "# #", " # ", " # ", "#####"],
24
+ "3": [" ### ", " #", " ### ", " #", " ### "],
25
+ "4": [" # #", "# # ", "#####", " # ", " # "],
26
+ "5": ["#####", "# ", "#### ", " #", "#### "],
27
+ "6": [" ### ", "# ", "#### ", "# #", " ### "],
28
+ "7": ["#####", " # ", " # ", " # ", " # "],
29
+ "8": [" ### ", "# #", " ### ", "# #", " ### "],
30
+ "9": [" ### ", "# #", " ####", " #", " ### "],
31
+ "A": [" ### ", "# #", "#####", "# #", "# #"],
32
+ "B": ["#### ", "# #", "#### ", "# #", "#### "],
33
+ "C": [" ### ", "# #", "# ", "# #", " ### "],
34
+ "D": ["#### ", "# #", "# #", "# #", "#### "],
35
+ "E": ["#####", "# ", "#### ", "# ", "#####"],
36
+ "F": ["#####", "# ", "#### ", "# ", "# "],
37
+ "G": [" ### ", "# ", "# ##", "# #", " ### "],
38
+ "H": ["# #", "# #", "#####", "# #", "# #"],
39
+ "I": [" ### ", " # ", " # ", " # ", " ### "],
40
+ "J": [" ###", " # ", " # ", "# # ", " ## "],
41
+ "K": ["# #", "# # ", "### ", "# # ", "# #"],
42
+ "L": ["# ", "# ", "# ", "# ", "#####"],
43
+ "M": ["# #", "## ##", "# # #", "# #", "# #"],
44
+ "N": ["# #", "## #", "# # #", "# ##", "# #"],
45
+ "O": [" ### ", "# #", "# #", "# #", " ### "],
46
+ "P": ["#### ", "# #", "#### ", "# ", "# "],
47
+ "Q": [" ### ", "# #", "# #", "# ##", " ### "],
48
+ "R": ["#### ", "# #", "#### ", "# # ", "# #"],
49
+ "S": [" ####", "# ", " ### ", " #", "#### "],
50
+ "T": ["#####", " # ", " # ", " # ", " # "],
51
+ "U": ["# #", "# #", "# #", "# #", " ### "],
52
+ "V": ["# #", "# #", "# #", " # # ", " # "],
53
+ "W": ["# #", "# #", "# # #", "## ##", "# #"],
54
+ "X": ["# #", " # # ", " # ", " # # ", "# #"],
55
+ "Y": ["# #", " # # ", " # ", " # ", " # "],
56
+ "Z": ["#####", " # ", " # ", " # ", "#####"],
57
+ }
58
+
59
+
60
+ def _is_ascii_art_request(text: str) -> bool:
61
+ t = text.strip()
62
+ if not t:
63
+ return False
64
+ if re.search(rf"(?i)\b(?:from|of)\s+.+\.{_IMAGE_EXT}\b", t):
65
+ return True
66
+ if re.search(rf"(?i)\b.+\.{_IMAGE_EXT}\s+(?:to|into)\s+ascii", t):
67
+ return True
68
+ return bool(
69
+ re.search(
70
+ r"(?i)(?:^|\b)(?:make|create|show|print|render|draw)\s+(?:an?\s+)?ascii\s+(?:art|banner|text)\b",
71
+ t,
72
+ )
73
+ or re.search(r"(?i)(?:^|\b)ascii\s+(?:art|banner)\b", t)
74
+ or re.search(r"(?i)(?:^|\b)figlet\b", t)
75
+ or re.match(r"(?i)^ascii\s+\S", t)
76
+ )
77
+
78
+
79
+ def _extract_text_prompt(text: str) -> str:
80
+ t = text.strip()
81
+ for pat in (
82
+ r"(?i)^(?:make|create|show|print|render|draw)\s+(?:an?\s+)?ascii\s+(?:art|banner|text)\s+(?:of|for|with|say(?:ing)?|that\s+says)?\s*",
83
+ r"(?i)^ascii\s+(?:art|banner)\s+(?:of|for|with|say(?:ing)?|that\s+says)?\s*",
84
+ r"(?i)^figlet\s+",
85
+ r"(?i)^ascii\s+",
86
+ ):
87
+ t = re.sub(pat, "", t).strip()
88
+ return t.strip("'\"")
89
+
90
+
91
+ def _extract_image_path(text: str) -> str:
92
+ t = text.strip()
93
+ m = re.search(rf"(?i)(?:from|of)\s+([^\s'\"]+\.{_IMAGE_EXT})\b", t)
94
+ if m:
95
+ return m.group(1)
96
+ m = re.search(rf"(?i)([^\s'\"]+\.{_IMAGE_EXT})\s+(?:to|into)\s+ascii", t)
97
+ if m:
98
+ return m.group(1)
99
+ return ""
100
+
101
+
102
+ def nl_to_argv(text: str) -> list[str]:
103
+ t = text.strip()
104
+ if not t or not _is_ascii_art_request(t):
105
+ return []
106
+
107
+ img = _extract_image_path(t)
108
+ if img:
109
+ argv = ["--from-image", img]
110
+ m = re.search(r"(?i)--width\s+(\d+)", t)
111
+ if m:
112
+ argv.extend(["--width", m.group(1)])
113
+ return argv
114
+
115
+ prompt = _extract_text_prompt(t)
116
+ m = re.search(r"(?i)(?:font|style)\s+([a-z0-9_-]+)", t)
117
+ if m:
118
+ prompt = re.sub(r"(?i)\s*(?:font|style)\s+[a-z0-9_-]+\s*$", "", prompt).strip()
119
+ if not prompt:
120
+ return []
121
+
122
+ argv = [prompt]
123
+ if m:
124
+ argv[:0] = ["--font", m.group(1)]
125
+ return argv
126
+
127
+
128
+ def _render_pyfiglet(text: str, font: str) -> str | None:
129
+ try:
130
+ import pyfiglet
131
+ except ImportError:
132
+ return None
133
+ try:
134
+ return pyfiglet.figlet_format(text, font=font)
135
+ except Exception:
136
+ try:
137
+ return pyfiglet.figlet_format(text, font=DEFAULT_FONT)
138
+ except Exception:
139
+ return None
140
+
141
+
142
+ def _render_system_figlet(text: str, font: str) -> str | None:
143
+ exe = shutil.which("figlet")
144
+ if not exe:
145
+ return None
146
+ for f in (font, DEFAULT_FONT):
147
+ try:
148
+ proc = subprocess.run(
149
+ [exe, "-f", f, text],
150
+ capture_output=True,
151
+ text=True,
152
+ timeout=15,
153
+ check=False,
154
+ )
155
+ if proc.returncode == 0 and proc.stdout.strip():
156
+ return proc.stdout
157
+ except (OSError, subprocess.TimeoutExpired):
158
+ continue
159
+ return None
160
+
161
+
162
+ def _render_npx_figlet(text: str) -> str | None:
163
+ if not shutil.which("npx"):
164
+ return None
165
+ try:
166
+ proc = subprocess.run(
167
+ ["npx", "--yes", "figlet-cli", text],
168
+ capture_output=True,
169
+ text=True,
170
+ timeout=45,
171
+ check=False,
172
+ )
173
+ if proc.returncode == 0 and proc.stdout.strip():
174
+ return proc.stdout
175
+ except (OSError, subprocess.TimeoutExpired):
176
+ pass
177
+ return None
178
+
179
+
180
+ def _render_block_fallback(text: str) -> str:
181
+ rows = [""] * 5
182
+ for ch in text.upper():
183
+ glyph = _BLOCK_FONT.get(ch, _BLOCK_FONT.get("?"))
184
+ if glyph is None:
185
+ glyph = [" ? ", " # # ", " # ", " # # ", " ? "]
186
+ for i, line in enumerate(glyph):
187
+ rows[i] += line + " "
188
+ return "\n".join(rows).rstrip() + "\n"
189
+
190
+
191
+ def render_text(text: str, font: str = DEFAULT_FONT) -> str:
192
+ text = text.strip()
193
+ if not text:
194
+ raise ValueError("empty text")
195
+ for fn in (
196
+ lambda: _render_pyfiglet(text, font),
197
+ lambda: _render_system_figlet(text, font),
198
+ lambda: _render_npx_figlet(text),
199
+ ):
200
+ out = fn()
201
+ if out:
202
+ return out if out.endswith("\n") else out + "\n"
203
+ return _render_block_fallback(text)
204
+
205
+
206
+ def image_to_ascii(path: Path, width: int = 80) -> str:
207
+ try:
208
+ from PIL import Image
209
+ except ImportError as exc:
210
+ raise SystemExit(
211
+ "Pillow is required for image-to-ASCII.\n"
212
+ "Install: pip install Pillow\n"
213
+ "Or: pip install 'arka-agent[vision]'"
214
+ ) from exc
215
+
216
+ if not path.is_file():
217
+ raise SystemExit(f"Image not found: {path}")
218
+
219
+ width = max(20, min(width, 200))
220
+ img = Image.open(path).convert("L")
221
+ aspect = img.height / img.width if img.width else 1
222
+ height = max(1, int(width * aspect * 0.55))
223
+ img = img.resize((width, height))
224
+
225
+ lines: list[str] = []
226
+ pixels = img.load()
227
+ for y in range(height):
228
+ row = []
229
+ for x in range(width):
230
+ lum = pixels[x, y] if pixels is not None else 0
231
+ idx = int(lum / 256 * len(ASCII_CHARS))
232
+ idx = min(idx, len(ASCII_CHARS) - 1)
233
+ row.append(ASCII_CHARS[idx])
234
+ lines.append("".join(row))
235
+ return "\n".join(lines) + "\n"
236
+
237
+
238
+ def render_and_output(
239
+ *,
240
+ text: str = "",
241
+ font: str = DEFAULT_FONT,
242
+ from_image: str = "",
243
+ width: int = 80,
244
+ output: str = "",
245
+ ) -> int:
246
+ if from_image:
247
+ art = image_to_ascii(Path(from_image).expanduser(), width=width)
248
+ else:
249
+ if not text.strip():
250
+ print("Usage: ascii_art <text> [--font NAME] [-o path]", file=sys.stderr)
251
+ print(" ascii_art --from-image photo.jpg [--width 80]", file=sys.stderr)
252
+ return 1
253
+ art = render_text(text, font=font)
254
+
255
+ print(art, end="" if art.endswith("\n") else "\n")
256
+
257
+ if output:
258
+ out = Path(output).expanduser()
259
+ out.parent.mkdir(parents=True, exist_ok=True)
260
+ out.write_text(art, encoding="utf-8")
261
+ print(f"Saved: {out}")
262
+
263
+ return 0
264
+
265
+
266
+ def cmd_parse(args: argparse.Namespace) -> int:
267
+ argv = nl_to_argv(" ".join(args.text))
268
+ if not argv:
269
+ return 1
270
+ print(" ".join(shlex.quote(a) for a in argv))
271
+ return 0
272
+
273
+
274
+ def build_parser() -> argparse.ArgumentParser:
275
+ p = argparse.ArgumentParser(description="Render ASCII art (figlet / pyfiglet / image)")
276
+ sub = p.add_subparsers(dest="cmd")
277
+
278
+ p_parse = sub.add_parser("parse", help="Parse natural language → ascii_art args")
279
+ p_parse.add_argument("text", nargs="+")
280
+ p_parse.set_defaults(func=cmd_parse)
281
+
282
+ return p
283
+
284
+
285
+ def main(argv: list[str] | None = None) -> int:
286
+ argv = list(argv if argv is not None else sys.argv[1:])
287
+ if argv and argv[0] == "parse":
288
+ args = build_parser().parse_args(argv)
289
+ return args.func(args)
290
+
291
+ if argv and argv[0] in {"-h", "--help", "help"}:
292
+ build_parser().print_help()
293
+ return 0
294
+
295
+ nl = nl_to_argv(" ".join(argv))
296
+ if nl and not any(a.startswith("-") for a in argv[:2]):
297
+ argv = nl
298
+
299
+ parser = argparse.ArgumentParser(description="Render ASCII art (figlet / pyfiglet / image)")
300
+ parser.add_argument("text", nargs="*", help="Text to render")
301
+ parser.add_argument("-f", "--font", default=DEFAULT_FONT, help="Figlet font name")
302
+ parser.add_argument("--from-image", metavar="PATH", help="Convert image to ASCII")
303
+ parser.add_argument("--width", type=int, default=80, help="Image ASCII width (default 80)")
304
+ parser.add_argument("-o", "--output", help="Save output to file (also prints to terminal)")
305
+ args = parser.parse_args(argv)
306
+
307
+ if args.from_image:
308
+ return render_and_output(from_image=args.from_image, width=args.width, output=args.output or "")
309
+
310
+ text = " ".join(args.text).strip()
311
+ return render_and_output(text=text, font=args.font, output=args.output or "")
312
+
313
+
314
+ if __name__ == "__main__":
315
+ raise SystemExit(main())