Python bindings for PulseHive — shared consciousness SDK for multi-agent AI systems
Project description
PulseHive Python Bindings
Python bindings for the PulseHive Rust SDK — shared consciousness for multi-agent AI systems.
Get Rust-native performance with Python ergonomics. Define agents, tools, and workflows in Python while the runtime executes in Rust.
Installation
pip install pulsehive
For development:
cd pulsehive-py
python -m venv .venv && source .venv/bin/activate
pip install maturin pytest pytest-asyncio
maturin develop
Quickstart
import asyncio
from pulsehive import (
HiveMind, AgentDefinition, AgentKind,
Lens, LlmConfig, Task, openai_provider,
)
async def main():
# Build HiveMind with substrate and LLM provider
hive = (
HiveMind.builder()
.substrate_path("/tmp/my_project.db")
.llm_provider("openai", openai_provider("sk-...", "gpt-4"))
.build()
)
# Define an agent with perception lens
agent = AgentDefinition("analyzer", AgentKind.llm(
system_prompt="You are a code analysis expert.",
lens=Lens(["code", "architecture"]),
llm_config=LlmConfig("openai", "gpt-4"),
))
# Deploy and consume events
stream = await hive.deploy([agent], [Task("Analyze the codebase")])
async for event in stream:
print(f"[{event.event_type}] {event.data}")
if event.event_type == "agent_completed":
break
asyncio.run(main())
Custom Tools
Define tools as plain Python classes — no base class needed (duck-typing protocol):
class SearchTool:
def name(self): return "search"
def description(self): return "Search the web for information"
def parameters(self): return {
"type": "object",
"properties": {"query": {"type": "string"}},
"required": ["query"],
}
def execute(self, params, context):
# context.agent_id and context.collective_id available
return f"Results for: {params['query']}"
# Attach tools to agents
agent = AgentDefinition("researcher", AgentKind.llm(
"You research topics.", Lens([]), LlmConfig("openai", "gpt-4"),
tools=[SearchTool()],
))
Tools must implement name(), description(), parameters(), and execute(params, context). Optional: requires_approval() returning True for sensitive operations.
Workflow Agents
# Sequential pipeline — each agent perceives previous results
pipeline = AgentDefinition("pipeline", AgentKind.sequential([
AgentDefinition("step1", AgentKind.llm("Analyze", lens, config)),
AgentDefinition("step2", AgentKind.llm("Summarize", lens, config)),
]))
# Parallel execution — agents work concurrently, sharing substrate
team = AgentDefinition("team", AgentKind.parallel([agent1, agent2]))
# Loop — repeat until [LOOP_DONE] or max iterations
loop = AgentDefinition("iterator", AgentKind.loop_(agent, max_iterations=5))
API Reference
Core Types
| Type | Description |
|---|---|
LlmConfig(provider, model) |
LLM selection and generation parameters |
Lens(domains) |
Perception filter for substrate access |
RecencyCurve.exponential(h) / .uniform() |
Temporal decay function |
AgentKind.llm(prompt, lens, config, tools) |
LLM-powered agent |
AgentKind.sequential(agents) |
Run children in order |
AgentKind.parallel(agents) |
Run children concurrently |
AgentKind.loop_(agent, n) |
Repeat agent N times |
AgentDefinition(name, kind) |
Agent blueprint |
Task(description) |
Task for deployment |
HiveEvent |
Lifecycle event (.event_type, .data, .agent_id) |
ToolContext |
Runtime context for tools (.agent_id, .collective_id) |
ToolResult.text(s) / .json(d) / .error(s) |
Tool execution result |
Provider Factories
openai_provider(api_key, model="gpt-4", base_url=None) # OpenAI, Azure, Ollama, vLLM
anthropic_provider(api_key) # Anthropic Claude
Examples
See examples/ for runnable scripts:
- getting_started.py — Single agent with event stream
- multi_agent.py — Sequential + Parallel workflows
- custom_tools.py — Python-defined tools with ToolContext
Running Tests
pytest pulsehive-py/tests/ -v
License
AGPL-3.0-only
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pulsehive-0.3.0b2.tar.gz.
File metadata
- Download URL: pulsehive-0.3.0b2.tar.gz
- Upload date:
- Size: 139.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c479cf9c26d1b111ec6ffcb0f7fb012b4c5a11f8afdbad34cdfb98b4936ab923
|
|
| MD5 |
35e593725c717331f860fdb7e678cfb4
|
|
| BLAKE2b-256 |
8e438c39b9e03c435f6fd29b0f90ea09bae04cb1e54df10ecf84cbb84bff6801
|
Provenance
The following attestation bundles were made for pulsehive-0.3.0b2.tar.gz:
Publisher:
python-release.yml on pulseai-labs/PulseHive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pulsehive-0.3.0b2.tar.gz -
Subject digest:
c479cf9c26d1b111ec6ffcb0f7fb012b4c5a11f8afdbad34cdfb98b4936ab923 - Sigstore transparency entry: 2056794989
- Sigstore integration time:
-
Permalink:
pulseai-labs/PulseHive@eda134f7517ba3709200646fa47f870432b80dd7 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/pulseai-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@eda134f7517ba3709200646fa47f870432b80dd7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pulsehive-0.3.0b2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pulsehive-0.3.0b2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 11.9 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab7bb86e0a5b64e90488216cfb66a296d0ea24af77418cb82c579fd8b3d2da40
|
|
| MD5 |
89cc7ed68ea0395530717029d18b14e3
|
|
| BLAKE2b-256 |
c11b5d31ee5586d3bec2c7e753cc91bf262266e6fcebd810df6baa87e64d2107
|
Provenance
The following attestation bundles were made for pulsehive-0.3.0b2-cp312-cp312-win_amd64.whl:
Publisher:
python-release.yml on pulseai-labs/PulseHive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pulsehive-0.3.0b2-cp312-cp312-win_amd64.whl -
Subject digest:
ab7bb86e0a5b64e90488216cfb66a296d0ea24af77418cb82c579fd8b3d2da40 - Sigstore transparency entry: 2056795870
- Sigstore integration time:
-
Permalink:
pulseai-labs/PulseHive@eda134f7517ba3709200646fa47f870432b80dd7 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/pulseai-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@eda134f7517ba3709200646fa47f870432b80dd7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pulsehive-0.3.0b2-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pulsehive-0.3.0b2-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 15.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7471ac5bee37ce4cc8b5f5dd688c956af010aed91a75357dc16f517f829f5e5
|
|
| MD5 |
406442117236b0371e8eb26cb4c6c8cc
|
|
| BLAKE2b-256 |
7bd0fb437c0dfb0afc9246fb2683296f3528d4624ae938612b8ef64dc0f170ce
|
Provenance
The following attestation bundles were made for pulsehive-0.3.0b2-cp312-cp312-manylinux_2_28_x86_64.whl:
Publisher:
python-release.yml on pulseai-labs/PulseHive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pulsehive-0.3.0b2-cp312-cp312-manylinux_2_28_x86_64.whl -
Subject digest:
e7471ac5bee37ce4cc8b5f5dd688c956af010aed91a75357dc16f517f829f5e5 - Sigstore transparency entry: 2056795464
- Sigstore integration time:
-
Permalink:
pulseai-labs/PulseHive@eda134f7517ba3709200646fa47f870432b80dd7 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/pulseai-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@eda134f7517ba3709200646fa47f870432b80dd7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pulsehive-0.3.0b2-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pulsehive-0.3.0b2-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 12.9 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d81b6a4356272b5808cb0c0dc6809057d8108ed2cd6857a1670561be6bb5144
|
|
| MD5 |
ad1903d9192fbb2347710803aab49620
|
|
| BLAKE2b-256 |
c5ed521b13c96991f588e8acc18fc8a4207276d6db4be3abe61b29105035d9a1
|
Provenance
The following attestation bundles were made for pulsehive-0.3.0b2-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
python-release.yml on pulseai-labs/PulseHive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pulsehive-0.3.0b2-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
6d81b6a4356272b5808cb0c0dc6809057d8108ed2cd6857a1670561be6bb5144 - Sigstore transparency entry: 2056796253
- Sigstore integration time:
-
Permalink:
pulseai-labs/PulseHive@eda134f7517ba3709200646fa47f870432b80dd7 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/pulseai-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@eda134f7517ba3709200646fa47f870432b80dd7 -
Trigger Event:
push
-
Statement type: