Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
feat(admin): add case-insensitive query search to account listing (#5306)
nocvalight184a5cecef06
diff --git a/docs/en/api/08-admin.md b/docs/en/api/08-admin.mdindex 7b9456386..3e9ac4704 100644--- a/docs/en/api/08-admin.md+++ b/docs/en/api/08-admin.md@@ -707,6 +707,7 @@ List all workspaces (ROOT only).| name | str | No | null | Filter by account ID (wildcard `*` and `?` matching) || limit | int | No | null | Page size (≥1). Omit to return all matches || page | int | No | 1 | 1-based page number; only applies when `limit` is set |+| query | str | No | null | Case-insensitive substring match on the account ID |Results are returned in creation order.@@ -727,6 +728,10 @@ curl -X GET http://localhost:1933/api/v1/admin/accounts \curl -X GET "http://localhost:1933/api/v1/admin/accounts?name=*acme*" \-H "X-API-Key: <root-key>"+# With case-insensitive substring search+curl -X GET "http://localhost:1933/api/v1/admin/accounts?query=acme" \+ -H "X-API-Key: <root-key>"+# Paginated (second page of 50)curl -X GET "http://localhost:1933/api/v1/admin/accounts?limit=50&page=2" \-H "X-API-Key: <root-key>"diff --git a/docs/zh/api/08-admin.md b/docs/zh/api/08-admin.mdindex 98dba30f9..8c33c4a38 100644--- a/docs/zh/api/08-admin.md+++ b/docs/zh/api/08-admin.md@@ -623,6 +623,7 @@ ov --sudo admin create-account acme-private --admin alice \| name | str | 否 | null | 按账户 ID 过滤(通配符 `*` 和 `?` 匹配) || limit | int | 否 | null | 每页数量(≥1)。省略则返回所有匹配项 || page | int | 否 | 1 | 从 1 开始的页码;仅在设置了 `limit` 时生效 |+| query | str | 否 | null | 对账户 ID 做不区分大小写的子串匹配 |结果按创建顺序返回。@@ -643,6 +644,10 @@ curl -X GET http://localhost:1933/api/v1/admin/accounts \curl -X GET "http://localhost:1933/api/v1/admin/accounts?name=*acme*" \-H "X-API-Key: <root-key>"+# 不区分大小写的子串搜索+curl -X GET "http://localhost:1933/api/v1/admin/accounts?query=acme" \+ -H "X-API-Key: <root-key>"+# 分页(每页 50,取第 2 页)curl -X GET "http://localhost:1933/api/v1/admin/accounts?limit=50&page=2" \-H "X-API-Key: <root-key>"diff --git a/openviking/server/api_keys/legacy.py b/openviking/server/api_keys/legacy.pyindex dd4b0bead..e5f5e8ef8 100644--- a/openviking/server/api_keys/legacy.py+++ b/openviking/server/api_keys/legacy.py@@ -1005,19 +1005,25 @@ class LegacyAPIKeyManager:name_filter: str | None = None,limit: int | None = None,page: int = 1,+ query_filter: str | None = None,) -> list:"""List accounts in creation (insertion) order.- ``name_filter`` uses wildcard (``*`` and ``?``) matching. Pagination is- opt-in: ``limit=None`` returns every matching account so internal- callers that rely on the full account set are unaffected; when ``limit``- is set, ``page`` (1-based) selects the slice.+ ``name_filter`` uses wildcard (``*`` and ``?``) matching. ``query_filter``+ is a case-insensitive substring match on the account id, mirroring the+ user listing search. Pagination is opt-in: ``limit=None`` returns every+ matching account so internal callers that rely on the full account set+ are unaffected; when ``limit`` is set, ``page`` (1-based) selects the+ slice."""result = []+ query = (query_filter or "").strip().casefold()for account_id, info in self._accounts.items():# Apply name filter if provided (fnmatch wildcard matching)if name_filter and not fnmatch.fnmatch(account_id, name_filter):continue+ if query and query not in account_id.casefold():+ continueresult.append({diff --git a/openviking/server/api_keys/new.py b/openviking/server/api_keys/new.pyindex d33ee2598..cebd2e7d0 100644--- a/openviking/server/api_keys/new.py+++ b/openviking/server/api_keys/new.py@@ -536,9 +536,15 @@ class NewAPIKeyManager:name_filter: str | None = None,limit: int | None = None,page: int = 1,+ query_filter: str | None = None,) -> list:"""List all accounts."""- return self._legacy.get_accounts(name_filter=name_filter, limit=limit, page=page)+ return self._legacy.get_accounts(+ name_filter=name_filter,+ limit=limit,+ page=page,+ query_filter=query_filter,+ )def get_users(self,diff --git a/openviking/server/routers/admin.py b/openviking/server/routers/admin.pyindex 5d3003bee..c0d6dec83 100644--- a/openviking/server/routers/admin.py+++ b/openviking/server/routers/admin.py@@ -491,13 +491,14 @@ async def list_accounts(name: str | None = None,limit: int | None = Query(None, ge=1, description="Page size; omit to return all"),page: int = Query(1, ge=1, description="1-based page number (requires limit)"),+ query: str | None = Query(None, description="Case-insensitive account id substring"),ctx: RequestContext = Depends(get_request_context),):"""List accounts in creation order. `name` supports wildcard (* and ?) matching."""manager = _get_api_key_manager(request)if not _registry_watcher_running(request):await manager.refresh_accounts_from_store()- accounts = manager.get_accounts(name_filter=name, limit=limit, page=page)+ accounts = manager.get_accounts(name_filter=name, limit=limit, page=page, query_filter=query)return Response(status="ok", result=accounts)diff --git a/sdk/python/openviking_sdk/client.py b/sdk/python/openviking_sdk/client.pyindex f812e2495..58dfce6b6 100644--- a/sdk/python/openviking_sdk/client.py+++ b/sdk/python/openviking_sdk/client.py@@ -1833,6 +1833,7 @@ class AsyncHTTPClient:name: Optional[str] = None,limit: Optional[int] = None,page: int = 1,+ query: Optional[str] = None,) -> List[Any]:params: Dict[str, Any] = {}if name is not None:@@ -1840,6 +1841,8 @@ class AsyncHTTPClient:if limit is not None:params["limit"] = limitparams["page"] = page+ if query is not None:+ params["query"] = queryresponse = await self._request("GET", "/api/v1/admin/accounts", params=params)return self._handle_response(response)@@ -1874,6 +1877,7 @@ class AsyncHTTPClient:name: Optional[str] = None,role: Optional[str] = None,page: int = 1,+ query: Optional[str] = None,) -> List[Any]:params: Dict[str, Any] = {}if limit is not None:@@ -1883,6 +1887,8 @@ class AsyncHTTPClient:params["name"] = nameif role is not None:params["role"] = role+ if query is not None:+ params["query"] = queryresponse = await self._request("GET", f"/api/v1/admin/accounts/{account_id}/users", params=params)@@ -2854,8 +2860,11 @@ class SyncHTTPClient:name: Optional[str] = None,limit: Optional[int] = None,page: int = 1,+ query: Optional[str] = None,) -> List[Any]:- return run_async(self._async_client.admin_list_accounts(name=name, limit=limit, page=page))+ return run_async(+ self._async_client.admin_list_accounts(name=name, limit=limit, page=page, query=query)+ )def admin_delete_account(self, account_id: str) -> Dict[str, Any]:return run_async(self._async_client.admin_delete_account(account_id))@@ -2885,10 +2894,11 @@ class SyncHTTPClient:name: Optional[str] = None,role: Optional[str] = None,page: int = 1,+ query: Optional[str] = None,) -> List[Any]:return run_async(self._async_client.admin_list_users(- account_id, limit=limit, name=name, role=role, page=page+ account_id, limit=limit, name=name, role=role, page=page, query=query))diff --git a/tests/server/test_admin_api.py b/tests/server/test_admin_api.pyindex 4ed841653..a59d036b6 100644--- a/tests/server/test_admin_api.py+++ b/tests/server/test_admin_api.py@@ -1915,6 +1915,18 @@ async def test_list_accounts(admin_client: httpx.AsyncClient):assert "default" in account_idsassert acct in account_ids+ # `query` is a case-insensitive substring match on the account id.+ fragment = acct[:5].upper() # "ACME_", proving the match ignores case+ resp = await admin_client.get(+ "/api/v1/admin/accounts",+ params={"query": fragment},+ headers=root_headers(),+ )+ assert resp.status_code == 200+ queried_ids = {a["account_id"] for a in resp.json()["result"]}+ assert acct in queried_ids+ assert "default" not in queried_ids+async def test_list_accounts_without_watcher_reads_only_accounts_registry(lightweight_admin_client: httpx.AsyncClient,