@agentikos/omega-os 0.1.0 → 0.19.5

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 (379) hide show
  1. package/README.md +56 -14
  2. package/bootstrap/lib/__pycache__/claude-code-settings.cpython-313.pyc +0 -0
  3. package/bootstrap/lib/__pycache__/llm-clis.cpython-313.pyc +0 -0
  4. package/bootstrap/lib/__pycache__/manifest-helpers.cpython-313.pyc +0 -0
  5. package/bootstrap/lib/claude-code-settings.py +176 -0
  6. package/bootstrap/lib/common.sh +457 -1
  7. package/bootstrap/lib/llm-clis.py +341 -0
  8. package/bootstrap/lib/manifest-helpers.py +384 -0
  9. package/bootstrap/lib/steps.sh +1000 -26
  10. package/bootstrap/manifest.example.yaml +93 -2
  11. package/bootstrap/templates/aisb/CLAUDE.md +305 -0
  12. package/bootstrap/templates/aisb/architect.md +204 -0
  13. package/bootstrap/templates/aisb/checkers/CLAUDE.md +9 -0
  14. package/bootstrap/templates/aisb/checkers/checker-architect.md +151 -0
  15. package/bootstrap/templates/aisb/checkers/checker-common.md +171 -0
  16. package/bootstrap/templates/aisb/checkers/checker-construct.md +129 -0
  17. package/bootstrap/templates/aisb/checkers/checker-keymaker.md +204 -0
  18. package/bootstrap/templates/aisb/checkers/checker-link.md +205 -0
  19. package/bootstrap/templates/aisb/checkers/checker-merovingian.md +219 -0
  20. package/bootstrap/templates/aisb/checkers/checker-morpheus.md +211 -0
  21. package/bootstrap/templates/aisb/checkers/checker-neo.md +177 -0
  22. package/bootstrap/templates/aisb/checkers/checker-niobe.md +156 -0
  23. package/bootstrap/templates/aisb/checkers/checker-oracle.md +164 -0
  24. package/bootstrap/templates/aisb/checkers/checker-seraph.md +187 -0
  25. package/bootstrap/templates/aisb/checkers/checker-smith.md +195 -0
  26. package/bootstrap/templates/aisb/checkers/checker-zion.md +113 -0
  27. package/bootstrap/templates/aisb/construct.md +135 -0
  28. package/bootstrap/templates/aisb/keymaker.md +227 -0
  29. package/bootstrap/templates/aisb/link.md +170 -0
  30. package/bootstrap/templates/aisb/lmc-protocol.md +57 -0
  31. package/bootstrap/templates/aisb/merovingian.md +159 -0
  32. package/bootstrap/templates/aisb/morpheus.md +243 -0
  33. package/bootstrap/templates/aisb/neo.md +147 -0
  34. package/bootstrap/templates/aisb/niobe.md +197 -0
  35. package/bootstrap/templates/aisb/oracle.md +244 -0
  36. package/bootstrap/templates/aisb/protocols/handoff-templates.md +204 -0
  37. package/bootstrap/templates/aisb/protocols/shared-protocol.md +248 -0
  38. package/bootstrap/templates/aisb/pythia.md +153 -0
  39. package/bootstrap/templates/aisb/seraph.md +315 -0
  40. package/bootstrap/templates/aisb/smith.md +202 -0
  41. package/bootstrap/templates/aisb/zion.md +172 -0
  42. package/bootstrap/templates/autonomous/audit-patrol.yaml +41 -0
  43. package/bootstrap/templates/autonomous/smith-reflect.yaml +43 -0
  44. package/bootstrap/templates/autonomous/ssh-key-rotate.yaml +46 -0
  45. package/bootstrap/templates/autonomous/support-agent.yaml +38 -0
  46. package/docs/AUDITS.md +85 -0
  47. package/docs/COMPLETION-PLAN.md +48 -0
  48. package/docs/GAP-ANALYSIS.md +214 -0
  49. package/docs/INSTALL.md +47 -9
  50. package/docs/MCP-AND-PLUGINS.md +31 -4
  51. package/docs/SIMULATION.md +171 -0
  52. package/docs/simulate.sh +211 -0
  53. package/install.sh +164 -17
  54. package/omega/Agentik_Engine/README.md +27 -10
  55. package/omega/Agentik_Engine/omega_engine/__init__.py +212 -2
  56. package/omega/Agentik_Engine/omega_engine/__pycache__/__init__.cpython-313.pyc +0 -0
  57. package/omega/Agentik_Engine/omega_engine/__pycache__/account.cpython-313.pyc +0 -0
  58. package/omega/Agentik_Engine/omega_engine/__pycache__/agent_messages.cpython-313.pyc +0 -0
  59. package/omega/Agentik_Engine/omega_engine/__pycache__/aisb_chat.cpython-313.pyc +0 -0
  60. package/omega/Agentik_Engine/omega_engine/__pycache__/audit_diff.cpython-313.pyc +0 -0
  61. package/omega/Agentik_Engine/omega_engine/__pycache__/audit_gate.cpython-313.pyc +0 -0
  62. package/omega/Agentik_Engine/omega_engine/__pycache__/auto_update.cpython-313.pyc +0 -0
  63. package/omega/Agentik_Engine/omega_engine/__pycache__/autonomous.cpython-313.pyc +0 -0
  64. package/omega/Agentik_Engine/omega_engine/__pycache__/backup.cpython-313.pyc +0 -0
  65. package/omega/Agentik_Engine/omega_engine/__pycache__/cadence.cpython-313.pyc +0 -0
  66. package/omega/Agentik_Engine/omega_engine/__pycache__/classifier.cpython-313.pyc +0 -0
  67. package/omega/Agentik_Engine/omega_engine/__pycache__/cleanup.cpython-313.pyc +0 -0
  68. package/omega/Agentik_Engine/omega_engine/__pycache__/cli.cpython-313.pyc +0 -0
  69. package/omega/Agentik_Engine/omega_engine/__pycache__/completions.cpython-313.pyc +0 -0
  70. package/omega/Agentik_Engine/omega_engine/__pycache__/costs.cpython-313.pyc +0 -0
  71. package/omega/Agentik_Engine/omega_engine/__pycache__/done_signal.cpython-313.pyc +0 -0
  72. package/omega/Agentik_Engine/omega_engine/__pycache__/envelope.cpython-313.pyc +0 -0
  73. package/omega/Agentik_Engine/omega_engine/__pycache__/executor.cpython-313.pyc +0 -0
  74. package/omega/Agentik_Engine/omega_engine/__pycache__/handoff.cpython-313.pyc +0 -0
  75. package/omega/Agentik_Engine/omega_engine/__pycache__/hermes.cpython-313.pyc +0 -0
  76. package/omega/Agentik_Engine/omega_engine/__pycache__/hermes_bootstrap.cpython-313.pyc +0 -0
  77. package/omega/Agentik_Engine/omega_engine/__pycache__/hermes_desktop.cpython-313.pyc +0 -0
  78. package/omega/Agentik_Engine/omega_engine/__pycache__/learning.cpython-313.pyc +0 -0
  79. package/omega/Agentik_Engine/omega_engine/__pycache__/managed_agent.cpython-313.pyc +0 -0
  80. package/omega/Agentik_Engine/omega_engine/__pycache__/memory.cpython-313.pyc +0 -0
  81. package/omega/Agentik_Engine/omega_engine/__pycache__/menu.cpython-313.pyc +0 -0
  82. package/omega/Agentik_Engine/omega_engine/__pycache__/mission.cpython-313.pyc +0 -0
  83. package/omega/Agentik_Engine/omega_engine/__pycache__/plan.cpython-313.pyc +0 -0
  84. package/omega/Agentik_Engine/omega_engine/__pycache__/project.cpython-313.pyc +0 -0
  85. package/omega/Agentik_Engine/omega_engine/__pycache__/prompts.cpython-313.pyc +0 -0
  86. package/omega/Agentik_Engine/omega_engine/__pycache__/provider.cpython-313.pyc +0 -0
  87. package/omega/Agentik_Engine/omega_engine/__pycache__/prune.cpython-313.pyc +0 -0
  88. package/omega/Agentik_Engine/omega_engine/__pycache__/pursue.cpython-313.pyc +0 -0
  89. package/omega/Agentik_Engine/omega_engine/__pycache__/reducer.cpython-313.pyc +0 -0
  90. package/omega/Agentik_Engine/omega_engine/__pycache__/router.cpython-313.pyc +0 -0
  91. package/omega/Agentik_Engine/omega_engine/__pycache__/skill_routing.cpython-313.pyc +0 -0
  92. package/omega/Agentik_Engine/omega_engine/__pycache__/smoke.cpython-313.pyc +0 -0
  93. package/omega/Agentik_Engine/omega_engine/__pycache__/store.cpython-313.pyc +0 -0
  94. package/omega/Agentik_Engine/omega_engine/__pycache__/sync.cpython-313.pyc +0 -0
  95. package/omega/Agentik_Engine/omega_engine/__pycache__/telegram_history.cpython-313.pyc +0 -0
  96. package/omega/Agentik_Engine/omega_engine/__pycache__/tmux.cpython-313.pyc +0 -0
  97. package/omega/Agentik_Engine/omega_engine/__pycache__/tools.cpython-313.pyc +0 -0
  98. package/omega/Agentik_Engine/omega_engine/__pycache__/understand_anything.cpython-313.pyc +0 -0
  99. package/omega/Agentik_Engine/omega_engine/__pycache__/updater.cpython-313.pyc +0 -0
  100. package/omega/Agentik_Engine/omega_engine/__pycache__/validate.cpython-313.pyc +0 -0
  101. package/omega/Agentik_Engine/omega_engine/__pycache__/vault.cpython-313.pyc +0 -0
  102. package/omega/Agentik_Engine/omega_engine/__pycache__/webhooks.cpython-313.pyc +0 -0
  103. package/omega/Agentik_Engine/omega_engine/__pycache__/worker.cpython-313.pyc +0 -0
  104. package/omega/Agentik_Engine/omega_engine/account.py +502 -0
  105. package/omega/Agentik_Engine/omega_engine/agent_messages.py +167 -0
  106. package/omega/Agentik_Engine/omega_engine/aisb_chat.py +128 -0
  107. package/omega/Agentik_Engine/omega_engine/audit_diff.py +99 -0
  108. package/omega/Agentik_Engine/omega_engine/audit_gate.py +149 -0
  109. package/omega/Agentik_Engine/omega_engine/audits/__init__.py +60 -0
  110. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/__init__.cpython-313.pyc +0 -0
  111. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/batcher.cpython-313.pyc +0 -0
  112. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/dispatcher.cpython-313.pyc +0 -0
  113. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/generator.cpython-313.pyc +0 -0
  114. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/history.cpython-313.pyc +0 -0
  115. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/pipeline.cpython-313.pyc +0 -0
  116. package/omega/Agentik_Engine/omega_engine/audits/batcher.py +218 -0
  117. package/omega/Agentik_Engine/omega_engine/audits/dispatcher.py +92 -0
  118. package/omega/Agentik_Engine/omega_engine/audits/generator.py +234 -0
  119. package/omega/Agentik_Engine/omega_engine/audits/history.py +168 -0
  120. package/omega/Agentik_Engine/omega_engine/audits/pipeline.py +198 -0
  121. package/omega/Agentik_Engine/omega_engine/auto_update.py +339 -0
  122. package/omega/Agentik_Engine/omega_engine/autonomous.py +538 -0
  123. package/omega/Agentik_Engine/omega_engine/backup.py +215 -0
  124. package/omega/Agentik_Engine/omega_engine/cadence.py +158 -0
  125. package/omega/Agentik_Engine/omega_engine/classifier.py +215 -0
  126. package/omega/Agentik_Engine/omega_engine/cleanup.py +673 -0
  127. package/omega/Agentik_Engine/omega_engine/cli.py +4564 -56
  128. package/omega/Agentik_Engine/omega_engine/completions.py +260 -0
  129. package/omega/Agentik_Engine/omega_engine/costs.py +100 -0
  130. package/omega/Agentik_Engine/omega_engine/daemons/__init__.py +14 -0
  131. package/omega/Agentik_Engine/omega_engine/daemons/__pycache__/__init__.cpython-313.pyc +0 -0
  132. package/omega/Agentik_Engine/omega_engine/daemons/__pycache__/autonomous.cpython-313.pyc +0 -0
  133. package/omega/Agentik_Engine/omega_engine/daemons/__pycache__/engine.cpython-313.pyc +0 -0
  134. package/omega/Agentik_Engine/omega_engine/daemons/__pycache__/telegram.cpython-313.pyc +0 -0
  135. package/omega/Agentik_Engine/omega_engine/daemons/autonomous.py +56 -0
  136. package/omega/Agentik_Engine/omega_engine/daemons/engine.py +236 -0
  137. package/omega/Agentik_Engine/omega_engine/daemons/telegram.py +315 -0
  138. package/omega/Agentik_Engine/omega_engine/done_signal.py +154 -0
  139. package/omega/Agentik_Engine/omega_engine/educators/__init__.py +51 -0
  140. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/__init__.cpython-313.pyc +0 -0
  141. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/artifact.cpython-313.pyc +0 -0
  142. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/automation.cpython-313.pyc +0 -0
  143. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/base.cpython-313.pyc +0 -0
  144. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/claudecode.cpython-313.pyc +0 -0
  145. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/connection.cpython-313.pyc +0 -0
  146. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/coworker.cpython-313.pyc +0 -0
  147. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/loop.cpython-313.pyc +0 -0
  148. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/prompt.cpython-313.pyc +0 -0
  149. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/skill.cpython-313.pyc +0 -0
  150. package/omega/Agentik_Engine/omega_engine/educators/artifact.py +65 -0
  151. package/omega/Agentik_Engine/omega_engine/educators/automation.py +76 -0
  152. package/omega/Agentik_Engine/omega_engine/educators/base.py +327 -0
  153. package/omega/Agentik_Engine/omega_engine/educators/claudecode.py +71 -0
  154. package/omega/Agentik_Engine/omega_engine/educators/connection.py +75 -0
  155. package/omega/Agentik_Engine/omega_engine/educators/coworker.py +68 -0
  156. package/omega/Agentik_Engine/omega_engine/educators/loop.py +82 -0
  157. package/omega/Agentik_Engine/omega_engine/educators/prompt.py +68 -0
  158. package/omega/Agentik_Engine/omega_engine/educators/skill.py +69 -0
  159. package/omega/Agentik_Engine/omega_engine/envelope.py +219 -0
  160. package/omega/Agentik_Engine/omega_engine/executor.py +195 -16
  161. package/omega/Agentik_Engine/omega_engine/genesis/__init__.py +134 -0
  162. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/__init__.cpython-313.pyc +0 -0
  163. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/orchestrator.cpython-313.pyc +0 -0
  164. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/phases.cpython-313.pyc +0 -0
  165. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/stack.cpython-313.pyc +0 -0
  166. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/state.cpython-313.pyc +0 -0
  167. package/omega/Agentik_Engine/omega_engine/genesis/orchestrator.py +262 -0
  168. package/omega/Agentik_Engine/omega_engine/genesis/phases.py +950 -0
  169. package/omega/Agentik_Engine/omega_engine/genesis/stack.py +324 -0
  170. package/omega/Agentik_Engine/omega_engine/genesis/state.py +353 -0
  171. package/omega/Agentik_Engine/omega_engine/handoff.py +459 -0
  172. package/omega/Agentik_Engine/omega_engine/hermes.py +426 -0
  173. package/omega/Agentik_Engine/omega_engine/hermes_bootstrap.py +382 -0
  174. package/omega/Agentik_Engine/omega_engine/hermes_desktop.py +469 -0
  175. package/omega/Agentik_Engine/omega_engine/integrations/__init__.py +30 -0
  176. package/omega/Agentik_Engine/omega_engine/integrations/__pycache__/__init__.cpython-313.pyc +0 -0
  177. package/omega/Agentik_Engine/omega_engine/integrations/__pycache__/graphify.cpython-313.pyc +0 -0
  178. package/omega/Agentik_Engine/omega_engine/integrations/graphify.py +234 -0
  179. package/omega/Agentik_Engine/omega_engine/learning.py +268 -0
  180. package/omega/Agentik_Engine/omega_engine/managed_agent.py +467 -0
  181. package/omega/Agentik_Engine/omega_engine/memory.py +271 -0
  182. package/omega/Agentik_Engine/omega_engine/menu.py +1065 -0
  183. package/omega/Agentik_Engine/omega_engine/migrations/__init__.py +144 -0
  184. package/omega/Agentik_Engine/omega_engine/migrations/__pycache__/__init__.cpython-313.pyc +0 -0
  185. package/omega/Agentik_Engine/omega_engine/migrations/__pycache__/v0_14_0.cpython-313.pyc +0 -0
  186. package/omega/Agentik_Engine/omega_engine/migrations/v0_14_0.py +29 -0
  187. package/omega/Agentik_Engine/omega_engine/mission.py +29 -14
  188. package/omega/Agentik_Engine/omega_engine/plan.py +846 -0
  189. package/omega/Agentik_Engine/omega_engine/prompts.py +158 -0
  190. package/omega/Agentik_Engine/omega_engine/provider.py +408 -13
  191. package/omega/Agentik_Engine/omega_engine/prune.py +151 -0
  192. package/omega/Agentik_Engine/omega_engine/pursue.py +205 -0
  193. package/omega/Agentik_Engine/omega_engine/rag/__init__.py +21 -0
  194. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/__init__.cpython-313.pyc +0 -0
  195. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/agentic.cpython-313.pyc +0 -0
  196. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/base.cpython-313.pyc +0 -0
  197. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/corrective.cpython-313.pyc +0 -0
  198. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/graph.cpython-313.pyc +0 -0
  199. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/hybrid.cpython-313.pyc +0 -0
  200. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/multimodal.cpython-313.pyc +0 -0
  201. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/router.cpython-313.pyc +0 -0
  202. package/omega/Agentik_Engine/omega_engine/rag/agentic.py +83 -0
  203. package/omega/Agentik_Engine/omega_engine/rag/base.py +42 -0
  204. package/omega/Agentik_Engine/omega_engine/rag/corrective.py +119 -0
  205. package/omega/Agentik_Engine/omega_engine/rag/graph.py +169 -0
  206. package/omega/Agentik_Engine/omega_engine/rag/hybrid.py +205 -0
  207. package/omega/Agentik_Engine/omega_engine/rag/multimodal.py +136 -0
  208. package/omega/Agentik_Engine/omega_engine/rag/router.py +110 -0
  209. package/omega/Agentik_Engine/omega_engine/reducer.py +21 -3
  210. package/omega/Agentik_Engine/omega_engine/router.py +28 -0
  211. package/omega/Agentik_Engine/omega_engine/skill_discovery/__init__.py +48 -0
  212. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/__init__.cpython-313.pyc +0 -0
  213. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/auditor.cpython-313.pyc +0 -0
  214. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/finder.cpython-313.pyc +0 -0
  215. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/installer.cpython-313.pyc +0 -0
  216. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/marketplaces.cpython-313.pyc +0 -0
  217. package/omega/Agentik_Engine/omega_engine/skill_discovery/auditor.py +232 -0
  218. package/omega/Agentik_Engine/omega_engine/skill_discovery/finder.py +94 -0
  219. package/omega/Agentik_Engine/omega_engine/skill_discovery/installer.py +129 -0
  220. package/omega/Agentik_Engine/omega_engine/skill_discovery/marketplaces.py +80 -0
  221. package/omega/Agentik_Engine/omega_engine/skill_routing.py +388 -0
  222. package/omega/Agentik_Engine/omega_engine/smoke.py +81 -0
  223. package/omega/Agentik_Engine/omega_engine/store.py +132 -25
  224. package/omega/Agentik_Engine/omega_engine/sync.py +445 -0
  225. package/omega/Agentik_Engine/omega_engine/telegram_history.py +260 -0
  226. package/omega/Agentik_Engine/omega_engine/tmux.py +526 -0
  227. package/omega/Agentik_Engine/omega_engine/tools.py +272 -0
  228. package/omega/Agentik_Engine/omega_engine/understand_anything.py +275 -0
  229. package/omega/Agentik_Engine/omega_engine/updater.py +70 -0
  230. package/omega/Agentik_Engine/omega_engine/validate.py +186 -0
  231. package/omega/Agentik_Engine/omega_engine/vault.py +342 -0
  232. package/omega/Agentik_Engine/omega_engine/webhooks.py +262 -0
  233. package/omega/Agentik_Engine/omega_engine/worker.py +526 -0
  234. package/omega/Agentik_Engine/pyproject.toml +1 -1
  235. package/omega/Agentik_Engine/tests/__pycache__/test_account.cpython-313-pytest-8.4.2.pyc +0 -0
  236. package/omega/Agentik_Engine/tests/__pycache__/test_account.cpython-313.pyc +0 -0
  237. package/omega/Agentik_Engine/tests/__pycache__/test_adversarial.cpython-313-pytest-8.4.2.pyc +0 -0
  238. package/omega/Agentik_Engine/tests/__pycache__/test_adversarial.cpython-313.pyc +0 -0
  239. package/omega/Agentik_Engine/tests/__pycache__/test_agents_envelope.cpython-313-pytest-8.4.2.pyc +0 -0
  240. package/omega/Agentik_Engine/tests/__pycache__/test_agents_envelope.cpython-313.pyc +0 -0
  241. package/omega/Agentik_Engine/tests/__pycache__/test_audit_arsenal.cpython-313-pytest-8.4.2.pyc +0 -0
  242. package/omega/Agentik_Engine/tests/__pycache__/test_audits_pipeline.cpython-313-pytest-8.4.2.pyc +0 -0
  243. package/omega/Agentik_Engine/tests/__pycache__/test_audits_pipeline.cpython-313.pyc +0 -0
  244. package/omega/Agentik_Engine/tests/__pycache__/test_auto_update_and_migrations.cpython-313-pytest-8.4.2.pyc +0 -0
  245. package/omega/Agentik_Engine/tests/__pycache__/test_auto_update_and_migrations.cpython-313.pyc +0 -0
  246. package/omega/Agentik_Engine/tests/__pycache__/test_autonomous.cpython-313-pytest-8.4.2.pyc +0 -0
  247. package/omega/Agentik_Engine/tests/__pycache__/test_autonomous.cpython-313.pyc +0 -0
  248. package/omega/Agentik_Engine/tests/__pycache__/test_educators.cpython-313-pytest-8.4.2.pyc +0 -0
  249. package/omega/Agentik_Engine/tests/__pycache__/test_educators.cpython-313.pyc +0 -0
  250. package/omega/Agentik_Engine/tests/__pycache__/test_executor.cpython-313-pytest-8.4.2.pyc +0 -0
  251. package/omega/Agentik_Engine/tests/__pycache__/test_genesis_and_plan.cpython-313-pytest-8.4.2.pyc +0 -0
  252. package/omega/Agentik_Engine/tests/__pycache__/test_genesis_and_plan.cpython-313.pyc +0 -0
  253. package/omega/Agentik_Engine/tests/__pycache__/test_graphify.cpython-313-pytest-8.4.2.pyc +0 -0
  254. package/omega/Agentik_Engine/tests/__pycache__/test_graphify.cpython-313.pyc +0 -0
  255. package/omega/Agentik_Engine/tests/__pycache__/test_handoff.cpython-313-pytest-8.4.2.pyc +0 -0
  256. package/omega/Agentik_Engine/tests/__pycache__/test_handoff.cpython-313.pyc +0 -0
  257. package/omega/Agentik_Engine/tests/__pycache__/test_hermes_and_ua.cpython-313-pytest-8.4.2.pyc +0 -0
  258. package/omega/Agentik_Engine/tests/__pycache__/test_hermes_and_ua.cpython-313.pyc +0 -0
  259. package/omega/Agentik_Engine/tests/__pycache__/test_hermes_bootstrap_and_desktop.cpython-313-pytest-8.4.2.pyc +0 -0
  260. package/omega/Agentik_Engine/tests/__pycache__/test_hermes_bootstrap_and_desktop.cpython-313.pyc +0 -0
  261. package/omega/Agentik_Engine/tests/__pycache__/test_install_steps.cpython-313-pytest-8.4.2.pyc +0 -0
  262. package/omega/Agentik_Engine/tests/__pycache__/test_install_steps.cpython-313.pyc +0 -0
  263. package/omega/Agentik_Engine/tests/__pycache__/test_install_ux.cpython-313-pytest-8.4.2.pyc +0 -0
  264. package/omega/Agentik_Engine/tests/__pycache__/test_install_ux.cpython-313.pyc +0 -0
  265. package/omega/Agentik_Engine/tests/__pycache__/test_installer_wiring.cpython-313-pytest-8.4.2.pyc +0 -0
  266. package/omega/Agentik_Engine/tests/__pycache__/test_installer_wiring.cpython-313.pyc +0 -0
  267. package/omega/Agentik_Engine/tests/__pycache__/test_intelligence.cpython-313-pytest-8.4.2.pyc +0 -0
  268. package/omega/Agentik_Engine/tests/__pycache__/test_intelligence.cpython-313.pyc +0 -0
  269. package/omega/Agentik_Engine/tests/__pycache__/test_llm_clis_and_uninstall.cpython-313-pytest-8.4.2.pyc +0 -0
  270. package/omega/Agentik_Engine/tests/__pycache__/test_llm_clis_and_uninstall.cpython-313.pyc +0 -0
  271. package/omega/Agentik_Engine/tests/__pycache__/test_managed_agent.cpython-313-pytest-8.4.2.pyc +0 -0
  272. package/omega/Agentik_Engine/tests/__pycache__/test_managed_agent.cpython-313.pyc +0 -0
  273. package/omega/Agentik_Engine/tests/__pycache__/test_max_provider_and_menu.cpython-313-pytest-8.4.2.pyc +0 -0
  274. package/omega/Agentik_Engine/tests/__pycache__/test_max_provider_and_menu.cpython-313.pyc +0 -0
  275. package/omega/Agentik_Engine/tests/__pycache__/test_menu_coverage.cpython-313-pytest-8.4.2.pyc +0 -0
  276. package/omega/Agentik_Engine/tests/__pycache__/test_menu_coverage.cpython-313.pyc +0 -0
  277. package/omega/Agentik_Engine/tests/__pycache__/test_mission.cpython-313-pytest-8.4.2.pyc +0 -0
  278. package/omega/Agentik_Engine/tests/__pycache__/test_progress.cpython-313-pytest-8.4.2.pyc +0 -0
  279. package/omega/Agentik_Engine/tests/__pycache__/test_project.cpython-313-pytest-8.4.2.pyc +0 -0
  280. package/omega/Agentik_Engine/tests/__pycache__/test_pursue_cadence.cpython-313-pytest-8.4.2.pyc +0 -0
  281. package/omega/Agentik_Engine/tests/__pycache__/test_pursue_cadence.cpython-313.pyc +0 -0
  282. package/omega/Agentik_Engine/tests/__pycache__/test_rag.cpython-313-pytest-8.4.2.pyc +0 -0
  283. package/omega/Agentik_Engine/tests/__pycache__/test_rag.cpython-313.pyc +0 -0
  284. package/omega/Agentik_Engine/tests/__pycache__/test_reducer.cpython-313-pytest-8.4.2.pyc +0 -0
  285. package/omega/Agentik_Engine/tests/__pycache__/test_report.cpython-313-pytest-8.4.2.pyc +0 -0
  286. package/omega/Agentik_Engine/tests/__pycache__/test_role_aliases_and_ssot.cpython-313-pytest-8.4.2.pyc +0 -0
  287. package/omega/Agentik_Engine/tests/__pycache__/test_role_aliases_and_ssot.cpython-313.pyc +0 -0
  288. package/omega/Agentik_Engine/tests/__pycache__/test_skill_discovery_and_gate.cpython-313-pytest-8.4.2.pyc +0 -0
  289. package/omega/Agentik_Engine/tests/__pycache__/test_skill_discovery_and_gate.cpython-313.pyc +0 -0
  290. package/omega/Agentik_Engine/tests/__pycache__/test_skill_power.cpython-313-pytest-8.4.2.pyc +0 -0
  291. package/omega/Agentik_Engine/tests/__pycache__/test_skill_power.cpython-313.pyc +0 -0
  292. package/omega/Agentik_Engine/tests/__pycache__/test_skill_routing.cpython-313-pytest-8.4.2.pyc +0 -0
  293. package/omega/Agentik_Engine/tests/__pycache__/test_skill_routing.cpython-313.pyc +0 -0
  294. package/omega/Agentik_Engine/tests/__pycache__/test_snapshot_partial.cpython-313-pytest-8.4.2.pyc +0 -0
  295. package/omega/Agentik_Engine/tests/__pycache__/test_snapshot_partial.cpython-313.pyc +0 -0
  296. package/omega/Agentik_Engine/tests/__pycache__/test_telegram_history.cpython-313-pytest-8.4.2.pyc +0 -0
  297. package/omega/Agentik_Engine/tests/__pycache__/test_telegram_history.cpython-313.pyc +0 -0
  298. package/omega/Agentik_Engine/tests/__pycache__/test_tmux_and_aisb_chat.cpython-313-pytest-8.4.2.pyc +0 -0
  299. package/omega/Agentik_Engine/tests/__pycache__/test_tmux_and_aisb_chat.cpython-313.pyc +0 -0
  300. package/omega/Agentik_Engine/tests/__pycache__/test_tools_and_sync.cpython-313-pytest-8.4.2.pyc +0 -0
  301. package/omega/Agentik_Engine/tests/__pycache__/test_tools_and_sync.cpython-313.pyc +0 -0
  302. package/omega/Agentik_Engine/tests/__pycache__/test_v06_features.cpython-313-pytest-8.4.2.pyc +0 -0
  303. package/omega/Agentik_Engine/tests/__pycache__/test_v06_features.cpython-313.pyc +0 -0
  304. package/omega/Agentik_Engine/tests/__pycache__/test_vault.cpython-313-pytest-8.4.2.pyc +0 -0
  305. package/omega/Agentik_Engine/tests/__pycache__/test_vault.cpython-313.pyc +0 -0
  306. package/omega/Agentik_Engine/tests/__pycache__/test_webhooks_and_readiness.cpython-313-pytest-8.4.2.pyc +0 -0
  307. package/omega/Agentik_Engine/tests/__pycache__/test_webhooks_and_readiness.cpython-313.pyc +0 -0
  308. package/omega/Agentik_Engine/tests/__pycache__/test_worker_and_cleanup.cpython-313-pytest-8.4.2.pyc +0 -0
  309. package/omega/Agentik_Engine/tests/__pycache__/test_worker_and_cleanup.cpython-313.pyc +0 -0
  310. package/omega/Agentik_Engine/tests/test_account.py +338 -0
  311. package/omega/Agentik_Engine/tests/test_adversarial.py +351 -0
  312. package/omega/Agentik_Engine/tests/test_agents_envelope.py +274 -0
  313. package/omega/Agentik_Engine/tests/test_audits_pipeline.py +348 -0
  314. package/omega/Agentik_Engine/tests/test_auto_update_and_migrations.py +394 -0
  315. package/omega/Agentik_Engine/tests/test_autonomous.py +361 -0
  316. package/omega/Agentik_Engine/tests/test_educators.py +233 -0
  317. package/omega/Agentik_Engine/tests/test_genesis_and_plan.py +573 -0
  318. package/omega/Agentik_Engine/tests/test_graphify.py +190 -0
  319. package/omega/Agentik_Engine/tests/test_handoff.py +311 -0
  320. package/omega/Agentik_Engine/tests/test_hermes_and_ua.py +387 -0
  321. package/omega/Agentik_Engine/tests/test_hermes_bootstrap_and_desktop.py +358 -0
  322. package/omega/Agentik_Engine/tests/test_install_steps.py +359 -0
  323. package/omega/Agentik_Engine/tests/test_install_ux.py +151 -0
  324. package/omega/Agentik_Engine/tests/test_installer_wiring.py +496 -0
  325. package/omega/Agentik_Engine/tests/test_intelligence.py +285 -0
  326. package/omega/Agentik_Engine/tests/test_llm_clis_and_uninstall.py +228 -0
  327. package/omega/Agentik_Engine/tests/test_managed_agent.py +363 -0
  328. package/omega/Agentik_Engine/tests/test_max_provider_and_menu.py +231 -0
  329. package/omega/Agentik_Engine/tests/test_menu_coverage.py +72 -0
  330. package/omega/Agentik_Engine/tests/test_pursue_cadence.py +217 -0
  331. package/omega/Agentik_Engine/tests/test_rag.py +287 -0
  332. package/omega/Agentik_Engine/tests/test_role_aliases_and_ssot.py +207 -0
  333. package/omega/Agentik_Engine/tests/test_skill_discovery_and_gate.py +337 -0
  334. package/omega/Agentik_Engine/tests/test_skill_power.py +259 -0
  335. package/omega/Agentik_Engine/tests/test_skill_routing.py +189 -0
  336. package/omega/Agentik_Engine/tests/test_snapshot_partial.py +172 -0
  337. package/omega/Agentik_Engine/tests/test_telegram_history.py +209 -0
  338. package/omega/Agentik_Engine/tests/test_tmux_and_aisb_chat.py +223 -0
  339. package/omega/Agentik_Engine/tests/test_tools_and_sync.py +312 -0
  340. package/omega/Agentik_Engine/tests/test_v06_features.py +370 -0
  341. package/omega/Agentik_Engine/tests/test_vault.py +173 -0
  342. package/omega/Agentik_Engine/tests/test_webhooks_and_readiness.py +277 -0
  343. package/omega/Agentik_Engine/tests/test_worker_and_cleanup.py +541 -0
  344. package/omega/Agentik_Extra/etc/secrets/.vault-key +3 -0
  345. package/omega/Agentik_Extra/etc/secrets/.vault-pub +1 -0
  346. package/omega/Agentik_Runtime/audits.db +0 -0
  347. package/omega/Agentik_SSOT/VERSION +1 -1
  348. package/omega/Agentik_SSOT/claude-plugins/claude-plugins.yaml +100 -0
  349. package/omega/Agentik_SSOT/docs/LAYERS.md +90 -0
  350. package/omega/Agentik_SSOT/docs/USER-JOURNEY.md +283 -0
  351. package/omega/Agentik_SSOT/marketplaces/design-discipline.yaml +86 -0
  352. package/omega/Agentik_SSOT/skills/a11yaudit/SKILL.md +161 -0
  353. package/omega/Agentik_SSOT/skills/apiaudit/SKILL.md +157 -0
  354. package/omega/Agentik_SSOT/skills/automationaudit/SKILL.md +161 -0
  355. package/omega/Agentik_SSOT/skills/cadence/SKILL.md +76 -0
  356. package/omega/Agentik_SSOT/skills/codeaudit/SKILL.md +153 -0
  357. package/omega/Agentik_SSOT/skills/copyaudit/SKILL.md +161 -0
  358. package/omega/Agentik_SSOT/skills/dataaudit/SKILL.md +157 -0
  359. package/omega/Agentik_SSOT/skills/debugaudit/SKILL.md +161 -0
  360. package/omega/Agentik_SSOT/skills/dispatch/SKILL.md +79 -0
  361. package/omega/Agentik_SSOT/skills/dxaudit/SKILL.md +161 -0
  362. package/omega/Agentik_SSOT/skills/featureaudit/SKILL.md +161 -0
  363. package/omega/Agentik_SSOT/skills/flowaudit/SKILL.md +165 -0
  364. package/omega/Agentik_SSOT/skills/genesis/SKILL.md +116 -0
  365. package/omega/Agentik_SSOT/skills/handoff/SKILL.md +117 -0
  366. package/omega/Agentik_SSOT/skills/logicaudit/SKILL.md +165 -0
  367. package/omega/Agentik_SSOT/skills/motionaudit/SKILL.md +165 -0
  368. package/omega/Agentik_SSOT/skills/perfaudit/SKILL.md +161 -0
  369. package/omega/Agentik_SSOT/skills/plan/SKILL.md +127 -0
  370. package/omega/Agentik_SSOT/skills/pursue/SKILL.md +68 -0
  371. package/omega/Agentik_SSOT/skills/rag-route.md +82 -0
  372. package/omega/Agentik_SSOT/skills/refontaudit/SKILL.md +165 -0
  373. package/omega/Agentik_SSOT/skills/retentionaudit/SKILL.md +165 -0
  374. package/omega/Agentik_SSOT/skills/secaudit/SKILL.md +157 -0
  375. package/omega/Agentik_SSOT/skills/seoaudit/SKILL.md +161 -0
  376. package/omega/Agentik_SSOT/skills/skill-auditor/SKILL.md +83 -0
  377. package/omega/Agentik_SSOT/skills/skill-finder/SKILL.md +116 -0
  378. package/omega/Agentik_SSOT/skills/uiuxaudit/SKILL.md +165 -0
  379. package/package.json +2 -2
@@ -0,0 +1,315 @@
1
+ """The Telegram daemon — listens to the bot, routes messages.
2
+
3
+ Long-polls ``getUpdates`` (HTTP via ``curl``, the same pattern
4
+ :class:`omega_engine.telegram.TelegramBridge` uses) and routes every inbound
5
+ message:
6
+
7
+ 1. If the message is in a forum topic that an autonomous charter is bound to
8
+ → :meth:`AutonomousSupervisor.on_channel_message` (the agent handles it).
9
+ 2. Else, if the topic is a *project* topic registered in
10
+ ``Agentik_Coding/projects.json`` → :func:`run_mission` with that topic id.
11
+ 3. Else (no topic, just a DM to the bot) → log and ignore.
12
+
13
+ History: every routed message is persisted to
14
+ ``Agentik_Runtime/telegram-history.db`` via
15
+ :mod:`omega_engine.telegram_history`. When a topic message arrives, the
16
+ last N exchanges are prepended to the intent — that's the "the bot has
17
+ memory of the conversation" fix.
18
+
19
+ Routing rule: notifications NEVER go to the AISB DM. They go into the
20
+ project topic the mission was triggered from. The daemon enforces this by
21
+ refusing to start a mission for a message that came in without a
22
+ ``message_thread_id``.
23
+
24
+ The daemon shares no in-process state with the engine daemon — it talks to it
25
+ through the engine's HTTP API when a mission has to run (avoids two parallel
26
+ SQLite writers). Telegram is best-effort: a network blip never kills the loop.
27
+
28
+ On SIGTERM/SIGINT the daemon stops cleanly.
29
+ """
30
+ from __future__ import annotations
31
+
32
+ import json
33
+ import logging
34
+ import os
35
+ import signal
36
+ import subprocess
37
+ import time
38
+ from pathlib import Path
39
+ from typing import Any
40
+
41
+ from omega_engine.autonomous import build_supervisor_from_home
42
+
43
+ logger = logging.getLogger("omega.daemon.telegram")
44
+
45
+ _POLL_TIMEOUT_S = 25 # Telegram long-poll
46
+ _BACKOFF_S = 5.0 # on network / API errors
47
+ _API = "https://api.telegram.org"
48
+
49
+
50
+ def _omega_home() -> Path:
51
+ return Path(os.environ.get("OMEGA_HOME", str(Path.home() / "Omega")))
52
+
53
+
54
+ # ─────────────────────────────────────────────────────────────────────────────
55
+ # Telegram bot — getUpdates loop (curl-based, no extra deps)
56
+ # ─────────────────────────────────────────────────────────────────────────────
57
+
58
+ def _read_token(home: Path) -> str:
59
+ env_file = home / "Agentik_Extra" / "etc" / "secrets" / "telegram.env"
60
+ if not env_file.exists():
61
+ raise RuntimeError(f"telegram secret not found: {env_file}")
62
+ for line in env_file.read_text().splitlines():
63
+ line = line.strip()
64
+ if line.startswith("TELEGRAM_TOKEN="):
65
+ return line.split("=", 1)[1].strip()
66
+ raise RuntimeError("TELEGRAM_TOKEN missing from the vault")
67
+
68
+
69
+ def _curl_json(url: str, *, timeout: int) -> dict[str, Any]:
70
+ """Issue one curl call; return the parsed JSON or ``{}`` on hard failure."""
71
+ cmd = ["curl", "-s", "--max-time", str(timeout + 5), url]
72
+ proc = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout + 10)
73
+ if proc.returncode != 0:
74
+ raise RuntimeError(f"curl exit {proc.returncode}: {proc.stderr[:200]}")
75
+ try:
76
+ return json.loads(proc.stdout or "{}")
77
+ except json.JSONDecodeError as exc:
78
+ raise RuntimeError(f"bad JSON: {proc.stdout[:200]}") from exc
79
+
80
+
81
+ def _get_updates(token: str, offset: int) -> list[dict[str, Any]]:
82
+ """One long-poll cycle. Returns the new updates (possibly empty)."""
83
+ url = (f"{_API}/bot{token}/getUpdates?"
84
+ f"timeout={_POLL_TIMEOUT_S}&offset={offset}")
85
+ data = _curl_json(url, timeout=_POLL_TIMEOUT_S)
86
+ if not data.get("ok"):
87
+ raise RuntimeError(f"getUpdates: {data.get('description', 'unknown')}")
88
+ return data.get("result", []) or []
89
+
90
+
91
+ # ─────────────────────────────────────────────────────────────────────────────
92
+ # Routing
93
+ # ─────────────────────────────────────────────────────────────────────────────
94
+
95
+ def _project_topic_map(home: Path) -> dict[int, str]:
96
+ """Read the project registry. Returns ``{topic_id: slug}``.
97
+
98
+ A project owns a forum topic; messages in that topic are addressed to the
99
+ project (the missions the user types there run against it).
100
+ """
101
+ registry = home / "Agentik_Coding" / "projects.json"
102
+ if not registry.exists():
103
+ return {}
104
+ try:
105
+ rows = json.loads(registry.read_text() or "[]")
106
+ except json.JSONDecodeError:
107
+ return {}
108
+ out: dict[int, str] = {}
109
+ for row in rows:
110
+ topic = row.get("topic_id")
111
+ slug = row.get("slug")
112
+ if topic is not None and slug:
113
+ out[int(topic)] = str(slug)
114
+ return out
115
+
116
+
117
+ def _extract_message_fields(
118
+ update: dict[str, Any],
119
+ ) -> tuple[int | None, int | None, str | None, int | None]:
120
+ """Pull (topic_id, message_id, text, chat_id) from an update.
121
+
122
+ Returns all four; any may be None when the update isn't a text message.
123
+ We DON'T short-circuit on missing topic_id any more — DM messages now
124
+ flow through for logging + the operator-may-add-routing later.
125
+ """
126
+ msg = update.get("message") or update.get("edited_message") or {}
127
+ text = msg.get("text")
128
+ if not text:
129
+ return None, None, None, None
130
+ topic_id = msg.get("message_thread_id")
131
+ message_id = msg.get("message_id")
132
+ chat = msg.get("chat") or {}
133
+ chat_id = chat.get("id")
134
+ return topic_id, message_id, text, chat_id
135
+
136
+
137
+ def _route_one(
138
+ *,
139
+ topic_id: int | None,
140
+ text: str,
141
+ message_id: int | None,
142
+ chat_id: int | None,
143
+ supervisor,
144
+ project_map: dict[int, str],
145
+ home: Path,
146
+ telegram_bridge,
147
+ ) -> str:
148
+ """Route one inbound message; return a short tag for the log.
149
+
150
+ Now context-aware: every inbound + outbound exchange is persisted to
151
+ ``telegram-history`` so the Oracle sees the conversation, not just the
152
+ latest message.
153
+ """
154
+ from omega_engine import telegram_history
155
+
156
+ # DM (no topic) — log it, refuse to start a mission. AISB DM
157
+ # is NOT where the orchestration runs; it's where the operator
158
+ # talks to the bot 1:1. The mission must run inside a project topic.
159
+ if topic_id is None:
160
+ # We still record DM history so the operator's question + the
161
+ # bot's eventual reply (handled elsewhere) are linked.
162
+ telegram_history.record_inbound(
163
+ home, topic_id=0, text=text, message_id=message_id,
164
+ )
165
+ logger.info(
166
+ "telegram in: DM (chat=%s) text=%r — refusing to start a "
167
+ "mission from the DM; ask in a project topic instead",
168
+ chat_id, text[:80],
169
+ )
170
+ if telegram_bridge is not None and chat_id is not None:
171
+ try:
172
+ telegram_bridge._call("sendMessage", { # noqa: SLF001
173
+ "chat_id": str(chat_id),
174
+ "text": (
175
+ "Missions only run from a project topic in the "
176
+ "OmegaOS group — not the DM. Open the topic for "
177
+ "the project and re-send your request there."
178
+ ),
179
+ })
180
+ except Exception: # noqa: BLE001
181
+ logger.warning("telegram daemon: DM reply failed", exc_info=True)
182
+ return "dm:refused"
183
+
184
+ # Topic message — record + route.
185
+ telegram_history.record_inbound(
186
+ home, topic_id=topic_id, text=text, message_id=message_id,
187
+ )
188
+
189
+ # 1. autonomous-agent channel match wins
190
+ fired = supervisor.on_channel_message(topic_id, text)
191
+ if fired:
192
+ return f"autonomous:{','.join(fired)}"
193
+ # 2. project topic → run_mission with conversation context
194
+ slug = project_map.get(topic_id)
195
+ if slug:
196
+ # Build a context-aware intent that includes the last N exchanges
197
+ # in this topic — the Oracle now sees the conversation, not just
198
+ # the new line. THIS is the "bot has memory" fix.
199
+ enriched = telegram_history.build_context_prompt(
200
+ home, topic_id=topic_id, new_intent=text, limit=10,
201
+ )
202
+ from omega_engine.mission import run_mission
203
+ try:
204
+ outcome = run_mission(
205
+ intent=enriched,
206
+ omega_home=home,
207
+ topic_id=topic_id,
208
+ telegram=telegram_bridge,
209
+ )
210
+ except Exception: # noqa: BLE001
211
+ logger.exception("telegram daemon: project mission failed")
212
+ return f"project:{slug}:error"
213
+
214
+ # Record the bot's summary as an outbound message so the next
215
+ # inbound in this topic sees it as context.
216
+ summary = (
217
+ getattr(outcome, "summary", None)
218
+ or f"mission {getattr(outcome, 'mission_id', '?')} "
219
+ f"→ {getattr(getattr(outcome, 'final_state', None), 'value', '?')}"
220
+ )
221
+ telegram_history.record_outbound(
222
+ home, topic_id=topic_id, text=summary[:1000],
223
+ )
224
+ return f"project:{slug}"
225
+
226
+ # 3. unknown topic — log only; don't start a mission for stranger topics
227
+ logger.info(
228
+ "telegram in: unknown topic %s text=%r — no project routes here",
229
+ topic_id, text[:80],
230
+ )
231
+ return "topic:unknown"
232
+
233
+
234
+ # ─────────────────────────────────────────────────────────────────────────────
235
+ # Main loop
236
+ # ─────────────────────────────────────────────────────────────────────────────
237
+
238
+ def main() -> int:
239
+ logging.basicConfig(
240
+ level=os.environ.get("OMEGA_LOG_LEVEL", "INFO"),
241
+ format="%(asctime)s %(name)s %(levelname)s %(message)s",
242
+ )
243
+ home = _omega_home()
244
+ try:
245
+ token = _read_token(home)
246
+ except RuntimeError as exc:
247
+ logger.error("telegram daemon: %s", exc)
248
+ return 1
249
+
250
+ # the supervisor stays loaded (charters discovered at startup); we DO NOT
251
+ # call .run() — we just use it as a router. Channel-trigger firings will
252
+ # be dispatched via its callable runner (defaults to run_mission).
253
+ supervisor = build_supervisor_from_home(home)
254
+ project_map = _project_topic_map(home)
255
+ logger.info("telegram daemon: %d charter(s) bound, %d project(s) mapped",
256
+ len(supervisor.charters()), len(project_map))
257
+
258
+ # an outbound bridge for project missions (progress edits + PDF delivery)
259
+ telegram_bridge = None
260
+ try:
261
+ from omega_engine.telegram import TelegramBridge
262
+ telegram_bridge = TelegramBridge.from_vault(home)
263
+ except Exception as exc: # noqa: BLE001
264
+ logger.warning("telegram daemon: outbound bridge disabled (%s)", exc)
265
+
266
+ stop = [False]
267
+ signal.signal(signal.SIGTERM, lambda *_: stop.__setitem__(0, True))
268
+ signal.signal(signal.SIGINT, lambda *_: stop.__setitem__(0, True))
269
+
270
+ offset = 0 # only positive update_ids; 0 = "give me everything"
271
+ backoff = 0.0
272
+ while not stop[0]:
273
+ if backoff > 0:
274
+ # use a *short* sleep loop so SIGTERM still wakes us promptly
275
+ slept = 0.0
276
+ while slept < backoff and not stop[0]:
277
+ time.sleep(min(1.0, backoff - slept))
278
+ slept += 1.0
279
+ backoff = 0.0
280
+ if stop[0]:
281
+ break
282
+
283
+ try:
284
+ updates = _get_updates(token, offset)
285
+ except Exception as exc: # noqa: BLE001
286
+ logger.warning("telegram daemon: poll failed (%s) — backing off", exc)
287
+ backoff = _BACKOFF_S
288
+ continue
289
+
290
+ for update in updates:
291
+ offset = max(offset, int(update.get("update_id", 0)) + 1)
292
+ topic_id, message_id, text, chat_id = _extract_message_fields(update)
293
+ if not text:
294
+ continue
295
+ # refresh the project map periodically so newly created projects
296
+ # become routable without restarting the daemon
297
+ project_map = _project_topic_map(home)
298
+ try:
299
+ tag = _route_one(
300
+ topic_id=topic_id, text=text,
301
+ message_id=message_id, chat_id=chat_id,
302
+ supervisor=supervisor,
303
+ project_map=project_map, home=home,
304
+ telegram_bridge=telegram_bridge,
305
+ )
306
+ logger.info("telegram in: topic=%s text=%r -> %s",
307
+ topic_id, text[:80], tag)
308
+ except Exception: # noqa: BLE001
309
+ logger.exception("telegram daemon: routing failed")
310
+ logger.info("telegram daemon stopped")
311
+ return 0
312
+
313
+
314
+ if __name__ == "__main__": # pragma: no cover
315
+ raise SystemExit(main())
@@ -0,0 +1,154 @@
1
+ """Worker `.done.json` — the structured completion signal.
2
+
3
+ Events are the source of truth (event-sourcing). But events are *facts about
4
+ state*, not *artifacts the worker produced*. The done file is the workspace
5
+ artifact: the worker's structured summary of what it did, what's still
6
+ pending, what failed.
7
+
8
+ Schema
9
+ ------
10
+ ::
11
+
12
+ {
13
+ "status": "done_clean" | "pending" | "failed",
14
+ "summary": str,
15
+ "files_changed": [str, ...],
16
+ "artifacts": {str: any},
17
+ "pending_actions": [str, ...],
18
+ "errors": [str, ...],
19
+ "audit": {...} # optional, set by the verifier
20
+ }
21
+
22
+ Where it lives
23
+ --------------
24
+ ::
25
+
26
+ $OMEGA_HOME/Agentik_Runtime/sessions/<task_id>/.done.json
27
+
28
+ The executor passes this path to the worker through the envelope; the worker
29
+ writes there when finished; the audit gate reads it back before flipping
30
+ VERIFIED. AISB / parent dispatchers can also read it to surface progress.
31
+ """
32
+ from __future__ import annotations
33
+
34
+ import json
35
+ import os
36
+ import threading
37
+ from dataclasses import asdict, dataclass, field
38
+ from pathlib import Path
39
+ from typing import Any
40
+
41
+
42
+ VALID_STATUSES = {"done_clean", "pending", "failed"}
43
+
44
+
45
+ class DoneSignalError(RuntimeError):
46
+ """The done file is missing, malformed, or claims an invalid status."""
47
+
48
+
49
+ @dataclass
50
+ class DoneSignal:
51
+ status: str = "pending"
52
+ summary: str = ""
53
+ files_changed: list[str] = field(default_factory=list)
54
+ artifacts: dict[str, Any] = field(default_factory=dict)
55
+ pending_actions: list[str] = field(default_factory=list)
56
+ errors: list[str] = field(default_factory=list)
57
+ audit: dict[str, Any] = field(default_factory=dict)
58
+
59
+ def to_json(self) -> str:
60
+ return json.dumps(asdict(self), indent=2, ensure_ascii=False)
61
+
62
+
63
+ def session_dir(omega_home: str | Path, task_id: str) -> Path:
64
+ """Per-task session directory; created on demand with mode 700."""
65
+ d = Path(omega_home) / "Agentik_Runtime" / "sessions" / task_id
66
+ d.mkdir(parents=True, exist_ok=True)
67
+ try:
68
+ os.chmod(d, 0o700)
69
+ except OSError:
70
+ pass
71
+ return d
72
+
73
+
74
+ def done_path(omega_home: str | Path, task_id: str) -> Path:
75
+ return session_dir(omega_home, task_id) / ".done.json"
76
+
77
+
78
+ def write_done(
79
+ omega_home: str | Path,
80
+ task_id: str,
81
+ signal: DoneSignal,
82
+ ) -> Path:
83
+ """Write a DoneSignal as JSON to the session dir, ATOMICALLY.
84
+
85
+ Atomicity matters here: ``read_done`` is polled by the audit gate, the
86
+ Telegram patrol, AISB, and a partial write would make the verifier read
87
+ half a JSON blob. We write to a temp file in the same dir, fsync, then
88
+ rename — rename within the same filesystem is atomic.
89
+ """
90
+ if signal.status not in VALID_STATUSES:
91
+ raise DoneSignalError(
92
+ f"invalid status {signal.status!r} — must be one of {VALID_STATUSES}"
93
+ )
94
+ path = done_path(omega_home, task_id)
95
+ # Unique tmp suffix per call so concurrent writers from different
96
+ # threads don't clobber each other's intermediate file.
97
+ tmp = path.with_suffix(
98
+ path.suffix + f".tmp.{os.getpid()}.{threading.get_ident()}"
99
+ )
100
+ # Write + fsync + close. `os.fdopen` takes ownership of `fd` so the
101
+ # `with` block is responsible for closing — we never double-close.
102
+ fd = os.open(str(tmp), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
103
+ with os.fdopen(fd, "w") as fh:
104
+ fh.write(signal.to_json())
105
+ fh.flush()
106
+ try:
107
+ os.fsync(fh.fileno())
108
+ except OSError:
109
+ # tmpfs / network FS may not support fsync — best-effort.
110
+ pass
111
+ # Atomic rename. POSIX guarantees same-dir rename is atomic; readers
112
+ # see either the old file or the new file, never a partial blob.
113
+ os.replace(tmp, path)
114
+ return path
115
+
116
+
117
+ def read_done(omega_home: str | Path, task_id: str) -> DoneSignal | None:
118
+ """Read a DoneSignal back. Returns None if the file is missing."""
119
+ path = done_path(omega_home, task_id)
120
+ if not path.exists():
121
+ return None
122
+ try:
123
+ data = json.loads(path.read_text())
124
+ except (json.JSONDecodeError, OSError) as exc:
125
+ raise DoneSignalError(f"unparseable done file at {path}: {exc}") from exc
126
+ if not isinstance(data, dict):
127
+ raise DoneSignalError(f"done file must be a JSON object, got {type(data)}")
128
+ status = data.get("status", "")
129
+ if status not in VALID_STATUSES:
130
+ raise DoneSignalError(
131
+ f"done file {path} has invalid status {status!r}"
132
+ )
133
+ return DoneSignal(
134
+ status=status,
135
+ summary=str(data.get("summary", "")),
136
+ files_changed=list(data.get("files_changed") or []),
137
+ artifacts=dict(data.get("artifacts") or {}),
138
+ pending_actions=list(data.get("pending_actions") or []),
139
+ errors=list(data.get("errors") or []),
140
+ audit=dict(data.get("audit") or {}),
141
+ )
142
+
143
+
144
+ def attach_audit_to_done(
145
+ omega_home: str | Path,
146
+ task_id: str,
147
+ audit: dict[str, Any],
148
+ ) -> None:
149
+ """Update an existing done file in place with the verifier's verdict."""
150
+ signal = read_done(omega_home, task_id)
151
+ if signal is None:
152
+ signal = DoneSignal(status="pending", summary="(audit-only)")
153
+ signal.audit = dict(audit)
154
+ write_done(omega_home, task_id, signal)
@@ -0,0 +1,51 @@
1
+ """The educators — the self-improving layer of OmegaOS.
2
+
3
+ Eight generators that produce SSOT artifacts under the same quality gate that
4
+ guards code. The framework lives in ``base``; each domain has its own focused
5
+ module. None of them write to the SSOT directly — every proposal goes through
6
+ ``StagingPipeline``.
7
+
8
+ Usage::
9
+
10
+ from omega_engine.educators import EducatorRegistry, StagingPipeline
11
+ from omega_engine.provider import MockProvider
12
+
13
+ registry = EducatorRegistry.default()
14
+ staging = StagingPipeline("/path/to/Agentik_Extra/staging/promotion")
15
+ proposal = registry.get("prompt").generate(
16
+ intent="oracle dispatches to a fresh worker",
17
+ context={"source": "oracle", "target": "worker"},
18
+ provider=MockProvider(),
19
+ )
20
+ record = staging.stage(proposal)
21
+ """
22
+ from omega_engine.educators.artifact import ArtifactEducator
23
+ from omega_engine.educators.automation import AutomationEducator
24
+ from omega_engine.educators.base import (
25
+ Artifact,
26
+ Educator,
27
+ EducatorProposal,
28
+ EducatorRegistry,
29
+ StagingPipeline,
30
+ StagingRecord,
31
+ build_education_prompt,
32
+ parse_proposal,
33
+ run_education,
34
+ )
35
+ from omega_engine.educators.claudecode import ClaudecodeEducator
36
+ from omega_engine.educators.connection import ConnectionEducator
37
+ from omega_engine.educators.coworker import CoworkerEducator
38
+ from omega_engine.educators.loop import LoopEducator
39
+ from omega_engine.educators.prompt import PromptEducator
40
+ from omega_engine.educators.skill import SkillEducator
41
+
42
+ __all__ = [
43
+ # framework
44
+ "Artifact", "Educator", "EducatorProposal", "EducatorRegistry",
45
+ "StagingPipeline", "StagingRecord",
46
+ "build_education_prompt", "parse_proposal", "run_education",
47
+ # the eight
48
+ "PromptEducator", "ArtifactEducator", "SkillEducator", "CoworkerEducator",
49
+ "ConnectionEducator", "AutomationEducator", "ClaudecodeEducator",
50
+ "LoopEducator",
51
+ ]
@@ -0,0 +1,65 @@
1
+ """`artifact-educator` — generates templates for deliverables.
2
+
3
+ The signature: produces a reusable template for a class of artifacts that
4
+ workers ship at the end of a mission — mission reports, audit reports, doc
5
+ pages, component scaffolds, PR descriptions, ADRs.
6
+
7
+ Target SSOT path: ``Agentik_SSOT/templates/<kind>.md``.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ from typing import Any
12
+
13
+ from omega_engine.educators.base import EducatorProposal, run_education
14
+ from omega_engine.provider import AgentProvider
15
+
16
+ _INSTRUCTIONS = """\
17
+ Produce ONE artifact TEMPLATE — a reusable scaffold that workers fill in when
18
+ they ship work of this kind. The template MUST:
19
+
20
+ 1. Open with a one-line statement of what THIS template is for.
21
+ 2. Define the required sections (use H2 headings) in fill-in order — every
22
+ section title MUST be the noun-phrase the worker uses ("Summary",
23
+ "Changes", "Tests", "Verify Command", "Screenshots"), never a generic
24
+ "details" or "info".
25
+ 3. Mark required-vs-optional sections explicitly (e.g. "[required]").
26
+ 4. Provide ONE-LINE placeholders in each section, in the form
27
+ `<short prompt to the worker, in imperative voice>` — never lorem ipsum.
28
+ 5. End with a quality checklist (3-7 boxes) the worker self-checks before
29
+ declaring done — the items must be falsifiable, not feel-good.
30
+
31
+ The template MUST NOT:
32
+ - assume the worker has unbounded time or tokens (sections must be terse)
33
+ - omit a verification section (every deliverable shows HOW it was verified)
34
+ - duplicate work that other templates already handle — state the boundary
35
+ if there is overlap.
36
+
37
+ Format the artifact as Markdown.
38
+ """
39
+
40
+
41
+ class ArtifactEducator:
42
+ """Generates artifact templates for worker deliverables."""
43
+
44
+ name = "artifact"
45
+ domain = "deliverable-templates"
46
+
47
+ def generate(
48
+ self,
49
+ intent: str,
50
+ context: dict[str, Any],
51
+ provider: AgentProvider,
52
+ ) -> EducatorProposal:
53
+ kind = str(context.get("artifact_kind", "report"))
54
+ target_path = f"Agentik_SSOT/templates/{kind}.md"
55
+ return run_education(
56
+ educator_name=self.name,
57
+ domain=self.domain,
58
+ intent=intent,
59
+ target_kind="template",
60
+ target_path=target_path,
61
+ domain_instructions=_INSTRUCTIONS,
62
+ context={**context, "artifact_kind": kind},
63
+ provider=provider,
64
+ artifact_id=kind,
65
+ )
@@ -0,0 +1,76 @@
1
+ """`automation-educator` — generates hooks, crons, reactors.
2
+
3
+ The signature: an automation declares a TRIGGER → ACTION binding the supervisor
4
+ runs unattended. Crons (time), hooks (event), reactors (state change). Every
5
+ automation is auditable: it logs to the event store and inherits the deadman.
6
+
7
+ Target SSOT path: ``Agentik_SSOT/automations/<id>.yaml``.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ from typing import Any
12
+
13
+ from omega_engine.educators.base import EducatorProposal, run_education
14
+ from omega_engine.provider import AgentProvider
15
+
16
+ _INSTRUCTIONS = """\
17
+ Produce ONE automation config in YAML. The config MUST contain these fields:
18
+
19
+ id: <stable identifier, lowercase, kebab-case>
20
+ kind: cron | hook | reactor
21
+ description: <one line>
22
+ trigger:
23
+ # for cron: schedule: "<cron expression>" + timezone: <IANA tz>
24
+ # for hook: event: <event.type from the event store>
25
+ # for reactor: state_from: <FSM state> state_to: <FSM state>
26
+ # kind_filter: <task kind | "*">
27
+ action:
28
+ skill: <skill id, OR>
29
+ command: <shell command, OR>
30
+ dispatch_role: <role from Agentik_SSOT/agents/>
31
+ budget:
32
+ max_iterations: <int>
33
+ wall_timeout_sec: <int>
34
+ cost_cap_usd: <number | null>
35
+ guards:
36
+ - <a pre-condition predicate the supervisor evaluates before firing>
37
+ on_failure: log_only | retry_n | escalate
38
+ observability:
39
+ heartbeat_sec: <int> # missed heartbeat = deadman terminal
40
+ emits: [ <event.type the action emits> ]
41
+
42
+ The automation MUST NOT:
43
+ - fire without a heartbeat (silent automations are a debug nightmare).
44
+ - bypass the audit gate when its action produces artifacts.
45
+ - declare more than one of (skill, command, dispatch_role) — exactly one.
46
+ - omit `on_failure` (default behaviour is too important to leave implicit).
47
+
48
+ Format the artifact as valid YAML — strict.
49
+ """
50
+
51
+
52
+ class AutomationEducator:
53
+ """Generates automation specs (cron / hook / reactor) for the SSOT."""
54
+
55
+ name = "automation"
56
+ domain = "automations"
57
+
58
+ def generate(
59
+ self,
60
+ intent: str,
61
+ context: dict[str, Any],
62
+ provider: AgentProvider,
63
+ ) -> EducatorProposal:
64
+ automation_id = str(context.get("automation_id", "new-automation"))
65
+ target_path = f"Agentik_SSOT/automations/{automation_id}.yaml"
66
+ return run_education(
67
+ educator_name=self.name,
68
+ domain=self.domain,
69
+ intent=intent,
70
+ target_kind="automation",
71
+ target_path=target_path,
72
+ domain_instructions=_INSTRUCTIONS,
73
+ context={**context, "automation_id": automation_id},
74
+ provider=provider,
75
+ artifact_id=automation_id,
76
+ )