Merge feature/workbench-w4-resources into unify/skills-20261112
Conflicts combined W1 (Inbox leaves the Stream for Tasks, Waits on Operator) with W4 (Resources tab): five tabs with Resources, Stream keeps only the Firewall, the inbox hash keeps its redirect; index.html.j2 includes both diffs.js and resources.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
515fe61009
21 files changed
+1937
-18
No files matched your search
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
import secrets
|
||||
import time
|
||||
from collections.abc import Callable
|
||||
from http import HTTPStatus
|
||||
from urllib.parse import urlsplit
|
||||
@@ -9,6 +10,7 @@ from urllib.parse import urlsplit
|
||||
from .diffs import DIFF_BODY_LIMIT
|
||||
from .engines import STT_LIMIT
|
||||
from .exchange import PLAIN_CSP, Exchange
|
||||
from .resources import RESOURCES, sampled
|
||||
|
||||
BODY_LIMIT = 1 << 20
|
||||
UPLOAD_LIMIT = 50 << 20
|
||||
@@ -114,6 +116,8 @@ class Handler(Exchange):
|
||||
self.answer(lambda: hub.events(self.query()), HTTPStatus.OK)
|
||||
elif path == "/api/tree":
|
||||
self.answer(hub.repositories, HTTPStatus.OK)
|
||||
elif path == "/api/resources":
|
||||
self.answer(lambda: sampled(hub.kept / RESOURCES, hub.span(self.query(), time.time())), HTTPStatus.OK)
|
||||
elif path == "/api/subagents":
|
||||
self.answer(lambda: hub.subagents(self.query()), HTTPStatus.OK)
|
||||
elif path == "/api/runner/jobs":
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from .records import epoch, parse_line, read_regular
|
||||
|
||||
RESOURCES = "resources"
|
||||
SAMPLES = "samples.jsonl"
|
||||
TOKENS = "tokens.jsonl"
|
||||
HOUR = 3600
|
||||
FILE_LIMIT = 64 << 20
|
||||
|
||||
|
||||
def rows_between(path: Path, begin: float, end: float, width: float) -> list[dict]:
|
||||
try:
|
||||
lines = read_regular(path, FILE_LIMIT).splitlines()
|
||||
except (OSError, ValueError):
|
||||
return []
|
||||
found = []
|
||||
for row in map(parse_line, lines):
|
||||
t = None if row is None else epoch(row.get("t"))
|
||||
if t is not None and begin <= t + width and t <= end:
|
||||
found.append(row)
|
||||
return found
|
||||
|
||||
|
||||
def sampled(folder: Path, span: tuple[float, float]) -> dict:
|
||||
"""Args:
|
||||
folder: the host sampler's directory, mounted read-only.
|
||||
span: (begin, end) of the page's time window in epoch seconds.
|
||||
|
||||
Returns:
|
||||
{"since", "until", "samples", "tokens"}: the rows of samples.jsonl
|
||||
within the span and those of tokens.jsonl whose hour overlaps it, as
|
||||
the host unit wrote them; the hub reads nothing of the host itself.
|
||||
"""
|
||||
begin, end = span
|
||||
return {"since": begin, "until": end, "samples": rows_between(folder / SAMPLES, begin, end, 0), "tokens": rows_between(folder / TOKENS, begin, end, HOUR)}
|
||||
Reference in new issue
Block a user