supermemory-bash
A virtual bash environment for AI agents, backed by your Supermemory container. Files persist across sessions, and a built-in sgrep command does semantic search across the entire filesystem.
Contents
Install
pip install supermemory-bash
# or
uv add supermemory-bash
You'll need a Supermemory API key. Get one at supermemory.ai.
Quickstart
import asyncio
from supermemory_bash import create_bash
async def main():
result = await create_bash(
api_key="sm-...",
container_tag="user_42",
)
bash = result.bash
# Run any shell command:
r = await bash.exec("echo 'hello' > /a.md && cat /a.md")
print(r.stdout) # "hello\n"
# Files persist across sessions, even from a fresh process:
r2 = await bash.exec("cat /a.md")
print(r2.stdout) # "hello\n"
# Semantic search across the whole container:
r3 = await bash.exec("sgrep 'authentication tokens'")
print(r3.stdout)
# /work/auth.md:OAuth implementation handles token refresh and session management.
# /notes/security.md:Two-factor authentication via TOTP is required for admin accounts.
asyncio.run(main())
Hand the bash tool to your LLM
create_bash returns a tool_description field. It's the package's opinionated description of the bash tool (sgrep guidance, persistence semantics, eventual-consistency notes, what's not supported), shipped so the agent doesn't have to discover any of it on its own. Drop it into the description field of your tool schema.
The same string is also exported as the named constant TOOL_DESCRIPTION if you'd rather import it directly (from supermemory_bash import TOOL_DESCRIPTION). Either form works. Examples below use the result field for consistency.
The agent gets:
- All standard shell commands:
cat,ls,mkdir,rm,mv,cp,grep,head,tail,wc,sed, pipes, redirects. - A custom
sgrepcommand for semantic search across every file in the container. - A read-only
/profile.mdvirtual file with memories synthesized from the container's content. - Files persist: writes are durable, reads work across sessions.
OpenAI
from openai import AsyncOpenAI
from supermemory_bash import create_bash
result = await create_bash(api_key="sm-...", container_tag="user_42")
client = AsyncOpenAI()
response = await client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "Search my notes for authentication."}],
tools=[{
"type": "function",
"function": {
"name": "bash",
"description": result.tool_description,
"parameters": {
"type": "object",
"properties": {"cmd": {"type": "string"}},
"required": ["cmd"],
},
},
}],
)
# In your tool-use loop, call `await result.bash.exec(cmd)` and feed the result back.
Anthropic
from anthropic import AsyncAnthropic
from supermemory_bash import create_bash
result = await create_bash(api_key="sm-...", container_tag="user_42")
client = AsyncAnthropic()
response = await client.messages.create(
model="claude-sonnet-4-6",
max_tokens=4096,
tools=[{
"name": "bash",
"description": result.tool_description,
"input_schema": {
"type": "object",
"properties": {"cmd": {"type": "string"}},
"required": ["cmd"],
},
}],
messages=[{"role": "user", "content": "Find my notes about authentication and summarize."}],
)
# In your tool-use loop, call `await result.bash.exec(cmd)` and feed the result back.
Options
await create_bash(
api_key="sm-...",
container_tag="user_42", # one container per user / project
base_url=None, # API override
eager_load=True, # default: True (warm path_index at construction)
eager_content=True, # default: True (also warm content cache)
cache_ttl_ms=150_000, # default: 150_000 (2.5 min). None = never expires (single-writer). 0 = no cache.
cwd="/", # default working directory
env=None, # extra environment variables
)
For very large containers (10k+ docs), set eager_content=False to skip the content warm and pay HTTP per cat. Path resolution stays warm.
cache_ttl_ms controls how long the in-memory content cache trusts itself. The default (2.5 min) assumes other writers exist (other agent sessions, dashboard uploads, webhooks). Single-writer apps can pass None for max speed.
What's not supported
chmod,utimes, symlinks (ln -s,readlink). Supermemory has no permission or symlink model; these throwENOSYS./dev/nullredirects./dev/nullexists as a directory marker but isn't a writable target. Use2>/tmp/discard.logif you need to discard output.- Truly binary uploads. Content gets text-extracted server-side; raw binary write is not supported in this version.
License
MIT
Release files for supermemory-bash 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| supermemory_bash-0.0.2.tar.gz | 69.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| supermemory_bash-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 133.9 kB
Release files / supermemory_bash-0.0.2.tar.gz
| Download URL | supermemory_bash-0.0.2.tar.gz |
|---|---|
| Size | 69.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
09daa9efd4185ec120ff074472fe85858de754205c7c448ea52b184f0c0f1fd9
|
|
BLAKE2b-256 checksum How to use checksums |
b4e4a00948cfb2e24c9b6e91f8869bf6a1308b349839f18aa57e553b6bb20237
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.12
|
Release files / supermemory_bash-0.0.2-py3-none-any.whl
| Download URL | supermemory_bash-0.0.2-py3-none-any.whl |
|---|---|
| Size | 64.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d59e071491a72151b3f05865e8f4e6d8bdffbd2ec817ec7898ab71732f37d37
|
|
BLAKE2b-256 checksum How to use checksums |
a98d71694906f09a3eb9ddc09b389c03f0f5cce60329a8575136bd610be1ead6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.12
|