hsafa-sdk
Python SDK for Hsafa Core v7. Connect any service to a Haseef brain — register tools, handle tool calls over SSE, push events, and read/write the haseef's memory and profile.
Install
pip install hsafa-sdk
Or from source:
cd sdks/python
pip install -e .
Quick Start
import asyncio
import os
from hsafa_sdk import HsafaSDK, SdkOptions
async def main():
sdk = HsafaSDK(SdkOptions(
core_url="http://localhost:3001",
api_key=os.environ.get("HSAFA_CORE_KEY", "test-key"),
skill="weather",
))
# 1. Register tools
await sdk.register_tools([{
"name": "get_weather",
"description": "Get current weather for a city",
"input": {"city": "string", "units": "string?"},
}])
# 2. Handle tool calls
async def handle_weather(args, ctx):
print(f"{ctx['haseef']['name']} wants weather for {args.get('city')}")
return {"temperature": 72, "conditions": "sunny", "city": args.get("city")}
sdk.on_tool_call("get_weather", handle_weather)
# 3. Listen to lifecycle events
def on_run_started(e):
print(f"Run started for {e['haseef']['name']}")
sdk.on("run.started", on_run_started)
# 4. Connect the SSE stream (blocks until disconnect)
# For background usage alongside a web server:
# asyncio.create_task(sdk.connect())
try:
await sdk.connect()
except KeyboardInterrupt:
await sdk.disconnect()
if __name__ == "__main__":
asyncio.run(main())
Namespaces
| Namespace | Methods |
|---|---|
sdk.haseef |
list(), get(id), create(data), update(id, patch), delete(id), get_profile(id), update_profile(id, patch), add_skill(id, name), remove_skill(id, name), status(id) |
sdk.memory |
list(id), search(id, query, limit), set(id, memories), delete(id, keys), episodes(id, limit), search_episodes(id, query, limit), social(id), procedural(id), stats(id) |
sdk.runs |
list(haseef_id?, status?, limit?), get(run_id) |
License
MIT
Metadata
Release files for hsafa-sdk 0.1.0
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 |
|---|---|---|---|---|
| hsafa_sdk-0.1.0.tar.gz | 7.4 kB | Without provenance | Details for hsafa_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hsafa_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for hsafa_sdk-0.1.0-py3-none-any.whl |
Total release size: 14.8 kB
Release files / hsafa_sdk-0.1.0.tar.gz
| Download URL | hsafa_sdk-0.1.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4ac9d3a0cb5195f4455722ddbfa15b1e5b3ec7c6399ac2d92cf7bd7bad5233a
|
|
BLAKE2b-256 checksum How to use checksums |
fdd10e63640c15d557fd0cf50d560c55321c1502fe371c4c428cd7bc23382970
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Release files / hsafa_sdk-0.1.0-py3-none-any.whl
| Download URL | hsafa_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d9bda7c8e45ac0f4761fc0c6dff86b9c9bfb065e0452a3e4cd2787811e611eb
|
|
BLAKE2b-256 checksum How to use checksums |
2056b8838f85e515f5d7778e53552fa85c9b110cde46c87fa9eee66384a03ebf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Security for hsafa-sdk 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.