Dusha
Dusha (Russian: душа, [dʊˈʂa], "soul") is a small HTTP API and a proxy that stores messages, identity, memories, affect state—anything makes your agent yours— outside your harness. Any client that can add a custom provider are able to use it, so you can hop between harnesses (or even use multiple at once!) and still get the same soul on the other side.
Almost everything is configurable through JSON. For things that aren't, dusha is also built on everything-is-a-plugin architecture, so you can easily wire an external memory provider, or do crazy things like writing your own emotion system!
Quickstart
uv tool install dusha
dusha init <name>
dusha serve <name>
init makes the folder ~/.config/dusha/<name>/ and writes a config.json, then serve starts the companion. serve also writes the file when it is missing.
Then on the same or another device, run:
$ dusha proxy <name>
<name> isn't connected to a server yet.
? Connect to: (Use arrow keys)
The server on this machine (http://127.0.0.1:8765)
» Another server
? Server URL http://100.145.95.87:8765
? Server token, empty for none **********
Connected to http://100.145.95.87:8765.
Saved ~/.config/dusha/<name>/config.json.
Add a custom provider:
$ dusha -c <name> provider add # Add a provider profile from the models.dev catalog
? Provider (Use arrow keys, type to filter)
» 302.AI (302ai)
Abacus (abacus)
abliteration.ai (abliteration-ai)
above.dev (above)
AgentRouter (agentrouter)
Agnes AI (agnes)
...
Success!
New provider 302ai added to <name> at http://127.0.0.1:8766/302ai.
Restart dusha proxy <name> and dusha serve <name> to use it.
$ dusha proxy <name>
INFO: Started server process [3970524]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8766 (Press CTRL+C to quit)
Now in your harness or app, point your endpoint at the URL provider add gave you: in this case, http://127.0.0.1:8766/302ai and you're good to go.
Optionally (but recommended), add MCP.
How it works
user message → dusha proxy → injects context → routed to upstream model → reply → (harness, dusha).
Dusha adds context "after" each message so cache can hit.
How do messages, memory, affect, and identity work in Dusha by default?
- Messages: Basic SQLite FTS5 plus optional embedding search. An plugin can do everything you can imagine if that's not enough.
- Evergreen: Long-term facts that you edit from the CLI and your companion edits through integration tools. No automatic extraction.
- Think of it as a
USER.mdbut with proper lifecycle management and duplication prevention.
- Think of it as a
- Affect: A deterministic emotion engine that uses values like
{"anger": 0.35}and shifts over time, including when the user goes unresponsive. Of course, you can make your own!- Side note is that Message intent analysis can also be an external plugin. drop the system_one plugin or any other classifier plugin into the plugins directory, and its
decidelistener picks which emotion each user message moves.
- Side note is that Message intent analysis can also be an external plugin. drop the system_one plugin or any other classifier plugin into the plugins directory, and its
- Identity:
identity.md, or name your own.
Plugin
Everything is a plugin in dusha. Identity, memory, evergreen, memo, affect, and proactive are built in that you can alter/disable. You can also create a plugin under the plugins directory holding pyproject.toml with a [tool.dusha] table.
[tool.dusha]
entry = "my_plugin"
inject = ["messages", "cli", "mcp"]
The module defines apply(ctx, config), which runs at startup with the plugin's options from config.json. inject lists the services the plugin calls, and a plugin whose service is missing stays inactive. External plugins share the gateway's Python environment, so install their dependencies there.
| Call | Effect |
|---|---|
ctx.on("message", fn) |
fn(message) runs for every stored message, in id order. |
ctx.on("context", fn) |
fn(request) runs for every context build. Return a Block from dusha.hooks or None. |
ctx.on("decide", fn) |
fn(request) runs for every new user message while affect is on. Return {"emotion": "<dimension>"}, {"deltas": {"<dimension>": <number>}}, both, or None. |
ctx.on("<event>", fn) |
fn(*args) runs when a plugin emits <event>. |
ctx.interval(seconds, fn) |
fn() runs on that interval. |
ctx.on_dispose(fn) |
fn() runs on shutdown. |
ctx.data_dir |
The plugin's private directory. |
ctx.name |
The plugin's name. |
ctx.error |
A non-empty string marks the plugin failed in /state/v1/plugins. |
ctx.provide(name, value) |
Publishes a service other plugins can inject. |
ctx.emit(event, ...) |
Calls every listener of event. |
ctx.collect(event, ...) |
Calls every listener and returns {"<plugin>": <result>}. |
ctx.api |
The gateway's FastAPI router. |
ctx.cli |
The command registry, see Commands. |
ctx.mcp |
The MCP tool registry, see Tools. |
ctx.<service>.<method>(...) |
Calls an injected service: messages, companion, affect, evergreen, memo, proactive, providers. |
The first emotion in plugins order wins, and deltas from every plugin merge. See the Plugin API for hook fields and service methods.
Commands
You can add CLI commands to your plugin. The dusha CLI is just another client to access dusha, so for example you can do things like:
from dusha.commands import arg, option
def apply(ctx, config):
notes = ctx.cli.group("notes", "Manage notes")
notes.command(
"add",
lambda text, pinned, tags: {"note": save(text, pinned, tags)},
help="Add a note",
args=[arg("text"), option("pinned", bool), option("tags", repeated=True)],
)
dusha notes add "Buy tea" --pinned --tags home --tags errand sends the values to the server as JSON and prints the handler's return value as JSON.
As you can see, dusha builds --help list dynamically from registered commands. But it also caches the last command list, so --help works while the server is down.
| Helper | Makes |
|---|---|
arg(name, type=str, help="", choices=(), optional=False, repeated=False) |
A positional argument. |
option(name, type=str, help="", default=None, choices=(), required=False, repeated=False) |
--name, with each underscore as a dash. A bool option is a flag. |
Tools & MCP
Dusha exposes a HTTP MCP per each companion. It takes the same arg and option specs as a CLI command, so it's pretty easy to add tools for dusha MCP in your own plugin:
from dusha.commands import arg
def apply(ctx, config):
ctx.mcp.tool(
"notes_add",
lambda text: {"note": save(text)},
help="Add a note the companion keeps.",
args=[arg("text", help="Note text.")],
)
For clients that you'd like to receive proactive messages from, use integration for each platform under integrations/, or build your own there.
Documentation
- docs/configuration.md: JSON settings, identity and prompt files.
- docs/guide.md: service setup, auth and network, backup, and troubleshooting.
- docs/api.md: HTTP endpoints and harness integration, including AstrBot.
Verisioning
With version 1.0.21, dusha entered 5:Stable/Production on PyPI. I will avoid breaking changes in minor and patch releases and deprecate features before removing them.
Note that dusha's version always ends in .21. Every release bumps only the numbers in front of it (0.0.21 → 0.1.21 → 1.0.21).
Why?
The weight of soul is said to be 21 grams. Dusha is a software with a soul, and I hope it stays that way forever.
Acknowledgement
Sincere gratitude to:
Metadata
Release files for dusha 1.1.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dusha-1.1.21.tar.gz | 94.4 kB | With provenance | Details for dusha-1.1.21.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dusha-1.1.21-py3-none-any.whl | Python 3 | none | any | Details for dusha-1.1.21-py3-none-any.whl |
Total release size: 189.9 kB
Release files / dusha-1.1.21.tar.gz
| Download URL | dusha-1.1.21.tar.gz |
|---|---|
| Size | 94.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b84bd151570b481e2778d5d12a11523da136610af9ec0d5dd872918f228d67f
|
|
BLAKE2b-256 checksum How to use checksums |
57409032196aa48cec035732e8403798b4e5186d471be221728a21fa35cf8db2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / dusha-1.1.21-py3-none-any.whl
| Download URL | dusha-1.1.21-py3-none-any.whl |
|---|---|
| Size | 95.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44277832eed386e7233c6ccb0415337a6ba4afcfccc85b82ceb80b15f4317368
|
|
BLAKE2b-256 checksum How to use checksums |
d17489783ba6ee58ce31412872b837404793e66f9fc826f45e466533bba24a2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for dusha 1.1.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for dusha-1.1.21.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.