mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-29 00:38:33 +00:00
* fix(proactive): simplify round files and restore failed summaries * fix(proactive): validate document-relative Markdown links * feat(proactive_agent): implement v2 daily record workflow with single-file decision - Add ProactiveAgentStepV2 class to support single daily note decision and reminder - Introduce RoundOutputs for v2 round file tracking, and keep RoundArtifacts for v1 summary backup - Refactor AgentOutbox to support both v1 standalone reminder files and v2 daily reminder records - Add proactive_record utilities to parse and validate v2 daily record frontmatter and metadata - Enhance proactive_agent to prepare, read, and manage artifacts for both v1 and v2 flows - Add configuration profile proactive_v2 to enable new workflow with backward compatibility - Update proactive.yaml and reactive proactive_agent_step configuration comment for easy switching - Provide extensive schema validation for v2 reminders ensuring priority and message consistency - Document v2 workflow and usage in English and Chinese runtime docs - Add unit tests for v2 step verifying single file output and proper decision handling * refactor(agent/runtime): replace ReminderRef with string keys and simplify reminder handling - Remove ReminderRef model and switch to using workspace-relative string keys for reminders - Simplify AgentOutbox to read, write, and manage reminders keyed by strings - Change file locking and version checking to protect concurrent edits on daily record files - Replace legacy and v2 reminder file handling with unified ReminderFiles storage - Adjust ChatNotifications to operate with the new key scheme and update pending/read sets - Refactor RoundOutputs to RoundRecord for safer round record tracking and rollback - Remove unused ProactiveRunResult and related references from imports and exports - Update InboxWakeRequest, AgentReminder, and related models for consistent ID and path validation - Adjust proactive agent runtime and local runtime to check reminder versions before commit - Correct language and docs to describe reminders as daily records instead of separate files - Clean up roles of inbox and outbox for reminder ownership, delivery, and acknowledgments * fix(proactive): serialize round commits and align desktop reminders * refactor(proactive): unify task triggers in Proactive Runtime * fix(proactive): bound reminder payloads and simplify receipts * refactor(studio): share workbench and simplify proactive delivery * fix(studio): update and centralize build dependencies * fix(proactive): guard draft repair and verify Studio deployments * chore(docs): update source-map-js * feat(release): support publishing selected artifacts from a tag * chore(studio): remove the public playground * refactor: simplify reminders and release workflows * fix: preserve proactive records and align release provenance * test(proactive): remove brittle prompt and preset assertions * fix(proactive): register reminders after input acknowledgement * feat(notebook): list projects across todos and ideas * feat(studio): connect mobile apps to configurable ReMe services * fix(proactive): reserve registered reminder paths * fix(studio): request Android local network access * fix(proactive): reserve reminder paths referenced by receipts
123 lines
3.9 KiB
Python
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", "proactive", "cron"]
|
|
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)
|