UNPKG

@fusedashlabs/ui9000-workspace

Version:

UI9000 workspace MCP. One tool, show_workspace, draws a chart from your table. Set TYPESAFE_API_KEY to let Jev choose the chart.

49 lines (48 loc) • 2.07 kB
/** * Filesystem TTL store — copied from mcp-ui `src/utils/dataLinkStore.ts`. * * Same role as mcp-ui's `.data/`: one JSON file per link id, each wrapping the * payload in a `{ value, exp }` envelope so an expired file is dropped on the * next touch rather than lingering. Reads and writes are sync on purpose — the * store is small and the signing path must not interleave. * * Deviation from mcp-ui: the stored record carries an opaque `payload` instead * of mcp-ui's `{ config, data }` split, because this package's contract * (`SignDataLink = (payload: unknown) => SignedLink`) signs arbitrary payloads. * The envelope, file layout, and expiry mechanics are unchanged. */ export type StoredDataLink = { id: string; createdAt: string; ttlSeconds: number; payload: unknown; }; /** * Resolve the on-disk TTL store directory. * Cursor/Claude stdio often have cwd=$HOME, so `path.resolve(cwd, '.data')` * would write to ~/.data while the server reads the package `.data` — the * links then 404. Default: `<packageRoot>/.data` unless STORAGE_DIR is absolute. */ export declare function resolveDataLinkStorageDir(env?: NodeJS.ProcessEnv, root?: string): string; export declare const DEFAULT_TTL_MS: number; export declare class TtlStore { private readonly defaultTtlMs; private readonly dataDir; constructor(defaultTtlMs?: number, dataDir?: string); private ensureDir; private filePathFor; set(id: string, payload: unknown, customTtlMs?: number): void; get(id: string): StoredDataLink | null; has(id: string): boolean; delete(id: string): boolean; size(): number; /** Drop every link. Used by tests and by store teardown. */ destroy(): void; private linkFiles; private unlinkQuietly; /** Sweep expired (and unreadable) files so the directory cannot grow forever. */ private cleanup; } export declare function getDataLinkStore(): TtlStore; /** Test-only: drop the singleton so STORAGE_DIR can be re-read. */ export declare function resetDataLinkStoreForTests(): void;