mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-27 23:58:47 +00:00
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
* 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.
92 lines
3.9 KiB
Python
92 lines
3.9 KiB
Python
"""Typed runtime access and workspace authorization shared by agent steps."""
|
|
|
|
import asyncio
|
|
from uuid import uuid4
|
|
|
|
from ...base_step import BaseStep, Ref
|
|
from ...file_io import check_path_permission
|
|
from ....components.proactive_manager import BaseProactiveManager
|
|
from ....enumeration import ComponentEnum
|
|
from ....schema import AgentActivity, Response, collect_reply
|
|
from ._activity import ActivityTracker
|
|
|
|
|
|
class BaseAgentStep(BaseStep):
|
|
"""Keep request handlers stateless; the application component owns the runtime."""
|
|
|
|
proactive_manager: BaseProactiveManager = Ref(BaseProactiveManager, ComponentEnum.PROACTIVE_MANAGER)
|
|
|
|
async def query_reply(self, agent_name, query, *, on_chunk=None):
|
|
"""Ask a disposable fork while retaining the selected task session."""
|
|
manager = self.proactive_manager
|
|
options = {"job_tools": [], "sandbox": "read-only", "approval_mode": "deny_all"}
|
|
async with manager.query_session(agent_name, options) as session_id:
|
|
|
|
async def observe(chunk):
|
|
await on_chunk(chunk.model_copy(update={"session_id": chunk.session_id or session_id}))
|
|
|
|
return await collect_reply(
|
|
manager.agent_wrapper.reply_stream(
|
|
query,
|
|
resume=session_id,
|
|
**options,
|
|
),
|
|
on_chunk=observe if on_chunk else None,
|
|
)
|
|
|
|
async def stream_reply(self, query: str, *, session_id: str, agent_name: str, on_chunk, **options) -> Response:
|
|
"""Relay a formal conversation and preserve its terminal outcome and native metadata."""
|
|
manager = self.proactive_manager
|
|
tracker = ActivityTracker(
|
|
AgentActivity(
|
|
session_id=session_id,
|
|
execution_session_id=session_id,
|
|
turn_id=uuid4().hex,
|
|
phase="thinking",
|
|
started_at=manager.now(),
|
|
),
|
|
)
|
|
manager.activities[agent_name] = tracker.activity
|
|
|
|
async def observe(chunk):
|
|
if chunk.turn_id:
|
|
tracker.activity = tracker.activity.model_copy(
|
|
update={
|
|
"turn_id": chunk.turn_id,
|
|
"execution_session_id": chunk.session_id or session_id,
|
|
},
|
|
)
|
|
manager.activities[agent_name] = tracker.update(chunk)
|
|
publish(chunk)
|
|
await on_chunk(chunk.model_copy(update={"session_id": chunk.session_id or session_id}))
|
|
|
|
try:
|
|
with manager.live_turns.observe(agent_name, session_id, query) as publish:
|
|
result = await collect_reply(
|
|
manager.agent_wrapper.reply_stream(query, resume=session_id, **options),
|
|
on_chunk=observe,
|
|
)
|
|
except BaseException as exc:
|
|
phase = "interrupted" if isinstance(exc, asyncio.CancelledError) else "failed"
|
|
manager.activities[agent_name] = tracker.activity.model_copy(update={"phase": phase, "tool": None})
|
|
raise
|
|
response = self.context.response
|
|
response.success = result["status"] == "completed" and self.context.stream_error is None
|
|
response.answer = result["result"]
|
|
response.metadata.update(result, agent_name=agent_name)
|
|
return response
|
|
|
|
def require_paths(self, *paths):
|
|
"""Preserve fail-closed tool bindings before accessing runtime files."""
|
|
if any(
|
|
not check_path_permission(self.workspace_path, path, self.context.get("_allowed_paths")) for path in paths
|
|
):
|
|
raise PermissionError("no permission to access agent runtime files")
|
|
|
|
def parameters(self):
|
|
"""Separate server-injected context from public request arguments."""
|
|
return {
|
|
key: value
|
|
for key, value in self.context.data.items()
|
|
if key not in {"metadata", "_allowed_paths", "_agent_name", "_inbox_turn"}
|
|
}
|