Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

feat(cli): readable data queries and uniform record output (#2981)

Call White30127761846d
diff --git a/core/session_handoff.py b/core/session_handoff.py
index 9e4139675..05f561e03 100644
--- a/core/session_handoff.py
+++ b/core/session_handoff.py
@@ -185,7 +185,7 @@ def _history_query(session_id: str) -> str | None:
"SELECT created_at, type, substr(content_text,1,2000) FROM messages"
f" WHERE session_id='{session_id}' ORDER BY created_at, id LIMIT 50 OFFSET 0"
)
- return f'vibe data query --sql "{sql}"'
+ return f'vibe data query --sql "{sql}" --format text'
def _open_work_lines(items: Sequence[Mapping[str, Any]]) -> list[str]:
diff --git a/docs/CLI.md b/docs/CLI.md
index b428bc346..47a87ace5 100644
--- a/docs/CLI.md
+++ b/docs/CLI.md
@@ -43,7 +43,8 @@ and one output rule.
`watch`, `show`, `vault`, `data query`, `data skill-usage`, `skill list`, and
`status`) print one JSON object on stdout:
`{"schema_version": 1, "ok": true, "kind": "<kind>", ...fields}`. They accept
- `--json`, which changes nothing.
+ `--json`, which changes nothing. `vibe data query --format text` prints rows
+ as readable records instead.
- **Failures** of those commands, and every argument error, print the same
envelope on stderr with `"ok": false`, `"kind": "error"`, a stable `code`, the
`error` text, and when useful a `hint`, `help_command`, and `details`. The exit
@@ -79,10 +80,17 @@ takes `--page` only.
List rows carry only what is needed to decide the next step and omit null,
empty, and zero-valued fields, so an absent field means unset. A Show Page row
is its `session_id`, `visibility`, `active_url` (the URL to share), `path` (the
-workspace to edit), and `updated_at`. `vibe task show`, `vibe watch show`,
-`vibe runs show`, `vibe session get`, `vibe agent show`, and `vibe show status`
-print the full record; add `--brief` to print exactly the row the matching list
-command prints. A removed Task or Watch shows `lifecycle_state: "removed"` and
+workspace to edit), and `updated_at`. An Agent row is its `name`, `backend`,
+`model`, `reasoning_effort`, `source`, and `updated_at`; a disabled Agent adds
+`enabled: false`. A Vault row, the same from `vibe vault list` and
+`vibe vault find`, is the secret's `name`, `kind`, `protection`, `fields` (a
+multi-field secret adds `default_field`, the field `NAME` alone selects),
+`tags`, `description`, `policy`, a keypair's `signing_addresses`, and
+`per_use_sign: true` when `vibe vault sign` can use the key; it never holds a
+value. `vibe task show`, `vibe watch show`, `vibe runs show`,
+`vibe session get`, `vibe agent show`, and `vibe show status` print the full
+record; add `--brief` to print exactly the row the matching list command
+prints. A removed Task or Watch shows `lifecycle_state: "removed"` and
`removed_at`, and none of the live fields (`enabled`, health, next fire, or
waiter state) it no longer has.
@@ -349,8 +357,17 @@ vibe data query --sql "select group_concat(name, ', ') as columns from pragma_ta
vibe data query --sql "PRAGMA table_info(run_definitions)" --limit 100 # with types and keys
vibe data query --sql "select id, status, created_at from agent_runs order by created_at desc"
vibe data query --sql-file query.sql --limit 50
+vibe data query --sql "select created_at, author, content_text from messages where session_id = 'sesk8m4q2p7x' order by created_at" --format text
```
+`--format text` prints each row as a record for reading long text such as a
+transcript or a message body: a `-[ RECORD n ]` line, then one `column: value`
+line per column. Values are printed as stored, with real newlines; a multi-line
+value starts on the line after its column name, indented two spaces, and SQL
+`NULL` prints as `(null)`. When more rows exist, the last line is
+`next_command: ...`, which keeps `--format text`. JSON stays the default, and
+errors are the JSON error envelope on stderr in both formats.
+
The connection is read-only: writes, schema changes, `ATTACH`, and transactions
are refused. The schema PRAGMAs `table_list`, `table_info`, `table_xinfo`,
`index_list`, `index_info`, and `foreign_key_list` run as statements or as
@@ -522,9 +539,13 @@ vibe runs show # inside an Avibe Agent shell, show the c
`vibe runs list` follows the [Session-owned list](#session-owned-lists) scope
grammar. `vibe runs show` can omit the run id inside an
Avibe-injected Agent run and defaults to `AVIBE_RUN_ID`. It prints the full
-record, with the text sent to the Agent as `message` and the reply as
-`result_text`; `--brief` prints the same compact row as `vibe runs list`, for
-status checks.
+record once: status and timing, `error`, the callback fields, the text sent to
+the Agent as `message`, the reply as `result_text`, and where the Run ran and
+came from (Agent, Session, `source_kind`, `source_session_id`,
+`parent_run_id`). Reply text delivered beside the final reply, such as a
+message sent mid-turn, is `other_outputs`; delivery bookkeeping, turn and
+process ids, and copies of other fields are not printed. `--brief` prints the
+same compact row as `vibe runs list`, for status checks.
### `vibe task`
diff --git a/docs/CLI_ZH.md b/docs/CLI_ZH.md
index 08a9971d5..674a3a759 100644
--- a/docs/CLI_ZH.md
+++ b/docs/CLI_ZH.md
@@ -38,7 +38,8 @@ vibe stop # 停止所有服务
`show`、`vault`、`data query`、`data skill-usage`、`skill list` 和 `status`)
在 stdout 输出一个 JSON 对象:
`{"schema_version": 1, "ok": true, "kind": "<kind>", ...字段}`。它们接受
- `--json`,但不改变任何行为。
+ `--json`,但不改变任何行为。`vibe data query --format text` 则把各行输出为便于
+ 阅读的记录。
- **失败**:这些命令的失败以及所有参数错误,都会在 stderr 输出同样的信封,其中
`"ok": false`、`"kind": "error"`,并带有稳定的 `code`、`error` 文本,必要时还有
`hint`、`help_command` 和 `details`。退出码非零。
@@ -66,7 +67,13 @@ list/find/tags、Show Page 的 list/marks、`vibe data query`、`vibe task list`
列表行只携带决定下一步所需的字段,并省略 null、空值和零值字段,因此缺失的字段即表示
未设置。Show Page 的列表行只有 `session_id`、`visibility`、`active_url`(用于分享的
-URL)、`path`(要编辑的工作目录)和 `updated_at`。`vibe task show`、`vibe watch show`、
+URL)、`path`(要编辑的工作目录)和 `updated_at`。Agent 的列表行是 `name`、
+`backend`、`model`、`reasoning_effort`、`source` 和 `updated_at`;已停用的 Agent
+另带 `enabled: false`。Vault 的列表行在 `vibe vault list` 和 `vibe vault find` 中
+相同,包括 secret 的 `name`、`kind`、`protection`、`fields`(多字段 secret 另带
+`default_field`,即单写 `NAME` 时选中的字段)、`tags`、`description`、`policy`、
+keypair 的 `signing_addresses`,以及 `vibe vault sign` 可用该密钥时的
+`per_use_sign: true`;行中从不包含 secret 值。`vibe task show`、`vibe watch show`、
`vibe runs show`、`vibe session get`、`vibe agent show` 和 `vibe show status` 输出完整
记录;加上 `--brief` 则只输出对应 list 命令打印的那一行。已删除的 Task 或 Watch 显示
`lifecycle_state: "removed"` 和 `removed_at`,不再带它已经没有的实时字段(`enabled`、
@@ -256,8 +263,15 @@ vibe data query --sql "select group_concat(name, ', ') as columns from pragma_ta
vibe data query --sql "PRAGMA table_info(run_definitions)" --limit 100 # 含类型与主键
vibe data query --sql "select id, status, created_at from agent_runs order by created_at desc"
vibe data query --sql-file query.sql --limit 50
+vibe data query --sql "select created_at, author, content_text from messages where session_id = 'sesk8m4q2p7x' order by created_at" --format text
```
+`--format text` 把每一行输出为一条记录,适合阅读对话记录或消息正文这类长文本:先是
+一行 `-[ RECORD n ]`,然后每列一行 `column: value`。值按存储原样输出,换行就是真实
+换行;多行的值从列名的下一行开始,缩进两个空格;SQL `NULL` 输出为 `(null)`。还有更多
+行时,最后一行是 `next_command: ...`,并保留 `--format text`。默认仍是 JSON;两种格式
+下的错误都是 stderr 上的 JSON 错误信封。
+
连接是只读的:写入、schema 变更、`ATTACH` 和事务都会被拒绝。schema PRAGMA
`table_list`、`table_info`、`table_xinfo`、`index_list`、`index_info` 和
`foreign_key_list` 可以作为语句执行,也可以作为 `pragma_*` 表值函数使用;其他
@@ -413,9 +427,12 @@ vibe runs show # 在 Avibe Agent shell 内查看调用
`vibe runs list` 遵循 [Session 归属的列表](#session-归属的列表) 的范围语法。
`vibe runs show` 在 Avibe 已注入 caller context 的 Agent run 内
-可以省略 run id,并默认使用 `AVIBE_RUN_ID`。它输出完整记录:发给 Agent 的文本在
-`message`,回复在 `result_text`;`--brief` 只输出与 `vibe runs list` 相同的精简行,
-用于查看状态。
+可以省略 run id,并默认使用 `AVIBE_RUN_ID`。它把完整记录的每项事实输出一次:状态与
+时间、`error`、回调字段、发给 Agent 的文本 `message`、回复 `result_text`,以及 Run
+在哪里运行、从哪里来(Agent、Session、`source_kind`、`source_session_id`、
+`parent_run_id`)。最终回复之外送达的回复文本(例如回合中途发出的消息)在
+`other_outputs`;投递记账、turn 与进程 id,以及其他字段的副本都不输出。`--brief`
+只输出与 `vibe runs list` 相同的精简行,用于查看状态。
### `vibe task`
diff --git a/modules/agents/vibey/context.py b/modules/agents/vibey/context.py
index 9ec97f42e..a86752770 100644
--- a/modules/agents/vibey/context.py
+++ b/modules/agents/vibey/context.py
@@ -140,7 +140,7 @@ def example_query(session_id: str, through_seq: int) -> Optional[str]:
f" WHERE session_id='{session_id}' AND type='user' AND context_seq <= {int(through_seq)}"
" ORDER BY context_seq LIMIT 50"
)
- return f'vibe data query --sql "{sql}"'
+ return f'vibe data query --sql "{sql}" --format text'
def _environment(fields: Mapping[str, EnvironmentValue]) -> str:
diff --git a/skills/use-avibe-harness/SKILL.md b/skills/use-avibe-harness/SKILL.md
index 2df32c0ac..97120e231 100644
--- a/skills/use-avibe-harness/SKILL.md
+++ b/skills/use-avibe-harness/SKILL.md
@@ -35,6 +35,8 @@ Use `vibe harness status` first for this Session's active Runs, armed Watches, u
Discover the schema before guessing names: `vibe data query --sql "select group_concat(name, ', ') as tables from pragma_table_list where schema = 'main'"` lists the tables in one row, and `vibe data query --sql "select group_concat(name, ', ') as columns from pragma_table_info('agent_runs')"` lists one table's columns; `PRAGMA table_info(agent_runs)` adds types and keys at one row per column. Schema PRAGMAs are the only PRAGMAs allowed. The Harness tables are `agents`, `agent_sessions`, `agent_runs`, `messages`, `scopes`, `scope_settings`, and `run_definitions`, which holds both Tasks and Watches (`definition_type` is `scheduled` or `watch`). A `no such table` or `no such column` error carries a `hint` with the closest names and the real columns, so read it before retrying.
+To read long text such as a Session transcript, message bodies, or a run's message and reply, add `--format text`: each row prints as a `-[ RECORD n ]` record with one `column: value` line per column, values as stored with real newlines (a multi-line value is indented under its column), and SQL `NULL` as `(null)`. For example, `vibe data query --sql "select created_at, author, content_text from messages where session_id = '<session-id>' order by created_at" --format text`. Read it directly instead of piping JSON through a script; the last line is `next_command: ...` when more rows exist.
+
`vibe task show <id>` and `vibe watch show <id>` still read a removed definition, with `lifecycle_state: "removed"` and `removed_at`; other commands on it fail with `task_removed` / `watch_removed`. `task_not_found` / `watch_not_found` means the id never existed.
Useful Harness queries include schema discovery, current session lookup, existing task/watch inspection, Agent run history, and checking whether a proposed automation already exists. Prefer this CLI over direct SQLite access.
diff --git a/skills/use-avibe-vault/SKILL.md b/skills/use-avibe-vault/SKILL.md
index 7cc963d77..e01d650c7 100644
--- a/skills/use-avibe-vault/SKILL.md
+++ b/skills/use-avibe-vault/SKILL.md
@@ -21,7 +21,7 @@ Rules:
- Static secrets can be used with `run` / `fetch`; keypair secrets can only be used with `vibe vault sign`. Keypairs do not accept field refs.
- Authorization is per secret: approving a protected secret unlocks **all its fields** for the grant's lifetime. The CLI cannot create, replace, or delete fields; the user does that in the browser.
- `--env NAME.field` delivers one value to `NAME_FIELD` (only the field is uppercased); `--env LOCAL=NAME.field` chooses the variable. `--tag` and `--skill` deliver every field of each selected secret, using `NAME` for the default and `NAME_FIELD` for extras. Conflicting variable mappings fail before delivery.
-- `list` and `find` return value-free `default_field` and `fields` metadata. If a ref fails with `field_not_found`, use the listed field names rather than guessing.
+- `list` and `find` print the same value-free row: a static secret lists its `fields`, and a multi-field secret also names its `default_field`, the field `NAME` selects. If a ref fails with `field_not_found`, use the listed field names rather than guessing.
- `export` remains deprecated and has no delivery. Prefer `run`; advanced `inject` writes a restricted-permission file, so use it only for tools that require file-based configuration.
- With `vibe vault run`, the child process receives static secrets as environment variables, so never run commands that may print env vars, debug config, or secret-bearing errors.
- When protected `run` / `fetch` needs approval, Avibe automatically asks the user to decrypt and authorize access, and the command waits for that approval (540 seconds by default; `--approval-wait SECONDS` or `--no-approval-wait` to change it). If the command then succeeds, it ran once: do not run it again. If it returns `approval_required`, `approval_wait_timeout`, or `approval_handed_off`, or your call to it is stopped before it gets the approval, the command did not run; Avibe resumes this session once the request is decided, and after an approval you run the same `run` / `fetch` command once.
diff --git a/tests/test_cli_pagination.py b/tests/test_cli_pagination.py
index 511b7555f..1150baf71 100644
--- a/tests/test_cli_pagination.py
+++ b/tests/test_cli_pagination.py
@@ -424,6 +424,87 @@ def test_runs_show_prints_the_run_text_once_and_brief_prints_the_list_row(monkey
assert (brief["status"], "message" in brief) == ("succeeded", False)
+def test_runs_show_prints_each_fact_once_without_delivery_bookkeeping(monkeypatch, tmp_path, capsys) -> None:
+ """The full record keeps what an Agent acts on and drops the reply's ledger and internals."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ paths.ensure_data_dirs()
+ provenance = {"turn_id": "trn_1", "run_id": "run-delegate", "detached": False}
+ store = SQLiteBackgroundTaskStore()
+ try:
+ store.enqueue_run(
+ {
+ "id": "run-delegate",
+ "request_type": "agent_run",
+ "status": "succeeded",
+ "agent_name": "helper",
+ "agent_id": "agent-internal-id",
+ "agent_backend": "codex",
+ "session_id": "ses-delegate",
+ "source_kind": "agent",
+ "source_actor": "ses-caller",
+ "message": "Review PR #1.",
+ "result_text": "No findings.",
+ "result_payload": {
+ "outputs": [
+ {"id": "msg_1", "text": "Reviewing now.", "provenance": provenance},
+ {"id": "terminal", "text": "No findings.", "provenance": provenance},
+ ]
+ },
+ "message_ids": ["msg_1"],
+ "pid": 4242,
+ "created_at": "2026-05-25T00:00:00+00:00",
+ "completed_at": "2026-05-25T00:05:00+00:00",
+ "updated_at": "2026-05-25T00:05:00+00:00",
+ "metadata": {
+ "caller_context": {"session_id": "ses-caller", "channel_id": "ses-caller"},
+ "delivery_intent": "steer",
+ "delivery_outcome": {"intent": "steer", "status": "claimed"},
+ "last_activity_at": "2026-05-25T00:04:00+00:00",
+ "turn_id": "trn_1",
+ "close_after": True,
+ },
+ }
+ )
+ # A callback names the Session its result came from only in metadata.
+ store.enqueue_run(
+ {
+ "id": "run-callback",
+ "request_type": "agent_run",
+ "status": "queued",
+ "session_id": "ses-caller",
+ "source_kind": "callback",
+ "source_actor": "run-delegate",
+ "parent_run_id": "run-delegate",
+ "message": "No findings.",
+ "created_at": "2026-05-25T00:05:00+00:00",
+ "metadata": {"source_session_id": "ses-delegate", "callback_parent_run_id": "run-delegate"},
+ }
+ )
+ finally:
+ store.close()
+
+ assert cli.cmd_runs_show(cli.build_parser().parse_args(["runs", "show", "run-delegate"])) == 0
+ out = capsys.readouterr().out
+ run = json.loads(out)["run"]
+ assert out.count("No findings.") == 1
+ assert (run["result_text"], run["other_outputs"]) == ("No findings.", ["Reviewing now."])
+ assert run["source_session_id"] == "ses-caller"
+ assert run["last_activity_at"] == "2026-05-25T00:04:00+00:00"
+ assert run["metadata"] == {"close_after": True}
+ for omitted in (
+ "result_payload", "message_ids", "pid", "ok", "cancel_requested",
+ "agent_id", "updated_at", "source_actor",
+ ):
+ assert omitted not in run
+
+ monkeypatch.setattr(cli, "_live_session_runtime_for_run", lambda run: None)
+ assert cli.cmd_runs_show(cli.build_parser().parse_args(["runs", "show", "run-callback"])) == 0
+ callback = json.loads(capsys.readouterr().out)["run"]
+ assert (callback["source_session_id"], callback["parent_run_id"]) == ("ses-delegate", "run-delegate")
+ assert "source_actor" not in callback and "metadata" not in callback
+
+
def test_runs_show_attaches_live_session_owner_for_queued_run(monkeypatch, tmp_path, capsys) -> None:
"""HFR-002: CLI diagnosis names the authoritative live Session owner."""
@@ -544,6 +625,38 @@ def test_data_query_cli_omits_next_command_for_stdin_sql(monkeypatch, tmp_path,
assert payload["message"] == "More records are available. Add --page to continue."
+def test_data_query_text_prints_records_with_values_verbatim_and_pages(monkeypatch, tmp_path, capsys) -> None:
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ paths.ensure_data_dirs()
+ SQLiteBackgroundTaskStore().close()
+ sql = (
+ "select 'Line one' || char(10) || 'He said \"hi\"' as body, null as gone, 7 as n "
+ "union all select 'second', '', 8 union all select 'third', 'x', 9"
+ )
+
+ args = cli.build_parser().parse_args(["data", "query", "--sql", sql, "--limit", "2", "--format", "text"])
+ assert cli.cmd_data_query(args) == 0
+ *records, next_line = capsys.readouterr().out.splitlines()
+ assert records == [
+ "-[ RECORD 1 ]",
+ "body:",
+ " Line one",
+ ' He said "hi"',
+ "gone: (null)",
+ "n: 7",
+ "-[ RECORD 2 ]",
+ "body: second",
+ "gone:",
+ "n: 8",
+ ]
+ label, next_command = next_line.split(": ", 1)
+ assert label == "next_command"
+
+ args = cli.build_parser().parse_args(shlex.split(next_command)[1:])
+ assert cli.cmd_data_query(args) == 0
+ assert capsys.readouterr().out.splitlines() == ["-[ RECORD 3 ]", "body: third", "gone: x", "n: 9"]
+
+
@pytest.mark.parametrize(
("sql", "fragments"),
[
diff --git a/tests/test_cli_task_command.py b/tests/test_cli_task_command.py
index f96775f08..50ee12f8c 100644
--- a/tests/test_cli_task_command.py
+++ b/tests/test_cli_task_command.py
@@ -200,7 +200,7 @@ def test_agent_remove_cli_archives_agent(tmp_path: Path, capsys, sqlite_schema_d
payload = json.loads(capsys.readouterr().out)
assert payload["removed_agent"] == "worker"
assert payload["archived_agent"]["name"].startswith("_worker-")
- assert payload["archived_agent"]["display_name"] == "worker"
+ assert payload["archived_agent"]["archived_at"]
assert agent_store.get("worker") is None
finally:
agent_store.close()
@@ -294,7 +294,16 @@ def test_agent_list_is_bounded_and_compact_by_default(tmp_path: Path, capsys, sq
payload = json.loads(capsys.readouterr().out)
assert len(payload["agents"]) == 20
- assert "system_prompt" not in payload["agents"][0]
+ # The Agent's key and what it runs on; the unset effort and the default enabled
+ # state are absent.
+ stored = agent_store.get("worker-00")
+ assert payload["agents"][0] == {
+ "name": "worker-00",
+ "backend": "codex",
+ "model": stored.model,
+ "source": "user",
+ "updated_at": stored.updated_at,
+ }
assert payload["pagination"]["next_command"] == "vibe agent list --page 2 --limit 20"
diff --git a/tests/test_session_cli.py b/tests/test_session_cli.py
index 907b23df2..2f6415489 100644
--- a/tests/test_session_cli.py
+++ b/tests/test_session_cli.py
@@ -63,14 +63,23 @@ def test_list_excludes_archived_and_orders_by_activity(monkeypatch, tmp_path, ca
assert "message" not in payload
-def test_list_row_has_only_lean_fields(monkeypatch, tmp_path, capsys):
+def test_list_row_has_only_lean_present_fields(monkeypatch, tmp_path, capsys):
+ from core.services import sessions as sessions_service
+
engine = _setup(monkeypatch, tmp_path)
_seed(engine, "sesaaa", platform="slack", native="C1")
+ with engine.begin() as conn:
+ standalone = sessions_service.create_session(
+ conn, scope_id=None, agent_backend="codex", agent_name="codex", visibility="foreground"
+ )
_, payload = _run(cli.cmd_session_list, ["session", "list"], capsys)
- row = payload["sessions"][0]
+ rows = {row["id"]: row for row in payload["sessions"]}
+ row = rows["sesaaa"]
assert set(row) == {"id", "title", "platform", "project_id", "agent_name", "agent_status", "last_active_at"}
assert row["platform"] == "slack"
assert "agent_backend" not in row and "status" not in row
+ # An untitled standalone Session has no title, platform, or project: the keys are absent.
+ assert set(rows[standalone["id"]]) == {"id", "agent_name", "agent_status", "last_active_at"}
def test_list_type_filter(monkeypatch, tmp_path, capsys):
diff --git a/tests/test_vault_cli.py b/tests/test_vault_cli.py
index 13cef546a..3dc3ce938 100644
--- a/tests/test_vault_cli.py
+++ b/tests/test_vault_cli.py
@@ -92,6 +92,11 @@ def _create_standard_secret(name: str, *, sealed: Sealed | None = None, **kwargs
return vault_service.create_secret(conn, name=name, sealed=sealed or _sealed(), **kwargs)
+def _secret_meta(name: str) -> dict:
+ with cli._open_vault_engine().connect() as conn:
+ return vault_service.get_secret_meta(conn, name)
+
+
def _grant_from_request(conn, request: dict, *, session_id: str | None = None) -> dict:
option = request["card"]["grant_options"][0]
return vault_service.create_grant(
@@ -438,22 +443,19 @@ def test_provision_field_hint_predicate_is_shared_across_callback_and_sync(metad
assert f"--env {metadata['name']} --" in sync and ".value" not in sync
-def test_find_reports_value_free_capabilities(tmp_path, capfd, monkeypatch):
[email protected]("command", ["list", "find"])
+def test_list_and_find_print_the_same_value_free_row(capfd, command):
_create_standard_secret("STANDARD_KEY")
+ _create_standard_secret(
+ "LOGIN",
+ default_field="password",
+ fields=[{"name": "username", "sealed": _sealed("user")}],
+ tags=["github"],
+ description="GitHub login",
+ policy={"allowed_hosts": ["github.com"], "auth": {"type": "bearer"}},
+ )
with cli._open_vault_engine().begin() as conn:
- vault_service.create_secret(
- conn,
- name="ETH_KEY",
- kind="keypair",
- signer_kind="local",
- sealed=_sealed("key"),
- )
- vault_service.create_secret(
- conn,
- name="PROTECTED_STATIC_KEY",
- protection="protected",
- sealed=_sealed("protected-static"),
- )
+ vault_service.create_secret(conn, name="ETH_KEY", kind="keypair", signer_kind="local", sealed=_sealed("key"))
vault_service.create_secret(
conn,
name="PROTECTED_ETH_KEY",
@@ -464,35 +466,36 @@ def test_find_reports_value_free_capabilities(tmp_path, capfd, monkeypatch):
public_meta=PROTECTED_SIGNING_PUBLIC_META,
)
vault_service.create_secret(
- conn,
- name="REMOTE_ETH_KEY",
- kind="keypair",
- signer_kind="remote",
- sealed=_sealed("remote-key"),
+ conn, name="REMOTE_ETH_KEY", kind="keypair", signer_kind="remote", sealed=_sealed("remote-key")
)
- assert cli.cmd_vault_find(_ns()) == 0
+ assert getattr(cli, f"cmd_vault_{command}")(_ns()) == 0
payload = json.loads(capfd.readouterr().out)
- assert payload["kind"] == "vault_find"
secrets = {item["name"]: item for item in payload["secrets"]}
+ # Unset and false fields are absent; usage counters, timestamps, and signer
+ # internals are not row fields.
assert secrets["STANDARD_KEY"] == {
"name": "STANDARD_KEY",
"kind": "static",
"protection": "standard",
- "default_field": "value",
"fields": ["value"],
- "tags": [],
- "description": None,
- "policy": {},
- "access_grantable": True,
- "per_use_sign": False,
}
- assert secrets["ETH_KEY"]["per_use_sign"] is True
- assert secrets["PROTECTED_STATIC_KEY"]["access_grantable"] is True
+ assert secrets["LOGIN"] == {
+ "name": "LOGIN",
+ "kind": "static",
+ "protection": "standard",
+ "fields": ["password", "username"],
+ "default_field": "password",
+ "tags": ["github"],
+ "description": "GitHub login",
+ "policy": {"allowed_hosts": ["github.com"], "auth": {"type": "bearer"}},
+ }
+ # A keypair takes no field refs; it says whether ``vibe vault sign`` can use it.
+ assert secrets["ETH_KEY"] == {"name": "ETH_KEY", "kind": "keypair", "protection": "standard", "per_use_sign": True}
+ assert secrets["REMOTE_ETH_KEY"] == {"name": "REMOTE_ETH_KEY", "kind": "keypair", "protection": "standard"}
assert secrets["PROTECTED_ETH_KEY"]["per_use_sign"] is True
- assert secrets["REMOTE_ETH_KEY"]["per_use_sign"] is False
- assert "sk-" not in json.dumps(payload)
+ assert "ct-" not in json.dumps(payload)
def test_list_paginates_through_next_command_alone(capfd):
@@ -571,13 +574,8 @@ def test_tags_lists_normal_and_skill_tags(capfd):
payload = json.loads(capfd.readouterr().out)
tags = {item["tag"]: item for item in payload["tags"]}
- assert tags["openai"] == {"tag": "openai", "type": "tag", "secret_count": 2}
- assert tags["skill:model-work"] == {
- "tag": "skill:model-work",
- "type": "skill",
- "secret_count": 2,
- "skill": "model-work",
- }
+ assert tags["openai"] == {"tag": "openai", "secret_count": 2}
+ assert tags["skill:model-work"] == {"tag": "skill:model-work", "secret_count": 2}
def test_tags_filters_skill_tags_by_query(capfd):
@@ -1072,8 +1070,7 @@ def test_run_calls_avault_with_env_mapping_and_records_delivery(tmp_path, capfd,
[{"name": "SRC_KEY", "env": "LOCAL_NAME", "envelope": _sealed("run"), "tier": "standard"}],
["python3", "-c", "pass"],
)
- cli.cmd_vault_list(_ns())
- secret = json.loads(capfd.readouterr().out)["secrets"][0]
+ secret = _secret_meta("SRC_KEY")
assert secret["use_count"] == 1
assert secret["last_used_at"] is not None
@@ -2672,9 +2669,7 @@ def test_run_records_protected_delivery_when_child_exits_70(capfd, monkeypatch):
monkeypatch.setattr(api, "avault_deliver_run", Mock())
assert cli.cmd_vault_run(_ns(env=["PROTECTED_KEY"], command_argv=["python3", "-c", "pass"])) == 70
- cli.cmd_vault_list(_ns())
- secret = json.loads(capfd.readouterr().out)["secrets"][0]
- assert secret["use_count"] == 1
+ assert _secret_meta("PROTECTED_KEY")["use_count"] == 1
def test_run_records_delivery_when_legacy_avault_returns_70(tmp_path, capfd, monkeypatch):
@@ -2686,9 +2681,7 @@ def test_run_records_delivery_when_legacy_avault_returns_70(tmp_path, capfd, mon
monkeypatch.setattr(api, "avault_deliver_run", Mock(return_value=70))
assert cli.cmd_vault_run(_ns(env=["NODELIVER_KEY"], command_argv=["python3", "-c", "pass"])) == 70
- cli.cmd_vault_list(_ns())
- secret = json.loads(capfd.readouterr().out)["secrets"][0]
- assert secret["use_count"] == 1
+ assert _secret_meta("NODELIVER_KEY")["use_count"] == 1
def test_run_releases_standard_always_ask_grant_on_explicit_pre_handoff_failure(tmp_path, capfd, monkeypatch):
@@ -2700,9 +2693,7 @@ def test_run_releases_standard_always_ask_grant_on_explicit_pre_handoff_failure(
monkeypatch.setattr(api, "avault_deliver_run", Mock(return_value={"exit_code": 70, "delivered": False}))
assert cli.cmd_vault_run(_ns(env=["ASK_KEY"], command_argv=["python3", "-c", "pass"], session_id="ses_cli")) == 70
- cli.cmd_vault_list(_ns())
- secret = json.loads(capfd.readouterr().out)["secrets"][0]
- assert secret["use_count"] == 0
+ assert _secret_meta("ASK_KEY")["use_count"] == 0
with cli._open_vault_engine().connect() as conn:
status = conn.execute(vault_grants.select().where(vault_grants.c.id == grant["id"])).mappings().one()["status"]
assert status == "active"
@@ -2722,8 +2713,7 @@ def test_run_bad_command_does_not_call_avault_or_deliver(tmp_path, capfd, monkey
assert code == 1
assert json.loads(captured.err)["code"] == "command_not_found"
deliver.assert_not_called()
- cli.cmd_vault_list(_ns())
- assert json.loads(capfd.readouterr().out)["secrets"][0]["use_count"] == 0
+ assert _secret_meta("NODELIVER_KEY")["use_count"] == 0
def test_run_missing_secret_is_clean_error(capfd):
diff --git a/tests/test_vault_export_inject.py b/tests/test_vault_export_inject.py
index 864e042d3..3ac4a9843 100644
--- a/tests/test_vault_export_inject.py
+++ b/tests/test_vault_export_inject.py
@@ -39,6 +39,11 @@ def _sealed(suffix: str = "1") -> Sealed:
return Sealed(ciphertext=f"ct-{suffix}", nonce=f"n-{suffix}", wrap_meta=f"wm-{suffix}")
+def _use_count(name: str) -> int:
+ with cli._open_vault_engine().connect() as conn:
+ return vault_service.get_secret_meta(conn, name)["use_count"]
+
+
def _create_standard_secret(
name: str,
*,
@@ -118,10 +123,8 @@ def test_inject_calls_avault_and_records_delivery(tmp_path, capfd, monkeypatch,
{"name": "B_KEY", "key": "B_KEY", "envelope": _sealed("b"), "tier": "standard"},
],
)
- cli.cmd_vault_list(_ns())
- secrets = {s["name"]: s for s in json.loads(capfd.readouterr().out)["secrets"]}
- assert secrets["A_KEY"]["use_count"] == 1
- assert secrets["B_KEY"]["use_count"] == 1
+ assert _use_count("A_KEY") == 1
+ assert _use_count("B_KEY") == 1
def test_inject_canonicalizes_default_alias_and_maps_extra_field_key(tmp_path, capfd, monkeypatch):
@@ -532,8 +535,7 @@ def test_inject_dedupes_repeated_keys(tmp_path, capfd, monkeypatch):
"dotenv",
[{"name": "A_KEY", "key": "A_KEY", "envelope": _sealed("a"), "tier": "standard"}],
)
- cli.cmd_vault_list(_ns())
- assert json.loads(capfd.readouterr().out)["secrets"][0]["use_count"] == 1
+ assert _use_count("A_KEY") == 1
def test_inject_payload_does_not_leak_value(tmp_path, capfd, monkeypatch):
@@ -561,8 +563,7 @@ def test_inject_does_not_record_delivery_when_avault_fails(tmp_path, capfd, monk
captured = capfd.readouterr()
assert code == 1
assert json.loads(captured.err)["code"] == "avault_failed"
- cli.cmd_vault_list(_ns())
- assert json.loads(capfd.readouterr().out)["secrets"][0]["use_count"] == 0
+ assert _use_count("A_KEY") == 0
def test_inject_succeeds_even_if_audit_fails(tmp_path, capfd, monkeypatch):
diff --git a/tests/test_vibey_agent_context.py b/tests/test_vibey_agent_context.py
index dcf7d208f..b3c2d04ac 100644
--- a/tests/test_vibey_agent_context.py
+++ b/tests/test_vibey_agent_context.py
@@ -397,7 +397,7 @@ async def test_the_earlier_record_example_runs_through_the_real_read_only_guard(
hint = VibeyContextHost(engine, environment=lambda _: {}).earlier_record(SESSION, 3)
(line,) = [line for line in hint.splitlines() if line.startswith("vibe data query ")]
argv = shlex.split(line)
- assert argv[:4] == ["vibe", "data", "query", "--sql"] and len(argv) == 5
+ assert argv[:4] == ["vibe", "data", "query", "--sql"] and argv[5:] == ["--format", "text"]
sql = argv[4]
assert "WITH" not in sql.upper().split()[0] and "json" not in sql.lower()
result = run_read_only_query(sql, db_path=Path(engine.url.database), page_request=PageRequest())
diff --git a/vibe/cli.py b/vibe/cli.py
index 59e9eb7d3..abb7e3096 100644
--- a/vibe/cli.py
+++ b/vibe/cli.py
@@ -2530,10 +2530,42 @@ _WORKBENCH_SESSION_LABEL_FIELDS = frozenset(
_CLI_OMITTED_DEFINITION_FIELDS = _CLI_LEGACY_FIELDS | _WORKBENCH_SESSION_LABEL_FIELDS | {"prefix"}
#: ``request_type`` repeats ``run_type`` and ``task_id`` repeats ``definition_id``;
#: ``callback_session`` and ``source_session`` are Workbench labels of two more Sessions.
+#: ``result_payload`` is the reply's delivery ledger (``result_text`` and
+#: ``other_outputs`` carry its text); ``message_ids``, ``delivery_id``, and
+#: ``callback_terminal_turn_id`` are delivery bookkeeping; ``ok`` repeats
+#: ``status``; ``agent_id`` is not the Agent's key (``agent_name`` is); and
+#: ``updated_at`` is the record's write stamp, which ``last_activity_at`` and
+#: ``completed_at`` already report.
_CLI_OMITTED_RUN_FIELDS = (
_CLI_LEGACY_FIELDS
| _WORKBENCH_SESSION_LABEL_FIELDS
| {"request_type", "task_id", "callback_session", "source_session"}
+ | {"result_payload", "message_ids", "delivery_id", "callback_terminal_turn_id"}
+ | {"pid", "ok", "agent_id", "updated_at"}
+)
+#: Run metadata the CLI never prints: delivery and scheduler bookkeeping, the
+#: caller's raw routing identity (``source_*`` fields carry the lineage), turn
+#: ids, and copies of fields the Run prints at the top level.
+_CLI_INTERNAL_RUN_METADATA_KEYS = frozenset(
+ {
+ "delivery_intent",
+ "delivery_outcome",
+ "delivered_reports",
+ "owed_failure_notice",
+ "turn_failure_notification",
+ "watch_recent_event_timestamps",
+ "watch_lifetime_started_at",
+ "task_schedule_consumed",
+ "job_watch_authorization",
+ "caller_context",
+ "created_by",
+ "turn_id",
+ "callback_terminal_turn_id",
+ "callback_parent_run_id",
+ "last_activity_at",
+ "session_fork",
+ "source_session_id",
+ }
)
@@ -3883,19 +3915,20 @@ def _watch_mutation_payload(watch, runtime_entry: Optional[dict[str, object]]) -
def _agent_payload(agent, *, brief: bool = False) -> dict:
payload = agent.to_dict()
if brief:
- return {
- "id": payload["id"],
- "name": payload["name"],
- "display_name": payload["display_name"],
- "backend": payload["backend"],
- "model": payload["model"],
- "reasoning_effort": payload["reasoning_effort"],
- "enabled": payload["enabled"],
- "archived": payload["archived"],
- "archived_at": payload["archived_at"],
- "source": payload["source"],
- "updated_at": payload["updated_at"],
- }
+ # ``name`` is the Agent's key. Only a disabled Agent says ``enabled: false``;
+ # only an archived one has ``archived_at``.
+ return _present_fields(
+ {
+ "name": payload["name"],
+ "backend": payload["backend"],
+ "model": payload["model"],
+ "reasoning_effort": payload["reasoning_effort"],
+ "enabled": None if payload["enabled"] else False,
+ "archived_at": payload["archived_at"],
+ "source": payload["source"],
+ "updated_at": payload["updated_at"],
+ }
+ )
return payload
@@ -3933,12 +3966,45 @@ def _run_payload(run: dict, *, brief: bool = False) -> dict:
"callback_run_id": normalized.get("callback_run_id"),
}
)
- normalized["metadata"] = public_message_metadata(normalized.get("metadata") or {})
+ metadata = public_message_metadata(normalized.get("metadata") or {})
+ normalized["metadata"] = {
+ key: value for key, value in metadata.items() if key not in _CLI_INTERNAL_RUN_METADATA_KEYS
+ }
normalized["run_type"] = normalized.get("run_type") or normalized.get("request_type")
normalized["definition_id"] = normalized.get("definition_id") or normalized.get("task_id")
- return _present_fields(
- {key: value for key, value in normalized.items() if key not in _CLI_OMITTED_RUN_FIELDS}
- )
+ # A callback names the Session its result came from only in metadata.
+ normalized["source_session_id"] = normalized.get("source_session_id") or metadata.get("source_session_id")
+ # ``source_actor`` is printed only when it is not the source Session or parent Run.
+ if normalized.get("source_actor") in {normalized.get("source_session_id"), normalized.get("parent_run_id")}:
+ normalized["source_actor"] = None
+ normalized["cancel_requested"] = normalized.get("cancel_requested") or None
+ normalized["definition_deleted"] = normalized.get("definition_deleted") or None
+ detail: dict = {}
+ for key, value in normalized.items():
+ if key not in _CLI_OMITTED_RUN_FIELDS:
+ detail[key] = value
+ if key == "result_text":
+ detail["other_outputs"] = _run_other_outputs(normalized)
+ return _present_fields(detail)
+
+
+def _run_other_outputs(run: Mapping[str, object]) -> list[str]:
+ """Reply text the Run delivered that ``result_text`` does not already hold.
+
+ Almost every delivered output is the final reply ``result_text`` repeats; a
+ message sent mid-turn, or the only reply of a Run that ended without
+ ``result_text``, is not.
+ """
+
+ payload = run.get("result_payload")
+ outputs = payload.get("outputs") if isinstance(payload, dict) else None
+ result_text = str(run.get("result_text") or "")
+ texts: list[str] = []
+ for output in outputs if isinstance(outputs, list) else []:
+ text = output.get("text") if isinstance(output, dict) else None
+ if isinstance(text, str) and text.strip() and text not in result_text and text not in texts:
+ texts.append(text)
+ return texts
def cmd_harness_status(args) -> int:
@@ -7380,6 +7446,36 @@ def cmd_data_skill_usage(args):
return 1
+def _query_records_text(result, page_fields: dict) -> str:
+ """``vibe data query --format text``: each row as an expanded record, values verbatim.
+
+ JSON escapes every newline and quote of a transcript or message body, so
+ Agents re-printed rows just to read them. A multi-line value starts on the
+ line after its column name, indented two spaces; SQL NULL prints ``(null)``.
+ """
+
+ lines: list[str] = []
+ offset = (result.pagination.page - 1) * result.pagination.limit
+ for number, row in enumerate(result.rows, start=offset + 1):
+ lines.append(f"-[ RECORD {number} ]")
+ for column, value in row.items():
+ text = "(null)" if value is None else str(value)
+ value_lines = text.splitlines()
+ if len(value_lines) > 1:
+ lines.append(f"{column}:")
+ lines.extend(f" {line}" if line else "" for line in value_lines)
+ else:
+ lines.append(f"{column}: {text}" if text else f"{column}:")
+ if not result.rows:
+ lines.append("(0 rows)")
+ pagination = page_fields["pagination"]
+ if pagination.get("next_command"):
+ lines.append(f"next_command: {pagination['next_command']}")
+ elif page_fields.get("message"):
+ lines.append(page_fields["message"])
+ return "\n".join(lines)
+
+
def cmd_data_query(args):
try:
sql = getattr(args, "sql", None)
@@ -7396,17 +7492,19 @@ def cmd_data_query(args):
_add_optional_arg(command, "--sql", getattr(args, "sql", None))
elif sql_file and sql_file != "-":
_add_optional_arg(command, "--sql-file", sql_file)
+ text_format = getattr(args, "format", "json") == "text"
+ if text_format:
+ command.extend(["--format", "text"])
omit_next_command = bool(sql_file == "-")
- payload = {
- "columns": result.columns,
- "rows": result.rows,
- **_paginated_fields(
- result.pagination,
- command=command,
- include_next_command=not omit_next_command,
- ),
- }
- _print_cli_payload("data_query", **payload)
+ page_fields = _paginated_fields(
+ result.pagination,
+ command=command,
+ include_next_command=not omit_next_command,
+ )
+ if text_format:
+ print(_query_records_text(result, page_fields))
+ return 0
+ _print_cli_payload("data_query", columns=result.columns, rows=result.rows, **page_fields)
return 0
except ReadOnlyQueryError as exc:
_print_task_error(
@@ -7440,7 +7538,7 @@ _SESSION_GET_OMIT = ("status", "session_anchor", "agent_id")
def _session_row(payload: dict, *, brief: bool) -> dict:
if brief:
- return {key: payload.get(key) for key in _SESSION_LIST_FIELDS}
+ return _present_fields({key: payload.get(key) for key in _SESSION_LIST_FIELDS})
return {key: value for key, value in payload.items() if key not in _SESSION_GET_OMIT}
@@ -8184,21 +8282,31 @@ def _vault_page_payload(
return result.items, _paginated_fields(result, command=command)["pagination"]
-def _vault_capability_payload(secret: dict) -> dict:
+def _vault_secret_row(secret: dict) -> dict:
+ """One ``vibe vault list`` / ``find`` row: what an Agent picks a secret by, never its value.
+
+ Only a static secret has fields to reference, and ``NAME`` alone selects the
+ default one, so ``default_field`` is named only when there are several. A
+ keypair says ``per_use_sign: true`` when ``vibe vault sign`` can use it.
+ """
+
default_field = secret.get("default_field") or "value"
- return {
- "name": secret["name"],
- "kind": secret.get("kind"),
- "protection": secret.get("protection"),
- "default_field": default_field,
- "fields": secret.get("fields") or [default_field],
- **({"fields_state": "corrupt"} if secret.get("fields_state") == "corrupt" else {}),
- "tags": secret.get("tags") or [],
- "description": secret.get("description"),
- "policy": secret.get("policy") or {},
- "access_grantable": bool(secret.get("access_grantable")),
- "per_use_sign": bool(secret.get("per_use_sign")),
- }
+ fields = (secret.get("fields") or [default_field]) if secret.get("kind") != "keypair" else []
+ return _present_fields(
+ {
+ "name": secret["name"],
+ "kind": secret.get("kind"),
+ "protection": secret.get("protection"),
+ "fields": fields,
+ "default_field": default_field if len(fields) > 1 else None,
+ "fields_state": "corrupt" if secret.get("fields_state") == "corrupt" else None,
+ "tags": secret.get("tags"),
+ "description": secret.get("description"),
+ "policy": secret.get("policy"),
+ "signing_addresses": secret.get("signing_addresses"),
+ "per_use_sign": bool(secret.get("per_use_sign")) or None,
+ }
+ )
def cmd_vault_list(args):
@@ -8224,7 +8332,7 @@ def cmd_vault_list(args):
_add_optional_arg(command, "--kind", getattr(args, "kind", None))
_add_optional_arg(command, "--protection", getattr(args, "protection", None))
page_items, page_payload = _vault_page_payload(
- items=secrets,
+ items=[_vault_secret_row(secret) for secret in secrets],
args=args,
help_command=help_command,
command=command,
@@ -8269,9 +8377,8 @@ def cmd_vault_find(args):
_add_optional_arg(command, "--tag", tag)
_add_optional_arg(command, "--kind", getattr(args, "kind", None))
_add_optional_arg(command, "--protection", getattr(args, "protection", None))
- capabilities = [_vault_capability_payload(secret) for secret in secrets]
page_items, page_payload = _vault_page_payload(
- items=capabilities,
+ items=[_vault_secret_row(secret) for secret in secrets],
args=args,
help_command=help_command,
command=command,
@@ -8281,7 +8388,7 @@ def cmd_vault_find(args):
"pagination": page_payload,
}
if not page_items:
- payload["message"] = "No Vault capabilities matched. Try a broader keyword, inspect `vibe vault tags`, or request a missing static secret with `vibe vault request NAME --reason ...`."
+ payload["message"] = "No Vault secrets matched. Try a broader keyword, inspect `vibe vault tags`, or request a missing static secret with `vibe vault request NAME --reason ...`."
_print_cli_payload("vault_find", **payload)
return 0
except TaskCliError as exc:
@@ -8307,7 +8414,8 @@ def cmd_vault_tags(args):
_add_optional_arg(command, "--q", getattr(args, "query_filter", None))
_add_optional_arg(command, "--type", getattr(args, "type", None))
page_items, page_payload = _vault_page_payload(
- items=tags,
+ # A skill tag says it is one by its ``skill:`` prefix.
+ items=[{"tag": tag["tag"], "secret_count": tag["secret_count"]} for tag in tags],
args=args,
help_command=help_command,
command=command,
@@ -17472,8 +17580,8 @@ def build_parser():
vault_find_parser = vault_subparsers.add_parser(
"find",
- help="Find requestable secrets and signing keys",
- description="Search value-free Vault capabilities for agents: name, kind, protection tier, tags, fetch policy, access grantability, and per-use signing.",
+ help="Search secrets and signing keys by keyword",
+ description="Search Vault secrets by keyword, 20 per page by default. Rows are the same value-free rows 'vibe vault list' prints.",
formatter_class=argparse.RawDescriptionHelpFormatter,
error_help_command="vibe vault find --help",
)
@@ -17822,7 +17930,9 @@ def build_parser():
" vibe data query --sql \"select group_concat(name, ', ') as columns from pragma_table_info('run_definitions')\"\n"
" vibe data query --sql \"PRAGMA table_info(run_definitions)\" --limit 100 # with types and keys\n"
f"Only schema PRAGMAs run: {', '.join(sorted(SCHEMA_PRAGMAS))}.\n"
- "Tasks and Watches are rows of run_definitions (definition_type is scheduled or watch)."
+ "Tasks and Watches are rows of run_definitions (definition_type is scheduled or watch).\n"
+ "Read long text such as a transcript as records with real newlines:\n"
+ " vibe data query --sql \"select created_at, author, content_text from messages where session_id = 'ses...' order by created_at\" --format text"
),
formatter_class=argparse.RawDescriptionHelpFormatter,
error_help_command="vibe data query --help",
@@ -17830,6 +17940,12 @@ def build_parser():
sql_group = data_query_parser.add_mutually_exclusive_group(required=True)
sql_group.add_argument("--sql", help="SQL SELECT/WITH statement or schema PRAGMA to run.")
sql_group.add_argument("--sql-file", help="Read SQL from a UTF-8 file, or '-' for stdin.")
+ data_query_parser.add_argument(
+ "--format",
+ choices=("json", "text"),
+ default="json",
+ help="json (default) prints the JSON envelope; text prints each row as a record with values verbatim.",
+ )
_add_pagination_args(data_query_parser, help_command="vibe data query --help")
_add_json_noop(data_query_parser)
data_retention_parser = data_subparsers.add_parser(