ReMe/reme/schema/agent_view.py
jinliyl ae55e2e570
Some checks are pending
CI / Python packages / Build and verify distributions (push) Waiting to run
CI / Python quality / GitHub Actions (push) Waiting to run
CI / Python quality / Pre-commit (push) Waiting to run
CI / Python tests / Hermes embedded - ubuntu-latest (push) Waiting to run
CI / Python tests / Hermes embedded - windows-latest (push) Waiting to run
CI / Python tests / Unit Tests - py3.11 (push) Waiting to run
CI / Python tests / Unit Tests - py3.12 (push) Waiting to run
CI / Python tests / Unit Tests - py3.13 (push) Waiting to run
CI / Python tests / Unit Tests - py3.14 (push) Waiting to run
CI / ReMe Studio / Studio checks (push) Waiting to run
CI / Windows / CLI smoke - py3.11 (push) Waiting to run
Deploy / Documentation / Build documentation (push) Waiting to run
Deploy / Documentation / deploy (push) Blocked by required conditions
Security / CodeQL / Analyze javascript-typescript (push) Waiting to run
Security / CodeQL / Analyze python (push) Waiting to run
feat!: split proactive runtimes and add Studio backend management (#776)
* refactor(proactive)!: separate runtime ownership and unify delivery

* refactor(proactive): finish runtime and Studio migration

* test(proactive): make scheduled skip coverage deterministic

* refactor(studio): unify navigation and notebook resource loading

* feat(studio): edit workspace documents and update proactive task names

* refactor(studio): simplify task settings and navigation

* feat(studio): secure and supervise backend settings

* feat(studio): unify workbench timelines and refine desktop updates

Use shared timeline panes for notebook, memory, and resources. Add Todo creation ordering, persist companion visibility, and align desktop update handling and release artifacts.

Recheck editor file versions at read and publication boundaries. Retry reminder detail requests from the resource view.

* fix(studio): support unsigned GitHub preview releases

* fix: verify container state and isolate proactive view errors

Mount private supervisor state in Docker smoke tests and verify token and settings persistence. Exercise Studio startup with a loopback-only model fixture, and exclude packaged desktop output from Docker contexts.

Keep Remy subscriptions and healthy tasks available when an individual task has an invalid workspace path or session history.

* fix(home): align candidate Docker context exclusions

* chore(deps): update openai-codex dependency to v0.172.0

- Bump openai-codex from version 0.169.0 to 0.172.0 in pyproject.toml
- Keep other dependencies unchanged
- Ensure compatibility with latest openai-codex features and fixes

* fix(daemon): discover parent dotenv and isolate listeners

Restore parent-directory environment discovery in workers while retaining system precedence. Partition the default supervisor profile and lock by the configured bind address and port.
2026-11-25 21:33:16 +08:00

146 lines
4.5 KiB
Python

"""Read-only Agent workspaces and current conversation subscription contracts."""
from typing import Literal
from pydantic import BaseModel, ConfigDict, Field, model_validator
from ..constants import CHAT_AGENT_NAME
from .proactive_runtime import AgentName, AgentType
from .agent_activity import ActivityPhase, ActivitySource
from .agent_message import AgentMessage, ClientModel
from .proactive_agent import ProactiveRuntimeSettings
class AgentView(ProactiveRuntimeSettings):
"""A visible identity; paths refer to original workspace files, never copies."""
model_config = ConfigDict(extra="forbid")
agent_name: AgentName
agent_type: AgentType
status: Literal["active", "idle", "not_loaded", "error"] = "idle"
session_id: str | None = None
memory_path: str | None = None
task_path: str | None = None
directory: str
pending_events: int = 0
in_flight_events: int = 0
last_started_at: str | None = None
last_completed_at: str | None = None
next_trigger_at: str | None = None
error: str | None = None
class AgentRequest(BaseModel):
"""Resolve a conversation by application identity rather than a native thread ID."""
model_config = ConfigDict(extra="forbid")
agent_name: AgentName = CHAT_AGENT_NAME
class AskAgentRequest(AgentRequest):
"""A user message continues Chat or queries a fork of the latest task session."""
query: str = Field(min_length=1, max_length=100000)
class TaskDocumentRequest(BaseModel):
"""Read or save a task's original TASK.md without accepting arbitrary paths."""
model_config = ConfigDict(extra="forbid")
action: Literal["read", "save"]
agent_name: AgentName
content: str | None = Field(default=None, min_length=1, max_length=100000)
expected_mtime: str | None = Field(default=None, min_length=1, max_length=80)
@model_validator(mode="after")
def validate_action(self):
"""Require an editor revision for every write and reject irrelevant read inputs."""
if self.action == "save":
if self.content is None or not self.content.strip() or not self.expected_mtime:
raise ValueError("save requires nonblank content and expected_mtime")
elif self.model_fields_set & {"content", "expected_mtime"}:
raise ValueError("read does not accept content or expected_mtime")
return self
class ClientActivity(ClientModel):
"""For task activities, turn_id identifies a run and session_id may be empty during preparation."""
session_id: str
turn_id: str
source: ActivitySource
phase: ActivityPhase
tool: str | None = None
started_at: str | None = None
class AgentSessionView(ClientModel):
"""An authoritative Agent state and its ordered display messages."""
agent: AgentView
messages: list[AgentMessage] = Field(default_factory=list)
activities: dict[str, ClientActivity] = Field(default_factory=dict)
class AgentSnapshot(AgentSessionView):
"""Replace state atomically on connection, session switch or history replacement."""
type: Literal["snapshot"] = "snapshot"
agents: list[AgentView] | None = None
class AgentUpdate(AgentSessionView):
"""Replace state and upsert complete messages without replaying token deltas."""
type: Literal["update"] = "update"
agents: list[AgentView] | None = None
class AgentHeartbeat(ClientModel):
"""Transport liveness carries no application state."""
type: Literal["heartbeat"] = "heartbeat"
class ClientInfo(ClientModel):
"""Client capabilities independent of component wiring and model credentials."""
workspace_dir: str
timezone: str | None
resource_dir: str
daily_dir: str
digest_dir: str
tag_key: str
jobs: list[str]
asr: bool
tts: bool
speech_revision: str
class AgentPageRequest(AgentRequest):
"""Bound resource queries independently of the current conversation."""
offset: int = Field(default=0, ge=0, strict=True)
limit: int = Field(default=20, ge=1, le=100, strict=True)
class AgentInboxRequest(AgentPageRequest):
"""Observe inputs without claiming or acknowledging them."""
state: Literal["all", "pending", "processing", "processed"] = "all"
class ListTaskRemindersRequest(AgentPageRequest):
"""Page reminders produced by one task Agent."""
agent_name: AgentName
state: Literal["all", "pending", "processed"] = "all"
class AgentReminderRequest(AgentRequest):
"""Read a reminder by its workspace-relative path or Chat message ID."""
message_id: str = Field(min_length=1)