Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
Normalize CLI query filters
cyh197099f78045
diff --git a/storage/background.py b/storage/background.pyindex 94833aafb..ccf0e86aa 100644--- a/storage/background.py+++ b/storage/background.py@@ -44,6 +44,7 @@ RUN_STATUS_ALIASES: dict[str, str] = {"failed": "failed","canceled": "canceled",}+_LIKE_ESCAPE = "\\"def normalize_run_status(status: Any) -> str:@@ -56,6 +57,15 @@ def _status_query_values(status: str) -> list[str]:return values or [normalized]+def _like_contains_pattern(value: str) -> str:+ escaped = (+ value.replace(_LIKE_ESCAPE, _LIKE_ESCAPE + _LIKE_ESCAPE)+ .replace("%", _LIKE_ESCAPE + "%")+ .replace("_", _LIKE_ESCAPE + "_")+ )+ return f"%{escaped}%"++class SQLiteBackgroundTaskStore:def __init__(self, db_path: Optional[Path] = None):self.db_path = db_path or paths.get_sqlite_state_path()@@ -233,19 +243,19 @@ class SQLiteBackgroundTaskStore:if created_before:stmt = stmt.where(agent_runs.c.created_at <= created_before)if query:- pattern = f"%{query}%"+ pattern = _like_contains_pattern(query)stmt = stmt.where(or_(- agent_runs.c.id.like(pattern),- agent_runs.c.definition_id.like(pattern),- agent_runs.c.agent_name.like(pattern),- agent_runs.c.session_id.like(pattern),- agent_runs.c.prompt.like(pattern),- agent_runs.c.message.like(pattern),- agent_runs.c.result_text.like(pattern),- agent_runs.c.error.like(pattern),- agent_runs.c.stdout.like(pattern),- agent_runs.c.stderr.like(pattern),+ agent_runs.c.id.like(pattern, escape=_LIKE_ESCAPE),+ agent_runs.c.definition_id.like(pattern, escape=_LIKE_ESCAPE),+ agent_runs.c.agent_name.like(pattern, escape=_LIKE_ESCAPE),+ agent_runs.c.session_id.like(pattern, escape=_LIKE_ESCAPE),+ agent_runs.c.prompt.like(pattern, escape=_LIKE_ESCAPE),+ agent_runs.c.message.like(pattern, escape=_LIKE_ESCAPE),+ agent_runs.c.result_text.like(pattern, escape=_LIKE_ESCAPE),+ agent_runs.c.error.like(pattern, escape=_LIKE_ESCAPE),+ agent_runs.c.stdout.like(pattern, escape=_LIKE_ESCAPE),+ agent_runs.c.stderr.like(pattern, escape=_LIKE_ESCAPE),))return stmtdiff --git a/tests/test_cli_pagination.py b/tests/test_cli_pagination.pyindex 7437e52b6..9ccaf971a 100644--- a/tests/test_cli_pagination.py+++ b/tests/test_cli_pagination.py@@ -83,6 +83,39 @@ def test_runs_list_cli_filters_status_and_query(monkeypatch, tmp_path, capsys) -assert payload["pagination"]["has_more"] is False+def test_runs_list_cli_normalizes_offset_time_filters(monkeypatch, tmp_path, capsys) -> None:+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ paths.ensure_data_dirs()+ store = SQLiteBackgroundTaskStore()+ try:+ store.enqueue_run(+ {+ "id": "run-before",+ "request_type": "agent_run",+ "status": "succeeded",+ "created_at": "2026-05-25T01:59:59+00:00",+ "updated_at": "2026-05-25T01:59:59+00:00",+ }+ )+ store.enqueue_run(+ {+ "id": "run-after",+ "request_type": "agent_run",+ "status": "succeeded",+ "created_at": "2026-05-25T02:00:00+00:00",+ "updated_at": "2026-05-25T02:00:00+00:00",+ }+ )+ finally:+ store.close()++ args = cli.build_parser().parse_args(["runs", "list", "--created-after", "2026-05-25T10:00:00+08:00", "--brief"])+ assert cli.cmd_runs_list(args) == 0++ payload = json.loads(capsys.readouterr().out)+ assert [item["id"] for item in payload["runs"]] == ["run-after"]++def test_data_query_cli_runs_read_only_sql(monkeypatch, tmp_path, capsys) -> None:monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))paths.ensure_data_dirs()diff --git a/tests/test_scheduled_tasks.py b/tests/test_scheduled_tasks.pyindex 7fae77052..939a99d0a 100644--- a/tests/test_scheduled_tasks.py+++ b/tests/test_scheduled_tasks.py@@ -732,6 +732,35 @@ def test_sqlite_run_listing_pages_and_filters(tmp_path: Path) -> None:sqlite.close()+def test_sqlite_run_query_filter_treats_like_wildcards_as_literals(tmp_path: Path) -> None:+ sqlite = SQLiteBackgroundTaskStore(tmp_path / "state" / "vibe.sqlite")+ try:+ for run_id, message in [+ ("run-underscore", "foo_bar"),+ ("run-letter", "fooxbar"),+ ("run-percent", "100% done"),+ ("run-plain", "1000 done"),+ ]:+ sqlite.enqueue_run(+ {+ "id": run_id,+ "request_type": "agent_run",+ "status": "succeeded",+ "message": message,+ "created_at": "2026-05-25T00:00:00+00:00",+ "updated_at": "2026-05-25T00:00:00+00:00",+ }+ )++ underscore = sqlite.list_runs_page(query="foo_", page_request=PageRequest(page=1, limit=20))+ percent = sqlite.list_runs_page(query="100%", page_request=PageRequest(page=1, limit=20))++ assert [item["id"] for item in underscore.items] == ["run-underscore"]+ assert [item["id"] for item in percent.items] == ["run-percent"]+ finally:+ sqlite.close()++def test_runtime_session_reservation_uses_legacy_scope_backend(tmp_path: Path, monkeypatch) -> None:db_path = tmp_path / "state" / "vibe.sqlite"monkeypatch.setattr(paths, "get_state_dir", lambda: db_path.parent)diff --git a/vibe/cli.py b/vibe/cli.pyindex d77e2be89..24606100f 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -222,14 +222,16 @@ def _parse_cli_time_filter(value: str | None, *, field_name: str, help_command:delta = timedelta(**{units[suffix]: int(amount)})return (datetime.now(timezone.utc) - delta).isoformat()try:- datetime.fromisoformat(raw.replace("Z", "+00:00"))+ parsed = datetime.fromisoformat(raw.replace("Z", "+00:00"))except ValueError as exc:raise TaskCliError(f"{field_name} must be an ISO timestamp or a relative value like 30m, 6h, or 7d",code="invalid_time_filter",help_command=help_command,) from exc- return raw+ if parsed.tzinfo is None:+ parsed = parsed.replace(tzinfo=timezone.utc)+ return parsed.astimezone(timezone.utc).isoformat()def _non_negative_float(value: str) -> float: