klir-bot 0.1.0__tar.gz

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 (264) hide show
  1. klir_bot-0.1.0/.gitignore +59 -0
  2. klir_bot-0.1.0/Dockerfile.sandbox +48 -0
  3. klir_bot-0.1.0/LICENSE +21 -0
  4. klir_bot-0.1.0/PKG-INFO +364 -0
  5. klir_bot-0.1.0/README.md +325 -0
  6. klir_bot-0.1.0/config.example.json +96 -0
  7. klir_bot-0.1.0/docs/README.md +80 -0
  8. klir_bot-0.1.0/klir/__init__.py +3 -0
  9. klir_bot-0.1.0/klir/__main__.py +302 -0
  10. klir_bot-0.1.0/klir/_banner.txt +13 -0
  11. klir_bot-0.1.0/klir/_home_defaults/RULES.md +73 -0
  12. klir_bot-0.1.0/klir/_home_defaults/config/RULES-all-clis.md +107 -0
  13. klir_bot-0.1.0/klir/_home_defaults/config/RULES-claude-only.md +87 -0
  14. klir_bot-0.1.0/klir/_home_defaults/config/RULES-codex-only.md +95 -0
  15. klir_bot-0.1.0/klir/_home_defaults/config/RULES-gemini-only.md +93 -0
  16. klir_bot-0.1.0/klir/_home_defaults/workspace/RULES.md +175 -0
  17. klir_bot-0.1.0/klir/_home_defaults/workspace/cron_tasks/RULES-all-clis.md +155 -0
  18. klir_bot-0.1.0/klir/_home_defaults/workspace/cron_tasks/RULES-claude-only.md +88 -0
  19. klir_bot-0.1.0/klir/_home_defaults/workspace/cron_tasks/RULES-codex-only.md +111 -0
  20. klir_bot-0.1.0/klir/_home_defaults/workspace/cron_tasks/RULES-gemini-only.md +100 -0
  21. klir_bot-0.1.0/klir/_home_defaults/workspace/memory_system/MAINMEMORY.md +13 -0
  22. klir_bot-0.1.0/klir/_home_defaults/workspace/memory_system/RULES.md +51 -0
  23. klir_bot-0.1.0/klir/_home_defaults/workspace/output_to_user/RULES.md +20 -0
  24. klir_bot-0.1.0/klir/_home_defaults/workspace/skills/RULES.md +44 -0
  25. klir_bot-0.1.0/klir/_home_defaults/workspace/skills/skill-creator/LICENSE.txt +202 -0
  26. klir_bot-0.1.0/klir/_home_defaults/workspace/skills/skill-creator/SKILL.md +357 -0
  27. klir_bot-0.1.0/klir/_home_defaults/workspace/skills/skill-creator/references/output-patterns.md +82 -0
  28. klir_bot-0.1.0/klir/_home_defaults/workspace/skills/skill-creator/references/workflows.md +28 -0
  29. klir_bot-0.1.0/klir/_home_defaults/workspace/skills/skill-creator/scripts/init_skill.py +304 -0
  30. klir_bot-0.1.0/klir/_home_defaults/workspace/skills/skill-creator/scripts/package_skill.py +111 -0
  31. klir_bot-0.1.0/klir/_home_defaults/workspace/skills/skill-creator/scripts/quick_validate.py +107 -0
  32. klir_bot-0.1.0/klir/_home_defaults/workspace/tasks/RULES.md +17 -0
  33. klir_bot-0.1.0/klir/_home_defaults/workspace/telegram_files/RULES.md +43 -0
  34. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/RULES.md +48 -0
  35. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/_tool_shared.py +71 -0
  36. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/agent_tools/RULES.md +148 -0
  37. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/agent_tools/ask_agent.py +83 -0
  38. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/agent_tools/ask_agent_async.py +114 -0
  39. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/agent_tools/create_agent.py +201 -0
  40. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/agent_tools/edit_shared_knowledge.py +84 -0
  41. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/agent_tools/list_agents.py +72 -0
  42. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/agent_tools/remove_agent.py +70 -0
  43. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/RULES-all-clis.md +156 -0
  44. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/RULES-claude-only.md +106 -0
  45. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/RULES-codex-only.md +118 -0
  46. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/RULES-gemini-only.md +109 -0
  47. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/_shared.py +119 -0
  48. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/cron_add.py +368 -0
  49. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/cron_edit.py +381 -0
  50. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/cron_list.py +83 -0
  51. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/cron_remove.py +153 -0
  52. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/cron_tools/cron_time.py +103 -0
  53. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/task_tools/RULES.md +83 -0
  54. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/task_tools/_shared.py +72 -0
  55. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/task_tools/ask_parent.py +59 -0
  56. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/task_tools/cancel_task.py +46 -0
  57. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/task_tools/create_task.py +107 -0
  58. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/task_tools/delete_task.py +47 -0
  59. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/task_tools/list_tasks.py +55 -0
  60. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/task_tools/resume_task.py +60 -0
  61. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/telegram_tools/RULES.md +35 -0
  62. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/telegram_tools/file_info.py +92 -0
  63. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/telegram_tools/list_files.py +83 -0
  64. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/telegram_tools/process_video.py +273 -0
  65. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/telegram_tools/read_document.py +110 -0
  66. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/telegram_tools/transcribe_audio.py +151 -0
  67. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/user_tools/RULES.md +31 -0
  68. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/RULES-all-clis.md +318 -0
  69. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/RULES-claude-only.md +236 -0
  70. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/RULES-codex-only.md +258 -0
  71. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/RULES-gemini-only.md +244 -0
  72. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/_shared.py +61 -0
  73. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/webhook_add.py +442 -0
  74. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/webhook_edit.py +282 -0
  75. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/webhook_list.py +73 -0
  76. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/webhook_remove.py +83 -0
  77. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/webhook_rotate_token.py +124 -0
  78. klir_bot-0.1.0/klir/_home_defaults/workspace/tools/webhook_tools/webhook_test.py +195 -0
  79. klir_bot-0.1.0/klir/api/__init__.py +6 -0
  80. klir_bot-0.1.0/klir/api/crypto.py +50 -0
  81. klir_bot-0.1.0/klir/api/server.py +633 -0
  82. klir_bot-0.1.0/klir/approval.py +94 -0
  83. klir_bot-0.1.0/klir/background/__init__.py +8 -0
  84. klir_bot-0.1.0/klir/background/models.py +55 -0
  85. klir_bot-0.1.0/klir/background/observer.py +278 -0
  86. klir_bot-0.1.0/klir/bot/__init__.py +38 -0
  87. klir_bot-0.1.0/klir/bot/abort.py +71 -0
  88. klir_bot-0.1.0/klir/bot/app.py +1587 -0
  89. klir_bot-0.1.0/klir/bot/approval_handler.py +124 -0
  90. klir_bot-0.1.0/klir/bot/binding_cleanup.py +75 -0
  91. klir_bot-0.1.0/klir/bot/buttons.py +140 -0
  92. klir_bot-0.1.0/klir/bot/callbacks.py +120 -0
  93. klir_bot-0.1.0/klir/bot/chat_tracker.py +135 -0
  94. klir_bot-0.1.0/klir/bot/conflict_detector.py +56 -0
  95. klir_bot-0.1.0/klir/bot/dedup.py +78 -0
  96. klir_bot-0.1.0/klir/bot/edit_streaming.py +426 -0
  97. klir_bot-0.1.0/klir/bot/file_browser.py +140 -0
  98. klir_bot-0.1.0/klir/bot/formatting.py +209 -0
  99. klir_bot-0.1.0/klir/bot/forward_context.py +49 -0
  100. klir_bot-0.1.0/klir/bot/forward_parser.py +36 -0
  101. klir_bot-0.1.0/klir/bot/forward_sender.py +53 -0
  102. klir_bot-0.1.0/klir/bot/handlers.py +196 -0
  103. klir_bot-0.1.0/klir/bot/media.py +292 -0
  104. klir_bot-0.1.0/klir/bot/message_dispatch.py +179 -0
  105. klir_bot-0.1.0/klir/bot/middleware.py +439 -0
  106. klir_bot-0.1.0/klir/bot/pair_handler.py +37 -0
  107. klir_bot-0.1.0/klir/bot/poll_parser.py +53 -0
  108. klir_bot-0.1.0/klir/bot/poll_sender.py +37 -0
  109. klir_bot-0.1.0/klir/bot/reactions.py +73 -0
  110. klir_bot-0.1.0/klir/bot/retry.py +135 -0
  111. klir_bot-0.1.0/klir/bot/sender.py +338 -0
  112. klir_bot-0.1.0/klir/bot/session_factory.py +74 -0
  113. klir_bot-0.1.0/klir/bot/startup.py +143 -0
  114. klir_bot-0.1.0/klir/bot/streaming.py +181 -0
  115. klir_bot-0.1.0/klir/bot/topic.py +166 -0
  116. klir_bot-0.1.0/klir/bot/typing.py +56 -0
  117. klir_bot-0.1.0/klir/bot/upgrade_handler.py +207 -0
  118. klir_bot-0.1.0/klir/bot/welcome.py +115 -0
  119. klir_bot-0.1.0/klir/bus/__init__.py +16 -0
  120. klir_bot-0.1.0/klir/bus/adapters.py +270 -0
  121. klir_bot-0.1.0/klir/bus/bus.py +168 -0
  122. klir_bot-0.1.0/klir/bus/envelope.py +89 -0
  123. klir_bot-0.1.0/klir/bus/lock_pool.py +59 -0
  124. klir_bot-0.1.0/klir/bus/telegram_transport.py +279 -0
  125. klir_bot-0.1.0/klir/cleanup/__init__.py +5 -0
  126. klir_bot-0.1.0/klir/cleanup/observer.py +145 -0
  127. klir_bot-0.1.0/klir/cli/__init__.py +33 -0
  128. klir_bot-0.1.0/klir/cli/auth.py +407 -0
  129. klir_bot-0.1.0/klir/cli/base.py +220 -0
  130. klir_bot-0.1.0/klir/cli/claude_provider.py +215 -0
  131. klir_bot-0.1.0/klir/cli/coalescer.py +149 -0
  132. klir_bot-0.1.0/klir/cli/codex_cache.py +126 -0
  133. klir_bot-0.1.0/klir/cli/codex_cache_observer.py +36 -0
  134. klir_bot-0.1.0/klir/cli/codex_discovery.py +149 -0
  135. klir_bot-0.1.0/klir/cli/codex_events.py +283 -0
  136. klir_bot-0.1.0/klir/cli/codex_provider.py +285 -0
  137. klir_bot-0.1.0/klir/cli/executor.py +327 -0
  138. klir_bot-0.1.0/klir/cli/factory.py +27 -0
  139. klir_bot-0.1.0/klir/cli/gemini_cache.py +61 -0
  140. klir_bot-0.1.0/klir/cli/gemini_cache_observer.py +54 -0
  141. klir_bot-0.1.0/klir/cli/gemini_events.py +214 -0
  142. klir_bot-0.1.0/klir/cli/gemini_provider.py +648 -0
  143. klir_bot-0.1.0/klir/cli/gemini_utils.py +455 -0
  144. klir_bot-0.1.0/klir/cli/init_wizard.py +643 -0
  145. klir_bot-0.1.0/klir/cli/model_cache.py +259 -0
  146. klir_bot-0.1.0/klir/cli/param_resolver.py +137 -0
  147. klir_bot-0.1.0/klir/cli/process_registry.py +207 -0
  148. klir_bot-0.1.0/klir/cli/service.py +363 -0
  149. klir_bot-0.1.0/klir/cli/stream_events.py +188 -0
  150. klir_bot-0.1.0/klir/cli/timeout_controller.py +223 -0
  151. klir_bot-0.1.0/klir/cli/types.py +78 -0
  152. klir_bot-0.1.0/klir/cli_commands/__init__.py +1 -0
  153. klir_bot-0.1.0/klir/cli_commands/agents.py +305 -0
  154. klir_bot-0.1.0/klir/cli_commands/api_cmd.py +176 -0
  155. klir_bot-0.1.0/klir/cli_commands/docker.py +522 -0
  156. klir_bot-0.1.0/klir/cli_commands/lifecycle.py +300 -0
  157. klir_bot-0.1.0/klir/cli_commands/service.py +92 -0
  158. klir_bot-0.1.0/klir/cli_commands/status.py +209 -0
  159. klir_bot-0.1.0/klir/commands.py +52 -0
  160. klir_bot-0.1.0/klir/config.py +499 -0
  161. klir_bot-0.1.0/klir/config_reload.py +222 -0
  162. klir_bot-0.1.0/klir/config_resolver.py +74 -0
  163. klir_bot-0.1.0/klir/cron/__init__.py +6 -0
  164. klir_bot-0.1.0/klir/cron/dependency_queue.py +163 -0
  165. klir_bot-0.1.0/klir/cron/execution.py +260 -0
  166. klir_bot-0.1.0/klir/cron/manager.py +196 -0
  167. klir_bot-0.1.0/klir/cron/observer.py +370 -0
  168. klir_bot-0.1.0/klir/errors.py +37 -0
  169. klir_bot-0.1.0/klir/files/__init__.py +1 -0
  170. klir_bot-0.1.0/klir/files/allowed_roots.py +27 -0
  171. klir_bot-0.1.0/klir/files/prompt.py +64 -0
  172. klir_bot-0.1.0/klir/files/storage.py +36 -0
  173. klir_bot-0.1.0/klir/files/tags.py +113 -0
  174. klir_bot-0.1.0/klir/heartbeat/__init__.py +5 -0
  175. klir_bot-0.1.0/klir/heartbeat/observer.py +171 -0
  176. klir_bot-0.1.0/klir/infra/__init__.py +22 -0
  177. klir_bot-0.1.0/klir/infra/atomic_io.py +51 -0
  178. klir_bot-0.1.0/klir/infra/base_observer.py +55 -0
  179. klir_bot-0.1.0/klir/infra/base_task_observer.py +68 -0
  180. klir_bot-0.1.0/klir/infra/boot_id.py +83 -0
  181. klir_bot-0.1.0/klir/infra/docker.py +460 -0
  182. klir_bot-0.1.0/klir/infra/docker_extras.py +292 -0
  183. klir_bot-0.1.0/klir/infra/env_secrets.py +109 -0
  184. klir_bot-0.1.0/klir/infra/file_watcher.py +73 -0
  185. klir_bot-0.1.0/klir/infra/fs.py +57 -0
  186. klir_bot-0.1.0/klir/infra/inflight.py +113 -0
  187. klir_bot-0.1.0/klir/infra/install.py +44 -0
  188. klir_bot-0.1.0/klir/infra/json_store.py +33 -0
  189. klir_bot-0.1.0/klir/infra/pidlock.py +145 -0
  190. klir_bot-0.1.0/klir/infra/platform.py +17 -0
  191. klir_bot-0.1.0/klir/infra/process_tree.py +214 -0
  192. klir_bot-0.1.0/klir/infra/proxy.py +40 -0
  193. klir_bot-0.1.0/klir/infra/recovery.py +104 -0
  194. klir_bot-0.1.0/klir/infra/restart.py +63 -0
  195. klir_bot-0.1.0/klir/infra/service.py +65 -0
  196. klir_bot-0.1.0/klir/infra/service_base.py +134 -0
  197. klir_bot-0.1.0/klir/infra/service_linux.py +254 -0
  198. klir_bot-0.1.0/klir/infra/service_logs.py +81 -0
  199. klir_bot-0.1.0/klir/infra/service_macos.py +237 -0
  200. klir_bot-0.1.0/klir/infra/service_windows.py +315 -0
  201. klir_bot-0.1.0/klir/infra/startup_state.py +89 -0
  202. klir_bot-0.1.0/klir/infra/task_runner.py +130 -0
  203. klir_bot-0.1.0/klir/infra/updater.py +303 -0
  204. klir_bot-0.1.0/klir/infra/version.py +111 -0
  205. klir_bot-0.1.0/klir/log_context.py +69 -0
  206. klir_bot-0.1.0/klir/logging_config.py +137 -0
  207. klir_bot-0.1.0/klir/multiagent/__init__.py +8 -0
  208. klir_bot-0.1.0/klir/multiagent/bus.py +451 -0
  209. klir_bot-0.1.0/klir/multiagent/commands.py +110 -0
  210. klir_bot-0.1.0/klir/multiagent/health.py +55 -0
  211. klir_bot-0.1.0/klir/multiagent/internal_api.py +453 -0
  212. klir_bot-0.1.0/klir/multiagent/models.py +87 -0
  213. klir_bot-0.1.0/klir/multiagent/registry.py +109 -0
  214. klir_bot-0.1.0/klir/multiagent/shared_knowledge.py +129 -0
  215. klir_bot-0.1.0/klir/multiagent/stack.py +72 -0
  216. klir_bot-0.1.0/klir/multiagent/supervisor.py +646 -0
  217. klir_bot-0.1.0/klir/orchestrator/__init__.py +6 -0
  218. klir_bot-0.1.0/klir/orchestrator/commands.py +356 -0
  219. klir_bot-0.1.0/klir/orchestrator/core.py +722 -0
  220. klir_bot-0.1.0/klir/orchestrator/directives.py +65 -0
  221. klir_bot-0.1.0/klir/orchestrator/flows.py +704 -0
  222. klir_bot-0.1.0/klir/orchestrator/hooks.py +131 -0
  223. klir_bot-0.1.0/klir/orchestrator/injection.py +316 -0
  224. klir_bot-0.1.0/klir/orchestrator/lifecycle.py +193 -0
  225. klir_bot-0.1.0/klir/orchestrator/observers.py +214 -0
  226. klir_bot-0.1.0/klir/orchestrator/providers.py +198 -0
  227. klir_bot-0.1.0/klir/orchestrator/registry.py +77 -0
  228. klir_bot-0.1.0/klir/orchestrator/selectors/__init__.py +1 -0
  229. klir_bot-0.1.0/klir/orchestrator/selectors/cron_selector.py +201 -0
  230. klir_bot-0.1.0/klir/orchestrator/selectors/model_selector.py +426 -0
  231. klir_bot-0.1.0/klir/orchestrator/selectors/models.py +28 -0
  232. klir_bot-0.1.0/klir/orchestrator/selectors/session_selector.py +152 -0
  233. klir_bot-0.1.0/klir/orchestrator/selectors/task_selector.py +221 -0
  234. klir_bot-0.1.0/klir/orchestrator/selectors/utils.py +14 -0
  235. klir_bot-0.1.0/klir/pairing.py +93 -0
  236. klir_bot-0.1.0/klir/security/__init__.py +11 -0
  237. klir_bot-0.1.0/klir/security/content.py +98 -0
  238. klir_bot-0.1.0/klir/security/paths.py +52 -0
  239. klir_bot-0.1.0/klir/session/__init__.py +8 -0
  240. klir_bot-0.1.0/klir/session/key.py +41 -0
  241. klir_bot-0.1.0/klir/session/manager.py +595 -0
  242. klir_bot-0.1.0/klir/session/named.py +342 -0
  243. klir_bot-0.1.0/klir/tasks/__init__.py +1 -0
  244. klir_bot-0.1.0/klir/tasks/hub.py +559 -0
  245. klir_bot-0.1.0/klir/tasks/models.py +131 -0
  246. klir_bot-0.1.0/klir/tasks/registry.py +301 -0
  247. klir_bot-0.1.0/klir/text/__init__.py +0 -0
  248. klir_bot-0.1.0/klir/text/response_format.py +163 -0
  249. klir_bot-0.1.0/klir/utils/__init__.py +0 -0
  250. klir_bot-0.1.0/klir/utils/quiet_hours.py +42 -0
  251. klir_bot-0.1.0/klir/webhook/__init__.py +6 -0
  252. klir_bot-0.1.0/klir/webhook/auth.py +172 -0
  253. klir_bot-0.1.0/klir/webhook/manager.py +100 -0
  254. klir_bot-0.1.0/klir/webhook/models.py +143 -0
  255. klir_bot-0.1.0/klir/webhook/observer.py +308 -0
  256. klir_bot-0.1.0/klir/webhook/server.py +171 -0
  257. klir_bot-0.1.0/klir/workspace/__init__.py +41 -0
  258. klir_bot-0.1.0/klir/workspace/cron_tasks.py +232 -0
  259. klir_bot-0.1.0/klir/workspace/init.py +484 -0
  260. klir_bot-0.1.0/klir/workspace/loader.py +26 -0
  261. klir_bot-0.1.0/klir/workspace/paths.py +193 -0
  262. klir_bot-0.1.0/klir/workspace/rules_selector.py +263 -0
  263. klir_bot-0.1.0/klir/workspace/skill_sync.py +430 -0
  264. klir_bot-0.1.0/pyproject.toml +201 -0
@@ -0,0 +1,59 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ *.egg
7
+ .eggs/
8
+ dist/
9
+ build/
10
+ *.whl
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # Type checking & linting
18
+ .mypy_cache/
19
+ .ruff_cache/
20
+ .dmypy.json
21
+ dmypy.json
22
+
23
+ # Testing
24
+ .pytest_cache/
25
+ .coverage
26
+ .coverage.*
27
+ coverage.xml
28
+ htmlcov/
29
+ .hypothesis/
30
+
31
+ # IDE & editors
32
+ .idea/
33
+ .vscode/
34
+ .claude/
35
+ *.swp
36
+ *.swo
37
+ *.swn
38
+ *~
39
+ .project
40
+ .settings/
41
+
42
+ # OS
43
+ .DS_Store
44
+ Thumbs.db
45
+ desktop.ini
46
+
47
+ # Environment & secrets
48
+ .env
49
+ .env.*
50
+
51
+ # Runtime
52
+ *.pid
53
+ *.log
54
+ *.sock
55
+
56
+ # Personal / dev-only (not part of the project)
57
+ start_bot.sh
58
+ python_best_practice.md
59
+ run.py
@@ -0,0 +1,48 @@
1
+ # Dockerfile.sandbox -- lightweight sandbox for klir CLI execution.
2
+ # Based on Node 22 (Debian bookworm) with Python 3, Claude Code CLI,
3
+ # and Codex CLI pre-installed. The container runs "sleep infinity" so
4
+ # klir can `docker exec` into it on demand.
5
+
6
+ FROM node:22-bookworm-slim
7
+
8
+ ENV DEBIAN_FRONTEND=noninteractive \
9
+ LANG=en_US.UTF-8 \
10
+ LC_ALL=en_US.UTF-8 \
11
+ PIP_BREAK_SYSTEM_PACKAGES=1
12
+
13
+ # System packages: Python, build tools, Git, locale support
14
+ RUN apt-get update \
15
+ && apt-get install -y --no-install-recommends \
16
+ python3 python3-pip python3-venv python3-dev \
17
+ build-essential git curl ca-certificates sudo locales \
18
+ && sed -i '/en_US.UTF-8/s/^# //' /etc/locale.gen && locale-gen \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Chrome/Chromium runtime dependencies for browser-based skills
22
+ # (e.g. patchright, playwright). Only shared libraries -- no browser binary.
23
+ RUN apt-get update \
24
+ && apt-get install -y --no-install-recommends \
25
+ libasound2 libatk-bridge2.0-0 libatk1.0-0 libcairo2 libcups2 \
26
+ libdbus-1-3 libdrm2 libexpat1 libgbm1 libglib2.0-0 libnspr4 \
27
+ libnss3 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 \
28
+ libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 \
29
+ libxrandr2 libxshmfence1 \
30
+ fonts-liberation fonts-noto-color-emoji \
31
+ && rm -rf /var/lib/apt/lists/*
32
+
33
+ # Allow pip installs without the "externally managed" guard
34
+ RUN rm -f /usr/lib/python*/EXTERNALLY-MANAGED
35
+
36
+ # Install Claude Code CLI and Codex CLI
37
+ RUN npm install -g @anthropic-ai/claude-code @openai/codex @google/gemini-cli
38
+
39
+ # Prepare a writable data directory
40
+ RUN mkdir -p /data && chown node:node /data
41
+
42
+ # Let the `node` user run sudo without a password (useful for apt inside sandbox)
43
+ RUN echo "node ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/node
44
+
45
+ USER node
46
+ WORKDIR /workspace
47
+
48
+ CMD ["sleep", "infinity"]
klir_bot-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 PleasePrompto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,364 @@
1
+ Metadata-Version: 2.4
2
+ Name: klir-bot
3
+ Version: 0.1.0
4
+ Summary: Control AI coding CLIs from Telegram. Live streaming, sessions, cron jobs, webhooks, Docker sandboxing. Originally forked from ductor by PleasePrompto.
5
+ Project-URL: Repository, https://github.com/js-krinay/klir
6
+ Project-URL: Issues, https://github.com/js-krinay/klir/issues
7
+ Project-URL: Changelog, https://github.com/js-krinay/klir/releases
8
+ Author: Jinay Shah
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent,ai,automation,bot,claude,cli,codex,klir,streaming,telegram
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Framework :: AsyncIO
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Communications :: Chat
24
+ Classifier: Topic :: Software Development
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.11
27
+ Requires-Dist: aiogram<4.0.0,>=3.24.0
28
+ Requires-Dist: aiohttp<4.0.0,>=3.9.0
29
+ Requires-Dist: cronsim>=2.7
30
+ Requires-Dist: filetype>=1.2.0
31
+ Requires-Dist: pydantic>=2.12.5
32
+ Requires-Dist: pyyaml>=6.0.3
33
+ Requires-Dist: questionary>=2.1.1
34
+ Requires-Dist: rich>=14.3.2
35
+ Requires-Dist: tzdata>=2024.1
36
+ Provides-Extra: api
37
+ Requires-Dist: pynacl>=1.6.2; extra == 'api'
38
+ Description-Content-Type: text/markdown
39
+
40
+ <p align="center">
41
+ <img src="https://raw.githubusercontent.com/js-krinay/klir/main/klir/bot/klir_images/logo_text.png" alt="klir" width="100%" />
42
+ </p>
43
+
44
+ <p align="center">
45
+ <strong>Claude Code, Codex CLI, and Gemini CLI as your Telegram assistant.</strong><br>
46
+ Uses only official CLIs. Nothing spoofed, nothing proxied.
47
+ </p>
48
+
49
+ <p align="center">
50
+ <a href="https://pypi.org/project/klir/"><img src="https://img.shields.io/pypi/v/klir?color=blue" alt="PyPI" /></a>
51
+ <a href="https://pypi.org/project/klir/"><img src="https://img.shields.io/pypi/pyversions/klir?v=1" alt="Python" /></a>
52
+ <a href="https://github.com/js-krinay/klir/blob/main/LICENSE"><img src="https://img.shields.io/github/license/js-krinay/klir" alt="License" /></a>
53
+ </p>
54
+
55
+ <p align="center">
56
+ <a href="#quick-start">Quick start</a> &middot;
57
+ <a href="#how-chats-work">How chats work</a> &middot;
58
+ <a href="#telegram-commands">Commands</a> &middot;
59
+ <a href="docs/README.md">Docs</a> &middot;
60
+ <a href="#contributing">Contributing</a>
61
+ </p>
62
+
63
+ ---
64
+
65
+ If you want to control Claude Code, Google's Gemini CLI, or OpenAI's Codex CLI via Telegram, build automations, or manage multiple agents easily — klir is the right tool for you.
66
+
67
+ klir runs on your machine and sends simple console commands as if you were typing them yourself, so you can use your active subscriptions (Claude Max, etc.) directly. No API proxying, no SDK patching, no spoofed headers. Just the official CLIs, executed as subprocesses, with all state kept in plain JSON and Markdown under `~/.klir/`.
68
+
69
+ <p align="center">
70
+ <img src="https://raw.githubusercontent.com/js-krinay/klir/main/docs/images/klir-start.jpeg" alt="klir /start screen" width="49%" />
71
+ <img src="https://raw.githubusercontent.com/js-krinay/klir/main/docs/images/klir-quick-actions.jpeg" alt="klir quick action buttons" width="49%" />
72
+ </p>
73
+
74
+ ## Quick start
75
+
76
+ ```bash
77
+ pipx install klir
78
+ klir
79
+ ```
80
+
81
+ The onboarding wizard handles CLI checks, Telegram setup, timezone, optional Docker, and optional background service install.
82
+
83
+ **Requirements:** Python 3.11+, at least one CLI installed (`claude`, `codex`, or `gemini`), a Telegram Bot Token from [@BotFather](https://t.me/BotFather).
84
+
85
+ Detailed setup: [`docs/installation.md`](docs/installation.md)
86
+
87
+ ## How chats work
88
+
89
+ klir gives you multiple ways to interact with your coding agents. Each level builds on the previous one.
90
+
91
+ ### 1. Single chat (your main agent)
92
+
93
+ This is where everyone starts. You get a private 1:1 Telegram chat with your bot. Every message goes to the CLI you have active (`claude`, `codex`, or `gemini`), responses stream back in real time.
94
+
95
+ ```text
96
+ You: "Explain the auth flow in this codebase"
97
+ Bot: [streams response from Claude Code]
98
+
99
+ You: /model
100
+ Bot: [interactive model/provider picker]
101
+
102
+ You: "Now refactor the parser"
103
+ Bot: [streams response, same session context]
104
+ ```
105
+
106
+ This single chat is all you need. Everything else below is optional.
107
+
108
+ ### 2. Groups with topics (multiple isolated chats)
109
+
110
+ Create a Telegram group, enable topics (forum mode), and add your bot. Now every topic becomes its own isolated chat with its own CLI context.
111
+
112
+ ```text
113
+ Group: "My Projects"
114
+ ├── General ← own context (isolated from your single chat)
115
+ ├── Topic: Auth ← own context
116
+ ├── Topic: Frontend ← own context
117
+ ├── Topic: Database ← own context
118
+ └── Topic: Refactor ← own context
119
+ ```
120
+
121
+ That's 5 independent conversations from a single group. Your private single chat stays separate too — 6 total contexts, all running in parallel.
122
+
123
+ Each topic can use a different model. Run `/model` inside a topic to change just that topic's provider.
124
+
125
+ All chats share the same `~/.klir/` workspace — same tools, same memory, same files. The only thing isolated is the conversation context.
126
+
127
+ > **Note:** The Telegram Bot API has no method to list existing forum topics. klir learns topic names from `forum_topic_created` and `forum_topic_edited` events — so only topics created or renamed while the bot is in the group are known by name. Pre-existing topics show as "Topic #N" until they are edited. This is a Telegram limitation, not a klir limitation.
128
+
129
+ ### 3. Named sessions (extra contexts within any chat)
130
+
131
+ Need to work on something unrelated without losing your current context? Start a named session. It runs inside the same chat but has its own CLI conversation.
132
+
133
+ ```text
134
+ You: "Let's work on authentication" ← main context builds up
135
+ Bot: [responds about auth]
136
+
137
+ /session Fix the broken CSV export ← starts session "firmowl"
138
+ Bot: [works on CSV in separate context]
139
+
140
+ You: "Back to auth — add rate limiting" ← main context is still clean
141
+ Bot: [remembers exactly where you left off]
142
+
143
+ @firmowl Also add error handling ← follow-up to the session
144
+ ```
145
+
146
+ Sessions work everywhere — in your single chat, in group topics, in sub-agent chats. Think of them as opening a second terminal window next to your current one.
147
+
148
+ ### 4. Background tasks (async delegation)
149
+
150
+ Any chat can delegate long-running work to a background task. You keep chatting while the task runs autonomously. When it finishes, the result flows back into your conversation.
151
+
152
+ ```text
153
+ You: "Research the top 5 competitors and write a summary"
154
+ Bot: → delegates to background task, you keep chatting
155
+ Bot: → task finishes, result appears in your chat
156
+
157
+ You: "Delegate this: generate reports for all Q4 metrics"
158
+ Bot: → explicitly delegated, runs in background
159
+ Bot: → task has a question? It asks the agent → agent asks you → you answer → task continues
160
+ ```
161
+
162
+ Each task gets its own memory file (`TASKMEMORY.md`) and can be resumed with follow-ups.
163
+
164
+ ### 5. Sub-agents (fully isolated second agent)
165
+
166
+ Sub-agents are completely separate bots — own Telegram chat, own workspace, own memory, own CLI auth, own config settings (heartbeat, timeouts, model defaults, etc.). Like having klir installed twice on different machines.
167
+
168
+ ```bash
169
+ klir agents add codex-agent # creates a new bot (needs its own BotFather token)
170
+ ```
171
+
172
+ ```text
173
+ Your main chat (Claude): "Explain the auth flow"
174
+ codex-agent chat (Codex): "Refactor the parser module"
175
+ ```
176
+
177
+ Sub-agents live under `~/.klir/agents/<name>/` with their own workspace, tools, and memory — fully isolated from the main agent.
178
+
179
+ You can delegate tasks between agents:
180
+
181
+ ```text
182
+ Main chat: "Ask codex-agent to write tests for the API"
183
+ → Claude sends the task to Codex
184
+ → Codex works in its own workspace
185
+ → Result flows back to your main chat
186
+ ```
187
+
188
+ ### Comparison
189
+
190
+ | | Single chat | Group topics | Named sessions | Background tasks | Sub-agents |
191
+ |---|---|---|---|---|---|
192
+ | **What it is** | Your main 1:1 chat | One topic = one chat | Extra context in any chat | "Do this while I keep working" | Separate bot, own everything |
193
+ | **Context** | One per provider | One per topic per provider | Own context per session | Own context, result flows back | Fully isolated |
194
+ | **Workspace** | `~/.klir/` | Shared with main | Shared with parent chat | Shared with parent agent | Own under `~/.klir/agents/` |
195
+ | **Config** | Main config | Shared with main | Shared with parent chat | Shared with parent agent | Own config (heartbeat, timeouts, model, ...) |
196
+ | **Setup** | Automatic | Create group + enable topics | `/session <prompt>` | Automatic or "delegate this" | `klir agents add` + BotFather |
197
+
198
+ ### How it all fits together
199
+
200
+ ```text
201
+ ~/.klir/ ← shared workspace (tools, memory, files)
202
+
203
+ ├── Single chat ← main agent, private 1:1
204
+ │ ├── main context
205
+ │ └── named sessions
206
+
207
+ ├── Group: "My Projects" ← same agent, same workspace
208
+ │ ├── General (own context)
209
+ │ ├── Topic: Auth (own context, own model)
210
+ │ ├── Topic: Frontend (own context)
211
+ │ └── each topic can have named sessions too
212
+
213
+ └── agents/codex-agent/ ← sub-agent, fully isolated workspace
214
+ ├── own single chat
215
+ ├── own group support
216
+ ├── own named sessions
217
+ └── own background tasks
218
+ ```
219
+
220
+ ## Features
221
+
222
+ - **Real-time streaming** — live Telegram message edits as the CLI produces output
223
+ - **Provider switching** — `/model` to change provider/model, `@model` directives for inline targeting
224
+ - **Persistent memory** — plain Markdown files that survive across sessions
225
+ - **Cron jobs** — in-process scheduler with timezone support, per-job overrides, quiet hours
226
+ - **Webhooks** — `wake` (inject into active chat) and `cron_task` (isolated task run) modes
227
+ - **Heartbeat** — proactive checks in active sessions with cooldown
228
+ - **Config hot-reload** — most settings update without restart
229
+ - **Docker sandbox** — optional sidecar container with configurable host mounts
230
+ - **Service manager** — Linux (systemd), macOS (launchd), Windows (Task Scheduler)
231
+ - **Cross-tool skill sync** — shared skills across `~/.claude/`, `~/.codex/`, `~/.gemini/`
232
+
233
+ ## Auth
234
+
235
+ klir uses a dual-allowlist model. Every message must pass both checks.
236
+
237
+ | Chat type | Check |
238
+ |---|---|
239
+ | **Private** | `user_id ∈ allowed_user_ids` |
240
+ | **Group** | `group_id ∈ allowed_group_ids` AND `user_id ∈ allowed_user_ids` |
241
+
242
+ - **`allowed_user_ids`** — Telegram user IDs that may talk to the bot. At least one required.
243
+ - **`allowed_group_ids`** — Telegram group IDs where the bot may operate. Default `[]` = no groups.
244
+ - **`group_mention_only`** — When `true`, the bot only responds in groups when @mentioned or replied to.
245
+
246
+ All three are **hot-reloadable** — edit `config.json` and changes take effect within seconds.
247
+
248
+ > **Privacy Mode:** Telegram bots have Privacy Mode enabled by default and only see `/commands` in groups. To let the bot see all messages, make it a **group admin** or disable Privacy Mode via BotFather (`/setprivacy` → Disable). If changed after joining, remove and re-add the bot.
249
+
250
+ **Group management:** When the bot is added to a group not in `allowed_group_ids`, it warns and auto-leaves. Use `/where` to see tracked groups and their IDs.
251
+
252
+ ## Telegram commands
253
+
254
+ | Command | Description |
255
+ |---|---|
256
+ | `/model` | Interactive model/provider selector |
257
+ | `/new` | Reset active provider session |
258
+ | `/stop` | Abort active run |
259
+ | `/stop_all` | Abort runs across all agents |
260
+ | `/status` | Session/provider/auth status |
261
+ | `/memory` | Show persistent memory |
262
+ | `/session <prompt>` | Start a named background session |
263
+ | `/sessions` | View/manage active sessions |
264
+ | `/tasks` | View/manage background tasks |
265
+ | `/cron` | Interactive cron management |
266
+ | `/showfiles` | Browse `~/.klir/` |
267
+ | `/diagnose` | Runtime diagnostics |
268
+ | `/upgrade` | Check/apply updates |
269
+ | `/agents` | Multi-agent status |
270
+ | `/agent_commands` | Multi-agent command reference |
271
+ | `/where` | Show tracked chats/groups |
272
+ | `/leave <id>` | Manually leave a group |
273
+ | `/info` | Version + links |
274
+
275
+ ## CLI commands
276
+
277
+ ```bash
278
+ klir # Start bot (auto-onboarding if needed)
279
+ klir stop # Stop bot
280
+ klir restart # Restart bot
281
+ klir upgrade # Upgrade and restart
282
+ klir status # Runtime status
283
+
284
+ klir service install # Install as background service
285
+ klir service logs # View service logs
286
+
287
+ klir docker enable # Enable Docker sandbox
288
+ klir docker rebuild # Rebuild sandbox container
289
+ klir docker mount /p # Add host mount
290
+
291
+ klir agents list # List configured sub-agents
292
+ klir agents add NAME # Add a sub-agent
293
+ klir agents remove NAME
294
+
295
+ klir api enable # Enable WebSocket API (beta)
296
+ ```
297
+
298
+ ## Workspace layout
299
+
300
+ ```text
301
+ ~/.klir/
302
+ config/config.json # Bot configuration
303
+ sessions.json # Chat session state
304
+ named_sessions.json # Named background sessions
305
+ tasks.json # Background task registry
306
+ cron_jobs.json # Scheduled tasks
307
+ webhooks.json # Webhook definitions
308
+ agents.json # Sub-agent registry (optional)
309
+ SHAREDMEMORY.md # Shared knowledge across all agents
310
+ CLAUDE.md / AGENTS.md / GEMINI.md # Rule files
311
+ logs/agent.log
312
+ workspace/
313
+ memory_system/MAINMEMORY.md # Persistent memory
314
+ cron_tasks/ skills/ tools/ # Scripts and tools
315
+ tasks/ # Per-task folders
316
+ telegram_files/ output_to_user/ # File I/O
317
+ agents/<name>/ # Sub-agent workspaces (isolated)
318
+ ```
319
+
320
+ Full config reference: [`docs/config.md`](docs/config.md)
321
+
322
+ ## Documentation
323
+
324
+ | Doc | Content |
325
+ |---|---|
326
+ | [System Overview](docs/system_overview.md) | End-to-end runtime overview |
327
+ | [Developer Quickstart](docs/developer_quickstart.md) | Quickest path for contributors |
328
+ | [Architecture](docs/architecture.md) | Startup, routing, streaming, callbacks |
329
+ | [Configuration](docs/config.md) | Config schema and merge behavior |
330
+ | [Automation](docs/automation.md) | Cron, webhooks, heartbeat setup |
331
+ | [Module docs](docs/modules/) | Per-module deep dives |
332
+
333
+ ## Why klir?
334
+
335
+ Other projects manipulate SDKs or patch CLIs and risk violating provider terms of service. klir simply runs the official CLI binaries as subprocesses — nothing more.
336
+
337
+ - Official CLIs only (`claude`, `codex`, `gemini`)
338
+ - Rule files are plain Markdown (`CLAUDE.md`, `AGENTS.md`, `GEMINI.md`)
339
+ - Memory is one Markdown file per agent
340
+ - All state is JSON — no database, no external services
341
+
342
+ ## Disclaimer
343
+
344
+ klir runs official provider CLIs and does not impersonate provider clients. Validate your own compliance requirements before unattended automation.
345
+
346
+ - [Anthropic Terms](https://www.anthropic.com/policies/terms)
347
+ - [OpenAI Terms](https://openai.com/policies/terms-of-use)
348
+ - [Google Terms](https://policies.google.com/terms)
349
+
350
+ ## Contributing
351
+
352
+ ```bash
353
+ git clone https://github.com/js-krinay/klir.git
354
+ cd klir
355
+ python -m venv .venv && source .venv/bin/activate
356
+ pip install -e ".[dev]"
357
+ pytest && ruff format . && ruff check . && mypy klir
358
+ ```
359
+
360
+ Zero warnings, zero errors.
361
+
362
+ ## License
363
+
364
+ [MIT](LICENSE)