Environment Variables

Environment variables

ℹ️

See the Souls section for instructions on how to set the environment at runtime.

The Soul Engine supports templated environment variables, either directly from the environment via the global soul.env or templated via the convience method $$(...). These can be used anywhere in a soul's Blueprint

import { useActions } from "@opensouls/engine"
 
const provesEnvironmentVariablesWork: MentalProcess = async ({ workingMemory }) => {
  log("liked things: " + JSON.stringify(soul.env.likedThings))
 
  speak($$("I like {{likedThings}}."))
 
  return workingMemory
}

Any environment variables used should have a default so that the web-based debugger will not have undefined state. These defaults are set in your /soul/default.env.ts file using a plain typescript object:

soul/default.env.ts
{
  entityName: "Bob",
  emotions: ["angry", "sad"],
  speakingStyle: {
    adjective: "witty",
  },
}

Additionally, the soul's markdown file (soul/[soul-name].md) is processed and supports templated entity name and context.

Instead of a file like soul/Samantha.md you could instead have soul/{{entityName}}.md where the contents are also templated:

soul/{{entiyName}}.md
You are modeling the mind of {{entityName}}.md
 
They have a speaking style of {{speakingStyle.adjective}}