refactor: drop unreferenced dead code

Every removed symbol has no reference anywhere in the tree (Python AST and
TypeScript identifier scans over all tracked files, including tests, docs,
WebUI/TUI clients, and JSON/YAML data):

- nanobot/webui/settings_api.py: four aliases with no importer and no
  in-module use; the helpers that tests still import stay.
- nanobot/sdk/types.py: snapshot_from_payload had no caller since session
  restore moved to snapshot_from_session.
- nanobot/session/jsonl_migration.py: INTRODUCED_VERSION and
  LAST_SUPPORTED_RELEASE_LINE duplicated the module docstring.
- nanobot/providers/transcription.py: StepFunTranscriptionProvider._DEFAULT_URL
  was superseded by _resolve_stepfun_asr_url.
- nanobot/channels/whatsapp_agent/protocol.py: CODE_MISSING_AUTH is neither
  exported nor compared; validation still checks the wire value 190.
- webui/src/lib/canonical-run-snapshot.ts: canonicalRunSnapshot had no caller.
- webui/src/components/icons/product-icons.tsx: SendIcon and RunningTaskIcon
  are not rendered anywhere.
- webui/src/components/thread/AgentActivityCluster.tsx: drop an unused
  isAgentActivityMember re-export and its import.
- webui: drop the unused micromark-util-decode-string dependency.

Framework-dispatched code (Typer commands, pydantic validators, pytest hooks
and fixtures, channel runtime classes, ast visitor hooks) was excluded from
the scans, so the change removes only code nothing references.
This commit is contained in:
chengyongru authored and chengyongru committed 2026-11-12 22:54:51 +08:00
1 parent eb8546c321
commit 25ed91ffeb
10 files changed
+1 -56

No files matched your search

@@ -29,7 +29,6 @@ RATE_LIMITS = {
# error.code values that carry a specific recovery contract.
CODE_INVALID_TOKEN = 100
CODE_MISSING_AUTH = 190
CODE_RATE_LIMITED = 130429
CODE_NOT_CREATOR = 131005
CODE_BAD_REQUEST = 131009
-2
View File
@@ -708,8 +708,6 @@ class XiaomiMiMoTranscriptionProvider:
class StepFunTranscriptionProvider:
"""Voice transcription provider using StepFun ASR SSE endpoint."""
_DEFAULT_URL = "https://api.stepfun.com/v1/audio/asr/sse"
def __init__(
self,
api_key: str | None = None,
+1 -23
View File
@@ -2,7 +2,7 @@ from __future__ import annotations
from copy import deepcopy
from dataclasses import dataclass, field
from typing import Any, Literal, Mapping, TypeAlias, cast
from typing import Any, Literal, TypeAlias, cast
from nanobot.providers.base import LLMUsage
from nanobot.runtime_context import public_history_messages
@@ -137,28 +137,6 @@ def snapshot_from_session(
)
def snapshot_from_payload(
payload: Mapping[str, Any],
*,
include_runtime_context: bool = False,
) -> SessionSnapshot:
raw_messages: list[Any] = list(payload.get("messages") or [])
messages: list[dict[str, Any]] = [
deepcopy(dict(cast(Mapping[str, Any], message)))
for message in raw_messages
if isinstance(message, Mapping)
]
if not include_runtime_context:
messages = public_history_messages(messages)
return SessionSnapshot(
key=str(payload.get("key") or ""),
created_at=payload.get("created_at"),
updated_at=payload.get("updated_at"),
metadata=deepcopy(dict(cast(Mapping[str, Any], payload.get("metadata") or {}))),
messages=messages,
)
def result_from_response(response: Any, capture: Any) -> RunResult:
content = (response.content if response else None) or ""
metadata = dict(response.metadata) if response and response.metadata else {}
-2
View File
@@ -26,8 +26,6 @@ from nanobot.session.manager import Session
if TYPE_CHECKING:
from nanobot.session.sqlite_store import SqliteSessionStore
INTRODUCED_VERSION = "0.3.6"
LAST_SUPPORTED_RELEASE_LINE = "0.4.x"
SUNSET_VERSION = "0.5.0"
WORKSPACE_BACKUP_DIR = "jsonl-backup"
_WORKSPACE_SOURCES_KEY = "jsonl_workspace_sources"
-5
View File
@@ -31,14 +31,9 @@ RuntimeSurface = Literal["browser", "native"]
# Preserve established direct imports of focused helpers.
_docs_version = system.docs_version
_parse_bool = contracts.parse_bool
_query_first = contracts.query_first
_query_first_alias = contracts.query_first_alias
_query_has_alias = contracts.query_has_alias
_model_catalog_kind = models.model_catalog_kind
_oauth_provider_status = models.oauth_provider_status
_provider_requires_api_key = models.provider_requires_api_key
_reasoning_effort_values_for = models.reasoning_effort_values_for
_RUNTIME_CAPABILITIES = {
-1
View File
@@ -23,7 +23,6 @@
"i18next": "^26.0.6",
"lucide-react": "^0.469.0",
"micromark-factory-space": "^2.0.1",
"micromark-util-decode-string": "^2.0.1",
"motion": "^14.4.0",
"pele": "1.9.0",
"qrcode": "^1.5.4",
-1
View File
@@ -36,7 +36,6 @@
"i18next": "^26.0.6",
"lucide-react": "^0.469.0",
"micromark-factory-space": "^2.0.1",
"micromark-util-decode-string": "^2.0.1",
"motion": "^14.4.0",
"pele": "1.9.0",
"qrcode": "^1.5.4",
@@ -33,7 +33,6 @@ export const SystemIcon = productIcon("system", <><rect x="3" y="3" width="18" h
export const AdvancedIcon = productIcon("advanced", <><path d="M3 6h5m4 0h9M3 12h11m4 0h3M3 18h2m4 0h12" /><circle cx="10" cy="6" r="2" /><circle cx="16" cy="12" r="2" /><circle cx="7" cy="18" r="2" /></>);
export const AboutIcon = productIcon("about", <><circle cx="12" cy="12" r="9" /><path d="M12 11v6m0-10h.01" /></>);
export const AttachIcon = productIcon("attach", <path d="M8.5 12.5 14 7a2.75 2.75 0 0 1 3.89 3.89l-7.43 7.43a4.25 4.25 0 0 1-6.01-6.01l7.43-7.43a5.75 5.75 0 0 1 8.13 8.13L12.5 20.5" />);
export const SendIcon = productIcon("send", <><path d="m4 5 17 7-17 7 3-7-3-7Z" /><path d="M7 12h14" /></>);
export const VoiceIcon = productIcon("voice", <><rect x="9" y="3" width="6" height="12" rx="3" /><path d="M6 11v1a6 6 0 0 0 12 0v-1M12 18v3m-3 0h6" /></>);
export const StopIcon = productIcon("stop", <rect x="5" y="5" width="14" height="14" rx="2.5" />);
export const RestrictedAccessIcon = productIcon("restricted-access", <><rect x="5" y="10" width="14" height="11" rx="2.5" /><path d="M8 10V7a4 4 0 0 1 8 0v3m-4 5v2" /></>);
@@ -46,7 +45,6 @@ export const DelegationIcon = productIcon("delegation", <><rect x="8" y="3" widt
export const TaskInspectIcon = productIcon("task-inspect", <><rect x="3" y="3" width="13" height="18" rx="2" /><path d="M7 7h5M7 11h3" /><circle cx="16" cy="15" r="4" /><path d="m19 18 3 3" /></>);
export const TaskMessageIcon = productIcon("task-message", <><path d="M12 19H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4v4M7 8h10M7 12h4" /><path d="M14 17h7m-3-3 3 3-3 3" /></>);
export const QueuedTaskIcon = productIcon("task-queued", <><circle cx="12" cy="12" r="8.5" /><path d="M12 7v5l3 2" /></>);
export const RunningTaskIcon = productIcon("task-running", <><path d="M12 3a9 9 0 1 1-9 9" /><path d="M3 7v.01M6 4v.01" /></>);
export const StoppingTaskIcon = productIcon("task-stopping", <><path d="M12 3a9 9 0 1 1-9 9M3 7v.01M6 4v.01" /><rect x="9" y="9" width="6" height="6" rx="1" /></>);
export const CompletedTaskIcon = productIcon("task-completed", <><circle cx="12" cy="12" r="9" /><path d="m7.5 12 3 3 6-6" /></>);
export const CancelledTaskIcon = productIcon("task-cancelled", <><circle cx="12" cy="12" r="9" /><path d="m9 9 6 6m0-6-6 6" /></>);
@@ -44,7 +44,6 @@ import {
import { WebSearchRun } from "@/components/thread/activity/WebSearchRun";
import { webSearchRunsByTraceLine } from "@/components/thread/activity/web-search-model";
import {
isAgentActivityMember,
isReasoningOnlyAssistant,
} from "@/lib/activity-timeline";
import { useFileEditDisplayMode } from "@/hooks/useFileEditDisplayMode";
@@ -68,8 +67,6 @@ import type {
const EMPTY_CLI_APPS: CliAppInfo[] = [];
const EMPTY_MCP_PRESETS: McpPresetInfo[] = [];
export { isAgentActivityMember };
interface ActivityCounts {
reasoningSteps: number;
toolCalls: number;
-16
View File
@@ -8,22 +8,6 @@ export function completedAssistantTurnIds(messages: UIMessage[]): string[] {
))));
}
export function canonicalRunSnapshot(
messages: UIMessage[],
hasPendingToolCalls: boolean,
activeTurnId: string | null,
completionIdsProvided = false,
): CanonicalRunSnapshot {
return {
observedTurnIds: Array.from(new Set(messages.flatMap((message) => (
message.role === "user" && message.turnId ? [message.turnId] : []
)))),
hasPendingToolCalls,
activeTurnId,
completionIdsProvided,
};
}
export function persistedCanonicalRunState(body: WebuiThreadPersistedPayload): {
completedTurnIds: string[];
snapshot: CanonicalRunSnapshot;