Skip to main content

Python SDK for controlling Happy agent sessions

Project description

happy-engineering-sdk

PyPI version Python versions License: MIT

Python SDK for controlling Happy agent sessions.

Installation

pip install happy-engineering-sdk

Credentials

The SDK authenticates using a key file and a server URL.

Key file — download agent.key from the Happy dashboard and place it at:

~/.happy/agent.key

Server URL — set the HAPPY_SERVER_URL environment variable to your Happy server's base URL:

export HAPPY_SERVER_URL=https://api.happy.engineering

Quick start

The simplest usage is run_task() — it spawns a session, sends a prompt, waits for the agent to finish, and stops the session, all in one call:

import asyncio
from happy_sdk import HappyClient

async def main():
    client = HappyClient()
    session_id = await client.run_task(
        machine_id="my-machine",
        directory="/home/user/project",
        prompt="Summarise this week's PRs",
    )
    print(f"Task complete — session {session_id}")

asyncio.run(main())

Manual lifecycle

For finer control, manage the session lifecycle directly:

import asyncio
from happy_sdk import HappyClient

async def main():
    client = HappyClient()

    session_id = await client.spawn_session(
        machine_id="my-machine",
        directory="/home/user/project",
    )
    await client.send_message(session_id, "Hello")
    await client.wait_for_turn_completion(session_id)
    await client.stop_session(session_id)

asyncio.run(main())

API reference

All methods are async and must be called from an async context.

Method Signature Description
run_task (machine_id, directory, prompt, agent="claude", timeout_seconds=600) Spawn a session, send a prompt, wait for turn completion, and stop — returns the session ID
spawn_session (machine_id, directory, agent="claude", create_dir=False) Create a new agent session on the given machine in the given directory — returns the session ID
send_message (session_id, text, permission_mode="yolo") Send a message to an active session
wait_for_turn_completion (session_id, timeout_seconds=300) Block until the agent finishes its current turn
stop_session (session_id) Stop a running session

License

MIT — see LICENSE.

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

happy_engineering_sdk-0.1.0.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

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

happy_engineering_sdk-0.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file happy_engineering_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: happy_engineering_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for happy_engineering_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1abd87443de6209533ecdff16b023b199ba02b4b9569e2a44a00c5d6e0147c05
MD5 9449571d169a509b8e7f4ff0c0a29039
BLAKE2b-256 e27bbb6ce86ad3efec516913d47fa5d65c519bdd22ed1c8d7f60675b993916aa

See more details on using hashes here.

File details

Details for the file happy_engineering_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for happy_engineering_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38e8f0ed5220f9a221dda8cce63546f78bbdc7e5b6abfbc92182ed8a3fbab6f6
MD5 39402dd9c6eab273c975ee90c508ff30
BLAKE2b-256 1ea61d6852c1afb90e0f825a86840a758154166aa017a618b463d95546506544

See more details on using hashes here.

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