@openlife/cli 1.7.3

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 (394) hide show
  1. package/INSTALL.md +266 -0
  2. package/LICENSE +21 -0
  3. package/README.md +142 -0
  4. package/bin/openlife.js +3 -0
  5. package/dist/admin_panel_server.js +66 -0
  6. package/dist/cli/AgentManager.js +109 -0
  7. package/dist/cli/AutonomousInstaller.js +134 -0
  8. package/dist/cli/DreamOrganizer.js +88 -0
  9. package/dist/cli/HostInstaller.js +426 -0
  10. package/dist/cli/InstallBanner.js +16 -0
  11. package/dist/cli/InstallFlow.js +256 -0
  12. package/dist/cli/InstallHeadless.js +47 -0
  13. package/dist/cli/InstallModules.js +148 -0
  14. package/dist/cli/InstallStateStore.js +75 -0
  15. package/dist/cli/InstallWizard.js +364 -0
  16. package/dist/cli/ProfileManager.js +163 -0
  17. package/dist/cli/SystemInstaller.js +89 -0
  18. package/dist/cli/WorldClassCommands.js +208 -0
  19. package/dist/design/DesignMdImporter.js +82 -0
  20. package/dist/design/DesignMdMode.js +93 -0
  21. package/dist/design/DesignMdRegistry.js +67 -0
  22. package/dist/index.js +2575 -0
  23. package/dist/memory/ConversationMemory.js +33 -0
  24. package/dist/memory/LocalMemoryProvider.js +86 -0
  25. package/dist/memory/Mem0Provider.js +16 -0
  26. package/dist/memory/MemoryNamespacePolicy.js +27 -0
  27. package/dist/memory/MemoryOrchestrator.js +65 -0
  28. package/dist/memory/MemoryPromotionFlow.js +32 -0
  29. package/dist/memory/MemoryProvider.js +2 -0
  30. package/dist/memory/MemoryProviderRegistry.js +27 -0
  31. package/dist/memory/MemoryRetentionPolicy.js +60 -0
  32. package/dist/memory/MempalaceProvider.js +72 -0
  33. package/dist/memory/OmniMemory.js +106 -0
  34. package/dist/memory/RedisAgentMemoryProvider.js +16 -0
  35. package/dist/memory/SessionManager.js +86 -0
  36. package/dist/memory/ZepGraphitiProvider.js +16 -0
  37. package/dist/orchestrator/AgentRegistry.js +56 -0
  38. package/dist/orchestrator/AgentScoring.js +82 -0
  39. package/dist/orchestrator/AgentTeam.js +22 -0
  40. package/dist/orchestrator/ArbitrationAgent.js +43 -0
  41. package/dist/orchestrator/ArbitrationScorecard.js +17 -0
  42. package/dist/orchestrator/AssetPromotionEngine.js +65 -0
  43. package/dist/orchestrator/AssetReuseRouter.js +63 -0
  44. package/dist/orchestrator/BenchmarkEngine.js +75 -0
  45. package/dist/orchestrator/Brain.js +298 -0
  46. package/dist/orchestrator/CadenceEngine.js +76 -0
  47. package/dist/orchestrator/CapabilityRouter.js +36 -0
  48. package/dist/orchestrator/CommandLanguage.js +27 -0
  49. package/dist/orchestrator/CommandRouter.js +70 -0
  50. package/dist/orchestrator/ConsequenceForecaster.js +286 -0
  51. package/dist/orchestrator/CronManager.js +286 -0
  52. package/dist/orchestrator/DynamicAgentBuilder.js +48 -0
  53. package/dist/orchestrator/DynamicAgentExecutor.js +15 -0
  54. package/dist/orchestrator/EnterpriseAgenticCore.js +276 -0
  55. package/dist/orchestrator/ExecutionBoard.js +86 -0
  56. package/dist/orchestrator/ExecutionIntent.js +13 -0
  57. package/dist/orchestrator/ExecutionModePolicy.js +48 -0
  58. package/dist/orchestrator/ExecutionRouter.js +9 -0
  59. package/dist/orchestrator/ExecutionState.js +20 -0
  60. package/dist/orchestrator/ExecutorHealth.js +86 -0
  61. package/dist/orchestrator/ExternalCatalogRegistry.js +83 -0
  62. package/dist/orchestrator/Gatekeeper.js +414 -0
  63. package/dist/orchestrator/Gateway.js +508 -0
  64. package/dist/orchestrator/GovernanceConsentStore.js +66 -0
  65. package/dist/orchestrator/GovernanceLayer.js +179 -0
  66. package/dist/orchestrator/GovernancePolicyStore.js +53 -0
  67. package/dist/orchestrator/GovernanceScopeLedger.js +134 -0
  68. package/dist/orchestrator/GovernanceScopePolicy.js +67 -0
  69. package/dist/orchestrator/IntentClassifier.js +45 -0
  70. package/dist/orchestrator/JobLifecycle.js +91 -0
  71. package/dist/orchestrator/LearningRouter.js +24 -0
  72. package/dist/orchestrator/MediaManager.js +92 -0
  73. package/dist/orchestrator/MemoryCuratorAgent.js +41 -0
  74. package/dist/orchestrator/MissionState.js +155 -0
  75. package/dist/orchestrator/ModelManager.js +84 -0
  76. package/dist/orchestrator/OperatingSystem.js +71 -0
  77. package/dist/orchestrator/OperationalMemoryStore.js +94 -0
  78. package/dist/orchestrator/OptimizationLoop.js +72 -0
  79. package/dist/orchestrator/OrchestrationLoop.js +905 -0
  80. package/dist/orchestrator/OrgStructure.js +88 -0
  81. package/dist/orchestrator/OutcomeSimulator.js +46 -0
  82. package/dist/orchestrator/ParallelOrchestrationLoop.js +36 -0
  83. package/dist/orchestrator/PerformanceScorecard.js +105 -0
  84. package/dist/orchestrator/PlannerAgent.js +46 -0
  85. package/dist/orchestrator/ProcessSandbox.js +129 -0
  86. package/dist/orchestrator/PromotionPipeline.js +74 -0
  87. package/dist/orchestrator/PromotionReviewGate.js +11 -0
  88. package/dist/orchestrator/QueueScheduler.js +260 -0
  89. package/dist/orchestrator/ReleaseGate.js +36 -0
  90. package/dist/orchestrator/ReleaseWorkflow.js +68 -0
  91. package/dist/orchestrator/RemotePublisher.js +139 -0
  92. package/dist/orchestrator/ReuseEngine.js +89 -0
  93. package/dist/orchestrator/ReviewerAgent.js +49 -0
  94. package/dist/orchestrator/RoleHandoff.js +65 -0
  95. package/dist/orchestrator/RuntimeHealthMonitor.js +143 -0
  96. package/dist/orchestrator/RuntimePolicy.js +105 -0
  97. package/dist/orchestrator/RuntimeProbe.js +97 -0
  98. package/dist/orchestrator/RuntimeRegistry.js +73 -0
  99. package/dist/orchestrator/SandboxPolicy.js +22 -0
  100. package/dist/orchestrator/SecurityDownloadGuard.js +169 -0
  101. package/dist/orchestrator/SecurityEventStore.js +58 -0
  102. package/dist/orchestrator/ServiceCompletionPolicy.js +36 -0
  103. package/dist/orchestrator/ServiceState.js +195 -0
  104. package/dist/orchestrator/SkillCreator.js +404 -0
  105. package/dist/orchestrator/SkillLearningLoop.js +57 -0
  106. package/dist/orchestrator/SkillManager.js +75 -0
  107. package/dist/orchestrator/SkillNetwork.js +29 -0
  108. package/dist/orchestrator/SkillRegistryV2.js +28 -0
  109. package/dist/orchestrator/SkillScoring.js +70 -0
  110. package/dist/orchestrator/SquadAutoCreator.js +64 -0
  111. package/dist/orchestrator/SquadCreator.js +727 -0
  112. package/dist/orchestrator/SquadRegistry.js +28 -0
  113. package/dist/orchestrator/SquadRouter.js +33 -0
  114. package/dist/orchestrator/SquadScoring.js +70 -0
  115. package/dist/orchestrator/SubagentLifecycle.js +90 -0
  116. package/dist/orchestrator/SynthesizerAgent.js +48 -0
  117. package/dist/orchestrator/SystemDoctor.js +224 -0
  118. package/dist/orchestrator/TaskExecutor.js +422 -0
  119. package/dist/orchestrator/TeammateBoard.js +61 -0
  120. package/dist/orchestrator/TestHarness.js +184 -0
  121. package/dist/orchestrator/VoiceManager.js +203 -0
  122. package/dist/orchestrator/VoiceRouter.js +89 -0
  123. package/dist/orchestrator/capability/CapabilityGenesisEngine.js +278 -0
  124. package/dist/orchestrator/capability/CapabilityPackParser.js +223 -0
  125. package/dist/orchestrator/capability/CapabilityPackSchema.js +62 -0
  126. package/dist/orchestrator/capability/CapabilityPackState.js +163 -0
  127. package/dist/orchestrator/providers/AgentProvider.js +2 -0
  128. package/dist/orchestrator/providers/CapabilityProvider.js +12 -0
  129. package/dist/orchestrator/providers/CloudAgentProvider.js +55 -0
  130. package/dist/orchestrator/providers/CloudSkillProvider.js +55 -0
  131. package/dist/orchestrator/providers/CloudSquadProvider.js +55 -0
  132. package/dist/orchestrator/providers/CompositeAgentProvider.js +16 -0
  133. package/dist/orchestrator/providers/CompositeCapabilityProvider.js +25 -0
  134. package/dist/orchestrator/providers/CompositeSkillProvider.js +16 -0
  135. package/dist/orchestrator/providers/CompositeSquadProvider.js +16 -0
  136. package/dist/orchestrator/providers/CompositeWorkflowProvider.js +46 -0
  137. package/dist/orchestrator/providers/FileAgentProvider.js +105 -0
  138. package/dist/orchestrator/providers/FileCapabilityProvider.js +106 -0
  139. package/dist/orchestrator/providers/FileSkillProvider.js +65 -0
  140. package/dist/orchestrator/providers/FileSquadProvider.js +69 -0
  141. package/dist/orchestrator/providers/FileWorkflowProvider.js +103 -0
  142. package/dist/orchestrator/providers/SkillProvider.js +2 -0
  143. package/dist/orchestrator/providers/SquadProvider.js +2 -0
  144. package/dist/orchestrator/toolset/ToolsetGuard.js +69 -0
  145. package/dist/orchestrator/toolset/ToolsetRegistry.js +65 -0
  146. package/dist/orchestrator/toolset/ToolsetSchema.js +21 -0
  147. package/dist/orchestrator/util/AtomicWriter.js +204 -0
  148. package/dist/orchestrator/util/DistributedLock.js +232 -0
  149. package/dist/orchestrator/util/TemplateRenderer.js +87 -0
  150. package/dist/orchestrator/util/WatchdogHeartbeat.js +116 -0
  151. package/dist/orchestrator/workflow/ConditionParser.js +232 -0
  152. package/dist/orchestrator/workflow/WorkflowEngine.js +379 -0
  153. package/dist/orchestrator/workflow/WorkflowParser.js +368 -0
  154. package/dist/orchestrator/workflow/WorkflowSchema.js +65 -0
  155. package/dist/orchestrator/workflow/WorkflowState.js +11 -0
  156. package/dist/reversa/ReversaAgent.js +134 -0
  157. package/dist/reversa/ReversaContracts.js +62 -0
  158. package/dist/reversa/ReversaExecutors.js +65 -0
  159. package/dist/skills/SkillRegistry.js +71 -0
  160. package/dist/squads/SquadManager.js +87 -0
  161. package/dist/test_admin_teams_networks.js +54 -0
  162. package/dist/test_agent_team_skill_network.js +15 -0
  163. package/dist/test_aiobuilder_cli_parity.js +169 -0
  164. package/dist/test_ask_exit.js +73 -0
  165. package/dist/test_atomic_writer.js +209 -0
  166. package/dist/test_autonomous_soak.js +141 -0
  167. package/dist/test_benchmark_engine.js +41 -0
  168. package/dist/test_brain_error_diagnostics.js +51 -0
  169. package/dist/test_brain_fallback_chain.js +93 -0
  170. package/dist/test_capability_genesis_engine.js +225 -0
  171. package/dist/test_capability_pack_schema.js +214 -0
  172. package/dist/test_catalog_quality.js +150 -0
  173. package/dist/test_cli_crud_roundtrip.js +154 -0
  174. package/dist/test_cli_diagnostics.js +131 -0
  175. package/dist/test_cli_doc_parity.js +126 -0
  176. package/dist/test_cli_help_surface.js +106 -0
  177. package/dist/test_cli_service_commands.js +83 -0
  178. package/dist/test_consequence_forecast_brain.js +165 -0
  179. package/dist/test_consequence_forecaster.js +24 -0
  180. package/dist/test_conversation_memory.js +36 -0
  181. package/dist/test_create_entities.js +54 -0
  182. package/dist/test_creator_placeholders_completed.js +177 -0
  183. package/dist/test_cron_manager.js +123 -0
  184. package/dist/test_daemon_sigterm.js +72 -0
  185. package/dist/test_deep_research_capability.js +87 -0
  186. package/dist/test_designmd_import_registry.js +16 -0
  187. package/dist/test_designmd_mode.js +50 -0
  188. package/dist/test_designmd_mode_workspace.js +13 -0
  189. package/dist/test_dist_templates_layout.js +135 -0
  190. package/dist/test_distributed_lock.js +201 -0
  191. package/dist/test_distribution_installability.js +67 -0
  192. package/dist/test_doctor_sandbox_check.js +44 -0
  193. package/dist/test_dream_organizer.js +25 -0
  194. package/dist/test_dual_mode.js +15 -0
  195. package/dist/test_enterprise_agentic_core.js +128 -0
  196. package/dist/test_forecast_brain_wiring.js +87 -0
  197. package/dist/test_gateway_telegram_guardrails.js +52 -0
  198. package/dist/test_governance.js +34 -0
  199. package/dist/test_governance_advanced.js +75 -0
  200. package/dist/test_governance_scope_ledger.js +147 -0
  201. package/dist/test_governance_v13_policies.js +44 -0
  202. package/dist/test_guided_creator_cli.js +100 -0
  203. package/dist/test_host_install_e2e.js +324 -0
  204. package/dist/test_host_installer.js +259 -0
  205. package/dist/test_host_installers_gemini_codex.js +95 -0
  206. package/dist/test_host_uninstaller.js +295 -0
  207. package/dist/test_install_flow.js +70 -0
  208. package/dist/test_install_flow_host_validation.js +143 -0
  209. package/dist/test_install_wizard.js +272 -0
  210. package/dist/test_integration_gemini_live.js +95 -0
  211. package/dist/test_integration_http_trigger_live.js +154 -0
  212. package/dist/test_integration_telegram_live.js +102 -0
  213. package/dist/test_job_lifecycle.js +16 -0
  214. package/dist/test_memory_orchestrator.js +33 -0
  215. package/dist/test_memory_promotion.js +36 -0
  216. package/dist/test_memory_retention.js +37 -0
  217. package/dist/test_mission_checkpoint.js +204 -0
  218. package/dist/test_multi_host_docs_parity.js +125 -0
  219. package/dist/test_openlife_auto_creator_routing.js +69 -0
  220. package/dist/test_openlife_evolution_surface.js +77 -0
  221. package/dist/test_openlife_gatekeeper_routing.js +15 -0
  222. package/dist/test_openlife_routing_surface.js +27 -0
  223. package/dist/test_openlife_runtime_source_truth.js +25 -0
  224. package/dist/test_operating_system.js +45 -0
  225. package/dist/test_optimization_loop.js +38 -0
  226. package/dist/test_orchestration_assets_lifecycle.js +78 -0
  227. package/dist/test_outcome_simulator.js +38 -0
  228. package/dist/test_performance_latency.js +215 -0
  229. package/dist/test_performance_scorecard.js +38 -0
  230. package/dist/test_phase1_check_exit.js +103 -0
  231. package/dist/test_phase6_board.js +31 -0
  232. package/dist/test_phase6_cadence.js +29 -0
  233. package/dist/test_phase6_ops.js +37 -0
  234. package/dist/test_post_mission_evaluation.js +190 -0
  235. package/dist/test_process_sandbox.js +88 -0
  236. package/dist/test_profile_toolset_mcp.js +125 -0
  237. package/dist/test_queue_scheduler.js +239 -0
  238. package/dist/test_release_gate.js +23 -0
  239. package/dist/test_remote_publish.js +193 -0
  240. package/dist/test_reversa_contracts_e2e.js +48 -0
  241. package/dist/test_reversa_export_and_strict.js +51 -0
  242. package/dist/test_reversa_full_execution.js +12 -0
  243. package/dist/test_reversa_lite.js +9 -0
  244. package/dist/test_royal_stack_golden.js +179 -0
  245. package/dist/test_runtime_health_backoff.js +154 -0
  246. package/dist/test_runtime_policy.js +26 -0
  247. package/dist/test_runtime_probe.js +19 -0
  248. package/dist/test_runtime_profile_oauth_only.js +262 -0
  249. package/dist/test_runtime_registry.js +11 -0
  250. package/dist/test_security_download_and_scan.js +103 -0
  251. package/dist/test_security_download_guard.js +14 -0
  252. package/dist/test_service_command_surface.js +12 -0
  253. package/dist/test_service_completion_policy.js +32 -0
  254. package/dist/test_service_guardrails_delete.js +12 -0
  255. package/dist/test_service_mode_explicit_only.js +174 -0
  256. package/dist/test_sources_import_ref.js +46 -0
  257. package/dist/test_sources_scaffold.js +43 -0
  258. package/dist/test_squad_skill_creator.js +305 -0
  259. package/dist/test_squad_skill_design_llm.js +176 -0
  260. package/dist/test_subsystems_org_state.js +271 -0
  261. package/dist/test_subsystems_promotion_memory_assets.js +343 -0
  262. package/dist/test_subsystems_routing_governance.js +234 -0
  263. package/dist/test_task_executor_sandbox_optin.js +127 -0
  264. package/dist/test_teammate_learning.js +15 -0
  265. package/dist/test_telegram_delete_guardrail.js +21 -0
  266. package/dist/test_toolset_enforcement.js +188 -0
  267. package/dist/test_trigger_basic_auth.js +112 -0
  268. package/dist/test_util/doc_parity.js +120 -0
  269. package/dist/test_v15_e2e_integration.js +207 -0
  270. package/dist/test_watchdog_heartbeat.js +152 -0
  271. package/dist/test_workflow_condition_parser.js +63 -0
  272. package/dist/test_workflow_e2e.js +240 -0
  273. package/dist/test_workflow_engine.js +330 -0
  274. package/dist/test_workflow_parser.js +245 -0
  275. package/dist/test_workflow_schema_backward_compat.js +197 -0
  276. package/dist-templates/README.md +91 -0
  277. package/dist-templates/claude-code/agents/openlife-atlas.md +52 -0
  278. package/dist-templates/claude-code/agents/openlife-forge.md +42 -0
  279. package/dist-templates/claude-code/agents/openlife-genesis.md +59 -0
  280. package/dist-templates/claude-code/agents/openlife-lyra.md +40 -0
  281. package/dist-templates/claude-code/agents/openlife-maestro.md +45 -0
  282. package/dist-templates/claude-code/commands/openlife/ask.md +14 -0
  283. package/dist-templates/claude-code/commands/openlife/doctor.md +19 -0
  284. package/dist-templates/claude-code/commands/openlife/dream.md +20 -0
  285. package/dist-templates/claude-code/commands/openlife/status.md +14 -0
  286. package/dist-templates/claude-code/mcp/openlife-orchestrator.json +46 -0
  287. package/dist-templates/codex/README.md +7 -0
  288. package/dist-templates/codex/agents/openlife-atlas.md +52 -0
  289. package/dist-templates/codex/agents/openlife-forge.md +42 -0
  290. package/dist-templates/codex/agents/openlife-genesis.md +59 -0
  291. package/dist-templates/codex/agents/openlife-lyra.md +40 -0
  292. package/dist-templates/codex/agents/openlife-maestro.md +45 -0
  293. package/dist-templates/codex/commands/openlife/ask.md +14 -0
  294. package/dist-templates/codex/commands/openlife/doctor.md +19 -0
  295. package/dist-templates/codex/commands/openlife/dream.md +20 -0
  296. package/dist-templates/codex/commands/openlife/status.md +14 -0
  297. package/dist-templates/codex/mcp/openlife-orchestrator.json +46 -0
  298. package/dist-templates/gemini-cli/README.md +8 -0
  299. package/dist-templates/gemini-cli/agents/openlife-atlas.md +52 -0
  300. package/dist-templates/gemini-cli/agents/openlife-forge.md +42 -0
  301. package/dist-templates/gemini-cli/agents/openlife-genesis.md +59 -0
  302. package/dist-templates/gemini-cli/agents/openlife-lyra.md +40 -0
  303. package/dist-templates/gemini-cli/agents/openlife-maestro.md +45 -0
  304. package/dist-templates/gemini-cli/commands/openlife/ask.md +14 -0
  305. package/dist-templates/gemini-cli/commands/openlife/doctor.md +19 -0
  306. package/dist-templates/gemini-cli/commands/openlife/dream.md +20 -0
  307. package/dist-templates/gemini-cli/commands/openlife/status.md +14 -0
  308. package/dist-templates/gemini-cli/mcp/openlife-orchestrator.json +46 -0
  309. package/dist-templates/skill-template/README.md +34 -0
  310. package/dist-templates/skill-template/SKILL.md.template +59 -0
  311. package/dist-templates/squad-template/README.md +82 -0
  312. package/dist-templates/squad-template/SQUAD.md.template +51 -0
  313. package/dist-templates/squad-template/agent-template.md +51 -0
  314. package/dist-templates/squad-template/checklist-template.md +25 -0
  315. package/dist-templates/squad-template/task-template.md +36 -0
  316. package/dist-templates/workflows/PORTED_WORKFLOWS.md +60 -0
  317. package/dist-templates/workflows/brownfield-discovery.yaml +137 -0
  318. package/dist-templates/workflows/greenfield-fullstack.yaml +132 -0
  319. package/dist-templates/workflows/qa-loop.yaml +125 -0
  320. package/dist-templates/workflows/story-development-cycle.yaml +80 -0
  321. package/docs/CHANGELOG_FEATURE_ROLLOUT_DESIGNMD.md +43 -0
  322. package/docs/EXTERNAL_SOURCES_AND_SECURITY_GUARD.md +33 -0
  323. package/docs/OPENLIFE_AUDIT_2026-05-06.md +170 -0
  324. package/docs/OPENLIFE_CONSOLIDATED_PLAN_2026-05-06.md +299 -0
  325. package/docs/OPENLIFE_DUAL_MODE_IMPLEMENTATION_PLAN.md +205 -0
  326. package/docs/OPENLIFE_EVOLUTION_SURFACE_2026-05-07.md +53 -0
  327. package/docs/OPENLIFE_SKILLS_IMPORT_2026-05-07.json +223 -0
  328. package/docs/OPENLIFE_SQUADS_IMPORT_2026-05-07.json +184 -0
  329. package/docs/PAPERCLIP_OPENLIFE_INVESTIGATION.md +85 -0
  330. package/docs/README.md +28 -0
  331. package/docs/RELEASE_ORGANIZATION_PLAN.md +164 -0
  332. package/docs/audit/CLI-EXECUTION-RESULTS.md +113 -0
  333. package/docs/audit/CLI-MATRIX.md +556 -0
  334. package/docs/audit/DOC-PARITY-GAPS.md +351 -0
  335. package/docs/audit/ORCHESTRATOR-MATRIX.md +136 -0
  336. package/docs/audit/TEST-COVERAGE-GAPS.md +334 -0
  337. package/docs/audit/integrations/SKIPPED.md +101 -0
  338. package/docs/autonomous-install.md +79 -0
  339. package/docs/capability-genesis.md +137 -0
  340. package/docs/capability-pack-schema.md +157 -0
  341. package/docs/commands.md +82 -0
  342. package/docs/deep-research-capability.md +114 -0
  343. package/docs/development/typescript-conventions.md +95 -0
  344. package/docs/host-installers.md +68 -0
  345. package/docs/install/aiobuilder.md +70 -0
  346. package/docs/install/claude-code.md +83 -0
  347. package/docs/install/codex.md +64 -0
  348. package/docs/install/gemini-cli.md +64 -0
  349. package/docs/install/runtime-profiles.md +83 -0
  350. package/docs/openlife-agent-os-blueprint.md +114 -0
  351. package/docs/openlife-install-backlog.md +115 -0
  352. package/docs/openlife-install-spec.md +306 -0
  353. package/docs/operations/CLOUD_CUTOVER_AUDIT.md +37 -0
  354. package/docs/operations/PHASE_PROGRESS_CONTINUATION.md +24 -0
  355. package/docs/performance-benchmarks.md +83 -0
  356. package/docs/planning/v1.3-capability-genesis.md +157 -0
  357. package/docs/plans/2026-05-05-admin-interface-professional-dark-premium-plan.md +84 -0
  358. package/docs/plans/2026-05-05-openlife-autonomous-domain-marketplace-masterplan.md +122 -0
  359. package/docs/quickstart.md +60 -0
  360. package/docs/release-process.md +236 -0
  361. package/docs/roadmap/OPENLIFE_MASTER_PLAN_CLOUD_V3.md +97 -0
  362. package/docs/sandboxing-research.md +117 -0
  363. package/docs/stories/epic-feature-audit/1.1.story.md +84 -0
  364. package/docs/stories/epic-feature-audit/1.2.story.md +102 -0
  365. package/docs/stories/epic-feature-audit/1.3.story.md +93 -0
  366. package/docs/stories/epic-feature-audit/1.5.story.md +121 -0
  367. package/docs/stories/epic-feature-audit/1.6.story.md +80 -0
  368. package/docs/stories/epic-feature-completeness/2.1.story.md +70 -0
  369. package/docs/stories/epic-feature-completeness/2.2.story.md +49 -0
  370. package/docs/stories/epic-feature-completeness/2.3.story.md +74 -0
  371. package/docs/stories/epic-feature-completeness/2.4.story.md +71 -0
  372. package/docs/stories/epic-feature-completeness/3.1.story.md +56 -0
  373. package/docs/stories/epic-feature-completeness/3.2.story.md +80 -0
  374. package/docs/stories/epic-feature-completeness/3.3.story.md +68 -0
  375. package/docs/stories/epic-feature-completeness/3.4.story.md +71 -0
  376. package/docs/stories/epic-feature-completeness/3.5.story.md +72 -0
  377. package/docs/stories/epic-feature-completeness/3.6.story.md +69 -0
  378. package/docs/stories/epic-feature-completeness/3.7.story.md +68 -0
  379. package/docs/stories/epic-feature-completeness/3.8.story.md +57 -0
  380. package/docs/toolset-enforcement.md +122 -0
  381. package/docs/v1.4-changelog.md +159 -0
  382. package/docs/v1.5-changelog.md +106 -0
  383. package/docs/v1.5-roadmap.md +121 -0
  384. package/docs/v1.6-changelog.md +67 -0
  385. package/docs/v1.6-roadmap.md +89 -0
  386. package/docs/v1.7-changelog.md +98 -0
  387. package/docs/workflow-schema.md +177 -0
  388. package/package.json +177 -0
  389. package/scripts/clean-test-pollution.js +61 -0
  390. package/scripts/openlife-agent-start.sh +6 -0
  391. package/scripts/openlife-agent.service.example +13 -0
  392. package/scripts/openlife-agent.supervisord.conf.example +8 -0
  393. package/scripts/openlife-autonomous-install.sh +29 -0
  394. package/scripts/postinstall-check.sh +37 -0
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ /**
37
+ * Phase 3 — SUB-06 (Org/teams lifecycle) + SUB-07 (State persistence) round-trip tests.
38
+ *
39
+ * Uses snapshot-and-restore to leave .artifacts/ and .openlife/ byte-identical to the pre-test state.
40
+ * All entities use a TEST_PREFIX so they cannot collide with real data.
41
+ */
42
+ const fs = __importStar(require("fs"));
43
+ const path = __importStar(require("path"));
44
+ const OrgStructure_1 = require("./orchestrator/OrgStructure");
45
+ const TeammateBoard_1 = require("./orchestrator/TeammateBoard");
46
+ const CadenceEngine_1 = require("./orchestrator/CadenceEngine");
47
+ const ExecutionBoard_1 = require("./orchestrator/ExecutionBoard");
48
+ const RoleHandoff_1 = require("./orchestrator/RoleHandoff");
49
+ const JobLifecycle_1 = require("./orchestrator/JobLifecycle");
50
+ const MissionState_1 = require("./orchestrator/MissionState");
51
+ const ServiceState_1 = require("./orchestrator/ServiceState");
52
+ const RuntimeRegistry_1 = require("./orchestrator/RuntimeRegistry");
53
+ const SubagentLifecycle_1 = require("./orchestrator/SubagentLifecycle");
54
+ const ExecutionState_1 = require("./orchestrator/ExecutionState");
55
+ const ROOT = process.cwd();
56
+ const TEST_PREFIX = `test-p3-${process.pid}-${Date.now()}`;
57
+ const TEST_WS = `${TEST_PREFIX}-ws`;
58
+ function assert(condition, message) {
59
+ if (!condition)
60
+ throw new Error(message);
61
+ }
62
+ function snap(filePath) {
63
+ const existed = fs.existsSync(filePath);
64
+ return {
65
+ filePath,
66
+ existed,
67
+ content: existed ? fs.readFileSync(filePath, 'utf-8') : null
68
+ };
69
+ }
70
+ function restore(s) {
71
+ if (s.existed && s.content !== null) {
72
+ fs.writeFileSync(s.filePath, s.content, 'utf-8');
73
+ }
74
+ else if (!s.existed && fs.existsSync(s.filePath)) {
75
+ fs.unlinkSync(s.filePath);
76
+ }
77
+ }
78
+ function removeIfMine(filePath) {
79
+ // Only remove if our prefix appears in the path itself.
80
+ if (filePath.includes(TEST_PREFIX) && fs.existsSync(filePath)) {
81
+ try {
82
+ const stat = fs.statSync(filePath);
83
+ if (stat.isDirectory()) {
84
+ fs.rmSync(filePath, { recursive: true, force: true });
85
+ }
86
+ else {
87
+ fs.unlinkSync(filePath);
88
+ }
89
+ }
90
+ catch {
91
+ /* ignore */
92
+ }
93
+ }
94
+ }
95
+ async function main() {
96
+ // Files we will mutate via shared registries (must snapshot+restore).
97
+ const sharedFiles = [
98
+ path.join(ROOT, '.artifacts', 'cadence-events.json'),
99
+ path.join(ROOT, '.artifacts', 'execution-board.json'),
100
+ path.join(ROOT, '.artifacts', 'role-handoffs.json'),
101
+ path.join(ROOT, '.openlife', 'org-structure.json')
102
+ ];
103
+ const snapshots = sharedFiles.map(snap);
104
+ // Per-workspace test dirs we create — fully removable.
105
+ const wsDir = path.join(ROOT, '.artifacts', 'workspaces', TEST_WS);
106
+ // Subagent lifecycle file (unique per test, env-overridable).
107
+ const subagentFile = path.join(ROOT, '.artifacts', `${TEST_PREFIX}-cloud-subagents.json`);
108
+ process.env.OPENLIFE_CLOUD_SUBAGENTS_FILE = subagentFile;
109
+ // Mission ids (unique to our prefix).
110
+ const missionId = `${TEST_PREFIX}-mission`;
111
+ const missionFile = path.join(ROOT, '.artifacts', 'missions', `${missionId}.json`);
112
+ try {
113
+ let cases = 0;
114
+ // ============ SUB-06 ============
115
+ // 1. OrgStructure — fetch defaults; assert non-empty.
116
+ const org = new OrgStructure_1.OrgStructure();
117
+ const roles = org.all();
118
+ assert(Array.isArray(roles) && roles.length > 0, 'OrgStructure.all should return non-empty list');
119
+ const cto = org.get('cto');
120
+ assert(cto?.id === 'cto', 'OrgStructure.get(cto) should return cto role');
121
+ cases++;
122
+ // 2. TeammateBoard — upsert + list.
123
+ const teammate = new TeammateBoard_1.TeammateBoardStore(TEST_WS);
124
+ const card = {
125
+ id: `${TEST_PREFIX}-card-1`,
126
+ workspaceId: TEST_WS,
127
+ owner: 'cto',
128
+ status: 'in_progress',
129
+ title: 'Test teammate card',
130
+ blockers: [],
131
+ comments: ['initial'],
132
+ updatedAt: new Date().toISOString()
133
+ };
134
+ teammate.upsert(card);
135
+ const teammateList = teammate.list();
136
+ assert(teammateList.some((c) => c.id === card.id && c.title === card.title), 'TeammateBoard.upsert should make the card discoverable in list()');
137
+ cases++;
138
+ // 3. CadenceEngine — schedule + getAll.
139
+ const cadence = new CadenceEngine_1.CadenceEngine();
140
+ const cadenceTitle = `${TEST_PREFIX}-review`;
141
+ const event = cadence.schedule('review', cadenceTitle, 'cto', `${TEST_PREFIX}-mission-ops`);
142
+ assert(event.id && event.status === 'scheduled', 'CadenceEngine.schedule should return scheduled event');
143
+ const cadenceList = cadence.getAll();
144
+ assert(cadenceList.some((e) => e.title === cadenceTitle), 'CadenceEngine.getAll should include the scheduled event');
145
+ cases++;
146
+ // 4. ExecutionBoard — add + getAll.
147
+ const board = new ExecutionBoard_1.ExecutionBoard();
148
+ const boardId = `${TEST_PREFIX}-board-1`;
149
+ board.add({
150
+ id: boardId,
151
+ title: 'Test board item',
152
+ ownerRole: 'cto',
153
+ status: 'queued',
154
+ priority: 'medium',
155
+ dependencies: [],
156
+ slaHours: 24,
157
+ notes: 'phase3 test'
158
+ });
159
+ const boardList = board.getAll();
160
+ assert(boardList.some((b) => b.id === boardId && b.status === 'queued'), 'ExecutionBoard.add should persist the item visible in getAll');
161
+ cases++;
162
+ // 5. RoleHandoff — create + getAll.
163
+ const handoff = new RoleHandoff_1.RoleHandoff();
164
+ const handoffId = `${TEST_PREFIX}-handoff-1`;
165
+ handoff.create({
166
+ id: handoffId,
167
+ fromRole: 'cpo',
168
+ toRole: 'cto',
169
+ missionId: boardId,
170
+ summary: 'Test handoff',
171
+ status: 'queued'
172
+ });
173
+ const handoffList = handoff.getAll();
174
+ assert(handoffList.some((h) => h.id === handoffId && h.summary === 'Test handoff'), 'RoleHandoff.create should persist record visible in getAll');
175
+ cases++;
176
+ // ============ SUB-07 ============
177
+ // 6. JobLifecycle — enqueue → transition → get/events round-trip.
178
+ const jobs = new JobLifecycle_1.JobLifecycleStore(TEST_WS);
179
+ const job = jobs.enqueue('phase3-state-test', TEST_WS);
180
+ jobs.transition(job.jobId, TEST_WS, 'started', 'started by test', 'agent-test');
181
+ const jobRead = jobs.get(job.jobId);
182
+ assert(jobRead !== null, 'JobLifecycleStore.get should round-trip the job');
183
+ assert(jobRead.jobId === job.jobId, 'jobId should round-trip');
184
+ assert(jobRead.goal === 'phase3-state-test', 'goal should round-trip');
185
+ assert(jobRead.status === 'started', 'transition should be persisted');
186
+ const evts = jobs.events(job.jobId);
187
+ assert(evts.length >= 2, 'JobLifecycleStore.events should record enqueue+transition');
188
+ cases++;
189
+ // 7. MissionState — persist + read raw JSON round-trip.
190
+ const missionStore = new MissionState_1.MissionStateStore();
191
+ const exec = (0, ExecutionState_1.createExecutionState)(missionId, 'phase3 mission goal', 'test-user');
192
+ const mission = {
193
+ ...exec,
194
+ workspaceId: TEST_WS,
195
+ mode: 'task',
196
+ chosenAgents: [],
197
+ chosenSquads: [],
198
+ chosenSkills: [],
199
+ routeMode: 'single',
200
+ memoryCandidates: []
201
+ };
202
+ const persistPath = missionStore.persist(mission);
203
+ assert(fs.existsSync(persistPath), 'MissionStateStore.persist should write a file');
204
+ const reread = JSON.parse(fs.readFileSync(persistPath, 'utf-8'));
205
+ assert(reread.taskId === mission.taskId, 'MissionState.taskId round-trip');
206
+ assert(reread.goal === mission.goal, 'MissionState.goal round-trip');
207
+ assert(reread.mode === 'task', 'MissionState.mode round-trip');
208
+ cases++;
209
+ // 8. ServiceState — promoteTaskToService + getById round-trip.
210
+ const services = new ServiceState_1.ServiceStateStore(TEST_WS);
211
+ const serviceId = `${TEST_PREFIX}-svc`;
212
+ const svc = services.promoteTaskToService(mission, serviceId, 'phase3 service objective', {
213
+ actor: 'phase3-test',
214
+ consentScope: 'task_promotion',
215
+ reason: 'subsystems regression test',
216
+ });
217
+ assert(svc.serviceId === serviceId, 'ServiceState.promoteTaskToService returns matching serviceId');
218
+ const svcRead = services.getById(serviceId);
219
+ assert(svcRead !== null, 'ServiceState.getById should round-trip');
220
+ assert(svcRead.objective === 'phase3 service objective', 'ServiceState.objective round-trip');
221
+ assert(svcRead.missionIds.includes(mission.taskId), 'ServiceState.missionIds should include promoted mission');
222
+ cases++;
223
+ // 9. RuntimeRegistry — probe + list round-trip.
224
+ const runtime = new RuntimeRegistry_1.RuntimeRegistry(TEST_WS);
225
+ const probed = runtime.probe();
226
+ assert(probed.length >= 1, 'RuntimeRegistry.probe should return at least one entry');
227
+ assert(probed.some((e) => e.id === 'local-shell' && e.available === true), 'local-shell should be available');
228
+ const listed = runtime.list();
229
+ assert(listed.length === probed.length, 'RuntimeRegistry.list should round-trip probe result');
230
+ assert(listed.every((e, i) => e.id === probed[i].id && e.kind === probed[i].kind), 'RuntimeRegistry list entries should deep-equal probe (id+kind)');
231
+ cases++;
232
+ // 10. SubagentLifecycle — create + transition + list round-trip.
233
+ const subagents = new SubagentLifecycle_1.SubagentLifecycle(subagentFile);
234
+ const sub = subagents.create(`${TEST_PREFIX}-sub`, ['cap-a', 'cap-b']);
235
+ assert(sub.state === 'proposed', 'New subagent should be in proposed state');
236
+ const transitioned = subagents.transition(sub.id, 'trial');
237
+ assert(transitioned?.state === 'trial', 'SubagentLifecycle.transition proposed→trial should succeed');
238
+ const subList = subagents.list();
239
+ const found = subList.find((s) => s.id === sub.id);
240
+ assert(found !== undefined, 'SubagentLifecycle.list should round-trip created subagent');
241
+ assert(found.name === sub.name, 'subagent.name round-trip');
242
+ assert(JSON.stringify(found.capabilities) === JSON.stringify(sub.capabilities), 'capabilities round-trip');
243
+ assert(found.state === 'trial', 'persisted state reflects transition');
244
+ cases++;
245
+ // 11. ExecutionState — factory round-trip (in-memory; no persistence of its own).
246
+ const es = (0, ExecutionState_1.createExecutionState)(`${TEST_PREFIX}-exec`, 'goal-x', 'user-x');
247
+ assert(es.taskId === `${TEST_PREFIX}-exec`, 'createExecutionState.taskId');
248
+ assert(es.status === 'running', 'createExecutionState.status default running');
249
+ assert(Array.isArray(es.attempts) && es.attempts.length === 0, 'attempts initially empty');
250
+ assert(Array.isArray(es.governanceEvents), 'governanceEvents initialised');
251
+ cases++;
252
+ console.log(`TEST_SUBSYSTEMS_ORG_STATE cases=${cases}`);
253
+ console.log('TEST_SUBSYSTEMS_ORG_STATE_OK');
254
+ }
255
+ finally {
256
+ // === Cleanup hygiene ===
257
+ // 1. Restore shared snapshots so any test-prefixed entries we appended are wiped.
258
+ for (const s of snapshots) {
259
+ restore(s);
260
+ }
261
+ // 2. Remove per-test artefacts.
262
+ removeIfMine(wsDir);
263
+ removeIfMine(subagentFile);
264
+ removeIfMine(missionFile);
265
+ delete process.env.OPENLIFE_CLOUD_SUBAGENTS_FILE;
266
+ }
267
+ }
268
+ main().catch((err) => {
269
+ console.error('TEST_SUBSYSTEMS_ORG_STATE_FAIL:', err?.message || err);
270
+ process.exit(1);
271
+ });
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+ /**
3
+ * SUB-08, SUB-09, SUB-10 — consolidated subsystem tests
4
+ *
5
+ * SUB-08: Promotion/scoring (AgentScoring, SkillScoring, SquadScoring,
6
+ * PerformanceScorecard, ArbitrationScorecard, PromotionPipeline,
7
+ * PromotionReviewGate, AssetPromotionEngine)
8
+ * SUB-09: Memory layer (LocalMemoryProvider live, Mem0/Mempalace/Redis/Zep
9
+ * construct-only, OmniMemory facade routes to injected orchestrator)
10
+ * SUB-10: Asset providers (File/Cloud/Composite × Agent/Skill/Squad)
11
+ */
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ const fs = __importStar(require("fs"));
47
+ const os = __importStar(require("os"));
48
+ const path = __importStar(require("path"));
49
+ const AgentScoring_1 = require("./orchestrator/AgentScoring");
50
+ const SkillScoring_1 = require("./orchestrator/SkillScoring");
51
+ const SquadScoring_1 = require("./orchestrator/SquadScoring");
52
+ const PerformanceScorecard_1 = require("./orchestrator/PerformanceScorecard");
53
+ const ArbitrationScorecard_1 = require("./orchestrator/ArbitrationScorecard");
54
+ const PromotionPipeline_1 = require("./orchestrator/PromotionPipeline");
55
+ const PromotionReviewGate_1 = require("./orchestrator/PromotionReviewGate");
56
+ const AssetPromotionEngine_1 = require("./orchestrator/AssetPromotionEngine");
57
+ const LocalMemoryProvider_1 = require("./memory/LocalMemoryProvider");
58
+ const Mem0Provider_1 = require("./memory/Mem0Provider");
59
+ const MempalaceProvider_1 = require("./memory/MempalaceProvider");
60
+ const RedisAgentMemoryProvider_1 = require("./memory/RedisAgentMemoryProvider");
61
+ const ZepGraphitiProvider_1 = require("./memory/ZepGraphitiProvider");
62
+ const OmniMemory_1 = require("./memory/OmniMemory");
63
+ const FileAgentProvider_1 = require("./orchestrator/providers/FileAgentProvider");
64
+ const CloudAgentProvider_1 = require("./orchestrator/providers/CloudAgentProvider");
65
+ const CompositeAgentProvider_1 = require("./orchestrator/providers/CompositeAgentProvider");
66
+ const FileSkillProvider_1 = require("./orchestrator/providers/FileSkillProvider");
67
+ const CloudSkillProvider_1 = require("./orchestrator/providers/CloudSkillProvider");
68
+ const CompositeSkillProvider_1 = require("./orchestrator/providers/CompositeSkillProvider");
69
+ const FileSquadProvider_1 = require("./orchestrator/providers/FileSquadProvider");
70
+ const CloudSquadProvider_1 = require("./orchestrator/providers/CloudSquadProvider");
71
+ const CompositeSquadProvider_1 = require("./orchestrator/providers/CompositeSquadProvider");
72
+ function assert(cond, msg) {
73
+ if (!cond)
74
+ throw new Error(msg);
75
+ }
76
+ function makeTempDir(prefix) {
77
+ return fs.mkdtempSync(path.join(os.tmpdir(), `openlife-${prefix}-`));
78
+ }
79
+ // --------------------------------------------------------------------------
80
+ // SUB-08 — Scoring & Promotion
81
+ // --------------------------------------------------------------------------
82
+ async function testAgentScoring() {
83
+ const scoring = new AgentScoring_1.AgentScoring();
84
+ const id = `test-agent-${Date.now()}`;
85
+ scoring.record(id, 'success');
86
+ scoring.record(id, 'success');
87
+ scoring.record(id, 'failed');
88
+ const got = scoring.get(id);
89
+ assert(got, 'AGENT_SCORE_NOT_PERSISTED');
90
+ assert(got.successes === 2 && got.failures === 1, `AGENT_SCORE_COUNTS_WRONG: ${JSON.stringify(got)}`);
91
+ // 2*2 + 0*0.5 - 1*1.5 = 2.5
92
+ assert(Math.abs(got.score - 2.5) < 1e-6, `AGENT_SCORE_FORMULA_WRONG: ${got.score}`);
93
+ }
94
+ async function testSkillAndSquadScoring() {
95
+ const skill = new SkillScoring_1.SkillScoring();
96
+ const sid = `test-skill-${Date.now()}`;
97
+ skill.record(sid, 'partial');
98
+ const sAll = skill.getAll();
99
+ assert(sAll[sid] && sAll[sid].partials === 1, `SKILL_SCORE_FAIL: ${JSON.stringify(sAll[sid])}`);
100
+ assert(Math.abs(sAll[sid].score - 0.5) < 1e-6, `SKILL_SCORE_FORMULA: ${sAll[sid].score}`);
101
+ const squad = new SquadScoring_1.SquadScoring();
102
+ const qid = `test-squad-${Date.now()}`;
103
+ squad.record(qid, 'success');
104
+ const qAll = squad.getAll();
105
+ assert(qAll[qid] && qAll[qid].successes === 1, `SQUAD_SCORE_FAIL: ${JSON.stringify(qAll[qid])}`);
106
+ assert(Math.abs(qAll[qid].score - 2) < 1e-6, `SQUAD_SCORE_FORMULA: ${qAll[qid].score}`);
107
+ }
108
+ async function testPerformanceScorecard() {
109
+ const card = new PerformanceScorecard_1.PerformanceScorecard();
110
+ const id = `perf-entity-${Date.now()}`;
111
+ card.record({ entityId: id, entityType: 'agent', status: 'success', durationMs: 1000, reviewScore: 4, fallbackUsed: false, timestamp: new Date().toISOString() });
112
+ card.record({ entityId: id, entityType: 'agent', status: 'failed', durationMs: 2000, reviewScore: 2, fallbackUsed: true, timestamp: new Date().toISOString() });
113
+ const got = card.get(id);
114
+ assert(got, 'PERF_NOT_PERSISTED');
115
+ assert(got.runs === 2, `PERF_RUN_COUNT: ${got.runs}`);
116
+ assert(typeof got.score === 'number' && Number.isFinite(got.score), `PERF_SCORE_TYPE: ${got.score}`);
117
+ }
118
+ async function testArbitrationScorecard() {
119
+ const card = new ArbitrationScorecard_1.ArbitrationScorecard();
120
+ const branches = [
121
+ 'curto',
122
+ 'esta é uma resposta um pouco mais elaborada com várias frases\ne uma quebra de linha',
123
+ 'X'.repeat(900)
124
+ ];
125
+ const scored = card.score(branches);
126
+ assert(scored.length === 3, `ARB_LENGTH: ${scored.length}`);
127
+ for (const s of scored) {
128
+ assert(typeof s.finalScore === 'number' && Number.isFinite(s.finalScore), `ARB_SCORE_NAN: ${JSON.stringify(s)}`);
129
+ assert(s.relevance >= 0 && s.relevance <= 10, `ARB_RELEVANCE_RANGE: ${s.relevance}`);
130
+ assert(s.clarity >= 0 && s.clarity <= 10, `ARB_CLARITY_RANGE: ${s.clarity}`);
131
+ }
132
+ // Longer branch should not score lower than the shortest.
133
+ assert(scored[2].finalScore >= scored[0].finalScore, `ARB_ORDER_REGRESSION: ${scored[0].finalScore} vs ${scored[2].finalScore}`);
134
+ }
135
+ async function testPromotionPipelineAndGate() {
136
+ const pipeline = new PromotionPipeline_1.PromotionPipeline();
137
+ const gate = new PromotionReviewGate_1.PromotionReviewGate();
138
+ const candidate = {
139
+ id: `cand-${Date.now()}`,
140
+ type: 'playbook',
141
+ sourceMissionId: 'mission-test-001',
142
+ summary: 'Resumo deterministico com mais de vinte caracteres para aprovacao.',
143
+ createdAt: new Date().toISOString()
144
+ };
145
+ const shortCandidate = { ...candidate, id: candidate.id + '-short', summary: 'curto' };
146
+ assert(gate.approve(candidate) === true, 'GATE_SHOULD_APPROVE_VALID');
147
+ assert(gate.approve(shortCandidate) === false, 'GATE_SHOULD_REJECT_SHORT');
148
+ pipeline.add(candidate);
149
+ const all = pipeline.getAll();
150
+ assert(all.some(c => c.id === candidate.id), 'PIPELINE_NOT_PERSISTED');
151
+ }
152
+ async function testAssetPromotionEngine() {
153
+ const engine = new AssetPromotionEngine_1.AssetPromotionEngine();
154
+ const cand = {
155
+ id: `promo-${Date.now()}`,
156
+ type: 'agent',
157
+ sourceMissionId: 'mission-promo-001',
158
+ summary: 'Agente promovido para teste deterministico',
159
+ createdAt: new Date().toISOString()
160
+ };
161
+ const result = engine.promote(cand);
162
+ assert(result.id === cand.id, 'PROMO_ID_MISMATCH');
163
+ assert(fs.existsSync(result.filePath), `PROMO_FILE_MISSING: ${result.filePath}`);
164
+ const body = fs.readFileSync(result.filePath, 'utf-8');
165
+ assert(body.includes(cand.summary), 'PROMO_FILE_MISSING_SUMMARY');
166
+ // cleanup
167
+ try {
168
+ fs.unlinkSync(result.filePath);
169
+ }
170
+ catch { /* ignore */ }
171
+ }
172
+ // --------------------------------------------------------------------------
173
+ // SUB-09 — Memory layer
174
+ // --------------------------------------------------------------------------
175
+ async function testLocalMemoryProviderRoundTrip() {
176
+ const tmp = makeTempDir('memlocal');
177
+ const provider = new LocalMemoryProvider_1.LocalMemoryProvider(tmp);
178
+ assert(provider.name() === 'local', 'LOCAL_NAME_WRONG');
179
+ const rec = {
180
+ id: 'mem-test-1',
181
+ type: 'semantic',
182
+ namespace: { project: 'openlife-test' },
183
+ content: 'unique sentinel phrase XOXOXO',
184
+ summary: 'sentinel summary',
185
+ tags: ['sentinel'],
186
+ createdAt: new Date().toISOString()
187
+ };
188
+ await provider.save(rec);
189
+ const hits = await provider.search({ query: 'XOXOXO' });
190
+ assert(hits.length === 1, `LOCAL_SEARCH_LEN: ${hits.length}`);
191
+ assert(hits[0].content === rec.content, 'LOCAL_SEARCH_CONTENT_MISMATCH');
192
+ // namespace filter respected
193
+ const miss = await provider.search({ query: 'XOXOXO', namespace: { project: 'other' } });
194
+ assert(miss.length === 0, `LOCAL_NAMESPACE_FILTER_LEAK: ${miss.length}`);
195
+ }
196
+ async function testNetworkMemoryProvidersConstructible() {
197
+ const mem0 = new Mem0Provider_1.Mem0Provider();
198
+ const palace = new MempalaceProvider_1.MempalaceProvider('/nonexistent/path');
199
+ const redis = new RedisAgentMemoryProvider_1.RedisAgentMemoryProvider();
200
+ const zep = new ZepGraphitiProvider_1.ZepGraphitiProvider();
201
+ assert(mem0.name() === 'mem0', 'MEM0_NAME');
202
+ assert(palace.name() === 'mempalace', 'MEMPALACE_NAME');
203
+ assert(redis.name() === 'redis-ams', 'REDIS_NAME');
204
+ assert(zep.name() === 'zep-graphiti', 'ZEP_NAME');
205
+ // All search() implementations must return safely without throwing — no network calls.
206
+ const probe = { query: 'no-network-probe' };
207
+ for (const [label, p] of [['mem0', mem0], ['redis', redis], ['zep', zep]]) {
208
+ const r = await p.search(probe);
209
+ assert(Array.isArray(r) && r.length === 0, `${label.toUpperCase()}_SEARCH_NOT_EMPTY`);
210
+ }
211
+ // Save() is a no-op for stub providers; must not throw.
212
+ const fake = { id: 'x', type: 'semantic', namespace: {}, content: 'x', createdAt: new Date().toISOString() };
213
+ await mem0.save(fake);
214
+ await redis.save(fake);
215
+ await zep.save(fake);
216
+ }
217
+ async function testOmniMemoryFacadeRouting() {
218
+ const omni = new OmniMemory_1.OmniMemory();
219
+ let searchCalls = 0;
220
+ let saveCalls = 0;
221
+ // Inject a fake orchestrator with the surface OmniMemory uses.
222
+ omni.orchestrator = {
223
+ search: async () => {
224
+ searchCalls++;
225
+ return [{ provider: 'fake', record: { content: 'routed-via-fake', summary: 'routed' } }];
226
+ },
227
+ save: async () => { saveCalls++; }
228
+ };
229
+ const out = await omni.search('anything');
230
+ assert(searchCalls === 1, `OMNI_SEARCH_NOT_ROUTED: ${searchCalls}`);
231
+ assert(out.includes('routed-via-fake') || out.includes('routed'), `OMNI_SEARCH_OUTPUT_WRONG: ${out}`);
232
+ // saveFact also writes evidence_log.md as a side effect — intercept by swapping orchestrator.
233
+ // We avoid writing real files by chdir'ing into a temp dir for this call.
234
+ const cwd = process.cwd();
235
+ const tmp = makeTempDir('omni');
236
+ process.chdir(tmp);
237
+ try {
238
+ await omni.saveFact('fato', { source_uri: 'test://x', timestamp: Date.now() });
239
+ assert(saveCalls === 1, `OMNI_SAVE_NOT_ROUTED: ${saveCalls}`);
240
+ assert(fs.existsSync(path.join(tmp, 'evidence_log.md')), 'OMNI_EVIDENCE_NOT_WRITTEN');
241
+ }
242
+ finally {
243
+ process.chdir(cwd);
244
+ }
245
+ }
246
+ // --------------------------------------------------------------------------
247
+ // SUB-10 — Asset providers
248
+ // --------------------------------------------------------------------------
249
+ async function testFileProvidersShapeStable() {
250
+ // Empty roots — must return [] without throwing.
251
+ const emptyAgent = new FileAgentProvider_1.FileAgentProvider([]).load();
252
+ const emptySkill = new FileSkillProvider_1.FileSkillProvider([]).load();
253
+ const emptySquad = new FileSquadProvider_1.FileSquadProvider('').load();
254
+ assert(Array.isArray(emptyAgent) && emptyAgent.length === 0, 'FILE_AGENT_EMPTY');
255
+ assert(Array.isArray(emptySkill) && emptySkill.length === 0, 'FILE_SKILL_EMPTY');
256
+ assert(Array.isArray(emptySquad) && emptySquad.length === 0, 'FILE_SQUAD_EMPTY');
257
+ // Populated fixture: agent .md, skill dir with SKILL.md, squad .md
258
+ const tmp = makeTempDir('fileprov');
259
+ // Agent
260
+ const agentDir = path.join(tmp, 'agents');
261
+ fs.mkdirSync(agentDir, { recursive: true });
262
+ fs.writeFileSync(path.join(agentDir, 'alpha.md'), 'name: Alpha\nrole: "tester"\ntags: [foo, bar]\n', 'utf-8');
263
+ const agents = new FileAgentProvider_1.FileAgentProvider([agentDir]).load();
264
+ assert(agents.length === 1 && agents[0].id === 'alpha', `FILE_AGENT_PARSE: ${JSON.stringify(agents)}`);
265
+ assert(agents[0].tags.includes('foo'), `FILE_AGENT_TAGS: ${JSON.stringify(agents[0].tags)}`);
266
+ // Skill
267
+ const skillRoot = path.join(tmp, 'skills');
268
+ const oneSkill = path.join(skillRoot, 'my-skill');
269
+ fs.mkdirSync(oneSkill, { recursive: true });
270
+ fs.writeFileSync(path.join(oneSkill, 'SKILL.md'), '<description>does a thing, also that thing</description>', 'utf-8');
271
+ const skills = new FileSkillProvider_1.FileSkillProvider([skillRoot]).load();
272
+ assert(skills.length === 1 && skills[0].id === 'my-skill', `FILE_SKILL_PARSE: ${JSON.stringify(skills)}`);
273
+ // Squad
274
+ const squadRoot = path.join(tmp, 'squads');
275
+ fs.mkdirSync(squadRoot, { recursive: true });
276
+ fs.writeFileSync(path.join(squadRoot, 'sq1.md'), '# Squad One\nDoes A, B.\n', 'utf-8');
277
+ const squads = new FileSquadProvider_1.FileSquadProvider(squadRoot).load();
278
+ assert(squads.length === 1, `FILE_SQUAD_LEN: ${squads.length}`);
279
+ assert(squads[0].id === 'sq1', `FILE_SQUAD_ID: ${squads[0].id}`);
280
+ }
281
+ async function testCloudProvidersConstructAndShape() {
282
+ // Without env vars / files, all cloud providers return [] (offline-safe).
283
+ const a = new CloudAgentProvider_1.CloudAgentProvider('').load();
284
+ const s = new CloudSkillProvider_1.CloudSkillProvider('').load();
285
+ const q = new CloudSquadProvider_1.CloudSquadProvider('').load();
286
+ assert(Array.isArray(a) && a.length === 0, 'CLOUD_AGENT_NOENV_EMPTY');
287
+ assert(Array.isArray(s) && s.length === 0, 'CLOUD_SKILL_NOENV_EMPTY');
288
+ assert(Array.isArray(q) && q.length === 0, 'CLOUD_SQUAD_NOENV_EMPTY');
289
+ // Methods present
290
+ assert(typeof new CloudAgentProvider_1.CloudAgentProvider('').load === 'function', 'CLOUD_AGENT_NO_LOAD');
291
+ assert(typeof new CloudSkillProvider_1.CloudSkillProvider('').load === 'function', 'CLOUD_SKILL_NO_LOAD');
292
+ assert(typeof new CloudSquadProvider_1.CloudSquadProvider('').load === 'function', 'CLOUD_SQUAD_NO_LOAD');
293
+ // Pointed at a real file containing records
294
+ const tmp = makeTempDir('cloud');
295
+ const agentFile = path.join(tmp, 'agents.json');
296
+ fs.writeFileSync(agentFile, JSON.stringify([{ id: 'cloudy', name: 'Cloudy', role: 'r', capabilities: [], sourcePath: agentFile, priority: 1, tags: [] }]), 'utf-8');
297
+ const loaded = new CloudAgentProvider_1.CloudAgentProvider(agentFile).load();
298
+ assert(loaded.length === 1 && loaded[0].id === 'cloudy', `CLOUD_AGENT_LOAD_FAIL: ${JSON.stringify(loaded)}`);
299
+ }
300
+ async function testCompositeProvidersChainPrimaryThenFallback() {
301
+ // Primary empty -> falls back to secondary
302
+ const primaryEmpty = { load: () => [] };
303
+ const fallbackAgents = { load: () => [{ id: 'fb', name: 'FB', role: 'r', capabilities: [], sourcePath: '/x', priority: 1, tags: [] }] };
304
+ const compositeAgent = new CompositeAgentProvider_1.CompositeAgentProvider(primaryEmpty, fallbackAgents).load();
305
+ assert(compositeAgent.length === 1 && compositeAgent[0].id === 'fb', `COMPOSITE_AGENT_FALLBACK: ${JSON.stringify(compositeAgent)}`);
306
+ // Primary non-empty -> fallback skipped
307
+ const primaryFull = { load: () => [{ id: 'pri', name: 'Pri', role: 'r', capabilities: [], sourcePath: '/y', priority: 1, tags: [] }] };
308
+ let fallbackCalled = false;
309
+ const fallbackSpy = { load: () => { fallbackCalled = true; return []; } };
310
+ const composite2 = new CompositeAgentProvider_1.CompositeAgentProvider(primaryFull, fallbackSpy).load();
311
+ assert(composite2.length === 1 && composite2[0].id === 'pri', 'COMPOSITE_AGENT_PRIMARY');
312
+ assert(fallbackCalled === false, 'COMPOSITE_AGENT_FALLBACK_LEAKED');
313
+ // Skill + Squad mirror the same shape
314
+ const skillComp = new CompositeSkillProvider_1.CompositeSkillProvider({ load: () => [] }, { load: () => [{ id: 's', name: 's', sourcePath: '/p', capabilities: [] }] }).load();
315
+ assert(skillComp.length === 1 && skillComp[0].id === 's', 'COMPOSITE_SKILL_FALLBACK');
316
+ const squadComp = new CompositeSquadProvider_1.CompositeSquadProvider({ load: () => [] }, { load: () => [{ id: 'sq', name: 'sq', sourcePath: '/p', domain: 'd', capabilities: [] }] }).load();
317
+ assert(squadComp.length === 1 && squadComp[0].id === 'sq', 'COMPOSITE_SQUAD_FALLBACK');
318
+ }
319
+ // --------------------------------------------------------------------------
320
+ // Entrypoint
321
+ // --------------------------------------------------------------------------
322
+ async function main() {
323
+ // SUB-08
324
+ await testAgentScoring();
325
+ await testSkillAndSquadScoring();
326
+ await testPerformanceScorecard();
327
+ await testArbitrationScorecard();
328
+ await testPromotionPipelineAndGate();
329
+ await testAssetPromotionEngine();
330
+ // SUB-09
331
+ await testLocalMemoryProviderRoundTrip();
332
+ await testNetworkMemoryProvidersConstructible();
333
+ await testOmniMemoryFacadeRouting();
334
+ // SUB-10
335
+ await testFileProvidersShapeStable();
336
+ await testCloudProvidersConstructAndShape();
337
+ await testCompositeProvidersChainPrimaryThenFallback();
338
+ console.log('TEST_SUBSYSTEMS_PROMOTION_MEMORY_ASSETS_OK');
339
+ }
340
+ main().catch((err) => {
341
+ console.error('TEST_SUBSYSTEMS_PROMOTION_MEMORY_ASSETS_FAIL:', err?.message || err);
342
+ process.exit(1);
343
+ });