Files
openclaw/src/cli/program/register.audit.ts
Peter Steinberger 7a466b33f3 feat: add metadata-only message audit events (#103903)
* feat: add metadata-only message audit events

* chore(protocol): restore generated swift models and config baseline after rebase

* fix(state): gate agent-db ownership check before schema version

* fix(cli): sync audit command description into the root-help catalog

* fix(audit): require destination proof before classifying outbound messages as direct

* refactor(audit): drop dead migration guard and add contract comments

* docs(gateway): add dedicated audit history page and cross-links

* test(e2e): enable direct-mode message audit in the telegram proof SUT config

* test(channels): expect declared conversationKind in durable delivery session context

* fix(audit): record the routing channel id for inbound rows from plugin channels

* fix(audit): match channel-prefixed delivery targets in the destination route gate

* fix(audit): validate explicit target kind against the destination route kind

* fix(audit): use the canonical target-prefix grammar in the destination route gate and fail closed on foreign migration tables

* fix(audit): normalize nested provider and kind target prefixes in the destination gate

* fix(audit): strip registered provider aliases and the direct kind prefix in the destination gate

* chore(docs): refresh config baseline after rebase
2026-07-11 13:14:08 -07:00

56 lines
2.6 KiB
TypeScript

// Audit command registration for privacy-preserving activity history.
import type { Command } from "commander";
import { formatDocsLink } from "../../../packages/terminal-core/src/links.js";
import { theme } from "../../../packages/terminal-core/src/theme.js";
import { auditListCommand, type AuditListCommandOptions } from "../../commands/audit.js";
import { defaultRuntime } from "../../runtime.js";
import { runCommandWithRuntime } from "../cli-utils.js";
/** Register the bounded operator audit query command. */
export function registerAuditCommand(program: Command): void {
program
.command("audit")
.description("Inspect metadata-only run, tool, and message lifecycle records")
.option("--agent <id>", "Filter by agent id")
.option("--session <key>", "Filter by exact session key")
.option("--run <id>", "Filter by run id")
.option("--kind <kind>", "Filter by kind (agent_run, tool_action, or message)")
.option(
"--status <status>",
"Filter by status (started, succeeded, failed, cancelled, timed_out, blocked, unknown)",
)
.option("--direction <direction>", "Filter message direction (inbound or outbound)")
.option("--channel <channel>", "Filter message channel")
.option("--after <timestamp>", "Include records at/after ISO time or Unix milliseconds")
.option("--before <timestamp>", "Include records at/before ISO time or Unix milliseconds")
.option("--cursor <sequence>", "Continue from a previous result cursor")
.option("--limit <count>", "Maximum records (1-500)", "100")
.option("--json", "Output a bounded JSON page", false)
.addHelpText(
"after",
() =>
`\n${theme.muted("Docs:")} ${formatDocsLink("/cli/audit", "docs.openclaw.ai/cli/audit")}\n`,
)
.action(async (opts) => {
await runCommandWithRuntime(defaultRuntime, async () => {
await auditListCommand(
{
agentId: opts.agent as string | undefined,
sessionKey: opts.session as string | undefined,
runId: opts.run as string | undefined,
kind: opts.kind as AuditListCommandOptions["kind"],
status: opts.status as AuditListCommandOptions["status"],
direction: opts.direction as AuditListCommandOptions["direction"],
channel: opts.channel as string | undefined,
after: opts.after as string | undefined,
before: opts.before as string | undefined,
cursor: opts.cursor as string | undefined,
limit: opts.limit as string | undefined,
json: Boolean(opts.json),
},
defaultRuntime,
);
});
});
}