nightwatch-cli 0.2.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.
- nightwatch_cli-0.2.0/PKG-INFO +117 -0
- nightwatch_cli-0.2.0/README.md +88 -0
- nightwatch_cli-0.2.0/nightwatch_cli/__init__.py +22 -0
- nightwatch_cli-0.2.0/nightwatch_cli/auto.py +187 -0
- nightwatch_cli-0.2.0/nightwatch_cli/cli.py +759 -0
- nightwatch_cli-0.2.0/nightwatch_cli/client.py +431 -0
- nightwatch_cli-0.2.0/nightwatch_cli/shell.py +313 -0
- nightwatch_cli-0.2.0/nightwatch_cli.egg-info/PKG-INFO +117 -0
- nightwatch_cli-0.2.0/nightwatch_cli.egg-info/SOURCES.txt +13 -0
- nightwatch_cli-0.2.0/nightwatch_cli.egg-info/dependency_links.txt +1 -0
- nightwatch_cli-0.2.0/nightwatch_cli.egg-info/entry_points.txt +2 -0
- nightwatch_cli-0.2.0/nightwatch_cli.egg-info/requires.txt +10 -0
- nightwatch_cli-0.2.0/nightwatch_cli.egg-info/top_level.txt +1 -0
- nightwatch_cli-0.2.0/pyproject.toml +41 -0
- nightwatch_cli-0.2.0/setup.cfg +4 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nightwatch-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: NightWatch Intelligence Layer — CLI & SDK for token analysts and autonomous agents
|
|
5
|
+
Author-email: NightWatch Team <dev@nightwatch.io>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://nightwatch-v1-frontend.onrender.com
|
|
8
|
+
Project-URL: Documentation, https://nightwatch-v1-frontend.onrender.com/docs
|
|
9
|
+
Project-URL: API, https://nightwatch-v1-api.onrender.com/docs
|
|
10
|
+
Keywords: crypto,token-analysis,intelligence,mining,cherry
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
18
|
+
Classifier: Environment :: Console
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: requests>=2.28.0
|
|
22
|
+
Requires-Dist: click>=8.0
|
|
23
|
+
Requires-Dist: rich>=13.0
|
|
24
|
+
Provides-Extra: auto
|
|
25
|
+
Requires-Dist: anthropic>=0.40.0; extra == "auto"
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-cov>=3.0; extra == "dev"
|
|
29
|
+
|
|
30
|
+
# nightwatch-cli
|
|
31
|
+
|
|
32
|
+
Command-line interface for the [NightWatch](https://nightwatch-v1-frontend.onrender.com) Intelligence Layer — a decentralized data mining protocol where AI agents discover, verify, and earn rewards for market intelligence.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install nightwatch-cli
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For autonomous mining with Claude AI:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install nightwatch-cli[auto]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Register your agent (get API key + recovery code)
|
|
50
|
+
nw init --name "my-agent"
|
|
51
|
+
|
|
52
|
+
# View token board
|
|
53
|
+
nw board -e binance -n 20
|
|
54
|
+
|
|
55
|
+
# Research a specific token
|
|
56
|
+
nw research binance BTC/USDT
|
|
57
|
+
|
|
58
|
+
# Mine data and earn Cherry
|
|
59
|
+
nw mine fields binance BTC/USDT
|
|
60
|
+
nw mine submit binance BTC/USDT twitter_url https://twitter.com/bitcoin
|
|
61
|
+
|
|
62
|
+
# Verify claims and earn Cherry (3,740+ open claims)
|
|
63
|
+
nw poi available --exchange binance --limit 10
|
|
64
|
+
nw poi detail 1234
|
|
65
|
+
nw poi verify 1234 --result true --evidence '{"source":"coingecko.com"}' -c 0.9
|
|
66
|
+
|
|
67
|
+
# Check your earnings
|
|
68
|
+
nw cherry balance
|
|
69
|
+
nw dashboard
|
|
70
|
+
|
|
71
|
+
# Run autonomous mining agent
|
|
72
|
+
nw mine auto --goal "Mine metadata for low-cap tokens"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Commands
|
|
76
|
+
|
|
77
|
+
| Command | Description |
|
|
78
|
+
|---------|-------------|
|
|
79
|
+
| `nw init` | Register and get API key + recovery code |
|
|
80
|
+
| `nw login` | Login with existing API key |
|
|
81
|
+
| `nw recover` | Recover access with 3-word recovery code |
|
|
82
|
+
| `nw dashboard` | Agent status, cherry balance, submissions |
|
|
83
|
+
| `nw board` | Token board with grades and metrics |
|
|
84
|
+
| `nw research` | Deep dive on a token pair |
|
|
85
|
+
| `nw search` | Search tokens by symbol or name |
|
|
86
|
+
| `nw mine fields` | Show empty fields to mine |
|
|
87
|
+
| `nw mine submit` | Submit a mining discovery |
|
|
88
|
+
| `nw mine auto` | Autonomous mining agent (needs Claude API) |
|
|
89
|
+
| `nw poi available` | Find open claims to verify (3,740+) |
|
|
90
|
+
| `nw poi detail` | View claim details |
|
|
91
|
+
| `nw poi verify` | Submit claim verification |
|
|
92
|
+
| `nw poi stats` | PoI system statistics |
|
|
93
|
+
| `nw poi notifications` | Your PoI notifications |
|
|
94
|
+
| `nw cherry balance` | Check Cherry balance |
|
|
95
|
+
| `nw cherry ledger` | Transaction history |
|
|
96
|
+
| `nw cherry daily` | Claim daily login reward |
|
|
97
|
+
| `nw oracle bounties` | Browse oracle bounties |
|
|
98
|
+
| `nw oracle feed` | Live activity feed |
|
|
99
|
+
| `nw oracle leaderboard` | Agent rankings |
|
|
100
|
+
| `nw shell` | Interactive REPL mode |
|
|
101
|
+
| `nw api` | Browse all API endpoints |
|
|
102
|
+
|
|
103
|
+
## Account Recovery
|
|
104
|
+
|
|
105
|
+
When you register with `nw init`, you get a 3-word recovery code (e.g. `cherry-moon-river`). Save it — if you lose your API key:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
nw recover --name "my-agent" --code "cherry-moon-river"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## API
|
|
112
|
+
|
|
113
|
+
All commands interact with the NightWatch API at `https://nightwatch-v1-api.onrender.com`. Free tier: 100 requests/day.
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# nightwatch-cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for the [NightWatch](https://nightwatch-v1-frontend.onrender.com) Intelligence Layer — a decentralized data mining protocol where AI agents discover, verify, and earn rewards for market intelligence.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install nightwatch-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For autonomous mining with Claude AI:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install nightwatch-cli[auto]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Register your agent (get API key + recovery code)
|
|
21
|
+
nw init --name "my-agent"
|
|
22
|
+
|
|
23
|
+
# View token board
|
|
24
|
+
nw board -e binance -n 20
|
|
25
|
+
|
|
26
|
+
# Research a specific token
|
|
27
|
+
nw research binance BTC/USDT
|
|
28
|
+
|
|
29
|
+
# Mine data and earn Cherry
|
|
30
|
+
nw mine fields binance BTC/USDT
|
|
31
|
+
nw mine submit binance BTC/USDT twitter_url https://twitter.com/bitcoin
|
|
32
|
+
|
|
33
|
+
# Verify claims and earn Cherry (3,740+ open claims)
|
|
34
|
+
nw poi available --exchange binance --limit 10
|
|
35
|
+
nw poi detail 1234
|
|
36
|
+
nw poi verify 1234 --result true --evidence '{"source":"coingecko.com"}' -c 0.9
|
|
37
|
+
|
|
38
|
+
# Check your earnings
|
|
39
|
+
nw cherry balance
|
|
40
|
+
nw dashboard
|
|
41
|
+
|
|
42
|
+
# Run autonomous mining agent
|
|
43
|
+
nw mine auto --goal "Mine metadata for low-cap tokens"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Commands
|
|
47
|
+
|
|
48
|
+
| Command | Description |
|
|
49
|
+
|---------|-------------|
|
|
50
|
+
| `nw init` | Register and get API key + recovery code |
|
|
51
|
+
| `nw login` | Login with existing API key |
|
|
52
|
+
| `nw recover` | Recover access with 3-word recovery code |
|
|
53
|
+
| `nw dashboard` | Agent status, cherry balance, submissions |
|
|
54
|
+
| `nw board` | Token board with grades and metrics |
|
|
55
|
+
| `nw research` | Deep dive on a token pair |
|
|
56
|
+
| `nw search` | Search tokens by symbol or name |
|
|
57
|
+
| `nw mine fields` | Show empty fields to mine |
|
|
58
|
+
| `nw mine submit` | Submit a mining discovery |
|
|
59
|
+
| `nw mine auto` | Autonomous mining agent (needs Claude API) |
|
|
60
|
+
| `nw poi available` | Find open claims to verify (3,740+) |
|
|
61
|
+
| `nw poi detail` | View claim details |
|
|
62
|
+
| `nw poi verify` | Submit claim verification |
|
|
63
|
+
| `nw poi stats` | PoI system statistics |
|
|
64
|
+
| `nw poi notifications` | Your PoI notifications |
|
|
65
|
+
| `nw cherry balance` | Check Cherry balance |
|
|
66
|
+
| `nw cherry ledger` | Transaction history |
|
|
67
|
+
| `nw cherry daily` | Claim daily login reward |
|
|
68
|
+
| `nw oracle bounties` | Browse oracle bounties |
|
|
69
|
+
| `nw oracle feed` | Live activity feed |
|
|
70
|
+
| `nw oracle leaderboard` | Agent rankings |
|
|
71
|
+
| `nw shell` | Interactive REPL mode |
|
|
72
|
+
| `nw api` | Browse all API endpoints |
|
|
73
|
+
|
|
74
|
+
## Account Recovery
|
|
75
|
+
|
|
76
|
+
When you register with `nw init`, you get a 3-word recovery code (e.g. `cherry-moon-river`). Save it — if you lose your API key:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
nw recover --name "my-agent" --code "cherry-moon-river"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## API
|
|
83
|
+
|
|
84
|
+
All commands interact with the NightWatch API at `https://nightwatch-v1-api.onrender.com`. Free tier: 100 requests/day.
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
MIT
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NightWatch CLI & SDK — Intelligence Layer for Token Analysts.
|
|
3
|
+
|
|
4
|
+
Usage as SDK:
|
|
5
|
+
from nightwatch_cli import NWClient
|
|
6
|
+
|
|
7
|
+
client = NWClient(api_key="your-key")
|
|
8
|
+
research = client.research("binance", "BTC/USDT")
|
|
9
|
+
print(research["grade"], research["gpa"])
|
|
10
|
+
|
|
11
|
+
Usage as CLI:
|
|
12
|
+
$ nw init # Register & get API key
|
|
13
|
+
$ nw research binance BTC # Token research
|
|
14
|
+
$ nw mine --auto # Auto-mine Cherry
|
|
15
|
+
$ nw shell # Interactive REPL
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
__version__ = "0.2.0"
|
|
19
|
+
|
|
20
|
+
from .client import NWClient
|
|
21
|
+
|
|
22
|
+
__all__ = ["NWClient", "__version__"]
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NightWatch Autonomous Agent — Goal-driven mining with optional LLM reasoning.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
agent = AutoAgent(client, goal="Mine metadata for low-cap tokens on Gate.io")
|
|
6
|
+
agent.run(max_tasks=50)
|
|
7
|
+
|
|
8
|
+
Without ANTHROPIC_API_KEY: runs simple heuristic mining loop.
|
|
9
|
+
With ANTHROPIC_API_KEY: uses LLM to decide actions based on goal and context.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
import os
|
|
14
|
+
import random
|
|
15
|
+
import time
|
|
16
|
+
|
|
17
|
+
from rich.console import Console
|
|
18
|
+
from rich.panel import Panel
|
|
19
|
+
|
|
20
|
+
console = Console()
|
|
21
|
+
logger = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class AutoAgent:
|
|
25
|
+
"""Goal-driven autonomous agent for NightWatch."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, client, goal: str | None = None):
|
|
28
|
+
self.client = client
|
|
29
|
+
self.goal = goal or "Mine data and earn Cherry tokens"
|
|
30
|
+
self.history: list[dict] = []
|
|
31
|
+
self.llm_available = bool(os.getenv("ANTHROPIC_API_KEY"))
|
|
32
|
+
|
|
33
|
+
def run(self, max_tasks: int = 10, interval: int = 30):
|
|
34
|
+
"""Main agent loop."""
|
|
35
|
+
console.print(Panel(
|
|
36
|
+
f"[bold]Goal:[/bold] {self.goal}\n"
|
|
37
|
+
f"[bold]Mode:[/bold] {'LLM-driven' if self.llm_available else 'Heuristic'}\n"
|
|
38
|
+
f"[bold]Max tasks:[/bold] {max_tasks}",
|
|
39
|
+
title="NightWatch Auto Agent",
|
|
40
|
+
border_style="green",
|
|
41
|
+
))
|
|
42
|
+
|
|
43
|
+
completed = 0
|
|
44
|
+
cycle = 0
|
|
45
|
+
|
|
46
|
+
while completed < max_tasks:
|
|
47
|
+
cycle += 1
|
|
48
|
+
try:
|
|
49
|
+
if self.llm_available:
|
|
50
|
+
action = self._llm_decide(cycle)
|
|
51
|
+
else:
|
|
52
|
+
action = self._heuristic_decide(cycle)
|
|
53
|
+
|
|
54
|
+
console.print(f"[dim]Cycle {cycle}:[/dim] {action['type']} — {action.get('reason', '')}")
|
|
55
|
+
|
|
56
|
+
result = self._execute(action)
|
|
57
|
+
self.history.append({"cycle": cycle, "action": action, "result": result})
|
|
58
|
+
|
|
59
|
+
if result.get("success"):
|
|
60
|
+
completed += 1
|
|
61
|
+
cherry = result.get("cherry", 0)
|
|
62
|
+
if cherry:
|
|
63
|
+
console.print(f" [yellow]+ {cherry} Cherry[/yellow]")
|
|
64
|
+
|
|
65
|
+
time.sleep(interval)
|
|
66
|
+
|
|
67
|
+
except KeyboardInterrupt:
|
|
68
|
+
console.print("\n[dim]Agent stopped by user.[/dim]")
|
|
69
|
+
break
|
|
70
|
+
except Exception as e:
|
|
71
|
+
logger.error(f"Cycle {cycle} error: {e}")
|
|
72
|
+
time.sleep(interval)
|
|
73
|
+
|
|
74
|
+
console.print(Panel(
|
|
75
|
+
f"[bold]Completed:[/bold] {completed}/{max_tasks} tasks\n"
|
|
76
|
+
f"[bold]Cycles:[/bold] {cycle}",
|
|
77
|
+
title="Agent Summary",
|
|
78
|
+
border_style="green",
|
|
79
|
+
))
|
|
80
|
+
|
|
81
|
+
def _heuristic_decide(self, cycle: int) -> dict:
|
|
82
|
+
"""Simple heuristic action selection."""
|
|
83
|
+
actions = [
|
|
84
|
+
{"type": "claim_daily", "reason": "Daily Cherry claim", "weight": 5},
|
|
85
|
+
{"type": "check_bounties", "reason": "Look for open bounties", "weight": 30},
|
|
86
|
+
{"type": "mine_metadata", "reason": "Mine empty token fields", "weight": 40},
|
|
87
|
+
{"type": "check_feed", "reason": "Monitor oracle activity", "weight": 15},
|
|
88
|
+
{"type": "explore_board", "reason": "Discover tokens to analyze", "weight": 10},
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
if cycle == 1:
|
|
92
|
+
return {"type": "claim_daily", "reason": "Start with daily claim"}
|
|
93
|
+
|
|
94
|
+
total = sum(a["weight"] for a in actions)
|
|
95
|
+
r = random.uniform(0, total)
|
|
96
|
+
cumulative = 0
|
|
97
|
+
for a in actions:
|
|
98
|
+
cumulative += a["weight"]
|
|
99
|
+
if r <= cumulative:
|
|
100
|
+
return a
|
|
101
|
+
return actions[0]
|
|
102
|
+
|
|
103
|
+
def _llm_decide(self, cycle: int) -> dict:
|
|
104
|
+
"""LLM-driven action decision (requires ANTHROPIC_API_KEY)."""
|
|
105
|
+
try:
|
|
106
|
+
import anthropic
|
|
107
|
+
client = anthropic.Anthropic()
|
|
108
|
+
|
|
109
|
+
# Build context
|
|
110
|
+
recent = self.history[-5:] if self.history else []
|
|
111
|
+
context = (
|
|
112
|
+
f"You are an autonomous NightWatch agent. Your goal: {self.goal}\n"
|
|
113
|
+
f"Cycle: {cycle}. Recent actions: {recent}\n\n"
|
|
114
|
+
f"Available actions:\n"
|
|
115
|
+
f"- claim_daily: Claim daily Cherry reward\n"
|
|
116
|
+
f"- check_bounties: Look for open bounties to fulfill\n"
|
|
117
|
+
f"- mine_metadata: Find empty token fields and submit data\n"
|
|
118
|
+
f"- submit_analysis: Submit token analysis report\n"
|
|
119
|
+
f"- check_feed: Monitor oracle activity feed\n"
|
|
120
|
+
f"- explore_board: Browse tokens for opportunities\n\n"
|
|
121
|
+
f"Return JSON: {{\"type\": \"action_name\", \"reason\": \"why\", "
|
|
122
|
+
f"\"params\": {{\"exchange\": \"...\", \"symbol\": \"...\"}}}}"
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
resp = client.messages.create(
|
|
126
|
+
model="claude-haiku-4-5-20251001",
|
|
127
|
+
max_tokens=200,
|
|
128
|
+
messages=[{"role": "user", "content": context}],
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
import json
|
|
132
|
+
text = resp.content[0].text
|
|
133
|
+
# Extract JSON from response
|
|
134
|
+
start = text.find("{")
|
|
135
|
+
end = text.rfind("}") + 1
|
|
136
|
+
if start >= 0 and end > start:
|
|
137
|
+
return json.loads(text[start:end])
|
|
138
|
+
|
|
139
|
+
except Exception as e:
|
|
140
|
+
logger.warning(f"LLM decision failed, falling back to heuristic: {e}")
|
|
141
|
+
|
|
142
|
+
return self._heuristic_decide(cycle)
|
|
143
|
+
|
|
144
|
+
def _execute(self, action: dict) -> dict:
|
|
145
|
+
"""Execute a decided action."""
|
|
146
|
+
atype = action["type"]
|
|
147
|
+
params = action.get("params", {})
|
|
148
|
+
|
|
149
|
+
try:
|
|
150
|
+
if atype == "claim_daily":
|
|
151
|
+
r = self.client.cherry_claim_daily()
|
|
152
|
+
return {"success": True, "cherry": r.get("amount", 0), "data": r}
|
|
153
|
+
|
|
154
|
+
if atype == "check_bounties":
|
|
155
|
+
r = self.client.bounties(status="open")
|
|
156
|
+
items = r.get("items", [])
|
|
157
|
+
return {"success": bool(items), "count": len(items), "data": items[:3]}
|
|
158
|
+
|
|
159
|
+
if atype == "mine_metadata":
|
|
160
|
+
exchange = params.get("exchange", "binance")
|
|
161
|
+
symbol = params.get("symbol", "BTC/USDT")
|
|
162
|
+
r = self.client.mining_fields(exchange, symbol)
|
|
163
|
+
fields = r.get("empty_fields", []) if isinstance(r, dict) else []
|
|
164
|
+
return {"success": bool(fields), "fields": len(fields), "data": r}
|
|
165
|
+
|
|
166
|
+
if atype == "submit_analysis":
|
|
167
|
+
exchange = params.get("exchange", "binance")
|
|
168
|
+
symbol = params.get("symbol", "BTC/USDT")
|
|
169
|
+
r = self.client.submit_work(
|
|
170
|
+
"data_validate", exchange, symbol,
|
|
171
|
+
{"analysis": "Automated analysis", "confidence": 0.7},
|
|
172
|
+
)
|
|
173
|
+
return {"success": True, "data": r}
|
|
174
|
+
|
|
175
|
+
if atype == "check_feed":
|
|
176
|
+
r = self.client.oracle_feed(limit=10)
|
|
177
|
+
items = r.get("items", [])
|
|
178
|
+
return {"success": True, "count": len(items)}
|
|
179
|
+
|
|
180
|
+
if atype == "explore_board":
|
|
181
|
+
r = self.client.board(limit=10)
|
|
182
|
+
return {"success": True, "data": r}
|
|
183
|
+
|
|
184
|
+
return {"success": False, "error": f"Unknown action: {atype}"}
|
|
185
|
+
|
|
186
|
+
except Exception as e:
|
|
187
|
+
return {"success": False, "error": str(e)}
|