/** * Host half of dsh-token-dashboard. * * This half owns everything that needs the filesystem: locating `$DSH_HOME`, * discovering session logs, decoding them, and folding usage. It publishes the * result as one JSON route that the browser half polls. No model call, no * prompt content, and no writes are involved — the plugin only reads logs the * harness already wrote. * * `webServer` is acquired through a NESTED `ctx.inject` rather than the * module-level `inject` array on purpose. A module-level dependency would keep * the whole plugin unmounted in any composition without an HTTP carrier (a CLI * session, for instance), so a user who installed it for the web GUI would see * an activation failure in a context where the plugin has nothing to do. Nested, * it simply never registers a route there. * * @module dsh-token-dashboard */ import type { IncomingMessage, ServerResponse } from 'node:http'; import type { StatsQuery } from '../shared/types.js'; /** * The wire contract the `/api/stats` route answers with, re-exported from the * package root. * * Nothing else publishes these: a consumer that wants to type the snapshot — a * test harness, a second panel, a script reading the route — has no entry point * for them otherwise, because a type-only import is not a re-export. */ export type { CacheStats, ContextPressure, CountedBuckets, DayUsage, Insights, ProfileIdentity, ProfileSummary, RouteUsage, SessionRow, Share, StatsQuery, TokenBuckets, UsageCount, UsageSnapshot, WorkspaceUsage, } from '../shared/types.js'; /** * Cordis plugin name. * * The UNSCOPED short name, not the npm package name: the package publishes as * `@etheslay/dsh-token-dashboard`, but DSH's own plugins name themselves this * way (`@deepseek-ai/dsh-session-stats` → `session-stats`, * `@michengai/dsh-automation` → `dsh-automation`, `dsh-better-sidebar` → * `dsh-better-sidebar`). The Loader entry in `cordis.patch.yml` has its own * `id`, which is deliberately the same string, but the two are separate * identities — see the note there. */ export declare const name = "dsh-token-dashboard"; /** Route prefix this plugin owns. No other plugin may register it. */ export declare const ROUTE_PREFIX = "/dsh-token-dashboard"; /** The minimal Cordis context surface this plugin touches. */ interface HostContext { effect(callback: () => unknown, label?: string): void; inject(dependencies: string[], callback: (scoped: HostContext) => void): void; /** Optional-service lookup; `strict: false` returns `undefined` when absent. */ get?(name: string, strict?: boolean): unknown; webServer?: { register(route: { kind: 'exact' | 'prefix'; path: string; handler: (request: IncomingMessage, response: ServerResponse) => void | Promise; }): () => void; }; } /** * Parse and validate the `GET /api/stats` query. * @param url - The request URL. * @param defaultTimeZone - Zone used when the request omits one. * @returns The normalized query. */ export declare function parseStatsQuery(url: URL, defaultTimeZone: string): Required> & Pick; /** * Mount the plugin. * @param ctx - The Cordis context. */ export declare function apply(ctx: HostContext): void;