refactor(api)!: remove the standalone API server (#6614)
This commit is contained in:
1 parent
5c72ced2fe
commit
220d5e6970
99 files changed
+240
-4133
No files matched your search
@@ -335,16 +335,13 @@ async def test_non_goal_direct_turn_cannot_reuse_prior_goal_command(tmp_path):
|
||||
])
|
||||
loop = AgentLoop(bus=MessageBus(), provider=provider, workspace=tmp_path, model="test-model",
|
||||
builtin_assembly=install_goal)
|
||||
session = loop.sessions.get_or_create("api:default")
|
||||
session = loop.sessions.get_or_create("cli:direct")
|
||||
session.add_message("user", "/goal old completed request")
|
||||
session.add_message("assistant", "The old request is complete.")
|
||||
|
||||
result = await loop.process_direct(
|
||||
"Handle this as an ordinary one-time task.",
|
||||
session_key=session.key,
|
||||
channel="api",
|
||||
chat_id="default",
|
||||
persist_user_message=False,
|
||||
)
|
||||
|
||||
assert result is not None
|
||||
|
||||
@@ -1807,32 +1807,6 @@ async def test_process_direct_rejects_reserved_system_channel(tmp_path: Path) ->
|
||||
loop._process_message.assert_not_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_process_direct_skip_user_persist_does_not_save_retry_user(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
loop = _make_full_loop(tmp_path)
|
||||
session = loop.sessions.get_or_create("api:default")
|
||||
session.add_message("user", "hello")
|
||||
session.add_message("assistant", "previous empty-response attempt")
|
||||
loop.sessions.save(session)
|
||||
|
||||
await loop.process_direct(
|
||||
"hello",
|
||||
session_key=session.key,
|
||||
channel="api",
|
||||
chat_id="default",
|
||||
persist_user_message=False,
|
||||
)
|
||||
|
||||
session = loop.sessions.get_or_create("api:default")
|
||||
assert [(m["role"], m["content"]) for m in session.messages] == [
|
||||
("user", "hello"),
|
||||
("assistant", "previous empty-response attempt"),
|
||||
("assistant", "Test title"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_request_context_uses_effective_key_for_subagent_tool(tmp_path: Path) -> None:
|
||||
loop = _make_full_loop(tmp_path)
|
||||
|
||||
@@ -755,33 +755,6 @@ class TestChannelCommonRegistration:
|
||||
assert config.channels.feishu["appId"] == "test123"
|
||||
|
||||
|
||||
class TestApiServerRegistration:
|
||||
|
||||
def test_api_server_in_settings_sections(self):
|
||||
from nanobot.cli.onboard import _SETTINGS_SECTIONS
|
||||
|
||||
assert "API Server" in _SETTINGS_SECTIONS
|
||||
|
||||
def test_api_server_getter_returns_api(self):
|
||||
from nanobot.cli.onboard import _SETTINGS_GETTER
|
||||
|
||||
config = Config()
|
||||
result = _SETTINGS_GETTER["API Server"](config)
|
||||
assert result is config.api
|
||||
|
||||
def test_api_server_setter_writes_api(self):
|
||||
from nanobot.cli.onboard import _SETTINGS_SETTER
|
||||
|
||||
config = Config()
|
||||
from nanobot.config.schema import ApiConfig
|
||||
|
||||
new_api = ApiConfig(host="0.0.0.0", port=9999, api_key="secret")
|
||||
_SETTINGS_SETTER["API Server"](config, new_api)
|
||||
assert config.api.host == "0.0.0.0"
|
||||
assert config.api.port == 9999
|
||||
assert config.api.api_key == "secret"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def prompt_input():
|
||||
with create_pipe_input() as pipe:
|
||||
@@ -1708,35 +1681,6 @@ class TestMainMenuInteraction:
|
||||
assert result.should_save is True
|
||||
assert result.config.channels.send_tool_hints is True
|
||||
|
||||
def test_run_onboard_api_server_edit(self, monkeypatch):
|
||||
initial_config = Config()
|
||||
|
||||
responses = iter([
|
||||
"[A] Advanced Settings",
|
||||
"[I] API Server",
|
||||
KeyboardInterrupt(),
|
||||
"[S] Save and Exit",
|
||||
])
|
||||
|
||||
def fake_select_with_back(*_args, **_kwargs):
|
||||
response = next(responses)
|
||||
if isinstance(response, BaseException):
|
||||
raise response
|
||||
return response
|
||||
|
||||
def fake_configure_general_settings(config, section):
|
||||
if section == "API Server":
|
||||
config.api.port = 9999
|
||||
|
||||
monkeypatch.setattr(onboard_wizard, "_show_main_menu_header", lambda: None)
|
||||
monkeypatch.setattr(onboard_wizard, "_select_with_back", fake_select_with_back)
|
||||
monkeypatch.setattr(onboard_wizard, "_configure_general_settings", fake_configure_general_settings)
|
||||
|
||||
result = run_onboard(initial_config=initial_config)
|
||||
|
||||
assert result.should_save is True
|
||||
assert result.config.api.port == 9999
|
||||
|
||||
def test_view_summary_calls_pause(self, monkeypatch):
|
||||
initial_config = Config()
|
||||
pause_called = {"n": 0}
|
||||
|
||||
Reference in new issue
Block a user