pythonclaw 0.2.0__py3-none-any.whl → 0.2.2__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.
- pythonclaw/__init__.py +1 -1
- pythonclaw/main.py +37 -19
- pythonclaw/onboard.py +48 -0
- pythonclaw/server.py +35 -55
- pythonclaw/web/app.py +86 -1
- pythonclaw/web/static/index.html +126 -0
- {pythonclaw-0.2.0.dist-info → pythonclaw-0.2.2.dist-info}/METADATA +5 -2
- {pythonclaw-0.2.0.dist-info → pythonclaw-0.2.2.dist-info}/RECORD +12 -12
- {pythonclaw-0.2.0.dist-info → pythonclaw-0.2.2.dist-info}/WHEEL +0 -0
- {pythonclaw-0.2.0.dist-info → pythonclaw-0.2.2.dist-info}/entry_points.txt +0 -0
- {pythonclaw-0.2.0.dist-info → pythonclaw-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {pythonclaw-0.2.0.dist-info → pythonclaw-0.2.2.dist-info}/top_level.txt +0 -0
pythonclaw/__init__.py
CHANGED
pythonclaw/main.py
CHANGED
|
@@ -149,28 +149,46 @@ def _run_foreground(args) -> None:
|
|
|
149
149
|
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
|
150
150
|
)
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
print(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
# Web-only
|
|
159
|
-
try:
|
|
160
|
-
import uvicorn
|
|
161
|
-
except ImportError:
|
|
162
|
-
print("Error: Web mode requires 'fastapi' and 'uvicorn'.")
|
|
163
|
-
print("Install with: pip install pythonclaw[web]")
|
|
164
|
-
return
|
|
152
|
+
try:
|
|
153
|
+
import uvicorn
|
|
154
|
+
except ImportError:
|
|
155
|
+
print("Error: Web mode requires 'fastapi' and 'uvicorn'.")
|
|
156
|
+
print("Install with: pip install pythonclaw[web]")
|
|
157
|
+
return
|
|
165
158
|
|
|
166
|
-
|
|
159
|
+
from .web.app import create_app
|
|
167
160
|
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
host = config.get_str("web", "host", default="0.0.0.0")
|
|
162
|
+
port = config.get_int("web", "port", default=7788)
|
|
170
163
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
164
|
+
app = create_app(provider, build_provider_fn=_build_provider)
|
|
165
|
+
|
|
166
|
+
ch_to_start = channels or _detect_configured_channels()
|
|
167
|
+
if ch_to_start:
|
|
168
|
+
from .server import start_channels
|
|
169
|
+
from .web import app as web_app_module
|
|
170
|
+
label = "explicit" if channels else "auto-detected"
|
|
171
|
+
print(f"[PythonClaw] Channels ({label}): {', '.join(ch_to_start)}")
|
|
172
|
+
|
|
173
|
+
@app.on_event("startup")
|
|
174
|
+
async def _start_channels():
|
|
175
|
+
bots = await start_channels(provider, ch_to_start)
|
|
176
|
+
web_app_module._active_bots.extend(bots)
|
|
177
|
+
|
|
178
|
+
print(f"[PythonClaw] Web dashboard: http://localhost:{port}")
|
|
179
|
+
uvicorn.run(app, host=host, port=port, log_level="info")
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _detect_configured_channels() -> list[str]:
|
|
183
|
+
"""Return channel names that have a token configured."""
|
|
184
|
+
found = []
|
|
185
|
+
tg_token = config.get_str("channels", "telegram", "token", default="")
|
|
186
|
+
if tg_token:
|
|
187
|
+
found.append("telegram")
|
|
188
|
+
dc_token = config.get_str("channels", "discord", "token", default="")
|
|
189
|
+
if dc_token:
|
|
190
|
+
found.append("discord")
|
|
191
|
+
return found
|
|
174
192
|
|
|
175
193
|
|
|
176
194
|
def _cmd_stop(args) -> None:
|
pythonclaw/onboard.py
CHANGED
|
@@ -214,6 +214,54 @@ def _optional_keys(cfg: dict) -> None:
|
|
|
214
214
|
print(" → SkillHub key set")
|
|
215
215
|
|
|
216
216
|
print()
|
|
217
|
+
_channel_keys(cfg)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def _channel_keys(cfg: dict) -> None:
|
|
221
|
+
print(_c(" Channels (press Enter to skip):", _DIM))
|
|
222
|
+
print()
|
|
223
|
+
|
|
224
|
+
channels = cfg.setdefault("channels", {})
|
|
225
|
+
|
|
226
|
+
# Telegram
|
|
227
|
+
tg = channels.setdefault("telegram", {"token": "", "allowedUsers": []})
|
|
228
|
+
tg_existing = tg.get("token", "")
|
|
229
|
+
if tg_existing:
|
|
230
|
+
masked = tg_existing[:6] + "****" + tg_existing[-4:] if len(tg_existing) > 10 else "****"
|
|
231
|
+
print(f" Telegram Bot Token (current: {masked}, press Enter to keep)")
|
|
232
|
+
token = input(" Telegram Bot Token: ").strip()
|
|
233
|
+
if token:
|
|
234
|
+
tg["token"] = token
|
|
235
|
+
print(" → Telegram token set")
|
|
236
|
+
elif tg_existing:
|
|
237
|
+
print(" → Keeping existing Telegram token")
|
|
238
|
+
|
|
239
|
+
allowed = input(" Telegram Allowed User IDs (comma-separated, or Enter to allow all): ").strip()
|
|
240
|
+
if allowed:
|
|
241
|
+
tg["allowedUsers"] = [uid.strip() for uid in allowed.split(",") if uid.strip()]
|
|
242
|
+
print(f" → {len(tg['allowedUsers'])} user(s) whitelisted")
|
|
243
|
+
|
|
244
|
+
print()
|
|
245
|
+
|
|
246
|
+
# Discord
|
|
247
|
+
dc = channels.setdefault("discord", {"token": "", "allowedUsers": [], "allowedChannels": []})
|
|
248
|
+
dc_existing = dc.get("token", "")
|
|
249
|
+
if dc_existing:
|
|
250
|
+
masked = dc_existing[:6] + "****" + dc_existing[-4:] if len(dc_existing) > 10 else "****"
|
|
251
|
+
print(f" Discord Bot Token (current: {masked}, press Enter to keep)")
|
|
252
|
+
dc_token = input(" Discord Bot Token: ").strip()
|
|
253
|
+
if dc_token:
|
|
254
|
+
dc["token"] = dc_token
|
|
255
|
+
print(" → Discord token set")
|
|
256
|
+
elif dc_existing:
|
|
257
|
+
print(" → Keeping existing Discord token")
|
|
258
|
+
|
|
259
|
+
dc_channels = input(" Discord Allowed Channel IDs (comma-separated, or Enter to allow all): ").strip()
|
|
260
|
+
if dc_channels:
|
|
261
|
+
dc["allowedChannels"] = [ch.strip() for ch in dc_channels.split(",") if ch.strip()]
|
|
262
|
+
print(f" → {len(dc['allowedChannels'])} channel(s) whitelisted")
|
|
263
|
+
|
|
264
|
+
print()
|
|
217
265
|
|
|
218
266
|
|
|
219
267
|
def _validate_key(cfg: dict, provider: dict) -> None:
|
pythonclaw/server.py
CHANGED
|
@@ -2,21 +2,7 @@
|
|
|
2
2
|
Daemon server for PythonClaw — multi-channel mode.
|
|
3
3
|
|
|
4
4
|
Supports Telegram and Discord channels, individually or combined.
|
|
5
|
-
|
|
6
|
-
Architecture
|
|
7
|
-
------------
|
|
8
|
-
+----------------------------------------+
|
|
9
|
-
| SessionManager |
|
|
10
|
-
| "{channel}:{id}" → Agent |
|
|
11
|
-
| "cron:{job_id}" → Agent |
|
|
12
|
-
| (Markdown-backed via SessionStore) |
|
|
13
|
-
+----------------------------------------+
|
|
14
|
-
|
|
|
15
|
-
+--------------------+--------------------+
|
|
16
|
-
| | |
|
|
17
|
-
TelegramBot CronScheduler HeartbeatMonitor
|
|
18
|
-
DiscordBot static + dynamic
|
|
19
|
-
jobs
|
|
5
|
+
The web dashboard always runs; channels are started alongside it.
|
|
20
6
|
"""
|
|
21
7
|
|
|
22
8
|
from __future__ import annotations
|
|
@@ -30,43 +16,29 @@ from .core.llm.base import LLMProvider
|
|
|
30
16
|
from .core.persistent_agent import PersistentAgent
|
|
31
17
|
from .core.session_store import SessionStore
|
|
32
18
|
from .scheduler.cron import CronScheduler
|
|
33
|
-
from .scheduler.heartbeat import create_heartbeat
|
|
34
19
|
from .session_manager import SessionManager
|
|
35
20
|
|
|
36
21
|
logger = logging.getLogger(__name__)
|
|
37
22
|
|
|
38
23
|
|
|
39
|
-
async def
|
|
24
|
+
async def start_channels(
|
|
40
25
|
provider: LLMProvider,
|
|
41
|
-
channels: list[str]
|
|
42
|
-
) ->
|
|
43
|
-
"""
|
|
44
|
-
Main entry point for daemon mode.
|
|
26
|
+
channels: list[str],
|
|
27
|
+
) -> list:
|
|
28
|
+
"""Start messaging channels (Telegram, Discord) as background tasks.
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
provider : the LLM provider to use
|
|
49
|
-
channels : list of channels to start, e.g. ["telegram", "discord"].
|
|
50
|
-
Defaults to ["telegram"] for backward compatibility.
|
|
30
|
+
Returns the list of successfully started bot objects.
|
|
31
|
+
Safe to call during FastAPI startup — failures are logged, not raised.
|
|
51
32
|
"""
|
|
52
|
-
if channels is None:
|
|
53
|
-
channels = ["telegram"]
|
|
54
|
-
|
|
55
|
-
# ── 1. Session store (Markdown persistence) ───────────────────────────────
|
|
56
33
|
store = SessionStore()
|
|
57
|
-
logger.info("[Server] SessionStore initialised at '%s'", store.base_dir)
|
|
58
|
-
|
|
59
|
-
# ── 2. SessionManager (placeholder factory, updated below) ────────────────
|
|
60
34
|
session_manager = SessionManager(agent_factory=lambda sid: None, store=store)
|
|
61
35
|
|
|
62
|
-
# ── 3. CronScheduler ─────────────────────────────────────────────────────
|
|
63
36
|
jobs_path = os.path.join("context", "cron", "jobs.yaml")
|
|
64
37
|
scheduler = CronScheduler(
|
|
65
38
|
session_manager=session_manager,
|
|
66
39
|
jobs_path=jobs_path,
|
|
67
40
|
)
|
|
68
41
|
|
|
69
|
-
# ── 4. Real agent factory ─────────────────────────────────────────────────
|
|
70
42
|
def agent_factory(session_id: str) -> PersistentAgent:
|
|
71
43
|
return PersistentAgent(
|
|
72
44
|
provider=provider,
|
|
@@ -78,7 +50,6 @@ async def run_server(
|
|
|
78
50
|
|
|
79
51
|
session_manager.set_factory(agent_factory)
|
|
80
52
|
|
|
81
|
-
# ── 5. Start channels ─────────────────────────────────────────────────────
|
|
82
53
|
active_bots: list = []
|
|
83
54
|
|
|
84
55
|
if "telegram" in channels:
|
|
@@ -89,8 +60,8 @@ async def run_server(
|
|
|
89
60
|
await bot.start_async()
|
|
90
61
|
active_bots.append(bot)
|
|
91
62
|
logger.info("[Server] Telegram bot started.")
|
|
92
|
-
except
|
|
93
|
-
logger.warning("[Server] Telegram
|
|
63
|
+
except Exception as exc:
|
|
64
|
+
logger.warning("[Server] Telegram channel failed to start: %s", exc)
|
|
94
65
|
|
|
95
66
|
if "discord" in channels:
|
|
96
67
|
try:
|
|
@@ -99,25 +70,36 @@ async def run_server(
|
|
|
99
70
|
asyncio.create_task(discord_bot.start_async())
|
|
100
71
|
active_bots.append(discord_bot)
|
|
101
72
|
logger.info("[Server] Discord bot started.")
|
|
102
|
-
except
|
|
103
|
-
logger.warning("[Server] Discord
|
|
73
|
+
except Exception as exc:
|
|
74
|
+
logger.warning("[Server] Discord channel failed to start: %s", exc)
|
|
104
75
|
|
|
105
|
-
if
|
|
106
|
-
|
|
107
|
-
|
|
76
|
+
if active_bots:
|
|
77
|
+
scheduler.start()
|
|
78
|
+
logger.info("[Server] Channels running: %s", ", ".join(channels))
|
|
79
|
+
else:
|
|
80
|
+
logger.warning("[Server] No channels started — check tokens in pythonclaw.json.")
|
|
108
81
|
|
|
109
|
-
|
|
110
|
-
scheduler.start()
|
|
82
|
+
return active_bots
|
|
111
83
|
|
|
112
|
-
# ── 7. Heartbeat monitor ──────────────────────────────────────────────────
|
|
113
|
-
telegram_bot = next((b for b in active_bots if hasattr(b, '_app')), None)
|
|
114
|
-
heartbeat = create_heartbeat(provider=provider, telegram_bot=telegram_bot)
|
|
115
|
-
await heartbeat.start()
|
|
116
84
|
|
|
117
|
-
|
|
118
|
-
|
|
85
|
+
async def run_server(
|
|
86
|
+
provider: LLMProvider,
|
|
87
|
+
channels: list[str] | None = None,
|
|
88
|
+
) -> None:
|
|
89
|
+
"""Standalone server entry point (channels only, no web).
|
|
90
|
+
|
|
91
|
+
Kept for backward compatibility. Prefer using ``start_channels``
|
|
92
|
+
together with the web dashboard in ``_run_foreground``.
|
|
93
|
+
"""
|
|
94
|
+
if channels is None:
|
|
95
|
+
channels = ["telegram"]
|
|
96
|
+
|
|
97
|
+
active_bots = await start_channels(provider, channels)
|
|
98
|
+
|
|
99
|
+
if not active_bots:
|
|
100
|
+
logger.error("[Server] No channels started. Exiting.")
|
|
101
|
+
return
|
|
119
102
|
|
|
120
|
-
# ── Graceful shutdown ─────────────────────────────────────────────────────
|
|
121
103
|
stop_event = asyncio.Event()
|
|
122
104
|
|
|
123
105
|
def _signal_handler() -> None:
|
|
@@ -136,9 +118,7 @@ async def run_server(
|
|
|
136
118
|
except (KeyboardInterrupt, asyncio.CancelledError):
|
|
137
119
|
pass
|
|
138
120
|
finally:
|
|
139
|
-
logger.info("[Server] Shutting down
|
|
140
|
-
await heartbeat.stop()
|
|
141
|
-
scheduler.stop()
|
|
121
|
+
logger.info("[Server] Shutting down...")
|
|
142
122
|
for bot in active_bots:
|
|
143
123
|
if hasattr(bot, 'stop_async'):
|
|
144
124
|
await bot.stop_async()
|
pythonclaw/web/app.py
CHANGED
|
@@ -37,6 +37,7 @@ _provider: LLMProvider | None = None
|
|
|
37
37
|
_store: SessionStore | None = None
|
|
38
38
|
_start_time: float = 0.0
|
|
39
39
|
_build_provider_fn = None
|
|
40
|
+
_active_bots: list = []
|
|
40
41
|
|
|
41
42
|
WEB_SESSION_ID = "web:dashboard"
|
|
42
43
|
|
|
@@ -73,6 +74,8 @@ def create_app(provider: LLMProvider | None, *, build_provider_fn=None) -> FastA
|
|
|
73
74
|
app.add_api_route("/api/skillhub/search", _api_skillhub_search, methods=["POST"])
|
|
74
75
|
app.add_api_route("/api/skillhub/browse", _api_skillhub_browse, methods=["GET"])
|
|
75
76
|
app.add_api_route("/api/skillhub/install", _api_skillhub_install, methods=["POST"])
|
|
77
|
+
app.add_api_route("/api/channels", _api_channels_status, methods=["GET"])
|
|
78
|
+
app.add_api_route("/api/channels/restart", _api_channels_restart, methods=["POST"])
|
|
76
79
|
app.add_websocket_route("/ws/chat", _ws_chat)
|
|
77
80
|
|
|
78
81
|
return app
|
|
@@ -226,7 +229,14 @@ async def _api_config_save(request: Request):
|
|
|
226
229
|
logger.warning("[Web] Provider rebuild failed: %s", exc)
|
|
227
230
|
_provider = None
|
|
228
231
|
|
|
229
|
-
|
|
232
|
+
channels_started = await _maybe_start_channels()
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
"ok": True,
|
|
236
|
+
"configPath": str(cfg_path),
|
|
237
|
+
"providerReady": _provider is not None,
|
|
238
|
+
"channelsStarted": channels_started,
|
|
239
|
+
}
|
|
230
240
|
|
|
231
241
|
|
|
232
242
|
async def _api_skills():
|
|
@@ -507,6 +517,81 @@ async def _api_skillhub_install(request: Request):
|
|
|
507
517
|
return JSONResponse({"ok": False, "error": str(exc)}, status_code=500)
|
|
508
518
|
|
|
509
519
|
|
|
520
|
+
async def _maybe_start_channels() -> list[str]:
|
|
521
|
+
"""Start channels whose tokens are now configured but not yet running."""
|
|
522
|
+
global _active_bots
|
|
523
|
+
if _provider is None:
|
|
524
|
+
return []
|
|
525
|
+
|
|
526
|
+
wanted = []
|
|
527
|
+
tg_token = config.get_str("channels", "telegram", "token", default="")
|
|
528
|
+
if tg_token:
|
|
529
|
+
wanted.append("telegram")
|
|
530
|
+
dc_token = config.get_str("channels", "discord", "token", default="")
|
|
531
|
+
if dc_token:
|
|
532
|
+
wanted.append("discord")
|
|
533
|
+
|
|
534
|
+
if not wanted:
|
|
535
|
+
return []
|
|
536
|
+
|
|
537
|
+
running_types = set()
|
|
538
|
+
for bot in _active_bots:
|
|
539
|
+
cls_name = type(bot).__name__.lower()
|
|
540
|
+
if "telegram" in cls_name:
|
|
541
|
+
running_types.add("telegram")
|
|
542
|
+
elif "discord" in cls_name:
|
|
543
|
+
running_types.add("discord")
|
|
544
|
+
|
|
545
|
+
to_start = [ch for ch in wanted if ch not in running_types]
|
|
546
|
+
if not to_start:
|
|
547
|
+
return list(running_types)
|
|
548
|
+
|
|
549
|
+
try:
|
|
550
|
+
from ..server import start_channels
|
|
551
|
+
new_bots = await start_channels(_provider, to_start)
|
|
552
|
+
_active_bots.extend(new_bots)
|
|
553
|
+
return [ch for ch in wanted if ch in running_types or ch in to_start]
|
|
554
|
+
except Exception as exc:
|
|
555
|
+
logger.warning("[Web] Channel start failed: %s", exc)
|
|
556
|
+
return list(running_types)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
async def _api_channels_status():
|
|
560
|
+
"""Return status of messaging channels."""
|
|
561
|
+
channels = []
|
|
562
|
+
for bot in _active_bots:
|
|
563
|
+
cls_name = type(bot).__name__
|
|
564
|
+
ch_type = "telegram" if "Telegram" in cls_name else "discord" if "Discord" in cls_name else cls_name
|
|
565
|
+
channels.append({"type": ch_type, "running": True})
|
|
566
|
+
|
|
567
|
+
tg_token = config.get_str("channels", "telegram", "token", default="")
|
|
568
|
+
dc_token = config.get_str("channels", "discord", "token", default="")
|
|
569
|
+
running_types = {c["type"] for c in channels}
|
|
570
|
+
|
|
571
|
+
if tg_token and "telegram" not in running_types:
|
|
572
|
+
channels.append({"type": "telegram", "running": False, "tokenSet": True})
|
|
573
|
+
if dc_token and "discord" not in running_types:
|
|
574
|
+
channels.append({"type": "discord", "running": False, "tokenSet": True})
|
|
575
|
+
|
|
576
|
+
return {"channels": channels}
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
async def _api_channels_restart(request: Request):
|
|
580
|
+
"""Stop and restart all configured channels."""
|
|
581
|
+
global _active_bots
|
|
582
|
+
|
|
583
|
+
for bot in _active_bots:
|
|
584
|
+
if hasattr(bot, "stop_async"):
|
|
585
|
+
try:
|
|
586
|
+
await bot.stop_async()
|
|
587
|
+
except Exception:
|
|
588
|
+
pass
|
|
589
|
+
_active_bots = []
|
|
590
|
+
|
|
591
|
+
started = await _maybe_start_channels()
|
|
592
|
+
return {"ok": True, "channels": started}
|
|
593
|
+
|
|
594
|
+
|
|
510
595
|
def _reload_agent_identity() -> None:
|
|
511
596
|
"""Reload the agent's soul/persona from disk without full reset."""
|
|
512
597
|
global _agent
|
pythonclaw/web/static/index.html
CHANGED
|
@@ -209,6 +209,16 @@
|
|
|
209
209
|
<div id="stat-history" class="text-[.6875rem] text-gray-500">0 msgs in history</div>
|
|
210
210
|
</div>
|
|
211
211
|
</div>
|
|
212
|
+
<div class="stat-card section-card flex items-start gap-3.5">
|
|
213
|
+
<div class="w-9 h-9 rounded-lg bg-cyan-500/15 flex items-center justify-center shrink-0 mt-0.5">
|
|
214
|
+
<svg class="w-4.5 h-4.5 text-cyan-400" fill="none" stroke="currentColor" stroke-width="1.75" viewBox="0 0 24 24"><path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/></svg>
|
|
215
|
+
</div>
|
|
216
|
+
<div class="min-w-0">
|
|
217
|
+
<div class="text-[.6875rem] text-gray-500 font-medium uppercase tracking-wider mb-1">Channels</div>
|
|
218
|
+
<div id="stat-channels" class="text-base font-semibold text-white">Web only</div>
|
|
219
|
+
<div id="stat-channels-detail" class="text-[.6875rem] text-gray-500">web dashboard</div>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
212
222
|
</div>
|
|
213
223
|
|
|
214
224
|
<!-- Identity & Status Row -->
|
|
@@ -266,6 +276,18 @@
|
|
|
266
276
|
</div>
|
|
267
277
|
</div>
|
|
268
278
|
|
|
279
|
+
<!-- Memory -->
|
|
280
|
+
<div class="section-card mb-6">
|
|
281
|
+
<h3 class="text-[.8125rem] font-semibold text-white mb-3 flex items-center gap-2">
|
|
282
|
+
<svg class="w-4 h-4 text-cyan-400" fill="none" stroke="currentColor" stroke-width="1.75" viewBox="0 0 24 24"><path d="M12 2a10 10 0 100 20 10 10 0 000-20z"/><path d="M12 6v6l4 2"/></svg>
|
|
283
|
+
Memory
|
|
284
|
+
<span id="memory-badge" class="text-[.625rem] text-gray-500 font-normal ml-1">0 entries</span>
|
|
285
|
+
</h3>
|
|
286
|
+
<div id="memory-content" class="max-h-[260px] overflow-y-auto chat-scroll">
|
|
287
|
+
<span class="text-[.75rem] text-gray-600 italic">No memories stored yet.</span>
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
|
|
269
291
|
<!-- Tools & Quick Actions Row -->
|
|
270
292
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
|
271
293
|
<!-- Tools List -->
|
|
@@ -479,6 +501,33 @@
|
|
|
479
501
|
</div>
|
|
480
502
|
</div>
|
|
481
503
|
|
|
504
|
+
<!-- Channels -->
|
|
505
|
+
<div class="cfg-section">
|
|
506
|
+
<h3 class="cfg-title flex items-center gap-2">
|
|
507
|
+
Channels
|
|
508
|
+
<span id="cfg-channel-status" class="text-[.625rem] font-normal text-gray-500"></span>
|
|
509
|
+
</h3>
|
|
510
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-4">
|
|
511
|
+
<div class="sm:col-span-2">
|
|
512
|
+
<label class="block text-xs text-gray-500 mb-1.5">Telegram Bot Token</label>
|
|
513
|
+
<input id="cfg-tg-token" type="password" class="input-field">
|
|
514
|
+
</div>
|
|
515
|
+
<div>
|
|
516
|
+
<label class="block text-xs text-gray-500 mb-1.5">Telegram Allowed Users</label>
|
|
517
|
+
<input id="cfg-tg-users" type="text" placeholder="Comma-separated user IDs (blank = allow all)" class="input-field">
|
|
518
|
+
</div>
|
|
519
|
+
<div class="sm:col-span-2 mt-2">
|
|
520
|
+
<label class="block text-xs text-gray-500 mb-1.5">Discord Bot Token</label>
|
|
521
|
+
<input id="cfg-dc-token" type="password" class="input-field">
|
|
522
|
+
</div>
|
|
523
|
+
<div>
|
|
524
|
+
<label class="block text-xs text-gray-500 mb-1.5">Discord Allowed Channels</label>
|
|
525
|
+
<input id="cfg-dc-channels" type="text" placeholder="Comma-separated channel IDs (blank = allow all)" class="input-field">
|
|
526
|
+
</div>
|
|
527
|
+
</div>
|
|
528
|
+
<p class="text-[.6875rem] text-gray-600 mt-3">Channels auto-start after saving. Tokens are stored securely.</p>
|
|
529
|
+
</div>
|
|
530
|
+
|
|
482
531
|
<!-- Web Dashboard -->
|
|
483
532
|
<div class="cfg-section">
|
|
484
533
|
<h3 class="cfg-title">Web Dashboard</h3>
|
|
@@ -601,6 +650,21 @@ async function refreshDashboard() {
|
|
|
601
650
|
banner.classList.toggle('hidden', d.providerReady !== false);
|
|
602
651
|
} catch (e) { console.error('Status fetch:', e); }
|
|
603
652
|
|
|
653
|
+
try {
|
|
654
|
+
const chRes = await fetch('/api/channels');
|
|
655
|
+
const chData = await chRes.json();
|
|
656
|
+
const running = (chData.channels || []).filter(c => c.running).map(c => c.type);
|
|
657
|
+
const chEl = document.getElementById('stat-channels');
|
|
658
|
+
const chDetailEl = document.getElementById('stat-channels-detail');
|
|
659
|
+
if (running.length > 0) {
|
|
660
|
+
chEl.textContent = (running.length + 1) + ' active';
|
|
661
|
+
chDetailEl.textContent = 'web + ' + running.join(', ');
|
|
662
|
+
} else {
|
|
663
|
+
chEl.textContent = 'Web only';
|
|
664
|
+
chDetailEl.textContent = 'web dashboard';
|
|
665
|
+
}
|
|
666
|
+
} catch (e) {}
|
|
667
|
+
|
|
604
668
|
try {
|
|
605
669
|
const res2 = await fetch('/api/identity');
|
|
606
670
|
const id = await res2.json();
|
|
@@ -653,6 +717,29 @@ async function refreshDashboard() {
|
|
|
653
717
|
`).join('');
|
|
654
718
|
}
|
|
655
719
|
} catch (e) { console.error('Identity fetch:', e); }
|
|
720
|
+
|
|
721
|
+
try {
|
|
722
|
+
const res3 = await fetch('/api/memories');
|
|
723
|
+
const mem = await res3.json();
|
|
724
|
+
const container = document.getElementById('memory-content');
|
|
725
|
+
const badge = document.getElementById('memory-badge');
|
|
726
|
+
const entries = mem.memories || {};
|
|
727
|
+
const keys = Object.keys(entries);
|
|
728
|
+
badge.textContent = keys.length + ' entries';
|
|
729
|
+
|
|
730
|
+
if (keys.length === 0) {
|
|
731
|
+
container.innerHTML = '<span class="text-[.75rem] text-gray-600 italic">No memories stored yet. Chat with the agent to build memory.</span>';
|
|
732
|
+
} else {
|
|
733
|
+
container.innerHTML = '<div class="space-y-2">' + keys.map(k => {
|
|
734
|
+
const val = escapeHtml(String(entries[k]));
|
|
735
|
+
const preview = val.length > 200 ? val.substring(0, 200) + '...' : val;
|
|
736
|
+
return `<div class="px-3 py-2 rounded-lg bg-surface-800/50 border border-surface-700/30">
|
|
737
|
+
<div class="text-[.6875rem] text-cyan-400 font-medium mb-1">${escapeHtml(k)}</div>
|
|
738
|
+
<div class="text-[.75rem] text-gray-400 leading-relaxed whitespace-pre-wrap">${preview}</div>
|
|
739
|
+
</div>`;
|
|
740
|
+
}).join('') + '</div>';
|
|
741
|
+
}
|
|
742
|
+
} catch (e) { console.error('Memories fetch:', e); }
|
|
656
743
|
}
|
|
657
744
|
|
|
658
745
|
// ── Identity Editor ──────────────────────────────────────────────────────────
|
|
@@ -1008,12 +1095,38 @@ async function loadConfig() {
|
|
|
1008
1095
|
ghTokenField.placeholder = secretsSet['skills.github.token']
|
|
1009
1096
|
? '(token is set — leave blank to keep)' : 'ghp_xxxxxxxxxx';
|
|
1010
1097
|
|
|
1098
|
+
const channels = _rawConfig.channels || {};
|
|
1099
|
+
const tgCfg = channels.telegram || {};
|
|
1100
|
+
const tgTokenField = document.getElementById('cfg-tg-token');
|
|
1101
|
+
tgTokenField.value = '';
|
|
1102
|
+
tgTokenField.placeholder = secretsSet['channels.telegram.token'] ? '(token is set — leave blank to keep)' : 'Enter Telegram bot token';
|
|
1103
|
+
document.getElementById('cfg-tg-users').value = (tgCfg.allowedUsers || []).join(', ');
|
|
1104
|
+
|
|
1105
|
+
const dcCfg = channels.discord || {};
|
|
1106
|
+
const dcTokenField = document.getElementById('cfg-dc-token');
|
|
1107
|
+
dcTokenField.value = '';
|
|
1108
|
+
dcTokenField.placeholder = secretsSet['channels.discord.token'] ? '(token is set — leave blank to keep)' : 'Enter Discord bot token';
|
|
1109
|
+
document.getElementById('cfg-dc-channels').value = (dcCfg.allowedChannels || []).join(', ');
|
|
1110
|
+
|
|
1011
1111
|
const web = _rawConfig.web || {};
|
|
1012
1112
|
document.getElementById('cfg-web-host').value = web.host || '0.0.0.0';
|
|
1013
1113
|
document.getElementById('cfg-web-port').value = web.port || 7788;
|
|
1014
1114
|
|
|
1015
1115
|
document.getElementById('cfg-json-raw').value = JSON.stringify(_rawConfig, null, 2);
|
|
1016
1116
|
document.getElementById('config-save-status').textContent = '';
|
|
1117
|
+
|
|
1118
|
+
// Channel status
|
|
1119
|
+
try {
|
|
1120
|
+
const chRes = await fetch('/api/channels');
|
|
1121
|
+
const chData = await chRes.json();
|
|
1122
|
+
const statusEl = document.getElementById('cfg-channel-status');
|
|
1123
|
+
const running = (chData.channels || []).filter(c => c.running).map(c => c.type);
|
|
1124
|
+
if (running.length > 0) {
|
|
1125
|
+
statusEl.innerHTML = '<span class="text-accent-green">● ' + running.join(', ') + ' running</span>';
|
|
1126
|
+
} else {
|
|
1127
|
+
statusEl.textContent = '';
|
|
1128
|
+
}
|
|
1129
|
+
} catch (e) {}
|
|
1017
1130
|
} catch (e) { console.error('Config fetch:', e); }
|
|
1018
1131
|
}
|
|
1019
1132
|
|
|
@@ -1090,6 +1203,19 @@ async function saveConfig() {
|
|
|
1090
1203
|
const ghToken = document.getElementById('cfg-github-token').value.trim();
|
|
1091
1204
|
if (ghToken) cfg.skills.github.token = ghToken;
|
|
1092
1205
|
|
|
1206
|
+
if (!cfg.channels) cfg.channels = {};
|
|
1207
|
+
if (!cfg.channels.telegram) cfg.channels.telegram = {};
|
|
1208
|
+
const tgToken = document.getElementById('cfg-tg-token').value.trim();
|
|
1209
|
+
if (tgToken) cfg.channels.telegram.token = tgToken;
|
|
1210
|
+
const tgUsers = document.getElementById('cfg-tg-users').value.trim();
|
|
1211
|
+
cfg.channels.telegram.allowedUsers = tgUsers ? tgUsers.split(',').map(s => s.trim()).filter(Boolean) : [];
|
|
1212
|
+
|
|
1213
|
+
if (!cfg.channels.discord) cfg.channels.discord = {};
|
|
1214
|
+
const dcToken = document.getElementById('cfg-dc-token').value.trim();
|
|
1215
|
+
if (dcToken) cfg.channels.discord.token = dcToken;
|
|
1216
|
+
const dcChannels = document.getElementById('cfg-dc-channels').value.trim();
|
|
1217
|
+
cfg.channels.discord.allowedChannels = dcChannels ? dcChannels.split(',').map(s => s.trim()).filter(Boolean) : [];
|
|
1218
|
+
|
|
1093
1219
|
if (!cfg.web) cfg.web = {};
|
|
1094
1220
|
cfg.web.host = document.getElementById('cfg-web-host').value.trim() || '0.0.0.0';
|
|
1095
1221
|
cfg.web.port = parseInt(document.getElementById('cfg-web-port').value) || 7788;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pythonclaw
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: OpenClaw reimagined in pure Python — autonomous AI agent with memory, RAG, skills, web dashboard, and multi-channel support.
|
|
5
5
|
Author-email: Eric Wang <wangchen2007915@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -76,7 +76,10 @@ Dynamic: license-file
|
|
|
76
76
|
<a href="https://github.com/ericwang915/PythonClaw/actions/workflows/ci.yml">
|
|
77
77
|
<img src="https://github.com/ericwang915/PythonClaw/actions/workflows/ci.yml/badge.svg" alt="CI">
|
|
78
78
|
</a>
|
|
79
|
-
<
|
|
79
|
+
<a href="https://pypi.org/project/pythonclaw/">
|
|
80
|
+
<img src="https://img.shields.io/pypi/v/pythonclaw?color=blue" alt="PyPI">
|
|
81
|
+
</a>
|
|
82
|
+
<img src="https://img.shields.io/pypi/pyversions/pythonclaw" alt="Python">
|
|
80
83
|
<a href="LICENSE">
|
|
81
84
|
<img src="https://img.shields.io/github/license/ericwang915/PythonClaw" alt="MIT License">
|
|
82
85
|
</a>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
pythonclaw/__init__.py,sha256=
|
|
1
|
+
pythonclaw/__init__.py,sha256=WUtCQQOhI2PW7Bj-z9y7VqLQ2mCAklPE9kbIAv2ziwo,389
|
|
2
2
|
pythonclaw/__main__.py,sha256=8q42hSuG6znq4wWXSPDmCtmG77SF7P_23hjwaRb-V9I,123
|
|
3
3
|
pythonclaw/config.py,sha256=QreP_tBvUTK6UD2wsEMgBX51Tzb6KuIjznQQFgkKVOI,5395
|
|
4
4
|
pythonclaw/daemon.py,sha256=i07DGJd-REzSW6tHQIEgHpx3Is44ZcxjCcUxFV8_p0c,6519
|
|
5
5
|
pythonclaw/init.py,sha256=SMPaW-esuUeMIEYAEVC8Kl5jxmGz_BKgfm-ay5EMbe8,2311
|
|
6
|
-
pythonclaw/main.py,sha256=
|
|
7
|
-
pythonclaw/onboard.py,sha256=
|
|
8
|
-
pythonclaw/server.py,sha256=
|
|
6
|
+
pythonclaw/main.py,sha256=Fo1jGbRFngwcecphF7X_dN8DMspFYzG39DkpLd4-KZs,18071
|
|
7
|
+
pythonclaw/onboard.py,sha256=mzGhHmVghoveSc9Cku0YxOA_0O4blXRim12GIqJ2JVM,11693
|
|
8
|
+
pythonclaw/server.py,sha256=2rHC9xJXeur4qoA8UCmHN3u7oooB3nSYByjZcsxdEyQ,3857
|
|
9
9
|
pythonclaw/session_manager.py,sha256=oWxvyztYqAwgkG5ofJYiXf0XHR8NKD8wmF7FmWsetM8,3969
|
|
10
10
|
pythonclaw/channels/discord_bot.py,sha256=ToEs5wm0woo7pjMfjyiVDvBjt2nxQ9MfyJU9g5U5o1w,9293
|
|
11
11
|
pythonclaw/channels/telegram_bot.py,sha256=S2GSQQHQnUDRemhj2NMUgMxTbTTIsACwquMdIpdVUJw,9959
|
|
@@ -100,13 +100,13 @@ pythonclaw/templates/skills/web/CATEGORY.md,sha256=sCfrbWk9kfbWAv5_wkB7J2Fzz1I7f
|
|
|
100
100
|
pythonclaw/templates/skills/web/tavily/SKILL.md,sha256=j9chgkhxHEVNpnZv0fBLp8vDtZmqfiS577E5OWda2U4,2018
|
|
101
101
|
pythonclaw/templates/soul/SOUL.md,sha256=DskXNm-rKTG1pG_k17CEjOBfcC-7YlVVgPAoRHGQDXs,2182
|
|
102
102
|
pythonclaw/web/__init__.py,sha256=ZgKF2tEAcpGnM22EC1CpNKtV4PQ8RbHw2qIqhw7i3UM,86
|
|
103
|
-
pythonclaw/web/app.py,sha256=
|
|
103
|
+
pythonclaw/web/app.py,sha256=YfaPbq2D6zgYyuY0UsA-uJQgPy_-xbngd2V4Qcnak7o,24049
|
|
104
104
|
pythonclaw/web/static/favicon.png,sha256=zJA13uE8mSe6lOlR5NyAhiOmnZkfv7ZlBbSBNCH7iTM,2557
|
|
105
|
-
pythonclaw/web/static/index.html,sha256=
|
|
105
|
+
pythonclaw/web/static/index.html,sha256=voy3AbwE0ftNL7nnFFqfN920cMaL0D7twwwQeoGEhnU,75713
|
|
106
106
|
pythonclaw/web/static/logo.png,sha256=h7v0HHllD23FtmCL2UvjjTDt0UgqKjGy5jOhI3rb7lM,28359
|
|
107
|
-
pythonclaw-0.2.
|
|
108
|
-
pythonclaw-0.2.
|
|
109
|
-
pythonclaw-0.2.
|
|
110
|
-
pythonclaw-0.2.
|
|
111
|
-
pythonclaw-0.2.
|
|
112
|
-
pythonclaw-0.2.
|
|
107
|
+
pythonclaw-0.2.2.dist-info/licenses/LICENSE,sha256=wbYsm5Ofe8cnxHgWSnSG1vUJDNiY1DIeTyxHSbo1HqM,1066
|
|
108
|
+
pythonclaw-0.2.2.dist-info/METADATA,sha256=shmBvIvx1M7_1_oG8qpMX4Uh-G3YU2PNPRZXtNrzdDU,14586
|
|
109
|
+
pythonclaw-0.2.2.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
|
|
110
|
+
pythonclaw-0.2.2.dist-info/entry_points.txt,sha256=4uGCuBw-id_22IRdkoxPVOOcwgiPX5lNEpD1XKQWE4I,52
|
|
111
|
+
pythonclaw-0.2.2.dist-info/top_level.txt,sha256=S_lM2VH3gP3UeZbSWHXIrBOCNtoqn5pk491IAzgsV7M,11
|
|
112
|
+
pythonclaw-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|