@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.
71 lines (70 loc) • 2.01 kB
JavaScript
/**
* Closed risk table. Bands come from the action name in catalog metadata.
* A workspace spec cannot lower a band: this module never reads `spec.risk`
* or `spec.allowedActions`.
*
* low: hover, resize, pan, zoom
* held: submit, approve, reject, filter, drag
* anything else is held — an unlisted action is not low
*/
export const RISK_EFFECTS = ['observe', 'commit', 'narrow', 'move', 'unlisted'];
export const RISK_REVERSIBILITIES = ['reversible', 'irreversible'];
export const RISK_SCOPES = ['view', 'record', 'query', 'layout', 'unknown'];
const VIEW = {
effect: 'observe',
reversibility: 'reversible',
scope: 'view',
band: 'low',
};
const COMMIT = {
effect: 'commit',
reversibility: 'irreversible',
scope: 'record',
band: 'held',
};
const NARROW = {
effect: 'narrow',
reversibility: 'reversible',
scope: 'query',
band: 'held',
};
const MOVE = {
effect: 'move',
reversibility: 'reversible',
scope: 'layout',
band: 'held',
};
/** Fail closed. An action the table does not name cannot be low. */
const UNLISTED = {
effect: 'unlisted',
reversibility: 'irreversible',
scope: 'unknown',
band: 'held',
};
export const RISK_TABLE = {
hover: VIEW,
resize: VIEW,
pan: VIEW,
zoom: VIEW,
submit: COMMIT,
approve: COMMIT,
reject: COMMIT,
filter: NARROW,
drag: MOVE,
};
export function classifyAction(action) {
return { ...(RISK_TABLE[action] ?? UNLISTED) };
}
/** `allowedActions` from the catalog entry. Do not pass the spec's list. */
export function classifyActions(catalogActions) {
return catalogActions.map((action) => ({ action, ...classifyAction(action) }));
}
/**
* Catalog actions win. `spec` is accepted so a caller can pass the hostile
* document and we can prove it is ignored — including `spec.risk` and
* `spec.allowedActions`.
*/
export function classifyCatalogActions(catalogActions, spec) {
void spec;
return classifyActions(catalogActions ?? []);
}