@agentikos/omega-os 0.2.0 → 0.19.6

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 (376) hide show
  1. package/README.md +33 -3
  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 +790 -21
  10. package/bootstrap/manifest.example.yaml +87 -1
  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/GAP-ANALYSIS.md +214 -0
  48. package/docs/INSTALL.md +47 -9
  49. package/docs/MCP-AND-PLUGINS.md +31 -4
  50. package/docs/SIMULATION.md +171 -0
  51. package/docs/simulate.sh +211 -0
  52. package/install.sh +164 -17
  53. package/omega/Agentik_Engine/README.md +4 -2
  54. package/omega/Agentik_Engine/omega_engine/__init__.py +147 -1
  55. package/omega/Agentik_Engine/omega_engine/__pycache__/__init__.cpython-313.pyc +0 -0
  56. package/omega/Agentik_Engine/omega_engine/__pycache__/account.cpython-313.pyc +0 -0
  57. package/omega/Agentik_Engine/omega_engine/__pycache__/agent_messages.cpython-313.pyc +0 -0
  58. package/omega/Agentik_Engine/omega_engine/__pycache__/aisb_chat.cpython-313.pyc +0 -0
  59. package/omega/Agentik_Engine/omega_engine/__pycache__/audit.cpython-313.pyc +0 -0
  60. package/omega/Agentik_Engine/omega_engine/__pycache__/audit_arsenal.cpython-313.pyc +0 -0
  61. package/omega/Agentik_Engine/omega_engine/__pycache__/audit_diff.cpython-313.pyc +0 -0
  62. package/omega/Agentik_Engine/omega_engine/__pycache__/audit_gate.cpython-313.pyc +0 -0
  63. package/omega/Agentik_Engine/omega_engine/__pycache__/auto_update.cpython-313.pyc +0 -0
  64. package/omega/Agentik_Engine/omega_engine/__pycache__/autonomous.cpython-313.pyc +0 -0
  65. package/omega/Agentik_Engine/omega_engine/__pycache__/backup.cpython-313.pyc +0 -0
  66. package/omega/Agentik_Engine/omega_engine/__pycache__/barrier.cpython-313.pyc +0 -0
  67. package/omega/Agentik_Engine/omega_engine/__pycache__/bus.cpython-313.pyc +0 -0
  68. package/omega/Agentik_Engine/omega_engine/__pycache__/cadence.cpython-313.pyc +0 -0
  69. package/omega/Agentik_Engine/omega_engine/__pycache__/classifier.cpython-313.pyc +0 -0
  70. package/omega/Agentik_Engine/omega_engine/__pycache__/cleanup.cpython-313.pyc +0 -0
  71. package/omega/Agentik_Engine/omega_engine/__pycache__/cli.cpython-313.pyc +0 -0
  72. package/omega/Agentik_Engine/omega_engine/__pycache__/completions.cpython-313.pyc +0 -0
  73. package/omega/Agentik_Engine/omega_engine/__pycache__/costs.cpython-313.pyc +0 -0
  74. package/omega/Agentik_Engine/omega_engine/__pycache__/done_signal.cpython-313.pyc +0 -0
  75. package/omega/Agentik_Engine/omega_engine/__pycache__/envelope.cpython-313.pyc +0 -0
  76. package/omega/Agentik_Engine/omega_engine/__pycache__/events.cpython-313.pyc +0 -0
  77. package/omega/Agentik_Engine/omega_engine/__pycache__/executor.cpython-313.pyc +0 -0
  78. package/omega/Agentik_Engine/omega_engine/__pycache__/handoff.cpython-313.pyc +0 -0
  79. package/omega/Agentik_Engine/omega_engine/__pycache__/hermes.cpython-313.pyc +0 -0
  80. package/omega/Agentik_Engine/omega_engine/__pycache__/hermes_bootstrap.cpython-313.pyc +0 -0
  81. package/omega/Agentik_Engine/omega_engine/__pycache__/hermes_desktop.cpython-313.pyc +0 -0
  82. package/omega/Agentik_Engine/omega_engine/__pycache__/learning.cpython-313.pyc +0 -0
  83. package/omega/Agentik_Engine/omega_engine/__pycache__/managed_agent.cpython-313.pyc +0 -0
  84. package/omega/Agentik_Engine/omega_engine/__pycache__/memory.cpython-313.pyc +0 -0
  85. package/omega/Agentik_Engine/omega_engine/__pycache__/menu.cpython-313.pyc +0 -0
  86. package/omega/Agentik_Engine/omega_engine/__pycache__/mission.cpython-313.pyc +0 -0
  87. package/omega/Agentik_Engine/omega_engine/__pycache__/plan.cpython-313.pyc +0 -0
  88. package/omega/Agentik_Engine/omega_engine/__pycache__/progress.cpython-313.pyc +0 -0
  89. package/omega/Agentik_Engine/omega_engine/__pycache__/project.cpython-313.pyc +0 -0
  90. package/omega/Agentik_Engine/omega_engine/__pycache__/prompts.cpython-313.pyc +0 -0
  91. package/omega/Agentik_Engine/omega_engine/__pycache__/provider.cpython-313.pyc +0 -0
  92. package/omega/Agentik_Engine/omega_engine/__pycache__/prune.cpython-313.pyc +0 -0
  93. package/omega/Agentik_Engine/omega_engine/__pycache__/pursue.cpython-313.pyc +0 -0
  94. package/omega/Agentik_Engine/omega_engine/__pycache__/reducer.cpython-313.pyc +0 -0
  95. package/omega/Agentik_Engine/omega_engine/__pycache__/report.cpython-313.pyc +0 -0
  96. package/omega/Agentik_Engine/omega_engine/__pycache__/router.cpython-313.pyc +0 -0
  97. package/omega/Agentik_Engine/omega_engine/__pycache__/skill_routing.cpython-313.pyc +0 -0
  98. package/omega/Agentik_Engine/omega_engine/__pycache__/smoke.cpython-313.pyc +0 -0
  99. package/omega/Agentik_Engine/omega_engine/__pycache__/store.cpython-313.pyc +0 -0
  100. package/omega/Agentik_Engine/omega_engine/__pycache__/supervisor.cpython-313.pyc +0 -0
  101. package/omega/Agentik_Engine/omega_engine/__pycache__/sync.cpython-313.pyc +0 -0
  102. package/omega/Agentik_Engine/omega_engine/__pycache__/task.cpython-313.pyc +0 -0
  103. package/omega/Agentik_Engine/omega_engine/__pycache__/telegram.cpython-313.pyc +0 -0
  104. package/omega/Agentik_Engine/omega_engine/__pycache__/telegram_history.cpython-313.pyc +0 -0
  105. package/omega/Agentik_Engine/omega_engine/__pycache__/tmux.cpython-313.pyc +0 -0
  106. package/omega/Agentik_Engine/omega_engine/__pycache__/tools.cpython-313.pyc +0 -0
  107. package/omega/Agentik_Engine/omega_engine/__pycache__/understand_anything.cpython-313.pyc +0 -0
  108. package/omega/Agentik_Engine/omega_engine/__pycache__/updater.cpython-313.pyc +0 -0
  109. package/omega/Agentik_Engine/omega_engine/__pycache__/validate.cpython-313.pyc +0 -0
  110. package/omega/Agentik_Engine/omega_engine/__pycache__/vault.cpython-313.pyc +0 -0
  111. package/omega/Agentik_Engine/omega_engine/__pycache__/webhooks.cpython-313.pyc +0 -0
  112. package/omega/Agentik_Engine/omega_engine/__pycache__/worker.cpython-313.pyc +0 -0
  113. package/omega/Agentik_Engine/omega_engine/account.py +28 -31
  114. package/omega/Agentik_Engine/omega_engine/agent_messages.py +167 -0
  115. package/omega/Agentik_Engine/omega_engine/aisb_chat.py +128 -0
  116. package/omega/Agentik_Engine/omega_engine/audit_diff.py +99 -0
  117. package/omega/Agentik_Engine/omega_engine/audit_gate.py +149 -0
  118. package/omega/Agentik_Engine/omega_engine/audits/__init__.py +60 -0
  119. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/__init__.cpython-313.pyc +0 -0
  120. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/batcher.cpython-313.pyc +0 -0
  121. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/dispatcher.cpython-313.pyc +0 -0
  122. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/generator.cpython-313.pyc +0 -0
  123. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/history.cpython-313.pyc +0 -0
  124. package/omega/Agentik_Engine/omega_engine/audits/__pycache__/pipeline.cpython-313.pyc +0 -0
  125. package/omega/Agentik_Engine/omega_engine/audits/batcher.py +218 -0
  126. package/omega/Agentik_Engine/omega_engine/audits/dispatcher.py +92 -0
  127. package/omega/Agentik_Engine/omega_engine/audits/generator.py +234 -0
  128. package/omega/Agentik_Engine/omega_engine/audits/history.py +168 -0
  129. package/omega/Agentik_Engine/omega_engine/audits/pipeline.py +198 -0
  130. package/omega/Agentik_Engine/omega_engine/auto_update.py +339 -0
  131. package/omega/Agentik_Engine/omega_engine/backup.py +215 -0
  132. package/omega/Agentik_Engine/omega_engine/cadence.py +158 -0
  133. package/omega/Agentik_Engine/omega_engine/classifier.py +215 -0
  134. package/omega/Agentik_Engine/omega_engine/cleanup.py +673 -0
  135. package/omega/Agentik_Engine/omega_engine/cli.py +4156 -86
  136. package/omega/Agentik_Engine/omega_engine/completions.py +260 -0
  137. package/omega/Agentik_Engine/omega_engine/costs.py +100 -0
  138. package/omega/Agentik_Engine/omega_engine/daemons/__pycache__/__init__.cpython-313.pyc +0 -0
  139. package/omega/Agentik_Engine/omega_engine/daemons/__pycache__/autonomous.cpython-313.pyc +0 -0
  140. package/omega/Agentik_Engine/omega_engine/daemons/__pycache__/engine.cpython-313.pyc +0 -0
  141. package/omega/Agentik_Engine/omega_engine/daemons/__pycache__/telegram.cpython-313.pyc +0 -0
  142. package/omega/Agentik_Engine/omega_engine/daemons/engine.py +53 -4
  143. package/omega/Agentik_Engine/omega_engine/daemons/telegram.py +101 -17
  144. package/omega/Agentik_Engine/omega_engine/done_signal.py +154 -0
  145. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/__init__.cpython-313.pyc +0 -0
  146. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/artifact.cpython-313.pyc +0 -0
  147. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/automation.cpython-313.pyc +0 -0
  148. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/base.cpython-313.pyc +0 -0
  149. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/claudecode.cpython-313.pyc +0 -0
  150. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/connection.cpython-313.pyc +0 -0
  151. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/coworker.cpython-313.pyc +0 -0
  152. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/loop.cpython-313.pyc +0 -0
  153. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/prompt.cpython-313.pyc +0 -0
  154. package/omega/Agentik_Engine/omega_engine/educators/__pycache__/skill.cpython-313.pyc +0 -0
  155. package/omega/Agentik_Engine/omega_engine/envelope.py +219 -0
  156. package/omega/Agentik_Engine/omega_engine/executor.py +149 -10
  157. package/omega/Agentik_Engine/omega_engine/genesis/__init__.py +134 -0
  158. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/__init__.cpython-313.pyc +0 -0
  159. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/orchestrator.cpython-313.pyc +0 -0
  160. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/phases.cpython-313.pyc +0 -0
  161. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/stack.cpython-313.pyc +0 -0
  162. package/omega/Agentik_Engine/omega_engine/genesis/__pycache__/state.cpython-313.pyc +0 -0
  163. package/omega/Agentik_Engine/omega_engine/genesis/orchestrator.py +262 -0
  164. package/omega/Agentik_Engine/omega_engine/genesis/phases.py +950 -0
  165. package/omega/Agentik_Engine/omega_engine/genesis/stack.py +324 -0
  166. package/omega/Agentik_Engine/omega_engine/genesis/state.py +353 -0
  167. package/omega/Agentik_Engine/omega_engine/handoff.py +459 -0
  168. package/omega/Agentik_Engine/omega_engine/hermes.py +426 -0
  169. package/omega/Agentik_Engine/omega_engine/hermes_bootstrap.py +382 -0
  170. package/omega/Agentik_Engine/omega_engine/hermes_desktop.py +469 -0
  171. package/omega/Agentik_Engine/omega_engine/integrations/__init__.py +30 -0
  172. package/omega/Agentik_Engine/omega_engine/integrations/__pycache__/__init__.cpython-313.pyc +0 -0
  173. package/omega/Agentik_Engine/omega_engine/integrations/__pycache__/graphify.cpython-313.pyc +0 -0
  174. package/omega/Agentik_Engine/omega_engine/integrations/graphify.py +234 -0
  175. package/omega/Agentik_Engine/omega_engine/learning.py +268 -0
  176. package/omega/Agentik_Engine/omega_engine/managed_agent.py +467 -0
  177. package/omega/Agentik_Engine/omega_engine/memory.py +271 -0
  178. package/omega/Agentik_Engine/omega_engine/menu.py +1065 -0
  179. package/omega/Agentik_Engine/omega_engine/migrations/__init__.py +144 -0
  180. package/omega/Agentik_Engine/omega_engine/migrations/__pycache__/__init__.cpython-313.pyc +0 -0
  181. package/omega/Agentik_Engine/omega_engine/migrations/__pycache__/v0_14_0.cpython-313.pyc +0 -0
  182. package/omega/Agentik_Engine/omega_engine/migrations/v0_14_0.py +29 -0
  183. package/omega/Agentik_Engine/omega_engine/mission.py +16 -13
  184. package/omega/Agentik_Engine/omega_engine/plan.py +846 -0
  185. package/omega/Agentik_Engine/omega_engine/prompts.py +158 -0
  186. package/omega/Agentik_Engine/omega_engine/provider.py +161 -12
  187. package/omega/Agentik_Engine/omega_engine/prune.py +151 -0
  188. package/omega/Agentik_Engine/omega_engine/pursue.py +205 -0
  189. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/__init__.cpython-313.pyc +0 -0
  190. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/agentic.cpython-313.pyc +0 -0
  191. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/base.cpython-313.pyc +0 -0
  192. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/corrective.cpython-313.pyc +0 -0
  193. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/graph.cpython-313.pyc +0 -0
  194. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/hybrid.cpython-313.pyc +0 -0
  195. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/multimodal.cpython-313.pyc +0 -0
  196. package/omega/Agentik_Engine/omega_engine/rag/__pycache__/router.cpython-313.pyc +0 -0
  197. package/omega/Agentik_Engine/omega_engine/router.py +28 -0
  198. package/omega/Agentik_Engine/omega_engine/skill_discovery/__init__.py +48 -0
  199. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/__init__.cpython-313.pyc +0 -0
  200. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/auditor.cpython-313.pyc +0 -0
  201. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/finder.cpython-313.pyc +0 -0
  202. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/installer.cpython-313.pyc +0 -0
  203. package/omega/Agentik_Engine/omega_engine/skill_discovery/__pycache__/marketplaces.cpython-313.pyc +0 -0
  204. package/omega/Agentik_Engine/omega_engine/skill_discovery/auditor.py +232 -0
  205. package/omega/Agentik_Engine/omega_engine/skill_discovery/finder.py +94 -0
  206. package/omega/Agentik_Engine/omega_engine/skill_discovery/installer.py +129 -0
  207. package/omega/Agentik_Engine/omega_engine/skill_discovery/marketplaces.py +80 -0
  208. package/omega/Agentik_Engine/omega_engine/skill_routing.py +388 -0
  209. package/omega/Agentik_Engine/omega_engine/smoke.py +81 -0
  210. package/omega/Agentik_Engine/omega_engine/store.py +88 -41
  211. package/omega/Agentik_Engine/omega_engine/sync.py +142 -1
  212. package/omega/Agentik_Engine/omega_engine/telegram_history.py +260 -0
  213. package/omega/Agentik_Engine/omega_engine/tmux.py +526 -0
  214. package/omega/Agentik_Engine/omega_engine/understand_anything.py +275 -0
  215. package/omega/Agentik_Engine/omega_engine/updater.py +70 -0
  216. package/omega/Agentik_Engine/omega_engine/validate.py +186 -0
  217. package/omega/Agentik_Engine/omega_engine/vault.py +342 -0
  218. package/omega/Agentik_Engine/omega_engine/webhooks.py +262 -0
  219. package/omega/Agentik_Engine/omega_engine/worker.py +526 -0
  220. package/omega/Agentik_Engine/pyproject.toml +1 -1
  221. package/omega/Agentik_Engine/tests/__pycache__/test_account.cpython-313-pytest-8.4.2.pyc +0 -0
  222. package/omega/Agentik_Engine/tests/__pycache__/test_account.cpython-313.pyc +0 -0
  223. package/omega/Agentik_Engine/tests/__pycache__/test_adversarial.cpython-313-pytest-8.4.2.pyc +0 -0
  224. package/omega/Agentik_Engine/tests/__pycache__/test_adversarial.cpython-313.pyc +0 -0
  225. package/omega/Agentik_Engine/tests/__pycache__/test_agents_envelope.cpython-313-pytest-8.4.2.pyc +0 -0
  226. package/omega/Agentik_Engine/tests/__pycache__/test_agents_envelope.cpython-313.pyc +0 -0
  227. package/omega/Agentik_Engine/tests/__pycache__/test_audit_arsenal.cpython-313-pytest-8.4.2.pyc +0 -0
  228. package/omega/Agentik_Engine/tests/__pycache__/test_audit_arsenal.cpython-313.pyc +0 -0
  229. package/omega/Agentik_Engine/tests/__pycache__/test_audits_pipeline.cpython-313-pytest-8.4.2.pyc +0 -0
  230. package/omega/Agentik_Engine/tests/__pycache__/test_audits_pipeline.cpython-313.pyc +0 -0
  231. package/omega/Agentik_Engine/tests/__pycache__/test_auto_update_and_migrations.cpython-313-pytest-8.4.2.pyc +0 -0
  232. package/omega/Agentik_Engine/tests/__pycache__/test_auto_update_and_migrations.cpython-313.pyc +0 -0
  233. package/omega/Agentik_Engine/tests/__pycache__/test_autonomous.cpython-313-pytest-8.4.2.pyc +0 -0
  234. package/omega/Agentik_Engine/tests/__pycache__/test_autonomous.cpython-313.pyc +0 -0
  235. package/omega/Agentik_Engine/tests/__pycache__/test_educators.cpython-313-pytest-8.4.2.pyc +0 -0
  236. package/omega/Agentik_Engine/tests/__pycache__/test_educators.cpython-313.pyc +0 -0
  237. package/omega/Agentik_Engine/tests/__pycache__/test_executor.cpython-313-pytest-8.4.2.pyc +0 -0
  238. package/omega/Agentik_Engine/tests/__pycache__/test_executor.cpython-313.pyc +0 -0
  239. package/omega/Agentik_Engine/tests/__pycache__/test_genesis_and_plan.cpython-313-pytest-8.4.2.pyc +0 -0
  240. package/omega/Agentik_Engine/tests/__pycache__/test_genesis_and_plan.cpython-313.pyc +0 -0
  241. package/omega/Agentik_Engine/tests/__pycache__/test_graphify.cpython-313-pytest-8.4.2.pyc +0 -0
  242. package/omega/Agentik_Engine/tests/__pycache__/test_graphify.cpython-313.pyc +0 -0
  243. package/omega/Agentik_Engine/tests/__pycache__/test_handoff.cpython-313-pytest-8.4.2.pyc +0 -0
  244. package/omega/Agentik_Engine/tests/__pycache__/test_handoff.cpython-313.pyc +0 -0
  245. package/omega/Agentik_Engine/tests/__pycache__/test_hermes_and_ua.cpython-313-pytest-8.4.2.pyc +0 -0
  246. package/omega/Agentik_Engine/tests/__pycache__/test_hermes_and_ua.cpython-313.pyc +0 -0
  247. package/omega/Agentik_Engine/tests/__pycache__/test_hermes_bootstrap_and_desktop.cpython-313-pytest-8.4.2.pyc +0 -0
  248. package/omega/Agentik_Engine/tests/__pycache__/test_hermes_bootstrap_and_desktop.cpython-313.pyc +0 -0
  249. package/omega/Agentik_Engine/tests/__pycache__/test_install_steps.cpython-313-pytest-8.4.2.pyc +0 -0
  250. package/omega/Agentik_Engine/tests/__pycache__/test_install_steps.cpython-313.pyc +0 -0
  251. package/omega/Agentik_Engine/tests/__pycache__/test_install_ux.cpython-313-pytest-8.4.2.pyc +0 -0
  252. package/omega/Agentik_Engine/tests/__pycache__/test_install_ux.cpython-313.pyc +0 -0
  253. package/omega/Agentik_Engine/tests/__pycache__/test_installer_wiring.cpython-313-pytest-8.4.2.pyc +0 -0
  254. package/omega/Agentik_Engine/tests/__pycache__/test_installer_wiring.cpython-313.pyc +0 -0
  255. package/omega/Agentik_Engine/tests/__pycache__/test_intelligence.cpython-313-pytest-8.4.2.pyc +0 -0
  256. package/omega/Agentik_Engine/tests/__pycache__/test_intelligence.cpython-313.pyc +0 -0
  257. package/omega/Agentik_Engine/tests/__pycache__/test_llm_clis_and_uninstall.cpython-313-pytest-8.4.2.pyc +0 -0
  258. package/omega/Agentik_Engine/tests/__pycache__/test_llm_clis_and_uninstall.cpython-313.pyc +0 -0
  259. package/omega/Agentik_Engine/tests/__pycache__/test_managed_agent.cpython-313-pytest-8.4.2.pyc +0 -0
  260. package/omega/Agentik_Engine/tests/__pycache__/test_managed_agent.cpython-313.pyc +0 -0
  261. package/omega/Agentik_Engine/tests/__pycache__/test_max_provider_and_menu.cpython-313-pytest-8.4.2.pyc +0 -0
  262. package/omega/Agentik_Engine/tests/__pycache__/test_max_provider_and_menu.cpython-313.pyc +0 -0
  263. package/omega/Agentik_Engine/tests/__pycache__/test_menu_coverage.cpython-313-pytest-8.4.2.pyc +0 -0
  264. package/omega/Agentik_Engine/tests/__pycache__/test_menu_coverage.cpython-313.pyc +0 -0
  265. package/omega/Agentik_Engine/tests/__pycache__/test_mission.cpython-313-pytest-8.4.2.pyc +0 -0
  266. package/omega/Agentik_Engine/tests/__pycache__/test_mission.cpython-313.pyc +0 -0
  267. package/omega/Agentik_Engine/tests/__pycache__/test_progress.cpython-313-pytest-8.4.2.pyc +0 -0
  268. package/omega/Agentik_Engine/tests/__pycache__/test_progress.cpython-313.pyc +0 -0
  269. package/omega/Agentik_Engine/tests/__pycache__/test_project.cpython-313-pytest-8.4.2.pyc +0 -0
  270. package/omega/Agentik_Engine/tests/__pycache__/test_project.cpython-313.pyc +0 -0
  271. package/omega/Agentik_Engine/tests/__pycache__/test_pursue_cadence.cpython-313-pytest-8.4.2.pyc +0 -0
  272. package/omega/Agentik_Engine/tests/__pycache__/test_pursue_cadence.cpython-313.pyc +0 -0
  273. package/omega/Agentik_Engine/tests/__pycache__/test_rag.cpython-313-pytest-8.4.2.pyc +0 -0
  274. package/omega/Agentik_Engine/tests/__pycache__/test_rag.cpython-313.pyc +0 -0
  275. package/omega/Agentik_Engine/tests/__pycache__/test_reducer.cpython-313-pytest-8.4.2.pyc +0 -0
  276. package/omega/Agentik_Engine/tests/__pycache__/test_reducer.cpython-313.pyc +0 -0
  277. package/omega/Agentik_Engine/tests/__pycache__/test_report.cpython-313-pytest-8.4.2.pyc +0 -0
  278. package/omega/Agentik_Engine/tests/__pycache__/test_report.cpython-313.pyc +0 -0
  279. package/omega/Agentik_Engine/tests/__pycache__/test_role_aliases_and_ssot.cpython-313-pytest-8.4.2.pyc +0 -0
  280. package/omega/Agentik_Engine/tests/__pycache__/test_role_aliases_and_ssot.cpython-313.pyc +0 -0
  281. package/omega/Agentik_Engine/tests/__pycache__/test_skill_discovery_and_gate.cpython-313-pytest-8.4.2.pyc +0 -0
  282. package/omega/Agentik_Engine/tests/__pycache__/test_skill_discovery_and_gate.cpython-313.pyc +0 -0
  283. package/omega/Agentik_Engine/tests/__pycache__/test_skill_power.cpython-313-pytest-8.4.2.pyc +0 -0
  284. package/omega/Agentik_Engine/tests/__pycache__/test_skill_power.cpython-313.pyc +0 -0
  285. package/omega/Agentik_Engine/tests/__pycache__/test_skill_routing.cpython-313-pytest-8.4.2.pyc +0 -0
  286. package/omega/Agentik_Engine/tests/__pycache__/test_skill_routing.cpython-313.pyc +0 -0
  287. package/omega/Agentik_Engine/tests/__pycache__/test_snapshot_partial.cpython-313-pytest-8.4.2.pyc +0 -0
  288. package/omega/Agentik_Engine/tests/__pycache__/test_snapshot_partial.cpython-313.pyc +0 -0
  289. package/omega/Agentik_Engine/tests/__pycache__/test_telegram_history.cpython-313-pytest-8.4.2.pyc +0 -0
  290. package/omega/Agentik_Engine/tests/__pycache__/test_telegram_history.cpython-313.pyc +0 -0
  291. package/omega/Agentik_Engine/tests/__pycache__/test_tmux_and_aisb_chat.cpython-313-pytest-8.4.2.pyc +0 -0
  292. package/omega/Agentik_Engine/tests/__pycache__/test_tmux_and_aisb_chat.cpython-313.pyc +0 -0
  293. package/omega/Agentik_Engine/tests/__pycache__/test_tools_and_sync.cpython-313-pytest-8.4.2.pyc +0 -0
  294. package/omega/Agentik_Engine/tests/__pycache__/test_tools_and_sync.cpython-313.pyc +0 -0
  295. package/omega/Agentik_Engine/tests/__pycache__/test_v06_features.cpython-313-pytest-8.4.2.pyc +0 -0
  296. package/omega/Agentik_Engine/tests/__pycache__/test_v06_features.cpython-313.pyc +0 -0
  297. package/omega/Agentik_Engine/tests/__pycache__/test_vault.cpython-313-pytest-8.4.2.pyc +0 -0
  298. package/omega/Agentik_Engine/tests/__pycache__/test_vault.cpython-313.pyc +0 -0
  299. package/omega/Agentik_Engine/tests/__pycache__/test_webhooks_and_readiness.cpython-313-pytest-8.4.2.pyc +0 -0
  300. package/omega/Agentik_Engine/tests/__pycache__/test_webhooks_and_readiness.cpython-313.pyc +0 -0
  301. package/omega/Agentik_Engine/tests/__pycache__/test_worker_and_cleanup.cpython-313-pytest-8.4.2.pyc +0 -0
  302. package/omega/Agentik_Engine/tests/__pycache__/test_worker_and_cleanup.cpython-313.pyc +0 -0
  303. package/omega/Agentik_Engine/tests/test_account.py +8 -3
  304. package/omega/Agentik_Engine/tests/test_adversarial.py +351 -0
  305. package/omega/Agentik_Engine/tests/test_agents_envelope.py +274 -0
  306. package/omega/Agentik_Engine/tests/test_audits_pipeline.py +348 -0
  307. package/omega/Agentik_Engine/tests/test_auto_update_and_migrations.py +394 -0
  308. package/omega/Agentik_Engine/tests/test_genesis_and_plan.py +573 -0
  309. package/omega/Agentik_Engine/tests/test_graphify.py +190 -0
  310. package/omega/Agentik_Engine/tests/test_handoff.py +311 -0
  311. package/omega/Agentik_Engine/tests/test_hermes_and_ua.py +387 -0
  312. package/omega/Agentik_Engine/tests/test_hermes_bootstrap_and_desktop.py +358 -0
  313. package/omega/Agentik_Engine/tests/test_install_steps.py +359 -0
  314. package/omega/Agentik_Engine/tests/test_install_ux.py +151 -0
  315. package/omega/Agentik_Engine/tests/test_installer_wiring.py +496 -0
  316. package/omega/Agentik_Engine/tests/test_intelligence.py +285 -0
  317. package/omega/Agentik_Engine/tests/test_llm_clis_and_uninstall.py +228 -0
  318. package/omega/Agentik_Engine/tests/test_managed_agent.py +363 -0
  319. package/omega/Agentik_Engine/tests/test_max_provider_and_menu.py +231 -0
  320. package/omega/Agentik_Engine/tests/test_menu_coverage.py +72 -0
  321. package/omega/Agentik_Engine/tests/test_pursue_cadence.py +217 -0
  322. package/omega/Agentik_Engine/tests/test_role_aliases_and_ssot.py +207 -0
  323. package/omega/Agentik_Engine/tests/test_skill_discovery_and_gate.py +337 -0
  324. package/omega/Agentik_Engine/tests/test_skill_power.py +259 -0
  325. package/omega/Agentik_Engine/tests/test_skill_routing.py +189 -0
  326. package/omega/Agentik_Engine/tests/test_telegram_history.py +209 -0
  327. package/omega/Agentik_Engine/tests/test_tmux_and_aisb_chat.py +223 -0
  328. package/omega/Agentik_Engine/tests/test_v06_features.py +370 -0
  329. package/omega/Agentik_Engine/tests/test_vault.py +173 -0
  330. package/omega/Agentik_Engine/tests/test_webhooks_and_readiness.py +277 -0
  331. package/omega/Agentik_Engine/tests/test_worker_and_cleanup.py +541 -0
  332. package/omega/Agentik_Extra/etc/secrets/.vault-key +3 -0
  333. package/omega/Agentik_Extra/etc/secrets/.vault-pub +1 -0
  334. package/omega/Agentik_Runtime/audits.db +0 -0
  335. package/omega/Agentik_SSOT/VERSION +1 -1
  336. package/omega/Agentik_SSOT/claude-plugins/claude-plugins.yaml +100 -0
  337. package/omega/Agentik_SSOT/docs/LAYERS.md +90 -0
  338. package/omega/Agentik_SSOT/docs/USER-JOURNEY.md +283 -0
  339. package/omega/Agentik_SSOT/docs/quality-arsenal/ARSENAL-INTERCONNECTIONS.md +283 -0
  340. package/omega/Agentik_SSOT/docs/quality-arsenal/ARSENAL-ORCHESTRATION-PLAYBOOK.md +364 -0
  341. package/omega/Agentik_SSOT/docs/quality-arsenal/AUDIT-VERIFICATION-CONTRACT.md +272 -0
  342. package/omega/Agentik_SSOT/docs/quality-arsenal/QUALITY-ARSENAL-PREAMBLE.md +462 -0
  343. package/omega/Agentik_SSOT/marketplaces/design-discipline.yaml +86 -0
  344. package/omega/Agentik_SSOT/skills/a11yaudit/SKILL.md +161 -0
  345. package/omega/Agentik_SSOT/skills/apiaudit/SKILL.md +157 -0
  346. package/omega/Agentik_SSOT/skills/audit-orchestrator.md +212 -0
  347. package/omega/Agentik_SSOT/skills/audit-pilot.md +466 -0
  348. package/omega/Agentik_SSOT/skills/audit-tracker.md +147 -0
  349. package/omega/Agentik_SSOT/skills/automationaudit/SKILL.md +161 -0
  350. package/omega/Agentik_SSOT/skills/cadence/SKILL.md +76 -0
  351. package/omega/Agentik_SSOT/skills/codeaudit/SKILL.md +153 -0
  352. package/omega/Agentik_SSOT/skills/copyaudit/SKILL.md +161 -0
  353. package/omega/Agentik_SSOT/skills/dataaudit/SKILL.md +157 -0
  354. package/omega/Agentik_SSOT/skills/debugaudit/SKILL.md +161 -0
  355. package/omega/Agentik_SSOT/skills/dispatch/SKILL.md +79 -0
  356. package/omega/Agentik_SSOT/skills/dxaudit/SKILL.md +161 -0
  357. package/omega/Agentik_SSOT/skills/featureaudit/SKILL.md +161 -0
  358. package/omega/Agentik_SSOT/skills/flowaudit/SKILL.md +165 -0
  359. package/omega/Agentik_SSOT/skills/genesis/SKILL.md +116 -0
  360. package/omega/Agentik_SSOT/skills/handoff/SKILL.md +117 -0
  361. package/omega/Agentik_SSOT/skills/logicaudit/SKILL.md +165 -0
  362. package/omega/Agentik_SSOT/skills/motionaudit/SKILL.md +165 -0
  363. package/omega/Agentik_SSOT/skills/newcmd.md +300 -0
  364. package/omega/Agentik_SSOT/skills/perfaudit/SKILL.md +161 -0
  365. package/omega/Agentik_SSOT/skills/plan/SKILL.md +127 -0
  366. package/omega/Agentik_SSOT/skills/pursue/SKILL.md +68 -0
  367. package/omega/Agentik_SSOT/skills/quality-arsenal.md +180 -0
  368. package/omega/Agentik_SSOT/skills/rag-route.md +9 -0
  369. package/omega/Agentik_SSOT/skills/refontaudit/SKILL.md +165 -0
  370. package/omega/Agentik_SSOT/skills/retentionaudit/SKILL.md +165 -0
  371. package/omega/Agentik_SSOT/skills/secaudit/SKILL.md +157 -0
  372. package/omega/Agentik_SSOT/skills/seoaudit/SKILL.md +161 -0
  373. package/omega/Agentik_SSOT/skills/skill-auditor/SKILL.md +83 -0
  374. package/omega/Agentik_SSOT/skills/skill-finder/SKILL.md +116 -0
  375. package/omega/Agentik_SSOT/skills/uiuxaudit/SKILL.md +165 -0
  376. package/package.json +2 -2
@@ -0,0 +1,339 @@
1
+ """Auto-update layer.
2
+
3
+ What this module does
4
+ ---------------------
5
+
6
+ Three jobs, distinct on purpose so each is testable:
7
+
8
+ 1. **Cached check** — ``check_cached(home)`` returns the latest known
9
+ version from a small JSON file under ``Agentik_Extra/var/``. If the
10
+ cache is fresh (< check_interval_s), no network is hit. Default
11
+ interval: 24 h. Every CLI invocation can call this for ~0 ms.
12
+
13
+ 2. **Banner emission** — ``maybe_emit_banner(home)`` prints a one-line
14
+ stderr notice if a new version is known to be available. Silent
15
+ when up-to-date or when the cache is empty (first run). Opt-out via
16
+ ``OMEGA_NO_UPDATE_BANNER=1``.
17
+
18
+ 3. **Apply** — ``apply_update(home)`` performs the actual upgrade:
19
+
20
+ (a) ``omega doctor --json`` baseline
21
+ (b) ``omega backup create --encrypt`` snapshot
22
+ (c) ``npm install -g @agentikos/omega-os@latest``
23
+ (d) ``omega upgrade --non-interactive``
24
+ (e) run ``migrations`` from current → latest
25
+ (f) ``omega doctor --json`` + ``omega smoke``
26
+ (g) on failure: ``omega backup restore <bundle>``
27
+
28
+ Atomic-ish: every step is recorded to a journal, and any non-zero
29
+ exit before step (g) triggers rollback. The operator sees a clear
30
+ "✗ update aborted — restored from <bundle>" or "✓ updated to vX.Y.Z".
31
+
32
+ Why all this care
33
+ -----------------
34
+
35
+ Updates that break the daily workflow are worse than no updates. Claude
36
+ Code's pattern (silent banner + manual apply) is the right default. The
37
+ ``omega update auto`` cadence opts the operator into background apply,
38
+ but ALWAYS through this same backup + verify + rollback pipeline.
39
+ """
40
+ from __future__ import annotations
41
+
42
+ import json
43
+ import os
44
+ import shlex
45
+ import subprocess
46
+ import sys
47
+ import time
48
+ from dataclasses import asdict, dataclass, field
49
+ from pathlib import Path
50
+ from typing import Any
51
+
52
+
53
+ _DEFAULT_INTERVAL_S = 24 * 3600 # one day
54
+ _CACHE_FILE = "last-update-check.json"
55
+ _JOURNAL_FILE = "update-journal.jsonl"
56
+
57
+
58
+ # ---------------------------------------------------------------------------
59
+ # Cached check
60
+ # ---------------------------------------------------------------------------
61
+
62
+
63
+ @dataclass
64
+ class CachedCheck:
65
+ current: str
66
+ latest: str
67
+ is_outdated: bool
68
+ checked_at: float
69
+ error: str = ""
70
+
71
+ def to_json(self) -> str:
72
+ return json.dumps(asdict(self), indent=2)
73
+
74
+ @staticmethod
75
+ def from_json(text: str) -> "CachedCheck":
76
+ return CachedCheck(**json.loads(text))
77
+
78
+
79
+ def _cache_path(home: Path) -> Path:
80
+ return home / "Agentik_Extra" / "var" / _CACHE_FILE
81
+
82
+
83
+ def _journal_path(home: Path) -> Path:
84
+ return home / "Agentik_Extra" / "var" / _JOURNAL_FILE
85
+
86
+
87
+ def _journal(home: Path, event: dict[str, Any]) -> None:
88
+ """Append a JSONL line to the update journal. Best-effort."""
89
+ p = _journal_path(home)
90
+ p.parent.mkdir(parents=True, exist_ok=True)
91
+ line = json.dumps({"ts": time.time(), **event}) + "\n"
92
+ try:
93
+ with p.open("a") as fh:
94
+ fh.write(line)
95
+ except OSError:
96
+ pass
97
+
98
+
99
+ def check_cached(
100
+ home: str | Path,
101
+ *,
102
+ interval_s: int = _DEFAULT_INTERVAL_S,
103
+ force: bool = False,
104
+ ) -> CachedCheck:
105
+ """Return the latest cached check; refresh from npm if stale.
106
+
107
+ Side-effect: writes the refreshed cache. Network access only when the
108
+ cache is stale or ``force=True``. Network errors set ``error`` but
109
+ don't raise — auto-update must never break a CLI invocation.
110
+ """
111
+ home = Path(home)
112
+ p = _cache_path(home)
113
+ p.parent.mkdir(parents=True, exist_ok=True)
114
+
115
+ if p.exists() and not force:
116
+ try:
117
+ cached = CachedCheck.from_json(p.read_text())
118
+ if time.time() - cached.checked_at < interval_s:
119
+ return cached
120
+ except (OSError, ValueError, KeyError):
121
+ pass
122
+
123
+ # Refresh.
124
+ from omega_engine import __version__
125
+ from omega_engine.updater import check_for_updates
126
+ info = check_for_updates(__version__, timeout=8)
127
+ fresh = CachedCheck(
128
+ current=info.current,
129
+ latest=info.latest,
130
+ is_outdated=info.is_outdated,
131
+ checked_at=time.time(),
132
+ error=info.error,
133
+ )
134
+ try:
135
+ # Atomic write — same pattern as done_signal.
136
+ tmp = p.with_suffix(p.suffix + f".tmp.{os.getpid()}")
137
+ tmp.write_text(fresh.to_json())
138
+ os.replace(tmp, p)
139
+ except OSError:
140
+ pass
141
+ return fresh
142
+
143
+
144
+ def maybe_emit_banner(home: str | Path, *, stream=sys.stderr) -> bool:
145
+ """Print a one-line update banner when a new version is known.
146
+
147
+ Returns True iff a banner was emitted. Opt-out via
148
+ ``OMEGA_NO_UPDATE_BANNER=1``. Never raises.
149
+ """
150
+ if os.environ.get("OMEGA_NO_UPDATE_BANNER") == "1":
151
+ return False
152
+ try:
153
+ check = check_cached(home)
154
+ except Exception: # noqa: BLE001
155
+ return False
156
+ if not check.is_outdated or check.error:
157
+ return False
158
+ msg = (
159
+ f"[omega] update available: {check.current} → {check.latest} "
160
+ f"run `omega update apply` to install"
161
+ )
162
+ try:
163
+ print(msg, file=stream)
164
+ except (OSError, ValueError):
165
+ return False
166
+ return True
167
+
168
+
169
+ # ---------------------------------------------------------------------------
170
+ # Apply
171
+ # ---------------------------------------------------------------------------
172
+
173
+
174
+ @dataclass
175
+ class ApplyResult:
176
+ ok: bool
177
+ from_version: str
178
+ to_version: str
179
+ bundle: str = "" # path to the pre-update backup
180
+ rolled_back: bool = False
181
+ duration_s: float = 0.0
182
+ steps: list[dict[str, Any]] = field(default_factory=list)
183
+ error: str = ""
184
+
185
+
186
+ def _which(bin_: str) -> str | None:
187
+ import shutil as _sh
188
+ return _sh.which(bin_)
189
+
190
+
191
+ def _run_step(
192
+ home: Path, label: str, cmd: list[str], *, timeout: int = 600,
193
+ ) -> tuple[int, str]:
194
+ """Run a step, journal it, return (returncode, tail-of-output)."""
195
+ started = time.time()
196
+ try:
197
+ proc = subprocess.run(
198
+ cmd, check=False, capture_output=True, text=True, timeout=timeout,
199
+ )
200
+ rc = proc.returncode
201
+ tail = (proc.stdout + "\n" + proc.stderr).strip()[-500:]
202
+ except subprocess.TimeoutExpired:
203
+ rc = 124
204
+ tail = f"timeout after {timeout}s"
205
+ except OSError as exc:
206
+ rc = 127
207
+ tail = f"exec error: {exc}"
208
+ _journal(home, {
209
+ "step": label, "rc": rc, "duration_s": round(time.time() - started, 2),
210
+ "tail": tail[:400],
211
+ })
212
+ return rc, tail
213
+
214
+
215
+ def apply_update(
216
+ home: str | Path,
217
+ *,
218
+ skip_backup: bool = False,
219
+ skip_verify: bool = False,
220
+ npm_global: bool = True,
221
+ ) -> ApplyResult:
222
+ """Apply the available update with full backup + migrate + verify + rollback.
223
+
224
+ Strict sequence:
225
+
226
+ 1. baseline doctor JSON
227
+ 2. backup create (skippable for tests)
228
+ 3. npm install -g @agentikos/omega-os@latest (or skipped when not on PATH)
229
+ 4. run migrations from <current> → <latest>
230
+ 5. omega upgrade --non-interactive (re-run install steps)
231
+ 6. doctor + smoke (skippable for tests)
232
+
233
+ Any failure between 2 and 6 triggers ``backup restore`` from the bundle.
234
+ """
235
+ home = Path(home)
236
+ start = time.time()
237
+ from omega_engine import __version__
238
+ info = check_cached(home, force=True)
239
+ if info.error:
240
+ return ApplyResult(
241
+ ok=False, from_version=__version__, to_version="?",
242
+ error=f"check failed: {info.error}",
243
+ duration_s=round(time.time() - start, 2),
244
+ )
245
+ if not info.is_outdated:
246
+ return ApplyResult(
247
+ ok=True, from_version=__version__, to_version=info.latest,
248
+ error="already up-to-date",
249
+ duration_s=round(time.time() - start, 2),
250
+ )
251
+
252
+ _journal(home, {"phase": "begin", "from": info.current, "to": info.latest})
253
+ steps: list[dict[str, Any]] = []
254
+ bundle = ""
255
+ omega_bin = _which("omega") or "omega"
256
+
257
+ # 1. baseline doctor (informational)
258
+ rc, _ = _run_step(home, "doctor-baseline",
259
+ [omega_bin, "doctor", "--json"],
260
+ timeout=60)
261
+ steps.append({"label": "doctor-baseline", "rc": rc})
262
+
263
+ # 2. backup
264
+ if not skip_backup:
265
+ from omega_engine.backup import backup as _bk
266
+ try:
267
+ res = _bk(home, out_dir=home / "Agentik_Extra" / "var" / "backups")
268
+ bundle = str(res.path)
269
+ steps.append({"label": "backup", "rc": 0, "bundle": bundle})
270
+ _journal(home, {"step": "backup", "bundle": bundle})
271
+ except Exception as exc: # noqa: BLE001
272
+ return ApplyResult(
273
+ ok=False, from_version=info.current, to_version=info.latest,
274
+ error=f"backup failed: {exc}",
275
+ duration_s=round(time.time() - start, 2), steps=steps,
276
+ )
277
+
278
+ def _rollback(reason: str) -> ApplyResult:
279
+ _journal(home, {"phase": "rollback", "reason": reason, "bundle": bundle})
280
+ if bundle and not skip_backup:
281
+ from omega_engine.backup import restore as _rs
282
+ try:
283
+ _rs(bundle, target=home)
284
+ except Exception as exc: # noqa: BLE001
285
+ _journal(home, {"phase": "rollback-failed", "reason": str(exc)})
286
+ return ApplyResult(
287
+ ok=False, from_version=info.current, to_version=info.latest,
288
+ bundle=bundle, rolled_back=bool(bundle),
289
+ error=reason,
290
+ duration_s=round(time.time() - start, 2), steps=steps,
291
+ )
292
+
293
+ # 3. npm install
294
+ if npm_global and _which("npm"):
295
+ rc, tail = _run_step(
296
+ home, "npm-install",
297
+ ["npm", "install", "-g", "@agentikos/omega-os@latest"],
298
+ timeout=600,
299
+ )
300
+ steps.append({"label": "npm-install", "rc": rc})
301
+ if rc != 0:
302
+ return _rollback(f"npm install failed: {tail[:200]}")
303
+
304
+ # 4. migrations
305
+ from omega_engine.migrations import run_migrations
306
+ try:
307
+ migrated = run_migrations(home, info.current, info.latest)
308
+ steps.append({
309
+ "label": "migrations", "rc": 0,
310
+ "applied": [m["name"] for m in migrated],
311
+ })
312
+ except Exception as exc: # noqa: BLE001
313
+ return _rollback(f"migrations failed: {exc}")
314
+
315
+ # 5. omega upgrade (re-run install steps, idempotent)
316
+ rc, tail = _run_step(
317
+ home, "omega-upgrade",
318
+ [omega_bin, "upgrade", "--non-interactive"],
319
+ timeout=900,
320
+ )
321
+ steps.append({"label": "omega-upgrade", "rc": rc})
322
+ if rc != 0:
323
+ return _rollback(f"omega upgrade failed: {tail[:200]}")
324
+
325
+ # 6. verify
326
+ if not skip_verify:
327
+ rc_doc, _ = _run_step(home, "doctor-verify",
328
+ [omega_bin, "doctor", "--json"], timeout=60)
329
+ rc_smk, _ = _run_step(home, "smoke", [omega_bin, "smoke"], timeout=120)
330
+ steps.append({"label": "doctor-verify", "rc": rc_doc})
331
+ steps.append({"label": "smoke", "rc": rc_smk})
332
+ if rc_smk != 0:
333
+ return _rollback(f"post-update smoke failed (rc={rc_smk})")
334
+
335
+ _journal(home, {"phase": "success", "to": info.latest})
336
+ return ApplyResult(
337
+ ok=True, from_version=info.current, to_version=info.latest,
338
+ bundle=bundle, duration_s=round(time.time() - start, 2), steps=steps,
339
+ )
@@ -0,0 +1,215 @@
1
+ """`omega backup` + `omega restore` — disaster-recovery for an OmegaOS deployment.
2
+
3
+ What we back up by default:
4
+
5
+ * ``Agentik_Runtime/`` (event log, audits, telegram history, sessions)
6
+ * ``Agentik_Extra/etc/secrets/`` (encrypted vault — the .age files +
7
+ the .vault-key)
8
+ * ``Agentik_SSOT/`` (operator-edited skills, audits, charters,
9
+ webhooks — anything modified post-install)
10
+ * ``Agentik_Coding/projects.json`` (project registry)
11
+
12
+ What we do NOT back up:
13
+
14
+ * The engine venv (regenerated by re-running install.sh)
15
+ * MCP binaries (installed by step 40, idempotent)
16
+ * Cache + tmp dirs
17
+
18
+ The bundle is a tar.gz at ``~/omega-backup-<timestamp>.tar.gz`` by
19
+ default. When the operator passes ``--encrypt``, the tarball is then
20
+ piped through ``age -r <pub>`` so the bundle itself is at-rest
21
+ encrypted. The recipient defaults to the operator's existing
22
+ ``.vault-pub`` so they need no extra key management.
23
+
24
+ ``omega backup verify <path>`` extracts the bundle into a temp dir and
25
+ re-runs ``omega doctor`` against it. Pass = the backup actually
26
+ restores; fail = the bundle is corrupt or incomplete.
27
+ """
28
+ from __future__ import annotations
29
+
30
+ import os
31
+ import shutil
32
+ import subprocess
33
+ import tarfile
34
+ import tempfile
35
+ import time
36
+ from dataclasses import dataclass
37
+ from pathlib import Path
38
+
39
+
40
+ BACKUP_ROOTS = [
41
+ "Agentik_Runtime",
42
+ "Agentik_Extra/etc/secrets",
43
+ "Agentik_SSOT",
44
+ "Agentik_Coding/projects.json",
45
+ ]
46
+
47
+
48
+ @dataclass
49
+ class BackupResult:
50
+ bundle: Path
51
+ bytes: int
52
+ encrypted: bool
53
+ duration_s: float
54
+ detail: str = ""
55
+
56
+
57
+ @dataclass
58
+ class RestoreResult:
59
+ bundle: Path
60
+ target: Path
61
+ files: int
62
+ duration_s: float
63
+ detail: str = ""
64
+
65
+
66
+ def _have(binary: str) -> bool:
67
+ return shutil.which(binary) is not None
68
+
69
+
70
+ def backup(
71
+ omega_home: str | Path,
72
+ *,
73
+ out_dir: str | Path | None = None,
74
+ encrypt: bool = False,
75
+ recipient_path: str | Path | None = None,
76
+ ) -> BackupResult:
77
+ """Create a tarball of the live tree's recoverable subset."""
78
+ home = Path(omega_home)
79
+ if not home.is_dir():
80
+ raise FileNotFoundError(f"OMEGA_HOME not found: {home}")
81
+ out_dir = Path(out_dir) if out_dir else Path.home()
82
+ out_dir.mkdir(parents=True, exist_ok=True)
83
+ ts = int(time.time())
84
+ bundle = out_dir / f"omega-backup-{ts}.tar.gz"
85
+
86
+ start = time.time()
87
+ with tarfile.open(bundle, "w:gz") as tar:
88
+ for relpath in BACKUP_ROOTS:
89
+ full = home / relpath
90
+ if not full.exists():
91
+ continue
92
+ tar.add(full, arcname=relpath)
93
+ elapsed = time.time() - start
94
+
95
+ if encrypt:
96
+ if not _have("age"):
97
+ raise RuntimeError("age not on PATH — install it or drop --encrypt")
98
+ rec_file = (
99
+ Path(recipient_path) if recipient_path
100
+ else home / "Agentik_Extra" / "etc" / "secrets" / ".vault-pub"
101
+ )
102
+ if not rec_file.exists():
103
+ raise RuntimeError(
104
+ f"no recipient public key at {rec_file} — provide --recipient-path"
105
+ )
106
+ recipient = rec_file.read_text().strip()
107
+ enc_bundle = bundle.with_suffix(bundle.suffix + ".age")
108
+ with bundle.open("rb") as inp, enc_bundle.open("wb") as out:
109
+ proc = subprocess.run(
110
+ ["age", "-r", recipient], stdin=inp, stdout=out,
111
+ check=False, capture_output=False, timeout=600,
112
+ )
113
+ if proc.returncode != 0:
114
+ raise RuntimeError(f"age encrypt exit {proc.returncode}")
115
+ bundle.unlink() # drop the plaintext tarball
116
+ bundle = enc_bundle
117
+
118
+ return BackupResult(
119
+ bundle=bundle, bytes=bundle.stat().st_size,
120
+ encrypted=encrypt, duration_s=round(elapsed, 2),
121
+ detail=f"{len(BACKUP_ROOTS)} root(s) archived",
122
+ )
123
+
124
+
125
+ def restore(
126
+ bundle: str | Path,
127
+ *,
128
+ target: str | Path,
129
+ age_identity: str | Path | None = None,
130
+ ) -> RestoreResult:
131
+ """Restore a bundle into ``target`` (typically ``$OMEGA_HOME``)."""
132
+ bundle = Path(bundle)
133
+ if not bundle.exists():
134
+ raise FileNotFoundError(f"bundle not found: {bundle}")
135
+ target = Path(target)
136
+ target.mkdir(parents=True, exist_ok=True)
137
+
138
+ start = time.time()
139
+ # If encrypted, decrypt to a temp file first.
140
+ tar_source: Path = bundle
141
+ cleanup_tmp: Path | None = None
142
+ if bundle.suffix == ".age":
143
+ if not _have("age"):
144
+ raise RuntimeError("age not on PATH — cannot decrypt bundle")
145
+ identity = (
146
+ Path(age_identity) if age_identity
147
+ else target / "Agentik_Extra" / "etc" / "secrets" / ".vault-key"
148
+ )
149
+ if not identity.exists():
150
+ raise RuntimeError(
151
+ f"no age identity at {identity} — provide --identity"
152
+ )
153
+ cleanup_tmp = Path(tempfile.mkstemp(suffix=".tar.gz")[1])
154
+ with cleanup_tmp.open("wb") as out:
155
+ proc = subprocess.run(
156
+ ["age", "-d", "-i", str(identity), str(bundle)],
157
+ stdout=out, check=False, timeout=600,
158
+ )
159
+ if proc.returncode != 0:
160
+ cleanup_tmp.unlink(missing_ok=True)
161
+ raise RuntimeError(f"age decrypt exit {proc.returncode}")
162
+ tar_source = cleanup_tmp
163
+
164
+ try:
165
+ with tarfile.open(tar_source, "r:gz") as tar:
166
+ members = tar.getmembers()
167
+ for m in members:
168
+ # Reject absolute paths + path traversal.
169
+ if m.name.startswith("/") or ".." in m.name.split("/"):
170
+ raise RuntimeError(f"unsafe path in bundle: {m.name}")
171
+ tar.extractall(path=target)
172
+ files = sum(1 for m in members if m.isfile())
173
+ finally:
174
+ if cleanup_tmp is not None:
175
+ cleanup_tmp.unlink(missing_ok=True)
176
+
177
+ return RestoreResult(
178
+ bundle=bundle, target=target, files=files,
179
+ duration_s=round(time.time() - start, 2),
180
+ detail=f"{files} file(s) extracted",
181
+ )
182
+
183
+
184
+ def verify(
185
+ bundle: str | Path,
186
+ *,
187
+ age_identity: str | Path | None = None,
188
+ ) -> dict:
189
+ """Restore the bundle into a temp dir + run a minimal sanity check.
190
+
191
+ Returns ``{ok: bool, files: int, detail: str}``. We do NOT run the
192
+ full ``omega doctor`` here because that would touch the operator's
193
+ real environment; we just confirm the bundle extracts cleanly and
194
+ looks like an OmegaOS tree.
195
+ """
196
+ bundle = Path(bundle)
197
+ with tempfile.TemporaryDirectory() as td:
198
+ result = restore(bundle, target=td, age_identity=age_identity)
199
+ # Smoke check: the well-known subset should be in there.
200
+ target = Path(td)
201
+ missing = [
202
+ root for root in BACKUP_ROOTS
203
+ if not (target / root).exists()
204
+ ]
205
+ if missing:
206
+ return {
207
+ "ok": False,
208
+ "files": result.files,
209
+ "detail": f"missing in bundle: {missing}",
210
+ }
211
+ return {
212
+ "ok": True,
213
+ "files": result.files,
214
+ "detail": f"all {len(BACKUP_ROOTS)} root(s) present + extracted",
215
+ }