/** * Resolving who the panel is about. * * Codex's profile panel leads with an avatar, a display name, and a handle. * A local harness has no such thing of its own, so the only honest source is * the DeepSeek account the user may be signed into — the same service `dsh-pet` * reads for its balance display. * * Everything here is optional and guarded. `deepseekAccount` is absent from * compositions that have no account platform, and `getProfile` returns `null` * when signed out; both cases simply drop the identity block rather than * inventing a placeholder name. * * @module dsh-token-dashboard/host/account */ import type { ProfileIdentity } from '../shared/types.js'; /** The account shape Codex-style clients pass to every account request. */ export interface AccountClientMetadata { /** Client version the platform uses for compatibility gating. */ version: string; /** Preferred locale for platform-rendered strings. */ locale: string; /** Minutes offset from UTC, as the platform SDKs send it. */ timezoneOffsetSeconds: number; } /** The slice of `ctx.deepseekAccount` this plugin touches. */ export interface DeepseekAccountService { getProfile(client: AccountClientMetadata): Promise<{ name?: string | null; avatarUrl?: string | null; contact?: string | null; } | null>; } /** The slice of a Cordis context this module needs to reach an optional service. */ export interface AccountContext { /** Optional-service lookup; cordis returns `undefined` for `strict: false`. */ get?(name: string, strict?: boolean): unknown; } /** * Read the signed-in account's display identity, if there is one. * * Never throws: a plugin whose account lookup fails should lose the avatar, not * the whole panel. * @param ctx - The host context, used to reach the optional service. * @returns The identity, or `undefined` when there is nothing to show. */ export declare function resolveIdentity(ctx: AccountContext): Promise; /** * A memoizing identity reader. * * The account platform answers over the network, so the panel must not pay for * it on every refresh. A failed lookup is cached too, but for a shorter time, so * signing in is picked up without a restart. */ export declare class IdentityCache { private readonly ttlMs; private readonly failureTtlMs; private value; private at; private resolved; /** * @param ttlMs - How long a successful lookup is reused. * @param failureTtlMs - How long an empty result is reused. */ constructor(ttlMs?: number, failureTtlMs?: number); /** * Read the cached identity, refreshing it when stale. * * A successful lookup is held for `ttlMs`; a lookup that found nothing is * held for `failureTtlMs` instead, so signing in is picked up without a * restart. * @param ctx - The host context. * @returns The identity, or `undefined` when there is nothing to show. */ read(ctx: AccountContext): Promise; }