talocode-loop 0.1.0__py3-none-any.whl
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.
- talocode_loop/__init__.py +6 -0
- talocode_loop/cli.py +20 -0
- talocode_loop/loop.py +87 -0
- talocode_loop-0.1.0.dist-info/METADATA +51 -0
- talocode_loop-0.1.0.dist-info/RECORD +9 -0
- talocode_loop-0.1.0.dist-info/WHEEL +5 -0
- talocode_loop-0.1.0.dist-info/entry_points.txt +2 -0
- talocode_loop-0.1.0.dist-info/licenses/LICENSE +21 -0
- talocode_loop-0.1.0.dist-info/top_level.txt +1 -0
talocode_loop/cli.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Command line for the Talocode loop."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from talocode_loop.loop import run_loop
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main() -> None:
|
|
11
|
+
parser = argparse.ArgumentParser(description="Search, verify, trace, and remember one Talocode loop.")
|
|
12
|
+
parser.add_argument("command", nargs="?", default="run", choices=["run"])
|
|
13
|
+
parser.add_argument("--query", default="Talocode official mint and credit claim")
|
|
14
|
+
parser.add_argument("--url", default="https://talocode.site/llms.txt")
|
|
15
|
+
parser.add_argument("--claim", default="6ptxwABxQz8zMhwhiPeVgRgWjGMdVcEBFBv8v8C3ory")
|
|
16
|
+
args = parser.parse_args()
|
|
17
|
+
receipt = run_loop(args.query, args.url, args.claim)
|
|
18
|
+
json.dump(receipt.to_dict(), sys.stdout, indent=2)
|
|
19
|
+
sys.stdout.write("\n")
|
|
20
|
+
raise SystemExit(0 if receipt.ok else 1)
|
talocode_loop/loop.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Search, verify, trace, and remember one Talocode loop."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import uuid
|
|
7
|
+
from dataclasses import asdict, dataclass
|
|
8
|
+
from datetime import datetime, timezone
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from urllib.request import Request, urlopen
|
|
11
|
+
|
|
12
|
+
STORE = Path.home() / ".talocode" / "loop-memory.json"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class Receipt:
|
|
17
|
+
ok: bool
|
|
18
|
+
product: str
|
|
19
|
+
version: str
|
|
20
|
+
query: str
|
|
21
|
+
url: str
|
|
22
|
+
trace_id: str
|
|
23
|
+
steps: list
|
|
24
|
+
|
|
25
|
+
def to_dict(self) -> dict:
|
|
26
|
+
return asdict(self)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def search(query: str, url: str) -> dict:
|
|
30
|
+
request = Request(url, headers={"user-agent": "talocode-loop/0.1"})
|
|
31
|
+
with urlopen(request, timeout=20) as response:
|
|
32
|
+
text = response.read().decode("utf-8", "replace")
|
|
33
|
+
status = response.status
|
|
34
|
+
words = [word.lower() for word in query.split() if len(word) > 3]
|
|
35
|
+
matches = [line for line in text.splitlines() if any(word in line.lower() for word in words)]
|
|
36
|
+
return {"name": "search", "ok": status == 200, "url": url, "status": status, "matches": matches[:8], "text": text}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def verify(text: str, claim: str) -> dict:
|
|
40
|
+
found = claim in text
|
|
41
|
+
return {
|
|
42
|
+
"name": "verify",
|
|
43
|
+
"ok": found,
|
|
44
|
+
"claim": claim,
|
|
45
|
+
"found": found,
|
|
46
|
+
"error": None if found else "claim not present in searched source",
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def remember(trace_id: str, query: str, claim: str, ok: bool) -> dict:
|
|
51
|
+
STORE.parent.mkdir(parents=True, exist_ok=True)
|
|
52
|
+
items = []
|
|
53
|
+
if STORE.exists():
|
|
54
|
+
items = json.loads(STORE.read_text())
|
|
55
|
+
memory = {
|
|
56
|
+
"id": str(uuid.uuid4()),
|
|
57
|
+
"traceId": trace_id,
|
|
58
|
+
"query": query,
|
|
59
|
+
"claim": claim,
|
|
60
|
+
"ok": ok,
|
|
61
|
+
"at": datetime.now(timezone.utc).isoformat(),
|
|
62
|
+
}
|
|
63
|
+
items.append(memory)
|
|
64
|
+
STORE.write_text(json.dumps(items[-50:], indent=2))
|
|
65
|
+
return {"name": "remember", "ok": True, "memory": memory}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def run_loop(query: str, url: str, claim: str) -> Receipt:
|
|
69
|
+
searched = search(query, url)
|
|
70
|
+
verified = verify(searched["text"], claim)
|
|
71
|
+
trace_id = f"loop_{uuid.uuid4()}"
|
|
72
|
+
traced = {
|
|
73
|
+
"name": "trace",
|
|
74
|
+
"ok": searched["ok"] and verified["ok"],
|
|
75
|
+
"id": trace_id,
|
|
76
|
+
"spans": [{k: v for k, v in searched.items() if k != "text"}, verified],
|
|
77
|
+
}
|
|
78
|
+
remembered = remember(trace_id, query, claim, traced["ok"])
|
|
79
|
+
return Receipt(
|
|
80
|
+
ok=traced["ok"],
|
|
81
|
+
product="talocode-loop",
|
|
82
|
+
version="0.1.0",
|
|
83
|
+
query=query,
|
|
84
|
+
url=url,
|
|
85
|
+
trace_id=trace_id,
|
|
86
|
+
steps=[{k: v for k, v in searched.items() if k != "text"}, verified, traced, remembered],
|
|
87
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: talocode-loop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The Talocode loop for agents: search a source, verify a claim against it, trace the run, and remember the receipt. CLI and SDK for the same local loop.
|
|
5
|
+
Author-email: Talocode <hello@talocode.site>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://talocode.site
|
|
8
|
+
Project-URL: Repository, https://github.com/talocode/loop
|
|
9
|
+
Project-URL: Issues, https://github.com/talocode/loop/issues
|
|
10
|
+
Keywords: talocode,agents,cli,verify,trace,search,memory
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Software Development
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# talocode-loop
|
|
19
|
+
|
|
20
|
+
The Talocode loop is one path: search a source, verify a claim against it, trace the run, and remember the receipt.
|
|
21
|
+
|
|
22
|
+
A failing verify returns the error. It does not pretend the run succeeded.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install talocode-loop
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## CLI
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
talocode-loop run \
|
|
34
|
+
--query "Talocode official mint" \
|
|
35
|
+
--url https://talocode.site/llms.txt \
|
|
36
|
+
--claim 6ptxwABxQz8zMhwhiPeVgRgWjGMdVcEBFBv8v8C3ory
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## SDK
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from talocode_loop import run_loop
|
|
43
|
+
|
|
44
|
+
receipt = run_loop(
|
|
45
|
+
"Talocode official mint",
|
|
46
|
+
"https://talocode.site/llms.txt",
|
|
47
|
+
"6ptxwABxQz8zMhwhiPeVgRgWjGMdVcEBFBv8v8C3ory",
|
|
48
|
+
)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The Node package is `@talocode/loop`. The repository is https://github.com/talocode/loop.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
talocode_loop/__init__.py,sha256=gru9zJUXtGQodtMqSwjyi0aqrS_cXO07e-98HtPUbVA,141
|
|
2
|
+
talocode_loop/cli.py,sha256=Y_16E6Kf6ldwLkiKBZlPbMYuXwxOd1yptN5EizZoE1w,796
|
|
3
|
+
talocode_loop/loop.py,sha256=5YdUFX3uo90s7_NLU0IMKYztuSMX5S8Mymi7-3glprs,2603
|
|
4
|
+
talocode_loop-0.1.0.dist-info/licenses/LICENSE,sha256=zk3xDU_kSwGYShYRgHiKyIqpG4TqQXkV2P31R-6U3-Q,1065
|
|
5
|
+
talocode_loop-0.1.0.dist-info/METADATA,sha256=rziruydKGAi6n8JvRi5wpm0WQRTrzEHj-70dXjAwVAQ,1430
|
|
6
|
+
talocode_loop-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
7
|
+
talocode_loop-0.1.0.dist-info/entry_points.txt,sha256=SodSfacWXES2riEda8qNYpIt3VOl6Wrvq_czetawaIM,57
|
|
8
|
+
talocode_loop-0.1.0.dist-info/top_level.txt,sha256=0exE1VrpCk5U3gwis14LkoUWbItxAdrf6TxwjTPYdWs,14
|
|
9
|
+
talocode_loop-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Talocode
|
|
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 @@
|
|
|
1
|
+
talocode_loop
|