feat(hub): grant split menu, radio redesign and answerable decision rows
The Grant bar becomes one split control: Select, or Grant N with a menu for Deny, Grant all green, the picked list, Clear and Direct mode; picked items turn pale green. The radio drops its filter flyout and gains three-state bells per row, a test per row including Speak, Auto or Morse on a second click, mute on the sender avatar and the agent profile, Cancel MAYDAY beside Send only while one is active, a Send menu with a test message and hold-to-record push-to-talk. Decision rows read as questions with their options; the signed answer is Decision <id> plus Answer: <answer>, and the card names its recipient. Security: the passkey-signed answer carries no agent-written text, the inbox lists answerable rows only when their id fullmatches the TASK rule of the installed rasci.py (skill_scripts.task_pattern), and rasci.py, operator.py and hotfix.py check task slugs with fullmatch, so a trailing newline no longer passes. Accepted MEDUSA findings after kvb-think-criticize: page-inbox.js:116 EXA006 (by design after the fix), page-inbox.js:125 EXA010, operator.py:173, 618 and 633 RP001, FT-TRIGGER-005 and RLHF-POISON-002, operator.py:639 MEX-SCAN-346, operator.py:968 MM-SCAN-058, operator.py:974 ACP-SCAN-028 (false positives). 🎯 Fix: 85 % 💥 Break: 10 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 77 🚦 Gate: ⛔ fix 85 % < 90, break 10 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ff9bbc19c2
commit
d695bb2b58
42 files changed
+1158
-340
No files matched your search
@@ -7,6 +7,8 @@ from .diffs import sealed_file, store_diff, store_sealed, valid_diff, valid_seal
|
||||
from .errors import Conflict, Missing, ToolError
|
||||
from .fields import (
|
||||
COMMAND_LIMIT,
|
||||
DESCRIPTION_LIMIT,
|
||||
OPTION_LIMIT,
|
||||
PATH_LIMIT,
|
||||
WAIT_CAP,
|
||||
bounded,
|
||||
@@ -21,8 +23,7 @@ from .fields import (
|
||||
from .signed import ask_signed
|
||||
|
||||
ASK_LIFETIME = 3600
|
||||
DESCRIPTION_LIMIT = 1000
|
||||
OPTION_LIMIT = 12
|
||||
PREVIEW_LIMIT = 4000
|
||||
ASK_TEXTS = {"command": COMMAND_LIMIT, "cwd": PATH_LIMIT, "session": 200, "agent": 200}
|
||||
ANSWERS = {"allow": "allowed", "deny": "denied"}
|
||||
|
||||
@@ -52,13 +53,22 @@ def decision_row(decision: dict) -> dict:
|
||||
|
||||
|
||||
def option_of(option: object) -> dict:
|
||||
"""Args:
|
||||
option: {"label", "description"} and an optional "preview", a
|
||||
multi-line mockup, snippet or table shown beside the options.
|
||||
|
||||
Returns:
|
||||
The option with its texts stripped; "preview" only when it was given
|
||||
and is not empty.
|
||||
"""
|
||||
if not isinstance(option, dict):
|
||||
raise ToolError("every option must be an object with label and description")
|
||||
expect(option, ("label", "description"))
|
||||
expect(option, ("label", "description", *(("preview",) if "preview" in option else ())))
|
||||
label = field(option, "label").strip()
|
||||
description = bounded(option, "description", DESCRIPTION_LIMIT).strip()
|
||||
visible({"description": description})
|
||||
return {"label": label, "description": description}
|
||||
preview = bounded(option, "preview", PREVIEW_LIMIT).rstrip() if "preview" in option else ""
|
||||
visible({"description": description, "preview": preview})
|
||||
return {"label": label, "description": description, **({"preview": preview} if preview.strip() else {})}
|
||||
|
||||
|
||||
class Asking:
|
||||
|
||||
@@ -12,6 +12,8 @@ TEXT_LIMIT = 20_000
|
||||
COMMAND_LIMIT = 4000
|
||||
PATH_LIMIT = limits.PATH_LIMIT
|
||||
NAME_LIMIT = 120
|
||||
DESCRIPTION_LIMIT = 1000
|
||||
OPTION_LIMIT = 12
|
||||
COUNT = re.compile(r"[0-9]{1,12}")
|
||||
PATH = re.compile(rf"/[^\x00-\x1f\x7f]{{0,{PATH_LIMIT - 1}}}")
|
||||
LINE = r"(?=[^\x00-\x1f\x7f]*\S)[^\x00-\x1f\x7f]{{1,{0}}}"
|
||||
|
||||
@@ -12,6 +12,7 @@ from .names import Directory
|
||||
from .records import digest, iso_epoch
|
||||
from .register import adder, operator_rows, runnable
|
||||
from .signed import signing
|
||||
from .skill_scripts import task_pattern
|
||||
|
||||
SNOOZE_LIMIT = 8 * 86400
|
||||
|
||||
@@ -19,7 +20,7 @@ SNOOZE_LIMIT = 8 * 86400
|
||||
class Inbox:
|
||||
def inbox(self, now: float, tasks: dict[str, dict], directory: Directory) -> list[dict]:
|
||||
claims = read_claims(self.council)
|
||||
base = {"agent": "", "to": "", "detail": "", "green": False, "gate": "", "score": "", "warnings": [], "options": [], "recommended": "", "command": "", "directory": "", "sha256": "", "runnable": False, "deniable": False, "job": None, "rule": None, "dry_run": None, "diff": None, "settled": False}
|
||||
base = {"agent": "", "to": "", "detail": "", "green": False, "gate": "", "score": "", "warnings": [], "options": [], "recommended": "", "check": "", "command": "", "directory": "", "sha256": "", "runnable": False, "deniable": False, "job": None, "rule": None, "dry_run": None, "diff": None, "settled": False}
|
||||
items = []
|
||||
for review in self.reviews.pending():
|
||||
created = iso_epoch(review["created"]) or now
|
||||
@@ -37,10 +38,11 @@ class Inbox:
|
||||
items.append({**base, "kind": "decision", "id": decision["id"], "ts": decision["created_ts"], **fields})
|
||||
held = self.open_jobs()
|
||||
consoles = self.consoles()
|
||||
rows = operator_rows(tasks)
|
||||
pattern = task_pattern(self.scripts.skills)
|
||||
rows = [row for row in operator_rows(tasks) if pattern is not None and pattern.fullmatch(row["task"])]
|
||||
for row in rows:
|
||||
busy = row["task"] in held
|
||||
fields = {"title": row["command"], "detail": row["why"], "agent": adder(tasks[row["task"]]), "to": requester_of(claims, adder(tasks[row["task"]]))[0], "command": row["command"], "directory": row["directory"], "sha256": digest(row["command"])}
|
||||
fields = {"title": row["command"], "detail": row["why"], "agent": adder(tasks[row["task"]]), "to": requester_of(claims, adder(tasks[row["task"]]))[0], "command": row["command"], "directory": row["directory"], "sha256": digest(row["command"]), "check": row["check"], "options": row["options"], "recommended": row["recommended"]}
|
||||
state = {"runnable": runnable(row) and not busy, "deniable": not busy, "job": console_of(consoles.get(row["task"]))}
|
||||
items.append({**base, "kind": "operator", "id": row["task"], "ts": self.watch.first(row["task"], now), **fields, **state})
|
||||
listed = {row["task"] for row in rows}
|
||||
|
||||
@@ -4,10 +4,9 @@ import json
|
||||
from http import HTTPStatus
|
||||
|
||||
from . import NAME
|
||||
from .asking import OPTION_LIMIT
|
||||
from .choosing import CHOICE_REQUEST
|
||||
from .errors import RpcError, ToolError
|
||||
from .fields import WAIT_CAP
|
||||
from .fields import OPTION_LIMIT, WAIT_CAP
|
||||
from .requesting import AGENT_CAP
|
||||
from .reviewing import GATES
|
||||
from .rules import RULE_KINDS
|
||||
@@ -34,7 +33,11 @@ class Mcp:
|
||||
wait = {"type": "number", "minimum": 0, "description": f"Seconds to wait, capped at {WAIT_CAP}."}
|
||||
option = {
|
||||
"type": "object",
|
||||
"properties": {"label": text_property("Button text, one line."), "description": text_property("What choosing it means; may be empty.")},
|
||||
"properties": {
|
||||
"label": text_property("Button text, one line."),
|
||||
"description": text_property("What choosing it means; may be empty."),
|
||||
"preview": text_property("Optional multi-line mockup, snippet, diff or table shown in monospace beside the options while this option is focused; only for options that need a visual comparison."),
|
||||
},
|
||||
"required": ["label", "description"],
|
||||
"additionalProperties": False,
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from .council import HUMAN, agent, ordered
|
||||
from .fields import ORDER_NAME
|
||||
from .fields import DESCRIPTION_LIMIT, OPTION_LIMIT, ORDER_NAME
|
||||
from .records import read_json, shown
|
||||
|
||||
LABEL_LIMIT = 80
|
||||
|
||||
REGISTER = "rasci.json"
|
||||
AGENT_ORDER = "agent-order.json"
|
||||
OPERATOR = "operator/"
|
||||
@@ -53,19 +55,46 @@ def is_open(task: str, row: dict, operator: bool) -> bool:
|
||||
return task.startswith(OPERATOR) == operator and status_of(row) not in ENDED
|
||||
|
||||
|
||||
def row_options(row: dict) -> list[dict]:
|
||||
"""Args:
|
||||
row: an operator row of the register, which agents write.
|
||||
|
||||
Returns:
|
||||
A decision row's options as {"label", "description"}, at most
|
||||
OPTION_LIMIT, each label one non-empty line of at most LABEL_LIMIT
|
||||
characters and unique; [] for any other row or malformed options.
|
||||
"""
|
||||
raw = row.get("options")
|
||||
if row.get("check") != "decision" or not isinstance(raw, list):
|
||||
return []
|
||||
options = []
|
||||
for option in raw[:OPTION_LIMIT]:
|
||||
label = option.get("label") if isinstance(option, dict) else None
|
||||
description = option.get("description", "") if isinstance(option, dict) else None
|
||||
if isinstance(label, str) and isinstance(description, str) and label.strip() and label.isprintable() and len(label) <= LABEL_LIMIT:
|
||||
options.append({"label": label.strip(), "description": " ".join(description.split())[:DESCRIPTION_LIMIT]})
|
||||
labels = [option["label"] for option in options]
|
||||
return options if len(set(labels)) == len(labels) else []
|
||||
|
||||
|
||||
def operator_rows(tasks: dict[str, dict]) -> list[dict]:
|
||||
return [
|
||||
{
|
||||
rows = []
|
||||
for task, row in sorted(tasks.items()):
|
||||
if not is_open(task, row, True):
|
||||
continue
|
||||
options = row_options(row)
|
||||
recommended = row.get("recommended")
|
||||
rows.append({
|
||||
"task": task,
|
||||
"command": shown(row.get("title")),
|
||||
"directory": shown(row.get("workdir")),
|
||||
"why": shown(row.get("description")),
|
||||
"check": shown(row.get("check")),
|
||||
"status": status_of(row),
|
||||
}
|
||||
for task, row in sorted(tasks.items())
|
||||
if is_open(task, row, True)
|
||||
]
|
||||
"options": options,
|
||||
"recommended": recommended if recommended in [option["label"] for option in options] else "",
|
||||
})
|
||||
return rows
|
||||
|
||||
|
||||
def runnable(row: dict) -> bool:
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import functools
|
||||
import importlib.util
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
@@ -50,6 +51,19 @@ def script_module(script: Path) -> ModuleType | None:
|
||||
return loaded(script, changed)
|
||||
|
||||
|
||||
def task_pattern(skills: Path) -> re.Pattern[str] | None:
|
||||
"""Args:
|
||||
skills: the installed skills directory, the hub's --skills mount.
|
||||
|
||||
Returns:
|
||||
TASK of the installed kvb-org-rasci rasci.py, the one rule for
|
||||
register task ids; None when the script is missing, does not load or
|
||||
holds no compiled pattern.
|
||||
"""
|
||||
found = getattr(script_module(skills / RASCI), "TASK", None)
|
||||
return found if isinstance(found, re.Pattern) else None
|
||||
|
||||
|
||||
@functools.cache
|
||||
def loaded(script: Path, changed: int) -> ModuleType | None:
|
||||
spec = importlib.util.spec_from_file_location(f"kvb_orchestrator_{script.stem}_{changed}", script)
|
||||
|
||||
Reference in new issue
Block a user