mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-27 23:58:47 +00:00
Some checks failed
CI and Release / Docker / Build and test / amd64 (push) Has been cancelled
CI and Release / Docker / Build and test / arm64 (push) Has been cancelled
Security / CodeQL / Analyze python (push) Has been cancelled
CI / Python quality / Pre-commit (push) Has been cancelled
CI / Python tests / Unit Tests - py3.12 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.13 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.14 (push) Has been cancelled
CI / Python packages / Build and verify distributions (push) Has been cancelled
CI / Python quality / GitHub Actions (push) Has been cancelled
CI / Python tests / Hermes embedded - ubuntu-latest (push) Has been cancelled
CI / Python tests / Hermes embedded - windows-latest (push) Has been cancelled
CI / Python tests / Unit Tests - py3.11 (push) Has been cancelled
CI / ReMe Studio / Studio checks (push) Has been cancelled
Deploy / Documentation / Build documentation (push) Has been cancelled
CI / Windows / CLI smoke - py3.11 (push) Has been cancelled
Security / CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI and Release / Docker / Publish multi-platform tags (push) Has been cancelled
Deploy / Documentation / deploy (push) Has been cancelled
* refactor(core): reorganize the ReMe runtime and shared helpers * test(status): import the base component from its canonical module * test: remove redundant unit checks * refactor(core): use canonical runtime imports and shared CLI discovery Restore evolve behavior to the base branch and update its imports. Use Application as the runtime entry point and encode SSE in the HTTP service. * fix(cli): honor caller config when service replay is incomplete Use partial startup overrides for port probes and resolve named configs before requesting the service process working directory.
62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
"""Portable manifests for connector-produced resource packages."""
|
|
|
|
from pathlib import PurePosixPath, PureWindowsPath
|
|
from typing import Literal
|
|
|
|
from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, field_validator, model_validator
|
|
|
|
RESOURCE_METADATA_FILENAME = "metadata.json"
|
|
|
|
|
|
class ResourceFile(BaseModel):
|
|
"""A package-relative payload path, with optional connector-specific fields."""
|
|
|
|
model_config = ConfigDict(extra="allow")
|
|
|
|
path: str
|
|
description: str | None = None
|
|
|
|
@field_validator("path")
|
|
@classmethod
|
|
def validate_path(cls, value: str) -> str:
|
|
"""Keep payload references inside the package and reserve its manifest name."""
|
|
path = PurePosixPath(value)
|
|
if any(
|
|
(
|
|
not value,
|
|
value.startswith("~"),
|
|
"\\" in value,
|
|
PureWindowsPath(value).anchor,
|
|
path.is_absolute(),
|
|
".." in path.parts,
|
|
path.as_posix() != value,
|
|
value == ".",
|
|
path.name.casefold() == RESOURCE_METADATA_FILENAME,
|
|
),
|
|
):
|
|
raise ValueError(f"path must be a package-relative file path other than {RESOURCE_METADATA_FILENAME}")
|
|
return value
|
|
|
|
|
|
class ResourceMetadata(BaseModel):
|
|
"""Describe one complete resource package; processing state belongs to the catalog."""
|
|
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
schema_version: Literal[1] = 1
|
|
dataclass: str = Field(min_length=1)
|
|
source: str = Field(min_length=1)
|
|
created_at: AwareDatetime
|
|
modified_at: AwareDatetime
|
|
description: str
|
|
files: list[ResourceFile] = Field(min_length=1)
|
|
|
|
@model_validator(mode="after")
|
|
def validate_package(self):
|
|
"""Require distinct payloads and chronological timestamps."""
|
|
paths = [item.path.casefold() for item in self.files]
|
|
if len(set(paths)) != len(paths):
|
|
raise ValueError("files must contain distinct paths")
|
|
if self.modified_at < self.created_at:
|
|
raise ValueError("modified_at must not precede created_at")
|
|
return self
|