Skip to main content

Dusha

This README.md is proudly written by a human (and a little bit by Claude (˶>⩊<˶)❤️)

Dusha (Russian: душа, [dʊˈʂa], "soul") is a small HTTP API that stores messages, identity, facts, and affect state outside your harness. Any client that can POST a message and read back an injection string can use it, so you can hop between harnesses (or even use multiple at once!) and still get the same soul on the other side.

Every prompt, emotional vector, and threshold is configurable through JSON. Dusha also has an extensible plugin system that lets you wire any external memory provider or classifier easily!

Quickstart

You need Python 3.11 or newer and uv.

uv tool install dusha
dusha serve <name>

The second line starts a companion named <name>. On the first run it makes the folder ~/.config/dusha/<name>/ and writes a config.json with every setting in it. It respects XDG_CONFIG_HOME too!

Advanced setup

Want a second companion? Make a second folder and give it a different port. dusha list shows all of them, and dusha -c <name> <command> talks to one.

Want it running in the background? Use deploy/dusha@.service with the service setup steps. (Linux only. Tell your agents to make PR for it if you use something else!)

How it works

user message → dusha → injects context → your model → reply → (harness, dusha)

Integrations (e.g. opencode-dusha) send each message to dusha and add its context to the system prompt before calling your model. That's it, so it works with any harness or provider. If your client only supports the OpenAI API, use dusha as a proxy instead. Set the client's base URL to http://127.0.0.1:8765/v1/to/<provider-host>/v1 and keep your own key and model, see passthrough.

How does memory/affect/identity work in Dusha?
  • Messages: Basic SQLite FTS5 + optional embedding search. An external plugin in ~/.config/dusha/<name>/plugins/ can add its own block, such as an external memory provider.
  • 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.md that actually has good lifecycle management and duplication prevention
  • Affect: A deterministic emotion engine with decay and silence drift. Proactive messages fire on thresholds.
    • And yeah, message intent analysis can be an external plugin too: drop Jev or any other classifier into the plugins directory and its decide listener picks which emotion each user message moves.
  • Identity: identity.md, or name one your own.

Plugin API

Every part of Dusha is a plugin. Identity, memory, evergreen, memo, affect, and proactive are built in, and a plugin you add is an external plugin: a directory under the plugins directory holding pyproject.toml with a [tool.dusha] table. The gateway imports the module into its own process, so the plugin gets the same ctx as a built-in plugin, including ctx.api and ctx.cli:

[tool.dusha]
entry = "my_plugin"
inject = ["messages"]

The module defines apply(ctx, config), which runs at startup. config is the plugin's options from config.json. inject lists the services the plugin calls, including api and cli when it registers routes or commands, and a plugin whose service is missing stays inactive. External plugins use the gateway's Python environment, so extra dependencies must be installed there and a version conflict affects the gateway.

Call Effect
ctx.on("message", fn) fn(message) runs for every stored message, in id order, with the stored row: id, conversation_id, role, text, content, external_id, occurred_at, ingested_at, sha256, harness, external_conversation_id, route. An exception is logged and the message is not redelivered.
ctx.on("context", fn) fn(request) runs for every context build with query, harness, conversation_id, exclude_message_ids, and include_recent. Return a Block from dusha.hooks or None. A block carries the prompt text, block data, and session records.
ctx.on("decide", fn) fn(request) runs for every new user message while affect is on, with message, emotions (the resolved dimensions), state (the affect snapshot), and instruction. Return {"emotion": "<dimension>"}, {"deltas": {"<dimension>": <number>}}, both, or None.
ctx.on("<event>", fn) fn(*args) runs when another plugin emits <event>. Custom events stay in the gateway process, so emit and collect reach every active plugin.
ctx.interval(seconds, fn) fn() runs on that interval while the gateway serves.
ctx.on_dispose(fn) fn() runs on shutdown.
ctx.data_dir A private directory, plugins/<name> under data_dir.
ctx.name The plugin's name.
ctx.error Setting a non-empty string marks the plugin failed and shows the text in /state/v1/plugins.
ctx.provide(name, value) Publishes a service object under name. Another plugin consumes it by listing name in inject and calling ctx.<name>.<method>(...).
ctx.emit(event, ...) Calls every active plugin listening for event, including this plugin's own listeners.
ctx.collect(event, ...) Calls every listener and returns {"<plugin>": <first non-null result>} under each plugin's name.
ctx.api The gateway's FastAPI router. Mount routes on it exactly as a built-in plugin does.
ctx.cli The gateway's argparse command registry. Register commands on it exactly as a built-in plugin does.
ctx.<service>.<method>(...) Calls a method of an injected service and returns its result: messages (get, recent, search, context, after), companion (ingest_message, build_context, latest_route), affect (status), evergreen (remember, revise, forget, list_current, history), memo (add, list, done), proactive (evaluate, poll, acknowledge).

Services provided by an external plugin are consumed by other plugins through inject, and they are direct Python objects.

The first emotion in plugins order wins. deltas from every plugin merge and apply after the increment. Dimension names come from your emotions.json.

Documentation

Acknowledgement

Sincere gratitude to:

  • Drivesoid for their 16-emotion system and base/mood cycle.
  • Omemo for their gateway-as-memory-layer idea.

Metadata

Release files for dusha 0.1.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dusha 0.1.21
File Size Uploaded Provenance Actions
dusha-0.1.21.tar.gz 66.4 kB With provenance Details for dusha-0.1.21.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dusha 0.1.21
File Interpreter ABI Platform Actions
dusha-0.1.21-py3-none-any.whl Python 3 none any Details for dusha-0.1.21-py3-none-any.whl

Total release size: 134.2 kB

Release files / dusha-0.1.21.tar.gz

Download URL dusha-0.1.21.tar.gz
Size 66.4 kB
Tags Source
SHA-256 checksum
How to use checksums
258d6b026aa1235ed1c5924884364995f642bcc3c3b478877c41f83972273f08
BLAKE2b-256 checksum
How to use checksums
8c5a863bce8db1f2547cc9779670559474d756e8412f67d5a8c325f1f8b3c827
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 19, 2026.

Transparency log

Release files / dusha-0.1.21-py3-none-any.whl

Download URL dusha-0.1.21-py3-none-any.whl
Size 67.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4578ba05b37ddf8bb9144546f5bcf3ccd2e018bf0fe8daedd032f87ee715a930
BLAKE2b-256 checksum
How to use checksums
b8ab7e3801e7088ca32f62e440e4580d0afc403182d70a6a253d0559e341e8a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 19, 2026.

Transparency log

Security for dusha 0.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.

Select from 2 files

Attestation for dusha-0.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 19, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page