Metadata-Version: 2.4
Name: langchain-verdo
Version: 0.1.0
Summary: LangChain tools for Verdo: structured team decisions with deadlines, routing and webhooks
Author: Verdo
License-Expression: MIT
Project-URL: Homepage, https://verdo.ink
Project-URL: Documentation, https://verdo.ink/agents
Keywords: langchain,verdo,decisions,approvals,human-in-the-loop,agents
Classifier: Programming Language :: Python :: 3
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-core<2.0,>=0.3.0
Requires-Dist: httpx>=0.25.0
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: pytest-asyncio>=0.23; extra == "test"
Requires-Dist: respx>=0.21; extra == "test"
Dynamic: license-file

# langchain-verdo

LangChain tools for [Verdo](https://verdo.ink): structured team decisions with deadlines, routing and webhooks.

Use it when your agent needs a person to approve, pick or sign off on something, and needs a structured result rather than a discussion. **The agent proposes; a person decides.** No tool invites people, approves, rejects or settles a decision.

## Install

```bash
pip install langchain-verdo
```

## Set up

Create a **full-access** API key in Verdo (Settings > API keys). It starts with `vdok_`.

```bash
export VERDO_API_KEY=vdok_...
```

Or pass `api_key=` to the toolkit or to any tool. The key is held as a `SecretStr`, so it doesn't appear in reprs, logs or traces.

## Use

```python
from langchain_verdo import VerdoToolkit

tools = VerdoToolkit().get_tools()
```

With an agent:

```python
from langchain.agents import create_agent

agent = create_agent(model, tools=tools)  # any tool-calling chat model
agent.invoke({"messages": [("user", "Ask the team whether we ship the new onboarding this sprint.")]})
```

Or call a tool directly:

```python
import json
from langchain_verdo import CreateDecisionTool, CheckDecisionTool

created = json.loads(CreateDecisionTool().invoke({
    "title": "Ship the redesigned onboarding this sprint?",
    "options": ["Ship it", "One more round of testing", "Descope"],
    "tags": ["engineering"],              # a routing rule on this tag assigns its approver
    "idempotency_key": "onboarding-sprint-47",
    "source_agent": "sprint-planner",
}))
print(created["url"])                     # send this to the person who decides

status = json.loads(CheckDecisionTool().invoke({"id": created["id"]}))
print(status["status"], status["outcome"])
```

## Tools

| Tool | What it does |
|---|---|
| `verdo_create_decision` | Proposes a decision. It invites nobody: the decision opens in the Verdo dashboard, and tags can route it to an approver configured in Verdo. With an `idempotency_key`, a retry returns the same open decision (`created: false`). |
| `verdo_check_decision` | Status, outcome once decided, votes per option, owner, dashboard link, `request_fingerprint`, `notification_status`, `routing_rule_label`. |
| `verdo_list_decisions` | Up to 25 decisions, filtered by title words, status, tags, `source_agent` or notification status. |
| `verdo_search_decisions` | Past decided decisions by title words, newest first. |
| `verdo_get_precedent` | One past decision's record, with related decisions. |
| `verdo_cancel_decision` | Withdraws a draft or open decision this key created. |
| `verdo_edit_decision` | Revises a draft or open decision this key created. A change voids the votes cast so far. |

Every tool returns a JSON string. Past decisions come back with `execution_authorized: false`: they're records, not consent to repeat them.

Async is supported (`ainvoke`).

## Errors

A failed call raises `VerdoAPIError` (a `ToolException`) with a sentence the agent can act on, such as a rate limit with its retry time or a draft-only key that can't create. Set `handle_tool_error=True` on a tool to return that sentence to the agent instead of raising it.

## Webhooks

Instead of polling `verdo_check_decision`, you can subscribe a public https URL. Make one subscription per event: `decision.settled`, `decision.rejected`, `decision.cancelled`, `decision.expired` or `decision.escalated`.

```bash
curl -X POST https://verdo.ink/api/v1/webhooks/subscribe \
  -H "Authorization: Bearer $VERDO_API_KEY" -H "Content-Type: application/json" \
  -d '{"event_type":"decision.settled","url":"https://your-server.example/webhook"}'
```

The response includes the `signing_secret`, and it's shown only once. Check every delivery's `X-Verdo-Signature` (HMAC-SHA256 over the `X-Verdo-Timestamp` and the body) before you trust it.

## Development

```bash
pip install -e ".[test]"
pytest tests/ --ignore=tests/integration_tests
VERDO_API_KEY=vdok_... pytest tests/integration_tests   # live; creates and cancels decisions
```

## License

MIT
