deusproof 0.3.0__tar.gz → 0.4.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.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deusproof
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Prove your AI agent's work existed at a given moment — one call, self-signed, timestamped and Bitcoin-anchored on a public append-only register. Free.
5
5
  Author: DEUSPROOF
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://deusproof.com
8
8
  Project-URL: Pantheon, https://deusproof.com/pantheon
9
- Keywords: ai-agents,provenance,audit-log,tamper-evident,did,bitcoin,rfc3161,langchain,langgraph
9
+ Keywords: ai-agents,provenance,audit-log,tamper-evident,did,bitcoin,rfc3161,langchain,langgraph,claude-code,cli
10
10
  Requires-Python: >=3.9
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: httpx>=0.24
@@ -106,6 +106,39 @@ It records runs, tool calls and model outputs (hashed; add `keep_payload=True` t
106
106
  the local file), and seals the head once when each top-level run ends. A failed seal never breaks
107
107
  your agent's run. Guide: https://deusproof.com/guides/tamper-evident-agent-logs
108
108
 
109
+ ## Seal any log you already have: no code changes
110
+
111
+ Your tool already writes a log (an agent runtime, an audit trail, a JSONL of tool calls)? Seal it
112
+ from the command line. Only its SHA-256 leaves your machine.
113
+
114
+ ```bash
115
+ deusproof seal runtime.jsonl --handle my-endpoint # e.g. once a day from cron
116
+ deusproof verify runtime.jsonl # anyone, any time, offline
117
+ ```
118
+
119
+ Logs grow, so each receipt records how many bytes it covered and `verify` re-hashes exactly that
120
+ part: lines appended later still pass; anything changed or cut inside a sealed part fails. Receipts
121
+ are kept beside the file in `runtime.jsonl.deusproof.jsonl` (no content, just digest, size, time
122
+ and the link to check the timestamp and the Bitcoin anchor).
123
+
124
+ ### Claude Code: every session sealed
125
+
126
+ Add a `SessionEnd` hook to `.claude/settings.json` (or `~/.claude/settings.json` for all projects):
127
+
128
+ ```json
129
+ {
130
+ "hooks": {
131
+ "SessionEnd": [
132
+ { "hooks": [ { "type": "command",
133
+ "command": "deusproof seal --hook --handle my-dev-agent --platform claude-code" } ] }
134
+ ]
135
+ }
136
+ }
137
+ ```
138
+
139
+ When a session ends, its transcript is fingerprinted and sealed. The transcript never leaves your
140
+ machine. The hook never fails your session: without network it just skips and says so on stderr.
141
+
109
142
  ## Use it from LangChain
110
143
 
111
144
  ```bash
@@ -88,6 +88,39 @@ It records runs, tool calls and model outputs (hashed; add `keep_payload=True` t
88
88
  the local file), and seals the head once when each top-level run ends. A failed seal never breaks
89
89
  your agent's run. Guide: https://deusproof.com/guides/tamper-evident-agent-logs
90
90
 
91
+ ## Seal any log you already have: no code changes
92
+
93
+ Your tool already writes a log (an agent runtime, an audit trail, a JSONL of tool calls)? Seal it
94
+ from the command line. Only its SHA-256 leaves your machine.
95
+
96
+ ```bash
97
+ deusproof seal runtime.jsonl --handle my-endpoint # e.g. once a day from cron
98
+ deusproof verify runtime.jsonl # anyone, any time, offline
99
+ ```
100
+
101
+ Logs grow, so each receipt records how many bytes it covered and `verify` re-hashes exactly that
102
+ part: lines appended later still pass; anything changed or cut inside a sealed part fails. Receipts
103
+ are kept beside the file in `runtime.jsonl.deusproof.jsonl` (no content, just digest, size, time
104
+ and the link to check the timestamp and the Bitcoin anchor).
105
+
106
+ ### Claude Code: every session sealed
107
+
108
+ Add a `SessionEnd` hook to `.claude/settings.json` (or `~/.claude/settings.json` for all projects):
109
+
110
+ ```json
111
+ {
112
+ "hooks": {
113
+ "SessionEnd": [
114
+ { "hooks": [ { "type": "command",
115
+ "command": "deusproof seal --hook --handle my-dev-agent --platform claude-code" } ] }
116
+ ]
117
+ }
118
+ }
119
+ ```
120
+
121
+ When a session ends, its transcript is fingerprinted and sealed. The transcript never leaves your
122
+ machine. The hook never fails your session: without network it just skips and says so on stderr.
123
+
91
124
  ## Use it from LangChain
92
125
 
93
126
  ```bash
@@ -15,4 +15,4 @@
15
15
  from .notary import Notary, Proof
16
16
 
17
17
  __all__ = ["Notary", "Proof"]
18
- __version__ = "0.3.0"
18
+ __version__ = "0.4.0"
@@ -0,0 +1,205 @@
1
+ """`deusproof` — seal any file or log from the command line, with no code changes.
2
+
3
+ deusproof seal runtime.jsonl --handle my-endpoint # once a day, from cron
4
+ deusproof verify runtime.jsonl # anyone, any time later
5
+ deusproof audit verify agent-audit.jsonl # the hash-chained log of deusproof.audit
6
+
7
+ WHY (16-nov-2026). Asking every tool to integrate a witness means waiting for
8
+ every maintainer. A command means any USER of any tool that already writes a
9
+ log (an agent runtime, a coding assistant, an audit trail) can get an outside
10
+ timestamp today, by themselves. Only the SHA-256 leaves the machine.
11
+
12
+ APPEND-ONLY LOGS. Logs grow. A seal records the byte length it covered, and
13
+ `verify` re-hashes exactly that prefix: "the first N bytes are as they were
14
+ when sealed; M bytes were added afterwards" is a pass, because appending is
15
+ what a log does. Changing or deleting anything inside the sealed prefix is a
16
+ fail. So the same receipt keeps meaning something while the log keeps growing.
17
+
18
+ RECEIPTS. Each seal appends one JSON line to `<file>.deusproof.jsonl` beside the
19
+ file (or `--receipts PATH`). It holds no content: digest, byte length, time,
20
+ certificate id and the URL where anyone can check the timestamp and the Bitcoin
21
+ anchor. Keep it with the file.
22
+
23
+ HOOK MODE. `deusproof seal --hook` reads a hook event as JSON on stdin and seals
24
+ its `transcript_path`. That makes it a one-line SessionEnd hook for Claude Code
25
+ (and any tool that passes a transcript path the same way). In hook mode it
26
+ never fails the caller: errors go to stderr and the exit code is 0.
27
+ """
28
+
29
+ from __future__ import annotations
30
+
31
+ import argparse
32
+ import hashlib
33
+ import json
34
+ import os
35
+ import sys
36
+ from datetime import datetime, timezone
37
+ from pathlib import Path
38
+ from typing import Any, Optional
39
+
40
+ __all__ = ["seal_file", "verify_file", "main"]
41
+
42
+ _CHUNK = 1 << 20
43
+
44
+
45
+ def _sha256_prefix(path: Path, length: Optional[int] = None) -> tuple[str, int]:
46
+ """SHA-256 of the first `length` bytes (the whole file if None). Returns (hex, bytes hashed)."""
47
+ h = hashlib.sha256()
48
+ done = 0
49
+ with path.open("rb") as fh:
50
+ while length is None or done < length:
51
+ want = _CHUNK if length is None else min(_CHUNK, length - done)
52
+ block = fh.read(want)
53
+ if not block:
54
+ break
55
+ h.update(block)
56
+ done += len(block)
57
+ return h.hexdigest(), done
58
+
59
+
60
+ def _receipts_path(path: Path, receipts: Optional[str]) -> Path:
61
+ return Path(receipts) if receipts else path.with_name(path.name + ".deusproof.jsonl")
62
+
63
+
64
+ def _read_receipts(rp: Path) -> list[dict]:
65
+ if not rp.exists():
66
+ return []
67
+ out = []
68
+ for line in rp.read_text(encoding="utf-8").splitlines():
69
+ line = line.strip()
70
+ if line:
71
+ try:
72
+ out.append(json.loads(line))
73
+ except ValueError:
74
+ continue
75
+ return out
76
+
77
+
78
+ def seal_file(path: str | Path, *, notary: Any, receipts: Optional[str] = None) -> dict:
79
+ """Hash `path` locally, timestamp the digest with `notary`, append a receipt. Returns the receipt."""
80
+ p = Path(path)
81
+ if not p.is_file():
82
+ raise FileNotFoundError(f"not a file: {p}")
83
+ digest, size = _sha256_prefix(p)
84
+ proof = notary.notarize_hash(output_hash=digest)
85
+ receipt = {
86
+ "file": p.name,
87
+ "sha256": digest,
88
+ "bytes": size,
89
+ "sealed_at": datetime.now(timezone.utc).isoformat(timespec="seconds"),
90
+ "certificate_id": proof.id,
91
+ "verify_url": proof.verify_url,
92
+ }
93
+ rp = _receipts_path(p, receipts)
94
+ rp.parent.mkdir(parents=True, exist_ok=True)
95
+ with rp.open("a", encoding="utf-8") as fh:
96
+ fh.write(json.dumps(receipt, ensure_ascii=False) + "\n")
97
+ return receipt
98
+
99
+
100
+ def verify_file(path: str | Path, *, receipts: Optional[str] = None) -> list[dict]:
101
+ """Check `path` against every receipt. Offline: re-hashes the sealed prefix of each.
102
+
103
+ Each result: the receipt plus `ok` (sealed bytes unchanged) and `added` (bytes
104
+ appended since). The timestamp itself is checked at `verify_url`, or offline
105
+ from the receipts at /api/anchors/{seed,tsr,ots}/<certificate_id>."""
106
+ p = Path(path)
107
+ rp = _receipts_path(p, receipts)
108
+ rows = _read_receipts(rp)
109
+ if not rows:
110
+ raise FileNotFoundError(f"no receipts at {rp}")
111
+ size_now = p.stat().st_size if p.is_file() else -1
112
+ results = []
113
+ for r in rows:
114
+ want = int(r.get("bytes", -1))
115
+ if size_now < 0 or want < 0 or size_now < want:
116
+ results.append({**r, "ok": False, "added": 0, "why": "file is shorter than what was sealed"})
117
+ continue
118
+ got, _ = _sha256_prefix(p, want)
119
+ ok = got == r.get("sha256")
120
+ results.append({**r, "ok": ok, "added": size_now - want if ok else 0,
121
+ "why": "" if ok else "the sealed bytes were changed"})
122
+ return results
123
+
124
+
125
+ # ---------------------------------------------------------------------- CLI
126
+ def _notary(args: argparse.Namespace):
127
+ from .notary import Notary # imported here so `verify` works without network deps configured
128
+
129
+ handle = args.handle or os.environ.get("DEUSPROOF_HANDLE", "")
130
+ if not handle:
131
+ raise SystemExit("seal needs a public name: --handle NAME or DEUSPROOF_HANDLE=NAME")
132
+ kw = {"handle": handle, "platform": args.platform}
133
+ if args.base_url:
134
+ kw["base_url"] = args.base_url
135
+ return Notary(**kw)
136
+
137
+
138
+ def _cmd_seal(args: argparse.Namespace) -> int:
139
+ target = args.path
140
+ if args.hook:
141
+ try:
142
+ event = json.loads(sys.stdin.read() or "{}")
143
+ target = event.get("transcript_path") or target
144
+ if not target:
145
+ print("deusproof: hook event has no transcript_path; nothing sealed", file=sys.stderr)
146
+ return 0
147
+ r = seal_file(os.path.expanduser(target), notary=_notary(args), receipts=args.receipts)
148
+ print(f"deusproof: sealed {r['bytes']} bytes | {r['verify_url']}", file=sys.stderr)
149
+ except BaseException as e: # a witness must never break the session it witnesses
150
+ print(f"deusproof: not sealed ({e})", file=sys.stderr)
151
+ return 0
152
+ if not target:
153
+ raise SystemExit("seal needs a file path (or --hook)")
154
+ r = seal_file(target, notary=_notary(args), receipts=args.receipts)
155
+ print(f"sealed {r['file']} | {r['bytes']} bytes | sha256 {r['sha256']}")
156
+ print(f" {r['verify_url']}")
157
+ print(f" receipt kept in {_receipts_path(Path(target), args.receipts)}")
158
+ return 0
159
+
160
+
161
+ def _cmd_verify(args: argparse.Namespace) -> int:
162
+ try:
163
+ results = verify_file(args.path, receipts=args.receipts)
164
+ except FileNotFoundError as e:
165
+ print(f"BROKEN: {e}")
166
+ return 1
167
+ bad = 0
168
+ for r in results:
169
+ if r["ok"]:
170
+ extra = f" · {r['added']} bytes added since" if r["added"] else ""
171
+ print(f"OK {r['sealed_at']} | first {r['bytes']} bytes unchanged{extra} | {r['verify_url']}")
172
+ else:
173
+ bad += 1
174
+ print(f"BROKEN {r['sealed_at']} | {r['why']} | sealed sha256 {r['sha256']}")
175
+ return 1 if bad else 0
176
+
177
+
178
+ def main(argv: Optional[list] = None) -> int:
179
+ ap = argparse.ArgumentParser(prog="deusproof", description="Timestamp files and logs with an outside witness. Only a SHA-256 leaves your machine.")
180
+ sub = ap.add_subparsers(dest="cmd", required=True)
181
+
182
+ s = sub.add_parser("seal", help="timestamp a file or log (only its SHA-256 is sent)")
183
+ s.add_argument("path", nargs="?", help="file to seal")
184
+ s.add_argument("--handle", help="public name for the seal (or DEUSPROOF_HANDLE)")
185
+ s.add_argument("--platform", default="cli", help="label for where the seal comes from (default: cli)")
186
+ s.add_argument("--receipts", help="where to keep receipts (default: <file>.deusproof.jsonl)")
187
+ s.add_argument("--base-url", help=argparse.SUPPRESS)
188
+ s.add_argument("--hook", action="store_true", help="read a hook event (JSON on stdin) and seal its transcript_path; never fails")
189
+ s.set_defaults(func=_cmd_seal)
190
+
191
+ v = sub.add_parser("verify", help="check a file against its receipts (offline)")
192
+ v.add_argument("path")
193
+ v.add_argument("--receipts")
194
+ v.set_defaults(func=_cmd_verify)
195
+
196
+ a = sub.add_parser("audit", help="hash-chained audit logs (deusproof.audit)")
197
+ a.add_argument("rest", nargs=argparse.REMAINDER)
198
+ a.set_defaults(func=lambda ns: __import__("deusproof.audit", fromlist=["_main"])._main(ns.rest))
199
+
200
+ args = ap.parse_args(argv)
201
+ return args.func(args)
202
+
203
+
204
+ if __name__ == "__main__": # pragma: no cover
205
+ sys.exit(main())
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deusproof
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Prove your AI agent's work existed at a given moment — one call, self-signed, timestamped and Bitcoin-anchored on a public append-only register. Free.
5
5
  Author: DEUSPROOF
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://deusproof.com
8
8
  Project-URL: Pantheon, https://deusproof.com/pantheon
9
- Keywords: ai-agents,provenance,audit-log,tamper-evident,did,bitcoin,rfc3161,langchain,langgraph
9
+ Keywords: ai-agents,provenance,audit-log,tamper-evident,did,bitcoin,rfc3161,langchain,langgraph,claude-code,cli
10
10
  Requires-Python: >=3.9
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: httpx>=0.24
@@ -106,6 +106,39 @@ It records runs, tool calls and model outputs (hashed; add `keep_payload=True` t
106
106
  the local file), and seals the head once when each top-level run ends. A failed seal never breaks
107
107
  your agent's run. Guide: https://deusproof.com/guides/tamper-evident-agent-logs
108
108
 
109
+ ## Seal any log you already have: no code changes
110
+
111
+ Your tool already writes a log (an agent runtime, an audit trail, a JSONL of tool calls)? Seal it
112
+ from the command line. Only its SHA-256 leaves your machine.
113
+
114
+ ```bash
115
+ deusproof seal runtime.jsonl --handle my-endpoint # e.g. once a day from cron
116
+ deusproof verify runtime.jsonl # anyone, any time, offline
117
+ ```
118
+
119
+ Logs grow, so each receipt records how many bytes it covered and `verify` re-hashes exactly that
120
+ part: lines appended later still pass; anything changed or cut inside a sealed part fails. Receipts
121
+ are kept beside the file in `runtime.jsonl.deusproof.jsonl` (no content, just digest, size, time
122
+ and the link to check the timestamp and the Bitcoin anchor).
123
+
124
+ ### Claude Code: every session sealed
125
+
126
+ Add a `SessionEnd` hook to `.claude/settings.json` (or `~/.claude/settings.json` for all projects):
127
+
128
+ ```json
129
+ {
130
+ "hooks": {
131
+ "SessionEnd": [
132
+ { "hooks": [ { "type": "command",
133
+ "command": "deusproof seal --hook --handle my-dev-agent --platform claude-code" } ] }
134
+ ]
135
+ }
136
+ }
137
+ ```
138
+
139
+ When a session ends, its transcript is fingerprinted and sealed. The transcript never leaves your
140
+ machine. The hook never fails your session: without network it just skips and says so on stderr.
141
+
109
142
  ## Use it from LangChain
110
143
 
111
144
  ```bash
@@ -2,11 +2,13 @@ README.md
2
2
  pyproject.toml
3
3
  deusproof/__init__.py
4
4
  deusproof/audit.py
5
+ deusproof/cli.py
5
6
  deusproof/langchain.py
6
7
  deusproof/langchain_audit.py
7
8
  deusproof/notary.py
8
9
  deusproof.egg-info/PKG-INFO
9
10
  deusproof.egg-info/SOURCES.txt
10
11
  deusproof.egg-info/dependency_links.txt
12
+ deusproof.egg-info/entry_points.txt
11
13
  deusproof.egg-info/requires.txt
12
14
  deusproof.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ deusproof = deusproof.cli:main
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "deusproof"
7
- version = "0.3.0"
7
+ version = "0.4.0"
8
8
  description = "Prove your AI agent's work existed at a given moment — one call, self-signed, timestamped and Bitcoin-anchored on a public append-only register. Free."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -15,7 +15,7 @@ dependencies = [
15
15
  "cryptography>=41",
16
16
  "base58>=2.1",
17
17
  ]
18
- keywords = ["ai-agents", "provenance", "audit-log", "tamper-evident", "did", "bitcoin", "rfc3161", "langchain", "langgraph"]
18
+ keywords = ["ai-agents", "provenance", "audit-log", "tamper-evident", "did", "bitcoin", "rfc3161", "langchain", "langgraph", "claude-code", "cli"]
19
19
 
20
20
  # LA SONDA, COMO EXTRA OPCIONAL (16-sep-2026). Quien instale `deusproof` a secas
21
21
  # no se descarga el arbol de LangChain; solo lo pide quien lo va a usar.
@@ -23,6 +23,11 @@ keywords = ["ai-agents", "provenance", "audit-log", "tamper-evident", "did", "bi
23
23
  [project.optional-dependencies]
24
24
  langchain = ["langchain-core>=0.3", "pydantic>=2"]
25
25
 
26
+ # EL COMANDO (16-nov-2026): `deusproof seal <fichero>` sella cualquier registro sin tocar
27
+ # el codigo de la herramienta que lo escribe; `--hook` lo convierte en gancho de Claude Code.
28
+ [project.scripts]
29
+ deusproof = "deusproof.cli:main"
30
+
26
31
  [project.urls]
27
32
  Homepage = "https://deusproof.com"
28
33
  Pantheon = "https://deusproof.com/pantheon"
File without changes
File without changes
File without changes