@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.
94 lines (93 loc) • 4.5 kB
TypeScript
/**
* Data first, then the chart the user asked for.
*
* The profile describes which families the columns support, and may name a
* closer chart. That name is a suggestion. A requested chart this workspace
* can draw is the one that is drawn, including a poor fit. Nothing is
* generated in its place.
*/
import type { ClassifiedColumn } from '../profiler/roles.js';
import type { DataProfile } from '../spec/data-profile.js';
import { type Intent } from '../spec/intent.js';
import { type ChartFamily, type ChartId } from './chart-roles.js';
export type ChartDiscussion = {
/** Family ids the columns can support, most specific first. */
dataFamilies: string[];
/** Resolved widgets id, when the request named a known chart. */
requestedChart?: string;
/**
* Closer chart from the column reading. A description, not a replacement.
* Absent when the drawn chart is already in a supported family, or when
* nothing drawable is worth naming.
*/
suggestion?: string;
suggestionWhy: string;
/**
* The named chart fits the columns and must stay, even when this workspace
* cannot draw it. Jev must not replace it with another chart.
*/
keepRequested?: boolean;
/**
* The drawn chart is outside the supported families, so chartWhy still
* names the local suggestion. Jev replaces that sentence with its own.
*/
poorFit?: boolean;
/** suggestionWhy is already Jev's offer. Do not append another closer sentence. */
suggestionFromJev?: boolean;
/** Set when the user's chart should be rendered now. */
drawId?: string;
awaitingUser: boolean;
/** Sentence the model must show the user. */
message: string;
/** Why the drawn chart fits. Empty when nothing is drawn. */
chartWhy: string;
};
export declare function discussChart(input: {
profile: DataProfile;
columns?: readonly ClassifiedColumn[];
requestedChart: string;
intent: Intent;
catalogIds: ReadonlySet<string>;
}): ChartDiscussion;
/** Component id, chartType key, or a short name such as "pie" / "bar chart". */
export declare function resolveChartName(name: string): ChartId | undefined;
/**
* True when the user's words name this chart. A model-invented id does not count.
* Aliases are whole tokens ("bar chart", "sankey"), not substrings ("bargain").
* A stem of 4 letters or fewer counts after "a", "an", or "the" ("a bar", "the map").
* "the area" does not confirm an area chart.
*/
export declare function utteranceNamesChart(utterance: string, requestedChart: string): boolean;
/**
* Keep requestedChart when the utterance is absent, when this is a datasetId
* follow-up with no new table, or when the words name that chart.
* On a new table, drop a known chart the words do not name.
* An unknown name stays, so the existing hold still applies.
*/
export declare function requestedChartFromUtterance(utterance: string | undefined, requestedChart: string | undefined, options?: {
followUp?: boolean;
}): string | undefined;
export declare function chartWhyFor(componentId: string): string | undefined;
/** Families whose data shape the profile can support. Same gates as discussChart. */
export declare function chartFamiliesFor(profile: DataProfile, columns?: readonly {
role: string;
}[], intent?: Intent): ChartFamily[];
/**
* The intent's own families, in preference order.
* Empty when the intent has a list and none of those families fit the columns.
*/
export declare function guidedChartFamilies(profile: DataProfile, columns: readonly {
role: string;
}[] | undefined, intent: Intent): ChartFamily[];
/** True when this intent should refuse a chart outside its families. */
export declare function intentGuidesCharts(intent: Intent): boolean;
/**
* A drawing has to match the profile, not only sit in the catalog.
* Line and area need time. Pie needs a small set of categories. A map needs geo.
*/
export declare function chartFitsProfile(id: string, profile: DataProfile): boolean;
/** The one chart the words name, or nothing when they name zero or several. */
export declare function chartNamedByWords(utterance: string): ChartId | undefined;
/** Both ids are the main or an alternative of one family the columns support. */
export declare function sharesEligibleFamily(left: string, right: string, familyIds: readonly string[]): boolean;
export declare function canDraw(id: string, profile: DataProfile, catalogIds: ReadonlySet<string>): boolean;