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
145 lines
4.4 KiB
Python
145 lines
4.4 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
|
|
from .agent_message import AgentMessage, ClientModel
|
|
from .proactive_agent import TaskSettings
|
|
|
|
|
|
class AgentView(TaskSettings):
|
|
"""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):
|
|
"""An activity is identified by its Agent map key, not by redundant task IDs."""
|
|
|
|
session_id: str
|
|
turn_id: str
|
|
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)
|