langchain-popcorn 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.
- langchain_popcorn-0.1.0/.gitignore +15 -0
- langchain_popcorn-0.1.0/LICENSE +9 -0
- langchain_popcorn-0.1.0/PKG-INFO +106 -0
- langchain_popcorn-0.1.0/PUBLISH-CHECKLIST.md +38 -0
- langchain_popcorn-0.1.0/README.md +83 -0
- langchain_popcorn-0.1.0/langchain_popcorn/__init__.py +35 -0
- langchain_popcorn-0.1.0/langchain_popcorn/client.py +104 -0
- langchain_popcorn-0.1.0/langchain_popcorn/tools.py +340 -0
- langchain_popcorn-0.1.0/pyproject.toml +40 -0
- langchain_popcorn-0.1.0/tests/test_tools.py +132 -0
- langchain_popcorn-0.1.0/vercel.json +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
POPCORN Read-and-Use Terms v1.2
|
|
2
|
+
LicenseRef-POPCORN-Read-and-Use-Terms
|
|
3
|
+
|
|
4
|
+
Copyright 2026 Violet Herod.
|
|
5
|
+
|
|
6
|
+
This package is offered under the owner's POPCORN Read-and-Use Terms v1.2.
|
|
7
|
+
The code is open to see and to use under those terms. It is not offered
|
|
8
|
+
under MIT, Apache, or any other permissive license, and no other license
|
|
9
|
+
applies. The full terms as published by the owner govern this package.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: langchain-popcorn
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LangChain tools for POPCORN, the witness service at 767-2676.com run by Violet Herod (Briarwood). Free receipt verification tools, plus paid signed time and witness tools behind an explicit opt-in flag.
|
|
5
|
+
Project-URL: Homepage, https://767-2676.com/
|
|
6
|
+
Project-URL: Documentation, https://767-2676.com/
|
|
7
|
+
Project-URL: Repository, https://github.com/violetclaire/popcorn-temporal-anchor
|
|
8
|
+
Author-email: Violet Herod <violet@briarwood.ai>
|
|
9
|
+
License: LicenseRef-POPCORN-Read-and-Use-Terms
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: langchain,mcp,popcorn,receipt,timestamp,witness,x402
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: langchain-core>=0.3.0
|
|
18
|
+
Requires-Dist: pydantic>=2.0.0
|
|
19
|
+
Requires-Dist: requests>=2.31.0
|
|
20
|
+
Provides-Extra: test
|
|
21
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# langchain-popcorn
|
|
25
|
+
|
|
26
|
+
LangChain tools for POPCORN, the witness service at
|
|
27
|
+
[767-2676.com](https://767-2676.com/), run by Violet Herod (Briarwood).
|
|
28
|
+
|
|
29
|
+
POPCORN stands outside the parties to a deal and signs what it saw, at
|
|
30
|
+
the time it saw it. A POPCORN receipt witnesses only that the node
|
|
31
|
+
received a fingerprint within a stated interval. It does not witness
|
|
32
|
+
agreement, authorship, competence, completion, fairness, or payment.
|
|
33
|
+
A receipt is evidence, not permission. Verification depends on
|
|
34
|
+
accepting the node's key and clock.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install langchain-popcorn
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This package is not on PyPI yet. Until it is, install it from this
|
|
43
|
+
folder:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install .
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Use
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from langchain_popcorn import get_tools
|
|
53
|
+
|
|
54
|
+
tools = get_tools()
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
That returns the five free tools. They call the POPCORN MCP endpoint at
|
|
58
|
+
`https://767-2676.com/mcp` (Streamable HTTP, POST JSON-RPC 2.0).
|
|
59
|
+
|
|
60
|
+
| Tool | Cost | What it does |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| `popcorn_sample` | Free | Checks the published October 14, 2026 sample receipt and a changed-digest control. |
|
|
63
|
+
| `popcorn_catalog` | Free | Reads the live catalog, the offer, and the published verification keys. |
|
|
64
|
+
| `popcorn_hash` | Free | Hashes public bytes on the server. Hash private work locally instead; submitted text reaches the server. |
|
|
65
|
+
| `popcorn_verify` | Free | Verifies a time or witness receipt against a caller-trusted JWKS and expected values. |
|
|
66
|
+
| `popcorn_verify_v2` | Free | Verifies leTAIN TAIN 2.0 evidence against the keys published by the issuer. |
|
|
67
|
+
|
|
68
|
+
## Paid tools
|
|
69
|
+
|
|
70
|
+
Two tools cost money:
|
|
71
|
+
|
|
72
|
+
| Tool | Cost | What it does |
|
|
73
|
+
| --- | --- | --- |
|
|
74
|
+
| `popcorn_time` | $0.001 | Buys a fresh signed time anchor. |
|
|
75
|
+
| `popcorn_witness` | $0.001 | Buys a fresh witness receipt for a payload digest. |
|
|
76
|
+
|
|
77
|
+
$0.001 is a tenth of a penny. Payment is in USDC on Base through x402.
|
|
78
|
+
|
|
79
|
+
Paid tools are off by default. They are returned only when you ask for
|
|
80
|
+
them, and each one checks the flag again before it calls:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
tools = get_tools(allow_paid_tools=True)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Calling a paid tool while the flag is off raises
|
|
87
|
+
`PopcornPaidToolDisabledError` with the price and the condition stated
|
|
88
|
+
in the error. Turning the flag on is the caller's statement that the
|
|
89
|
+
owner has authorized the payment. Paying also needs an x402-capable
|
|
90
|
+
wallet on the calling side. This package never pays on its own.
|
|
91
|
+
|
|
92
|
+
## What a receipt proves, and what it does not
|
|
93
|
+
|
|
94
|
+
A verified receipt proves that the holder of the published key signed
|
|
95
|
+
that fingerprint and that stated time interval, and that the bytes
|
|
96
|
+
were not changed after signing. It does not prove the claim inside the
|
|
97
|
+
bytes was checked by the witness, and it does not prove delivery,
|
|
98
|
+
completion, or agreement. Verification is free and can be done offline
|
|
99
|
+
against the published keys at
|
|
100
|
+
`https://767-2676.com/.well-known/popcorn-keys.json`.
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
POPCORN Read-and-Use Terms v1.2
|
|
105
|
+
(`LicenseRef-POPCORN-Read-and-Use-Terms`). Copyright 2026 Violet Herod.
|
|
106
|
+
The code is open to see and to use under those terms. It is not MIT.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# langchain-popcorn: publish checklist
|
|
2
|
+
|
|
3
|
+
Prepared 2026-11-29 at Violet's order. Nothing below has been published,
|
|
4
|
+
filed, or submitted. The package is built and verified; the remaining
|
|
5
|
+
steps are the ones only Violet can do.
|
|
6
|
+
|
|
7
|
+
## What is ready (verified 2026-11-29)
|
|
8
|
+
|
|
9
|
+
- Package: langchain-popcorn 0.1.0, at ~/workspace/framework-packages/langchain-popcorn/
|
|
10
|
+
- License: POPCORN Read-and-Use Terms v1.2 (LicenseRef-POPCORN-Read-and-Use-Terms),
|
|
11
|
+
LICENSE file inside both release files.
|
|
12
|
+
- Unit tests: 12 passed.
|
|
13
|
+
- Live check: the five free tools load in LangChain and the catalog tool
|
|
14
|
+
returned the live catalog from https://767-2676.com.
|
|
15
|
+
- Release files built:
|
|
16
|
+
- dist/langchain_popcorn-0.1.0.tar.gz
|
|
17
|
+
- dist/langchain_popcorn-0.1.0-py3-none-any.whl
|
|
18
|
+
- Metadata points at her public repo:
|
|
19
|
+
https://github.com/violetclaire/popcorn-temporal-anchor
|
|
20
|
+
- The two paid tools (signed time, witness) ship only behind an explicit
|
|
21
|
+
developer opt-in flag that defaults off. No paid call is made by the
|
|
22
|
+
free tools.
|
|
23
|
+
|
|
24
|
+
## Steps left, in order (all Violet's)
|
|
25
|
+
|
|
26
|
+
1. Public GitHub home for the package code. The metadata already names
|
|
27
|
+
violetclaire/popcorn-temporal-anchor. Either the package folder is
|
|
28
|
+
pushed into that repo, or a new repo is created for it. Her word
|
|
29
|
+
decides which.
|
|
30
|
+
2. A PyPI account in her name (pypi.org). Publishing needs an API token
|
|
31
|
+
from that account. The token goes through the secure vault card,
|
|
32
|
+
never through chat.
|
|
33
|
+
3. Her approval of the exact LangChain listing text, drafted at
|
|
34
|
+
~/workspace/framework-packages/langchain-listing-draft.md. Nothing is
|
|
35
|
+
filed with LangChain before she approves that text word for word.
|
|
36
|
+
|
|
37
|
+
After those three, Scout uploads the two release files to PyPI and the
|
|
38
|
+
package is installable with: pip install langchain-popcorn
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# langchain-popcorn
|
|
2
|
+
|
|
3
|
+
LangChain tools for POPCORN, the witness service at
|
|
4
|
+
[767-2676.com](https://767-2676.com/), run by Violet Herod (Briarwood).
|
|
5
|
+
|
|
6
|
+
POPCORN stands outside the parties to a deal and signs what it saw, at
|
|
7
|
+
the time it saw it. A POPCORN receipt witnesses only that the node
|
|
8
|
+
received a fingerprint within a stated interval. It does not witness
|
|
9
|
+
agreement, authorship, competence, completion, fairness, or payment.
|
|
10
|
+
A receipt is evidence, not permission. Verification depends on
|
|
11
|
+
accepting the node's key and clock.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install langchain-popcorn
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This package is not on PyPI yet. Until it is, install it from this
|
|
20
|
+
folder:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install .
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Use
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from langchain_popcorn import get_tools
|
|
30
|
+
|
|
31
|
+
tools = get_tools()
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
That returns the five free tools. They call the POPCORN MCP endpoint at
|
|
35
|
+
`https://767-2676.com/mcp` (Streamable HTTP, POST JSON-RPC 2.0).
|
|
36
|
+
|
|
37
|
+
| Tool | Cost | What it does |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `popcorn_sample` | Free | Checks the published October 14, 2026 sample receipt and a changed-digest control. |
|
|
40
|
+
| `popcorn_catalog` | Free | Reads the live catalog, the offer, and the published verification keys. |
|
|
41
|
+
| `popcorn_hash` | Free | Hashes public bytes on the server. Hash private work locally instead; submitted text reaches the server. |
|
|
42
|
+
| `popcorn_verify` | Free | Verifies a time or witness receipt against a caller-trusted JWKS and expected values. |
|
|
43
|
+
| `popcorn_verify_v2` | Free | Verifies leTAIN TAIN 2.0 evidence against the keys published by the issuer. |
|
|
44
|
+
|
|
45
|
+
## Paid tools
|
|
46
|
+
|
|
47
|
+
Two tools cost money:
|
|
48
|
+
|
|
49
|
+
| Tool | Cost | What it does |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| `popcorn_time` | $0.001 | Buys a fresh signed time anchor. |
|
|
52
|
+
| `popcorn_witness` | $0.001 | Buys a fresh witness receipt for a payload digest. |
|
|
53
|
+
|
|
54
|
+
$0.001 is a tenth of a penny. Payment is in USDC on Base through x402.
|
|
55
|
+
|
|
56
|
+
Paid tools are off by default. They are returned only when you ask for
|
|
57
|
+
them, and each one checks the flag again before it calls:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
tools = get_tools(allow_paid_tools=True)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Calling a paid tool while the flag is off raises
|
|
64
|
+
`PopcornPaidToolDisabledError` with the price and the condition stated
|
|
65
|
+
in the error. Turning the flag on is the caller's statement that the
|
|
66
|
+
owner has authorized the payment. Paying also needs an x402-capable
|
|
67
|
+
wallet on the calling side. This package never pays on its own.
|
|
68
|
+
|
|
69
|
+
## What a receipt proves, and what it does not
|
|
70
|
+
|
|
71
|
+
A verified receipt proves that the holder of the published key signed
|
|
72
|
+
that fingerprint and that stated time interval, and that the bytes
|
|
73
|
+
were not changed after signing. It does not prove the claim inside the
|
|
74
|
+
bytes was checked by the witness, and it does not prove delivery,
|
|
75
|
+
completion, or agreement. Verification is free and can be done offline
|
|
76
|
+
against the published keys at
|
|
77
|
+
`https://767-2676.com/.well-known/popcorn-keys.json`.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
POPCORN Read-and-Use Terms v1.2
|
|
82
|
+
(`LicenseRef-POPCORN-Read-and-Use-Terms`). Copyright 2026 Violet Herod.
|
|
83
|
+
The code is open to see and to use under those terms. It is not MIT.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""LangChain tools for POPCORN, the witness service at 767-2676.com."""
|
|
2
|
+
|
|
3
|
+
from langchain_popcorn.client import (
|
|
4
|
+
DEFAULT_MCP_URL,
|
|
5
|
+
PopcornMCPClient,
|
|
6
|
+
PopcornMCPError,
|
|
7
|
+
PopcornPaidToolDisabledError,
|
|
8
|
+
)
|
|
9
|
+
from langchain_popcorn.tools import (
|
|
10
|
+
PopcornCatalogTool,
|
|
11
|
+
PopcornHashTool,
|
|
12
|
+
PopcornSampleTool,
|
|
13
|
+
PopcornTimeTool,
|
|
14
|
+
PopcornVerifyTool,
|
|
15
|
+
PopcornVerifyV2Tool,
|
|
16
|
+
PopcornWitnessTool,
|
|
17
|
+
get_tools,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.0"
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"DEFAULT_MCP_URL",
|
|
24
|
+
"PopcornCatalogTool",
|
|
25
|
+
"PopcornHashTool",
|
|
26
|
+
"PopcornMCPClient",
|
|
27
|
+
"PopcornMCPError",
|
|
28
|
+
"PopcornPaidToolDisabledError",
|
|
29
|
+
"PopcornSampleTool",
|
|
30
|
+
"PopcornTimeTool",
|
|
31
|
+
"PopcornVerifyTool",
|
|
32
|
+
"PopcornVerifyV2Tool",
|
|
33
|
+
"PopcornWitnessTool",
|
|
34
|
+
"get_tools",
|
|
35
|
+
]
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""A small client for the POPCORN MCP endpoint.
|
|
2
|
+
|
|
3
|
+
POPCORN is the witness service at 767-2676.com, run by Violet Herod
|
|
4
|
+
(Briarwood). The endpoint speaks MCP over Streamable HTTP: POST a
|
|
5
|
+
JSON-RPC 2.0 message and read the ``data:`` line of the event-stream
|
|
6
|
+
response.
|
|
7
|
+
|
|
8
|
+
A POPCORN receipt witnesses only that the node received a fingerprint
|
|
9
|
+
within a stated interval. It does not witness agreement, authorship,
|
|
10
|
+
competence, completion, fairness, or payment. Verification depends on
|
|
11
|
+
accepting the node's key and clock.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
from typing import Any, Optional
|
|
18
|
+
|
|
19
|
+
import requests
|
|
20
|
+
|
|
21
|
+
DEFAULT_MCP_URL = "https://767-2676.com/mcp"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class PopcornMCPError(RuntimeError):
|
|
25
|
+
"""Raised when the POPCORN MCP endpoint returns an error."""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class PopcornPaidToolDisabledError(RuntimeError):
|
|
29
|
+
"""Raised when a paid tool is called while paid tools are off.
|
|
30
|
+
|
|
31
|
+
Paid POPCORN tools (popcorn_time, popcorn_witness) cost $0.001, a
|
|
32
|
+
tenth of a penny, per call, paid in USDC on Base through x402. They
|
|
33
|
+
run only when the owner of the calling agent has explicitly opted in
|
|
34
|
+
and authorized the payment.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class PopcornMCPClient:
|
|
39
|
+
"""Call tools on the POPCORN MCP endpoint."""
|
|
40
|
+
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
url: str = DEFAULT_MCP_URL,
|
|
44
|
+
timeout: float = 30.0,
|
|
45
|
+
session: Optional[requests.Session] = None,
|
|
46
|
+
) -> None:
|
|
47
|
+
self.url = url
|
|
48
|
+
self.timeout = timeout
|
|
49
|
+
self.session = session or requests.Session()
|
|
50
|
+
self._next_id = 0
|
|
51
|
+
|
|
52
|
+
def _rpc(self, method: str, params: Optional[dict] = None) -> Any:
|
|
53
|
+
self._next_id += 1
|
|
54
|
+
payload = {
|
|
55
|
+
"jsonrpc": "2.0",
|
|
56
|
+
"id": self._next_id,
|
|
57
|
+
"method": method,
|
|
58
|
+
"params": params or {},
|
|
59
|
+
}
|
|
60
|
+
response = self.session.post(
|
|
61
|
+
self.url,
|
|
62
|
+
json=payload,
|
|
63
|
+
headers={"Accept": "application/json, text/event-stream"},
|
|
64
|
+
timeout=self.timeout,
|
|
65
|
+
)
|
|
66
|
+
response.raise_for_status()
|
|
67
|
+
message = self._parse_message(response.text)
|
|
68
|
+
if "error" in message:
|
|
69
|
+
raise PopcornMCPError(f"POPCORN MCP error: {message['error']}")
|
|
70
|
+
return message.get("result")
|
|
71
|
+
|
|
72
|
+
@staticmethod
|
|
73
|
+
def _parse_message(text: str) -> dict:
|
|
74
|
+
"""Parse a JSON-RPC message out of an event-stream or JSON body."""
|
|
75
|
+
for line in text.splitlines():
|
|
76
|
+
if line.startswith("data: "):
|
|
77
|
+
return json.loads(line[len("data: ") :])
|
|
78
|
+
return json.loads(text)
|
|
79
|
+
|
|
80
|
+
def list_tools(self) -> list:
|
|
81
|
+
"""Return the server's tool list."""
|
|
82
|
+
result = self._rpc("tools/list")
|
|
83
|
+
return result.get("tools", []) if isinstance(result, dict) else []
|
|
84
|
+
|
|
85
|
+
def call_tool(self, name: str, arguments: Optional[dict] = None) -> Any:
|
|
86
|
+
"""Call one tool and return its structured content when present.
|
|
87
|
+
|
|
88
|
+
Falls back to the parsed text content, then to the raw result.
|
|
89
|
+
"""
|
|
90
|
+
result = self._rpc(
|
|
91
|
+
"tools/call", {"name": name, "arguments": arguments or {}}
|
|
92
|
+
)
|
|
93
|
+
if not isinstance(result, dict):
|
|
94
|
+
return result
|
|
95
|
+
if result.get("structuredContent") is not None:
|
|
96
|
+
return result["structuredContent"]
|
|
97
|
+
content = result.get("content") or []
|
|
98
|
+
for item in content:
|
|
99
|
+
if item.get("type") == "text":
|
|
100
|
+
try:
|
|
101
|
+
return json.loads(item["text"])
|
|
102
|
+
except (ValueError, KeyError):
|
|
103
|
+
return item.get("text")
|
|
104
|
+
return result
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"""LangChain tools for POPCORN, the witness service at 767-2676.com.
|
|
2
|
+
|
|
3
|
+
Free tools (no wallet, no payment):
|
|
4
|
+
|
|
5
|
+
- ``popcorn_sample``: check the published October 14, 2026 sample receipt
|
|
6
|
+
and a changed-digest control.
|
|
7
|
+
- ``popcorn_catalog``: read the live catalog, the offer, and the
|
|
8
|
+
published verification keys.
|
|
9
|
+
- ``popcorn_hash``: hash public bytes on the server. Hash private work
|
|
10
|
+
locally instead; submitted text reaches the server.
|
|
11
|
+
- ``popcorn_verify``: verify a time or witness receipt against a
|
|
12
|
+
caller-trusted JWKS and expected values.
|
|
13
|
+
- ``popcorn_verify_v2``: verify leTAIN TAIN 2.0 evidence against the
|
|
14
|
+
keys published by the issuer.
|
|
15
|
+
|
|
16
|
+
Paid tools (off by default):
|
|
17
|
+
|
|
18
|
+
- ``popcorn_time`` and ``popcorn_witness`` each cost $0.001, a tenth of
|
|
19
|
+
a penny, paid in USDC on Base through x402. They are included only
|
|
20
|
+
when the caller passes ``allow_paid_tools=True`` to :func:`get_tools`
|
|
21
|
+
(or sets the tool's own ``allow_paid`` field), and calling one while
|
|
22
|
+
it is off raises :class:`PopcornPaidToolDisabledError`. Paying needs
|
|
23
|
+
an x402-capable wallet and the owner's explicit authorization for the
|
|
24
|
+
payment. This package never pays on its own.
|
|
25
|
+
|
|
26
|
+
A receipt is evidence, not permission. A POPCORN receipt witnesses only
|
|
27
|
+
that the node received a fingerprint within a stated interval.
|
|
28
|
+
Verification depends on accepting the node's key and clock.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
from __future__ import annotations
|
|
32
|
+
|
|
33
|
+
from typing import Any, Optional, Type
|
|
34
|
+
|
|
35
|
+
from langchain_core.tools import BaseTool
|
|
36
|
+
from pydantic import BaseModel, Field
|
|
37
|
+
|
|
38
|
+
from langchain_popcorn.client import (
|
|
39
|
+
PopcornMCPClient,
|
|
40
|
+
PopcornPaidToolDisabledError,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
PAID_TOOL_PRICE_NOTE = (
|
|
44
|
+
"This is a paid POPCORN tool. It costs $0.001, a tenth of a penny, "
|
|
45
|
+
"paid in USDC on Base through x402, and it needs the owner's "
|
|
46
|
+
"explicit authorization for the payment."
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class _NoInput(BaseModel):
|
|
51
|
+
"""A tool that takes no arguments."""
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class PopcornHashInput(BaseModel):
|
|
55
|
+
payload_text: Optional[str] = Field(
|
|
56
|
+
default=None,
|
|
57
|
+
description=(
|
|
58
|
+
"Public text to hash on the server. Submitted text reaches "
|
|
59
|
+
"the server, so hash private work locally instead. Give one "
|
|
60
|
+
"of payload_text or payload_base64url."
|
|
61
|
+
),
|
|
62
|
+
)
|
|
63
|
+
payload_base64url: Optional[str] = Field(
|
|
64
|
+
default=None,
|
|
65
|
+
description=(
|
|
66
|
+
"Public bytes to hash, as base64url. Give one of "
|
|
67
|
+
"payload_text or payload_base64url."
|
|
68
|
+
),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class PopcornVerifyInput(BaseModel):
|
|
73
|
+
receipt_type: str = Field(
|
|
74
|
+
description="The kind of receipt being verified: 'time' or 'witness'."
|
|
75
|
+
)
|
|
76
|
+
response: dict = Field(
|
|
77
|
+
description="The receipt response to verify, as returned by the time or witness call."
|
|
78
|
+
)
|
|
79
|
+
jwks: dict = Field(
|
|
80
|
+
description="The JWKS you trust, holding the keys the receipt signature is checked against."
|
|
81
|
+
)
|
|
82
|
+
verification: dict = Field(
|
|
83
|
+
description="The expected values the receipt is checked against."
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class PopcornVerifyV2Input(BaseModel):
|
|
88
|
+
response: dict = Field(
|
|
89
|
+
description="The TAIN 2.0 receipt response to verify. Send a digest, never private work."
|
|
90
|
+
)
|
|
91
|
+
jwks: dict = Field(
|
|
92
|
+
description=(
|
|
93
|
+
"Accepted to match the call shape. The check replaces it "
|
|
94
|
+
"with the published keys fetched from the fixed POPCORN "
|
|
95
|
+
"issuer address."
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
expected_nonce: str = Field(
|
|
99
|
+
description="The nonce the receipt must carry."
|
|
100
|
+
)
|
|
101
|
+
expected_payload_digest: str = Field(
|
|
102
|
+
description="The payload digest the receipt must carry."
|
|
103
|
+
)
|
|
104
|
+
expected_node_id: Optional[str] = Field(
|
|
105
|
+
default=None, description="Optional. The node id the receipt must carry."
|
|
106
|
+
)
|
|
107
|
+
max_clock_accuracy_radius_ms: Optional[int] = Field(
|
|
108
|
+
default=None,
|
|
109
|
+
description="Optional. The largest clock accuracy radius, in milliseconds, the check accepts.",
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class PopcornTimeInput(BaseModel):
|
|
114
|
+
freshness_ms: Optional[int] = Field(
|
|
115
|
+
default=None,
|
|
116
|
+
description="Optional freshness window, in milliseconds, for the signed time.",
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class PopcornWitnessInput(BaseModel):
|
|
121
|
+
digest: str = Field(
|
|
122
|
+
description="The payload digest to witness. Send a digest, never the raw work."
|
|
123
|
+
)
|
|
124
|
+
nonce: str = Field(description="A nonce for this witness request.")
|
|
125
|
+
previous_attestation_digest: Optional[str] = Field(
|
|
126
|
+
default=None,
|
|
127
|
+
description="Optional. The digest of the previous attestation to link to.",
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class _PopcornTool(BaseTool):
|
|
132
|
+
"""Base class wiring a LangChain tool to the POPCORN MCP client."""
|
|
133
|
+
|
|
134
|
+
client: Any = Field(default=None, exclude=True)
|
|
135
|
+
|
|
136
|
+
def _client(self) -> PopcornMCPClient:
|
|
137
|
+
if self.client is None:
|
|
138
|
+
self.client = PopcornMCPClient()
|
|
139
|
+
return self.client
|
|
140
|
+
|
|
141
|
+
def _call(self, tool_name: str, arguments: dict) -> Any:
|
|
142
|
+
return self._client().call_tool(tool_name, arguments)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class PopcornSampleTool(_PopcornTool):
|
|
146
|
+
name: str = "popcorn_sample"
|
|
147
|
+
description: str = (
|
|
148
|
+
"Check the public October 14, 2026 POPCORN sample receipt and a "
|
|
149
|
+
"changed-digest control. Free. No inputs, no wallet, no payment. "
|
|
150
|
+
"Historical evidence, not a fresh clock."
|
|
151
|
+
)
|
|
152
|
+
args_schema: Type[BaseModel] = _NoInput
|
|
153
|
+
|
|
154
|
+
def _run(self, **kwargs: Any) -> Any:
|
|
155
|
+
return self._call("popcorn_sample", {})
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class PopcornCatalogTool(_PopcornTool):
|
|
159
|
+
name: str = "popcorn_catalog"
|
|
160
|
+
description: str = (
|
|
161
|
+
"Read the POPCORN live catalog, the offer, and the published "
|
|
162
|
+
"verification keys. Free; no payment."
|
|
163
|
+
)
|
|
164
|
+
args_schema: Type[BaseModel] = _NoInput
|
|
165
|
+
|
|
166
|
+
def _run(self, **kwargs: Any) -> Any:
|
|
167
|
+
return self._call("popcorn_catalog", {})
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class PopcornHashTool(_PopcornTool):
|
|
171
|
+
name: str = "popcorn_hash"
|
|
172
|
+
description: str = (
|
|
173
|
+
"Hash public bytes on the POPCORN server and return the SHA-256 "
|
|
174
|
+
"digest. Free. Submitted text reaches the server, so hash "
|
|
175
|
+
"private work locally instead."
|
|
176
|
+
)
|
|
177
|
+
args_schema: Type[BaseModel] = PopcornHashInput
|
|
178
|
+
|
|
179
|
+
def _run(
|
|
180
|
+
self,
|
|
181
|
+
payload_text: Optional[str] = None,
|
|
182
|
+
payload_base64url: Optional[str] = None,
|
|
183
|
+
**kwargs: Any,
|
|
184
|
+
) -> Any:
|
|
185
|
+
if (payload_text is None) == (payload_base64url is None):
|
|
186
|
+
raise ValueError(
|
|
187
|
+
"Give exactly one of payload_text or payload_base64url."
|
|
188
|
+
)
|
|
189
|
+
arguments = {}
|
|
190
|
+
if payload_text is not None:
|
|
191
|
+
arguments["payload_text"] = payload_text
|
|
192
|
+
if payload_base64url is not None:
|
|
193
|
+
arguments["payload_base64url"] = payload_base64url
|
|
194
|
+
return self._call("popcorn_hash", arguments)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class PopcornVerifyTool(_PopcornTool):
|
|
198
|
+
name: str = "popcorn_verify"
|
|
199
|
+
description: str = (
|
|
200
|
+
"Verify a POPCORN time or witness receipt using a caller-trusted "
|
|
201
|
+
"JWKS and expected values. Free; no payment. Caller keys do not "
|
|
202
|
+
"establish issuer identity, and a signature grants no authority. "
|
|
203
|
+
"Verification depends on accepting the node's key and clock."
|
|
204
|
+
)
|
|
205
|
+
args_schema: Type[BaseModel] = PopcornVerifyInput
|
|
206
|
+
|
|
207
|
+
def _run(
|
|
208
|
+
self,
|
|
209
|
+
receipt_type: str,
|
|
210
|
+
response: dict,
|
|
211
|
+
jwks: dict,
|
|
212
|
+
verification: dict,
|
|
213
|
+
**kwargs: Any,
|
|
214
|
+
) -> Any:
|
|
215
|
+
return self._call(
|
|
216
|
+
"popcorn_verify",
|
|
217
|
+
{
|
|
218
|
+
"receipt_type": receipt_type,
|
|
219
|
+
"response": response,
|
|
220
|
+
"jwks": jwks,
|
|
221
|
+
"verification": verification,
|
|
222
|
+
},
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class PopcornVerifyV2Tool(_PopcornTool):
|
|
227
|
+
name: str = "popcorn_verify_v2"
|
|
228
|
+
description: str = (
|
|
229
|
+
"Verify leTAIN TAIN 2.0 evidence against the keys published by "
|
|
230
|
+
"the POPCORN issuer. Free. Does not grant authority, establish "
|
|
231
|
+
"current time, or verify settlement on chain."
|
|
232
|
+
)
|
|
233
|
+
args_schema: Type[BaseModel] = PopcornVerifyV2Input
|
|
234
|
+
|
|
235
|
+
def _run(
|
|
236
|
+
self,
|
|
237
|
+
response: dict,
|
|
238
|
+
jwks: dict,
|
|
239
|
+
expected_nonce: str,
|
|
240
|
+
expected_payload_digest: str,
|
|
241
|
+
expected_node_id: Optional[str] = None,
|
|
242
|
+
max_clock_accuracy_radius_ms: Optional[int] = None,
|
|
243
|
+
**kwargs: Any,
|
|
244
|
+
) -> Any:
|
|
245
|
+
arguments: dict[str, Any] = {
|
|
246
|
+
"response": response,
|
|
247
|
+
"jwks": jwks,
|
|
248
|
+
"expected_nonce": expected_nonce,
|
|
249
|
+
"expected_payload_digest": expected_payload_digest,
|
|
250
|
+
}
|
|
251
|
+
if expected_node_id is not None:
|
|
252
|
+
arguments["expected_node_id"] = expected_node_id
|
|
253
|
+
if max_clock_accuracy_radius_ms is not None:
|
|
254
|
+
arguments["max_clock_accuracy_radius_ms"] = (
|
|
255
|
+
max_clock_accuracy_radius_ms
|
|
256
|
+
)
|
|
257
|
+
return self._call("popcorn_verify_v2", arguments)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class _PaidPopcornTool(_PopcornTool):
|
|
261
|
+
allow_paid: bool = Field(
|
|
262
|
+
default=False,
|
|
263
|
+
description=(
|
|
264
|
+
"Explicit opt-in for paid POPCORN calls. Defaults to off. "
|
|
265
|
+
+ PAID_TOOL_PRICE_NOTE
|
|
266
|
+
),
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
def _require_paid_allowed(self, tool_name: str) -> None:
|
|
270
|
+
if not self.allow_paid:
|
|
271
|
+
raise PopcornPaidToolDisabledError(
|
|
272
|
+
f"{tool_name} is a paid tool and paid tools are off. "
|
|
273
|
+
+ PAID_TOOL_PRICE_NOTE
|
|
274
|
+
+ " Set allow_paid=True only with that authorization."
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
class PopcornTimeTool(_PaidPopcornTool):
|
|
279
|
+
name: str = "popcorn_time"
|
|
280
|
+
description: str = (
|
|
281
|
+
"Buy a fresh signed time anchor from POPCORN. " + PAID_TOOL_PRICE_NOTE
|
|
282
|
+
)
|
|
283
|
+
args_schema: Type[BaseModel] = PopcornTimeInput
|
|
284
|
+
|
|
285
|
+
def _run(self, freshness_ms: Optional[int] = None, **kwargs: Any) -> Any:
|
|
286
|
+
self._require_paid_allowed("popcorn_time")
|
|
287
|
+
arguments = {}
|
|
288
|
+
if freshness_ms is not None:
|
|
289
|
+
arguments["freshness_ms"] = freshness_ms
|
|
290
|
+
return self._call("popcorn_time", arguments)
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
class PopcornWitnessTool(_PaidPopcornTool):
|
|
294
|
+
name: str = "popcorn_witness"
|
|
295
|
+
description: str = (
|
|
296
|
+
"Buy a fresh POPCORN witness receipt for a payload digest. "
|
|
297
|
+
"A receipt witnesses only that the node received a fingerprint "
|
|
298
|
+
"within a stated interval. " + PAID_TOOL_PRICE_NOTE
|
|
299
|
+
)
|
|
300
|
+
args_schema: Type[BaseModel] = PopcornWitnessInput
|
|
301
|
+
|
|
302
|
+
def _run(
|
|
303
|
+
self,
|
|
304
|
+
digest: str,
|
|
305
|
+
nonce: str,
|
|
306
|
+
previous_attestation_digest: Optional[str] = None,
|
|
307
|
+
**kwargs: Any,
|
|
308
|
+
) -> Any:
|
|
309
|
+
self._require_paid_allowed("popcorn_witness")
|
|
310
|
+
arguments: dict[str, Any] = {"digest": digest, "nonce": nonce}
|
|
311
|
+
if previous_attestation_digest is not None:
|
|
312
|
+
arguments["previous_attestation_digest"] = (
|
|
313
|
+
previous_attestation_digest
|
|
314
|
+
)
|
|
315
|
+
return self._call("popcorn_witness", arguments)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def get_tools(
|
|
319
|
+
client: Optional[PopcornMCPClient] = None,
|
|
320
|
+
allow_paid_tools: bool = False,
|
|
321
|
+
) -> list:
|
|
322
|
+
"""Return the POPCORN LangChain tools.
|
|
323
|
+
|
|
324
|
+
The five free tools are always returned. The two paid tools are
|
|
325
|
+
returned only when ``allow_paid_tools`` is True, and each paid tool
|
|
326
|
+
also carries the flag on itself, so a paid call made while the flag
|
|
327
|
+
is off fails with a clear error instead of spending.
|
|
328
|
+
"""
|
|
329
|
+
client = client or PopcornMCPClient()
|
|
330
|
+
tools: list = [
|
|
331
|
+
PopcornSampleTool(client=client),
|
|
332
|
+
PopcornCatalogTool(client=client),
|
|
333
|
+
PopcornHashTool(client=client),
|
|
334
|
+
PopcornVerifyTool(client=client),
|
|
335
|
+
PopcornVerifyV2Tool(client=client),
|
|
336
|
+
]
|
|
337
|
+
if allow_paid_tools:
|
|
338
|
+
tools.append(PopcornTimeTool(client=client, allow_paid=True))
|
|
339
|
+
tools.append(PopcornWitnessTool(client=client, allow_paid=True))
|
|
340
|
+
return tools
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "langchain-popcorn"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "LangChain tools for POPCORN, the witness service at 767-2676.com run by Violet Herod (Briarwood). Free receipt verification tools, plus paid signed time and witness tools behind an explicit opt-in flag."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "LicenseRef-POPCORN-Read-and-Use-Terms" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Violet Herod", email = "violet@briarwood.ai" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["langchain", "popcorn", "witness", "receipt", "mcp", "x402", "timestamp"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"langchain-core>=0.3.0",
|
|
24
|
+
"pydantic>=2.0.0",
|
|
25
|
+
"requests>=2.31.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
test = ["pytest>=8.0.0"]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://767-2676.com/"
|
|
33
|
+
Documentation = "https://767-2676.com/"
|
|
34
|
+
Repository = "https://github.com/violetclaire/popcorn-temporal-anchor"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.wheel]
|
|
37
|
+
packages = ["langchain_popcorn"]
|
|
38
|
+
|
|
39
|
+
[tool.pytest.ini_options]
|
|
40
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Unit tests for langchain-popcorn.
|
|
2
|
+
|
|
3
|
+
These tests use a fake client. They never touch the network and never
|
|
4
|
+
call a paid POPCORN tool.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from langchain_popcorn import (
|
|
10
|
+
PopcornMCPClient,
|
|
11
|
+
PopcornPaidToolDisabledError,
|
|
12
|
+
PopcornTimeTool,
|
|
13
|
+
PopcornWitnessTool,
|
|
14
|
+
get_tools,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class FakeClient:
|
|
19
|
+
"""Records calls and returns a canned result."""
|
|
20
|
+
|
|
21
|
+
def __init__(self):
|
|
22
|
+
self.calls = []
|
|
23
|
+
|
|
24
|
+
def call_tool(self, name, arguments=None):
|
|
25
|
+
self.calls.append((name, arguments or {}))
|
|
26
|
+
return {"called": name, "arguments": arguments or {}}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_get_tools_free_by_default():
|
|
30
|
+
tools = get_tools(client=FakeClient())
|
|
31
|
+
names = [tool.name for tool in tools]
|
|
32
|
+
assert names == [
|
|
33
|
+
"popcorn_sample",
|
|
34
|
+
"popcorn_catalog",
|
|
35
|
+
"popcorn_hash",
|
|
36
|
+
"popcorn_verify",
|
|
37
|
+
"popcorn_verify_v2",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_get_tools_paid_only_with_opt_in():
|
|
42
|
+
tools = get_tools(client=FakeClient(), allow_paid_tools=True)
|
|
43
|
+
names = [tool.name for tool in tools]
|
|
44
|
+
assert "popcorn_time" in names
|
|
45
|
+
assert "popcorn_witness" in names
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_sample_tool_calls_endpoint_tool():
|
|
49
|
+
fake = FakeClient()
|
|
50
|
+
tool = {t.name: t for t in get_tools(client=fake)}["popcorn_sample"]
|
|
51
|
+
result = tool.invoke({})
|
|
52
|
+
assert result == {"called": "popcorn_sample", "arguments": {}}
|
|
53
|
+
assert fake.calls == [("popcorn_sample", {})]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_catalog_tool_calls_endpoint_tool():
|
|
57
|
+
fake = FakeClient()
|
|
58
|
+
tool = {t.name: t for t in get_tools(client=fake)}["popcorn_catalog"]
|
|
59
|
+
result = tool.invoke({})
|
|
60
|
+
assert result["called"] == "popcorn_catalog"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_hash_tool_passes_text():
|
|
64
|
+
fake = FakeClient()
|
|
65
|
+
tool = {t.name: t for t in get_tools(client=fake)}["popcorn_hash"]
|
|
66
|
+
result = tool.invoke({"payload_text": "hello"})
|
|
67
|
+
assert fake.calls == [("popcorn_hash", {"payload_text": "hello"})]
|
|
68
|
+
assert result["called"] == "popcorn_hash"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_hash_tool_requires_exactly_one_input():
|
|
72
|
+
tool = {t.name: t for t in get_tools(client=FakeClient())}["popcorn_hash"]
|
|
73
|
+
with pytest.raises(ValueError):
|
|
74
|
+
tool.invoke({})
|
|
75
|
+
with pytest.raises(ValueError):
|
|
76
|
+
tool.invoke({"payload_text": "a", "payload_base64url": "YQ"})
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_verify_v2_tool_passes_expected_values():
|
|
80
|
+
fake = FakeClient()
|
|
81
|
+
tool = {t.name: t for t in get_tools(client=fake)}["popcorn_verify_v2"]
|
|
82
|
+
tool.invoke(
|
|
83
|
+
{
|
|
84
|
+
"response": {"receipt": 1},
|
|
85
|
+
"jwks": {"keys": []},
|
|
86
|
+
"expected_nonce": "n1",
|
|
87
|
+
"expected_payload_digest": "d1",
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
assert fake.calls == [
|
|
91
|
+
(
|
|
92
|
+
"popcorn_verify_v2",
|
|
93
|
+
{
|
|
94
|
+
"response": {"receipt": 1},
|
|
95
|
+
"jwks": {"keys": []},
|
|
96
|
+
"expected_nonce": "n1",
|
|
97
|
+
"expected_payload_digest": "d1",
|
|
98
|
+
},
|
|
99
|
+
)
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_paid_time_tool_blocked_by_default():
|
|
104
|
+
tool = PopcornTimeTool(client=FakeClient())
|
|
105
|
+
with pytest.raises(PopcornPaidToolDisabledError) as excinfo:
|
|
106
|
+
tool.invoke({})
|
|
107
|
+
assert "$0.001" in str(excinfo.value)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_paid_witness_tool_blocked_by_default():
|
|
111
|
+
tool = PopcornWitnessTool(client=FakeClient())
|
|
112
|
+
with pytest.raises(PopcornPaidToolDisabledError):
|
|
113
|
+
tool.invoke({"digest": "abc", "nonce": "n1"})
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_paid_tool_with_opt_in_calls_client():
|
|
117
|
+
fake = FakeClient()
|
|
118
|
+
tool = PopcornTimeTool(client=fake, allow_paid=True)
|
|
119
|
+
result = tool.invoke({})
|
|
120
|
+
assert result["called"] == "popcorn_time"
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def test_client_parses_event_stream_message():
|
|
124
|
+
message = PopcornMCPClient._parse_message(
|
|
125
|
+
'event: message\ndata: {"jsonrpc": "2.0", "id": 1, "result": {"ok": true}}\n\n'
|
|
126
|
+
)
|
|
127
|
+
assert message["result"] == {"ok": True}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_client_parses_plain_json_message():
|
|
131
|
+
message = PopcornMCPClient._parse_message('{"result": 3}')
|
|
132
|
+
assert message["result"] == 3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"$schema":"https://openapi.vercel.sh/vercel.json","ignoreCommand":"exit 0"}
|