openclaw-agent-dashboard 1.0.47 → 1.0.48
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.
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Regression tests for timeline_reader I/O helpers."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
BACKEND = Path(__file__).resolve().parent.parent.parent
|
|
10
|
+
sys.path.insert(0, str(BACKEND))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_read_text_lines_tail_mode_reads_small_file(tmp_path: Path) -> None:
|
|
14
|
+
"""max_lines > 0 must not return empty after seek-to-EOF on small jsonl files."""
|
|
15
|
+
from data.timeline_reader import _read_text_lines
|
|
16
|
+
|
|
17
|
+
session = tmp_path / "session.jsonl"
|
|
18
|
+
session.write_text(
|
|
19
|
+
'{"type":"session","id":"s1"}\n'
|
|
20
|
+
'{"type":"message","message":{"role":"user","content":[{"type":"text","text":"hi"}]}}\n',
|
|
21
|
+
encoding="utf-8",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
lines = _read_text_lines(session, max_lines=10)
|
|
25
|
+
assert len(lines) == 2
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_get_timeline_steps_subagent_small_session(tmp_path: Path, monkeypatch) -> None:
|
|
29
|
+
"""Sub-agent sessions under 64KB should produce timeline steps."""
|
|
30
|
+
from data import timeline_reader as tl
|
|
31
|
+
|
|
32
|
+
agent_id = "analyst-agent"
|
|
33
|
+
session_id = "740a6a44-test"
|
|
34
|
+
agent_dir = tmp_path / "agents" / agent_id / "sessions"
|
|
35
|
+
agent_dir.mkdir(parents=True)
|
|
36
|
+
session_file = agent_dir / f"{session_id}.jsonl"
|
|
37
|
+
session_file.write_text(
|
|
38
|
+
'{"type":"session","version":3,"id":"740a6a44-test","timestamp":"2026-05-28T13:03:10.984Z"}\n'
|
|
39
|
+
'{"type":"message","id":"u1","timestamp":"2026-05-28T13:03:11.000Z","message":{"role":"user","content":[{"type":"text","text":"task"}]}}\n'
|
|
40
|
+
'{"type":"message","id":"a1","timestamp":"2026-05-28T13:03:12.000Z","message":{"role":"assistant","content":[{"type":"text","text":"done"}],"stopReason":"stop"}}\n',
|
|
41
|
+
encoding="utf-8",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
monkeypatch.setattr(tl, "get_openclaw_root", lambda: tmp_path)
|
|
45
|
+
|
|
46
|
+
def fake_resolve(agent_id: str, session_key=None):
|
|
47
|
+
return session_file, session_id, f"agent:{agent_id}:subagent:test"
|
|
48
|
+
|
|
49
|
+
monkeypatch.setattr(tl, "resolve_agent_session_jsonl", fake_resolve)
|
|
50
|
+
monkeypatch.setattr(tl, "_get_main_agent_id", lambda: "project-manager")
|
|
51
|
+
monkeypatch.setattr(tl, "_get_requester_info_for_session", lambda *_: {})
|
|
52
|
+
monkeypatch.setattr(tl, "_subagent_run_anchor_ms", lambda *_: 1779973391013)
|
|
53
|
+
|
|
54
|
+
result = tl.get_timeline_steps(agent_id)
|
|
55
|
+
assert len(result["steps"]) >= 2
|
package/openclaw.plugin.json
CHANGED