@burdenoff/mcp-libs 2026.1107.1 → 2026.1107.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -241,12 +241,46 @@ var EXPORT_DASHBOARD = `
241
241
  }
242
242
  `;
243
243
  var IMPORT_DASHBOARD = `
244
- mutation BigConsoleMcpImportDashboard($input: BigConsoleImportDashboardInput!) {
245
- importDashboard(input: $input) {
246
- id
247
- name
248
- pageCount
249
- widgetCount
244
+ mutation BigConsoleMcpImportDashboard($input: ImportBigConsoleDashboardInput!) {
245
+ importBigConsoleDashboard(input: $input) {
246
+ success
247
+ errorMessage
248
+ dashboard {
249
+ id
250
+ name
251
+ pageCount
252
+ widgetCount
253
+ }
254
+ stats {
255
+ pagesCreated
256
+ widgetsCreated
257
+ actionsCreated
258
+ filtersCreated
259
+ dataSourcesSkipped
260
+ }
261
+ }
262
+ }
263
+ `;
264
+ var VALIDATE_DASHBOARD_IMPORT = `
265
+ query BigConsoleMcpValidateDashboardImport($content: String!) {
266
+ validateDashboardImport(content: $content) {
267
+ isValid
268
+ dashboardInfo {
269
+ name
270
+ pageCount
271
+ widgetCount
272
+ schemaVersion
273
+ }
274
+ errors {
275
+ code
276
+ message
277
+ path
278
+ }
279
+ warnings {
280
+ code
281
+ message
282
+ suggestion
283
+ }
250
284
  }
251
285
  }
252
286
  `;
@@ -308,7 +342,6 @@ var DashboardVisibilityEnum = z.enum(["PRIVATE", "WORKSPACE", "PUBLIC"]).describ
308
342
  var ParserTypeEnum = z.enum(["jq", "jsonata", "spark"]).describe("Parser transform engine \u2014 prefer jq");
309
343
  var ParserStatusEnum = z.enum(["active", "inactive"]).describe("Parser status");
310
344
  var DataSinkStatusEnum = z.enum(["ready", "refreshing", "stale", "error"]).describe("Data sink status filter");
311
- var ConflictResolutionEnum = z.enum(["RENAME", "OVERWRITE", "FAIL"]).describe("Import conflict strategy (default RENAME)");
312
345
  var DATA_SINK_KEY_PATTERN = /^[a-z0-9_]+$/;
313
346
  var DataSinkKey = z.string().regex(
314
347
  DATA_SINK_KEY_PATTERN,
@@ -513,25 +546,46 @@ function registerDashboardTools(server, ctx, track) {
513
546
  track(mcpToolName(ctx.productName, "dashboard_import")),
514
547
  {
515
548
  title: "Import Dashboard (Console Definition JSON)",
516
- description: "Reconstruct a dashboard from a Console Definition JSON string (from dashboard_export). This is the cross-workspace move: export in one workspace, import the string in another. Imported ids are REGENERATED \u2014 re-bind anything that referenced the old dashboard by id. " + WORKSPACE_NOTE,
549
+ description: "Reconstruct a dashboard from a Console Definition JSON string (from dashboard_export). This is the cross-workspace move: export in one workspace, import the string in another. Uses the v2.0 import path with per-entity stats \u2014 do NOT pair an export with the legacy importDashboard mutation, which expects the deprecated v1 layout and silently imports an empty dashboard. Imported ids are REGENERATED \u2014 re-bind anything that referenced the old dashboard by id. " + WORKSPACE_NOTE,
517
550
  inputSchema: {
518
- json: z.string().describe("The Console Definition JSON string"),
551
+ content: z.string().describe("The Console Definition JSON string"),
519
552
  name: z.string().optional().describe("Override the dashboard name"),
520
553
  visibility: DashboardVisibilityEnum.optional(),
521
- conflictResolution: ConflictResolutionEnum.optional()
554
+ skipWarnings: z.boolean().optional().describe("Import despite non-blocking validation warnings (default false)")
522
555
  }
523
556
  },
524
- async ({ json, name, visibility, conflictResolution }) => {
557
+ async ({ content, name, visibility, skipWarnings }) => {
525
558
  try {
526
559
  const result = await ctx.gql.workspace.request(IMPORT_DASHBOARD, {
527
560
  input: {
528
- json,
561
+ content,
529
562
  ...name !== void 0 ? { name } : {},
530
563
  ...visibility !== void 0 ? { visibility } : {},
531
- ...conflictResolution !== void 0 ? { conflictResolution } : {}
564
+ ...skipWarnings !== void 0 ? { skipWarnings } : {}
532
565
  }
533
566
  });
534
- return jsonResult(result.importDashboard);
567
+ if (!result.importBigConsoleDashboard.success) {
568
+ let detail = "";
569
+ try {
570
+ const validation = await ctx.gql.workspace.request(VALIDATE_DASHBOARD_IMPORT, { content });
571
+ const lines = [];
572
+ for (const e of validation.validateDashboardImport.errors ?? []) {
573
+ lines.push(`error ${e.code}: ${e.message}`);
574
+ }
575
+ for (const w of validation.validateDashboardImport.warnings ?? []) {
576
+ lines.push(
577
+ `warning ${w.code}: ${w.message}${w.suggestion ? ` (${w.suggestion})` : ""}`
578
+ );
579
+ }
580
+ if (lines.length > 0) detail = ` Validation says: ${lines.join(" | ")}`;
581
+ } catch {
582
+ }
583
+ return errorResult(
584
+ `Import failed: ${result.importBigConsoleDashboard.errorMessage ?? "unknown error"}.${detail}`,
585
+ "Read the errors/warnings above; fix the definition, or re-call with skipWarnings: true ONLY if every warning is understood and acceptable."
586
+ );
587
+ }
588
+ return jsonResult(result.importBigConsoleDashboard);
535
589
  } catch (error) {
536
590
  ctx.logger.error("bigconsole dashboard_import failed", { error: String(error) });
537
591
  return errorResult(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/modules/bigconsole/operations.ts","../../../src/modules/bigconsole/tools/shared.ts","../../../src/modules/bigconsole/tools/dashboards.ts","../../../src/modules/bigconsole/tools/datasinks.ts","../../../src/modules/bigconsole/tools/generate.ts","../../../src/modules/bigconsole/tools/parsers.ts","../../../src/modules/bigconsole/tools/widgets.ts","../../../src/modules/bigconsole/index.ts"],"names":["z"],"mappings":";;;;AAkCO,IAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AA2BxB,IAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAsBtB,IAAM,gBAAA,GAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAYzB,IAA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AK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,qBAAA,CAAsB,MAAA,EAAQ,KAAK,KAAK,CAAA;AACxC,IAAA,sBAAA,CAAuB,MAAA,EAAQ,KAAK,KAAK,CAAA;AACzC,IAAA,mBAAA,CAAoB,MAAA,EAAQ,KAAK,KAAK,CAAA;AACtC,IAAA,mBAAA,CAAoB,MAAA,EAAQ,KAAK,KAAK,CAAA;AACtC,IAAA,qBAAA,CAAsB,MAAA,EAAQ,KAAK,KAAK,CAAA;AAExC,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,kBAAA,GAAQ","file":"index.js","sourcesContent":["/**\n * Centralized GraphQL operations for the BigConsole MCP module (BOFF-3729).\n *\n * Backend subgraph: ~/products/wspace/bigconsole/wspace-bigconsole-svc/\n * (Hive service name `bigconsole`). Every operation here runs against the\n * WORKSPACE PUBLIC gateway, which is the only place `@rbac` is enforced from\n * the composed supergraph. This module authorises nothing itself and never\n * sees a token — `ctx.gql.workspace` injects the session's auth headers\n * (app-client-credentials or device-code login) plus the `x-workspace-id`\n * header set by `auth_select_workspace`.\n *\n * ### Selection sets are deliberately slim (BOFF-2719 / BOFF-2720)\n *\n * The gateway enforces a query-cost limit (`ARMOR_VIOLATION`) that fat\n * selection sets on `listDashboards` / `getDashboard` / `createDashboard`-\n * adjacent reads have tripped in production. So:\n *\n * - list queries select ids/keys/names and scalar metadata only — never\n * nested widget `config`, never `data` payloads;\n * - a widget's full `config` is only ever fetched for a single widget being\n * edited, and v1 ships no widget-config read at all;\n * - `getDataSink` never selects `data` (the payload can be arbitrarily large).\n *\n * Every operation name, argument and selected field below was verified\n * against the subgraph's `.hive-schema.graphql` — not assumed from naming.\n *\n * Uses template-string interpolation (not gql tagged fragments) to match the\n * canonical healthybowl / kadaikodi module operations files.\n */\n\n// ---------------------------------------------------------------------------\n// DataSinks\n// ---------------------------------------------------------------------------\n\nexport const LIST_DATA_SINKS = `\n query BigConsoleMcpListDataSinks($first: Int, $after: String, $search: String, $status: DataSinkStatus) {\n listDataSinks(first: $first, after: $after, search: $search, status: $status) {\n edges {\n node {\n id\n key\n name\n description\n status\n isActive\n setupState\n ttl\n version\n lastRefreshedAt\n updatedAt\n }\n }\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`;\n\nexport const GET_DATA_SINK = `\n query BigConsoleMcpGetDataSink($id: ID, $key: String) {\n getDataSink(id: $id, key: $key) {\n id\n key\n name\n description\n status\n isActive\n setupState\n dataClassification\n fieldMaskingEnabled\n ttl\n version\n linkedParserCount\n createdAt\n updatedAt\n lastRefreshedAt\n }\n }\n`;\n\nexport const CREATE_DATA_SINK = `\n mutation BigConsoleMcpCreateDataSink($input: CreateDataSinkInput!) {\n createDataSink(input: $input) {\n id\n key\n name\n status\n version\n }\n }\n`;\n\nexport const UPDATE_DATA_SINK = `\n mutation BigConsoleMcpUpdateDataSink($input: UpdateDataSinkInput!) {\n updateDataSink(input: $input) {\n id\n key\n name\n version\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Dashboards (consoles) + pages\n// ---------------------------------------------------------------------------\n\nexport const LIST_DASHBOARDS = `\n query BigConsoleMcpListDashboards(\n $first: Int\n $after: String\n $search: String\n $category: BigConsoleDashboardCategory\n $visibility: BigConsoleDashboardVisibility\n $includeArchived: Boolean\n ) {\n listDashboards(\n first: $first\n after: $after\n search: $search\n category: $category\n visibility: $visibility\n includeArchived: $includeArchived\n ) {\n edges {\n node {\n id\n name\n description\n category\n visibility\n status\n isArchived\n pageCount\n widgetCount\n updatedAt\n }\n }\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`;\n\nexport const GET_DASHBOARD = `\n query BigConsoleMcpGetDashboard($id: ID!) {\n getDashboard(id: $id) {\n id\n name\n description\n category\n visibility\n status\n isArchived\n pageCount\n widgetCount\n publishedAt\n globalFilters {\n id\n name\n type\n dependsOn\n }\n pages(first: 20) {\n edges {\n node {\n id\n name\n order\n widgetCount\n }\n }\n totalCount\n pageInfo {\n hasNextPage\n }\n }\n }\n }\n`;\n\nexport const CREATE_DASHBOARD = `\n mutation BigConsoleMcpCreateDashboard($input: BigConsoleCreateDashboardInput!) {\n createBigConsoleDashboard(input: $input) {\n id\n name\n category\n visibility\n status\n pageCount\n }\n }\n`;\n\nexport const CREATE_DASHBOARD_PAGE = `\n mutation BigConsoleMcpCreateDashboardPage($input: BigConsoleCreateDashboardPageInput!) {\n createDashboardPage(input: $input) {\n id\n name\n dashboardId\n order\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Parsers\n// ---------------------------------------------------------------------------\n\nexport const LIST_PARSERS = `\n query BigConsoleMcpListParsers($consoleId: ID!, $first: Int, $after: String) {\n listParsers(filter: { consoleId: $consoleId }, first: $first, after: $after) {\n edges {\n node {\n id\n name\n type\n status\n inputSinkKey\n outputKey\n version\n updatedAt\n }\n }\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`;\n\nexport const CREATE_PARSER = `\n mutation BigConsoleMcpCreateParser($input: CreateParserInput!) {\n createParser(input: $input) {\n id\n name\n type\n status\n inputSinkKey\n outputKey\n version\n }\n }\n`;\n\nexport const UPDATE_PARSER = `\n mutation BigConsoleMcpUpdateParser($id: ID!, $input: UpdateParserInput!, $version: Int!) {\n updateParser(id: $id, input: $input, version: $version) {\n id\n name\n type\n status\n inputSinkKey\n outputKey\n version\n }\n }\n`;\n\nexport const TEST_PARSER_EXPRESSION = `\n query BigConsoleMcpTestParserExpression($input: TestParserInput!) {\n testParserExpression(input: $input) {\n success\n output\n error\n executionTimeMs\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Widgets\n// ---------------------------------------------------------------------------\n\nexport const CREATE_WIDGET = `\n mutation BigConsoleMcpCreateWidget($input: BigConsoleCreateWidgetInput!) {\n createBigConsoleWidget(input: $input) {\n id\n title\n type\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Export / import — the Console Definition JSON round-trip\n// ---------------------------------------------------------------------------\n\nexport const EXPORT_DASHBOARD = `\n query BigConsoleMcpExportDashboard($id: ID!, $options: BigConsoleExportDashboardOptions) {\n exportDashboard(id: $id, options: $options)\n }\n`;\n\nexport const IMPORT_DASHBOARD = `\n mutation BigConsoleMcpImportDashboard($input: BigConsoleImportDashboardInput!) {\n importDashboard(input: $input) {\n id\n name\n pageCount\n widgetCount\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Generate-from-prompt lifecycle\n// ---------------------------------------------------------------------------\n\nexport const GENERATE_DASHBOARD_FROM_PROMPT = `\n mutation BigConsoleMcpGenerateDashboardFromPrompt($input: BigConsoleGenerateDashboardFromPromptInput!) {\n generateDashboardFromPrompt(input: $input) {\n id\n status\n }\n }\n`;\n\nexport const GET_PROMPT_GENERATION = `\n query BigConsoleMcpGetPromptGeneration($id: ID!) {\n getPromptGeneration(id: $id) {\n id\n status\n errorMessage\n generatedSpecDigest\n dashboardId\n }\n }\n`;\n\nexport const CREATE_DASHBOARD_FROM_GENERATION = `\n mutation BigConsoleMcpCreateDashboardFromGeneration($input: BigConsoleCreateDashboardFromGenerationInput!) {\n createDashboardFromGeneration(input: $input) {\n id\n name\n pageCount\n widgetCount\n }\n }\n`;\n","/**\n * Shared zod shapes + guardrails for the BigConsole tool surface.\n *\n * ### No tool here takes a workspace or a token\n *\n * `@rbac(scopeType: \"wspace\")` authorises the workspace named in the\n * `x-workspace-id` gateway header — the one `auth_select_workspace` sets — and\n * nothing else. BigConsole's inputs carry no workspace field at all, so there\n * is nothing to expose. Likewise no tool takes a token: the session's\n * credential (app-client-credentials or device-code login) is injected by\n * `ctx.gql.workspace` from the auth store, and a tool-level token input would\n * be a forwarded-user-token hole (AI_READINESS §2.1).\n *\n * ### The two footguns are encoded here, not in documentation\n *\n * 1. **The nine render-verified widget types.** Since BOFF-3550 every native\n * `BigConsoleWidgetType` member passes the gateway enum, but `config` is\n * opaque JSON and the renderer is the only judge — the v2.0-internal\n * lowercase keys (`kanban`, `pivot_table`, …) and the native types without\n * documented configs render wrong or not at all. The allowlist below is\n * the nine render-verified members; anything else is rejected client-side\n * with a message that names all nine.\n * 2. **Optimistic locking.** `updateDataSink` carries `version` inside the\n * input; `updateParser` takes it as a top-level argument. Both are\n * required `Int` tool inputs — a caller must read the current version\n * first (every read selects it) and send it back unchanged.\n *\n * @module bigconsole\n */\n\nimport { z } from 'zod';\n\n/** Appended to every tool description so the failure mode is stated where it will be read. */\nexport const WORKSPACE_NOTE =\n 'Operates on the workspace selected via auth_select_workspace — this tool takes no workspace ' +\n 'or token argument. Authorization is enforced at the gateway from the authenticated session.';\n\n// ── The nine render-verified widget types ───────────────────────────────────\n\nexport const WIDGET_TYPES = [\n 'LINE_CHART',\n 'BAR_CHART',\n 'AREA_CHART',\n 'PIE_CHART',\n 'TABLE',\n 'KPI',\n 'HEATMAP',\n 'FUNNEL',\n 'RETENTION',\n] as const;\n\nexport const WIDGET_TYPE_LIST = WIDGET_TYPES.join(', ');\n\nconst WIDGET_TYPE_REJECTION = (value: string): string =>\n `\"${value}\" is not a render-verified BigConsole widget type. This tool accepts exactly the nine ` +\n `render-verified types: ${WIDGET_TYPE_LIST}. (Since BOFF-3550 the gateway enum accepts more, ` +\n `but config is opaque JSON and only these nine have renderer-verified configs — see the ` +\n `bigconsole.md recipe / reference-widgets/widget-configs.json before reaching for anything else.)`;\n\nexport const WidgetTypeEnum = z\n .enum(WIDGET_TYPES)\n .describe(\n `Widget renderer — one of the nine render-verified types: ${WIDGET_TYPE_LIST}. ` +\n 'The lowercase v2.0-internal keys (kanban, pivot_table, …) are rejected here.',\n );\n\n/**\n * Same nine-value gate for list-shaped inputs (`preferredWidgetTypes`).\n * Rejects every non-member individually with the full list in the message.\n */\nexport const WidgetTypeArray = z\n .array(z.string())\n .superRefine((values, ctx) => {\n for (const value of values) {\n if (!(WIDGET_TYPES as readonly string[]).includes(value)) {\n ctx.addIssue({ code: 'custom', message: WIDGET_TYPE_REJECTION(value) });\n }\n }\n })\n .transform((values) => values as (typeof WIDGET_TYPES)[number][]);\n\n// ── Other enums ─────────────────────────────────────────────────────────────\n\nexport const DashboardCategoryEnum = z\n .enum(['CUSTOM', 'EXECUTIVE', 'FINANCIAL', 'HR', 'MARKETING', 'OPERATIONS', 'SALES'])\n .describe('Dashboard category — pick the closest fit; CUSTOM when nothing fits');\n\nexport const DashboardVisibilityEnum = z\n .enum(['PRIVATE', 'WORKSPACE', 'PUBLIC'])\n .describe('Dashboard visibility (default PRIVATE)');\n\nexport const ParserTypeEnum = z\n .enum(['jq', 'jsonata', 'spark'])\n .describe('Parser transform engine — prefer jq');\n\nexport const ParserStatusEnum = z.enum(['active', 'inactive']).describe('Parser status');\n\nexport const DataSinkStatusEnum = z\n .enum(['ready', 'refreshing', 'stale', 'error'])\n .describe('Data sink status filter');\n\nexport const ConflictResolutionEnum = z\n .enum(['RENAME', 'OVERWRITE', 'FAIL'])\n .describe('Import conflict strategy (default RENAME)');\n\n// ── DataSink key ────────────────────────────────────────────────────────────\n\nconst DATA_SINK_KEY_PATTERN = /^[a-z0-9_]+$/;\n\nexport const DataSinkKey = z\n .string()\n .regex(\n DATA_SINK_KEY_PATTERN,\n 'Data sink keys are lowercase letters, numbers and underscores only — no hyphens ' +\n '(e.g. sales_2026).',\n )\n .describe('Unique slug within the workspace — lowercase letters, numbers, underscores only');\n\n// ── Widget config guard (the custom-widget hard limits) ─────────────────────\n\n/** Config keys the backend hard-rejects; encoding them client-side fails faster and clearer. */\nconst FORBIDDEN_CONFIG_KEYS = [\n 'html',\n 'iframeUrl',\n 'script',\n 'scriptUrl',\n 'render',\n 'srcDoc',\n 'onClick',\n] as const;\n\nconst FORBIDDEN_VALUE_PATTERN = /javascript:/i;\n\nfunction configViolation(key: string): string {\n return (\n `Widget config key \"${key}\" is not allowed — BigConsole widgets are built-in renderers + ` +\n 'declarative config, never custom code. No html, iframeUrl, script, scriptUrl, render, ' +\n 'srcDoc, onClick, or javascript: values.'\n );\n}\n\nexport const WidgetConfig = z\n .record(z.string(), z.unknown())\n .superRefine((config, ctx) => {\n for (const key of Object.keys(config)) {\n if ((FORBIDDEN_CONFIG_KEYS as readonly string[]).includes(key)) {\n ctx.addIssue({ code: 'custom', message: configViolation(key) });\n continue;\n }\n const value = config[key];\n if (typeof value === 'string' && FORBIDDEN_VALUE_PATTERN.test(value)) {\n ctx.addIssue({ code: 'custom', message: configViolation(`${key} (javascript: URL)`) });\n }\n }\n })\n .describe(\n 'Declarative renderer config (never empty). Charts need config.chartType ' +\n '(\"line\"|\"bar\"|\"area\"|\"pie\") matching the type; a single KPI needs ' +\n 'config._internalWidgetType \"metric_card\"; retention needs \"retention\". Field names must ' +\n 'match the parser/sink output keys.',\n );\n\n// ── Widget position on the 12-column grid ───────────────────────────────────\n\nexport const WidgetPosition = z\n .object({\n x: z.number().int().min(0).max(11).describe('Column start, 0–11'),\n y: z.number().int().min(0).describe('Row start'),\n width: z.number().int().min(1).max(12).describe('Width in columns, 1–12'),\n height: z.number().int().min(1).describe('Height in rows'),\n })\n .superRefine((position, ctx) => {\n if (position.x + position.width > 12) {\n ctx.addIssue({\n code: 'custom',\n message: `x + width must be ≤ 12 on the 12-column grid (got x=${position.x}, width=${position.width}).`,\n });\n }\n })\n .describe('Grid position on a 12-column grid: x 0–11, width 1–12, x+width ≤ 12, height ≥ 1');\n\n// ── Version (optimistic lock) ───────────────────────────────────────────────\n\nexport const VersionInt = z\n .number()\n .int()\n .describe(\n 'Current version for optimistic locking — read it from a get/list call first and send it ' +\n 'back unchanged; a stale version is rejected, so re-read and retry rather than guessing.',\n );\n\n/**\n * Rejection an update tool returns when `version` was omitted. Declared\n * optional in the zod schema so the HANDLER can produce this explicit\n * optimistic-lock message instead of the SDK's generic schema error — the\n * requirement is real either way: no update reaches the gateway without a\n * version.\n */\nexport const VERSION_OMITTED_MESSAGE =\n 'version is required for optimistic locking — read the current version from a get/list call ' +\n 'first and send it back unchanged. A stale version is rejected by the backend, so re-read and ' +\n 'retry rather than guessing or incrementing.';\n\n// ── Pagination ──────────────────────────────────────────────────────────────\n\nexport const PageSize = z\n .number()\n .int()\n .min(1)\n .max(100)\n .default(20)\n .describe('Page size (max 100)');\n\nexport const PageCursor = z\n .string()\n .optional()\n .describe('Pagination cursor from pageInfo.endCursor');\n","/**\n * BigConsole dashboard (console) tools, including the export/import round-trip.\n *\n * Surface (6): dashboards_list, dashboard_get, dashboard_create,\n * dashboard_page_create, dashboard_export, dashboard_import.\n *\n * ### \"Dashboards as code\" is the point of this module\n *\n * `dashboard_export` returns the Console Definition JSON — one declarative\n * document with the whole console (pages, widgets, layout, global filters).\n * `dashboard_import` reconstructs a console from that string. Round-trip them\n * and a coding agent can commit a console definition next to application code\n * and diff it in review; that workflow is the positioning no incumbent BI\n * vendor offers. Imported dashboards get REGENERATED ids — re-bind anything\n * that referenced the old dashboard by id.\n *\n * ### Lifecycle mutations are deliberately absent\n *\n * `archiveDashboard` / `restoreDashboard` / `publishDashboard` are not here:\n * archiving a production console is the destructive action v1 refuses to\n * expose to an external agent (AI_READINESS §2.2/§2.3). Read + create +\n * export/import is the valuable 90%.\n *\n * ### Selection sets stay slim (BOFF-2719 / BOFF-2720)\n *\n * Lists select scalar metadata only. `dashboard_get` pages through at most\n * 20 pages with per-page widget counts — it never expands widget configs,\n * which is what tripped the gateway cost limit in production.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport {\n jsonResult,\n textResult,\n errorResult,\n mcpToolName,\n type McpContext,\n} from '../../../core/index.js';\nimport {\n CREATE_DASHBOARD,\n CREATE_DASHBOARD_PAGE,\n EXPORT_DASHBOARD,\n GET_DASHBOARD,\n IMPORT_DASHBOARD,\n LIST_DASHBOARDS,\n} from '../operations.js';\nimport {\n ConflictResolutionEnum,\n DashboardCategoryEnum,\n DashboardVisibilityEnum,\n PageCursor,\n PageSize,\n WORKSPACE_NOTE,\n} from './shared.js';\n\nexport function registerDashboardTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboards_list')),\n {\n title: 'List Dashboards',\n description:\n 'The dashboards (consoles) visible in the active workspace — metadata only, no widget ' +\n `configs. ${WORKSPACE_NOTE}`,\n inputSchema: {\n first: PageSize,\n after: PageCursor,\n search: z.string().optional().describe('Filter by name substring'),\n category: DashboardCategoryEnum.optional(),\n visibility: DashboardVisibilityEnum.optional(),\n includeArchived: z\n .boolean()\n .optional()\n .describe('Include archived dashboards (excluded by default)'),\n },\n },\n async ({ first, after, search, category, visibility, includeArchived }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n listDashboards: Record<string, unknown>;\n }>(LIST_DASHBOARDS, {\n first: first ?? 20,\n after: after ?? null,\n search: search ?? null,\n category: category ?? null,\n visibility: visibility ?? null,\n includeArchived: includeArchived ?? null,\n });\n return jsonResult(data.listDashboards);\n } catch (error) {\n ctx.logger.error('bigconsole dashboards_list failed', { error: String(error) });\n return errorResult(\n `Failed to list dashboards: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_get')),\n {\n title: 'Get Dashboard',\n description:\n 'One dashboard with its pages (ids — you need the page id to place widgets), global ' +\n 'filters, and page/widget counts. Widget configs are NOT expanded (gateway cost ' +\n 'limit). ' +\n WORKSPACE_NOTE,\n inputSchema: {\n id: z.string().describe('Dashboard ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getDashboard: Record<string, unknown> | null;\n }>(GET_DASHBOARD, { id });\n if (!data.getDashboard) {\n return errorResult(`Dashboard \"${id}\" not found or not visible.`);\n }\n return jsonResult(data.getDashboard);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_get failed', { error: String(error) });\n return errorResult(\n `Failed to get the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_create')),\n {\n title: 'Create Dashboard',\n description:\n 'Create a console (dashboard). `createDefaultPage` defaults to true, so a first page is ' +\n 'created for you — read its id back via dashboard_get to place widgets. Step 2 of the ' +\n 'pipeline (DataSink → Dashboard → Parser → Widget). ' +\n WORKSPACE_NOTE,\n inputSchema: {\n name: z.string().describe('Dashboard name'),\n category: DashboardCategoryEnum,\n description: z.string().optional(),\n visibility: DashboardVisibilityEnum.optional(),\n createDefaultPage: z.boolean().optional().describe('Create a first page (default true)'),\n },\n },\n async ({ name, category, description, visibility, createDefaultPage }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n createBigConsoleDashboard: Record<string, unknown>;\n }>(CREATE_DASHBOARD, {\n input: {\n name,\n category,\n ...(description !== undefined ? { description } : {}),\n ...(visibility !== undefined ? { visibility } : {}),\n ...(createDefaultPage !== undefined ? { createDefaultPage } : {}),\n },\n });\n return jsonResult(result.createBigConsoleDashboard);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_page_create')),\n {\n title: 'Create Dashboard Page',\n description:\n 'Add a page to an existing dashboard. Only needed for multi-page consoles — a new ' +\n 'dashboard already has a default page. Widgets are placed on a page, not on the ' +\n 'dashboard. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n dashboardId: z.string().describe('Parent dashboard ID'),\n name: z.string().describe('Page name'),\n },\n },\n async ({ dashboardId, name }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n createDashboardPage: Record<string, unknown>;\n }>(CREATE_DASHBOARD_PAGE, { input: { dashboardId, name } });\n return jsonResult(result.createDashboardPage);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_page_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the page: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_export')),\n {\n title: 'Export Dashboard (Console Definition JSON)',\n description:\n 'Export a dashboard as the portable Console Definition JSON — one declarative document ' +\n 'with pages, widgets, layout and global filters. Commit it next to your code, diff it ' +\n 'in review, feed it to dashboard_import to reconstruct. This is a QUERY, not a mutation. ' +\n 'Leave includeWebhookMappings false unless you hold dashboard-edit permission AND a ' +\n 'current export consent grant. ' +\n WORKSPACE_NOTE,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n inputSchema: {\n id: z.string().describe('Dashboard ID to export'),\n prettyPrint: z.boolean().optional().describe('Pretty-print the JSON (default true)'),\n includeDataSourceRefs: z\n .boolean()\n .optional()\n .describe('Include data source references (default false)'),\n includeWebhookMappings: z\n .boolean()\n .optional()\n .describe(\n 'Include webhook mappings (default false; requires dashboard-edit permission and a ' +\n 'current export consent grant — never request casually)',\n ),\n },\n },\n async ({ id, prettyPrint, includeDataSourceRefs, includeWebhookMappings }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n exportDashboard: string;\n }>(EXPORT_DASHBOARD, {\n id,\n options: {\n prettyPrint: prettyPrint ?? true,\n includeDataSourceRefs: includeDataSourceRefs ?? false,\n includeWebhookMappings: includeWebhookMappings ?? false,\n },\n });\n return textResult(data.exportDashboard);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_export failed', { error: String(error) });\n return errorResult(\n `Failed to export the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_import')),\n {\n title: 'Import Dashboard (Console Definition JSON)',\n description:\n 'Reconstruct a dashboard from a Console Definition JSON string (from dashboard_export). ' +\n 'This is the cross-workspace move: export in one workspace, import the string in ' +\n 'another. Imported ids are REGENERATED — re-bind anything that referenced the old ' +\n 'dashboard by id. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n json: z.string().describe('The Console Definition JSON string'),\n name: z.string().optional().describe('Override the dashboard name'),\n visibility: DashboardVisibilityEnum.optional(),\n conflictResolution: ConflictResolutionEnum.optional(),\n },\n },\n async ({ json, name, visibility, conflictResolution }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n importDashboard: Record<string, unknown>;\n }>(IMPORT_DASHBOARD, {\n input: {\n json,\n ...(name !== undefined ? { name } : {}),\n ...(visibility !== undefined ? { visibility } : {}),\n ...(conflictResolution !== undefined ? { conflictResolution } : {}),\n },\n });\n return jsonResult(result.importDashboard);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_import failed', { error: String(error) });\n return errorResult(\n `Failed to import the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * BigConsole data sink tools — the data layer of the console pipeline.\n *\n * Surface (4): datasinks_list, datasink_get, datasink_create, datasink_update.\n *\n * Read + create/update only — there is intentionally no `datasink_delete`:\n * sinks can feed live workflows and parsers, and an external agent retiring\n * one it does not fully understand is exactly the destructive action v1\n * omits (AI_READINESS §2.3).\n *\n * `datasink_get` never selects the `data` payload — sinks can hold arbitrary\n * bulk rows, and the MCP surface exists to author consoles, not to exfiltrate\n * data. Use `getDataSinkData` from the app when you actually need rows.\n *\n * `datasink_update` carries the optimistic-lock `version` INSIDE the input\n * (the backend's shape) and requires it as a tool input — see shared.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../../core/index.js';\nimport {\n CREATE_DATA_SINK,\n GET_DATA_SINK,\n LIST_DATA_SINKS,\n UPDATE_DATA_SINK,\n} from '../operations.js';\nimport {\n DataSinkKey,\n DataSinkStatusEnum,\n PageCursor,\n PageSize,\n VersionInt,\n VERSION_OMITTED_MESSAGE,\n WORKSPACE_NOTE,\n} from './shared.js';\n\nexport function registerDataSinkTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'datasinks_list')),\n {\n title: 'List Data Sinks',\n description:\n 'The data sinks of the active workspace with status and refresh metadata — metadata ' +\n `only, never payloads. ${WORKSPACE_NOTE}`,\n inputSchema: {\n first: PageSize,\n after: PageCursor,\n search: z.string().optional().describe('Filter by name or key substring'),\n status: DataSinkStatusEnum.optional(),\n },\n },\n async ({ first, after, search, status }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n listDataSinks: Record<string, unknown>;\n }>(LIST_DATA_SINKS, {\n first: first ?? 20,\n after: after ?? null,\n search: search ?? null,\n status: status ?? null,\n });\n return jsonResult(data.listDataSinks);\n } catch (error) {\n ctx.logger.error('bigconsole datasinks_list failed', { error: String(error) });\n return errorResult(\n `Failed to list data sinks: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'datasink_get')),\n {\n title: 'Get Data Sink',\n description:\n 'One data sink by id or key (exactly one of them) — metadata, linked-parser count and ' +\n 'version for optimistic-lock updates. Does NOT return the stored data payload. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n id: z.string().optional().describe('Data sink ID'),\n key: z.string().optional().describe('Data sink key (slug) — alternative to id'),\n },\n },\n async ({ id, key }) => {\n if (!id && !key) {\n return errorResult(\n 'Provide exactly one of id or key.',\n 'Pass the data sink id from datasinks_list, or its key (slug).',\n );\n }\n if (id && key) {\n return errorResult('Provide exactly one of id or key, not both.');\n }\n try {\n const data = await ctx.gql.workspace.request<{\n getDataSink: Record<string, unknown> | null;\n }>(GET_DATA_SINK, { id: id ?? null, key: key ?? null });\n if (!data.getDataSink) {\n return errorResult(`Data sink not found for ${id ? `id \"${id}\"` : `key \"${key}\"`}.`);\n }\n return jsonResult(data.getDataSink);\n } catch (error) {\n ctx.logger.error('bigconsole datasink_get failed', { error: String(error) });\n return errorResult(\n `Failed to get the data sink: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'datasink_create')),\n {\n title: 'Create Data Sink',\n description:\n 'Create a data sink — the first step of the console pipeline (DataSink → Dashboard → ' +\n 'Parser → Widget). `key` is the only required field; pass `data` as an array of row ' +\n 'objects for a snapshot, or leave it empty and feed the sink from a workflow later. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n key: DataSinkKey,\n name: z.string().optional().describe('Display name (defaults to the key)'),\n description: z.string().optional(),\n data: z\n .unknown()\n .optional()\n .describe('Initial payload — an array of row objects for a snapshot load'),\n ttl: z.number().int().min(0).optional().describe('Cache TTL in seconds (default 300)'),\n },\n },\n async ({ key, name, description, data, ttl }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n createDataSink: Record<string, unknown>;\n }>(CREATE_DATA_SINK, {\n input: {\n key,\n ...(name !== undefined ? { name } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(data !== undefined ? { data } : {}),\n ...(ttl !== undefined ? { ttl } : {}),\n },\n });\n return jsonResult(result.createDataSink);\n } catch (error) {\n ctx.logger.error('bigconsole datasink_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the data sink: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'datasink_update')),\n {\n title: 'Update Data Sink',\n description:\n 'Update a data sink with optimistic locking. `version` is REQUIRED — read the current ' +\n 'value from datasink_get first and send it back unchanged; a stale version is rejected, ' +\n 'so re-read and retry rather than incrementing blindly. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n id: z.string().describe('Data sink ID'),\n version: VersionInt.optional(),\n name: z.string().optional(),\n description: z.string().optional(),\n data: z.unknown().optional().describe('Replacement payload (array of row objects)'),\n ttl: z.number().int().min(0).optional(),\n isActive: z.boolean().optional(),\n },\n },\n async ({ id, version, name, description, data, ttl, isActive }) => {\n if (version === undefined) {\n return errorResult(VERSION_OMITTED_MESSAGE);\n }\n try {\n const result = await ctx.gql.workspace.request<{\n updateDataSink: Record<string, unknown>;\n }>(UPDATE_DATA_SINK, {\n input: {\n id,\n version,\n ...(name !== undefined ? { name } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(data !== undefined ? { data } : {}),\n ...(ttl !== undefined ? { ttl } : {}),\n ...(isActive !== undefined ? { isActive } : {}),\n },\n });\n return jsonResult(result.updateDataSink);\n } catch (error) {\n ctx.logger.error('bigconsole datasink_update failed', { error: String(error) });\n return errorResult(\n `Failed to update the data sink: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * BigConsole generate-from-prompt tool — the AI console lifecycle.\n *\n * Surface (1): dashboard_generate_from_prompt.\n *\n * Runs the whole lifecycle in one call: submit the generation, poll it to a\n * terminal status (PENDING → PROCESSING → GENERATING → COMPLETED | FAILED |\n * CANCELLED), then — only when `materialize` is explicitly true — turn the\n * completed spec into a real dashboard via createDashboardFromGeneration.\n *\n * ### Metering and defaults\n *\n * `generateDashboardFromPrompt` and `createDashboardFromGeneration` are\n * `@usage`-metered (they spend the workspace's AI credits). `materialize`\n * therefore defaults to FALSE: the default path spends exactly one\n * generation and hands the agent the spec digest to review, and turning it\n * into a dashboard is an explicit second decision. Pass the exact\n * `generatedSpecDigest` this tool returns back as `expectedSpecDigest` with\n * `materialize: true` so linked reuse refuses an obsolete revision instead of\n * silently materializing a changed spec.\n *\n * A generated console arrives bound to whatever the spec says — verify widget\n * bindings against the workspace's real data sinks (datasinks_list) before\n * trusting it as live.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../../core/index.js';\nimport {\n CREATE_DASHBOARD_FROM_GENERATION,\n GENERATE_DASHBOARD_FROM_PROMPT,\n GET_PROMPT_GENERATION,\n} from '../operations.js';\nimport {\n DashboardCategoryEnum,\n DashboardVisibilityEnum,\n WidgetTypeArray,\n WORKSPACE_NOTE,\n} from './shared.js';\n\nconst TERMINAL_STATUSES = ['COMPLETED', 'FAILED', 'CANCELLED'] as const;\n\nconst TERMINAL_SET: ReadonlySet<string> = new Set(TERMINAL_STATUSES);\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function registerGenerateTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_generate_from_prompt')),\n {\n title: 'Generate Dashboard From Prompt',\n description:\n 'Generate a whole console spec from natural language, poll it to completion, and ' +\n 'optionally materialize it into a real dashboard. Metered (spends AI credits): ' +\n 'generating always costs one generation; materialization only happens when ' +\n '`materialize: true`, and should pass the returned generatedSpecDigest back as ' +\n 'expectedSpecDigest so an obsolete spec revision is refused. After materializing, ' +\n \"verify widget bindings against the workspace's real data sinks. \" +\n WORKSPACE_NOTE,\n inputSchema: {\n prompt: z\n .string()\n .describe(\n 'Natural language description of the desired console, e.g. \"a sales dashboard with ' +\n 'revenue trends, top products and regional performance\"',\n ),\n maxWidgets: z\n .number()\n .int()\n .min(1)\n .max(24)\n .optional()\n .describe('Maximum widgets to generate (default 8)'),\n category: DashboardCategoryEnum.optional(),\n preferredWidgetTypes: z\n .array(z.string())\n .optional()\n .describe(\n 'Preferred widget types (from the nine render-verified types; any other value is ' +\n 'rejected with the full list)',\n ),\n additionalContext: z.string().optional(),\n visibility: DashboardVisibilityEnum.optional(),\n materialize: z\n .boolean()\n .optional()\n .describe(\n 'Materialize the completed spec into a real dashboard (default false; metered — ' +\n 'review the generatedSpecDigest first)',\n ),\n expectedSpecDigest: z\n .string()\n .optional()\n .describe(\n 'The exact generatedSpecDigest this tool returned, passed back so an obsolete spec ' +\n 'revision is refused (only used with materialize: true)',\n ),\n pollIntervalMs: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe('Poll interval while the generation runs (default 2000ms)'),\n pollTimeoutMs: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe('Give up polling after this long (default 120000ms)'),\n },\n },\n async ({\n prompt,\n maxWidgets,\n category,\n preferredWidgetTypes,\n additionalContext,\n visibility,\n materialize,\n expectedSpecDigest,\n pollIntervalMs,\n pollTimeoutMs,\n }) => {\n const parsedTypes = preferredWidgetTypes\n ? WidgetTypeArray.safeParse(preferredWidgetTypes)\n : null;\n if (parsedTypes && !parsedTypes.success) {\n return errorResult(\n parsedTypes.error.issues.map((issue) => issue.message).join(' '),\n 'Use only the nine render-verified widget types named in the message.',\n );\n }\n if (expectedSpecDigest && materialize !== true) {\n return errorResult(\n 'expectedSpecDigest is only meaningful with materialize: true.',\n 'Review the generatedSpecDigest from the result, then re-call with materialize: true ' +\n 'and the digest.',\n );\n }\n\n const interval = pollIntervalMs ?? 2000;\n const timeout = pollTimeoutMs ?? 120_000;\n\n let generation: {\n id: string;\n status: string;\n errorMessage?: string | null;\n generatedSpecDigest?: string | null;\n dashboardId?: string | null;\n } | null = null;\n\n try {\n const submitted = await ctx.gql.workspace.request<{\n generateDashboardFromPrompt: { id: string; status: string };\n }>(GENERATE_DASHBOARD_FROM_PROMPT, {\n input: {\n prompt,\n ...(maxWidgets !== undefined ? { maxWidgets } : {}),\n ...(category !== undefined ? { category } : {}),\n ...(parsedTypes?.data ? { preferredWidgetTypes: parsedTypes.data } : {}),\n ...(additionalContext !== undefined ? { additionalContext } : {}),\n ...(visibility !== undefined ? { visibility } : {}),\n },\n });\n\n const generationId = submitted.generateDashboardFromPrompt.id;\n const deadline = Date.now() + timeout;\n\n for (;;) {\n const polled = await ctx.gql.workspace.request<{\n getPromptGeneration: {\n id: string;\n status: string;\n errorMessage?: string | null;\n generatedSpecDigest?: string | null;\n dashboardId?: string | null;\n } | null;\n }>(GET_PROMPT_GENERATION, { id: generationId });\n\n generation = polled.getPromptGeneration ?? {\n id: generationId,\n status: 'MISSING',\n errorMessage: 'Generation record vanished while polling.',\n };\n\n if (TERMINAL_SET.has(generation.status) || Date.now() >= deadline) break;\n await sleep(interval);\n }\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_generate_from_prompt failed', {\n error: String(error),\n });\n return errorResult(\n `Failed to generate the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n if (!generation) {\n return errorResult('Generation did not return a record — try again.');\n }\n\n if (!TERMINAL_SET.has(generation.status)) {\n return jsonResult({\n generationId: generation.id,\n status: generation.status,\n note:\n 'Still running when the poll budget ran out — the generation continues server-side; ' +\n 're-check from the app or re-run with a larger pollTimeoutMs before materializing.',\n });\n }\n if (generation.status === 'FAILED' || generation.status === 'CANCELLED') {\n return errorResult(\n `Generation ${generation.status.toLowerCase()}${generation.errorMessage ? `: ${generation.errorMessage}` : '.'}`,\n 'Fix the prompt (or the workspace state) and submit a new generation — re-running a ' +\n 'failed one just spends another credit.',\n );\n }\n\n // COMPLETED\n const base = {\n generationId: generation.id,\n status: generation.status,\n generatedSpecDigest: generation.generatedSpecDigest ?? null,\n };\n\n if (materialize !== true) {\n return jsonResult({\n ...base,\n materialized: false,\n next:\n 'Review the generated spec, then re-call with materialize: true and pass ' +\n 'generatedSpecDigest as expectedSpecDigest to create the dashboard.',\n });\n }\n\n try {\n const created = await ctx.gql.workspace.request<{\n createDashboardFromGeneration: Record<string, unknown>;\n }>(CREATE_DASHBOARD_FROM_GENERATION, {\n input: {\n generationId: generation.id,\n ...(expectedSpecDigest !== undefined ? { expectedSpecDigest } : {}),\n },\n });\n return jsonResult({\n ...base,\n materialized: true,\n dashboard: created.createDashboardFromGeneration,\n });\n } catch (error) {\n ctx.logger.error('bigconsole dashboard materialization failed', { error: String(error) });\n return errorResult(\n `Generation completed but materialization failed: ${error instanceof Error ? error.message : String(error)}`,\n 'The spec is still there — re-call with materialize: true and the same ' +\n 'generatedSpecDigest as expectedSpecDigest.',\n );\n }\n },\n );\n}\n","/**\n * BigConsole parser tools — the shaping layer of the pipeline.\n *\n * Surface (4): parsers_list, parser_create, parser_update,\n * parser_test_expression.\n *\n * A parser transforms a data sink's rows into the shape a widget renders:\n * `jq` / `jsonata` / `spark` over the sink's payload, read by `inputSinkKey`\n * (the slug, NOT the id), written to `outputKey`, scoped to a console via\n * `consoleId` — which is the DASHBOARD id. Parsers are optional: if sink rows\n * are already chart-shaped, bind the widget straight to the sink.\n *\n * `parser_test_expression` runs the expression server-side against a stored\n * sink (by id or key) or inline sample rows, so an agent can iterate on the\n * expression before creating anything.\n *\n * `parser_update` takes the optimistic-lock `version` as a required top-level\n * tool input (the backend's shape differs from updateDataSink's in-input\n * version) — see shared.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../../core/index.js';\nimport {\n CREATE_PARSER,\n LIST_PARSERS,\n TEST_PARSER_EXPRESSION,\n UPDATE_PARSER,\n} from '../operations.js';\nimport {\n PageCursor,\n PageSize,\n ParserStatusEnum,\n ParserTypeEnum,\n VersionInt,\n VERSION_OMITTED_MESSAGE,\n WORKSPACE_NOTE,\n} from './shared.js';\n\nexport function registerParserTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'parsers_list')),\n {\n title: 'List Parsers',\n description:\n 'The parsers of one console. `consoleId` is the DASHBOARD id (not the workspace id, ' +\n 'not a page id) — parsers belong to the whole console. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n consoleId: z.string().describe('Dashboard (console) ID'),\n first: PageSize,\n after: PageCursor,\n },\n },\n async ({ consoleId, first, after }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n listParsers: Record<string, unknown>;\n }>(LIST_PARSERS, { consoleId, first: first ?? 20, after: after ?? null });\n return jsonResult(data.listParsers);\n } catch (error) {\n ctx.logger.error('bigconsole parsers_list failed', { error: String(error) });\n return errorResult(\n `Failed to list parsers: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'parser_create')),\n {\n title: 'Create Parser',\n description:\n 'Create a parser on a console. Step 3 of the pipeline (DataSink → Dashboard → Parser → ' +\n 'Widget). `consoleId` is the dashboard id; `inputSinkKey` is the data sink KEY (slug), ' +\n 'not its id; `outputKey` is a new slug the widget will read. Prefer type jq. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n consoleId: z.string().describe('Dashboard (console) ID'),\n name: z.string().describe('Parser name'),\n type: ParserTypeEnum,\n expression: z\n .string()\n .describe('Transform expression, e.g. jq: [.[] | {label: .grade, value: .present}]'),\n inputSinkKey: z\n .string()\n .describe('The data sink KEY (slug) the parser reads — not the sink id'),\n outputKey: z.string().describe('New slug for the parser output, e.g. sales_2026_chart'),\n description: z.string().optional(),\n ttl: z.number().int().min(0).optional(),\n },\n },\n async ({ consoleId, name, type, expression, inputSinkKey, outputKey, description, ttl }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n createParser: Record<string, unknown>;\n }>(CREATE_PARSER, {\n input: {\n consoleId,\n name,\n type,\n expression,\n inputSinkKey,\n outputKey,\n ...(description !== undefined ? { description } : {}),\n ...(ttl !== undefined ? { ttl } : {}),\n },\n });\n return jsonResult(result.createParser);\n } catch (error) {\n ctx.logger.error('bigconsole parser_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the parser: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'parser_update')),\n {\n title: 'Update Parser',\n description:\n 'Update a parser with optimistic locking. `version` is REQUIRED and is a top-level ' +\n 'argument (unlike the data sink, where it lives inside the input) — read the current ' +\n 'value from parsers_list first and send it back unchanged; a stale version is rejected, ' +\n 'so re-read and retry rather than incrementing blindly. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n id: z.string().describe('Parser ID'),\n version: VersionInt.optional(),\n name: z.string().optional(),\n expression: z.string().optional(),\n inputSinkKey: z.string().optional(),\n outputKey: z.string().optional(),\n description: z.string().optional(),\n ttl: z.number().int().min(0).optional(),\n status: ParserStatusEnum.optional(),\n },\n },\n async ({\n id,\n version,\n name,\n expression,\n inputSinkKey,\n outputKey,\n description,\n ttl,\n status,\n }) => {\n if (version === undefined) {\n return errorResult(VERSION_OMITTED_MESSAGE);\n }\n try {\n const result = await ctx.gql.workspace.request<{\n updateParser: Record<string, unknown>;\n }>(UPDATE_PARSER, {\n id,\n version,\n input: {\n ...(name !== undefined ? { name } : {}),\n ...(expression !== undefined ? { expression } : {}),\n ...(inputSinkKey !== undefined ? { inputSinkKey } : {}),\n ...(outputKey !== undefined ? { outputKey } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(ttl !== undefined ? { ttl } : {}),\n ...(status !== undefined ? { status } : {}),\n },\n });\n return jsonResult(result.updateParser);\n } catch (error) {\n ctx.logger.error('bigconsole parser_update failed', { error: String(error) });\n return errorResult(\n `Failed to update the parser: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'parser_test_expression')),\n {\n title: 'Test Parser Expression',\n description:\n 'Run a parser expression server-side WITHOUT creating anything — against a stored data ' +\n 'sink (by id or key, preferred: the payload never crosses the wire to you) or against ' +\n 'inline sample rows. Iterate on the expression here, then parser_create. ' +\n WORKSPACE_NOTE,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n inputSchema: {\n type: ParserTypeEnum,\n expression: z.string().describe('Transform expression to test'),\n dataSinkId: z\n .string()\n .optional()\n .describe('Stored data sink ID to test against (preferred)'),\n dataSinkKey: z\n .string()\n .optional()\n .describe('Stored data sink key (slug) — alternative to dataSinkId'),\n sampleData: z\n .unknown()\n .optional()\n .describe(\n 'Inline sample payload (array of row objects) — alternative to a sink reference',\n ),\n sampleLimit: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe('Cap rows evaluated when testing against a stored sink'),\n },\n },\n async ({ type, expression, dataSinkId, dataSinkKey, sampleData, sampleLimit }) => {\n const refs = [dataSinkId, dataSinkKey, sampleData].filter((v) => v !== undefined).length;\n if (refs === 0) {\n return errorResult(\n 'Provide exactly one test target: dataSinkId, dataSinkKey, or sampleData.',\n 'Prefer a data sink reference so the payload stays server-side; use sampleData only ' +\n 'for the hand-edited-JSON path.',\n );\n }\n if (refs > 1) {\n return errorResult(\n 'dataSinkId, dataSinkKey and sampleData are mutually exclusive — provide exactly one.',\n );\n }\n try {\n const data = await ctx.gql.workspace.request<{\n testParserExpression: Record<string, unknown>;\n }>(TEST_PARSER_EXPRESSION, {\n input: {\n type,\n expression,\n ...(dataSinkId !== undefined ? { dataSinkId } : {}),\n ...(dataSinkKey !== undefined ? { dataSinkKey } : {}),\n ...(sampleData !== undefined ? { sampleData } : {}),\n ...(sampleLimit !== undefined ? { sampleLimit } : {}),\n },\n });\n return jsonResult(data.testParserExpression);\n } catch (error) {\n ctx.logger.error('bigconsole parser_test_expression failed', { error: String(error) });\n return errorResult(\n `Failed to test the expression: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * BigConsole widget tool — the rendering layer of the pipeline.\n *\n * Surface (1): widget_create.\n *\n * A widget is a built-in renderer + a rich declarative `config` + a field\n * mapping, bound to a data sink and/or parser, placed on a PAGE (not the\n * dashboard — get the page id from dashboard_get). Step 4 of the pipeline.\n *\n * ### The config is the custom-widget builder\n *\n * There is no code path: `config` is opaque JSON the renderer reads, and the\n * two rules that make a widget render correctly are enforced by the zod\n * shapes in shared.ts, not by documentation:\n *\n * - charts store as one internal renderer — `config.chartType`\n * (\"line\"|\"bar\"|\"area\"|\"pie\") must match the enum type or the widget\n * renders as a line regardless of `type`;\n * - single-KPI cards need `config._internalWidgetType: \"metric_card\"` and\n * retention grids need `\"retention\"` — without them the wrong renderer\n * picks the widget up.\n *\n * Field names in the config must match the keys the parser/sink emits per\n * row: the renderer reads `row[config.valueField]`, `row[config.xAxisField]`,\n * `row[column.key]` — a mismatch renders an empty widget with no error.\n *\n * Only the nine render-verified types are accepted; see shared.ts for why.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../../core/index.js';\nimport { CREATE_WIDGET } from '../operations.js';\nimport { WidgetConfig, WidgetPosition, WidgetTypeEnum, WORKSPACE_NOTE } from './shared.js';\n\nexport function registerWidgetTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'widget_create')),\n {\n title: 'Create Widget',\n description:\n 'Place a widget on a dashboard page — the last step of the pipeline (DataSink → ' +\n 'Dashboard → Parser → Widget). Bind data with parserId (preferred — the parser output ' +\n 'is already chart-shaped) and/or dataSinkId. Build a rich config for the chosen type ' +\n '(never {}): charts need config.chartType matching the type, single-KPI needs ' +\n 'config._internalWidgetType \"metric_card\", retention needs \"retention\"; field names ' +\n 'must match the parser/sink output keys. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n pageId: z\n .string()\n .describe('Page ID (from dashboard_get — widgets live on pages, not dashboards)'),\n title: z.string().describe('Widget title'),\n type: WidgetTypeEnum,\n config: WidgetConfig,\n position: WidgetPosition,\n parserId: z\n .string()\n .optional()\n .describe('Parser whose output the widget reads (preferred binding)'),\n dataSinkId: z\n .string()\n .optional()\n .describe('Data sink the widget reads (use alone when rows are already chart-shaped)'),\n },\n },\n async ({ pageId, title, type, config, position, parserId, dataSinkId }) => {\n if (!parserId && !dataSinkId) {\n return errorResult(\n 'Bind the widget to data: provide parserId and/or dataSinkId.',\n 'Widgets without a binding render empty. Prefer parserId so the data is already ' +\n 'shaped for the renderer.',\n );\n }\n try {\n const result = await ctx.gql.workspace.request<{\n createBigConsoleWidget: Record<string, unknown>;\n }>(CREATE_WIDGET, {\n input: {\n pageId,\n title,\n type,\n config,\n position,\n ...(parserId !== undefined ? { parserId } : {}),\n ...(dataSinkId !== undefined ? { dataSinkId } : {}),\n },\n });\n return jsonResult(result.createBigConsoleWidget);\n } catch (error) {\n ctx.logger.error('bigconsole widget_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the widget: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * BigConsole module — console authoring for external agents (BOFF-3729).\n *\n * Backend subgraph: ~/products/wspace/bigconsole/wspace-bigconsole-svc/\n * (Hive service name `bigconsole`). Runs against the WORKSPACE PUBLIC gateway,\n * which is where `@rbac` is enforced from the composed supergraph. This module\n * authorises nothing itself and never touches a token — `ctx.gql.workspace`\n * injects the session credential (app-client-credentials or device-code login)\n * and the `x-workspace-id` header chosen via `auth_select_workspace`.\n *\n * ### The least-privilege surface (AI_READINESS §2.2)\n *\n * Sixteen tools covering exactly the console-authoring pipeline and nothing\n * else:\n *\n * - DataSinks: list / get / create / update (4)\n * - Dashboards + pages: list / get / create / page-create (4)\n * - Parsers: list / create / update / test-expression (4)\n * - Widgets: create (1)\n * - Console Definition JSON: export / import (2) — the headline round-trip\n * - Generate-from-prompt: submit + poll + optional materialize (1)\n *\n * Deliberately absent: every `delete_*` / `archive_*` / `publish` /\n * share / RLS / embed / template-store mutation. Read + create (+ the two\n * sanctioned updates, both version-locked) is the valuable 90%, and an\n * external agent that cannot archive a production console is the security\n * posture the readiness audit asks for (§2.2/§2.3).\n *\n * ### The recipe is the contract\n *\n * Tool shapes mirror `ai-assistant/context/api-calls/products/bigconsole.md`\n * (the authoritative build recipe): the forced DataSink → Dashboard → Parser\n * → Widget order falls out of the argument shapes (`consoleId` = dashboard\n * id, widgets bound by pageId / parserId / dataSinkId), and the two footguns\n * are tool-level zod constraints in tools/shared.ts, not documentation.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerDashboardTools } from './tools/dashboards.js';\nimport { registerDataSinkTools } from './tools/datasinks.js';\nimport { registerGenerateTools } from './tools/generate.js';\nimport { registerParserTools } from './tools/parsers.js';\nimport { registerWidgetTools } from './tools/widgets.js';\n\nconst bigconsoleModule: McpModule = {\n id: 'bigconsole',\n version: '0.0.1',\n displayName: 'BigConsole',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerDataSinkTools(server, ctx, track);\n registerDashboardTools(server, ctx, track);\n registerParserTools(server, ctx, track);\n registerWidgetTools(server, ctx, track);\n registerGenerateTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default bigconsoleModule;\n"]}
1
+ {"version":3,"sources":["../../../src/modules/bigconsole/operations.ts","../../../src/modules/bigconsole/tools/shared.ts","../../../src/modules/bigconsole/tools/dashboards.ts","../../../src/modules/bigconsole/tools/datasinks.ts","../../../src/modules/bigconsole/tools/generate.ts","../../../src/modules/bigconsole/tools/parsers.ts","../../../src/modules/bigconsole/tools/widgets.ts","../../../src/modules/bigconsole/index.ts"],"names":["z"],"mappings":";;;;AAkCO,IAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AA2BxB,IAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAsBtB,IAAM,gBAAA,GAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAYzB,IAAM,gBAAA,GAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAezB,IAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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A,mBAAA,CAAoB,MAAA,EAAQ,KAAK,KAAK,CAAA;AACtC,IAAA,qBAAA,CAAsB,MAAA,EAAQ,KAAK,KAAK,CAAA;AAExC,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,kBAAA,GAAQ","file":"index.js","sourcesContent":["/**\n * Centralized GraphQL operations for the BigConsole MCP module (BOFF-3729).\n *\n * Backend subgraph: ~/products/wspace/bigconsole/wspace-bigconsole-svc/\n * (Hive service name `bigconsole`). Every operation here runs against the\n * WORKSPACE PUBLIC gateway, which is the only place `@rbac` is enforced from\n * the composed supergraph. This module authorises nothing itself and never\n * sees a token — `ctx.gql.workspace` injects the session's auth headers\n * (app-client-credentials or device-code login) plus the `x-workspace-id`\n * header set by `auth_select_workspace`.\n *\n * ### Selection sets are deliberately slim (BOFF-2719 / BOFF-2720)\n *\n * The gateway enforces a query-cost limit (`ARMOR_VIOLATION`) that fat\n * selection sets on `listDashboards` / `getDashboard` / `createDashboard`-\n * adjacent reads have tripped in production. So:\n *\n * - list queries select ids/keys/names and scalar metadata only — never\n * nested widget `config`, never `data` payloads;\n * - a widget's full `config` is only ever fetched for a single widget being\n * edited, and v1 ships no widget-config read at all;\n * - `getDataSink` never selects `data` (the payload can be arbitrarily large).\n *\n * Every operation name, argument and selected field below was verified\n * against the subgraph's `.hive-schema.graphql` — not assumed from naming.\n *\n * Uses template-string interpolation (not gql tagged fragments) to match the\n * canonical healthybowl / kadaikodi module operations files.\n */\n\n// ---------------------------------------------------------------------------\n// DataSinks\n// ---------------------------------------------------------------------------\n\nexport const LIST_DATA_SINKS = `\n query BigConsoleMcpListDataSinks($first: Int, $after: String, $search: String, $status: DataSinkStatus) {\n listDataSinks(first: $first, after: $after, search: $search, status: $status) {\n edges {\n node {\n id\n key\n name\n description\n status\n isActive\n setupState\n ttl\n version\n lastRefreshedAt\n updatedAt\n }\n }\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`;\n\nexport const GET_DATA_SINK = `\n query BigConsoleMcpGetDataSink($id: ID, $key: String) {\n getDataSink(id: $id, key: $key) {\n id\n key\n name\n description\n status\n isActive\n setupState\n dataClassification\n fieldMaskingEnabled\n ttl\n version\n linkedParserCount\n createdAt\n updatedAt\n lastRefreshedAt\n }\n }\n`;\n\nexport const CREATE_DATA_SINK = `\n mutation BigConsoleMcpCreateDataSink($input: CreateDataSinkInput!) {\n createDataSink(input: $input) {\n id\n key\n name\n status\n version\n }\n }\n`;\n\nexport const UPDATE_DATA_SINK = `\n mutation BigConsoleMcpUpdateDataSink($input: UpdateDataSinkInput!) {\n updateDataSink(input: $input) {\n id\n key\n name\n version\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Dashboards (consoles) + pages\n// ---------------------------------------------------------------------------\n\nexport const LIST_DASHBOARDS = `\n query BigConsoleMcpListDashboards(\n $first: Int\n $after: String\n $search: String\n $category: BigConsoleDashboardCategory\n $visibility: BigConsoleDashboardVisibility\n $includeArchived: Boolean\n ) {\n listDashboards(\n first: $first\n after: $after\n search: $search\n category: $category\n visibility: $visibility\n includeArchived: $includeArchived\n ) {\n edges {\n node {\n id\n name\n description\n category\n visibility\n status\n isArchived\n pageCount\n widgetCount\n updatedAt\n }\n }\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`;\n\nexport const GET_DASHBOARD = `\n query BigConsoleMcpGetDashboard($id: ID!) {\n getDashboard(id: $id) {\n id\n name\n description\n category\n visibility\n status\n isArchived\n pageCount\n widgetCount\n publishedAt\n globalFilters {\n id\n name\n type\n dependsOn\n }\n pages(first: 20) {\n edges {\n node {\n id\n name\n order\n widgetCount\n }\n }\n totalCount\n pageInfo {\n hasNextPage\n }\n }\n }\n }\n`;\n\nexport const CREATE_DASHBOARD = `\n mutation BigConsoleMcpCreateDashboard($input: BigConsoleCreateDashboardInput!) {\n createBigConsoleDashboard(input: $input) {\n id\n name\n category\n visibility\n status\n pageCount\n }\n }\n`;\n\nexport const CREATE_DASHBOARD_PAGE = `\n mutation BigConsoleMcpCreateDashboardPage($input: BigConsoleCreateDashboardPageInput!) {\n createDashboardPage(input: $input) {\n id\n name\n dashboardId\n order\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Parsers\n// ---------------------------------------------------------------------------\n\nexport const LIST_PARSERS = `\n query BigConsoleMcpListParsers($consoleId: ID!, $first: Int, $after: String) {\n listParsers(filter: { consoleId: $consoleId }, first: $first, after: $after) {\n edges {\n node {\n id\n name\n type\n status\n inputSinkKey\n outputKey\n version\n updatedAt\n }\n }\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`;\n\nexport const CREATE_PARSER = `\n mutation BigConsoleMcpCreateParser($input: CreateParserInput!) {\n createParser(input: $input) {\n id\n name\n type\n status\n inputSinkKey\n outputKey\n version\n }\n }\n`;\n\nexport const UPDATE_PARSER = `\n mutation BigConsoleMcpUpdateParser($id: ID!, $input: UpdateParserInput!, $version: Int!) {\n updateParser(id: $id, input: $input, version: $version) {\n id\n name\n type\n status\n inputSinkKey\n outputKey\n version\n }\n }\n`;\n\nexport const TEST_PARSER_EXPRESSION = `\n query BigConsoleMcpTestParserExpression($input: TestParserInput!) {\n testParserExpression(input: $input) {\n success\n output\n error\n executionTimeMs\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Widgets\n// ---------------------------------------------------------------------------\n\nexport const CREATE_WIDGET = `\n mutation BigConsoleMcpCreateWidget($input: BigConsoleCreateWidgetInput!) {\n createBigConsoleWidget(input: $input) {\n id\n title\n type\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Export / import — the Console Definition JSON round-trip\n// ---------------------------------------------------------------------------\n\nexport const EXPORT_DASHBOARD = `\n query BigConsoleMcpExportDashboard($id: ID!, $options: BigConsoleExportDashboardOptions) {\n exportDashboard(id: $id, options: $options)\n }\n`;\n\n/**\n * Import is the v2.0 path (`importBigConsoleDashboard`), NOT the legacy\n * `importDashboard` mutation: the export QUERY emits schemaVersion \"1.0\"\n * with `pages` at the TOP level of the document, while the legacy v1\n * mutation reads `dashboard.pages` (the deprecated v1 export-mutation\n * layout) and silently imports an EMPTY dashboard from a v2 export. The v2\n * mutation is the verified round-trip partner of `exportDashboard` and\n * reports per-entity stats (pages/widgets/actions/filters created).\n */\nexport const IMPORT_DASHBOARD = `\n mutation BigConsoleMcpImportDashboard($input: ImportBigConsoleDashboardInput!) {\n importBigConsoleDashboard(input: $input) {\n success\n errorMessage\n dashboard {\n id\n name\n pageCount\n widgetCount\n }\n stats {\n pagesCreated\n widgetsCreated\n actionsCreated\n filtersCreated\n dataSourcesSkipped\n }\n }\n }\n`;\n\n/**\n * Validate an import WITHOUT creating anything. importBigConsoleDashboard\n * refuses (success: false) when the definition carries non-blocking warnings\n * until the caller passes skipWarnings: true — the agent needs the warning\n * text to make that call, and this query is how it reads them.\n */\nexport const VALIDATE_DASHBOARD_IMPORT = `\n query BigConsoleMcpValidateDashboardImport($content: String!) {\n validateDashboardImport(content: $content) {\n isValid\n dashboardInfo {\n name\n pageCount\n widgetCount\n schemaVersion\n }\n errors {\n code\n message\n path\n }\n warnings {\n code\n message\n suggestion\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Generate-from-prompt lifecycle\n// ---------------------------------------------------------------------------\n\nexport const GENERATE_DASHBOARD_FROM_PROMPT = `\n mutation BigConsoleMcpGenerateDashboardFromPrompt($input: BigConsoleGenerateDashboardFromPromptInput!) {\n generateDashboardFromPrompt(input: $input) {\n id\n status\n }\n }\n`;\n\nexport const GET_PROMPT_GENERATION = `\n query BigConsoleMcpGetPromptGeneration($id: ID!) {\n getPromptGeneration(id: $id) {\n id\n status\n errorMessage\n generatedSpecDigest\n dashboardId\n }\n }\n`;\n\nexport const CREATE_DASHBOARD_FROM_GENERATION = `\n mutation BigConsoleMcpCreateDashboardFromGeneration($input: BigConsoleCreateDashboardFromGenerationInput!) {\n createDashboardFromGeneration(input: $input) {\n id\n name\n pageCount\n widgetCount\n }\n }\n`;\n","/**\n * Shared zod shapes + guardrails for the BigConsole tool surface.\n *\n * ### No tool here takes a workspace or a token\n *\n * `@rbac(scopeType: \"wspace\")` authorises the workspace named in the\n * `x-workspace-id` gateway header — the one `auth_select_workspace` sets — and\n * nothing else. BigConsole's inputs carry no workspace field at all, so there\n * is nothing to expose. Likewise no tool takes a token: the session's\n * credential (app-client-credentials or device-code login) is injected by\n * `ctx.gql.workspace` from the auth store, and a tool-level token input would\n * be a forwarded-user-token hole (AI_READINESS §2.1).\n *\n * ### The two footguns are encoded here, not in documentation\n *\n * 1. **The nine render-verified widget types.** Since BOFF-3550 every native\n * `BigConsoleWidgetType` member passes the gateway enum, but `config` is\n * opaque JSON and the renderer is the only judge — the v2.0-internal\n * lowercase keys (`kanban`, `pivot_table`, …) and the native types without\n * documented configs render wrong or not at all. The allowlist below is\n * the nine render-verified members; anything else is rejected client-side\n * with a message that names all nine.\n * 2. **Optimistic locking.** `updateDataSink` carries `version` inside the\n * input; `updateParser` takes it as a top-level argument. Both are\n * required `Int` tool inputs — a caller must read the current version\n * first (every read selects it) and send it back unchanged.\n *\n * @module bigconsole\n */\n\nimport { z } from 'zod';\n\n/** Appended to every tool description so the failure mode is stated where it will be read. */\nexport const WORKSPACE_NOTE =\n 'Operates on the workspace selected via auth_select_workspace — this tool takes no workspace ' +\n 'or token argument. Authorization is enforced at the gateway from the authenticated session.';\n\n// ── The nine render-verified widget types ───────────────────────────────────\n\nexport const WIDGET_TYPES = [\n 'LINE_CHART',\n 'BAR_CHART',\n 'AREA_CHART',\n 'PIE_CHART',\n 'TABLE',\n 'KPI',\n 'HEATMAP',\n 'FUNNEL',\n 'RETENTION',\n] as const;\n\nexport const WIDGET_TYPE_LIST = WIDGET_TYPES.join(', ');\n\nconst WIDGET_TYPE_REJECTION = (value: string): string =>\n `\"${value}\" is not a render-verified BigConsole widget type. This tool accepts exactly the nine ` +\n `render-verified types: ${WIDGET_TYPE_LIST}. (Since BOFF-3550 the gateway enum accepts more, ` +\n `but config is opaque JSON and only these nine have renderer-verified configs — see the ` +\n `bigconsole.md recipe / reference-widgets/widget-configs.json before reaching for anything else.)`;\n\nexport const WidgetTypeEnum = z\n .enum(WIDGET_TYPES)\n .describe(\n `Widget renderer — one of the nine render-verified types: ${WIDGET_TYPE_LIST}. ` +\n 'The lowercase v2.0-internal keys (kanban, pivot_table, …) are rejected here.',\n );\n\n/**\n * Same nine-value gate for list-shaped inputs (`preferredWidgetTypes`).\n * Rejects every non-member individually with the full list in the message.\n */\nexport const WidgetTypeArray = z\n .array(z.string())\n .superRefine((values, ctx) => {\n for (const value of values) {\n if (!(WIDGET_TYPES as readonly string[]).includes(value)) {\n ctx.addIssue({ code: 'custom', message: WIDGET_TYPE_REJECTION(value) });\n }\n }\n })\n .transform((values) => values as (typeof WIDGET_TYPES)[number][]);\n\n// ── Other enums ─────────────────────────────────────────────────────────────\n\nexport const DashboardCategoryEnum = z\n .enum(['CUSTOM', 'EXECUTIVE', 'FINANCIAL', 'HR', 'MARKETING', 'OPERATIONS', 'SALES'])\n .describe('Dashboard category — pick the closest fit; CUSTOM when nothing fits');\n\nexport const DashboardVisibilityEnum = z\n .enum(['PRIVATE', 'WORKSPACE', 'PUBLIC'])\n .describe('Dashboard visibility (default PRIVATE)');\n\nexport const ParserTypeEnum = z\n .enum(['jq', 'jsonata', 'spark'])\n .describe('Parser transform engine — prefer jq');\n\nexport const ParserStatusEnum = z.enum(['active', 'inactive']).describe('Parser status');\n\nexport const DataSinkStatusEnum = z\n .enum(['ready', 'refreshing', 'stale', 'error'])\n .describe('Data sink status filter');\n\n// ── DataSink key ────────────────────────────────────────────────────────────\n\nconst DATA_SINK_KEY_PATTERN = /^[a-z0-9_]+$/;\n\nexport const DataSinkKey = z\n .string()\n .regex(\n DATA_SINK_KEY_PATTERN,\n 'Data sink keys are lowercase letters, numbers and underscores only — no hyphens ' +\n '(e.g. sales_2026).',\n )\n .describe('Unique slug within the workspace — lowercase letters, numbers, underscores only');\n\n// ── Widget config guard (the custom-widget hard limits) ─────────────────────\n\n/** Config keys the backend hard-rejects; encoding them client-side fails faster and clearer. */\nconst FORBIDDEN_CONFIG_KEYS = [\n 'html',\n 'iframeUrl',\n 'script',\n 'scriptUrl',\n 'render',\n 'srcDoc',\n 'onClick',\n] as const;\n\nconst FORBIDDEN_VALUE_PATTERN = /javascript:/i;\n\nfunction configViolation(key: string): string {\n return (\n `Widget config key \"${key}\" is not allowed — BigConsole widgets are built-in renderers + ` +\n 'declarative config, never custom code. No html, iframeUrl, script, scriptUrl, render, ' +\n 'srcDoc, onClick, or javascript: values.'\n );\n}\n\nexport const WidgetConfig = z\n .record(z.string(), z.unknown())\n .superRefine((config, ctx) => {\n for (const key of Object.keys(config)) {\n if ((FORBIDDEN_CONFIG_KEYS as readonly string[]).includes(key)) {\n ctx.addIssue({ code: 'custom', message: configViolation(key) });\n continue;\n }\n const value = config[key];\n if (typeof value === 'string' && FORBIDDEN_VALUE_PATTERN.test(value)) {\n ctx.addIssue({ code: 'custom', message: configViolation(`${key} (javascript: URL)`) });\n }\n }\n })\n .describe(\n 'Declarative renderer config (never empty). Charts need config.chartType ' +\n '(\"line\"|\"bar\"|\"area\"|\"pie\") matching the type; a single KPI needs ' +\n 'config._internalWidgetType \"metric_card\"; retention needs \"retention\". Field names must ' +\n 'match the parser/sink output keys.',\n );\n\n// ── Widget position on the 12-column grid ───────────────────────────────────\n\nexport const WidgetPosition = z\n .object({\n x: z.number().int().min(0).max(11).describe('Column start, 0–11'),\n y: z.number().int().min(0).describe('Row start'),\n width: z.number().int().min(1).max(12).describe('Width in columns, 1–12'),\n height: z.number().int().min(1).describe('Height in rows'),\n })\n .superRefine((position, ctx) => {\n if (position.x + position.width > 12) {\n ctx.addIssue({\n code: 'custom',\n message: `x + width must be ≤ 12 on the 12-column grid (got x=${position.x}, width=${position.width}).`,\n });\n }\n })\n .describe('Grid position on a 12-column grid: x 0–11, width 1–12, x+width ≤ 12, height ≥ 1');\n\n// ── Version (optimistic lock) ───────────────────────────────────────────────\n\nexport const VersionInt = z\n .number()\n .int()\n .describe(\n 'Current version for optimistic locking — read it from a get/list call first and send it ' +\n 'back unchanged; a stale version is rejected, so re-read and retry rather than guessing.',\n );\n\n/**\n * Rejection an update tool returns when `version` was omitted. Declared\n * optional in the zod schema so the HANDLER can produce this explicit\n * optimistic-lock message instead of the SDK's generic schema error — the\n * requirement is real either way: no update reaches the gateway without a\n * version.\n */\nexport const VERSION_OMITTED_MESSAGE =\n 'version is required for optimistic locking — read the current version from a get/list call ' +\n 'first and send it back unchanged. A stale version is rejected by the backend, so re-read and ' +\n 'retry rather than guessing or incrementing.';\n\n// ── Pagination ──────────────────────────────────────────────────────────────\n\nexport const PageSize = z\n .number()\n .int()\n .min(1)\n .max(100)\n .default(20)\n .describe('Page size (max 100)');\n\nexport const PageCursor = z\n .string()\n .optional()\n .describe('Pagination cursor from pageInfo.endCursor');\n","/**\n * BigConsole dashboard (console) tools, including the export/import round-trip.\n *\n * Surface (6): dashboards_list, dashboard_get, dashboard_create,\n * dashboard_page_create, dashboard_export, dashboard_import.\n *\n * ### \"Dashboards as code\" is the point of this module\n *\n * `dashboard_export` returns the Console Definition JSON — one declarative\n * document with the whole console (pages, widgets, layout, global filters).\n * `dashboard_import` reconstructs a console from that string. Round-trip them\n * and a coding agent can commit a console definition next to application code\n * and diff it in review; that workflow is the positioning no incumbent BI\n * vendor offers. Imported dashboards get REGENERATED ids — re-bind anything\n * that referenced the old dashboard by id.\n *\n * ### Lifecycle mutations are deliberately absent\n *\n * `archiveDashboard` / `restoreDashboard` / `publishDashboard` are not here:\n * archiving a production console is the destructive action v1 refuses to\n * expose to an external agent (AI_READINESS §2.2/§2.3). Read + create +\n * export/import is the valuable 90%.\n *\n * ### Selection sets stay slim (BOFF-2719 / BOFF-2720)\n *\n * Lists select scalar metadata only. `dashboard_get` pages through at most\n * 20 pages with per-page widget counts — it never expands widget configs,\n * which is what tripped the gateway cost limit in production.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport {\n jsonResult,\n textResult,\n errorResult,\n mcpToolName,\n type McpContext,\n} from '../../../core/index.js';\nimport {\n CREATE_DASHBOARD,\n CREATE_DASHBOARD_PAGE,\n EXPORT_DASHBOARD,\n GET_DASHBOARD,\n IMPORT_DASHBOARD,\n LIST_DASHBOARDS,\n VALIDATE_DASHBOARD_IMPORT,\n} from '../operations.js';\nimport {\n DashboardCategoryEnum,\n DashboardVisibilityEnum,\n PageCursor,\n PageSize,\n WORKSPACE_NOTE,\n} from './shared.js';\n\nexport function registerDashboardTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboards_list')),\n {\n title: 'List Dashboards',\n description:\n 'The dashboards (consoles) visible in the active workspace — metadata only, no widget ' +\n `configs. ${WORKSPACE_NOTE}`,\n inputSchema: {\n first: PageSize,\n after: PageCursor,\n search: z.string().optional().describe('Filter by name substring'),\n category: DashboardCategoryEnum.optional(),\n visibility: DashboardVisibilityEnum.optional(),\n includeArchived: z\n .boolean()\n .optional()\n .describe('Include archived dashboards (excluded by default)'),\n },\n },\n async ({ first, after, search, category, visibility, includeArchived }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n listDashboards: Record<string, unknown>;\n }>(LIST_DASHBOARDS, {\n first: first ?? 20,\n after: after ?? null,\n search: search ?? null,\n category: category ?? null,\n visibility: visibility ?? null,\n includeArchived: includeArchived ?? null,\n });\n return jsonResult(data.listDashboards);\n } catch (error) {\n ctx.logger.error('bigconsole dashboards_list failed', { error: String(error) });\n return errorResult(\n `Failed to list dashboards: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_get')),\n {\n title: 'Get Dashboard',\n description:\n 'One dashboard with its pages (ids — you need the page id to place widgets), global ' +\n 'filters, and page/widget counts. Widget configs are NOT expanded (gateway cost ' +\n 'limit). ' +\n WORKSPACE_NOTE,\n inputSchema: {\n id: z.string().describe('Dashboard ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getDashboard: Record<string, unknown> | null;\n }>(GET_DASHBOARD, { id });\n if (!data.getDashboard) {\n return errorResult(`Dashboard \"${id}\" not found or not visible.`);\n }\n return jsonResult(data.getDashboard);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_get failed', { error: String(error) });\n return errorResult(\n `Failed to get the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_create')),\n {\n title: 'Create Dashboard',\n description:\n 'Create a console (dashboard). `createDefaultPage` defaults to true, so a first page is ' +\n 'created for you — read its id back via dashboard_get to place widgets. Step 2 of the ' +\n 'pipeline (DataSink → Dashboard → Parser → Widget). ' +\n WORKSPACE_NOTE,\n inputSchema: {\n name: z.string().describe('Dashboard name'),\n category: DashboardCategoryEnum,\n description: z.string().optional(),\n visibility: DashboardVisibilityEnum.optional(),\n createDefaultPage: z.boolean().optional().describe('Create a first page (default true)'),\n },\n },\n async ({ name, category, description, visibility, createDefaultPage }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n createBigConsoleDashboard: Record<string, unknown>;\n }>(CREATE_DASHBOARD, {\n input: {\n name,\n category,\n ...(description !== undefined ? { description } : {}),\n ...(visibility !== undefined ? { visibility } : {}),\n ...(createDefaultPage !== undefined ? { createDefaultPage } : {}),\n },\n });\n return jsonResult(result.createBigConsoleDashboard);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_page_create')),\n {\n title: 'Create Dashboard Page',\n description:\n 'Add a page to an existing dashboard. Only needed for multi-page consoles — a new ' +\n 'dashboard already has a default page. Widgets are placed on a page, not on the ' +\n 'dashboard. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n dashboardId: z.string().describe('Parent dashboard ID'),\n name: z.string().describe('Page name'),\n },\n },\n async ({ dashboardId, name }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n createDashboardPage: Record<string, unknown>;\n }>(CREATE_DASHBOARD_PAGE, { input: { dashboardId, name } });\n return jsonResult(result.createDashboardPage);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_page_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the page: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_export')),\n {\n title: 'Export Dashboard (Console Definition JSON)',\n description:\n 'Export a dashboard as the portable Console Definition JSON — one declarative document ' +\n 'with pages, widgets, layout and global filters. Commit it next to your code, diff it ' +\n 'in review, feed it to dashboard_import to reconstruct. This is a QUERY, not a mutation. ' +\n 'Leave includeWebhookMappings false unless you hold dashboard-edit permission AND a ' +\n 'current export consent grant. ' +\n WORKSPACE_NOTE,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n inputSchema: {\n id: z.string().describe('Dashboard ID to export'),\n prettyPrint: z.boolean().optional().describe('Pretty-print the JSON (default true)'),\n includeDataSourceRefs: z\n .boolean()\n .optional()\n .describe('Include data source references (default false)'),\n includeWebhookMappings: z\n .boolean()\n .optional()\n .describe(\n 'Include webhook mappings (default false; requires dashboard-edit permission and a ' +\n 'current export consent grant — never request casually)',\n ),\n },\n },\n async ({ id, prettyPrint, includeDataSourceRefs, includeWebhookMappings }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n exportDashboard: string;\n }>(EXPORT_DASHBOARD, {\n id,\n options: {\n prettyPrint: prettyPrint ?? true,\n includeDataSourceRefs: includeDataSourceRefs ?? false,\n includeWebhookMappings: includeWebhookMappings ?? false,\n },\n });\n return textResult(data.exportDashboard);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_export failed', { error: String(error) });\n return errorResult(\n `Failed to export the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_import')),\n {\n title: 'Import Dashboard (Console Definition JSON)',\n description:\n 'Reconstruct a dashboard from a Console Definition JSON string (from dashboard_export). ' +\n 'This is the cross-workspace move: export in one workspace, import the string in ' +\n 'another. Uses the v2.0 import path with per-entity stats — do NOT pair an export with ' +\n 'the legacy importDashboard mutation, which expects the deprecated v1 layout and ' +\n 'silently imports an empty dashboard. Imported ids are REGENERATED — re-bind anything ' +\n 'that referenced the old dashboard by id. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n content: z.string().describe('The Console Definition JSON string'),\n name: z.string().optional().describe('Override the dashboard name'),\n visibility: DashboardVisibilityEnum.optional(),\n skipWarnings: z\n .boolean()\n .optional()\n .describe('Import despite non-blocking validation warnings (default false)'),\n },\n },\n async ({ content, name, visibility, skipWarnings }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n importBigConsoleDashboard: {\n success: boolean;\n errorMessage?: string | null;\n dashboard?: Record<string, unknown> | null;\n stats?: Record<string, unknown> | null;\n };\n }>(IMPORT_DASHBOARD, {\n input: {\n content,\n ...(name !== undefined ? { name } : {}),\n ...(visibility !== undefined ? { visibility } : {}),\n ...(skipWarnings !== undefined ? { skipWarnings } : {}),\n },\n });\n if (!result.importBigConsoleDashboard.success) {\n // The v2 importer refuses to create when the definition carries\n // non-blocking warnings until the caller passes skipWarnings: true.\n // Fetch the validation detail so the agent can SEE the warnings and\n // make an informed acknowledge-or-fix decision.\n let detail = '';\n try {\n const validation = await ctx.gql.workspace.request<{\n validateDashboardImport: {\n errors: Array<{ code: string; message: string }>;\n warnings: Array<{ code: string; message: string; suggestion?: string | null }>;\n };\n }>(VALIDATE_DASHBOARD_IMPORT, { content });\n const lines: string[] = [];\n for (const e of validation.validateDashboardImport.errors ?? []) {\n lines.push(`error ${e.code}: ${e.message}`);\n }\n for (const w of validation.validateDashboardImport.warnings ?? []) {\n lines.push(\n `warning ${w.code}: ${w.message}${w.suggestion ? ` (${w.suggestion})` : ''}`,\n );\n }\n if (lines.length > 0) detail = ` Validation says: ${lines.join(' | ')}`;\n } catch {\n // validation fetch is best-effort; the raw errorMessage still stands\n }\n return errorResult(\n `Import failed: ${result.importBigConsoleDashboard.errorMessage ?? 'unknown error'}.${detail}`,\n 'Read the errors/warnings above; fix the definition, or re-call with skipWarnings: ' +\n 'true ONLY if every warning is understood and acceptable.',\n );\n }\n return jsonResult(result.importBigConsoleDashboard);\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_import failed', { error: String(error) });\n return errorResult(\n `Failed to import the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * BigConsole data sink tools — the data layer of the console pipeline.\n *\n * Surface (4): datasinks_list, datasink_get, datasink_create, datasink_update.\n *\n * Read + create/update only — there is intentionally no `datasink_delete`:\n * sinks can feed live workflows and parsers, and an external agent retiring\n * one it does not fully understand is exactly the destructive action v1\n * omits (AI_READINESS §2.3).\n *\n * `datasink_get` never selects the `data` payload — sinks can hold arbitrary\n * bulk rows, and the MCP surface exists to author consoles, not to exfiltrate\n * data. Use `getDataSinkData` from the app when you actually need rows.\n *\n * `datasink_update` carries the optimistic-lock `version` INSIDE the input\n * (the backend's shape) and requires it as a tool input — see shared.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../../core/index.js';\nimport {\n CREATE_DATA_SINK,\n GET_DATA_SINK,\n LIST_DATA_SINKS,\n UPDATE_DATA_SINK,\n} from '../operations.js';\nimport {\n DataSinkKey,\n DataSinkStatusEnum,\n PageCursor,\n PageSize,\n VersionInt,\n VERSION_OMITTED_MESSAGE,\n WORKSPACE_NOTE,\n} from './shared.js';\n\nexport function registerDataSinkTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'datasinks_list')),\n {\n title: 'List Data Sinks',\n description:\n 'The data sinks of the active workspace with status and refresh metadata — metadata ' +\n `only, never payloads. ${WORKSPACE_NOTE}`,\n inputSchema: {\n first: PageSize,\n after: PageCursor,\n search: z.string().optional().describe('Filter by name or key substring'),\n status: DataSinkStatusEnum.optional(),\n },\n },\n async ({ first, after, search, status }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n listDataSinks: Record<string, unknown>;\n }>(LIST_DATA_SINKS, {\n first: first ?? 20,\n after: after ?? null,\n search: search ?? null,\n status: status ?? null,\n });\n return jsonResult(data.listDataSinks);\n } catch (error) {\n ctx.logger.error('bigconsole datasinks_list failed', { error: String(error) });\n return errorResult(\n `Failed to list data sinks: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'datasink_get')),\n {\n title: 'Get Data Sink',\n description:\n 'One data sink by id or key (exactly one of them) — metadata, linked-parser count and ' +\n 'version for optimistic-lock updates. Does NOT return the stored data payload. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n id: z.string().optional().describe('Data sink ID'),\n key: z.string().optional().describe('Data sink key (slug) — alternative to id'),\n },\n },\n async ({ id, key }) => {\n if (!id && !key) {\n return errorResult(\n 'Provide exactly one of id or key.',\n 'Pass the data sink id from datasinks_list, or its key (slug).',\n );\n }\n if (id && key) {\n return errorResult('Provide exactly one of id or key, not both.');\n }\n try {\n const data = await ctx.gql.workspace.request<{\n getDataSink: Record<string, unknown> | null;\n }>(GET_DATA_SINK, { id: id ?? null, key: key ?? null });\n if (!data.getDataSink) {\n return errorResult(`Data sink not found for ${id ? `id \"${id}\"` : `key \"${key}\"`}.`);\n }\n return jsonResult(data.getDataSink);\n } catch (error) {\n ctx.logger.error('bigconsole datasink_get failed', { error: String(error) });\n return errorResult(\n `Failed to get the data sink: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'datasink_create')),\n {\n title: 'Create Data Sink',\n description:\n 'Create a data sink — the first step of the console pipeline (DataSink → Dashboard → ' +\n 'Parser → Widget). `key` is the only required field; pass `data` as an array of row ' +\n 'objects for a snapshot, or leave it empty and feed the sink from a workflow later. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n key: DataSinkKey,\n name: z.string().optional().describe('Display name (defaults to the key)'),\n description: z.string().optional(),\n data: z\n .unknown()\n .optional()\n .describe('Initial payload — an array of row objects for a snapshot load'),\n ttl: z.number().int().min(0).optional().describe('Cache TTL in seconds (default 300)'),\n },\n },\n async ({ key, name, description, data, ttl }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n createDataSink: Record<string, unknown>;\n }>(CREATE_DATA_SINK, {\n input: {\n key,\n ...(name !== undefined ? { name } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(data !== undefined ? { data } : {}),\n ...(ttl !== undefined ? { ttl } : {}),\n },\n });\n return jsonResult(result.createDataSink);\n } catch (error) {\n ctx.logger.error('bigconsole datasink_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the data sink: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'datasink_update')),\n {\n title: 'Update Data Sink',\n description:\n 'Update a data sink with optimistic locking. `version` is REQUIRED — read the current ' +\n 'value from datasink_get first and send it back unchanged; a stale version is rejected, ' +\n 'so re-read and retry rather than incrementing blindly. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n id: z.string().describe('Data sink ID'),\n version: VersionInt.optional(),\n name: z.string().optional(),\n description: z.string().optional(),\n data: z.unknown().optional().describe('Replacement payload (array of row objects)'),\n ttl: z.number().int().min(0).optional(),\n isActive: z.boolean().optional(),\n },\n },\n async ({ id, version, name, description, data, ttl, isActive }) => {\n if (version === undefined) {\n return errorResult(VERSION_OMITTED_MESSAGE);\n }\n try {\n const result = await ctx.gql.workspace.request<{\n updateDataSink: Record<string, unknown>;\n }>(UPDATE_DATA_SINK, {\n input: {\n id,\n version,\n ...(name !== undefined ? { name } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(data !== undefined ? { data } : {}),\n ...(ttl !== undefined ? { ttl } : {}),\n ...(isActive !== undefined ? { isActive } : {}),\n },\n });\n return jsonResult(result.updateDataSink);\n } catch (error) {\n ctx.logger.error('bigconsole datasink_update failed', { error: String(error) });\n return errorResult(\n `Failed to update the data sink: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * BigConsole generate-from-prompt tool — the AI console lifecycle.\n *\n * Surface (1): dashboard_generate_from_prompt.\n *\n * Runs the whole lifecycle in one call: submit the generation, poll it to a\n * terminal status (PENDING → PROCESSING → GENERATING → COMPLETED | FAILED |\n * CANCELLED), then — only when `materialize` is explicitly true — turn the\n * completed spec into a real dashboard via createDashboardFromGeneration.\n *\n * ### Metering and defaults\n *\n * `generateDashboardFromPrompt` and `createDashboardFromGeneration` are\n * `@usage`-metered (they spend the workspace's AI credits). `materialize`\n * therefore defaults to FALSE: the default path spends exactly one\n * generation and hands the agent the spec digest to review, and turning it\n * into a dashboard is an explicit second decision. Pass the exact\n * `generatedSpecDigest` this tool returns back as `expectedSpecDigest` with\n * `materialize: true` so linked reuse refuses an obsolete revision instead of\n * silently materializing a changed spec.\n *\n * A generated console arrives bound to whatever the spec says — verify widget\n * bindings against the workspace's real data sinks (datasinks_list) before\n * trusting it as live.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../../core/index.js';\nimport {\n CREATE_DASHBOARD_FROM_GENERATION,\n GENERATE_DASHBOARD_FROM_PROMPT,\n GET_PROMPT_GENERATION,\n} from '../operations.js';\nimport {\n DashboardCategoryEnum,\n DashboardVisibilityEnum,\n WidgetTypeArray,\n WORKSPACE_NOTE,\n} from './shared.js';\n\nconst TERMINAL_STATUSES = ['COMPLETED', 'FAILED', 'CANCELLED'] as const;\n\nconst TERMINAL_SET: ReadonlySet<string> = new Set(TERMINAL_STATUSES);\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function registerGenerateTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'dashboard_generate_from_prompt')),\n {\n title: 'Generate Dashboard From Prompt',\n description:\n 'Generate a whole console spec from natural language, poll it to completion, and ' +\n 'optionally materialize it into a real dashboard. Metered (spends AI credits): ' +\n 'generating always costs one generation; materialization only happens when ' +\n '`materialize: true`, and should pass the returned generatedSpecDigest back as ' +\n 'expectedSpecDigest so an obsolete spec revision is refused. After materializing, ' +\n \"verify widget bindings against the workspace's real data sinks. \" +\n WORKSPACE_NOTE,\n inputSchema: {\n prompt: z\n .string()\n .describe(\n 'Natural language description of the desired console, e.g. \"a sales dashboard with ' +\n 'revenue trends, top products and regional performance\"',\n ),\n maxWidgets: z\n .number()\n .int()\n .min(1)\n .max(24)\n .optional()\n .describe('Maximum widgets to generate (default 8)'),\n category: DashboardCategoryEnum.optional(),\n preferredWidgetTypes: z\n .array(z.string())\n .optional()\n .describe(\n 'Preferred widget types (from the nine render-verified types; any other value is ' +\n 'rejected with the full list)',\n ),\n additionalContext: z.string().optional(),\n visibility: DashboardVisibilityEnum.optional(),\n materialize: z\n .boolean()\n .optional()\n .describe(\n 'Materialize the completed spec into a real dashboard (default false; metered — ' +\n 'review the generatedSpecDigest first)',\n ),\n expectedSpecDigest: z\n .string()\n .optional()\n .describe(\n 'The exact generatedSpecDigest this tool returned, passed back so an obsolete spec ' +\n 'revision is refused (only used with materialize: true)',\n ),\n pollIntervalMs: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe('Poll interval while the generation runs (default 2000ms)'),\n pollTimeoutMs: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe('Give up polling after this long (default 120000ms)'),\n },\n },\n async ({\n prompt,\n maxWidgets,\n category,\n preferredWidgetTypes,\n additionalContext,\n visibility,\n materialize,\n expectedSpecDigest,\n pollIntervalMs,\n pollTimeoutMs,\n }) => {\n const parsedTypes = preferredWidgetTypes\n ? WidgetTypeArray.safeParse(preferredWidgetTypes)\n : null;\n if (parsedTypes && !parsedTypes.success) {\n return errorResult(\n parsedTypes.error.issues.map((issue) => issue.message).join(' '),\n 'Use only the nine render-verified widget types named in the message.',\n );\n }\n if (expectedSpecDigest && materialize !== true) {\n return errorResult(\n 'expectedSpecDigest is only meaningful with materialize: true.',\n 'Review the generatedSpecDigest from the result, then re-call with materialize: true ' +\n 'and the digest.',\n );\n }\n\n const interval = pollIntervalMs ?? 2000;\n const timeout = pollTimeoutMs ?? 120_000;\n\n let generation: {\n id: string;\n status: string;\n errorMessage?: string | null;\n generatedSpecDigest?: string | null;\n dashboardId?: string | null;\n } | null = null;\n\n try {\n const submitted = await ctx.gql.workspace.request<{\n generateDashboardFromPrompt: { id: string; status: string };\n }>(GENERATE_DASHBOARD_FROM_PROMPT, {\n input: {\n prompt,\n ...(maxWidgets !== undefined ? { maxWidgets } : {}),\n ...(category !== undefined ? { category } : {}),\n ...(parsedTypes?.data ? { preferredWidgetTypes: parsedTypes.data } : {}),\n ...(additionalContext !== undefined ? { additionalContext } : {}),\n ...(visibility !== undefined ? { visibility } : {}),\n },\n });\n\n const generationId = submitted.generateDashboardFromPrompt.id;\n const deadline = Date.now() + timeout;\n\n for (;;) {\n const polled = await ctx.gql.workspace.request<{\n getPromptGeneration: {\n id: string;\n status: string;\n errorMessage?: string | null;\n generatedSpecDigest?: string | null;\n dashboardId?: string | null;\n } | null;\n }>(GET_PROMPT_GENERATION, { id: generationId });\n\n generation = polled.getPromptGeneration ?? {\n id: generationId,\n status: 'MISSING',\n errorMessage: 'Generation record vanished while polling.',\n };\n\n if (TERMINAL_SET.has(generation.status) || Date.now() >= deadline) break;\n await sleep(interval);\n }\n } catch (error) {\n ctx.logger.error('bigconsole dashboard_generate_from_prompt failed', {\n error: String(error),\n });\n return errorResult(\n `Failed to generate the dashboard: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n if (!generation) {\n return errorResult('Generation did not return a record — try again.');\n }\n\n if (!TERMINAL_SET.has(generation.status)) {\n return jsonResult({\n generationId: generation.id,\n status: generation.status,\n note:\n 'Still running when the poll budget ran out — the generation continues server-side; ' +\n 're-check from the app or re-run with a larger pollTimeoutMs before materializing.',\n });\n }\n if (generation.status === 'FAILED' || generation.status === 'CANCELLED') {\n return errorResult(\n `Generation ${generation.status.toLowerCase()}${generation.errorMessage ? `: ${generation.errorMessage}` : '.'}`,\n 'Fix the prompt (or the workspace state) and submit a new generation — re-running a ' +\n 'failed one just spends another credit.',\n );\n }\n\n // COMPLETED\n const base = {\n generationId: generation.id,\n status: generation.status,\n generatedSpecDigest: generation.generatedSpecDigest ?? null,\n };\n\n if (materialize !== true) {\n return jsonResult({\n ...base,\n materialized: false,\n next:\n 'Review the generated spec, then re-call with materialize: true and pass ' +\n 'generatedSpecDigest as expectedSpecDigest to create the dashboard.',\n });\n }\n\n try {\n const created = await ctx.gql.workspace.request<{\n createDashboardFromGeneration: Record<string, unknown>;\n }>(CREATE_DASHBOARD_FROM_GENERATION, {\n input: {\n generationId: generation.id,\n ...(expectedSpecDigest !== undefined ? { expectedSpecDigest } : {}),\n },\n });\n return jsonResult({\n ...base,\n materialized: true,\n dashboard: created.createDashboardFromGeneration,\n });\n } catch (error) {\n ctx.logger.error('bigconsole dashboard materialization failed', { error: String(error) });\n return errorResult(\n `Generation completed but materialization failed: ${error instanceof Error ? error.message : String(error)}`,\n 'The spec is still there — re-call with materialize: true and the same ' +\n 'generatedSpecDigest as expectedSpecDigest.',\n );\n }\n },\n );\n}\n","/**\n * BigConsole parser tools — the shaping layer of the pipeline.\n *\n * Surface (4): parsers_list, parser_create, parser_update,\n * parser_test_expression.\n *\n * A parser transforms a data sink's rows into the shape a widget renders:\n * `jq` / `jsonata` / `spark` over the sink's payload, read by `inputSinkKey`\n * (the slug, NOT the id), written to `outputKey`, scoped to a console via\n * `consoleId` — which is the DASHBOARD id. Parsers are optional: if sink rows\n * are already chart-shaped, bind the widget straight to the sink.\n *\n * `parser_test_expression` runs the expression server-side against a stored\n * sink (by id or key) or inline sample rows, so an agent can iterate on the\n * expression before creating anything.\n *\n * `parser_update` takes the optimistic-lock `version` as a required top-level\n * tool input (the backend's shape differs from updateDataSink's in-input\n * version) — see shared.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../../core/index.js';\nimport {\n CREATE_PARSER,\n LIST_PARSERS,\n TEST_PARSER_EXPRESSION,\n UPDATE_PARSER,\n} from '../operations.js';\nimport {\n PageCursor,\n PageSize,\n ParserStatusEnum,\n ParserTypeEnum,\n VersionInt,\n VERSION_OMITTED_MESSAGE,\n WORKSPACE_NOTE,\n} from './shared.js';\n\nexport function registerParserTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'parsers_list')),\n {\n title: 'List Parsers',\n description:\n 'The parsers of one console. `consoleId` is the DASHBOARD id (not the workspace id, ' +\n 'not a page id) — parsers belong to the whole console. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n consoleId: z.string().describe('Dashboard (console) ID'),\n first: PageSize,\n after: PageCursor,\n },\n },\n async ({ consoleId, first, after }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n listParsers: Record<string, unknown>;\n }>(LIST_PARSERS, { consoleId, first: first ?? 20, after: after ?? null });\n return jsonResult(data.listParsers);\n } catch (error) {\n ctx.logger.error('bigconsole parsers_list failed', { error: String(error) });\n return errorResult(\n `Failed to list parsers: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'parser_create')),\n {\n title: 'Create Parser',\n description:\n 'Create a parser on a console. Step 3 of the pipeline (DataSink → Dashboard → Parser → ' +\n 'Widget). `consoleId` is the dashboard id; `inputSinkKey` is the data sink KEY (slug), ' +\n 'not its id; `outputKey` is a new slug the widget will read. Prefer type jq. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n consoleId: z.string().describe('Dashboard (console) ID'),\n name: z.string().describe('Parser name'),\n type: ParserTypeEnum,\n expression: z\n .string()\n .describe('Transform expression, e.g. jq: [.[] | {label: .grade, value: .present}]'),\n inputSinkKey: z\n .string()\n .describe('The data sink KEY (slug) the parser reads — not the sink id'),\n outputKey: z.string().describe('New slug for the parser output, e.g. sales_2026_chart'),\n description: z.string().optional(),\n ttl: z.number().int().min(0).optional(),\n },\n },\n async ({ consoleId, name, type, expression, inputSinkKey, outputKey, description, ttl }) => {\n try {\n const result = await ctx.gql.workspace.request<{\n createParser: Record<string, unknown>;\n }>(CREATE_PARSER, {\n input: {\n consoleId,\n name,\n type,\n expression,\n inputSinkKey,\n outputKey,\n ...(description !== undefined ? { description } : {}),\n ...(ttl !== undefined ? { ttl } : {}),\n },\n });\n return jsonResult(result.createParser);\n } catch (error) {\n ctx.logger.error('bigconsole parser_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the parser: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'parser_update')),\n {\n title: 'Update Parser',\n description:\n 'Update a parser with optimistic locking. `version` is REQUIRED and is a top-level ' +\n 'argument (unlike the data sink, where it lives inside the input) — read the current ' +\n 'value from parsers_list first and send it back unchanged; a stale version is rejected, ' +\n 'so re-read and retry rather than incrementing blindly. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n id: z.string().describe('Parser ID'),\n version: VersionInt.optional(),\n name: z.string().optional(),\n expression: z.string().optional(),\n inputSinkKey: z.string().optional(),\n outputKey: z.string().optional(),\n description: z.string().optional(),\n ttl: z.number().int().min(0).optional(),\n status: ParserStatusEnum.optional(),\n },\n },\n async ({\n id,\n version,\n name,\n expression,\n inputSinkKey,\n outputKey,\n description,\n ttl,\n status,\n }) => {\n if (version === undefined) {\n return errorResult(VERSION_OMITTED_MESSAGE);\n }\n try {\n const result = await ctx.gql.workspace.request<{\n updateParser: Record<string, unknown>;\n }>(UPDATE_PARSER, {\n id,\n version,\n input: {\n ...(name !== undefined ? { name } : {}),\n ...(expression !== undefined ? { expression } : {}),\n ...(inputSinkKey !== undefined ? { inputSinkKey } : {}),\n ...(outputKey !== undefined ? { outputKey } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(ttl !== undefined ? { ttl } : {}),\n ...(status !== undefined ? { status } : {}),\n },\n });\n return jsonResult(result.updateParser);\n } catch (error) {\n ctx.logger.error('bigconsole parser_update failed', { error: String(error) });\n return errorResult(\n `Failed to update the parser: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'parser_test_expression')),\n {\n title: 'Test Parser Expression',\n description:\n 'Run a parser expression server-side WITHOUT creating anything — against a stored data ' +\n 'sink (by id or key, preferred: the payload never crosses the wire to you) or against ' +\n 'inline sample rows. Iterate on the expression here, then parser_create. ' +\n WORKSPACE_NOTE,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n inputSchema: {\n type: ParserTypeEnum,\n expression: z.string().describe('Transform expression to test'),\n dataSinkId: z\n .string()\n .optional()\n .describe('Stored data sink ID to test against (preferred)'),\n dataSinkKey: z\n .string()\n .optional()\n .describe('Stored data sink key (slug) — alternative to dataSinkId'),\n sampleData: z\n .unknown()\n .optional()\n .describe(\n 'Inline sample payload (array of row objects) — alternative to a sink reference',\n ),\n sampleLimit: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe('Cap rows evaluated when testing against a stored sink'),\n },\n },\n async ({ type, expression, dataSinkId, dataSinkKey, sampleData, sampleLimit }) => {\n const refs = [dataSinkId, dataSinkKey, sampleData].filter((v) => v !== undefined).length;\n if (refs === 0) {\n return errorResult(\n 'Provide exactly one test target: dataSinkId, dataSinkKey, or sampleData.',\n 'Prefer a data sink reference so the payload stays server-side; use sampleData only ' +\n 'for the hand-edited-JSON path.',\n );\n }\n if (refs > 1) {\n return errorResult(\n 'dataSinkId, dataSinkKey and sampleData are mutually exclusive — provide exactly one.',\n );\n }\n try {\n const data = await ctx.gql.workspace.request<{\n testParserExpression: Record<string, unknown>;\n }>(TEST_PARSER_EXPRESSION, {\n input: {\n type,\n expression,\n ...(dataSinkId !== undefined ? { dataSinkId } : {}),\n ...(dataSinkKey !== undefined ? { dataSinkKey } : {}),\n ...(sampleData !== undefined ? { sampleData } : {}),\n ...(sampleLimit !== undefined ? { sampleLimit } : {}),\n },\n });\n return jsonResult(data.testParserExpression);\n } catch (error) {\n ctx.logger.error('bigconsole parser_test_expression failed', { error: String(error) });\n return errorResult(\n `Failed to test the expression: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * BigConsole widget tool — the rendering layer of the pipeline.\n *\n * Surface (1): widget_create.\n *\n * A widget is a built-in renderer + a rich declarative `config` + a field\n * mapping, bound to a data sink and/or parser, placed on a PAGE (not the\n * dashboard — get the page id from dashboard_get). Step 4 of the pipeline.\n *\n * ### The config is the custom-widget builder\n *\n * There is no code path: `config` is opaque JSON the renderer reads, and the\n * two rules that make a widget render correctly are enforced by the zod\n * shapes in shared.ts, not by documentation:\n *\n * - charts store as one internal renderer — `config.chartType`\n * (\"line\"|\"bar\"|\"area\"|\"pie\") must match the enum type or the widget\n * renders as a line regardless of `type`;\n * - single-KPI cards need `config._internalWidgetType: \"metric_card\"` and\n * retention grids need `\"retention\"` — without them the wrong renderer\n * picks the widget up.\n *\n * Field names in the config must match the keys the parser/sink emits per\n * row: the renderer reads `row[config.valueField]`, `row[config.xAxisField]`,\n * `row[column.key]` — a mismatch renders an empty widget with no error.\n *\n * Only the nine render-verified types are accepted; see shared.ts for why.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../../core/index.js';\nimport { CREATE_WIDGET } from '../operations.js';\nimport { WidgetConfig, WidgetPosition, WidgetTypeEnum, WORKSPACE_NOTE } from './shared.js';\n\nexport function registerWidgetTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'widget_create')),\n {\n title: 'Create Widget',\n description:\n 'Place a widget on a dashboard page — the last step of the pipeline (DataSink → ' +\n 'Dashboard → Parser → Widget). Bind data with parserId (preferred — the parser output ' +\n 'is already chart-shaped) and/or dataSinkId. Build a rich config for the chosen type ' +\n '(never {}): charts need config.chartType matching the type, single-KPI needs ' +\n 'config._internalWidgetType \"metric_card\", retention needs \"retention\"; field names ' +\n 'must match the parser/sink output keys. ' +\n WORKSPACE_NOTE,\n inputSchema: {\n pageId: z\n .string()\n .describe('Page ID (from dashboard_get — widgets live on pages, not dashboards)'),\n title: z.string().describe('Widget title'),\n type: WidgetTypeEnum,\n config: WidgetConfig,\n position: WidgetPosition,\n parserId: z\n .string()\n .optional()\n .describe('Parser whose output the widget reads (preferred binding)'),\n dataSinkId: z\n .string()\n .optional()\n .describe('Data sink the widget reads (use alone when rows are already chart-shaped)'),\n },\n },\n async ({ pageId, title, type, config, position, parserId, dataSinkId }) => {\n if (!parserId && !dataSinkId) {\n return errorResult(\n 'Bind the widget to data: provide parserId and/or dataSinkId.',\n 'Widgets without a binding render empty. Prefer parserId so the data is already ' +\n 'shaped for the renderer.',\n );\n }\n try {\n const result = await ctx.gql.workspace.request<{\n createBigConsoleWidget: Record<string, unknown>;\n }>(CREATE_WIDGET, {\n input: {\n pageId,\n title,\n type,\n config,\n position,\n ...(parserId !== undefined ? { parserId } : {}),\n ...(dataSinkId !== undefined ? { dataSinkId } : {}),\n },\n });\n return jsonResult(result.createBigConsoleWidget);\n } catch (error) {\n ctx.logger.error('bigconsole widget_create failed', { error: String(error) });\n return errorResult(\n `Failed to create the widget: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * BigConsole module — console authoring for external agents (BOFF-3729).\n *\n * Backend subgraph: ~/products/wspace/bigconsole/wspace-bigconsole-svc/\n * (Hive service name `bigconsole`). Runs against the WORKSPACE PUBLIC gateway,\n * which is where `@rbac` is enforced from the composed supergraph. This module\n * authorises nothing itself and never touches a token — `ctx.gql.workspace`\n * injects the session credential (app-client-credentials or device-code login)\n * and the `x-workspace-id` header chosen via `auth_select_workspace`.\n *\n * ### The least-privilege surface (AI_READINESS §2.2)\n *\n * Sixteen tools covering exactly the console-authoring pipeline and nothing\n * else:\n *\n * - DataSinks: list / get / create / update (4)\n * - Dashboards + pages: list / get / create / page-create (4)\n * - Parsers: list / create / update / test-expression (4)\n * - Widgets: create (1)\n * - Console Definition JSON: export / import (2) — the headline round-trip\n * - Generate-from-prompt: submit + poll + optional materialize (1)\n *\n * Deliberately absent: every `delete_*` / `archive_*` / `publish` /\n * share / RLS / embed / template-store mutation. Read + create (+ the two\n * sanctioned updates, both version-locked) is the valuable 90%, and an\n * external agent that cannot archive a production console is the security\n * posture the readiness audit asks for (§2.2/§2.3).\n *\n * ### The recipe is the contract\n *\n * Tool shapes mirror `ai-assistant/context/api-calls/products/bigconsole.md`\n * (the authoritative build recipe): the forced DataSink → Dashboard → Parser\n * → Widget order falls out of the argument shapes (`consoleId` = dashboard\n * id, widgets bound by pageId / parserId / dataSinkId), and the two footguns\n * are tool-level zod constraints in tools/shared.ts, not documentation.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerDashboardTools } from './tools/dashboards.js';\nimport { registerDataSinkTools } from './tools/datasinks.js';\nimport { registerGenerateTools } from './tools/generate.js';\nimport { registerParserTools } from './tools/parsers.js';\nimport { registerWidgetTools } from './tools/widgets.js';\n\nconst bigconsoleModule: McpModule = {\n id: 'bigconsole',\n version: '0.0.1',\n displayName: 'BigConsole',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerDataSinkTools(server, ctx, track);\n registerDashboardTools(server, ctx, track);\n registerParserTools(server, ctx, track);\n registerWidgetTools(server, ctx, track);\n registerGenerateTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default bigconsoleModule;\n"]}
@@ -12,7 +12,8 @@ export declare const UPDATE_PARSER = "\n mutation BigConsoleMcpUpdateParser($id
12
12
  export declare const TEST_PARSER_EXPRESSION = "\n query BigConsoleMcpTestParserExpression($input: TestParserInput!) {\n testParserExpression(input: $input) {\n success\n output\n error\n executionTimeMs\n }\n }\n";
13
13
  export declare const CREATE_WIDGET = "\n mutation BigConsoleMcpCreateWidget($input: BigConsoleCreateWidgetInput!) {\n createBigConsoleWidget(input: $input) {\n id\n title\n type\n }\n }\n";
14
14
  export declare const EXPORT_DASHBOARD = "\n query BigConsoleMcpExportDashboard($id: ID!, $options: BigConsoleExportDashboardOptions) {\n exportDashboard(id: $id, options: $options)\n }\n";
15
- export declare const IMPORT_DASHBOARD = "\n mutation BigConsoleMcpImportDashboard($input: BigConsoleImportDashboardInput!) {\n importDashboard(input: $input) {\n id\n name\n pageCount\n widgetCount\n }\n }\n";
15
+ export declare const IMPORT_DASHBOARD = "\n mutation BigConsoleMcpImportDashboard($input: ImportBigConsoleDashboardInput!) {\n importBigConsoleDashboard(input: $input) {\n success\n errorMessage\n dashboard {\n id\n name\n pageCount\n widgetCount\n }\n stats {\n pagesCreated\n widgetsCreated\n actionsCreated\n filtersCreated\n dataSourcesSkipped\n }\n }\n }\n";
16
+ export declare const VALIDATE_DASHBOARD_IMPORT = "\n query BigConsoleMcpValidateDashboardImport($content: String!) {\n validateDashboardImport(content: $content) {\n isValid\n dashboardInfo {\n name\n pageCount\n widgetCount\n schemaVersion\n }\n errors {\n code\n message\n path\n }\n warnings {\n code\n message\n suggestion\n }\n }\n }\n";
16
17
  export declare const GENERATE_DASHBOARD_FROM_PROMPT = "\n mutation BigConsoleMcpGenerateDashboardFromPrompt($input: BigConsoleGenerateDashboardFromPromptInput!) {\n generateDashboardFromPrompt(input: $input) {\n id\n status\n }\n }\n";
17
18
  export declare const GET_PROMPT_GENERATION = "\n query BigConsoleMcpGetPromptGeneration($id: ID!) {\n getPromptGeneration(id: $id) {\n id\n status\n errorMessage\n generatedSpecDigest\n dashboardId\n }\n }\n";
18
19
  export declare const CREATE_DASHBOARD_FROM_GENERATION = "\n mutation BigConsoleMcpCreateDashboardFromGeneration($input: BigConsoleCreateDashboardFromGenerationInput!) {\n createDashboardFromGeneration(input: $input) {\n id\n name\n pageCount\n widgetCount\n }\n }\n";