ReMe/reme/schema/proactive_runtime.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

123 lines
3.9 KiB
Python

"""Shared agent identities, native sessions, notifications and inbox contracts."""
from typing import Annotated, Literal
import re
from pydantic import (
AfterValidator,
AwareDatetime,
BaseModel,
ConfigDict,
Field,
field_validator,
)
from ..constants import WINDOWS_RESERVED_DEVICE_NAMES
from .event import Event
def validate_agent_name(value: str) -> str:
"""Keep application identities portable as workspace directory names."""
valid_length = isinstance(value, str) and 1 <= len(value) <= 80
if (
not valid_length
or len(value.encode("utf-8")) > 192
or not re.fullmatch(r"[\w-]+", value)
or value.upper() in WINDOWS_RESERVED_DEVICE_NAMES
):
raise ValueError("agent_name must contain only letters, numbers, underscores or hyphens")
return value
AgentName = Annotated[str, Field(min_length=1, max_length=80, pattern=r"^[\w-]+$"), AfterValidator(validate_agent_name)]
AgentType = Literal["chat", "event", "time"]
ChatMessageId = Annotated[str, Field(pattern=r"^[a-zA-Z0-9_-]{1,128}$")]
InboxPriority = Literal["P0", "P1", "P2"]
class NotificationConfig(BaseModel):
"""Receiver-owned wakeup delays in seconds."""
model_config = ConfigDict(extra="forbid", allow_inf_nan=False)
p0_delay_seconds: float = Field(default=0, ge=0)
p1_idle_seconds: float = Field(default=10, ge=0)
p2_idle_seconds: float = Field(default=1800, ge=0)
@field_validator("p0_delay_seconds", "p1_idle_seconds", "p2_idle_seconds", mode="before")
@classmethod
def numeric_seconds(cls, value):
"""Reject booleans and strings rather than treating them as durations."""
if type(value) not in (int, float):
raise ValueError("inbox delays must be numbers")
return value
class AgentSession(BaseModel):
"""One durable native session reference; temporary branches never select the current session."""
model_config = ConfigDict(extra="forbid")
session_id: str = Field(min_length=1, max_length=128)
created_at: AwareDatetime
temporary: bool = False
signature: str | None = None
class ChatAgentConfig(BaseModel):
"""Startup settings for Remy's personal memory."""
model_config = ConfigDict(extra="forbid")
initial_memory: str = Field(default="", max_length=100000)
class AgentReminder(BaseModel):
"""A daily record reminder and its delivery and Chat processing state."""
model_config = ConfigDict(extra="forbid")
priority: InboxPriority
message: str = Field(min_length=1, max_length=100000)
id: str = Field(description="Workspace-relative path to the source daily record.")
delivered_at: AwareDatetime | None = None
read_at: AwareDatetime | None = None
chat_message_ids: list[ChatMessageId] = Field(default_factory=list)
@field_validator("message")
@classmethod
def nonblank_message(cls, value: str) -> str:
"""Require user-facing reminder text."""
if not value.strip():
raise ValueError("reminder message must not be blank")
return value
@field_validator("id")
@classmethod
def relative_path(cls, value: str) -> str:
"""Apply the same workspace-relative contract as event inputs."""
Event.validate_paths([value])
return value
class ProcessChatRemindersRequest(BaseModel):
"""A framework-selected batch eligible for automatic processing."""
model_config = ConfigDict(extra="forbid")
priority: InboxPriority
msg_ids: list[str] = Field(min_length=1, max_length=100)
@field_validator("msg_ids")
@classmethod
def relative_paths(cls, value: list[str]) -> list[str]:
"""Chat batches reference workspace-relative daily records."""
return Event.validate_paths(value)
class SubmitChatReminderRequest(BaseModel):
"""Submit user-facing text, or an empty decision to stay quiet."""
model_config = ConfigDict(extra="forbid")
content: str = Field(max_length=100000)