trucehq 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.
- trucehq-0.1.0/LICENSE +21 -0
- trucehq-0.1.0/PKG-INFO +65 -0
- trucehq-0.1.0/README.md +48 -0
- trucehq-0.1.0/pyproject.toml +20 -0
- trucehq-0.1.0/src/trucehq/__init__.py +69 -0
trucehq-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Truce (trucehq.com)
|
|
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.
|
trucehq-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: trucehq
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Truce for AI agents: a neutral mediator your agent can call to settle disputes with other agents or people. Free for AI agents.
|
|
5
|
+
Project-URL: Homepage, https://trucehq.com/agents
|
|
6
|
+
Project-URL: Documentation, https://trucehq.com/md/agents.md
|
|
7
|
+
Project-URL: Source, https://github.com/trucehq/truce-agents
|
|
8
|
+
Author-email: Truce <frank@trucehq.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: a2a,agents,ai-agents,dispute-resolution,mcp,mediation,negotiation
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# Truce for AI agents
|
|
19
|
+
|
|
20
|
+
**A neutral mediator your agent can call.** When your agent disagrees with another agent (a refund, a late delivery, an invoice, a booking, a contract term), Truce hears both sides, proposes a fair outcome on the merits, and settles it automatically when the outcome is inside both agents' private limits. Free for AI agents. Truce never moves money; humans have the final say.
|
|
21
|
+
|
|
22
|
+
- MCP server: `https://trucehq.com/mcp` (Streamable HTTP, no key). Official MCP Registry: `com.trucehq/truce`
|
|
23
|
+
- A2A: agent card `https://trucehq.com/.well-known/agent-card.json`, endpoint `POST https://trucehq.com/a2a`
|
|
24
|
+
- REST: `https://trucehq.com/openapi.json`
|
|
25
|
+
- Open protocol: [PROTOCOL.md](PROTOCOL.md) (Agent Dispute Protocol v0.1)
|
|
26
|
+
- Full guide with snippets for OpenAI, Claude, LangChain, CrewAI, Google ADK and Vercel AI SDK: [AGENTS_GUIDE.md](AGENTS_GUIDE.md)
|
|
27
|
+
|
|
28
|
+
## Python
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install trucehq
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from trucehq import Truce
|
|
36
|
+
t = Truce()
|
|
37
|
+
a = t.open_dispute(topic="Late delivery refund", name="Buyer agent", acting_for="Sam Lee",
|
|
38
|
+
statement="Lamp ordered for $80 arrived 12 days late, scratched.",
|
|
39
|
+
wants="A $40 refund", mandate={"role": "payee", "limit_usd": 20, "auto_accept": True})
|
|
40
|
+
# send a["invite_code"] to the other agent; it calls:
|
|
41
|
+
b = t.respond(invite_code=a["invite_code"], name="Seller agent", acting_for="Lamp Shop Ltd",
|
|
42
|
+
statement="Courier delay; the scratch is minor.", wants="$15 credit",
|
|
43
|
+
mandate={"role": "payer", "limit_usd": 35, "auto_accept": True})
|
|
44
|
+
print(b["status"], b["proposal"]["settlement_usd"]) # e.g. agreed 25
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## JavaScript / TypeScript
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install trucehq
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { Truce } from "trucehq";
|
|
55
|
+
const t = new Truce();
|
|
56
|
+
const a = await t.openDispute({ topic: "Late delivery refund", name: "Buyer agent", actingFor: "Sam Lee",
|
|
57
|
+
statement: "Lamp arrived 12 days late, scratched.", wants: "A $40 refund",
|
|
58
|
+
mandate: { role: "payee", limit_usd: 20, auto_accept: true } });
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Rules
|
|
62
|
+
|
|
63
|
+
Act only for a person or organisation that asked you to (`authorized: true` is sent for you; only use the client when that is true). Never sign, pay or answer for the other side. Keep keys secret. Not for abuse, violence, threats, a child's safety or crimes.
|
|
64
|
+
|
|
65
|
+
MIT licensed. Questions: frank@trucehq.com · https://trucehq.com/agents
|
trucehq-0.1.0/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Truce for AI agents
|
|
2
|
+
|
|
3
|
+
**A neutral mediator your agent can call.** When your agent disagrees with another agent (a refund, a late delivery, an invoice, a booking, a contract term), Truce hears both sides, proposes a fair outcome on the merits, and settles it automatically when the outcome is inside both agents' private limits. Free for AI agents. Truce never moves money; humans have the final say.
|
|
4
|
+
|
|
5
|
+
- MCP server: `https://trucehq.com/mcp` (Streamable HTTP, no key). Official MCP Registry: `com.trucehq/truce`
|
|
6
|
+
- A2A: agent card `https://trucehq.com/.well-known/agent-card.json`, endpoint `POST https://trucehq.com/a2a`
|
|
7
|
+
- REST: `https://trucehq.com/openapi.json`
|
|
8
|
+
- Open protocol: [PROTOCOL.md](PROTOCOL.md) (Agent Dispute Protocol v0.1)
|
|
9
|
+
- Full guide with snippets for OpenAI, Claude, LangChain, CrewAI, Google ADK and Vercel AI SDK: [AGENTS_GUIDE.md](AGENTS_GUIDE.md)
|
|
10
|
+
|
|
11
|
+
## Python
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install trucehq
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from trucehq import Truce
|
|
19
|
+
t = Truce()
|
|
20
|
+
a = t.open_dispute(topic="Late delivery refund", name="Buyer agent", acting_for="Sam Lee",
|
|
21
|
+
statement="Lamp ordered for $80 arrived 12 days late, scratched.",
|
|
22
|
+
wants="A $40 refund", mandate={"role": "payee", "limit_usd": 20, "auto_accept": True})
|
|
23
|
+
# send a["invite_code"] to the other agent; it calls:
|
|
24
|
+
b = t.respond(invite_code=a["invite_code"], name="Seller agent", acting_for="Lamp Shop Ltd",
|
|
25
|
+
statement="Courier delay; the scratch is minor.", wants="$15 credit",
|
|
26
|
+
mandate={"role": "payer", "limit_usd": 35, "auto_accept": True})
|
|
27
|
+
print(b["status"], b["proposal"]["settlement_usd"]) # e.g. agreed 25
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## JavaScript / TypeScript
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install trucehq
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Truce } from "trucehq";
|
|
38
|
+
const t = new Truce();
|
|
39
|
+
const a = await t.openDispute({ topic: "Late delivery refund", name: "Buyer agent", actingFor: "Sam Lee",
|
|
40
|
+
statement: "Lamp arrived 12 days late, scratched.", wants: "A $40 refund",
|
|
41
|
+
mandate: { role: "payee", limit_usd: 20, auto_accept: true } });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Rules
|
|
45
|
+
|
|
46
|
+
Act only for a person or organisation that asked you to (`authorized: true` is sent for you; only use the client when that is true). Never sign, pay or answer for the other side. Keep keys secret. Not for abuse, violence, threats, a child's safety or crimes.
|
|
47
|
+
|
|
48
|
+
MIT licensed. Questions: frank@trucehq.com · https://trucehq.com/agents
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "trucehq"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Truce for AI agents: a neutral mediator your agent can call to settle disputes with other agents or people. Free for AI agents."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [{ name = "Truce", email = "frank@trucehq.com" }]
|
|
13
|
+
keywords = ["ai-agents", "mcp", "a2a", "dispute-resolution", "mediation", "agents", "negotiation"]
|
|
14
|
+
classifiers = ["Programming Language :: Python :: 3", "Operating System :: OS Independent", "Topic :: Software Development :: Libraries"]
|
|
15
|
+
dependencies = []
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://trucehq.com/agents"
|
|
19
|
+
Documentation = "https://trucehq.com/md/agents.md"
|
|
20
|
+
Source = "https://github.com/trucehq/truce-agents"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Truce for AI agents: a neutral mediator your agent can call. https://trucehq.com/agents"""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import urllib.error
|
|
6
|
+
import urllib.request
|
|
7
|
+
from typing import Any, Optional
|
|
8
|
+
|
|
9
|
+
__all__ = ["Truce", "TruceError"]
|
|
10
|
+
__version__ = "0.1.0"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TruceError(Exception):
|
|
14
|
+
def __init__(self, status: int, message: str):
|
|
15
|
+
super().__init__(f"{status}: {message}")
|
|
16
|
+
self.status = status
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Truce:
|
|
20
|
+
"""Thin client for the Truce agent API. No key needed. Only act for someone who asked you to."""
|
|
21
|
+
|
|
22
|
+
def __init__(self, base_url: str = "https://trucehq.com", timeout: float = 60.0):
|
|
23
|
+
self.base_url = base_url.rstrip("/")
|
|
24
|
+
self.timeout = timeout
|
|
25
|
+
|
|
26
|
+
def _req(self, method: str, path: str, body: Optional[dict] = None) -> Any:
|
|
27
|
+
data = None if body is None else json.dumps(body).encode()
|
|
28
|
+
req = urllib.request.Request(
|
|
29
|
+
self.base_url + path, data=data, method=method,
|
|
30
|
+
headers={"Content-Type": "application/json", "User-Agent": f"trucehq-python/{__version__}"},
|
|
31
|
+
)
|
|
32
|
+
try:
|
|
33
|
+
with urllib.request.urlopen(req, timeout=self.timeout) as r:
|
|
34
|
+
return json.loads(r.read() or b"{}")
|
|
35
|
+
except urllib.error.HTTPError as e:
|
|
36
|
+
try:
|
|
37
|
+
msg = json.loads(e.read()).get("error", e.reason)
|
|
38
|
+
except Exception:
|
|
39
|
+
msg = e.reason
|
|
40
|
+
raise TruceError(e.code, str(msg)) from None
|
|
41
|
+
|
|
42
|
+
# Agent Truce (agent vs agent)
|
|
43
|
+
def open_dispute(self, topic: str, name: str, statement: str, wants: str, *, acting_for: str = "",
|
|
44
|
+
evidence: str = "", category: str = "", mandate: Optional[dict] = None) -> dict:
|
|
45
|
+
return self._req("POST", "/api/agent-disputes", {
|
|
46
|
+
"topic": topic, "name": name, "acting_for": acting_for, "statement": statement, "wants": wants,
|
|
47
|
+
"evidence": evidence, "category": category, "mandate": mandate or {}, "authorized": True})
|
|
48
|
+
|
|
49
|
+
def respond(self, invite_code: str, name: str, statement: str, wants: str, *, acting_for: str = "",
|
|
50
|
+
evidence: str = "", mandate: Optional[dict] = None) -> dict:
|
|
51
|
+
return self._req("POST", "/api/agent-disputes/respond", {
|
|
52
|
+
"invite_code": invite_code, "name": name, "acting_for": acting_for, "statement": statement,
|
|
53
|
+
"wants": wants, "evidence": evidence, "mandate": mandate or {}, "authorized": True})
|
|
54
|
+
|
|
55
|
+
def decide(self, key: str, decision: str, note: str = "") -> dict:
|
|
56
|
+
return self._req("POST", "/api/agent-disputes/decide", {"key": key, "decision": decision, "note": note})
|
|
57
|
+
|
|
58
|
+
def get(self, key: str) -> dict:
|
|
59
|
+
return self._req("GET", f"/api/agent-disputes/{key}")
|
|
60
|
+
|
|
61
|
+
def invite(self, invite_code: str) -> dict:
|
|
62
|
+
return self._req("GET", f"/api/agent-disputes/invite/{invite_code}")
|
|
63
|
+
|
|
64
|
+
# Truce for a human user (the user sends the invite and signs)
|
|
65
|
+
def start_truce(self, **fields: Any) -> dict:
|
|
66
|
+
return self._req("POST", "/api/truces", {**fields, "source": fields.get("source", "agent-python")})
|
|
67
|
+
|
|
68
|
+
def start_whos_right(self, **fields: Any) -> dict:
|
|
69
|
+
return self._req("POST", "/api/whos-right", fields)
|