dsh-agent-control-center 0.4.1 → 0.6.0
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.
- package/CHANGELOG.md +80 -0
- package/README.md +4 -4
- package/README.zh.md +4 -4
- package/client.js +226 -5
- package/docs/01-CONTRACT.md +1 -1
- package/docs/05-ACCEPTANCE-EVIDENCE.md +71 -0
- package/docs/07-GUIDE.md +1 -1
- package/docs/09-ARCHITECTURE.md +1 -1
- package/docs/12-PLUGIN-HEALTH.md +18 -1
- package/docs/14-INTERACTION-REGRESSION-0.5.0.md +79 -0
- package/docs/15-WRITE-REGRESSION.md +43 -0
- package/docs/16-TOOLS-FIRST-PAINT.md +36 -0
- package/index.js +1 -1
- package/lib/modules/l-health.js +182 -1
- package/package.json +1 -1
- package/scripts/interaction-regression.py +278 -0
- package/scripts/write-regression.py +107 -0
- package/src/client/i18n/health.js +56 -0
- package/src/client/i18n/tools.js +2 -0
- package/src/client/pages/health.js +147 -0
- package/src/client/pages/tools.js +19 -3
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Per-page interaction regression for the Agent Control Center settings pages.
|
|
3
|
+
|
|
4
|
+
Drives a real Chrome against a running verification instance and asserts one or
|
|
5
|
+
two concrete interactions per page. It is intentionally not part of
|
|
6
|
+
`node scripts/verify.mjs`: it needs Playwright, a Chrome binary, and a live
|
|
7
|
+
host, so it runs on demand instead of on every gate.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
python3 scripts/interaction-regression.py --token <web token> [--base http://127.0.0.1:38080] [--out /tmp/acc-interaction]
|
|
11
|
+
|
|
12
|
+
Exit code 0 means every assertion passed; 1 means at least one failed (the JSON
|
|
13
|
+
result file lists them).
|
|
14
|
+
"""
|
|
15
|
+
import argparse, json, os, sys, time
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def parse_args():
|
|
19
|
+
parser = argparse.ArgumentParser()
|
|
20
|
+
parser.add_argument("--token", required=True)
|
|
21
|
+
parser.add_argument("--base", default="http://127.0.0.1:38080")
|
|
22
|
+
parser.add_argument("--out", default="/tmp/acc-interaction")
|
|
23
|
+
parsed = parser.parse_args()
|
|
24
|
+
os.makedirs(parsed.out, exist_ok=True)
|
|
25
|
+
return parsed
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
args = parse_args()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
results, console = [], []
|
|
32
|
+
|
|
33
|
+
def rec(page, step, ok, detail=""):
|
|
34
|
+
results.append({"page": page, "step": step, "ok": bool(ok), "detail": str(detail)[:300]})
|
|
35
|
+
print(f" {'PASS' if ok else 'FAIL'} {page} / {step}{'' if detail == '' else ' — ' + str(detail)[:120]}")
|
|
36
|
+
|
|
37
|
+
def text(page):
|
|
38
|
+
return page.evaluate("() => document.querySelector('.acc-root')?.innerText || ''")
|
|
39
|
+
|
|
40
|
+
def wait_for(page, needle, seconds=30):
|
|
41
|
+
end = time.time() + seconds
|
|
42
|
+
while time.time() < end:
|
|
43
|
+
if needle in text(page): return True
|
|
44
|
+
page.wait_for_timeout(400)
|
|
45
|
+
return False
|
|
46
|
+
|
|
47
|
+
def nav(page, label):
|
|
48
|
+
item = page.locator(f'.acc-nav-item:has-text("{label}")').first
|
|
49
|
+
item.scroll_into_view_if_needed(timeout=4000)
|
|
50
|
+
item.click(timeout=4000)
|
|
51
|
+
page.wait_for_timeout(600)
|
|
52
|
+
|
|
53
|
+
with sync_playwright() as p:
|
|
54
|
+
b = p.chromium.launch(executable_path="/usr/bin/google-chrome", headless=True, args=["--no-sandbox", "--disable-dev-shm-usage"])
|
|
55
|
+
page = b.new_page(viewport={"width": 1440, "height": 1000}, locale="en-US")
|
|
56
|
+
page.on("console", lambda m: console.append((m.type, m.text[:200]) if m.type in ("error", "warning") else None))
|
|
57
|
+
page.on("pageerror", lambda e: console.append(("pageerror", str(e)[:300])))
|
|
58
|
+
page.goto(f"{args.base}/?token={args.token}", wait_until="domcontentloaded", timeout=60000)
|
|
59
|
+
end = time.time() + 60
|
|
60
|
+
while time.time() < end:
|
|
61
|
+
if page.evaluate("() => document.querySelector('[data-dsh-boot]') === null"): break
|
|
62
|
+
page.wait_for_timeout(400)
|
|
63
|
+
page.wait_for_timeout(2500)
|
|
64
|
+
for _ in range(8):
|
|
65
|
+
if page.evaluate("() => document.querySelectorAll('[role=dialog]').length") == 0: break
|
|
66
|
+
try: page.locator('button:has-text("Continue")').first.click(timeout=1000, force=True); page.wait_for_timeout(500); continue
|
|
67
|
+
except Exception: pass
|
|
68
|
+
try: page.locator('[aria-label="Close"]').first.click(timeout=1000, force=True); page.wait_for_timeout(500); continue
|
|
69
|
+
except Exception: page.keyboard.press("Escape"); page.wait_for_timeout(300)
|
|
70
|
+
for _ in range(3):
|
|
71
|
+
try:
|
|
72
|
+
page.locator('[aria-label="Account menu"]').first.click(timeout=4000, force=True); page.wait_for_timeout(700)
|
|
73
|
+
page.locator('[role=menuitem]:has-text("Settings")').first.click(timeout=4000); page.wait_for_timeout(1200)
|
|
74
|
+
page.get_by_text("Agent Control Center", exact=True).first.click(timeout=6000); page.wait_for_timeout(2200)
|
|
75
|
+
if "Overview" in text(page): break
|
|
76
|
+
except Exception: page.keyboard.press("Escape"); page.wait_for_timeout(400)
|
|
77
|
+
|
|
78
|
+
steps = 0
|
|
79
|
+
def safe(page, label, fn):
|
|
80
|
+
global steps
|
|
81
|
+
try:
|
|
82
|
+
fn()
|
|
83
|
+
|
|
84
|
+
except Exception as exc:
|
|
85
|
+
rec(label, "interaction", False, f"{type(exc).__name__}: {exc}")
|
|
86
|
+
page.keyboard.press("Escape")
|
|
87
|
+
|
|
88
|
+
# --- Overview: click a stat card and expect navigation ---
|
|
89
|
+
def overview_page():
|
|
90
|
+
nav(page, "Overview")
|
|
91
|
+
end = time.time() + 25
|
|
92
|
+
while time.time() < end and page.locator('.acc-root .acc-stat').count() == 0:
|
|
93
|
+
page.wait_for_timeout(500)
|
|
94
|
+
count = page.locator('.acc-root .acc-stat').count()
|
|
95
|
+
rec("Overview", "stat tiles render", count > 0, f"{count} tiles")
|
|
96
|
+
if count == 0: return
|
|
97
|
+
page.locator('.acc-root .acc-stat').first.click(timeout=5000); page.wait_for_timeout(1200)
|
|
98
|
+
rec("Overview", "stat tile navigates", page.evaluate("() => document.querySelector('.acc-root')?.getAttribute('data-acc-page')") != "overview",
|
|
99
|
+
page.evaluate("() => document.querySelector('.acc-root')?.getAttribute('data-acc-page')"))
|
|
100
|
+
safe(page, "Overview", overview_page)
|
|
101
|
+
|
|
102
|
+
# --- AGENTS.md: select a file row ---
|
|
103
|
+
def agents_page():
|
|
104
|
+
nav(page, "AGENTS.md")
|
|
105
|
+
if not wait_for(page, "AGENTS.md"):
|
|
106
|
+
rec("AGENTS.md", "list loaded", False, text(page)[:140]); return
|
|
107
|
+
time.sleep(4)
|
|
108
|
+
rec("AGENTS.md", "chain renders", len(text(page)) > 800, f"{len(text(page))} chars")
|
|
109
|
+
rows = page.locator('.acc-root button:has-text("AGENTS.md")')
|
|
110
|
+
if rows.count() == 0:
|
|
111
|
+
rec("AGENTS.md", "file rows", False, "no rows"); return
|
|
112
|
+
rows.first.click(timeout=5000); page.wait_for_timeout(900)
|
|
113
|
+
rec("AGENTS.md", "row selection", True, f"{rows.count()} rows")
|
|
114
|
+
safe(page, "AGENTS.md", agents_page)
|
|
115
|
+
|
|
116
|
+
# --- Tools: search + expand + Esc keeps Settings ---
|
|
117
|
+
def tools_page():
|
|
118
|
+
nav(page, "Tools")
|
|
119
|
+
if not wait_for(page, "tools", 5): pass
|
|
120
|
+
page.wait_for_timeout(2500)
|
|
121
|
+
search = page.locator('.acc-root input[aria-label="Search tools"]').first
|
|
122
|
+
search.fill("read"); page.wait_for_timeout(700)
|
|
123
|
+
rec("Tools", "search narrows", "read" in text(page).lower())
|
|
124
|
+
expand = page.locator('.acc-root button[aria-label^="Expand detail"]').first
|
|
125
|
+
if expand.count() == 0:
|
|
126
|
+
rec("Tools", "expand row", False, "no expand button"); return
|
|
127
|
+
expand.click(timeout=5000); page.wait_for_timeout(900)
|
|
128
|
+
opened = page.evaluate("() => document.querySelectorAll('.acc-root button[aria-label^=\\'Collapse detail\\']').length")
|
|
129
|
+
rec("Tools", "row expands", opened >= 1, f"{opened} open")
|
|
130
|
+
page.keyboard.press("Escape"); page.wait_for_timeout(700)
|
|
131
|
+
rec("Tools", "Esc collapses row", page.evaluate("() => document.querySelectorAll('.acc-root button[aria-label^=\\'Collapse detail\\']').length") == 0)
|
|
132
|
+
rec("Tools", "Esc keeps Settings", page.evaluate("() => document.querySelector('.acc-root') !== null"))
|
|
133
|
+
search.fill(""); page.wait_for_timeout(500)
|
|
134
|
+
safe(page, "Tools", tools_page)
|
|
135
|
+
|
|
136
|
+
# --- Sessions: archived tab + select + expand ---
|
|
137
|
+
def sessions_page():
|
|
138
|
+
nav(page, "Sessions")
|
|
139
|
+
wait_for(page, "Session list", 20)
|
|
140
|
+
tabs = page.locator('.acc-root button:has-text("Archived")')
|
|
141
|
+
if tabs.count() > 0:
|
|
142
|
+
tabs.first.click(timeout=5000); page.wait_for_timeout(1500)
|
|
143
|
+
rec("Sessions", "archived tab", "Archived" in text(page))
|
|
144
|
+
page.locator('.acc-root button:has-text("All chats")').first.click(timeout=5000); page.wait_for_timeout(1200)
|
|
145
|
+
box = page.locator('.acc-root input[type=checkbox]').first
|
|
146
|
+
if box.count() > 0:
|
|
147
|
+
box.check(timeout=4000, force=True); page.wait_for_timeout(800)
|
|
148
|
+
rec("Sessions", "select shows toolbar", "selected" in text(page).lower())
|
|
149
|
+
safe(page, "Sessions", sessions_page)
|
|
150
|
+
|
|
151
|
+
# --- Usage: date switch ---
|
|
152
|
+
def usage_page():
|
|
153
|
+
nav(page, "Usage")
|
|
154
|
+
wait_for(page, "Usage", 10); page.wait_for_timeout(1200)
|
|
155
|
+
before = text(page)
|
|
156
|
+
sel = page.locator('.acc-root input[type=date], .acc-root select').first
|
|
157
|
+
if sel.count() == 0:
|
|
158
|
+
rec("Usage", "date control", False, "no date control"); return
|
|
159
|
+
try:
|
|
160
|
+
sel.fill("2026-11-01") if page.evaluate("() => document.querySelector('.acc-root input[type=date]') !== null") else sel.select_option(index=1)
|
|
161
|
+
page.wait_for_timeout(1400)
|
|
162
|
+
except Exception: pass
|
|
163
|
+
rec("Usage", "date switch re-renders", len(text(page)) > 500)
|
|
164
|
+
safe(page, "Usage", usage_page)
|
|
165
|
+
|
|
166
|
+
# --- Agent info: presets tab + export tab ---
|
|
167
|
+
def meta_page():
|
|
168
|
+
nav(page, "Agent info")
|
|
169
|
+
wait_for(page, "Agents", 10); page.wait_for_timeout(1200)
|
|
170
|
+
presets = page.locator('.acc-root button:has-text("Presets")').first
|
|
171
|
+
if presets.count() > 0:
|
|
172
|
+
presets.click(timeout=5000); page.wait_for_timeout(1500)
|
|
173
|
+
rec("Agent info", "presets view", "Presets" in text(page))
|
|
174
|
+
export_tab = page.locator('.acc-root button:has-text("Export")').last
|
|
175
|
+
if export_tab.count() > 0:
|
|
176
|
+
export_tab.click(timeout=5000); page.wait_for_timeout(1500)
|
|
177
|
+
rec("Agent info", "export view", "exportedAt" in text(page) or "Export configuration" in text(page))
|
|
178
|
+
safe(page, "Agent info", meta_page)
|
|
179
|
+
|
|
180
|
+
# --- Instruction: session view + compare ---
|
|
181
|
+
def instruction_page():
|
|
182
|
+
nav(page, "Instruction preview")
|
|
183
|
+
wait_for(page, "Instruction chain", 20); page.wait_for_timeout(1500)
|
|
184
|
+
by_session = page.locator('.acc-root button:has-text("By session")').first
|
|
185
|
+
if by_session.count() == 0:
|
|
186
|
+
rec("Instruction", "session tab", False, "no tab"); return
|
|
187
|
+
by_session.click(timeout=5000); page.wait_for_timeout(2500)
|
|
188
|
+
sel = page.locator('.acc-root select').first
|
|
189
|
+
if sel.count() > 0:
|
|
190
|
+
options = sel.locator('option').count()
|
|
191
|
+
rec("Instruction", "session selector", options > 1, f"{options} options")
|
|
192
|
+
rec("Instruction", "session view renders", "Session selection" in text(page) or "session" in text(page).lower())
|
|
193
|
+
safe(page, "Instruction", instruction_page)
|
|
194
|
+
|
|
195
|
+
# --- Templates: open a template detail ---
|
|
196
|
+
def templates_page():
|
|
197
|
+
nav(page, "Templates")
|
|
198
|
+
wait_for(page, "Template center", 15); page.wait_for_timeout(1200)
|
|
199
|
+
cards = page.locator('.acc-root [data-template-id], .acc-root .acc-list-item button, .acc-root button[aria-label]')
|
|
200
|
+
if cards.count() == 0:
|
|
201
|
+
rec("Templates", "list renders", False, text(page)[:120]); return
|
|
202
|
+
before = len(text(page))
|
|
203
|
+
cards.first.click(timeout=5000); page.wait_for_timeout(2500)
|
|
204
|
+
after = text(page)
|
|
205
|
+
# A template detail may render in a host modal (ported outside .acc-root).
|
|
206
|
+
dialog = page.evaluate("() => document.querySelectorAll('[role=dialog]').length")
|
|
207
|
+
rec("Templates", "detail opens", len(after) > before or "Apply" in after or dialog > 0,
|
|
208
|
+
f"{before} -> {len(after)}, dialogs={dialog}")
|
|
209
|
+
safe(page, "Templates", templates_page)
|
|
210
|
+
|
|
211
|
+
# --- Diagnostics: warn filter ---
|
|
212
|
+
def diagnostics_page():
|
|
213
|
+
nav(page, "Diagnostics")
|
|
214
|
+
wait_for(page, "System diagnostics", 20); page.wait_for_timeout(1500)
|
|
215
|
+
warn = page.locator('.acc-root button:has-text("Warning")').first
|
|
216
|
+
if warn.count() == 0:
|
|
217
|
+
rec("Diagnostics", "warning filter", False, "no filter"); return
|
|
218
|
+
warn.click(timeout=5000); page.wait_for_timeout(1200)
|
|
219
|
+
rec("Diagnostics", "filter applied", "Warning" in text(page))
|
|
220
|
+
safe(page, "Diagnostics", diagnostics_page)
|
|
221
|
+
|
|
222
|
+
# --- Health: drift block + bundle button ---
|
|
223
|
+
def health_page():
|
|
224
|
+
nav(page, "Health check")
|
|
225
|
+
got = wait_for(page, "Drift items", 30) or wait_for(page, "Plugin rows", 15)
|
|
226
|
+
rec("Health", "drift tiles", got)
|
|
227
|
+
if not got: return
|
|
228
|
+
rec("Health", "drift counts", "Addressable" in text(page) and "Profile-owned" in text(page))
|
|
229
|
+
btn = page.locator('.acc-root button:has-text("Check bundle installation")')
|
|
230
|
+
if btn.count() == 0:
|
|
231
|
+
rec("Health", "bundle button", False, "missing"); return
|
|
232
|
+
# The button is disabled while the first read is in flight.
|
|
233
|
+
for _ in range(30):
|
|
234
|
+
if not btn.first.is_disabled(): break
|
|
235
|
+
page.wait_for_timeout(500)
|
|
236
|
+
btn.first.scroll_into_view_if_needed(); btn.first.click(timeout=6000)
|
|
237
|
+
# The shallow render already says "No drift", so wait for the deep answer
|
|
238
|
+
# to arrive (its own marker), not for any of the two states.
|
|
239
|
+
end = time.time() + 40
|
|
240
|
+
while time.time() < end:
|
|
241
|
+
if "Declared but not installed" in text(page): break
|
|
242
|
+
page.wait_for_timeout(500)
|
|
243
|
+
rec("Health", "bundle check result", "Declared but not installed" in text(page), text(page)[-160:])
|
|
244
|
+
safe(page, "Health", health_page)
|
|
245
|
+
|
|
246
|
+
# --- Export: select a session and generate ---
|
|
247
|
+
def export_page():
|
|
248
|
+
nav(page, "Export")
|
|
249
|
+
wait_for(page, "Session", 15); page.wait_for_timeout(1500)
|
|
250
|
+
sel = page.locator('.acc-root select').first
|
|
251
|
+
if sel.count() > 0:
|
|
252
|
+
sel.select_option(index=1); page.wait_for_timeout(1500)
|
|
253
|
+
rec("Export", "session selected", True)
|
|
254
|
+
gen = page.locator('.acc-root button:has-text("Generate"), .acc-root button:has-text("Export")').first
|
|
255
|
+
if gen.count() == 0:
|
|
256
|
+
rec("Export", "generate", False, "no button"); return
|
|
257
|
+
gen.click(timeout=6000); page.wait_for_timeout(3000)
|
|
258
|
+
rec("Export", "preview produced", len(text(page)) > 800, f"{len(text(page))} chars")
|
|
259
|
+
safe(page, "Export", export_page)
|
|
260
|
+
|
|
261
|
+
# --- Restart & Resume: scan ---
|
|
262
|
+
def recovery_page():
|
|
263
|
+
nav(page, "Restart & Resume")
|
|
264
|
+
wait_for(page, "Restart", 10); page.wait_for_timeout(1200)
|
|
265
|
+
scan = page.locator('.acc-root button:has-text("Scan"), .acc-root button:has-text("Refresh")').first
|
|
266
|
+
if scan.count() == 0:
|
|
267
|
+
rec("Restart", "scan button", False, "none"); return
|
|
268
|
+
scan.click(timeout=6000); page.wait_for_timeout(2500)
|
|
269
|
+
rec("Restart", "scan runs", len(text(page)) > 300, f"{len(text(page))} chars")
|
|
270
|
+
safe(page, "Restart", recovery_page)
|
|
271
|
+
|
|
272
|
+
page.screenshot(path=f"{args.out}/final.png")
|
|
273
|
+
bad = [c for c in console if c is not None and c[0] in ("error", "pageerror")]
|
|
274
|
+
rec("global", "console errors", len(bad) == 0, json.dumps(bad[:3], ensure_ascii=False)[:240])
|
|
275
|
+
failed = [r for r in results if not r["ok"]]
|
|
276
|
+
print(f"RESULT {len(results) - len(failed)}/{len(results)} passed")
|
|
277
|
+
open(f"{args.out}/results.json", "w").write(json.dumps(results, ensure_ascii=False, indent=1))
|
|
278
|
+
b.close()
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Write-path end-to-end regression: save, backup, optimistic concurrency, restore.
|
|
3
|
+
|
|
4
|
+
Points at ONE existing instruction file inside a directory that is a session
|
|
5
|
+
working directory of the running verification instance. The file is restored to
|
|
6
|
+
its original bytes before the script exits; the caller should check that
|
|
7
|
+
afterwards (the script prints the final sha256).
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
python3 scripts/write-regression.py --token <web token> --cwd <session cwd> --file <instruction file> [--base ...]
|
|
11
|
+
|
|
12
|
+
Refuses to run when the target does not exist so it can never create one.
|
|
13
|
+
"""
|
|
14
|
+
import argparse, hashlib, json, os, subprocess, sys, time
|
|
15
|
+
|
|
16
|
+
def parse_args():
|
|
17
|
+
parser = argparse.ArgumentParser()
|
|
18
|
+
parser.add_argument("--token", required=True)
|
|
19
|
+
parser.add_argument("--cwd", required=True, help="a session working directory of the running instance")
|
|
20
|
+
parser.add_argument("--file", required=True, help="absolute path of an existing instruction file")
|
|
21
|
+
parser.add_argument("--base", default="http://127.0.0.1:38080")
|
|
22
|
+
parser.add_argument("--out", default="/tmp/acc-write-regression")
|
|
23
|
+
return parser.parse_args()
|
|
24
|
+
|
|
25
|
+
args = parse_args()
|
|
26
|
+
os.makedirs(args.out, exist_ok=True)
|
|
27
|
+
|
|
28
|
+
results = []
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def rec(step, ok, detail=''):
|
|
32
|
+
results.append((step, bool(ok), str(detail)[:200]))
|
|
33
|
+
print(f" {'PASS' if ok else 'FAIL'} {step}{'' if detail == '' else ' — ' + str(detail)[:140]}")
|
|
34
|
+
|
|
35
|
+
def login():
|
|
36
|
+
subprocess.run(['curl', '-sS', '-m', '10', '-c', J, '-o', '/dev/null',
|
|
37
|
+
f'{args.base}/?token={args.token}'], check=False, capture_output=True)
|
|
38
|
+
time.sleep(2)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def api(method, params=None, timeout=120):
|
|
42
|
+
body = json.dumps({'method': method, 'params': params or {}})
|
|
43
|
+
t0 = time.time()
|
|
44
|
+
out = subprocess.run(['curl','-sS','-m',str(timeout),'-b',J,'-H','Content-Type: application/json','-X','POST',f'{B}/api','-d',body], capture_output=True, text=True)
|
|
45
|
+
try: payload = json.loads(out.stdout)
|
|
46
|
+
except Exception: payload = {'ok': False, 'raw': out.stdout[:120]}
|
|
47
|
+
payload['_ms'] = round((time.time()-t0)*1000)
|
|
48
|
+
return payload
|
|
49
|
+
|
|
50
|
+
CWD = args.cwd
|
|
51
|
+
TARGET = args.file
|
|
52
|
+
J = os.path.join(args.out, 'cookies.txt')
|
|
53
|
+
B = args.base.rstrip('/') + '/__agent-control-center'
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def content_of(path):
|
|
57
|
+
return open(path, 'rb').read()
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
original = content_of(TARGET)
|
|
61
|
+
original_hash = hashlib.sha256(original).hexdigest()
|
|
62
|
+
open(os.path.join(args.out, 'original.bak'),'wb').write(original)
|
|
63
|
+
login()
|
|
64
|
+
print('target bytes:', len(original), 'sha256:', original_hash[:16])
|
|
65
|
+
|
|
66
|
+
live_before = content_of(TARGET)
|
|
67
|
+
|
|
68
|
+
# 1) Larger content, then a save through the real pipeline.
|
|
69
|
+
marker = f"\n\n<!-- write-e2e {time.strftime('%H%M%S')} -->\n"
|
|
70
|
+
edited = original.decode('utf-8') + marker
|
|
71
|
+
base = api('agents.summary')
|
|
72
|
+
rec('summary available', base.get('ok') is True, (base.get('value') or {}).get('cwd'))
|
|
73
|
+
|
|
74
|
+
backups_before = api('agents.backups', {'path': TARGET, 'cwd': CWD})
|
|
75
|
+
before_count = len(((backups_before.get('value') or {}).get('items')) or [])
|
|
76
|
+
rec('backups readable', backups_before.get('ok') is True, f'{before_count} existing')
|
|
77
|
+
|
|
78
|
+
save = api('agents.save', {'path': TARGET, 'cwd': CWD, 'content': edited, 'expectedHash': original_hash})
|
|
79
|
+
rec('save accepted', save.get('ok') is True, json.dumps(save.get('error'), ensure_ascii=False)[:120])
|
|
80
|
+
saved_hash = None
|
|
81
|
+
if save.get('ok'):
|
|
82
|
+
saved_hash = (save.get('value') or {}).get('hash')
|
|
83
|
+
rec('saved bytes match', content_of(TARGET).decode('utf-8') == edited, f'hash={saved_hash[:16] if saved_hash else None}')
|
|
84
|
+
rec('backup created', save.get('ok') and (save.get('value') or {}).get('backup') not in (None, ''), json.dumps((save.get('value') or {}).get('backup'))[:80])
|
|
85
|
+
|
|
86
|
+
after = api('agents.backups', {'path': TARGET, 'cwd': CWD})
|
|
87
|
+
after_count = len(((after.get('value') or {}).get('items')) or [])
|
|
88
|
+
rec('backup count grew', after_count > before_count, f'{before_count} -> {after_count}')
|
|
89
|
+
|
|
90
|
+
# 2) Stale-hash save must be refused (optimistic concurrency).
|
|
91
|
+
stale = api('agents.save', {'path': TARGET, 'cwd': CWD, 'content': edited + '\nstale\n', 'expectedHash': original_hash})
|
|
92
|
+
rec('stale hash refused', stale.get('ok') is False and (stale.get('error') or {}).get('code') in ('conflict', 'bad_request'), json.dumps(stale.get('error'), ensure_ascii=False)[:140])
|
|
93
|
+
|
|
94
|
+
# 3) Restore the newest backup and confirm exact bytes.
|
|
95
|
+
newest = ((after.get('value') or {}).get('items') or [{}])[0]
|
|
96
|
+
name = newest.get('name')
|
|
97
|
+
restore = api('agents.restore', {'path': TARGET, 'cwd': CWD, 'name': name})
|
|
98
|
+
rec('restore accepted', restore.get('ok') is True, json.dumps(restore.get('error'), ensure_ascii=False)[:120])
|
|
99
|
+
rec('bytes restored exactly', content_of(TARGET) == original, f'{len(content_of(TARGET))} bytes')
|
|
100
|
+
rec('restore made its own backup', restore.get('ok') and (restore.get('value') or {}).get('backupOfCurrent') not in (None, ''))
|
|
101
|
+
rec('fixture unchanged after restore', content_of(TARGET) == live_before)
|
|
102
|
+
|
|
103
|
+
json.dump([{'step': s, 'ok': o, 'detail': d} for s, o, d in results], open(os.path.join(args.out, 'results.json'),'w'), ensure_ascii=False, indent=1)
|
|
104
|
+
failed = [s for s, o, _ in results if not o]
|
|
105
|
+
print(f"RESULT {len(results)-len(failed)}/{len(results)} passed")
|
|
106
|
+
print('final sha256:', hashlib.sha256(content_of(TARGET)).hexdigest())
|
|
107
|
+
sys.exit(0 if not failed else 1)
|
|
@@ -57,6 +57,34 @@ ACC.addI18n({
|
|
|
57
57
|
'health.refresh.plugins': '刷新插件清单',
|
|
58
58
|
'health.refresh.settings': '刷新设置命名空间',
|
|
59
59
|
'health.refresh.sections': '刷新分区扫描结果',
|
|
60
|
+
'health.driftTitle': '声明与运行时(漂移)',
|
|
61
|
+
'health.driftSubtitle': 'profile 声明的插件行与 Loader 实际运行状态;不解析 patch 文件本身',
|
|
62
|
+
'health.driftTileRows': '插件行',
|
|
63
|
+
'health.driftTileMounted': 'profile 可寻址',
|
|
64
|
+
'health.driftTileInProfile': 'profile 管辖',
|
|
65
|
+
'health.driftTileCount': '漂移项',
|
|
66
|
+
'health.driftClean': '无漂移',
|
|
67
|
+
'health.driftFound': '有漂移',
|
|
68
|
+
'health.driftSelf': '本插件行',
|
|
69
|
+
'health.driftSelfEnabled': '启用',
|
|
70
|
+
'health.driftYes': '是',
|
|
71
|
+
'health.driftEmpty': '声明的插件行都在运行状态,未发现漂移。',
|
|
72
|
+
'health.driftCheckBundles': '检查 bundle 安装状态',
|
|
73
|
+
'health.driftCheckBundlesHint': '会读取每个安装位置,通常需要数秒',
|
|
74
|
+
'health.driftNotes': '说明',
|
|
75
|
+
'health.driftKindLabel': '类型',
|
|
76
|
+
'health.driftKindUnknown': '未知漂移类型',
|
|
77
|
+
'health.driftKind.startup-failed': '启动失败',
|
|
78
|
+
'health.driftKind.enabled-not-running': '已启用但未运行',
|
|
79
|
+
'health.driftKind.disabled-but-running': '已停用但仍在运行',
|
|
80
|
+
'health.driftKind.addressable-not-in-profile': '可寻址但不在 profile',
|
|
81
|
+
'health.driftKind.declared-not-installed': '声明未安装',
|
|
82
|
+
'health.driftAction.startup-failed': '修好该插件的配置或依赖,然后在 DSH 原生插件页重载',
|
|
83
|
+
'health.driftAction.enabled-not-running': '确认该模块是否加载失败(看 Diagnostics),必要时重载 profile',
|
|
84
|
+
'health.driftAction.disabled-but-running': '重载 profile 才会真正卸载该行',
|
|
85
|
+
'health.driftAction.addressable-not-in-profile': '确认该行来自哪一层 patch(bundle/内置/include)',
|
|
86
|
+
'health.driftAction.declared-not-installed': '重新安装该 bundle,或从 profile 移除该行',
|
|
87
|
+
'health.refresh.drift': '刷新漂移对比',
|
|
60
88
|
'health.refresh.compat': '刷新兼容性结论',
|
|
61
89
|
'health.refresh.host': '刷新宿主通道',
|
|
62
90
|
|
|
@@ -183,6 +211,34 @@ ACC.addI18n({
|
|
|
183
211
|
'health.refresh.plugins': 'Refresh plugin inventory',
|
|
184
212
|
'health.refresh.settings': 'Refresh settings namespaces',
|
|
185
213
|
'health.refresh.sections': 'Refresh section scan',
|
|
214
|
+
'health.driftTitle': 'Declared vs running (drift)',
|
|
215
|
+
'health.driftSubtitle': 'Plugin rows the profile declares against what the Loader actually runs; the patch file itself is not parsed',
|
|
216
|
+
'health.driftTileRows': 'Plugin rows',
|
|
217
|
+
'health.driftTileMounted': 'Addressable',
|
|
218
|
+
'health.driftTileInProfile': 'Profile-owned',
|
|
219
|
+
'health.driftTileCount': 'Drift items',
|
|
220
|
+
'health.driftClean': 'No drift',
|
|
221
|
+
'health.driftFound': 'Drift found',
|
|
222
|
+
'health.driftSelf': 'This plugin row',
|
|
223
|
+
'health.driftSelfEnabled': 'Enabled',
|
|
224
|
+
'health.driftYes': 'yes',
|
|
225
|
+
'health.driftEmpty': 'Every declared plugin row matches its running state.',
|
|
226
|
+
'health.driftCheckBundles': 'Check bundle installation',
|
|
227
|
+
'health.driftCheckBundlesHint': 'Reads every install location; usually takes seconds',
|
|
228
|
+
'health.driftNotes': 'Notes',
|
|
229
|
+
'health.driftKindLabel': 'Kind',
|
|
230
|
+
'health.driftKindUnknown': 'Unknown drift kind',
|
|
231
|
+
'health.driftKind.startup-failed': 'Startup failed',
|
|
232
|
+
'health.driftKind.enabled-not-running': 'Enabled but not running',
|
|
233
|
+
'health.driftKind.disabled-but-running': 'Disabled but still running',
|
|
234
|
+
'health.driftKind.addressable-not-in-profile': 'Addressable outside the profile',
|
|
235
|
+
'health.driftKind.declared-not-installed': 'Declared but not installed',
|
|
236
|
+
'health.driftAction.startup-failed': 'Fix that plugin configuration or dependency, then reload it from the native plugin page',
|
|
237
|
+
'health.driftAction.enabled-not-running': 'Check whether the module failed to load (Diagnostics) and reload the profile',
|
|
238
|
+
'health.driftAction.disabled-but-running': 'Reloading the profile is what actually unloads this row',
|
|
239
|
+
'health.driftAction.addressable-not-in-profile': 'Check which patch layer provides this row (bundle, built-in, include)',
|
|
240
|
+
'health.driftAction.declared-not-installed': 'Reinstall that bundle or remove the row from the profile',
|
|
241
|
+
'health.refresh.drift': 'Refresh drift comparison',
|
|
186
242
|
'health.refresh.compat': 'Refresh compatibility verdict',
|
|
187
243
|
'health.refresh.host': 'Refresh host channel',
|
|
188
244
|
|
package/src/client/i18n/tools.js
CHANGED
|
@@ -47,6 +47,7 @@ ACC.addI18n({
|
|
|
47
47
|
'tools.scanned': '已扫描会话',
|
|
48
48
|
'tools.available': '可用',
|
|
49
49
|
'tools.historyTruncated': '统计已截断',
|
|
50
|
+
'tools.historyLoading': '历史调用统计加载中:上面已是注册表实时结果,本块稍后填充(扫描会话需要数秒)',
|
|
50
51
|
'tools.historyEmpty': '扫描窗口内没有任何工具调用记录',
|
|
51
52
|
'tools.truncatedList': '清单已截断',
|
|
52
53
|
'tools.calls': '调用次数',
|
|
@@ -209,6 +210,7 @@ ACC.addI18n({
|
|
|
209
210
|
'tools.scanned': 'sessions scanned',
|
|
210
211
|
'tools.available': 'Available',
|
|
211
212
|
'tools.historyTruncated': 'statistics truncated',
|
|
213
|
+
'tools.historyLoading': 'Loading call history: the registry above is live; this block fills in after scanning sessions',
|
|
212
214
|
'tools.historyEmpty': 'No tool call events in the scanned window',
|
|
213
215
|
'tools.truncatedList': 'inventory truncated',
|
|
214
216
|
'tools.calls': 'Calls',
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
const STACK_STYLE = { display: 'flex', flexDirection: 'column', gap: '8px' }
|
|
23
23
|
const COLUMN_STYLE = { display: 'flex', flexDirection: 'column', gap: '2px' }
|
|
24
24
|
const SMALL_STYLE = { fontSize: '11px' }
|
|
25
|
+
const FLEX_WRAP_STYLE = { display: 'flex', flexWrap: 'wrap', gap: '8px' }
|
|
25
26
|
const BREAK_STYLE = { wordBreak: 'break-word' }
|
|
26
27
|
const EMPTY_VALUE = '—'
|
|
27
28
|
|
|
@@ -30,6 +31,9 @@
|
|
|
30
31
|
/** Anomaly kind → shared tone; `unaddressable` rows are usable, only uneditable. */
|
|
31
32
|
const ANOMALY_TONE = { 'duplicate-module': 'warn', unaddressable: 'warn' }
|
|
32
33
|
/** Summary section id → navigation copy. */
|
|
34
|
+
|
|
35
|
+
/** Drift kinds carry their own tone: a startup failure is red, the rest amber. */
|
|
36
|
+
const DRIFT_TONE = { 'startup-failed': 'danger', 'enabled-not-running': 'warn', 'disabled-but-running': 'warn', 'addressable-not-in-profile': 'warn', 'declared-not-installed': 'warn' }
|
|
33
37
|
const BLOCK_KEYS = {
|
|
34
38
|
plugins: 'health.block.plugins',
|
|
35
39
|
settings: 'health.block.settings',
|
|
@@ -95,6 +99,26 @@
|
|
|
95
99
|
return t('health.anomalyActionGeneric')
|
|
96
100
|
}
|
|
97
101
|
|
|
102
|
+
/** @param {string} kind @param {Function} t @returns {string} */
|
|
103
|
+
function driftKindLabel(kind, t) {
|
|
104
|
+
if (kind === 'startup-failed') return t('health.driftKind.startup-failed')
|
|
105
|
+
if (kind === 'enabled-not-running') return t('health.driftKind.enabled-not-running')
|
|
106
|
+
if (kind === 'disabled-but-running') return t('health.driftKind.disabled-but-running')
|
|
107
|
+
if (kind === 'addressable-not-in-profile') return t('health.driftKind.addressable-not-in-profile')
|
|
108
|
+
if (kind === 'declared-not-installed') return t('health.driftKind.declared-not-installed')
|
|
109
|
+
return t('health.driftKindUnknown')
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** @param {string} kind @param {Function} t @returns {string} */
|
|
113
|
+
function driftAction(kind, t) {
|
|
114
|
+
if (kind === 'startup-failed') return t('health.driftAction.startup-failed')
|
|
115
|
+
if (kind === 'enabled-not-running') return t('health.driftAction.enabled-not-running')
|
|
116
|
+
if (kind === 'disabled-but-running') return t('health.driftAction.disabled-but-running')
|
|
117
|
+
if (kind === 'addressable-not-in-profile') return t('health.driftAction.addressable-not-in-profile')
|
|
118
|
+
if (kind === 'declared-not-installed') return t('health.driftAction.declared-not-installed')
|
|
119
|
+
return t('health.anomalyActionGeneric')
|
|
120
|
+
}
|
|
121
|
+
|
|
98
122
|
/** @param {string} kind @param {Function} t @returns {string} */
|
|
99
123
|
function conflictKindLabel(kind, t) {
|
|
100
124
|
return kind === 'duplicate-id' ? t('health.conflictKind.duplicate-id') : t('health.conflictKindUnknown')
|
|
@@ -355,6 +379,128 @@
|
|
|
355
379
|
)
|
|
356
380
|
}
|
|
357
381
|
|
|
382
|
+
/** @param {{ t: Function, drift: any }} props */
|
|
383
|
+
function DriftNotice(props) {
|
|
384
|
+
const t = props.t
|
|
385
|
+
const drift = isRecord(props.drift) ? props.drift : {}
|
|
386
|
+
const kind = textOf(drift.kind)
|
|
387
|
+
return h(
|
|
388
|
+
C.Notice,
|
|
389
|
+
{ tone: DRIFT_TONE[kind] || 'warn' },
|
|
390
|
+
h(
|
|
391
|
+
'div',
|
|
392
|
+
{ style: { ...COLUMN_STYLE, gap: '3px' } },
|
|
393
|
+
h('span', null, h('strong', null, `${t('health.driftKindLabel')}: ${driftKindLabel(kind, t)}${kind.length > 0 ? ` · ${kind}` : ''}`)),
|
|
394
|
+
textOf(drift.detail).length > 0 ? h('div', { style: BREAK_STYLE }, textOf(drift.detail)) : null,
|
|
395
|
+
h('span', { className: 'acc-muted', style: SMALL_STYLE }, `${t('health.anomalySuggestion')}: ${driftAction(kind, t)}`),
|
|
396
|
+
),
|
|
397
|
+
)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** @param {{ t: Function, data: any, onDeep?: Function, loading?: boolean }} props */
|
|
401
|
+
function DriftBody(props) {
|
|
402
|
+
const t = props.t
|
|
403
|
+
const data = isRecord(props.data) ? props.data : {}
|
|
404
|
+
const drifts = Array.isArray(data.drifts) ? data.drifts : []
|
|
405
|
+
const notes = Array.isArray(data.notes) ? data.notes : []
|
|
406
|
+
const rows = typeof data.rows === 'number' ? data.rows : (Array.isArray(data.rows) ? data.rows.length : null)
|
|
407
|
+
const mounted = typeof data.mountedRows === 'number' ? data.mountedRows : null
|
|
408
|
+
const inProfile = typeof data.inProfileRows === 'number' ? data.inProfileRows : null
|
|
409
|
+
const self = isRecord(data.self) ? data.self : null
|
|
410
|
+
const source = textOf(data.source)
|
|
411
|
+
return h(
|
|
412
|
+
'div',
|
|
413
|
+
{ style: STACK_STYLE },
|
|
414
|
+
h(
|
|
415
|
+
'div',
|
|
416
|
+
{ className: 'acc-row', style: FLEX_WRAP_STYLE },
|
|
417
|
+
h(StatusTile, { label: t('health.driftTileRows'), value: countText(rows) }),
|
|
418
|
+
h(StatusTile, { label: t('health.driftTileMounted'), value: countText(mounted) }),
|
|
419
|
+
h(StatusTile, { label: t('health.driftTileInProfile'), value: countText(inProfile) }),
|
|
420
|
+
h(StatusTile, {
|
|
421
|
+
label: t('health.driftTileCount'),
|
|
422
|
+
value: countText(drifts.length),
|
|
423
|
+
hint: drifts.length === 0 ? h(C.Badge, { tone: 'success' }, t('health.driftClean')) : h(C.Badge, { tone: 'warn' }, t('health.driftFound')),
|
|
424
|
+
}),
|
|
425
|
+
),
|
|
426
|
+
self === null
|
|
427
|
+
? null
|
|
428
|
+
: h(
|
|
429
|
+
'div',
|
|
430
|
+
{ className: 'acc-muted', style: SMALL_STYLE },
|
|
431
|
+
`${t('health.driftSelf')}: ${textOf(self.entryId) || EMPTY_VALUE} · ${t('health.driftSelfEnabled')} ${self.enabled === true ? t('health.yes') : self.enabled === false ? t('health.no') : EMPTY_VALUE} · ${textOf(self.fiberPhase) || EMPTY_VALUE}`,
|
|
432
|
+
),
|
|
433
|
+
h(
|
|
434
|
+
'div',
|
|
435
|
+
{ className: 'acc-row' },
|
|
436
|
+
h('span', { className: 'acc-muted', style: SMALL_STYLE }, `${t('health.source')}:`),
|
|
437
|
+
h(C.Mono, { text: source.length > 0 ? source : EMPTY_VALUE }),
|
|
438
|
+
),
|
|
439
|
+
drifts.length === 0
|
|
440
|
+
? h(C.Notice, { tone: 'success' }, t('health.driftEmpty'))
|
|
441
|
+
: h(
|
|
442
|
+
'div',
|
|
443
|
+
{ style: STACK_STYLE },
|
|
444
|
+
drifts.map((drift, index) => h(DriftNotice, { key: `drift-${index}`, t, drift })),
|
|
445
|
+
),
|
|
446
|
+
props.onDeep === undefined || data.bundlesChecked === true
|
|
447
|
+
? null
|
|
448
|
+
: h(
|
|
449
|
+
'div',
|
|
450
|
+
{ className: 'acc-row', style: { justifyContent: 'flex-start' } },
|
|
451
|
+
h(
|
|
452
|
+
C.Btn,
|
|
453
|
+
{ tone: 'ghost', onClick: props.onDeep, disabled: props.loading === true, title: t('health.driftCheckBundlesHint') },
|
|
454
|
+
props.loading === true ? t('health.refreshing') : t('health.driftCheckBundles'),
|
|
455
|
+
),
|
|
456
|
+
h('span', { className: 'acc-muted', style: SMALL_STYLE }, t('health.driftCheckBundlesHint')),
|
|
457
|
+
),
|
|
458
|
+
notes.length === 0
|
|
459
|
+
? null
|
|
460
|
+
: h(
|
|
461
|
+
'div',
|
|
462
|
+
{ style: STACK_STYLE },
|
|
463
|
+
h('div', { className: 'acc-section-title' }, t('health.driftNotes')),
|
|
464
|
+
notes.map((note, index) =>
|
|
465
|
+
h('div', { key: `note-${index}`, className: 'acc-muted', style: { ...SMALL_STYLE, ...BREAK_STYLE } }, String(note)),
|
|
466
|
+
),
|
|
467
|
+
),
|
|
468
|
+
h(NoteLine, { t, text: data.note }),
|
|
469
|
+
)
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/** @param {{ t: Function, gate: any, onGateRefresh: Function }} props */
|
|
473
|
+
function DriftCard(props) {
|
|
474
|
+
const t = props.t
|
|
475
|
+
const gate = isRecord(props.gate) ? props.gate : {}
|
|
476
|
+
const blocked = gate.available === false
|
|
477
|
+
// Bundle inspection reads every install location and costs seconds, so it
|
|
478
|
+
// is a deliberate extra step, not part of the first read.
|
|
479
|
+
const [deep, setDeep] = ACC.useState(false)
|
|
480
|
+
const state = ACC.useAsync(
|
|
481
|
+
blocked
|
|
482
|
+
? gatedLoader(gate)
|
|
483
|
+
: (context) => ACC.api('health.drift', deep ? { includeBundles: true } : {}, context),
|
|
484
|
+
[deep],
|
|
485
|
+
)
|
|
486
|
+
return h(
|
|
487
|
+
BlockCard,
|
|
488
|
+
{
|
|
489
|
+
t,
|
|
490
|
+
title: t('health.driftTitle'),
|
|
491
|
+
subtitle: t('health.driftSubtitle'),
|
|
492
|
+
loading: state.status === 'loading',
|
|
493
|
+
onRefresh: blocked ? props.onGateRefresh : state.reload,
|
|
494
|
+
refreshLabel: t('health.refresh.drift'),
|
|
495
|
+
},
|
|
496
|
+
h(BlockContent, {
|
|
497
|
+
t,
|
|
498
|
+
state,
|
|
499
|
+
render: (data) => h(DriftBody, { t, data, onDeep: () => setDeep(true), loading: state.status === 'loading' }),
|
|
500
|
+
}),
|
|
501
|
+
)
|
|
502
|
+
}
|
|
503
|
+
|
|
358
504
|
/** @param {{ t: Function, anomaly: any }} props */
|
|
359
505
|
function AnomalyNotice(props) {
|
|
360
506
|
const t = props.t
|
|
@@ -816,6 +962,7 @@
|
|
|
816
962
|
h(PluginsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
817
963
|
h(SettingsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
818
964
|
h(SectionsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
965
|
+
h(DriftCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
819
966
|
h(CompatCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
820
967
|
)
|
|
821
968
|
}
|