Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
128 lines
3.3 KiB
Python
128 lines
3.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""ACP session project context metadata."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from acp import text_block
|
|
|
|
from qwenpaw.agents.acp.meta import (
|
|
ACP_EPHEMERAL_META_KEY,
|
|
ACP_PROJECT_DIR_META_KEY,
|
|
)
|
|
from qwenpaw.agents.acp.server import QwenPawACPAgent
|
|
|
|
|
|
class _FakeConn:
|
|
async def session_update(self, session_id, update): # noqa: ANN001
|
|
del session_id, update
|
|
return None
|
|
|
|
|
|
class _FakeWorkspace:
|
|
def __init__(self) -> None:
|
|
self.requests = []
|
|
|
|
async def stream_query(self, request): # noqa: ANN001
|
|
self.requests.append(request)
|
|
for event in ():
|
|
yield event
|
|
|
|
|
|
class _TestACPAgent(QwenPawACPAgent):
|
|
def __init__(self, workspace: _FakeWorkspace) -> None:
|
|
super().__init__(agent_id="default")
|
|
self._fake_workspace = workspace
|
|
|
|
async def _ensure_workspace(self):
|
|
return self._fake_workspace
|
|
|
|
|
|
async def test_acp_project_dir_flows_to_request_context(tmp_path):
|
|
project_dir = str(tmp_path)
|
|
workspace = _FakeWorkspace()
|
|
agent = _TestACPAgent(workspace)
|
|
agent.on_connect(_FakeConn())
|
|
|
|
response = await agent.new_session(
|
|
cwd=project_dir,
|
|
**{ACP_PROJECT_DIR_META_KEY: project_dir},
|
|
)
|
|
|
|
await agent.prompt(
|
|
prompt=[text_block("hello")],
|
|
session_id=response.session_id,
|
|
)
|
|
|
|
assert workspace.requests
|
|
assert workspace.requests[0].request_context["project_dir"] == project_dir
|
|
|
|
|
|
async def test_acp_project_dir_preserves_trailing_space(tmp_path):
|
|
project_dir = str(tmp_path)
|
|
provided_project_dir = f"{project_dir} "
|
|
workspace = _FakeWorkspace()
|
|
agent = _TestACPAgent(workspace)
|
|
agent.on_connect(_FakeConn())
|
|
|
|
response = await agent.new_session(
|
|
cwd=project_dir,
|
|
**{ACP_PROJECT_DIR_META_KEY: provided_project_dir},
|
|
)
|
|
|
|
await agent.prompt(
|
|
prompt=[text_block("hello")],
|
|
session_id=response.session_id,
|
|
)
|
|
|
|
assert (
|
|
workspace.requests[0].request_context["project_dir"]
|
|
== provided_project_dir
|
|
)
|
|
|
|
|
|
async def test_acp_resume_project_dir_preserves_trailing_space(tmp_path):
|
|
project_dir = str(tmp_path)
|
|
provided_project_dir = f"{project_dir} "
|
|
workspace = _FakeWorkspace()
|
|
agent = _TestACPAgent(workspace)
|
|
agent.on_connect(_FakeConn())
|
|
|
|
response = await agent.new_session(cwd=project_dir)
|
|
await agent.resume_session(
|
|
cwd=project_dir,
|
|
session_id=response.session_id,
|
|
**{ACP_PROJECT_DIR_META_KEY: provided_project_dir},
|
|
)
|
|
|
|
await agent.prompt(
|
|
prompt=[text_block("hello")],
|
|
session_id=response.session_id,
|
|
)
|
|
|
|
assert (
|
|
workspace.requests[0].request_context["project_dir"]
|
|
== provided_project_dir
|
|
)
|
|
|
|
|
|
async def test_acp_ephemeral_metadata_flows_to_request_context(tmp_path):
|
|
project_dir = str(tmp_path)
|
|
workspace = _FakeWorkspace()
|
|
agent = _TestACPAgent(workspace)
|
|
agent.on_connect(_FakeConn())
|
|
|
|
response = await agent.new_session(
|
|
cwd=project_dir,
|
|
**{ACP_EPHEMERAL_META_KEY: True},
|
|
)
|
|
|
|
await agent.prompt(
|
|
prompt=[text_block("warmup")],
|
|
session_id=response.session_id,
|
|
)
|
|
|
|
assert workspace.requests
|
|
assert (
|
|
workspace.requests[0].request_context[ACP_EPHEMERAL_META_KEY] is True
|
|
)
|