feat(agent): add persistent runtime context providers
This commit is contained in:
@@ -7,6 +7,7 @@ import time
|
||||
from pathlib import Path
|
||||
|
||||
from nanobot.agent.tools.cli_apps import CliAppsTool
|
||||
from nanobot.agent.tools.context import RequestContext
|
||||
from nanobot.apps.cli.service import CliAppManager, CliAppsRuntimeConfig
|
||||
|
||||
|
||||
@@ -125,3 +126,33 @@ def test_run_cli_app_description_names_only_settings_installed_apps(tmp_path: Pa
|
||||
|
||||
assert "Settings CLI Apps: drawio" in tool.description
|
||||
assert "ordinary system CLIs such as git, gh" in tool.description
|
||||
|
||||
|
||||
def test_cli_app_tool_provides_context_only_for_attachment(tmp_path: Path) -> None:
|
||||
tool = CliAppsTool(workspace=tmp_path)
|
||||
provider = tool.runtime_context_provider()
|
||||
assert provider is not None
|
||||
|
||||
empty = asyncio.run(provider(RequestContext(
|
||||
channel="websocket",
|
||||
chat_id="chat",
|
||||
original_user_text="hello",
|
||||
workspace=tmp_path,
|
||||
)))
|
||||
attached = asyncio.run(provider(RequestContext(
|
||||
channel="websocket",
|
||||
chat_id="chat",
|
||||
original_user_text="use @drawio",
|
||||
metadata={
|
||||
"cli_apps": [{
|
||||
"name": "drawio",
|
||||
"entry_point": "cli-anything-drawio",
|
||||
}],
|
||||
},
|
||||
workspace=tmp_path,
|
||||
)))
|
||||
|
||||
assert empty is None
|
||||
assert attached is not None
|
||||
assert attached.source == "cli_apps"
|
||||
assert "CLI App Attachment: @drawio" in attached.content
|
||||
|
||||
Reference in New Issue
Block a user