Metadata-Version: 2.4
Name: megacode-agent-sdk
Version: 0.31.0
Summary: Drive a MEGA harness agent session from a Python program.
License-Expression: MIT OR Apache-2.0
License-File: LICENSE-MIT
License-File: LICENSE-APACHE
Requires-Python: >=3.10
Project-URL: Homepage, https://megacode-harness.vercel.app/docs/sdk.html
Project-URL: Repository, https://megacode-harness.vercel.app/docs/
Description-Content-Type: text/markdown

# megacode-agent-sdk

Drive a MEGA harness agent session from a Python program: start a session, give the model tools your program
runs, answer its approval requests, and read what it does. One session is one `harness` process. Use it to
build an agent that is not a coding agent.

```sh
pip install megacode-agent-sdk
```

Python 3.10 or newer; the standard library only; a wheel, with no source build.

The package needs a `harness` binary of the same major and minor version. It uses the `binary` option, then the
`MEGACODE_AGENT_SDK_BINARY` environment variable, then a verified copy in its cache, and otherwise downloads
the matching release and checks it against digests built into the package.

```python
import asyncio
from megacode_agent_sdk import Client, Options, tool

@tool(
    "search_trains",
    "Find trains to a destination.",
    {"type": "object", "properties": {"to": {"type": "string"}}, "required": ["to"]},
)
async def search(args, ctx):
    return f"to {args['to']}: 9:10 for 42 pounds"

async def main():
    options = Options.plain("You are Pip, a personal assistant. Be brief.", tools=[search])
    async with await Client.start(options) as client:
        turn = await client.send("find me a train to Leeds")
        async for event in turn:
            print(event)

asyncio.run(main())
```

The options, tools, approvals, testing with a mock file, versions, the download and its trust rules are in the
[agent SDK guide](https://megacode-harness.vercel.app/docs/sdk.html) (`docs/sdk.md` in the source).

Licensed under either of MIT or Apache-2.0, at your option.
