mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-29 00:38:33 +00:00
Some checks failed
CI and Release / Docker / Build and test / amd64 (push) Has been cancelled
CI and Release / Docker / Build and test / arm64 (push) Has been cancelled
Security / CodeQL / Analyze python (push) Has been cancelled
CI / Python quality / Pre-commit (push) Has been cancelled
CI / Python tests / Unit Tests - py3.12 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.13 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.14 (push) Has been cancelled
CI / Python packages / Build and verify distributions (push) Has been cancelled
CI / Python quality / GitHub Actions (push) Has been cancelled
CI / Python tests / Hermes embedded - ubuntu-latest (push) Has been cancelled
CI / Python tests / Hermes embedded - windows-latest (push) Has been cancelled
CI / Python tests / Unit Tests - py3.11 (push) Has been cancelled
CI / ReMe Studio / Studio checks (push) Has been cancelled
Deploy / Documentation / Build documentation (push) Has been cancelled
CI / Windows / CLI smoke - py3.11 (push) Has been cancelled
Security / CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI and Release / Docker / Publish multi-platform tags (push) Has been cancelled
Deploy / Documentation / deploy (push) Has been cancelled
* refactor(core): reorganize the ReMe runtime and shared helpers * test(status): import the base component from its canonical module * test: remove redundant unit checks * refactor(core): use canonical runtime imports and shared CLI discovery Restore evolve behavior to the base branch and update its imports. Use Application as the runtime entry point and encode SSE in the HTTP service. * fix(cli): honor caller config when service replay is incomplete Use partial startup overrides for port probes and resolve named configs before requesting the service process working directory.
56 lines
2 KiB
Python
56 lines
2 KiB
Python
"""Draft accumulation steps scoped by agent tool context."""
|
|
|
|
from typing import Final
|
|
|
|
from ._tool_context import _ToolContextMixin
|
|
from ..base_step import BaseStep
|
|
from ...core.registry import R
|
|
|
|
|
|
@R.register("add_draft_step")
|
|
class AddDraftStep(_ToolContextMixin, BaseStep):
|
|
"""Append one draft text item to the current tool context."""
|
|
|
|
DRAFTS_KEY: Final[str] = "drafts"
|
|
|
|
async def execute(self):
|
|
assert self.context is not None
|
|
text = self.context.get("text", "")
|
|
tool_context_id: str = (self.context.get("tool_context_id", "") or "").strip()
|
|
|
|
if not tool_context_id:
|
|
self.context.response.success = False
|
|
self.context.response.answer = "Error: tool_context_id is required"
|
|
return self.context.response
|
|
if text is None or not isinstance(text, str):
|
|
self.context.response.success = False
|
|
self.context.response.answer = "Error: text must be a string"
|
|
return self.context.response
|
|
|
|
store = self._tool_context_store(tool_context_id)
|
|
drafts = store.setdefault(self.DRAFTS_KEY, [])
|
|
drafts.append(text)
|
|
|
|
self.context.response.answer = text
|
|
self.context.response.metadata["draft_count"] = len(drafts)
|
|
return self.context.response
|
|
|
|
|
|
@R.register("read_all_draft_step")
|
|
class ReadAllDraftStep(AddDraftStep):
|
|
"""Read all draft text items for the current tool context."""
|
|
|
|
async def execute(self):
|
|
assert self.context is not None
|
|
tool_context_id: str = (self.context.get("tool_context_id", "") or "").strip()
|
|
|
|
if not tool_context_id:
|
|
self.context.response.success = False
|
|
self.context.response.answer = "Error: tool_context_id is required"
|
|
return self.context.response
|
|
|
|
store = self._tool_context_store(tool_context_id)
|
|
drafts = store.setdefault(self.DRAFTS_KEY, [])
|
|
self.context.response.answer = "\n".join(drafts)
|
|
self.context.response.metadata["draft_count"] = len(drafts)
|
|
return self.context.response
|