autogen-verdo 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aethon Digital FZCO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.4
2
+ Name: autogen-verdo
3
+ Version: 0.1.0
4
+ Summary: AutoGen tools for Verdo: structured team decisions with deadlines, routing and webhooks
5
+ Author: Verdo
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://verdo.ink
8
+ Project-URL: Documentation, https://verdo.ink/agents
9
+ Keywords: autogen,autogen-extension,verdo,decisions,approvals,human-in-the-loop,agents
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Libraries
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: autogen-core>=0.4.0
17
+ Requires-Dist: httpx>=0.25.0
18
+ Provides-Extra: test
19
+ Requires-Dist: pytest>=8; extra == "test"
20
+ Requires-Dist: pytest-asyncio>=0.23; extra == "test"
21
+ Requires-Dist: respx>=0.21; extra == "test"
22
+ Dynamic: license-file
23
+
24
+ # autogen-verdo
25
+
26
+ [AutoGen](https://github.com/microsoft/autogen) tools for [Verdo](https://verdo.ink): structured team decisions with deadlines, routing and webhooks.
27
+
28
+ 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.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install autogen-verdo
34
+ ```
35
+
36
+ Needs Python 3.10+ and `autogen-core` 0.4 or newer.
37
+
38
+ ## Set up
39
+
40
+ Create a **full-access** API key in Verdo (Settings > API keys). It starts with `vdok_`.
41
+
42
+ ```bash
43
+ export VERDO_API_KEY=vdok_...
44
+ ```
45
+
46
+ Or pass `api_key=` to `VerdoTools`.
47
+
48
+ ## Use
49
+
50
+ ```python
51
+ from autogen_agentchat.agents import AssistantAgent
52
+ from autogen_verdo import VerdoTools
53
+
54
+ agent = AssistantAgent(
55
+ "planner",
56
+ model_client=model_client, # any autogen-ext chat completion client
57
+ tools=VerdoTools().get_tools(),
58
+ system_message="When a decision needs the team, propose it in Verdo and share the link.",
59
+ )
60
+ ```
61
+
62
+ Or call a tool directly, since they're plain async methods:
63
+
64
+ ```python
65
+ tools = VerdoTools()
66
+ created = await tools.create_decision(
67
+ "Ship the redesigned onboarding this sprint?",
68
+ ["Ship it", "One more round of testing", "Descope"],
69
+ tags=["engineering"], # a routing rule on this tag assigns its approver
70
+ idempotency_key="onboarding-sprint-47",
71
+ source_agent="sprint-planner",
72
+ )
73
+ print(created["url"]) # send this to the person who decides
74
+
75
+ status = await tools.check_decision(created["id"])
76
+ print(status["status"], status["outcome"])
77
+ ```
78
+
79
+ ## Tools
80
+
81
+ | Tool | What it does |
82
+ |---|---|
83
+ | `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`). |
84
+ | `verdo_check_decision` | Status, outcome once decided, votes per option, owner, link, `request_fingerprint`. |
85
+ | `verdo_list_decisions` | Up to 25 decisions, filtered by title words, status, tags, `source_agent` or notification status. |
86
+ | `verdo_search_decisions` | Past decided decisions by title words, newest first. |
87
+ | `verdo_get_precedent` | One past decision's record, with related decisions. |
88
+ | `verdo_cancel_decision` | Withdraws a draft or open decision this key created. |
89
+ | `verdo_edit_decision` | Revises a draft or open decision this key created. A change voids the votes cast so far. |
90
+
91
+ Past decisions come back with `execution_authorized: false`: they're records, not consent to repeat them. A failed call raises `VerdoAPIError` with a sentence the agent can act on.
92
+
93
+ ## Webhooks
94
+
95
+ Instead of polling, subscribe a public https URL to an event (`decision.settled`, `decision.rejected`, `decision.cancelled`, `decision.expired`, `decision.escalated`) with `POST https://verdo.ink/api/v1/webhooks/subscribe`. The full API is at [verdo.ink/openapi.yaml](https://verdo.ink/openapi.yaml).
96
+
97
+ ## Development
98
+
99
+ ```bash
100
+ pip install -e ".[test]"
101
+ pytest tests/
102
+ ```
103
+
104
+ ## License
105
+
106
+ MIT
@@ -0,0 +1,83 @@
1
+ # autogen-verdo
2
+
3
+ [AutoGen](https://github.com/microsoft/autogen) tools for [Verdo](https://verdo.ink): structured team decisions with deadlines, routing and webhooks.
4
+
5
+ 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.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install autogen-verdo
11
+ ```
12
+
13
+ Needs Python 3.10+ and `autogen-core` 0.4 or newer.
14
+
15
+ ## Set up
16
+
17
+ Create a **full-access** API key in Verdo (Settings > API keys). It starts with `vdok_`.
18
+
19
+ ```bash
20
+ export VERDO_API_KEY=vdok_...
21
+ ```
22
+
23
+ Or pass `api_key=` to `VerdoTools`.
24
+
25
+ ## Use
26
+
27
+ ```python
28
+ from autogen_agentchat.agents import AssistantAgent
29
+ from autogen_verdo import VerdoTools
30
+
31
+ agent = AssistantAgent(
32
+ "planner",
33
+ model_client=model_client, # any autogen-ext chat completion client
34
+ tools=VerdoTools().get_tools(),
35
+ system_message="When a decision needs the team, propose it in Verdo and share the link.",
36
+ )
37
+ ```
38
+
39
+ Or call a tool directly, since they're plain async methods:
40
+
41
+ ```python
42
+ tools = VerdoTools()
43
+ created = await tools.create_decision(
44
+ "Ship the redesigned onboarding this sprint?",
45
+ ["Ship it", "One more round of testing", "Descope"],
46
+ tags=["engineering"], # a routing rule on this tag assigns its approver
47
+ idempotency_key="onboarding-sprint-47",
48
+ source_agent="sprint-planner",
49
+ )
50
+ print(created["url"]) # send this to the person who decides
51
+
52
+ status = await tools.check_decision(created["id"])
53
+ print(status["status"], status["outcome"])
54
+ ```
55
+
56
+ ## Tools
57
+
58
+ | Tool | What it does |
59
+ |---|---|
60
+ | `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`). |
61
+ | `verdo_check_decision` | Status, outcome once decided, votes per option, owner, link, `request_fingerprint`. |
62
+ | `verdo_list_decisions` | Up to 25 decisions, filtered by title words, status, tags, `source_agent` or notification status. |
63
+ | `verdo_search_decisions` | Past decided decisions by title words, newest first. |
64
+ | `verdo_get_precedent` | One past decision's record, with related decisions. |
65
+ | `verdo_cancel_decision` | Withdraws a draft or open decision this key created. |
66
+ | `verdo_edit_decision` | Revises a draft or open decision this key created. A change voids the votes cast so far. |
67
+
68
+ Past decisions come back with `execution_authorized: false`: they're records, not consent to repeat them. A failed call raises `VerdoAPIError` with a sentence the agent can act on.
69
+
70
+ ## Webhooks
71
+
72
+ Instead of polling, subscribe a public https URL to an event (`decision.settled`, `decision.rejected`, `decision.cancelled`, `decision.expired`, `decision.escalated`) with `POST https://verdo.ink/api/v1/webhooks/subscribe`. The full API is at [verdo.ink/openapi.yaml](https://verdo.ink/openapi.yaml).
73
+
74
+ ## Development
75
+
76
+ ```bash
77
+ pip install -e ".[test]"
78
+ pytest tests/
79
+ ```
80
+
81
+ ## License
82
+
83
+ MIT
@@ -0,0 +1,7 @@
1
+ """AutoGen tools for Verdo: structured team decisions, with routing and webhooks."""
2
+
3
+ from autogen_verdo.tools import VerdoAPIError, VerdoTools
4
+
5
+ __version__ = "0.1.0"
6
+
7
+ __all__ = ["VerdoAPIError", "VerdoTools", "__version__"]
@@ -0,0 +1,240 @@
1
+ """Verdo tools for AutoGen agents (autogen-core FunctionTool).
2
+
3
+ The tools call the same Verdo REST routes as the verdo-mcp package:
4
+ /zapier/decisions (create, read, list, search, precedent) and
5
+ /v1/decisions/{id}/cancel and /edit (the caller's own decisions).
6
+
7
+ The agent proposes; a person decides. No tool invites people, approves, rejects or
8
+ settles a decision: create never sends participants.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import os
14
+ from typing import Annotated, Any, Dict, List, Literal, Optional
15
+ from urllib.parse import quote
16
+
17
+ import httpx
18
+ from autogen_core.tools import FunctionTool
19
+
20
+ DEFAULT_API_BASE = "https://verdo.ink/api"
21
+
22
+ Method = Literal["single_choice", "ranked_choice", "approval", "dot"]
23
+ AuthorityMode = Literal["majority", "consensus"]
24
+ LifecycleStatus = Literal["draft", "active", "decided", "implemented", "stalled", "superseded", "reversed", "cancelled", "rejected"]
25
+ NotificationStatus = Literal["pending", "delivered", "partially_delivered", "failed"]
26
+
27
+ _HINTS: Dict[str, str] = {
28
+ "workspace_read_only": "This workspace's plan has lapsed (read-only). The workspace owner can reactivate it at verdo.ink/dashboard/settings/billing.",
29
+ "upgrade_required": "This feature needs a Pro or Business plan. The workspace owner can upgrade at verdo.ink/dashboard/settings/billing.",
30
+ "draft_only_key": "This API key is draft-only. Creating, cancelling and editing decisions need a full-access key (verdo.ink/dashboard/settings > API keys).",
31
+ "invalid or missing API key": "The API key is invalid, revoked or missing. Create one at verdo.ink/dashboard/settings > API keys.",
32
+ }
33
+
34
+
35
+ class VerdoAPIError(Exception):
36
+ """A Verdo API call failed. ``str(err)`` is a sentence an agent can act on."""
37
+
38
+ def __init__(self, action: str, status_code: int, code: Optional[str] = None, message: Optional[str] = None, retry_after_seconds: Optional[float] = None) -> None:
39
+ self.action = action
40
+ self.status_code = status_code
41
+ self.code = code
42
+ self.retry_after_seconds = retry_after_seconds
43
+ if status_code >= 500:
44
+ text = f"Could not {action}: Verdo returned an internal error ({status_code}). This is not the caller's fault; try again in 30 seconds."
45
+ elif status_code == 429:
46
+ wait = f" Retry in {retry_after_seconds:g}s." if retry_after_seconds is not None else " Retry later."
47
+ text = f"Could not {action}: rate limited (HTTP 429).{wait}"
48
+ else:
49
+ detail = _HINTS.get(code or "") or _HINTS.get(message or "") or message or code or "unknown error"
50
+ text = f"Could not {action} (HTTP {status_code}): {detail}"
51
+ super().__init__(text)
52
+
53
+
54
+ def _seg(value: str) -> str:
55
+ return quote(str(value), safe="")
56
+
57
+
58
+ class VerdoTools:
59
+ """Verdo decision tools for AutoGen agents.
60
+
61
+ Example:
62
+ .. code-block:: python
63
+
64
+ from autogen_agentchat.agents import AssistantAgent
65
+ from autogen_verdo import VerdoTools
66
+
67
+ agent = AssistantAgent("planner", model_client=model_client, tools=VerdoTools().get_tools())
68
+ """
69
+
70
+ def __init__(self, api_key: Optional[str] = None, api_base: Optional[str] = None, timeout: float = 30.0) -> None:
71
+ key = api_key if api_key is not None else os.environ.get("VERDO_API_KEY", "")
72
+ if not key:
73
+ raise ValueError("A Verdo API key is required (vdok_...). Pass api_key or set VERDO_API_KEY.")
74
+ self._api_key = key
75
+ self.api_base = (api_base or os.environ.get("VERDO_API_URL") or DEFAULT_API_BASE).rstrip("/")
76
+ self.timeout = timeout
77
+
78
+ def __repr__(self) -> str: # never show the key
79
+ return f"VerdoTools(api_base={self.api_base!r})"
80
+
81
+ # ---- HTTP ----
82
+
83
+ def _headers(self) -> Dict[str, str]:
84
+ return {"Authorization": f"Bearer {self._api_key}", "Content-Type": "application/json", "User-Agent": "autogen-verdo"}
85
+
86
+ async def _request(self, method: str, path: str, action: str, *, params: Optional[Dict[str, Any]] = None, body: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
87
+ async with httpx.AsyncClient(timeout=self.timeout) as client:
88
+ r = await client.request(method, f"{self.api_base}{path}", params=params, json=body, headers=self._headers())
89
+ try:
90
+ data = r.json()
91
+ except ValueError:
92
+ data = {}
93
+ if not isinstance(data, dict):
94
+ data = {}
95
+ if r.is_success:
96
+ return data
97
+ retry: Optional[float] = None
98
+ raw = data.get("retry_after_seconds", r.headers.get("retry-after"))
99
+ if raw is not None:
100
+ try:
101
+ retry = float(raw)
102
+ except (TypeError, ValueError):
103
+ retry = None
104
+ code, message = data.get("error"), data.get("message")
105
+ raise VerdoAPIError(action, r.status_code, str(code) if code is not None else None, str(message) if message is not None else None, retry)
106
+
107
+ # ---- tools ----
108
+
109
+ async def create_decision(
110
+ self,
111
+ title: Annotated[str, "The decision question (max 140 characters)"],
112
+ options: Annotated[List[str], "2-10 options to choose from"],
113
+ tags: Annotated[Optional[List[str]], "Tags; a workspace routing rule matching one assigns its approver"] = None,
114
+ idempotency_key: Annotated[Optional[str], "Retry safety: while the decision this key created is open, the same key returns it"] = None,
115
+ source_agent: Annotated[Optional[str], "A name for the agent creating this, recorded on the decision"] = None,
116
+ method: Annotated[Optional[Method], "Voting method. Default single_choice"] = None,
117
+ deadline_hours: Annotated[Optional[int], "Hours until the decision closes. Default 48, max 720"] = None,
118
+ authority_mode: Annotated[Optional[AuthorityMode], "majority or consensus. Default majority"] = None,
119
+ anonymous: Annotated[Optional[bool], "Whether votes are anonymous. Default false"] = None,
120
+ ) -> Dict[str, Any]:
121
+ """Propose a team decision. It invites nobody: the decision opens in the Verdo dashboard."""
122
+ if not title.strip() or len(title) > 140:
123
+ raise ValueError("title must be 1-140 characters.")
124
+ if not 2 <= len(options) <= 10:
125
+ raise ValueError("options must be a list of 2-10 choices.")
126
+ # Never send participants: inviting people is a person's call, made in Verdo.
127
+ body: Dict[str, Any] = {
128
+ "title": title,
129
+ "options": list(options),
130
+ "method": method or "single_choice",
131
+ "deadline_hours": deadline_hours or 48,
132
+ "authority_mode": authority_mode or "majority",
133
+ "anonymous": bool(anonymous),
134
+ }
135
+ for k, v in (("tags", tags), ("idempotency_key", idempotency_key), ("source_agent", source_agent)):
136
+ if v is not None:
137
+ body[k] = v
138
+ data = await self._request("POST", "/zapier/decisions", "create the decision", body=body)
139
+ return {
140
+ "id": data.get("id"),
141
+ "url": data.get("url"),
142
+ "request_fingerprint": data.get("request_fingerprint"),
143
+ "created": data.get("created") is not False,
144
+ "next_step": "Send the url to the person who decides. Check the result with verdo_check_decision.",
145
+ }
146
+
147
+ async def check_decision(self, decision_id: Annotated[str, "The decision id from verdo_create_decision"]) -> Dict[str, Any]:
148
+ """Read a decision: status, the outcome once a person has decided, votes per option, owner, link."""
149
+ data = await self._request("GET", f"/zapier/decisions/{_seg(decision_id)}", "read the decision")
150
+ d = data.get("decision") or {}
151
+ keys = ("title", "status", "outcome", "decided_at", "owner", "vote_breakdown", "url", "request_fingerprint", "notification_status", "routing_rule_label", "source_agent", "idempotency_key")
152
+ return {"id": d.get("decision_id", decision_id), **{k: d.get(k) for k in keys}}
153
+
154
+ async def list_decisions(
155
+ self,
156
+ query: Annotated[Optional[str], "Words to match in decision titles"] = None,
157
+ lifecycle_status: Annotated[Optional[List[LifecycleStatus]], "Only these statuses"] = None,
158
+ tags: Annotated[Optional[List[str]], "Only decisions with any of these tags"] = None,
159
+ source_agent: Annotated[Optional[str], "Only decisions created by this agent name"] = None,
160
+ notification_status: Annotated[Optional[NotificationStatus], "Only decisions in this notification state"] = None,
161
+ ) -> Dict[str, Any]:
162
+ """List up to 25 decisions in the workspace, filtered. Read-only."""
163
+ params: Dict[str, str] = {}
164
+ if query:
165
+ params["query"] = query
166
+ if lifecycle_status:
167
+ params["lifecycle_status"] = ",".join(lifecycle_status)
168
+ if tags:
169
+ params["tags"] = ",".join(tags)
170
+ if source_agent:
171
+ params["source_agent"] = source_agent
172
+ if notification_status:
173
+ params["notification_status"] = notification_status
174
+ data = await self._request("GET", "/zapier/decisions/search", "list decisions", params=params)
175
+ rows = data.get("decisions") or []
176
+ return {"decisions": [{"id": r.get("decision_id", r.get("id")), "title": r.get("title"), "status": r.get("status"), "outcome": r.get("outcome"), "url": r.get("url")} for r in rows]}
177
+
178
+ async def search_decisions(
179
+ self,
180
+ query: Annotated[str, "Words to look for in past decision titles"],
181
+ limit: Annotated[Optional[int], "How many to return. Default 10, max 50"] = None,
182
+ ) -> Dict[str, Any]:
183
+ """Search past decided decisions by title, newest first. Past records, not consent."""
184
+ if not query.strip():
185
+ raise ValueError("query is required.")
186
+ params: Dict[str, Any] = {"query": query.strip()}
187
+ if limit is not None:
188
+ params["limit"] = limit
189
+ data = await self._request("GET", "/zapier/decisions/precedent", "search decisions", params=params)
190
+ return {"decisions": data.get("decisions") or [], "execution_authorized": False}
191
+
192
+ async def get_precedent(self, decision_id: Annotated[str, "A decided decision's id, from verdo_search_decisions"]) -> Dict[str, Any]:
193
+ """Read one past decision's record and related decisions. A past record, not consent."""
194
+ data = await self._request("GET", f"/zapier/decisions/{_seg(decision_id)}/precedent", "read the past decision")
195
+ return {"precedent": data.get("precedent"), "execution_authorized": False}
196
+
197
+ async def cancel_decision(
198
+ self,
199
+ decision_id: Annotated[str, "The decision id from verdo_create_decision"],
200
+ reason: Annotated[Optional[str], "Why it is being withdrawn (shown to the people it was sent to)"] = None,
201
+ ) -> Dict[str, Any]:
202
+ """Withdraw a draft or open decision this API key created. This decides nothing."""
203
+ body = {"reason": reason} if reason is not None else {}
204
+ data = await self._request("POST", f"/v1/decisions/{_seg(decision_id)}/cancel", "cancel the decision", body=body)
205
+ return {"id": data.get("id", decision_id), "status": data.get("status")}
206
+
207
+ async def edit_decision(
208
+ self,
209
+ decision_id: Annotated[str, "The decision id from verdo_create_decision"],
210
+ title: Annotated[Optional[str], "New question"] = None,
211
+ description: Annotated[Optional[str], "New description"] = None,
212
+ options: Annotated[Optional[List[str]], "The full new list of 2-10 options"] = None,
213
+ ) -> Dict[str, Any]:
214
+ """Revise a draft or open decision this API key created. A change voids the votes cast so far."""
215
+ body = {k: v for k, v in (("title", title), ("description", description), ("options", options)) if v is not None}
216
+ if not body:
217
+ raise ValueError("Nothing to edit: give a new title, description or options.")
218
+ data = await self._request("POST", f"/v1/decisions/{_seg(decision_id)}/edit", "edit the decision", body=body)
219
+ return {"id": data.get("id", decision_id), "changed": data.get("changed") is True, "votes_voided": data.get("votes_voided", 0), "request_fingerprint": data.get("request_fingerprint")}
220
+
221
+ def get_tools(self) -> List[FunctionTool]:
222
+ """All seven Verdo tools as AutoGen FunctionTools."""
223
+ return [
224
+ FunctionTool(self.create_decision, name="verdo_create_decision", description=(
225
+ "Propose a team decision in Verdo when a person needs to approve, pick or sign off on something. "
226
+ "The agent proposes; a person decides. It invites nobody; tags can route it to an approver configured in Verdo. "
227
+ "Returns the id, the dashboard url to share, the request_fingerprint, and created=false on an idempotent replay.")),
228
+ FunctionTool(self.check_decision, name="verdo_check_decision", description=(
229
+ "Check a Verdo decision: status, the outcome once a person has decided, votes per option, owner, url, request_fingerprint. Read-only.")),
230
+ FunctionTool(self.list_decisions, name="verdo_list_decisions", description=(
231
+ "List up to 25 Verdo decisions, filtered by title words, status, tags, source_agent or notification status. Read-only.")),
232
+ FunctionTool(self.search_decisions, name="verdo_search_decisions", description=(
233
+ "Search past decided Verdo decisions by title, newest first. Past records, not consent (execution_authorized: false). Read-only.")),
234
+ FunctionTool(self.get_precedent, name="verdo_get_precedent", description=(
235
+ "Read one past Verdo decision: outcome, date, owner, votes, rationale if shared, related decisions. A past record, not consent. Read-only.")),
236
+ FunctionTool(self.cancel_decision, name="verdo_cancel_decision", description=(
237
+ "Withdraw a draft or open Verdo decision this API key created. It closes as cancelled; this decides nothing. Needs a full-access key.")),
238
+ FunctionTool(self.edit_decision, name="verdo_edit_decision", description=(
239
+ "Revise a draft or open Verdo decision this API key created. A change voids every vote cast so far. Needs a full-access key.")),
240
+ ]
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.4
2
+ Name: autogen-verdo
3
+ Version: 0.1.0
4
+ Summary: AutoGen tools for Verdo: structured team decisions with deadlines, routing and webhooks
5
+ Author: Verdo
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://verdo.ink
8
+ Project-URL: Documentation, https://verdo.ink/agents
9
+ Keywords: autogen,autogen-extension,verdo,decisions,approvals,human-in-the-loop,agents
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Libraries
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: autogen-core>=0.4.0
17
+ Requires-Dist: httpx>=0.25.0
18
+ Provides-Extra: test
19
+ Requires-Dist: pytest>=8; extra == "test"
20
+ Requires-Dist: pytest-asyncio>=0.23; extra == "test"
21
+ Requires-Dist: respx>=0.21; extra == "test"
22
+ Dynamic: license-file
23
+
24
+ # autogen-verdo
25
+
26
+ [AutoGen](https://github.com/microsoft/autogen) tools for [Verdo](https://verdo.ink): structured team decisions with deadlines, routing and webhooks.
27
+
28
+ 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.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install autogen-verdo
34
+ ```
35
+
36
+ Needs Python 3.10+ and `autogen-core` 0.4 or newer.
37
+
38
+ ## Set up
39
+
40
+ Create a **full-access** API key in Verdo (Settings > API keys). It starts with `vdok_`.
41
+
42
+ ```bash
43
+ export VERDO_API_KEY=vdok_...
44
+ ```
45
+
46
+ Or pass `api_key=` to `VerdoTools`.
47
+
48
+ ## Use
49
+
50
+ ```python
51
+ from autogen_agentchat.agents import AssistantAgent
52
+ from autogen_verdo import VerdoTools
53
+
54
+ agent = AssistantAgent(
55
+ "planner",
56
+ model_client=model_client, # any autogen-ext chat completion client
57
+ tools=VerdoTools().get_tools(),
58
+ system_message="When a decision needs the team, propose it in Verdo and share the link.",
59
+ )
60
+ ```
61
+
62
+ Or call a tool directly, since they're plain async methods:
63
+
64
+ ```python
65
+ tools = VerdoTools()
66
+ created = await tools.create_decision(
67
+ "Ship the redesigned onboarding this sprint?",
68
+ ["Ship it", "One more round of testing", "Descope"],
69
+ tags=["engineering"], # a routing rule on this tag assigns its approver
70
+ idempotency_key="onboarding-sprint-47",
71
+ source_agent="sprint-planner",
72
+ )
73
+ print(created["url"]) # send this to the person who decides
74
+
75
+ status = await tools.check_decision(created["id"])
76
+ print(status["status"], status["outcome"])
77
+ ```
78
+
79
+ ## Tools
80
+
81
+ | Tool | What it does |
82
+ |---|---|
83
+ | `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`). |
84
+ | `verdo_check_decision` | Status, outcome once decided, votes per option, owner, link, `request_fingerprint`. |
85
+ | `verdo_list_decisions` | Up to 25 decisions, filtered by title words, status, tags, `source_agent` or notification status. |
86
+ | `verdo_search_decisions` | Past decided decisions by title words, newest first. |
87
+ | `verdo_get_precedent` | One past decision's record, with related decisions. |
88
+ | `verdo_cancel_decision` | Withdraws a draft or open decision this key created. |
89
+ | `verdo_edit_decision` | Revises a draft or open decision this key created. A change voids the votes cast so far. |
90
+
91
+ Past decisions come back with `execution_authorized: false`: they're records, not consent to repeat them. A failed call raises `VerdoAPIError` with a sentence the agent can act on.
92
+
93
+ ## Webhooks
94
+
95
+ Instead of polling, subscribe a public https URL to an event (`decision.settled`, `decision.rejected`, `decision.cancelled`, `decision.expired`, `decision.escalated`) with `POST https://verdo.ink/api/v1/webhooks/subscribe`. The full API is at [verdo.ink/openapi.yaml](https://verdo.ink/openapi.yaml).
96
+
97
+ ## Development
98
+
99
+ ```bash
100
+ pip install -e ".[test]"
101
+ pytest tests/
102
+ ```
103
+
104
+ ## License
105
+
106
+ MIT
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ autogen_verdo/__init__.py
5
+ autogen_verdo/tools.py
6
+ autogen_verdo.egg-info/PKG-INFO
7
+ autogen_verdo.egg-info/SOURCES.txt
8
+ autogen_verdo.egg-info/dependency_links.txt
9
+ autogen_verdo.egg-info/requires.txt
10
+ autogen_verdo.egg-info/top_level.txt
11
+ tests/test_tools.py
@@ -0,0 +1,7 @@
1
+ autogen-core>=0.4.0
2
+ httpx>=0.25.0
3
+
4
+ [test]
5
+ pytest>=8
6
+ pytest-asyncio>=0.23
7
+ respx>=0.21
@@ -0,0 +1 @@
1
+ autogen_verdo
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "autogen-verdo"
7
+ version = "0.1.0"
8
+ description = "AutoGen tools for Verdo: structured team decisions with deadlines, routing and webhooks"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "Verdo" }]
14
+ keywords = ["autogen", "autogen-extension", "verdo", "decisions", "approvals", "human-in-the-loop", "agents"]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Intended Audience :: Developers",
18
+ "Topic :: Software Development :: Libraries",
19
+ ]
20
+ dependencies = [
21
+ "autogen-core>=0.4.0",
22
+ "httpx>=0.25.0",
23
+ ]
24
+
25
+ [project.optional-dependencies]
26
+ test = ["pytest>=8", "pytest-asyncio>=0.23", "respx>=0.21"]
27
+
28
+ [project.urls]
29
+ Homepage = "https://verdo.ink"
30
+ Documentation = "https://verdo.ink/agents"
31
+
32
+ [tool.setuptools.packages.find]
33
+ include = ["autogen_verdo*"]
34
+
35
+ [tool.pytest.ini_options]
36
+ asyncio_mode = "auto"
37
+ asyncio_default_fixture_loop_scope = "function"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,158 @@
1
+ """Unit tests: every call is mocked with respx. Tools are run through AutoGen's own
2
+ FunctionTool.run_json, so the generated argument schemas are exercised too."""
3
+
4
+ import json
5
+
6
+ import httpx
7
+ import pytest
8
+ import respx
9
+ from autogen_core import CancellationToken
10
+
11
+ from autogen_verdo import VerdoAPIError, VerdoTools
12
+
13
+ BASE = "https://verdo.test/api"
14
+ KEY = "vdok_unit_test_key"
15
+ DID = "0a689ae4-90bf-4ae3-a16d-06a11ed6671c"
16
+
17
+
18
+ @pytest.fixture
19
+ def tools():
20
+ return {t.name: t for t in VerdoTools(api_key=KEY, api_base=BASE).get_tools()}
21
+
22
+
23
+ async def run(tool, args):
24
+ return await tool.run_json(args, CancellationToken())
25
+
26
+
27
+ def body_of(route):
28
+ return json.loads(route.calls.last.request.content)
29
+
30
+
31
+ def test_get_tools_returns_all_seven(tools):
32
+ assert list(tools) == [
33
+ "verdo_create_decision",
34
+ "verdo_check_decision",
35
+ "verdo_list_decisions",
36
+ "verdo_search_decisions",
37
+ "verdo_get_precedent",
38
+ "verdo_cancel_decision",
39
+ "verdo_edit_decision",
40
+ ]
41
+ # The agent proposes; a person decides.
42
+ assert not any(w in n for n in tools for w in ("approve", "reject", "settle", "vote", "invite"))
43
+
44
+
45
+ def test_schema_exposes_parameters(tools):
46
+ params = tools["verdo_create_decision"].schema["parameters"]
47
+ assert set(params["required"]) == {"title", "options"}
48
+ assert "participants" not in params["properties"]
49
+ assert "self" not in params["properties"]
50
+
51
+
52
+ @respx.mock
53
+ async def test_create_decision_sends_payload_and_returns_id(tools):
54
+ route = respx.post(f"{BASE}/zapier/decisions").mock(
55
+ return_value=httpx.Response(201, json={"id": DID, "url": "u", "request_fingerprint": "fp1", "created": True, "replayed": False})
56
+ )
57
+ out = await run(tools["verdo_create_decision"], {"title": "Ship it?", "options": ["Yes", "No"], "tags": ["eng"], "idempotency_key": "k1", "source_agent": "planner"})
58
+ assert body_of(route) == {
59
+ "title": "Ship it?",
60
+ "options": ["Yes", "No"],
61
+ "method": "single_choice",
62
+ "deadline_hours": 48,
63
+ "authority_mode": "majority",
64
+ "anonymous": False,
65
+ "tags": ["eng"],
66
+ "idempotency_key": "k1",
67
+ "source_agent": "planner",
68
+ }
69
+ assert route.calls.last.request.headers["authorization"] == f"Bearer {KEY}"
70
+ assert out["id"] == DID and out["created"] is True
71
+
72
+
73
+ @respx.mock
74
+ async def test_create_decision_replay_returns_created_false(tools):
75
+ respx.post(f"{BASE}/zapier/decisions").mock(return_value=httpx.Response(200, json={"id": DID, "url": "u", "created": False, "replayed": True}))
76
+ out = await run(tools["verdo_create_decision"], {"title": "Ship it?", "options": ["Yes", "No"], "idempotency_key": "k1"})
77
+ assert out["created"] is False and out["id"] == DID
78
+
79
+
80
+ @respx.mock
81
+ async def test_check_decision_returns_status_and_outcome(tools):
82
+ respx.get(f"{BASE}/zapier/decisions/{DID}").mock(
83
+ return_value=httpx.Response(200, json={"decision": {"decision_id": DID, "title": "Ship it?", "status": "decided", "outcome": "Yes", "request_fingerprint": "fp1"}})
84
+ )
85
+ out = await run(tools["verdo_check_decision"], {"decision_id": DID})
86
+ assert out["id"] == DID and out["status"] == "decided" and out["outcome"] == "Yes"
87
+
88
+
89
+ @respx.mock
90
+ async def test_list_decisions_filters(tools):
91
+ route = respx.get(f"{BASE}/zapier/decisions/search").mock(return_value=httpx.Response(200, json={"decisions": [{"decision_id": DID, "title": "t", "status": "active"}]}))
92
+ out = await run(tools["verdo_list_decisions"], {"source_agent": "planner", "lifecycle_status": ["active", "decided"]})
93
+ params = route.calls.last.request.url.params
94
+ assert params["source_agent"] == "planner" and params["lifecycle_status"] == "active,decided"
95
+ assert out["decisions"][0]["id"] == DID
96
+
97
+
98
+ @respx.mock
99
+ async def test_search_decisions_sends_query(tools):
100
+ route = respx.get(f"{BASE}/zapier/decisions/precedent").mock(return_value=httpx.Response(200, json={"decisions": [], "execution_authorized": False}))
101
+ out = await run(tools["verdo_search_decisions"], {"query": "onboarding", "limit": 5})
102
+ params = route.calls.last.request.url.params
103
+ assert params["query"] == "onboarding" and params["limit"] == "5"
104
+ assert out["execution_authorized"] is False
105
+
106
+
107
+ @respx.mock
108
+ async def test_get_precedent_reads_one_past_decision(tools):
109
+ route = respx.get(f"{BASE}/zapier/decisions/{DID}/precedent").mock(return_value=httpx.Response(200, json={"precedent": {"id": DID, "winner": "Ship it"}}))
110
+ out = await run(tools["verdo_get_precedent"], {"decision_id": DID})
111
+ assert route.called and out["precedent"]["winner"] == "Ship it"
112
+
113
+
114
+ @respx.mock
115
+ async def test_cancel_decision_sends_reason(tools):
116
+ route = respx.post(f"{BASE}/v1/decisions/{DID}/cancel").mock(return_value=httpx.Response(200, json={"id": DID, "status": "cancelled"}))
117
+ out = await run(tools["verdo_cancel_decision"], {"decision_id": DID, "reason": "Requirements changed"})
118
+ assert body_of(route) == {"reason": "Requirements changed"}
119
+ assert out == {"id": DID, "status": "cancelled"}
120
+
121
+
122
+ @respx.mock
123
+ async def test_edit_decision_sends_title_and_options(tools):
124
+ route = respx.post(f"{BASE}/v1/decisions/{DID}/edit").mock(return_value=httpx.Response(200, json={"id": DID, "changed": True, "votes_voided": 2, "request_fingerprint": "fp2"}))
125
+ out = await run(tools["verdo_edit_decision"], {"decision_id": DID, "title": "Ship it now?", "options": ["Yes", "Later"]})
126
+ assert body_of(route) == {"title": "Ship it now?", "options": ["Yes", "Later"]}
127
+ assert out["changed"] is True and out["votes_voided"] == 2
128
+
129
+
130
+ @pytest.mark.parametrize(
131
+ "status,body,expected",
132
+ [
133
+ (401, {"error": "invalid or missing API key", "message": "invalid or missing API key"}, "API key is invalid"),
134
+ (429, {"error": "rate_limited", "retry_after_seconds": 30}, "Retry in 30s"),
135
+ (500, {"error": "internal"}, "internal error"),
136
+ ],
137
+ )
138
+ @respx.mock
139
+ async def test_api_errors_raise_informative_exception(tools, status, body, expected):
140
+ respx.get(f"{BASE}/zapier/decisions/{DID}").mock(return_value=httpx.Response(status, json=body))
141
+ with pytest.raises(VerdoAPIError) as err:
142
+ await run(tools["verdo_check_decision"], {"decision_id": DID})
143
+ assert err.value.status_code == status and expected in str(err.value) and KEY not in str(err.value)
144
+
145
+
146
+ def test_key_required_and_hidden(monkeypatch):
147
+ monkeypatch.delenv("VERDO_API_KEY", raising=False)
148
+ with pytest.raises(ValueError, match="API key is required"):
149
+ VerdoTools()
150
+ assert KEY not in repr(VerdoTools(api_key=KEY))
151
+
152
+
153
+ async def test_input_guards():
154
+ t = VerdoTools(api_key=KEY, api_base=BASE)
155
+ with pytest.raises(ValueError, match="2-10"):
156
+ await t.create_decision("Ship it?", ["Yes"])
157
+ with pytest.raises(ValueError, match="Nothing to edit"):
158
+ await t.edit_decision(DID)