@agentikos/omega-os 0.2.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 (367) 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/marketplaces/design-discipline.yaml +86 -0
  340. package/omega/Agentik_SSOT/skills/a11yaudit/SKILL.md +161 -0
  341. package/omega/Agentik_SSOT/skills/apiaudit/SKILL.md +157 -0
  342. package/omega/Agentik_SSOT/skills/automationaudit/SKILL.md +161 -0
  343. package/omega/Agentik_SSOT/skills/cadence/SKILL.md +76 -0
  344. package/omega/Agentik_SSOT/skills/codeaudit/SKILL.md +153 -0
  345. package/omega/Agentik_SSOT/skills/copyaudit/SKILL.md +161 -0
  346. package/omega/Agentik_SSOT/skills/dataaudit/SKILL.md +157 -0
  347. package/omega/Agentik_SSOT/skills/debugaudit/SKILL.md +161 -0
  348. package/omega/Agentik_SSOT/skills/dispatch/SKILL.md +79 -0
  349. package/omega/Agentik_SSOT/skills/dxaudit/SKILL.md +161 -0
  350. package/omega/Agentik_SSOT/skills/featureaudit/SKILL.md +161 -0
  351. package/omega/Agentik_SSOT/skills/flowaudit/SKILL.md +165 -0
  352. package/omega/Agentik_SSOT/skills/genesis/SKILL.md +116 -0
  353. package/omega/Agentik_SSOT/skills/handoff/SKILL.md +117 -0
  354. package/omega/Agentik_SSOT/skills/logicaudit/SKILL.md +165 -0
  355. package/omega/Agentik_SSOT/skills/motionaudit/SKILL.md +165 -0
  356. package/omega/Agentik_SSOT/skills/perfaudit/SKILL.md +161 -0
  357. package/omega/Agentik_SSOT/skills/plan/SKILL.md +127 -0
  358. package/omega/Agentik_SSOT/skills/pursue/SKILL.md +68 -0
  359. package/omega/Agentik_SSOT/skills/rag-route.md +9 -0
  360. package/omega/Agentik_SSOT/skills/refontaudit/SKILL.md +165 -0
  361. package/omega/Agentik_SSOT/skills/retentionaudit/SKILL.md +165 -0
  362. package/omega/Agentik_SSOT/skills/secaudit/SKILL.md +157 -0
  363. package/omega/Agentik_SSOT/skills/seoaudit/SKILL.md +161 -0
  364. package/omega/Agentik_SSOT/skills/skill-auditor/SKILL.md +83 -0
  365. package/omega/Agentik_SSOT/skills/skill-finder/SKILL.md +116 -0
  366. package/omega/Agentik_SSOT/skills/uiuxaudit/SKILL.md +165 -0
  367. package/package.json +2 -2
@@ -0,0 +1,467 @@
1
+ """Anthropic Managed Agents — provider + client.
2
+
3
+ What this is
4
+ ------------
5
+
6
+ Wraps Anthropic's Managed Agents beta API (``/v1/agents``,
7
+ ``/v1/environments``, ``/v1/sessions``, SSE event stream) so OmegaOS can
8
+ dispatch missions to Anthropic's server-side agent runtime instead of —
9
+ or alongside — the local ``claude`` CLI.
10
+
11
+ Three resources, in order
12
+ -------------------------
13
+
14
+ 1. **Agent** — reusable template: model + system + tools. Created once,
15
+ referenced by ``agent_id`` across many sessions.
16
+ 2. **Environment** — sandbox config: ``cloud`` (Anthropic-managed
17
+ container) or ``self_hosted`` (your infra). Also reusable.
18
+ 3. **Session** — a running agent instance inside an environment. You
19
+ send ``user.message`` events into it and stream
20
+ ``agent.message`` / ``agent.tool_use`` / ``session.status_idle``
21
+ events back.
22
+
23
+ This module ships:
24
+
25
+ * :class:`ManagedAgentClient` — thin REST wrapper (zero deps beyond
26
+ stdlib). Send events, list resources, stream via SSE.
27
+ * :class:`ManagedAgentProvider` — implements the OmegaOS
28
+ ``AgentProvider`` contract so it slots into ``ModelRouter`` next to
29
+ ``ClaudeMaxProvider``.
30
+ * Persistent ID cache at
31
+ ``$OMEGA_HOME/Agentik_Runtime/managed_agents.json`` so we don't
32
+ re-create the agent + environment on every call (~250 ms saved per
33
+ request).
34
+
35
+ When to use this vs. ClaudeMaxProvider
36
+ --------------------------------------
37
+
38
+ ClaudeMaxProvider = local ``claude -p`` subprocess, Max OAuth, $0 per
39
+ call beyond the $200/month cap, requires tmux.
40
+ ManagedAgentProvider = Anthropic-managed sandbox, API key required,
41
+ per-token billing, persistent sessions,
42
+ long-running async work, no local subprocess.
43
+
44
+ Default routing stays on ``claude-max`` to honour OmegaOS's "no API key
45
+ burn" principle. Opt-in via:
46
+
47
+ * ``ANTHROPIC_API_KEY`` env var (the provider is added to the router
48
+ when ``ModelRouter.auto()`` sees it, but Max stays default).
49
+ * Explicit topology entry: ``role_provider: {worker: claude-managed-agent}``.
50
+
51
+ Beta header
52
+ -----------
53
+
54
+ All requests carry ``anthropic-beta: managed-agents-2026-04-01``. The
55
+ constant is exposed as :data:`MANAGED_AGENTS_BETA` so callers can override
56
+ when Anthropic bumps it.
57
+ """
58
+ from __future__ import annotations
59
+
60
+ import json
61
+ import os
62
+ import time
63
+ import urllib.error
64
+ import urllib.request
65
+ from dataclasses import dataclass, field
66
+ from pathlib import Path
67
+ from typing import Any, Iterator
68
+
69
+
70
+ MANAGED_AGENTS_BETA = "managed-agents-2026-04-01"
71
+ ANTHROPIC_VERSION = "2023-06-01"
72
+ _BASE_URL = "https://api.anthropic.com/v1"
73
+
74
+
75
+ # ---------------------------------------------------------------------------
76
+ # Errors
77
+ # ---------------------------------------------------------------------------
78
+
79
+
80
+ class ManagedAgentError(RuntimeError):
81
+ """Raised by the client when the API returns a non-2xx response."""
82
+
83
+
84
+ # ---------------------------------------------------------------------------
85
+ # REST client (stdlib-only)
86
+ # ---------------------------------------------------------------------------
87
+
88
+
89
+ @dataclass
90
+ class ManagedAgentClient:
91
+ api_key: str
92
+ timeout_s: int = 60
93
+ beta: str = MANAGED_AGENTS_BETA
94
+
95
+ def _headers(self, extra: dict[str, str] | None = None) -> dict[str, str]:
96
+ h = {
97
+ "x-api-key": self.api_key,
98
+ "anthropic-version": ANTHROPIC_VERSION,
99
+ "anthropic-beta": self.beta,
100
+ "content-type": "application/json",
101
+ }
102
+ if extra:
103
+ h.update(extra)
104
+ return h
105
+
106
+ def _request(
107
+ self,
108
+ method: str,
109
+ path: str,
110
+ body: dict[str, Any] | None = None,
111
+ *,
112
+ accept: str = "application/json",
113
+ timeout: int | None = None,
114
+ ) -> Any:
115
+ url = f"{_BASE_URL}{path}"
116
+ data = None if body is None else json.dumps(body).encode("utf-8")
117
+ req = urllib.request.Request(
118
+ url, data=data, method=method,
119
+ headers=self._headers({"Accept": accept}),
120
+ )
121
+ try:
122
+ with urllib.request.urlopen( # noqa: S310
123
+ req, timeout=timeout or self.timeout_s,
124
+ ) as resp:
125
+ raw = resp.read().decode("utf-8")
126
+ except urllib.error.HTTPError as exc:
127
+ detail = exc.read().decode("utf-8", errors="replace")[:400]
128
+ raise ManagedAgentError(
129
+ f"{method} {path} → HTTP {exc.code}: {detail}"
130
+ ) from exc
131
+ except (OSError, urllib.error.URLError) as exc:
132
+ raise ManagedAgentError(
133
+ f"{method} {path} → network: {exc}"
134
+ ) from exc
135
+ if not raw:
136
+ return None
137
+ try:
138
+ return json.loads(raw)
139
+ except json.JSONDecodeError:
140
+ return raw
141
+
142
+ # ----- Agents ---------------------------------------------------------
143
+
144
+ def create_agent(
145
+ self,
146
+ *,
147
+ name: str,
148
+ model: str = "claude-opus-4-7",
149
+ system: str = "",
150
+ tools: list[dict[str, Any]] | None = None,
151
+ ) -> dict[str, Any]:
152
+ tools = tools if tools is not None else [{"type": "agent_toolset_20260401"}]
153
+ body: dict[str, Any] = {"name": name, "model": model, "tools": tools}
154
+ if system:
155
+ body["system"] = system
156
+ return self._request("POST", "/agents", body)
157
+
158
+ def get_agent(self, agent_id: str) -> dict[str, Any]:
159
+ return self._request("GET", f"/agents/{agent_id}")
160
+
161
+ def list_agents(self, *, limit: int = 20) -> dict[str, Any]:
162
+ return self._request("GET", f"/agents?limit={limit}")
163
+
164
+ def delete_agent(self, agent_id: str) -> dict[str, Any] | None:
165
+ return self._request("DELETE", f"/agents/{agent_id}")
166
+
167
+ # ----- Environments ---------------------------------------------------
168
+
169
+ def create_environment(
170
+ self,
171
+ *,
172
+ name: str,
173
+ config: dict[str, Any] | None = None,
174
+ ) -> dict[str, Any]:
175
+ config = config or {
176
+ "type": "cloud",
177
+ "networking": {"type": "unrestricted"},
178
+ }
179
+ return self._request(
180
+ "POST", "/environments", {"name": name, "config": config},
181
+ )
182
+
183
+ def get_environment(self, env_id: str) -> dict[str, Any]:
184
+ return self._request("GET", f"/environments/{env_id}")
185
+
186
+ def list_environments(self, *, limit: int = 20) -> dict[str, Any]:
187
+ return self._request("GET", f"/environments?limit={limit}")
188
+
189
+ def delete_environment(self, env_id: str) -> dict[str, Any] | None:
190
+ return self._request("DELETE", f"/environments/{env_id}")
191
+
192
+ # ----- Sessions -------------------------------------------------------
193
+
194
+ def create_session(
195
+ self,
196
+ *,
197
+ agent_id: str,
198
+ environment_id: str,
199
+ title: str = "",
200
+ ) -> dict[str, Any]:
201
+ body: dict[str, Any] = {
202
+ "agent": agent_id,
203
+ "environment_id": environment_id,
204
+ }
205
+ if title:
206
+ body["title"] = title
207
+ return self._request("POST", "/sessions", body)
208
+
209
+ def get_session(self, session_id: str) -> dict[str, Any]:
210
+ return self._request("GET", f"/sessions/{session_id}")
211
+
212
+ def list_sessions(self, *, limit: int = 20) -> dict[str, Any]:
213
+ return self._request("GET", f"/sessions?limit={limit}")
214
+
215
+ def delete_session(self, session_id: str) -> dict[str, Any] | None:
216
+ return self._request("DELETE", f"/sessions/{session_id}")
217
+
218
+ def send_event(
219
+ self,
220
+ session_id: str,
221
+ events: list[dict[str, Any]],
222
+ ) -> Any:
223
+ return self._request(
224
+ "POST", f"/sessions/{session_id}/events",
225
+ {"events": events},
226
+ )
227
+
228
+ def send_user_message(self, session_id: str, text: str) -> Any:
229
+ """Convenience wrapper for the most common event shape."""
230
+ return self.send_event(session_id, [{
231
+ "type": "user.message",
232
+ "content": [{"type": "text", "text": text}],
233
+ }])
234
+
235
+ def stream_events(
236
+ self,
237
+ session_id: str,
238
+ *,
239
+ stop_on_idle: bool = True,
240
+ timeout_s: int = 600,
241
+ ) -> Iterator[dict[str, Any]]:
242
+ """Open the SSE stream + yield parsed event dicts.
243
+
244
+ Stops at the first ``session.status_idle`` when
245
+ ``stop_on_idle=True`` (the natural "agent is done" boundary).
246
+ """
247
+ url = f"{_BASE_URL}/sessions/{session_id}/stream"
248
+ req = urllib.request.Request(
249
+ url, headers=self._headers({"Accept": "text/event-stream"}),
250
+ )
251
+ try:
252
+ resp = urllib.request.urlopen(req, timeout=timeout_s) # noqa: S310
253
+ except urllib.error.HTTPError as exc:
254
+ detail = exc.read().decode("utf-8", errors="replace")[:400]
255
+ raise ManagedAgentError(
256
+ f"stream HTTP {exc.code}: {detail}"
257
+ ) from exc
258
+ try:
259
+ for line_bytes in resp:
260
+ line = line_bytes.decode("utf-8", errors="replace").strip()
261
+ if not line.startswith("data:"):
262
+ continue
263
+ payload = line[len("data:"):].strip()
264
+ if not payload:
265
+ continue
266
+ try:
267
+ event = json.loads(payload)
268
+ except json.JSONDecodeError:
269
+ continue
270
+ yield event
271
+ if stop_on_idle and event.get("type") == "session.status_idle":
272
+ return
273
+ finally:
274
+ try:
275
+ resp.close()
276
+ except OSError:
277
+ pass
278
+
279
+
280
+ # ---------------------------------------------------------------------------
281
+ # Persistent ID cache — don't re-create the agent/env on every call
282
+ # ---------------------------------------------------------------------------
283
+
284
+
285
+ def _cache_path(home: Path) -> Path:
286
+ return home / "Agentik_Runtime" / "managed_agents.json"
287
+
288
+
289
+ @dataclass
290
+ class ManagedAgentCache:
291
+ """Atomic JSON file keyed by ``(agent_name, env_name)``."""
292
+
293
+ home: Path
294
+
295
+ def _load(self) -> dict[str, Any]:
296
+ p = _cache_path(self.home)
297
+ if not p.exists():
298
+ return {"agents": {}, "environments": {}}
299
+ try:
300
+ return json.loads(p.read_text())
301
+ except (OSError, json.JSONDecodeError):
302
+ return {"agents": {}, "environments": {}}
303
+
304
+ def _save(self, data: dict[str, Any]) -> None:
305
+ import threading
306
+ p = _cache_path(self.home)
307
+ p.parent.mkdir(parents=True, exist_ok=True)
308
+ tmp = p.with_suffix(
309
+ p.suffix + f".tmp.{os.getpid()}.{threading.get_ident()}"
310
+ )
311
+ tmp.write_text(json.dumps(data, indent=2))
312
+ os.replace(tmp, p)
313
+
314
+ def get_agent(self, name: str) -> str | None:
315
+ return self._load()["agents"].get(name)
316
+
317
+ def get_environment(self, name: str) -> str | None:
318
+ return self._load()["environments"].get(name)
319
+
320
+ def set_agent(self, name: str, agent_id: str) -> None:
321
+ d = self._load()
322
+ d["agents"][name] = agent_id
323
+ self._save(d)
324
+
325
+ def set_environment(self, name: str, env_id: str) -> None:
326
+ d = self._load()
327
+ d["environments"][name] = env_id
328
+ self._save(d)
329
+
330
+
331
+ # ---------------------------------------------------------------------------
332
+ # Provider — slot into OmegaOS's AgentProvider contract
333
+ # ---------------------------------------------------------------------------
334
+
335
+
336
+ class ManagedAgentProvider:
337
+ """Implements the OmegaOS ``AgentProvider`` protocol via Managed Agents.
338
+
339
+ Each ``run(req)`` call:
340
+
341
+ 1. Resolves agent + environment IDs (from the cache; creates them
342
+ on first use).
343
+ 2. Creates a fresh session for this request (sessions are stateful,
344
+ we want isolation per call).
345
+ 3. Sends a single user.message with ``req.prompt`` as text.
346
+ 4. Streams events until ``session.status_idle``.
347
+ 5. Aggregates every ``agent.message`` text block into the result
348
+ and surfaces tool-use names in ``artifacts.tool_uses``.
349
+
350
+ The cost of a request lives in ``artifacts.usage`` when the API
351
+ returns it (it's per-organization billed, not per-request, so we
352
+ surface what we can but don't claim a per-call USD figure).
353
+ """
354
+
355
+ id = "claude-managed-agent"
356
+
357
+ def __init__(
358
+ self,
359
+ *,
360
+ api_key: str | None = None,
361
+ agent_name: str = "omega-default-agent",
362
+ env_name: str = "omega-default-env",
363
+ model: str = "claude-opus-4-7",
364
+ system: str = "You are an Omega OS managed agent. Execute the user's intent and stop when done.",
365
+ omega_home: str | Path | None = None,
366
+ timeout_s: int = 600,
367
+ ) -> None:
368
+ self._api_key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
369
+ if not self._api_key:
370
+ raise ValueError(
371
+ "ManagedAgentProvider requires ANTHROPIC_API_KEY "
372
+ "(or pass api_key=...)"
373
+ )
374
+ self._client = ManagedAgentClient(
375
+ api_key=self._api_key, timeout_s=timeout_s,
376
+ )
377
+ self._agent_name = agent_name
378
+ self._env_name = env_name
379
+ self._model = model
380
+ self._system = system
381
+ self._timeout_s = timeout_s
382
+ home = Path(omega_home or os.environ.get(
383
+ "OMEGA_HOME", str(Path.home() / "Omega")
384
+ ))
385
+ self._cache = ManagedAgentCache(home)
386
+
387
+ # ---- AgentProvider protocol ----
388
+
389
+ @staticmethod
390
+ def is_available() -> bool:
391
+ return bool(os.environ.get("ANTHROPIC_API_KEY"))
392
+
393
+ def _ensure_agent_and_env(self) -> tuple[str, str]:
394
+ agent_id = self._cache.get_agent(self._agent_name)
395
+ if not agent_id:
396
+ agent = self._client.create_agent(
397
+ name=self._agent_name,
398
+ model=self._model,
399
+ system=self._system,
400
+ )
401
+ agent_id = agent["id"]
402
+ self._cache.set_agent(self._agent_name, agent_id)
403
+
404
+ env_id = self._cache.get_environment(self._env_name)
405
+ if not env_id:
406
+ env = self._client.create_environment(name=self._env_name)
407
+ env_id = env["id"]
408
+ self._cache.set_environment(self._env_name, env_id)
409
+
410
+ return agent_id, env_id
411
+
412
+ def run(self, req): # type: ignore[no-untyped-def]
413
+ """Implements AgentProvider.run — synchronous: create session,
414
+ send prompt, drain stream, return aggregated text."""
415
+ # Local import to avoid forcing the provider module to depend on
416
+ # the rest of the engine.
417
+ from omega_engine.provider import AgentResult
418
+
419
+ agent_id, env_id = self._ensure_agent_and_env()
420
+ session = self._client.create_session(
421
+ agent_id=agent_id, environment_id=env_id,
422
+ title=f"omega:{req.role}:{(req.context or {}).get('mission_id','')[:24]}",
423
+ )
424
+ session_id = session["id"]
425
+ prompt = req.prompt
426
+ if req.system:
427
+ # The session's system prompt was set at agent-creation time;
428
+ # we prepend any per-call system text into the user message
429
+ # so the agent still sees it. Cheap; works for the common
430
+ # "use these skills" preface.
431
+ prompt = f"[system] {req.system}\n\n{prompt}"
432
+ self._client.send_user_message(session_id, prompt)
433
+
434
+ text_chunks: list[str] = []
435
+ tool_uses: list[str] = []
436
+ for ev in self._client.stream_events(
437
+ session_id, timeout_s=self._timeout_s,
438
+ ):
439
+ t = ev.get("type")
440
+ if t == "agent.message":
441
+ for block in ev.get("content", []):
442
+ if block.get("type") == "text":
443
+ text_chunks.append(block.get("text", ""))
444
+ elif t == "agent.tool_use":
445
+ name = ev.get("name") or "?"
446
+ tool_uses.append(name)
447
+ elif t == "session.status_idle":
448
+ break
449
+
450
+ return AgentResult(
451
+ text="".join(text_chunks),
452
+ claimed_done=True,
453
+ plan=[],
454
+ artifacts={
455
+ "managed_agent": {
456
+ "agent_id": agent_id,
457
+ "environment_id": env_id,
458
+ "session_id": session_id,
459
+ "tool_uses": tool_uses,
460
+ },
461
+ },
462
+ usage={
463
+ "input_tokens": 0,
464
+ "output_tokens": 0,
465
+ "cost_usd": 0.0,
466
+ },
467
+ )