mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-10 11:47:43 +02:00
[eric] backend: convert all relative imports to absolute backend.* paths (convention sweep)
This commit is contained in:
@@ -60,7 +60,7 @@ def p_event(kind: str, host: str, sig: str, rev: int = 0, state: str = "", **ext
|
||||
prove the skill layer helps vs. silently thrashes. Lazy + best-effort: this
|
||||
module never hard-depends on metrics, and a metrics failure never propagates."""
|
||||
try:
|
||||
from . import browser_metrics
|
||||
from backend.apps.agents.browser import browser_metrics
|
||||
browser_metrics.record_skill_event(kind, host, sig, rev=rev, state=state, extra=extra or None)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
The model-resolution gate: always go through here, never hardcode a model id.
|
||||
Pricing/tier scoring lives in pricing.py, OpenRouter plumbing in openrouter.py,
|
||||
thinking-level translation in thinking.py; all re-exported below so external
|
||||
thinking-level translation in thinking_params_for.py; all re-exported below so external
|
||||
importers keep their single entry point.
|
||||
"""
|
||||
|
||||
@@ -11,19 +11,19 @@ from __future__ import annotations
|
||||
import logging
|
||||
from typing import Any, TYPE_CHECKING
|
||||
|
||||
from .openrouter import (
|
||||
from backend.apps.agents.providers.openrouter import (
|
||||
OPENROUTER_VALUE_PREFIX,
|
||||
fetch_openrouter_models,
|
||||
get_direct_pricing,
|
||||
get_openrouter_pricing,
|
||||
invalidate_openrouter_cache,
|
||||
)
|
||||
from .pricing import (
|
||||
from backend.apps.agents.providers.pricing import (
|
||||
compute_billing_kind,
|
||||
compute_tiers,
|
||||
heuristic_tiers,
|
||||
)
|
||||
from .thinking_params_for import thinking_params_for
|
||||
from backend.apps.agents.providers.thinking_params_for import thinking_params_for
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from backend.apps.settings.models import AppSettings
|
||||
|
||||
@@ -18,7 +18,7 @@ the re-exports below.
|
||||
|
||||
import httpx # noqa: F401 patch point: tests stub backend.apps.nine_router.httpx.AsyncClient
|
||||
|
||||
from .process import (
|
||||
from backend.apps.nine_router.process import (
|
||||
NINE_ROUTER_API,
|
||||
NINE_ROUTER_NPM_VERSION,
|
||||
NINE_ROUTER_PORT,
|
||||
@@ -33,7 +33,7 @@ from .process import (
|
||||
is_running,
|
||||
stop,
|
||||
)
|
||||
from .sync import (
|
||||
from backend.apps.nine_router.sync import (
|
||||
NINE_ROUTER_CLAUDE_PRO_NAME,
|
||||
NINE_ROUTER_KEYED_NAME,
|
||||
NINE_ROUTER_OPENAI_KEYED_NAME,
|
||||
@@ -43,14 +43,14 @@ from .sync import (
|
||||
sync_openai_api_key,
|
||||
sync_openrouter_api_key,
|
||||
)
|
||||
from .sync_custom import (
|
||||
from backend.apps.nine_router.sync_custom import (
|
||||
NINE_ROUTER_CUSTOM_NAME_SUFFIX,
|
||||
normalize_openai_compat_base_url,
|
||||
sync_custom_providers,
|
||||
sync_openswarm_pro_as_claude,
|
||||
sync_pro_routing,
|
||||
)
|
||||
from .oauth import (
|
||||
from backend.apps.nine_router.oauth import (
|
||||
exchange_oauth,
|
||||
get_models,
|
||||
poll_oauth,
|
||||
|
||||
@@ -10,7 +10,7 @@ import os
|
||||
|
||||
import httpx
|
||||
|
||||
from .process import NINE_ROUTER_API, NINE_ROUTER_PORT, NINE_ROUTER_V1, cli_auth_headers
|
||||
from backend.apps.nine_router.process import NINE_ROUTER_API, NINE_ROUTER_PORT, NINE_ROUTER_V1, cli_auth_headers
|
||||
from backend.apps.oauth_state import pending_oauth, mark_oauth_completed
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -7,7 +7,7 @@ as OpenSwarm-managed apikey connections. Talks to the already-running
|
||||
|
||||
import logging
|
||||
|
||||
from .process import NINE_ROUTER_API, cli_auth_headers
|
||||
from backend.apps.nine_router.process import NINE_ROUTER_API, cli_auth_headers
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -128,7 +128,7 @@ async def sync_openai_api_key(api_key: str | None) -> None:
|
||||
above) so 9Router's translator dispatches to this provider-node
|
||||
instead of the built-in `openai` provider.
|
||||
"""
|
||||
from .sync_custom import sync_openai_compat_node
|
||||
from backend.apps.nine_router.sync_custom import sync_openai_compat_node
|
||||
await sync_openai_compat_node(api_key)
|
||||
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ spawns the subprocess (that's process.py's job).
|
||||
|
||||
import logging
|
||||
|
||||
from .process import NINE_ROUTER_API, cli_auth_headers
|
||||
from .sync import (
|
||||
from backend.apps.nine_router.process import NINE_ROUTER_API, cli_auth_headers
|
||||
from backend.apps.nine_router.sync import (
|
||||
NINE_ROUTER_CLAUDE_PRO_NAME,
|
||||
NINE_ROUTER_OPENAI_KEYED_PREFIX,
|
||||
find_keyed_connection,
|
||||
|
||||
@@ -25,7 +25,7 @@ def p_resolve_bash() -> str:
|
||||
return candidate
|
||||
return "bash"
|
||||
|
||||
from .runtime_proc import (
|
||||
from backend.apps.outputs.runtime_proc import (
|
||||
ERROR_PATTERNS,
|
||||
FRONTEND_BIND_POLL_INTERVAL,
|
||||
FRONTEND_BIND_TIMEOUT_SECONDS,
|
||||
|
||||
@@ -13,8 +13,8 @@ import zipfile
|
||||
from datetime import datetime, timezone
|
||||
from uuid import uuid4
|
||||
|
||||
from .exportable import RemapTable
|
||||
from .models import (
|
||||
from backend.apps.swarm.exportable import RemapTable
|
||||
from backend.apps.swarm.models import (
|
||||
FORMAT_VERSION,
|
||||
BundlePreview,
|
||||
BundleSummary,
|
||||
@@ -26,9 +26,9 @@ from .models import (
|
||||
Requirement,
|
||||
RequirementView,
|
||||
)
|
||||
from .redact import scrub_payload
|
||||
from .registry import IMPORT_ORDER, get_exportable
|
||||
from .ziputil import MANIFEST_NAME, BundleError, has_member, is_zip, pack, read_manifest, unpack, verify_checksum
|
||||
from backend.apps.swarm.redact import scrub_payload
|
||||
from backend.apps.swarm.registry import IMPORT_ORDER, get_exportable
|
||||
from backend.apps.swarm.ziputil import MANIFEST_NAME, BundleError, has_member, is_zip, pack, read_manifest, unpack, verify_checksum
|
||||
|
||||
|
||||
def p_now() -> str:
|
||||
@@ -315,8 +315,8 @@ def p_read_files(sandbox: str, ref: EntityRef) -> dict[str, bytes]:
|
||||
def review_bundle(sandbox: str, manifest: Manifest):
|
||||
"""Safety read of any app code in the staged bundle. Returns None when the
|
||||
bundle contains no apps (nothing to review)."""
|
||||
from .models import ReviewSummary
|
||||
from .scan_app_files import scan_app_files
|
||||
from backend.apps.swarm.models import ReviewSummary
|
||||
from backend.apps.swarm.scan_app_files import scan_app_files
|
||||
|
||||
findings: list[str] = []
|
||||
scanned: list[str] = []
|
||||
|
||||
@@ -12,8 +12,8 @@ from __future__ import annotations
|
||||
from datetime import datetime, timezone
|
||||
from uuid import uuid4
|
||||
|
||||
from ..exportable import DepRef, ExportContext, RemapTable
|
||||
from ..models import EntityType, Requirement, RequirementKind
|
||||
from backend.apps.swarm.exportable import DepRef, ExportContext, RemapTable
|
||||
from backend.apps.swarm.models import EntityType, Requirement, RequirementKind
|
||||
|
||||
P_BUILTIN_MODES = {"agent", "ask", "plan", "view-builder", "skill-builder"}
|
||||
# Transcript fields ride along so the shared agent keeps its history; ids inside
|
||||
|
||||
@@ -15,8 +15,8 @@ from backend.apps.outputs.models import Output
|
||||
from backend.apps.outputs.workspace_io import WALK_SKIP_DIRS, save, load_output
|
||||
from backend.config.paths import OUTPUTS_DIR, OUTPUTS_WORKSPACE_DIR
|
||||
|
||||
from ..exportable import DepRef, ExportContext, RemapTable
|
||||
from ..models import EntityType, Requirement
|
||||
from backend.apps.swarm.exportable import DepRef, ExportContext, RemapTable
|
||||
from backend.apps.swarm.models import EntityType, Requirement
|
||||
|
||||
P_MAX_APP_FILE = 25 * 1024 * 1024 # matches ziputil per-entry cap
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ from __future__ import annotations
|
||||
from datetime import datetime, timezone
|
||||
from uuid import uuid4
|
||||
|
||||
from ..exportable import DepRef, ExportContext, RemapTable
|
||||
from ..models import EntityType, Requirement
|
||||
from backend.apps.swarm.exportable import DepRef, ExportContext, RemapTable
|
||||
from backend.apps.swarm.models import EntityType, Requirement
|
||||
|
||||
|
||||
class DashboardExportable:
|
||||
|
||||
@@ -6,8 +6,8 @@ reuses an existing same-slug mode rather than clobbering it (keeps the session's
|
||||
`mode` pointer valid without rewriting it)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..exportable import DepRef, ExportContext, RemapTable
|
||||
from ..models import EntityType, Requirement
|
||||
from backend.apps.swarm.exportable import DepRef, ExportContext, RemapTable
|
||||
from backend.apps.swarm.models import EntityType, Requirement
|
||||
|
||||
# Machine-relative or install-owned fields that must not ride along.
|
||||
P_DROP = {"is_builtin", "default_folder"}
|
||||
@@ -49,7 +49,7 @@ class ModeExportable:
|
||||
store = p_store()
|
||||
model = p_model()
|
||||
if store is None or model is None:
|
||||
from ..ziputil import BundleError
|
||||
from backend.apps.swarm.ziputil import BundleError
|
||||
raise BundleError("can't import this mode on this build")
|
||||
mid = payload.get("id") or (payload.get("name") or "mode").lower().replace(" ", "-")
|
||||
# Reuse a same-slug mode (incl. built-ins) instead of overwriting it;
|
||||
|
||||
@@ -10,8 +10,8 @@ import os
|
||||
import shutil
|
||||
|
||||
from backend.apps.skills import skills as store
|
||||
from ..exportable import DepRef, ExportContext, RemapTable
|
||||
from ..models import EntityType, Requirement
|
||||
from backend.apps.swarm.exportable import DepRef, ExportContext, RemapTable
|
||||
from backend.apps.swarm.models import EntityType, Requirement
|
||||
|
||||
|
||||
class SkillExportable:
|
||||
|
||||
@@ -10,8 +10,8 @@ sharer's phone numbers (text/call escalation) are stripped as PII, and run
|
||||
history / session + dashboard linkage are dropped."""
|
||||
from __future__ import annotations
|
||||
|
||||
from ..exportable import DepRef, ExportContext, RemapTable
|
||||
from ..models import EntityType, Requirement, RequirementKind
|
||||
from backend.apps.swarm.exportable import DepRef, ExportContext, RemapTable
|
||||
from backend.apps.swarm.models import EntityType, Requirement, RequirementKind
|
||||
|
||||
P_BUILTIN_MODES = {"agent", "ask", "plan", "view-builder", "skill-builder"}
|
||||
|
||||
@@ -95,7 +95,7 @@ class WorkflowExportable:
|
||||
store = p_store()
|
||||
model = p_model()
|
||||
if store is None or model is None:
|
||||
from ..ziputil import BundleError
|
||||
from backend.apps.swarm.ziputil import BundleError
|
||||
raise BundleError("this build doesn't support workflows yet; please update OpenSwarm")
|
||||
clean = sanitize_workflow(payload)
|
||||
clean.pop("id", None) # fresh id via the model's default_factory
|
||||
|
||||
@@ -7,7 +7,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from typing import ClassVar, Protocol, runtime_checkable
|
||||
|
||||
from .models import EntityType, Requirement
|
||||
from backend.apps.swarm.models import EntityType, Requirement
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"""Maps an EntityType to the Exportable that handles it, and the leaves-first
|
||||
order import walks. Adding a shareable type is one entry here plus its module."""
|
||||
from .entities.apps import AppExportable
|
||||
from .entities.dashboards import DashboardExportable
|
||||
from .entities.modes import ModeExportable
|
||||
from .entities.SessionExportable import SessionExportable
|
||||
from .entities.skills import SkillExportable
|
||||
from .entities.workflows import WorkflowExportable
|
||||
from .models import EntityType
|
||||
from backend.apps.swarm.entities.apps import AppExportable
|
||||
from backend.apps.swarm.entities.dashboards import DashboardExportable
|
||||
from backend.apps.swarm.entities.modes import ModeExportable
|
||||
from backend.apps.swarm.entities.SessionExportable import SessionExportable
|
||||
from backend.apps.swarm.entities.skills import SkillExportable
|
||||
from backend.apps.swarm.entities.workflows import WorkflowExportable
|
||||
from backend.apps.swarm.models import EntityType
|
||||
|
||||
REGISTRY: dict[EntityType, type] = {
|
||||
EntityType.skill: SkillExportable,
|
||||
|
||||
@@ -8,7 +8,7 @@ from __future__ import annotations
|
||||
|
||||
from backend.apps.outputs.executor import get_code_warnings
|
||||
|
||||
from .models import ReviewSummary
|
||||
from backend.apps.swarm.models import ReviewSummary
|
||||
|
||||
|
||||
def scan_app_files(files: dict[str, bytes]) -> ReviewSummary:
|
||||
|
||||
@@ -12,8 +12,8 @@ from fastapi import File, HTTPException, Response, UploadFile
|
||||
|
||||
from backend.config.Apps import SubApp
|
||||
|
||||
from . import closure
|
||||
from .models import (
|
||||
from backend.apps.swarm import closure
|
||||
from backend.apps.swarm.models import (
|
||||
ExportPreflightResponse,
|
||||
ExportRequest,
|
||||
ImportCommitRequest,
|
||||
@@ -21,7 +21,7 @@ from .models import (
|
||||
ImportPreflightResponse,
|
||||
RequirementView,
|
||||
)
|
||||
from .ziputil import MAX_TOTAL_BYTES, BundleError
|
||||
from backend.apps.swarm.ziputil import MAX_TOTAL_BYTES, BundleError
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import shutil
|
||||
import tempfile
|
||||
import zipfile
|
||||
|
||||
from .redact import find_denied_keys, find_secrets_in_files
|
||||
from backend.apps.swarm.redact import find_denied_keys, find_secrets_in_files
|
||||
|
||||
MANIFEST_NAME = "manifest.json"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user