import { z } from 'zod'; import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js'; import type { UsageService, UsageQuery } from '../../services/usage-service.js'; import { type ClientId } from '../../models/usage-record.js'; import type { PageRequest, SortKey } from '../../db/repositories/usage-repository.js'; import type { PageInfo } from '../../services/aggregation-service.js'; /** Period + scope parameters shared by the period-based tools. */ export declare const periodShape: { days: z.ZodOptional; today: z.ZodOptional; since: z.ZodOptional; until: z.ZodOptional; includeSubagents: z.ZodOptional; projectPaths: z.ZodOptional>; models: z.ZodOptional>; /** * The pre-0.8.0 spelling, still honoured. * * Dropping it would not have failed loudly: an unknown argument is stripped * before the handler sees it, so a caller still passing `projectPath` would * have had its filter silently vanish and received the WHOLE database * presented as one project's usage. That is the one failure this project * cannot have, so the old spelling keeps working. */ projectPath: z.ZodOptional; }; /** * Accepts a list, or the single string callers used before 0.8.0. The bare * string is the older shape and errors loudly rather than silently if dropped, * but there is no reason to break it when accepting both costs one union. */ export declare const clientEnum: z.ZodOptional, z.ZodArray>]>>; /** Ordering and paging, shared by every list-shaped tool. */ export declare const pageShape: { limit: z.ZodOptional; offset: z.ZodOptional; sort: z.ZodOptional>; }; export type PageArgs = { limit?: number; offset?: number; sort?: SortKey; }; export declare function toPageRequest(args: PageArgs): PageRequest; /** * Display name plus the annotations that every tool in this server shares. * * Every tool only reads -- from the collectors' source files and from our own * SQLite -- so `readOnlyHint` lets a client stop prompting for confirmation on * each call. `openWorldHint: false` is the other half of that: the server makes * no network calls, so its domain of interaction is closed. `destructiveHint` * and `idempotentHint` are deliberately absent; the spec defines both as * meaningful only when `readOnlyHint` is false. * * The title is returned twice on purpose. `Tool.title` is the current field, but * the spec's display-name precedence is `title` -> `annotations.title` -> `name`, * so a client written against an earlier revision reads `annotations.title` and * would otherwise fall back to the snake_case tool name. Both come from this one * argument, so the two copies cannot drift apart. */ export declare function readOnlyTool(title: string): { title: string; annotations: ToolAnnotations; }; export interface ToolContext { service: UsageService; /** Brings the local database up to date before a read. */ ensureFresh(): Promise; } type ClientArg = ClientId; export type PeriodArgs = { days?: number; today?: boolean; since?: string; until?: string; includeSubagents?: boolean; client?: ClientArg | ClientArg[]; models?: string[]; projectPaths?: string[]; /** Pre-0.8.0 spelling of `projectPaths`. */ projectPath?: string; }; export declare function toQuery(args: PeriodArgs): UsageQuery; /** The page envelope, mirrored into `structuredContent` beside the rows. */ export declare function pageStructured(info: PageInfo): { sort: string; rowsWithoutSortValue: number; nextOffset?: number | undefined; hasMore: boolean; limit?: number | undefined; total: number; offset: number; }; /** * A tool result, plus the update notice if one is waiting. * * The notice is a *second* content block, never appended to the first: the data * block has to stay byte-identical to what the CLI prints for the same query * (`ai-usage stats --today` and `usage_summary` are asserted equal), and a * consumer reading `content[0]` should get usage, not server housekeeping. It is * mirrored into `structuredContent.serverNotice` for the same reason -- beside * the numbers, never mixed into them. */ export declare function textResult(text: string, structured?: Record): { structuredContent?: { serverNotice?: string | undefined; } | undefined; content: { type: "text"; text: string; }[]; }; export declare function errorResult(message: string): { content: { type: "text"; text: string; }[]; isError: boolean; }; export {};