* feat(webui): inspect file context in a live graph sidebar * refactor(webui): place preview controls in the shared sidebar header * fix(webui): synchronize npm lockfile for graph dependencies * fix(webui): preserve compacted context and refine graph inspection * fix(context): harden provenance, request usage, and drawer lifecycle * fix(webui): align source skeleton and browser fixtures * perf(context): reuse source analysis and capture request graphs once * perf(webui): compact graph history and render graph motion on canvas * fix(webui): remove redundant context sidebar header * style(webui): clarify context replay icon * perf(webui): pace context replay on an adaptive timeline * feat(webui): briefly reveal labels for new context nodes * fix(webui): reveal new labels only for loaded context files * fix(webui): restart graph animation clock after idle * fix(webui): reveal labels when replay reverses node exit * refactor(context): project file-use facts without retention tracking * refactor(context): observe file reads outside agent execution * fix(webui): animate context sidebar closing * refactor(context): remove unused graph and usage panel code * refactor(context): isolate prompt observation from execution metadata * fix(webui): clarify cache rate and show context token usage * fix(webui): abbreviate context token counts in thousands * fix(webui): omit token unit from context usage details * fix(webui): restore large source preview highlighting and panel elevation * fix(webui): distinguish modifier scrolling from keyboard focus * fix(webui): align preview tab and panel corner radii * fix(webui): attach file tabs to the header divider * fix(webui): use one action to toggle file preview mode * fix(webui): use hover hint for context replay * fix(webui): share composer layout between graph and file sidebars * fix(webui): align sidebar bottom with composer surface * fix(webui): restore mobile graph drawing and touch file details * test(webui): align legacy cache assertions with current label * perf(context): retain source analysis and bound graph animation work * style(webui): add light elevation to user messages * test(webui): await lazy graph scene before replay assertions * fix(webui): align preview skeleton and browser contracts
92 lines
3.8 KiB
Python
92 lines
3.8 KiB
Python
"""The contract between a shipped WebUI and an independently updated gateway.
|
|
|
|
Package versions are display metadata, not compatibility decisions. Adding an
|
|
optional capability must not raise the protocol floor for unrelated features.
|
|
See .agent/review-guide.md before changing this contract.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Literal, TypedDict, cast
|
|
|
|
from nanobot import __version__
|
|
|
|
WEBUI_PROTOCOL = 1
|
|
CORE_CAPABILITY = "webui.core.v1"
|
|
SUBAGENT_CAPABILITY = "webui.subagents.v1"
|
|
SUBAGENT_EVENTS_CAPABILITY = "webui.subagents.events.v1"
|
|
SUBAGENT_HISTORY_CAPABILITY = "webui.subagents.history.v1"
|
|
AUTOMATION_CHAT_CAPABILITY = "webui.automation-chat.v1"
|
|
BINARY_ATTACHMENTS_CAPABILITY = "webui.attachments.binary.v1"
|
|
UPDATE_PLAN_CAPABILITY = "webui.update-plans.v1"
|
|
UPDATE_JOB_CAPABILITY = "webui.update-jobs.read.v1"
|
|
UPDATE_PREPARATION_CAPABILITY = "webui.update-jobs.prepare.v1"
|
|
UPDATE_EXECUTION_CAPABILITY = "webui.update-jobs.execute.v1"
|
|
UPDATE_RETRY_CAPABILITY = "webui.update-jobs.retry-handoff.v1"
|
|
UPDATE_SETTLE_HANDOFF_CAPABILITY = "webui.update-jobs.settle-handoff.v1"
|
|
UPDATE_FLOW_CAPABILITY = "webui.update-flow.v1"
|
|
UPDATE_CHANNEL_CAPABILITY = "webui.update-channels.v1"
|
|
CONTEXT_GRAPH_REFERENCES_CAPABILITY = "webui.context-graph.references.v1"
|
|
PROMPT_NAVIGATION_CAPABILITY = "webui.prompt-navigation.v1"
|
|
|
|
|
|
class Compatibility(TypedDict):
|
|
status: Literal["compatible", "unknown", "update_host", "update_client"]
|
|
client_version: str
|
|
host_version: str
|
|
|
|
|
|
def webui_contract() -> dict[str, object]:
|
|
return {
|
|
"version": __version__,
|
|
"min_protocol": WEBUI_PROTOCOL,
|
|
"max_protocol": WEBUI_PROTOCOL,
|
|
"capabilities": [
|
|
CORE_CAPABILITY, SUBAGENT_CAPABILITY, SUBAGENT_EVENTS_CAPABILITY,
|
|
SUBAGENT_HISTORY_CAPABILITY, AUTOMATION_CHAT_CAPABILITY,
|
|
BINARY_ATTACHMENTS_CAPABILITY, UPDATE_PLAN_CAPABILITY,
|
|
UPDATE_JOB_CAPABILITY, UPDATE_PREPARATION_CAPABILITY, UPDATE_EXECUTION_CAPABILITY,
|
|
UPDATE_RETRY_CAPABILITY, UPDATE_SETTLE_HANDOFF_CAPABILITY, UPDATE_FLOW_CAPABILITY, UPDATE_CHANNEL_CAPABILITY,
|
|
PROMPT_NAVIGATION_CAPABILITY, CONTEXT_GRAPH_REFERENCES_CAPABILITY,
|
|
],
|
|
}
|
|
|
|
|
|
def gateway_identity(gateway_id: str) -> dict[str, object]:
|
|
# protocolVersion belongs to the pre-existing terminal transport contract.
|
|
# Do not overload it with the version of the independently shipped WebUI.
|
|
return {"protocolVersion": 1, "gatewayId": gateway_id, "webui": webui_contract()}
|
|
|
|
|
|
def assess_webui_contract(value: object) -> Compatibility:
|
|
result: Compatibility = {
|
|
"status": "unknown", "client_version": __version__, "host_version": "",
|
|
}
|
|
if not isinstance(value, dict):
|
|
return result
|
|
data = cast(dict[object, object], value)
|
|
version = data.get("version")
|
|
if isinstance(version, str) and len(version) <= 80 and version.isprintable():
|
|
result["host_version"] = version
|
|
minimum, maximum = data.get("min_protocol"), data.get("max_protocol")
|
|
capabilities = data.get("capabilities")
|
|
if (type(minimum) is not int or type(maximum) is not int
|
|
or not 1 <= minimum <= maximum
|
|
or not isinstance(capabilities, list)
|
|
or not all(isinstance(item, str) for item in cast(list[object], capabilities))):
|
|
return result
|
|
if minimum > WEBUI_PROTOCOL:
|
|
result["status"] = "update_client"
|
|
elif maximum < WEBUI_PROTOCOL or CORE_CAPABILITY not in capabilities:
|
|
result["status"] = "update_host"
|
|
else:
|
|
result["status"] = "compatible"
|
|
return result
|
|
|
|
|
|
def compatibility_error(report: Compatibility) -> str:
|
|
return {
|
|
"compatible": "", "unknown": "webui_compatibility_unknown",
|
|
"update_host": "host_update_required", "update_client": "client_update_required",
|
|
}[report["status"]]
|