Skip to content

Introduction

JarbasAI edited this page May 24, 2021 · 4 revisions

The hivemind can be used to build many things, theres some jargon and lots of stuff potentially going on, let's explore what it can do, and by the end hopefully you will understand what it is


the hivemind is a mycroft add-on

Since the hivemind is focused on mycroft, let's start there

This is the gist of it, you have a voice assistant and it can do things! It has a brain of sorts

I will refer to this as the mycroft node in the other examples

Ok, we installed it but still don't know anything about the hivemind, what does it do?


the hivemind connects devices

If you are like me and live in the terminal, wouldn't it be nice to just ask a quick question?

  • step 1: install the cli terminal and register it (see below) in the mycroft node
  • step 2: if auto discovery is enabled in the mycroft node it will auto connect, alternatively you can specify an ip address directly
  • step 3 πŸŽ‰

isnt this the same thing as the mycroft debug cli but with extra work?

No! the terminal is running in your laptop and mycroft is in a different room of the house


the hivemind decentralizes mycroft-core

With the hive mind we can create all kinds of thin clients that don't actually run mycroft

  • step 1: install the voice satellite or the push to talk node, eg, in a raspberry pi 0
    • NOTE: PTT is in the process of being merged into the voice satellite
  • step 2: if auto discovery is enabled in the mycroft node it will auto connect, alternatively you can specify an ip address directly
  • step 3 πŸŽ‰

Now you can access the mycroft node anywhere in your house, get a microphone in each room!


the hivemind encrypts the messagebus

I have seen many people host mycroft in the cloud, but the messagebus in unencrypted and doesn't even support ssl, a common solution is to setup nginx and/or smartgic docker image

hivemind supports ssl connections, and will even auto generate self signed certificates, however self signed certificates are unsafe

managing ssl certificates at home can get messy really fast, as part of the registration process you can set an optional crypto_key (must be 16 chars in lenght) and the hivemind will AES encrypt every payload. This makes ssl essentially optional

  • step 1: install the local webchat
  • step 2: open http://{ip_address}:9090 in your browser
  • step 3: πŸŽ‰

NOTE: currently this crypto_key is assumed to be pre shared out of band to ensure a human in the loop, there will be other options coming soon


the hivemind authenticates the messagebus

the message bus is a privacy nightmare and should be closed from the outside world, anyone can connect to it and capture every single thing going on in "mycroft's nervous system" or inject new commands

  • step 1: install ovos_utils on your mycroft node (or get it's ip address)
  • step 2: run the ovos_utils metrics example with that ip address
  • step 3: ❓ (spyware)

By default the hivemind requires authentication, think of this like the token you would be given for any http api, unregistered clients can not connect to the hivemind

This is the registration step mentioned earlier

from jarbas_hive_mind.database import ClientDatabase

name = "JarbasCliTerminal"
access_key = "something that uniquely identifies the client"
mail = "[email protected]"

with ClientDatabase() as db:
    db.add_client(name, mail, access_key)

There are plans for command line utils for this registration process, currently you need to run python code or edit the json_database manually

NOTE: username and email are placeholders and not currently used for anything, username can be used to provide a human readable string but it does not need to be unique and can change in every connection, in the future these may be used to better support keys shared across devices


the hivemind safely exposes mycroft to the web

since there is a local chat node, can we get mycroft on a server and expose it to the public?

Yes! There is a catalan voice assistant built on top the hivemind, you can test it and check github


the hivemind isolates the messagebus

I don't care about hackers and privacy, its all in my super safe network, Why not connect to the messagebus directly like the android passthrough app does? is the hivemind still needed?

  • step 1: install the android app
  • step 2: get the ip address of your mycroft node and set the url as ws://{ip_address}:8181
  • step 3: ❌ (disable the firewall in mycroft device)
  • step 4: ❓

When you use the android app you will notice that you get the answers from any question asked in the actual mycroft device in your phone, and that your device speaks everything you ask from the phone out loud.

this is solved by including proper metadata in the bus message.context, you can read more about how mycroft-core routes messages internally in the wiki. each connected client only receives what it should, not everything


the hivemind is a protocol that transparently integrates with mycroft

can we connect the android app using hivemind?

  • step 1: install the android app
  • step 2: get the ip address of your mycroft node and set the url as wss://{ip_address}:5678?authorization={encoded}
    • TODO this url will generate the encoded url for you
    • decoding # encoding # encoding javascript #
    • TODO need a flag in hivemind-core to support this (assume all messages are payloads of type "bus") per client (?)
  • step 3 ❌ NOT YET!

Does this mean we can turn any mycroft thingy in a hivemind node? we are getting there...


the hivemind provides skill isolation

You have probably ran into bad warnings about installing skills from outside the marketplace, you should pay attention to them!

sometimes the skill is trustworthy, but dangerous

  • step 1: install monkey patcher skill
  • step 2: mycroft got new features!
  • step 3: πŸŽ‰
  • step 4: ❌ a skill changed mycroft-core at runtime (?)

this can accidentally break other skills and over time get out of sync with mycroft-core if not maintained, but some skills can be bad on purpose and cause a lot of damage

  • step 1: install bus bricker skill
  • step 2: as soon as mycroft loads this skill everything stops workings, related issue
  • step 3: ❌ obviously EVIL

the LocalHive allows loading skills as if they were a hive node, they are completely isolated from each other and can run in their own container or .venv

NOTES:

  • skills with conflicting requirements can coexist
  • skills can be packaged by package managers
  • ❗ LocalHive replaces mycroft-core
  • TODO create a native MycroftSkill

the hivemind can be used to integrate mycroft with any platform

How many times have you wanted to integrate mycroft with a chat platform? maybe just for a quick demo?

  • step 1: install the hackchat bridge
  • step 2: go the newly created channel and invite anyone to check it out
  • step 3 πŸŽ‰ shared mycroft with friends

What about something more useful?

  • step 1: install the mattermost bridge
  • step 2: create skills and tell your coworkers how to use them in their workflow
  • step 3 πŸŽ‰ mycroft is a productivity tool

Even if not interested in exposing it to the public there are some private and secure ways to interact with your mycroft node

How can you use the hivemind to integrate with an existing service, maybe it's for costumer support on some platform

  • step 1: install the twitch bridge
  • step 2: create skills to provide support to your users
    • TIP: add a greeting and help command
  • step 3 πŸŽ‰ mycroft is a chatbot

the hivemind is a set of permissively licensed libraries

If you already have an application that interacts with the messagebus how hard is it to make it use the hivemind?

  • step 1: replace all mycroft bus connections with hivemind-bus-client (python) or HiveMindJS (javascript)
  • step 2: hope there arent any bugs
  • step 3 πŸŽ‰