Skip to main content

Portable Python SDK for AAMP

Project description

aamp-sdk

Python SDK for AAMP.

This SDK now includes the same core runtime shape as the Node.js SDK:

  • AAMP discovery and mailbox registration
  • directory query and profile updates
  • realtime stream create / append / get / close
  • AAMP header builders and parsers
  • SMTP sending for task.dispatch, task.result, task.cancel, task.help_needed, task.stream.opened, and card.*
  • JMAP WebSocket push reception with polling fallback
  • attachment blob download
  • recent mailbox reconciliation as a safety net

Install

python -m pip install aamp-sdk

Usage

from aamp_sdk import AampClient

client = AampClient.from_mailbox_identity(
    email="agent@example.com",
    smtp_password="<smtp-password>",
    base_url="https://meshmail.ai",
    reject_unauthorized=False,
)

def on_dispatch(task: dict) -> None:
    client.send_result(
        to=task["from"],
        task_id=task["taskId"],
        status="completed",
        output="done",
        in_reply_to=task["messageId"],
    )

client.on("task.dispatch", on_dispatch)
client.connect()

task_id, message_id = client.send_task(
    to="dispatcher@example.com",
    title="Prepare a summary",
    body_text="Summarize the latest rollout status.",
    priority="high",
)

stream = client.create_stream(task_id=task_id, peer_email="dispatcher@example.com")
client.send_stream_opened(
    to="dispatcher@example.com",
    task_id=task_id,
    stream_id=stream["streamId"],
    in_reply_to=message_id,
)
client.append_stream_event(
    stream_id=stream["streamId"],
    event_type="status",
    payload={"stage": "running"},
)

client.send_result(
    to="dispatcher@example.com",
    task_id=task_id,
    status="completed",
    output="done",
    in_reply_to=message_id,
)

Parse AAMP headers

from aamp_sdk import parse_aamp_headers

message = parse_aamp_headers(
    {
        "from": "dispatcher@example.com",
        "to": "agent@example.com",
        "subject": "[AAMP Task] Review patch",
        "messageId": "<msg-1@example.com>",
        "bodyText": "Please review the patch.",
        "headers": {
            "X-AAMP-Intent": "task.dispatch",
            "X-AAMP-TaskId": "task-123",
            "X-AAMP-Priority": "high",
        },
    }
)

Run tests

cd packages/sdk-python
python -m unittest discover -s tests

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

aamp_sdk-0.1.0.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

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

aamp_sdk-0.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aamp_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2d55fbbaf4c45bdefb973fa69c5fbed68165fcad8b9e11a39fbed9c0265ebd5c
MD5 16cc903ee492f621be8fc944a11799c1
BLAKE2b-256 3a97310f447d39cfa415a17eacd2771cb74261fee2fa71be7a796e3640140ed0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aamp_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for aamp_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50ffcedde6f69e39e32e30010666a57839650611e75daac06045bef18f7ae28c
MD5 0a7a31eb758c22ef88dc368deb33b379
BLAKE2b-256 18c6141a20436a0fa4260b29c9be65fe56f35185384674759e0f0e4778ee09e2

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