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.

78 lines (77 loc) • 3.19 kB
/** * Same ingest surface as mcp-ui `load_dataset`: csv | url | path | datasetId. * Rows stay on the server. The MCP result only gets datasetId + column names. */ import { type Table } from '../profiler/table.js'; export declare const DATASET_KIND: "dataset"; export declare const INGEST_KEYS: readonly ["csv", "url", "path", "datasetId"]; export type IngestKey = (typeof INGEST_KEYS)[number]; export type StoredDataset = { name?: string; columns: string[]; rows: Record<string, unknown>[]; }; export type IngestOptions = { /** Hosted/production: csv + datasetId only (no SSRF / no container file read). */ allowRemoteSources?: boolean; maxBytes?: number; cwd?: string; /** * When set, the real path must stay inside this directory. Unset keeps the * documented absolute-path read, still subject to the sensitive-path gate. */ datasetRoot?: string; fetchImpl?: (input: string, init?: { method?: string; redirect?: 'error' | 'follow' | 'manual'; }) => Promise<Pick<Response, 'ok' | 'status' | 'text'>>; loadDataset?: (id: string) => StoredDataset | undefined | Promise<StoredDataset | undefined>; }; export type IngestFail = { ok: false; code: 'invalid_ingest' | 'dataset_not_found'; reason: string; }; export type IngestOk = { ok: true; table: Table; rows: Record<string, string>[]; label: string; datasetId?: string; }; export type IngestResult = IngestOk | IngestFail | { ok: true; skip: true; }; /** Hidden files, key material, and well-known secret directories. Checks the whole path, not only the basename. */ export declare function isSensitiveDatasetFileName(fileName: string): boolean; /** System trees a chart table must not read, even when the basename looks harmless. */ export declare function isSensitiveDatasetPath(filePath: string): boolean; export declare function isDatasetPayload(value: unknown): value is { config: { kind: typeof DATASET_KIND; name?: string; }; data: { columns: string[]; rows: Record<string, unknown>[]; }; }; export declare function datasetFromPayload(payload: unknown): StoredDataset | undefined; export declare function datasetPersistPayload(label: string, table: Table): unknown; export declare function idFromDataUrl(dataUrl: string): string | undefined; export declare function tableFromRecords(records: readonly Record<string, unknown>[]): Table; export declare function tableFromStoredDataset(dataset: StoredDataset): Table; /** * Resolve a user table for this tool call. `{ skip: true }` means use the * server's current table (demo / last ingest / WORKSPACE_DATA_PATH). */ export declare function resolveWorkspaceIngest(args: Record<string, unknown>, options?: IngestOptions): Promise<IngestResult>; export type HostLookup = (hostname: string) => Promise<readonly { address: string; }[]>; /** * Refuse loopback, link-local, private, and cloud-metadata hosts before fetch. * A public name is refused when any resolved address is in those ranges. */ export declare function blockedDatasetUrl(raw: string, lookupHost?: HostLookup): Promise<string | undefined>;