@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,673 @@
1
+ """`omega cleanup` — disk cleanup adapted to the OmegaOS layout.
2
+
3
+ Why this exists (and why we don't just call the AISB cleanup script)
4
+ --------------------------------------------------------------------
5
+
6
+ The AISB cleanup script (``~/.claude/lib/cleanup.sh``) targets the live VPS
7
+ layout — ``~/.aisb/state``, ``~/.claude-mem``, ``~/VibeCoding/**``, etc. None
8
+ of those paths exist in a clean OmegaOS install. OmegaOS owns its own tree
9
+ under ``$OMEGA_HOME``:
10
+
11
+ Agentik_Engine/ code (DO NOT touch)
12
+ Agentik_SSOT/ source of truth for agents/charters (DO NOT touch)
13
+ Agentik_Tools/ installed binaries (DO NOT touch)
14
+ Agentik_Vault/ encrypted secrets (DO NOT touch)
15
+ Agentik_Coding/ project working trees + node_modules
16
+ Agentik_Runtime/ SQLite DBs + per-task sessions + memory index
17
+ Agentik_Extra/ var/{tmp,cache,logs}, staging, transcripts
18
+ Agentik_Providers/ registry yaml (DO NOT touch)
19
+ Agentik_Orchestration/ topology yaml (DO NOT touch)
20
+
21
+ The tier list below mirrors the AISB script's spirit but every path is
22
+ OmegaOS-native. Tier 3 delegates to :mod:`omega_engine.prune` so the
23
+ SQLite-bounded growth and per-task session cleanup are one source of truth.
24
+ Tier 4 delegates to :mod:`omega_engine.tmux` so stale workers go through the
25
+ existing kill path.
26
+
27
+ Modes
28
+ -----
29
+
30
+ cleanup(dry_run=True) — print what would be freed, touch nothing
31
+ cleanup(dry_run=False) — apply tiers 1-6
32
+ cleanup(deep=True) — also runs the deep tiers (staging,
33
+ transcripts, VACUUM, opensrc cache)
34
+ cleanup(target_pct=25) — stop early once disk usage < target_pct
35
+ cleanup(idle_days=14) — override node_modules idle threshold
36
+
37
+ Returns a list of :class:`TierResult`. Each report fits on one line in the
38
+ CLI summary.
39
+
40
+ Never touched (hardcoded never-list)
41
+ ------------------------------------
42
+
43
+ * ``Agentik_Engine/``, ``Agentik_SSOT/``, ``Agentik_Tools/``,
44
+ ``Agentik_Vault/``, ``Agentik_Providers/``, ``Agentik_Orchestration/``
45
+ * ``Agentik_Coding/projects/<slug>/`` source files (only ``node_modules``
46
+ are candidates, and only when the project itself hasn't been touched
47
+ for ``idle_days`` days)
48
+ * Per-task session dirs that have a ``brief.json`` but no ``.done.json``
49
+ (the worker is still running)
50
+ * Any file currently held open by a live tmux session
51
+ * Anything under ``$OMEGA_HOME/.vault-key`` or ``.vault-pub``
52
+ """
53
+ from __future__ import annotations
54
+
55
+ import os
56
+ import shutil
57
+ import sqlite3
58
+ import subprocess
59
+ import time
60
+ from dataclasses import dataclass, field
61
+ from pathlib import Path
62
+
63
+
64
+ @dataclass
65
+ class TierResult:
66
+ tier: str
67
+ items_removed: int = 0
68
+ bytes_freed: int = 0
69
+ dry_run: bool = False
70
+ detail: str = ""
71
+ skipped: list[str] = field(default_factory=list)
72
+
73
+ @property
74
+ def line(self) -> str:
75
+ bytes_str = _human(self.bytes_freed)
76
+ flag = " [dry-run]" if self.dry_run else ""
77
+ return (
78
+ f"{self.tier:30s} items={self.items_removed:4d} "
79
+ f"freed={bytes_str:>8s}{flag} {self.detail}"
80
+ )
81
+
82
+
83
+ # ---------------------------------------------------------------------------
84
+ # Helpers
85
+ # ---------------------------------------------------------------------------
86
+
87
+
88
+ def _human(n: int) -> str:
89
+ if n < 1024:
90
+ return f"{n}B"
91
+ for unit in ("K", "M", "G", "T"):
92
+ n_f = n / 1024.0
93
+ if n_f < 1024 or unit == "T":
94
+ return f"{n_f:.1f}{unit}"
95
+ n = int(n_f)
96
+ return f"{n}B"
97
+
98
+
99
+ def _dir_size(path: Path) -> int:
100
+ if not path.exists():
101
+ return 0
102
+ total = 0
103
+ try:
104
+ for p in path.rglob("*"):
105
+ try:
106
+ if p.is_file() and not p.is_symlink():
107
+ total += p.stat().st_size
108
+ except OSError:
109
+ pass
110
+ except OSError:
111
+ pass
112
+ return total
113
+
114
+
115
+ def _rm_tree(path: Path, *, dry_run: bool) -> int:
116
+ """Remove a dir tree. Returns bytes freed (size before)."""
117
+ if not path.exists():
118
+ return 0
119
+ sz = _dir_size(path)
120
+ if not dry_run:
121
+ shutil.rmtree(path, ignore_errors=True)
122
+ return sz
123
+
124
+
125
+ def _disk_usage_pct(home: Path) -> int:
126
+ """Return the % full of the filesystem holding `home`."""
127
+ try:
128
+ stat = os.statvfs(str(home))
129
+ used = (stat.f_blocks - stat.f_bavail) * stat.f_frsize
130
+ total = stat.f_blocks * stat.f_frsize
131
+ if total == 0:
132
+ return 0
133
+ return int(used / total * 100)
134
+ except OSError:
135
+ return 0
136
+
137
+
138
+ def _omega_home(home: str | Path | None) -> Path:
139
+ if home is not None:
140
+ return Path(home)
141
+ return Path(os.environ.get("OMEGA_HOME", str(Path.home() / "Omega")))
142
+
143
+
144
+ # ---------------------------------------------------------------------------
145
+ # Tier 1 — Regenerable system caches
146
+ # ---------------------------------------------------------------------------
147
+
148
+
149
+ _TIER1_PATHS: list[str] = [
150
+ "~/.npm/_npx",
151
+ "~/.npm/_cacache",
152
+ "~/.bun/install/cache",
153
+ "~/.cache/ms-playwright",
154
+ "~/.cache/uv",
155
+ "~/.cache/pip",
156
+ "~/.cache/bun",
157
+ "~/.cache/node-gyp",
158
+ ]
159
+
160
+
161
+ def tier1_caches(*, dry_run: bool = False) -> TierResult:
162
+ """System-wide regenerable caches. Self-healing on next npm/uv/pip run."""
163
+ total_bytes = 0
164
+ items = 0
165
+ for spec in _TIER1_PATHS:
166
+ p = Path(spec).expanduser()
167
+ if not p.exists():
168
+ continue
169
+ sz = _rm_tree(p, dry_run=dry_run)
170
+ if sz > 0:
171
+ total_bytes += sz
172
+ items += 1
173
+ return TierResult(
174
+ tier="1 system caches",
175
+ items_removed=items,
176
+ bytes_freed=total_bytes,
177
+ dry_run=dry_run,
178
+ detail=f"paths={items}",
179
+ )
180
+
181
+
182
+ # ---------------------------------------------------------------------------
183
+ # Tier 2 — OmegaOS scratch / temp scaffolds
184
+ # ---------------------------------------------------------------------------
185
+
186
+
187
+ def tier2_scratch(home: Path, *, dry_run: bool = False) -> TierResult:
188
+ """OmegaOS-tagged /tmp scaffolds + $OMEGA_HOME/Agentik_Extra/var/tmp."""
189
+ items = 0
190
+ bytes_freed = 0
191
+
192
+ # /tmp scaffolds tagged for OmegaOS / AISB
193
+ tmp = Path("/tmp")
194
+ if tmp.exists():
195
+ cutoff = time.time() - 86400 # >1d
196
+ for child in tmp.iterdir():
197
+ try:
198
+ name = child.name
199
+ if not (name.startswith("omega-") or name.startswith("aisb-")
200
+ or name.startswith("omega_") or name.startswith("aisb_")):
201
+ continue
202
+ if child.stat().st_mtime > cutoff:
203
+ continue
204
+ except OSError:
205
+ continue
206
+ sz = _dir_size(child) if child.is_dir() else _safe_size(child)
207
+ if not dry_run:
208
+ if child.is_dir():
209
+ shutil.rmtree(child, ignore_errors=True)
210
+ else:
211
+ try:
212
+ child.unlink()
213
+ except OSError:
214
+ pass
215
+ items += 1
216
+ bytes_freed += sz
217
+
218
+ # $OMEGA_HOME/Agentik_Extra/var/tmp/* + var/cache/*
219
+ var_tmp = home / "Agentik_Extra" / "var" / "tmp"
220
+ var_cache = home / "Agentik_Extra" / "var" / "cache"
221
+ for root in (var_tmp, var_cache):
222
+ if not root.is_dir():
223
+ continue
224
+ cutoff = time.time() - 86400
225
+ for child in root.iterdir():
226
+ try:
227
+ if child.stat().st_mtime > cutoff:
228
+ continue
229
+ except OSError:
230
+ continue
231
+ sz = _dir_size(child) if child.is_dir() else _safe_size(child)
232
+ if not dry_run:
233
+ if child.is_dir():
234
+ shutil.rmtree(child, ignore_errors=True)
235
+ else:
236
+ try:
237
+ child.unlink()
238
+ except OSError:
239
+ pass
240
+ items += 1
241
+ bytes_freed += sz
242
+
243
+ return TierResult(
244
+ tier="2 scratch + var/tmp", items_removed=items,
245
+ bytes_freed=bytes_freed, dry_run=dry_run,
246
+ detail=">1d under /tmp/omega-* + Agentik_Extra/var/{tmp,cache}",
247
+ )
248
+
249
+
250
+ def _safe_size(p: Path) -> int:
251
+ try:
252
+ return p.stat().st_size
253
+ except OSError:
254
+ return 0
255
+
256
+
257
+ # ---------------------------------------------------------------------------
258
+ # Tier 3 — OmegaOS runtime DBs + sessions (delegate to prune)
259
+ # ---------------------------------------------------------------------------
260
+
261
+
262
+ def tier3_runtime(
263
+ home: Path, *, older_than_days: int = 30, dry_run: bool = False,
264
+ ) -> TierResult:
265
+ """Delegate to omega.prune for events/audits/telegram/sessions."""
266
+ from omega_engine import prune as P
267
+
268
+ reports = [
269
+ P.prune_events(home, older_than_days=older_than_days, dry_run=dry_run),
270
+ P.prune_audits(home, older_than_days=older_than_days, dry_run=dry_run),
271
+ P.prune_telegram(home, older_than_days=older_than_days, dry_run=dry_run),
272
+ P.prune_sessions(home, older_than_days=older_than_days, dry_run=dry_run),
273
+ ]
274
+ items = sum(r.rows_deleted + r.files_deleted for r in reports)
275
+ bytes_freed = sum(r.bytes_freed for r in reports)
276
+ parts = [
277
+ f"{r.target}={r.rows_deleted or r.files_deleted}" for r in reports
278
+ ]
279
+ return TierResult(
280
+ tier="3 runtime DBs+sessions", items_removed=items,
281
+ bytes_freed=bytes_freed, dry_run=dry_run,
282
+ detail=", ".join(parts) + f" >={older_than_days}d",
283
+ )
284
+
285
+
286
+ # ---------------------------------------------------------------------------
287
+ # Tier 4 — Stale tmux worker sessions
288
+ # ---------------------------------------------------------------------------
289
+
290
+
291
+ def tier4_tmux(
292
+ home: Path, *, older_than_hours: int = 24, dry_run: bool = False,
293
+ ) -> TierResult:
294
+ """Kill detached worker tmux sessions older than `older_than_hours`."""
295
+ try:
296
+ from omega_engine import tmux as TX
297
+ except ImportError:
298
+ return TierResult(tier="4 tmux workers", dry_run=dry_run,
299
+ detail="tmux module unavailable")
300
+ res = TX.cleanup_stale(home, older_than_hours=older_than_hours,
301
+ dry_run=dry_run)
302
+ items = len(res.get("candidates", []))
303
+ return TierResult(
304
+ tier="4 tmux workers", items_removed=items, dry_run=dry_run,
305
+ detail=f">={older_than_hours}h detached: "
306
+ f"{', '.join(res.get('candidates', []))[:80]}",
307
+ )
308
+
309
+
310
+ # ---------------------------------------------------------------------------
311
+ # Tier 5 — Idle node_modules in OmegaOS coding tree
312
+ # ---------------------------------------------------------------------------
313
+
314
+
315
+ def tier5_node_modules(
316
+ home: Path, *, idle_days: int = 7, dry_run: bool = False,
317
+ ) -> TierResult:
318
+ """Remove node_modules in $OMEGA_HOME/Agentik_Coding/projects/<slug>/
319
+ when the *project* itself has had no edit in `idle_days` days.
320
+
321
+ We check the project root, not just `node_modules`, so a project that
322
+ was last touched 10d ago is safe to nuke even if `node_modules` mtime is
323
+ newer (e.g. a stale lockfile rewrite).
324
+ """
325
+ coding = home / "Agentik_Coding" / "projects"
326
+ if not coding.is_dir():
327
+ return TierResult(tier="5 node_modules", dry_run=dry_run,
328
+ detail="no Agentik_Coding/projects")
329
+ cutoff = time.time() - idle_days * 86400
330
+ items = 0
331
+ bytes_freed = 0
332
+ skipped = []
333
+ for proj in coding.iterdir():
334
+ if not proj.is_dir():
335
+ continue
336
+ nm = proj / "node_modules"
337
+ if not nm.is_dir():
338
+ continue
339
+ # Newest edit anywhere under the project (excluding node_modules itself)
340
+ newest = _newest_mtime(proj, ignore_subdir="node_modules")
341
+ if newest >= cutoff:
342
+ skipped.append(proj.name)
343
+ continue
344
+ sz = _dir_size(nm)
345
+ if not dry_run:
346
+ shutil.rmtree(nm, ignore_errors=True)
347
+ items += 1
348
+ bytes_freed += sz
349
+ return TierResult(
350
+ tier="5 node_modules", items_removed=items, bytes_freed=bytes_freed,
351
+ dry_run=dry_run, skipped=skipped,
352
+ detail=f"idle>={idle_days}d (kept {len(skipped)} active)",
353
+ )
354
+
355
+
356
+ def _newest_mtime(root: Path, *, ignore_subdir: str | None = None) -> float:
357
+ """Newest mtime of any FILE under root (dirs are skipped — their mtime
358
+ bumps on child create/delete, which is noise for "is this project idle").
359
+ """
360
+ newest = 0.0
361
+ try:
362
+ for p in root.iterdir():
363
+ if ignore_subdir and p.name == ignore_subdir:
364
+ continue
365
+ try:
366
+ if p.is_dir():
367
+ n = _newest_mtime(p)
368
+ else:
369
+ n = p.stat().st_mtime
370
+ if n > newest:
371
+ newest = n
372
+ except OSError:
373
+ continue
374
+ except OSError:
375
+ pass
376
+ # If no file anywhere — fall back to the root's own mtime to avoid
377
+ # nuking a brand-new but legitimately empty project.
378
+ if newest == 0.0:
379
+ try:
380
+ newest = root.stat().st_mtime
381
+ except OSError:
382
+ pass
383
+ return newest
384
+
385
+
386
+ # ---------------------------------------------------------------------------
387
+ # Tier 6 — Truncate giant logs
388
+ # ---------------------------------------------------------------------------
389
+
390
+
391
+ def tier6_logs(
392
+ home: Path, *, max_log_mb: int = 20, keep_tail_mb: int = 1,
393
+ dry_run: bool = False,
394
+ ) -> TierResult:
395
+ """Truncate (NOT delete) Agentik_Extra/var/logs/*.log when they exceed
396
+ `max_log_mb`. We keep the last `keep_tail_mb` bytes so context survives.
397
+ Daemons may hold the FD open, so truncate-in-place not unlink."""
398
+ logs = home / "Agentik_Extra" / "var" / "logs"
399
+ if not logs.is_dir():
400
+ return TierResult(tier="6 logs", dry_run=dry_run,
401
+ detail="no var/logs")
402
+ max_bytes = max_log_mb * 1024 * 1024
403
+ keep_bytes = keep_tail_mb * 1024 * 1024
404
+ items = 0
405
+ freed = 0
406
+ for child in logs.glob("*.log"):
407
+ try:
408
+ sz = child.stat().st_size
409
+ except OSError:
410
+ continue
411
+ if sz <= max_bytes:
412
+ continue
413
+ if dry_run:
414
+ items += 1
415
+ freed += sz - keep_bytes
416
+ continue
417
+ try:
418
+ with child.open("rb") as f:
419
+ f.seek(-keep_bytes, os.SEEK_END)
420
+ tail = f.read()
421
+ with child.open("wb") as f:
422
+ f.write(tail)
423
+ items += 1
424
+ freed += sz - keep_bytes
425
+ except OSError:
426
+ continue
427
+ return TierResult(
428
+ tier="6 logs", items_removed=items, bytes_freed=freed,
429
+ dry_run=dry_run, detail=f"truncated >{max_log_mb}MB → {keep_tail_mb}MB tail",
430
+ )
431
+
432
+
433
+ # ---------------------------------------------------------------------------
434
+ # Deep tier — staging, transcripts, VACUUM
435
+ # ---------------------------------------------------------------------------
436
+
437
+
438
+ def deep_staging(
439
+ home: Path, *, older_than_days: int = 14, dry_run: bool = False,
440
+ ) -> TierResult:
441
+ """Delete completed Smith insight proposals older than `older_than_days`.
442
+
443
+ Insights live under Agentik_Extra/staging/promotion/*.json — those are
444
+ OUTPUT of Smith reflection. Once they've been triaged (accepted/rejected)
445
+ they're safe to nuke. We use mtime as proxy for "triaged"."""
446
+ staging = home / "Agentik_Extra" / "staging" / "promotion"
447
+ if not staging.is_dir():
448
+ return TierResult(tier="D staging", dry_run=dry_run,
449
+ detail="no staging dir")
450
+ cutoff = time.time() - older_than_days * 86400
451
+ items = 0
452
+ freed = 0
453
+ for child in staging.iterdir():
454
+ try:
455
+ if child.stat().st_mtime > cutoff:
456
+ continue
457
+ sz = _safe_size(child) if child.is_file() else _dir_size(child)
458
+ except OSError:
459
+ continue
460
+ if not dry_run:
461
+ if child.is_dir():
462
+ shutil.rmtree(child, ignore_errors=True)
463
+ else:
464
+ try:
465
+ child.unlink()
466
+ except OSError:
467
+ pass
468
+ items += 1
469
+ freed += sz
470
+ return TierResult(
471
+ tier="D staging insights", items_removed=items, bytes_freed=freed,
472
+ dry_run=dry_run, detail=f">={older_than_days}d in staging/promotion",
473
+ )
474
+
475
+
476
+ def deep_transcripts(
477
+ home: Path, *, older_than_days: int = 7, dry_run: bool = False,
478
+ ) -> TierResult:
479
+ """Drop raw claude transcript blobs older than `older_than_days`.
480
+
481
+ Transcripts live as ``Agentik_Runtime/sessions/<task_id>/transcript.json``.
482
+ They're debug-only — the structured ``.done.json`` is the real artifact.
483
+ Only nuke transcripts for tasks that have a ``.done.json`` (i.e. completed)."""
484
+ sess_root = home / "Agentik_Runtime" / "sessions"
485
+ if not sess_root.is_dir():
486
+ return TierResult(tier="D transcripts", dry_run=dry_run,
487
+ detail="no sessions dir")
488
+ cutoff = time.time() - older_than_days * 86400
489
+ items = 0
490
+ freed = 0
491
+ for child in sess_root.iterdir():
492
+ if not child.is_dir():
493
+ continue
494
+ done = child / ".done.json"
495
+ tr = child / "transcript.json"
496
+ if not (done.exists() and tr.exists()):
497
+ continue
498
+ try:
499
+ if tr.stat().st_mtime > cutoff:
500
+ continue
501
+ sz = _safe_size(tr)
502
+ except OSError:
503
+ continue
504
+ if not dry_run:
505
+ try:
506
+ tr.unlink()
507
+ except OSError:
508
+ continue
509
+ items += 1
510
+ freed += sz
511
+ return TierResult(
512
+ tier="D transcripts", items_removed=items, bytes_freed=freed,
513
+ dry_run=dry_run, detail=f">={older_than_days}d for completed tasks",
514
+ )
515
+
516
+
517
+ def deep_vacuum(home: Path, *, dry_run: bool = False) -> TierResult:
518
+ """VACUUM the OmegaOS SQLite DBs to reclaim freelist pages after prune."""
519
+ dbs = [
520
+ home / "Agentik_Runtime" / "eventlog" / "omega.db",
521
+ home / "Agentik_Runtime" / "audits.db",
522
+ home / "Agentik_Runtime" / "telegram-history.db",
523
+ home / "Agentik_Runtime" / "memory" / "index.db",
524
+ ]
525
+ items = 0
526
+ freed = 0
527
+ for db in dbs:
528
+ if not db.exists():
529
+ continue
530
+ before = _safe_size(db)
531
+ if dry_run:
532
+ items += 1
533
+ continue
534
+ try:
535
+ conn = sqlite3.connect(str(db))
536
+ try:
537
+ conn.execute("VACUUM")
538
+ conn.commit()
539
+ finally:
540
+ conn.close()
541
+ after = _safe_size(db)
542
+ items += 1
543
+ freed += max(0, before - after)
544
+ except sqlite3.Error:
545
+ continue
546
+ return TierResult(
547
+ tier="D VACUUM DBs", items_removed=items, bytes_freed=freed,
548
+ dry_run=dry_run, detail="sqlite freelist reclaim",
549
+ )
550
+
551
+
552
+ def deep_opensrc(*, dry_run: bool = False) -> TierResult:
553
+ """Wipe ~/.opensrc/repos — re-fetched on next opensrc CLI use.
554
+ Not OmegaOS-specific but cheap and commonly large."""
555
+ p = Path.home() / ".opensrc" / "repos"
556
+ sz = _rm_tree(p, dry_run=dry_run)
557
+ return TierResult(
558
+ tier="D opensrc cache", items_removed=1 if sz else 0,
559
+ bytes_freed=sz, dry_run=dry_run, detail="~/.opensrc/repos",
560
+ )
561
+
562
+
563
+ def deep_git_gc(home: Path, *, dry_run: bool = False) -> TierResult:
564
+ """`git gc` on the engine + the 5 biggest project repos. Non-destructive."""
565
+ candidates: list[tuple[int, Path]] = []
566
+ coding = home / "Agentik_Coding" / "projects"
567
+ roots = [home]
568
+ if coding.is_dir():
569
+ roots.extend(p for p in coding.iterdir() if p.is_dir())
570
+ for r in roots:
571
+ git = r / ".git"
572
+ if git.is_dir():
573
+ candidates.append((_dir_size(git), r))
574
+ candidates.sort(key=lambda t: -t[0])
575
+ items = 0
576
+ freed = 0
577
+ for _size, root in candidates[:5]:
578
+ if dry_run:
579
+ items += 1
580
+ continue
581
+ try:
582
+ before = _dir_size(root / ".git")
583
+ subprocess.run(
584
+ ["git", "-C", str(root), "gc", "--auto", "--quiet"],
585
+ check=False, capture_output=True, timeout=120,
586
+ )
587
+ after = _dir_size(root / ".git")
588
+ items += 1
589
+ freed += max(0, before - after)
590
+ except (OSError, subprocess.SubprocessError):
591
+ continue
592
+ return TierResult(
593
+ tier="D git gc", items_removed=items, bytes_freed=freed,
594
+ dry_run=dry_run, detail="non-destructive repack",
595
+ )
596
+
597
+
598
+ # ---------------------------------------------------------------------------
599
+ # Top-level — `omega cleanup` entry point
600
+ # ---------------------------------------------------------------------------
601
+
602
+
603
+ def cleanup(
604
+ home: str | Path | None = None,
605
+ *,
606
+ dry_run: bool = True,
607
+ deep: bool = False,
608
+ target_pct: int | None = None,
609
+ idle_days: int = 7,
610
+ runtime_days: int = 30,
611
+ tmux_hours: int = 24,
612
+ ) -> list[TierResult]:
613
+ """Run the full OmegaOS cleanup pipeline. Returns one report per tier.
614
+
615
+ Parameters
616
+ ----------
617
+ home $OMEGA_HOME (defaults to env var, then ~/Omega)
618
+ dry_run when True (default), no file is touched
619
+ deep run the optional deep tiers (staging, transcripts, VACUUM,
620
+ opensrc, git gc)
621
+ target_pct stop early once `df` reports the FS for `home` is
622
+ under `target_pct` percent full
623
+ idle_days node_modules pruning threshold (tier 5)
624
+ runtime_days runtime DB / sessions retention (tier 3)
625
+ tmux_hours stale-worker tmux age (tier 4)
626
+ """
627
+ h = _omega_home(home)
628
+ out: list[TierResult] = []
629
+
630
+ def _maybe_stop() -> bool:
631
+ if target_pct is None or dry_run:
632
+ return False
633
+ return _disk_usage_pct(h) <= target_pct
634
+
635
+ out.append(tier1_caches(dry_run=dry_run))
636
+ if _maybe_stop():
637
+ return out
638
+ out.append(tier2_scratch(h, dry_run=dry_run))
639
+ if _maybe_stop():
640
+ return out
641
+ out.append(tier3_runtime(h, older_than_days=runtime_days, dry_run=dry_run))
642
+ if _maybe_stop():
643
+ return out
644
+ out.append(tier4_tmux(h, older_than_hours=tmux_hours, dry_run=dry_run))
645
+ if _maybe_stop():
646
+ return out
647
+ out.append(tier5_node_modules(h, idle_days=idle_days, dry_run=dry_run))
648
+ if _maybe_stop():
649
+ return out
650
+ out.append(tier6_logs(h, dry_run=dry_run))
651
+ if not deep or _maybe_stop():
652
+ return out
653
+
654
+ # Deep tiers — only on --deep
655
+ out.append(deep_staging(h, dry_run=dry_run))
656
+ out.append(deep_transcripts(h, dry_run=dry_run))
657
+ out.append(deep_vacuum(h, dry_run=dry_run))
658
+ out.append(deep_opensrc(dry_run=dry_run))
659
+ out.append(deep_git_gc(h, dry_run=dry_run))
660
+ return out
661
+
662
+
663
+ def format_summary(reports: list[TierResult], home: Path) -> str:
664
+ """Pretty-print the report list — one line per tier + a final total."""
665
+ lines = ["=== OmegaOS cleanup ==="]
666
+ lines.append(f"home: {home}")
667
+ total = 0
668
+ for r in reports:
669
+ lines.append(" " + r.line)
670
+ total += r.bytes_freed
671
+ flag = " [dry-run]" if reports and reports[0].dry_run else ""
672
+ lines.append(f"-- total freed: {_human(total)}{flag}")
673
+ return "\n".join(lines)