Skip to main content

STELE Python SDK and local bootstrap helpers (HTTP client + optional local steled launcher).

Project description

stele (Python)

Dependency-free Python SDK for STELE (stdlib urllib, Python 3.9+).

This package contains:

  • stele_sdk: the HTTP client (in-repo module)
  • stele: thin wrapper module + optional local bootstrap helpers (installed from pip install stele-sdk)

If you want a deeper dive, see the repo docs at docs/sdk/python.md.

Install

pip install stele-sdk
from stele import SteleClient, APIError

Package note:

  • PyPI distribution name: stele-sdk
  • Import module for published package usage: stele

Client Configuration

client = SteleClient(
    base_url="http://127.0.0.1:8080",
    api_version="v1",
    agent_id="agent-1",
    session_id="session-1",
    client_id="my-app",
    embedder_override="",     # optional
    ops_auth_token="",        # optional; also read from STELE_OPS_AUTH_TOKEN / STELE_MCP_AUTH_TOKEN
    timeout=15,
)

Environment defaults (when not passed explicitly):

  • STELE_BASE_URL
  • STELE_API_VERSION
  • STELE_AGENT_ID
  • STELE_SESSION_ID
  • STELE_CLIENT_ID
  • STELE_EMBEDDER_OVERRIDE
  • STELE_OPS_AUTH_TOKEN (ops endpoints)
  • STELE_MCP_AUTH_TOKEN (ops endpoints; convenience fallback)

Minimal Example: Write + Query

import time
from stele import SteleClient

client = SteleClient(
    base_url="http://127.0.0.1:8080",
    agent_id="agent-1",
    session_id="session-1",
)

write = client.write(
    {
        "memory": {
            "content": "We should attach provenance.source_refs to all writes.",
            "type": "MEMORY_TYPE_PROCEDURAL",
            "scope": "SCOPE_AGENT",
            "provenance": {
                "source_refs": ["run:sdk/python/README.md#minimal-example"],
                "citations": [],
                "origin_turn_id": "",
            },
            "timestamp_ms": int(time.time() * 1000),
        }
    }
)
print("wrote:", (write.get("memory") or {}).get("id"))

query = client.query(
    {
        "query_text": "What provenance should we attach?",
        "budget_tokens": 250,
        "scope_order": ["SCOPE_AGENT", "SCOPE_TEAM", "SCOPE_PROJECT", "SCOPE_GLOBAL"],
    }
)
print("recall:", len(query.get("memories") or []))

Optional: Local Bootstrap (No Go Toolchain)

If you have GitHub Release assets published for this repo, you can bootstrap a local steled before creating the client:

from stele.local import ensure_running
from stele import SteleClient

ensure_running()
client = SteleClient(agent_id="agent-1", session_id="session-1")
print(client.query({"query_text": "sanity check"}))

Error Handling

Non-2xx responses raise APIError:

from stele import APIError

try:
    client.reindex({})
except APIError as exc:
    print("status:", exc.status_code, "code:", exc.code, "request:", exc.request_id, "msg:", exc.message)

Graph Example: Add Edge + List

import time

client.edge_add(
    {
        "edge": {
            "from_id": "mem-aaa",
            "to_id": "mem-bbb",
            "type": "EDGE_TYPE_RELATES_TO",
            "weight": 1,
            "created_at_ms": int(time.time() * 1000),
        }
    }
)

edges = client.edge_list({"node_id": "mem-aaa"})
print(edges.get("edges"))

Proactive Surfacing Helper

Use the built-in trigger orchestrator when you want SDK-side proactive suggest parity:

suggestor = client.create_proactive_suggestor()
suggestor.trigger("bootstrap", {"active_files": ["README.md"]})
suggestor.trigger(
    "context_shift",
    {"active_files": ["src/auth/handler.go"], "recent_commands": ["plan:implement"]},
)
suggestor.trigger("pre_edit", {"active_symbols": ["AuthHandler"]})

ProactiveSuggestor enforces debounce, context-hash dedupe, rate limits, and payload caps before calling suggest.

Ops Endpoints (Bearer Token)

Ops endpoints require ops_auth_token (or env STELE_OPS_AUTH_TOKEN / STELE_MCP_AUTH_TOKEN):

  • bulk_forget
  • export_ndjson / export_to_file
  • import_memories
  • maintenance
  • reindex
  • decay

Export to File (Convenience)

import os
from stele import SteleClient

ops = SteleClient(
    base_url="http://127.0.0.1:8080",
    agent_id="agent-1",
    session_id="session-1",
    ops_auth_token=os.environ.get("STELE_OPS_AUTH_TOKEN", ""),
)
ops.export_to_file("stele-export.jsonl")

Import

from stele import SteleClient

with open("stele-export.jsonl", "r", encoding="utf-8") as f:
    ndjson = f.read()

ops.import_memories({"data": ndjson, "strict": False})

API Coverage (Method Map)

Methods map closely to steled routes:

  • Core: write, query, feedback, protect, supersede, forget
  • Retrieval utils: list_memories, get_memory, search_memories, update_memory, verify, extract
  • Bulk: bulk_write, bulk_forget (ops)
  • Ops: export_ndjson/export_to_file, import_memories, schema, metrics, maintenance, reindex, decay
  • Graph: edge_add, edge_delete, edge_list, edge_traverse, edge_suggest
  • Proactive/stream: suggest, watch
  • Sharing: learn_share (mistake-only)
  • Agent/system: agent_get, agent_upsert, access_mark_used, events, membership_add/remove/list, health, stats

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stele_sdk-0.2.2.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stele_sdk-0.2.2-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file stele_sdk-0.2.2.tar.gz.

File metadata

  • Download URL: stele_sdk-0.2.2.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stele_sdk-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d354235dbdef7729edf258ece118a058a3d6329b5b0605dcd30b78fab2b57d8a
MD5 37a86aa1bc3816168d664a29925f535c
BLAKE2b-256 3c952950c3ff952e54639dd5b45cdad8e58958c48f33652c9e1ddfdb751a1e6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for stele_sdk-0.2.2.tar.gz:

Publisher: pypi-publish.yml on sincover/stele

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stele_sdk-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: stele_sdk-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stele_sdk-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c9105f9ae772e4ad5714c27f76cd5f990240f2652178f8cf791ded28cfa99b79
MD5 075244d4a20baf639bdc488a6c0e76e0
BLAKE2b-256 6ae5df1c8345b5d5d621dc5663b873bb28f3c29d08c3c6345aa7bb649f5b07ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for stele_sdk-0.2.2-py3-none-any.whl:

Publisher: pypi-publish.yml on sincover/stele

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page