/** * Type definitions for the `RuntimeHandle.auditQuery` public method. * * These mirror the MCP `audit_query` tool contract (defined in * senpi-hyperliquid-mcp/src/tools/audit.tools.ts) but expressed as plain * TypeScript interfaces — Zod stays inside MCP, TypeBox stays inside * runtime-api. Anything new added to the MCP zod schema must be reflected * here as well. * * The implementation owns four MCP arguments and silently overrides any * caller-supplied values — these are intentionally absent from * {@link AuditQueryArgs}: * - `resource_type` (always `"strategy"`) * - `resource_id` (resolved wallet → strategyId) * - `user_ids` (server-controlled — the MCP API key user) * - `usernames` (server-controlled — same) */ /** * Caller-controlled subset of MCP `audit_query` parameters. * * Every field is optional. Field names match the MCP schema verbatim so * pass-through to the underlying tool stays drift-free. * * @see senpi-hyperliquid-mcp/src/tools/audit.tools.ts (`auditQueryInputSchema`) */ export interface AuditQueryArgs { /** Filter by exact tool name (e.g. `create_position`). */ tool_name?: string; /** Filter by action classification. */ action_type?: "read" | "create" | "update" | "delete"; /** Filter by success/failure. */ success?: boolean; /** ISO 8601 inclusive lower bound on `requested_at`. */ start_time?: string; /** ISO 8601 inclusive upper bound on `requested_at`. */ end_time?: string; /** Minimum end-to-end duration in ms (find slow operations). */ min_duration_ms?: number; /** Maximum end-to-end duration in ms (find fast operations). */ max_duration_ms?: number; /** Page size; MCP defaults to 100, max 1000. */ limit?: number; /** Offset-based pagination skip count; MCP default 0. */ offset?: number; /** Cursor timestamp for keyset pagination (must pair with `cursor_id`). */ cursor_requested_at?: string; /** Cursor id (UUID) for keyset pagination (must pair with `cursor_requested_at`). */ cursor_id?: string; } /** * Single audit-log entry as returned by MCP `audit_query`. * * @see senpi-hyperliquid-mcp/src/tools/audit.tools.ts (JSDoc on `handleAuditQuery`) */ export interface AuditEntry { /** Unique audit-entry identifier. */ id: string; /** Request identifier; correlates to MCP request id. */ request_id: string; /** When the tool was invoked (ISO 8601). */ timestamp: string; /** When execution finished (ISO 8601); may be absent on in-flight or partial entries. */ completed_at: string | null; /** End-to-end execution time in milliseconds, including downstream latency. */ duration_ms: number | null; /** Authenticated Senpi user id who performed the action. */ user_id: string; /** Exact tool name invoked. */ tool: string; /** Action classification. */ action_type: "read" | "create" | "update" | "delete"; /** AI-generated reasoning string; null for read tools. */ ai_reasoning: string | null; /** Boolean indicating successful completion. */ success: boolean; /** Error code when `success === false`. */ error_code: string | null; /** Failure details when `success === false`. */ error_message: string | null; /** Resources touched by the action (each `{ type, id }`). */ affected_resources: Array<{ type: string; id: string; }>; } /** * Pass-through MCP `audit_query` response payload (the `.data` portion of * the MCP envelope, after `unwrapEnvelope` strips `success`/`meta`). */ export interface AuditQueryResult { /** Audit entries on the current page. */ entries: AuditEntry[]; /** Number of entries on the current page. */ count: number; /** Approximate total matching entries (exact for small sets). */ total: number; /** Whether further results exist beyond the current page. */ has_more: boolean; } /** * Discriminated error class thrown by {@link RuntimeHandle.auditQuery}. * * Codes: * - `NOT_FOUND` — `listStrategies` returned 0 matches for the runtime's * wallet (the wallet does not belong to the API-key user). * - `UPSTREAM` — MCP returned an error (network, auth, schema). * - `ABORTED` — caller aborted via `opts.signal` before MCP responded. */ export declare class AuditQueryError extends Error { readonly code: "NOT_FOUND" | "UPSTREAM" | "ABORTED"; constructor(code: "NOT_FOUND" | "UPSTREAM" | "ABORTED", message: string); } //# sourceMappingURL=audit-query.types.d.ts.map