@milaboratories/pl-mcp-server 52.0.0 → 53.0.0

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.
Files changed (97) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/instructions.cjs +28 -0
  3. package/dist/instructions.cjs.map +1 -0
  4. package/dist/instructions.js +28 -0
  5. package/dist/instructions.js.map +1 -0
  6. package/dist/package.cjs +10 -0
  7. package/dist/package.cjs.map +1 -0
  8. package/dist/package.js +5 -0
  9. package/dist/package.js.map +1 -0
  10. package/dist/server.cjs +45 -41
  11. package/dist/server.cjs.map +1 -1
  12. package/dist/server.d.ts +15 -9
  13. package/dist/server.d.ts.map +1 -1
  14. package/dist/server.js +44 -40
  15. package/dist/server.js.map +1 -1
  16. package/dist/tools/await.cjs +8 -5
  17. package/dist/tools/await.cjs.map +1 -1
  18. package/dist/tools/await.js +9 -6
  19. package/dist/tools/await.js.map +1 -1
  20. package/dist/tools/block-action-context.cjs +7 -4
  21. package/dist/tools/block-action-context.cjs.map +1 -1
  22. package/dist/tools/block-action-context.js +8 -5
  23. package/dist/tools/block-action-context.js.map +1 -1
  24. package/dist/tools/block-api.cjs +23 -0
  25. package/dist/tools/block-api.cjs.map +1 -0
  26. package/dist/tools/block-api.js +22 -0
  27. package/dist/tools/block-api.js.map +1 -0
  28. package/dist/tools/block-params.cjs +21 -0
  29. package/dist/tools/block-params.cjs.map +1 -0
  30. package/dist/tools/block-params.js +21 -0
  31. package/dist/tools/block-params.js.map +1 -0
  32. package/dist/tools/block-state.cjs +18 -11
  33. package/dist/tools/block-state.cjs.map +1 -1
  34. package/dist/tools/block-state.js +19 -12
  35. package/dist/tools/block-state.js.map +1 -1
  36. package/dist/tools/blocks.cjs +130 -50
  37. package/dist/tools/blocks.cjs.map +1 -1
  38. package/dist/tools/blocks.js +131 -52
  39. package/dist/tools/blocks.js.map +1 -1
  40. package/dist/tools/connection.cjs +23 -6
  41. package/dist/tools/connection.cjs.map +1 -1
  42. package/dist/tools/connection.js +24 -7
  43. package/dist/tools/connection.js.map +1 -1
  44. package/dist/tools/data-query.cjs +14 -7
  45. package/dist/tools/data-query.cjs.map +1 -1
  46. package/dist/tools/data-query.js +15 -8
  47. package/dist/tools/data-query.js.map +1 -1
  48. package/dist/tools/ids.cjs +14 -0
  49. package/dist/tools/ids.cjs.map +1 -0
  50. package/dist/tools/ids.js +13 -0
  51. package/dist/tools/ids.js.map +1 -0
  52. package/dist/tools/logs.cjs +11 -6
  53. package/dist/tools/logs.cjs.map +1 -1
  54. package/dist/tools/logs.js +12 -7
  55. package/dist/tools/logs.js.map +1 -1
  56. package/dist/tools/ping.cjs +5 -1
  57. package/dist/tools/ping.cjs.map +1 -1
  58. package/dist/tools/ping.js +6 -2
  59. package/dist/tools/ping.js.map +1 -1
  60. package/dist/tools/projects.cjs +20 -7
  61. package/dist/tools/projects.cjs.map +1 -1
  62. package/dist/tools/projects.js +21 -8
  63. package/dist/tools/projects.js.map +1 -1
  64. package/dist/tools/screenshot.cjs +3 -1
  65. package/dist/tools/screenshot.cjs.map +1 -1
  66. package/dist/tools/screenshot.js +4 -2
  67. package/dist/tools/screenshot.js.map +1 -1
  68. package/dist/tools/types.cjs +51 -0
  69. package/dist/tools/types.cjs.map +1 -1
  70. package/dist/tools/types.js +50 -1
  71. package/dist/tools/types.js.map +1 -1
  72. package/dist/tools/ui-interaction.cjs +27 -13
  73. package/dist/tools/ui-interaction.cjs.map +1 -1
  74. package/dist/tools/ui-interaction.js +28 -14
  75. package/dist/tools/ui-interaction.js.map +1 -1
  76. package/package.json +11 -9
  77. package/src/index.ts +1 -0
  78. package/src/instructions.ts +24 -0
  79. package/src/server.test.ts +633 -0
  80. package/src/server.ts +65 -58
  81. package/src/tools/await.ts +9 -6
  82. package/src/tools/block-action-context.ts +9 -6
  83. package/src/tools/block-api.ts +24 -0
  84. package/src/tools/block-params.ts +30 -0
  85. package/src/tools/block-state.ts +21 -14
  86. package/src/tools/blocks.test.ts +148 -0
  87. package/src/tools/blocks.ts +216 -65
  88. package/src/tools/connection.ts +38 -17
  89. package/src/tools/data-query.ts +17 -10
  90. package/src/tools/ids.ts +11 -0
  91. package/src/tools/logs.ts +13 -8
  92. package/src/tools/ping.ts +14 -5
  93. package/src/tools/projects.ts +26 -11
  94. package/src/tools/screenshot.ts +7 -5
  95. package/src/tools/types.test.ts +19 -0
  96. package/src/tools/types.ts +71 -3
  97. package/src/tools/ui-interaction.ts +29 -18
@@ -1,20 +1,23 @@
1
1
  const require_types = require("./types.cjs");
2
+ const require_ids = require("./ids.cjs");
2
3
  const require_tokens = require("./tokens.cjs");
3
4
  const require_sandbox = require("./sandbox.cjs");
4
5
  let zod = require("zod");
5
- let _platforma_sdk_model = require("@platforma-sdk/model");
6
6
  let _milaboratories_pl_middle_layer = require("@milaboratories/pl-middle-layer");
7
+ let _platforma_sdk_model = require("@platforma-sdk/model");
7
8
  // src/tools/await.ts
8
9
  function registerAwaitTools(server, ctx) {
9
10
  server.registerTool("await_block_done", {
11
+ title: "Wait for Block",
12
+ annotations: require_types.hints.read,
10
13
  description: "Wait for a block to finish computation and outputs to stabilize. Returns block status, data, and concise output summary with token estimates. Use `transform` to extract specific data server-side on completion.",
11
- inputSchema: {
12
- projectId: zod.z.string().describe("Project ID"),
13
- blockId: zod.z.string().describe("Block ID to wait for"),
14
+ inputSchema: zod.z.object({
15
+ projectId: require_ids.projectIdInput.describe("Project ID"),
16
+ blockId: require_ids.blockIdInput.describe("Block ID to wait for"),
14
17
  timeout: zod.z.number().optional().default(12e4).describe("Timeout in ms (default 120000)"),
15
18
  transform: zod.z.string().optional().describe("JS expression evaluated server-side when block completes. Available variables: `data` (block args), `outputs` (raw outputs), `block` (status info). Omit for default concise summary."),
16
19
  transformTimeout: zod.z.number().optional().default(5e3).describe("Timeout in ms for transform evaluation (default 5000).")
17
- }
20
+ })
18
21
  }, async ({ projectId, blockId, timeout, transform, transformTimeout }) => {
19
22
  const project = await ctx.getOpenedProject(projectId);
20
23
  const deadline = Date.now() + timeout;
@@ -1 +1 @@
1
- {"version":3,"file":"await.cjs","names":["z","errorResult","isTimeoutError","textResult","deriveDataFromStorage","safeEval","summarizeOutputs"],"sources":["../../src/tools/await.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { isTimeoutError } from \"@milaboratories/pl-middle-layer\";\nimport { deriveDataFromStorage } from \"@platforma-sdk/model\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { summarizeOutputs } from \"./tokens\";\nimport { safeEval } from \"./sandbox\";\nimport { errorResult, textResult } from \"./types\";\n\nexport function registerAwaitTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"await_block_done\",\n {\n description:\n \"Wait for a block to finish computation and outputs to stabilize. \" +\n \"Returns block status, data, and concise output summary with token estimates. \" +\n \"Use `transform` to extract specific data server-side on completion.\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID\"),\n blockId: z.string().describe(\"Block ID to wait for\"),\n timeout: z.number().optional().default(120000).describe(\"Timeout in ms (default 120000)\"),\n transform: z\n .string()\n .optional()\n .describe(\n \"JS expression evaluated server-side when block completes. \" +\n \"Available variables: `data` (block args), `outputs` (raw outputs), `block` (status info). \" +\n \"Omit for default concise summary.\",\n ),\n transformTimeout: z\n .number()\n .optional()\n .default(5000)\n .describe(\"Timeout in ms for transform evaluation (default 5000).\"),\n },\n },\n async ({ projectId, blockId, timeout, transform, transformTimeout }) => {\n const project = await ctx.getOpenedProject(projectId);\n const deadline = Date.now() + timeout;\n\n while (Date.now() < deadline) {\n const overview = await project.overview.getValue();\n if (!overview) continue;\n const block = overview.blocks.find((b) => b.id === blockId);\n if (!block)\n return errorResult(\n `Block ${blockId} not found in project ${projectId}.`,\n \"Use get_project_overview to list all block IDs in this project.\",\n );\n\n // Terminal error states — return immediately\n if (block.calculationStatus === \"Limbo\") {\n return errorResult(\n \"Block entered Limbo state (upstream failed or was stopped).\",\n \"Check upstream blocks with get_project_overview. Fix or re-run the failed upstream, then retry.\",\n );\n }\n\n if (block.calculationStatus === \"NotCalculated\") {\n return errorResult(\n \"Block has not been started.\",\n \"Use run_block to start it first, then call await_block_done.\",\n );\n }\n\n if (block.calculationStatus === \"Done\") {\n // Await stable block state with remaining time budget\n const remaining = Math.max(deadline - Date.now(), 1000);\n let state;\n try {\n state = await project\n .getBlockState(blockId)\n .awaitStableValue(AbortSignal.timeout(remaining));\n } catch (e: unknown) {\n if (isTimeoutError(e)) {\n return textResult({\n timedOut: true,\n status: \"Done\",\n note: \"Computation done but outputs did not stabilize in time. Retry with a longer timeout.\",\n });\n }\n return errorResult(\n `Failed to get block state: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n\n const data = deriveDataFromStorage(state.blockStorage);\n\n const blockInfo = {\n id: block.id,\n title: block.title ?? block.label,\n calculationStatus: block.calculationStatus,\n canRun: block.canRun,\n stale: block.stale,\n outputErrors: block.outputErrors,\n };\n\n if (transform) {\n try {\n const result = await safeEval(\n transform,\n {\n data,\n outputs: state.outputs,\n block: blockInfo,\n },\n transformTimeout,\n );\n return textResult({ status: \"Done\", block: blockInfo, result });\n } catch (e: unknown) {\n return errorResult(\n `Transform failed: ${e instanceof Error ? e.message : String(e)}`,\n \"Check your JS expression syntax. Available variables: data, outputs, block.\",\n );\n }\n }\n\n return textResult({\n status: \"Done\",\n block: blockInfo,\n data,\n outputs: summarizeOutputs(state.outputs as Record<string, unknown> | undefined),\n });\n }\n\n // Still running — wait up to 5s for overview to change, then re-poll.\n // Minimum 500ms delay to avoid busy-looping if awaitChange resolves immediately.\n const pollStart = Date.now();\n try {\n const result = await project.overview.getFullValue();\n await project.overview.awaitChange(AbortSignal.timeout(5000), result.uTag);\n } catch {\n // timeout or abort — just re-poll\n }\n const elapsed = Date.now() - pollStart;\n if (elapsed < 500) {\n await new Promise((r) => setTimeout(r, 500 - elapsed));\n }\n }\n\n // Timed out while running\n const overview = await project.overview.getValue();\n const block = overview?.blocks.find((b) => b.id === blockId);\n return textResult({\n timedOut: true,\n status: block?.calculationStatus ?? \"Unknown\",\n hint: \"The block is still running. Call await_block_done again with a longer timeout.\",\n });\n },\n );\n}\n"],"mappings":";;;;;;;AASA,SAAgB,mBAAmB,QAAmB,KAAwB;CAC5E,OAAO,aACL,oBACA;EACE,aACE;EAGF,aAAa;GACX,WAAWA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,YAAY;GAC3C,SAASA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,sBAAsB;GACnD,SAASA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAM,CAAC,CAAC,SAAS,gCAAgC;GACxF,WAAWA,IAAAA,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,uLAGF;GACF,kBAAkBA,IAAAA,EACf,OAAO,CAAC,CACR,SAAS,CAAC,CACV,QAAQ,GAAI,CAAC,CACb,SAAS,wDAAwD;EACtE;CACF,GACA,OAAO,EAAE,WAAW,SAAS,SAAS,WAAW,uBAAuB;EACtE,MAAM,UAAU,MAAM,IAAI,iBAAiB,SAAS;EACpD,MAAM,WAAW,KAAK,IAAI,IAAI;EAE9B,OAAO,KAAK,IAAI,IAAI,UAAU;GAC5B,MAAM,WAAW,MAAM,QAAQ,SAAS,SAAS;GACjD,IAAI,CAAC,UAAU;GACf,MAAM,QAAQ,SAAS,OAAO,MAAM,MAAM,EAAE,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,OAAOC,cAAAA,YACL,SAAS,QAAQ,wBAAwB,UAAU,IACnD,iEACF;GAGF,IAAI,MAAM,sBAAsB,SAC9B,OAAOA,cAAAA,YACL,+DACA,iGACF;GAGF,IAAI,MAAM,sBAAsB,iBAC9B,OAAOA,cAAAA,YACL,+BACA,8DACF;GAGF,IAAI,MAAM,sBAAsB,QAAQ;IAEtC,MAAM,YAAY,KAAK,IAAI,WAAW,KAAK,IAAI,GAAG,GAAI;IACtD,IAAI;IACJ,IAA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AAQ,SAAS,SAAS,EAAA,EACzB,OAAO,MAAM,MAAM,EAAE,OAAO,OAAO;EAC3D,OAAOH,cAAAA,WAAW;GAChB,UAAU;GACV,QAAQ,OAAO,qBAAqB;GACpC,MAAM;EACR,CAAC;CACH,CACF;AACF"}
1
+ {"version":3,"file":"await.cjs","names":["hints","z","projectIdInput","blockIdInput","errorResult","isTimeoutError","textResult","deriveDataFromStorage","safeEval","summarizeOutputs"],"sources":["../../src/tools/await.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { isTimeoutError } from \"@milaboratories/pl-middle-layer\";\nimport { deriveDataFromStorage } from \"@platforma-sdk/model\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { summarizeOutputs } from \"./tokens\";\nimport { safeEval } from \"./sandbox\";\nimport { errorResult, hints, textResult } from \"./types\";\n\nexport function registerAwaitTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"await_block_done\",\n {\n title: \"Wait for Block\",\n annotations: hints.read,\n description:\n \"Wait for a block to finish computation and outputs to stabilize. \" +\n \"Returns block status, data, and concise output summary with token estimates. \" +\n \"Use `transform` to extract specific data server-side on completion.\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID\"),\n blockId: blockIdInput.describe(\"Block ID to wait for\"),\n timeout: z.number().optional().default(120000).describe(\"Timeout in ms (default 120000)\"),\n transform: z\n .string()\n .optional()\n .describe(\n \"JS expression evaluated server-side when block completes. \" +\n \"Available variables: `data` (block args), `outputs` (raw outputs), `block` (status info). \" +\n \"Omit for default concise summary.\",\n ),\n transformTimeout: z\n .number()\n .optional()\n .default(5000)\n .describe(\"Timeout in ms for transform evaluation (default 5000).\"),\n }),\n },\n async ({ projectId, blockId, timeout, transform, transformTimeout }) => {\n const project = await ctx.getOpenedProject(projectId);\n const deadline = Date.now() + timeout;\n\n while (Date.now() < deadline) {\n const overview = await project.overview.getValue();\n if (!overview) continue;\n const block = overview.blocks.find((b) => b.id === blockId);\n if (!block)\n return errorResult(\n `Block ${blockId} not found in project ${projectId}.`,\n \"Use get_project_overview to list all block IDs in this project.\",\n );\n\n // Terminal error states — return immediately\n if (block.calculationStatus === \"Limbo\") {\n return errorResult(\n \"Block entered Limbo state (upstream failed or was stopped).\",\n \"Check upstream blocks with get_project_overview. Fix or re-run the failed upstream, then retry.\",\n );\n }\n\n if (block.calculationStatus === \"NotCalculated\") {\n return errorResult(\n \"Block has not been started.\",\n \"Use run_block to start it first, then call await_block_done.\",\n );\n }\n\n if (block.calculationStatus === \"Done\") {\n // Await stable block state with remaining time budget\n const remaining = Math.max(deadline - Date.now(), 1000);\n let state;\n try {\n state = await project\n .getBlockState(blockId)\n .awaitStableValue(AbortSignal.timeout(remaining));\n } catch (e: unknown) {\n if (isTimeoutError(e)) {\n return textResult({\n timedOut: true,\n status: \"Done\",\n note: \"Computation done but outputs did not stabilize in time. Retry with a longer timeout.\",\n });\n }\n return errorResult(\n `Failed to get block state: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n\n const data = deriveDataFromStorage(state.blockStorage);\n\n const blockInfo = {\n id: block.id,\n title: block.title ?? block.label,\n calculationStatus: block.calculationStatus,\n canRun: block.canRun,\n stale: block.stale,\n outputErrors: block.outputErrors,\n };\n\n if (transform) {\n try {\n const result = await safeEval(\n transform,\n {\n data,\n outputs: state.outputs,\n block: blockInfo,\n },\n transformTimeout,\n );\n return textResult({ status: \"Done\", block: blockInfo, result });\n } catch (e: unknown) {\n return errorResult(\n `Transform failed: ${e instanceof Error ? e.message : String(e)}`,\n \"Check your JS expression syntax. Available variables: data, outputs, block.\",\n );\n }\n }\n\n return textResult({\n status: \"Done\",\n block: blockInfo,\n data,\n outputs: summarizeOutputs(state.outputs as Record<string, unknown> | undefined),\n });\n }\n\n // Still running — wait up to 5s for overview to change, then re-poll.\n // Minimum 500ms delay to avoid busy-looping if awaitChange resolves immediately.\n const pollStart = Date.now();\n try {\n const result = await project.overview.getFullValue();\n await project.overview.awaitChange(AbortSignal.timeout(5000), result.uTag);\n } catch {\n // timeout or abort — just re-poll\n }\n const elapsed = Date.now() - pollStart;\n if (elapsed < 500) {\n await new Promise((r) => setTimeout(r, 500 - elapsed));\n }\n }\n\n // Timed out while running\n const overview = await project.overview.getValue();\n const block = overview?.blocks.find((b) => b.id === blockId);\n return textResult({\n timedOut: true,\n status: block?.calculationStatus ?? \"Unknown\",\n hint: \"The block is still running. Call await_block_done again with a longer timeout.\",\n });\n },\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,mBAAmB,QAAmB,KAAwB;CAC5E,OAAO,aACL,oBACA;EACE,OAAO;EACP,aAAaA,cAAAA,MAAM;EACnB,aACE;EAGF,aAAaC,IAAAA,EAAE,OAAO;GACpB,WAAWC,YAAAA,eAAe,SAAS,YAAY;GAC/C,SAASC,YAAAA,aAAa,SAAS,sBAAsB;GACrD,SAASF,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAM,CAAC,CAAC,SAAS,gCAAgC;GACxF,WAAWA,IAAAA,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,uLAGF;GACF,kBAAkBA,IAAAA,EACf,OAAO,CAAC,CACR,SAAS,CAAC,CACV,QAAQ,GAAI,CAAC,CACb,SAAS,wDAAwD;EACtE,CAAC;CACH,GACA,OAAO,EAAE,WAAW,SAAS,SAAS,WAAW,uBAAuB;EACtE,MAAM,UAAU,MAAM,IAAI,iBAAiB,SAAS;EACpD,MAAM,WAAW,KAAK,IAAI,IAAI;EAE9B,OAAO,KAAK,IAAI,IAAI,UAAU;GAC5B,MAAM,WAAW,MAAM,QAAQ,SAAS,SAAS;GACjD,IAAI,CAAC,UAAU;GACf,MAAM,QAAQ,SAAS,OAAO,MAAM,MAAM,EAAE,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,OAAOG,cAAAA,YACL,SAAS,QAAQ,wBAAwB,UAAU,IACnD,iEACF;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,SAAS,aAAa;IACnD,MAAM,QAAQ,SAAS,YAAY,YAAY,QAAQ,GAAI,GAAG,OAAO,IAAI;GAC3E,QAAQ,CAER;GACA,MAAM,UAAU,KAAK,IAAI,IAAI;GAC7B,IAAI,UAAU,KACZ,MAAM,IAAI,SAAS,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC;EAEzD;EAIA,MAAM,SAAQ,MADS,QAAQ,SAAS,SAAS,EAAA,EACzB,OAAO,MAAM,MAAM,EAAE,OAAO,OAAO;EAC3D,OAAOH,cAAAA,WAAW;GAChB,UAAU;GACV,QAAQ,OAAO,qBAAqB;GACpC,MAAM;EACR,CAAC;CACH,CACF;AACF"}
@@ -1,20 +1,23 @@
1
- import { errorResult, textResult } from "./types.js";
1
+ import { errorResult, hints, textResult } from "./types.js";
2
+ import { blockIdInput, projectIdInput } from "./ids.js";
2
3
  import { summarizeOutputs } from "./tokens.js";
3
4
  import { safeEval } from "./sandbox.js";
4
5
  import { z } from "zod";
5
- import { deriveDataFromStorage } from "@platforma-sdk/model";
6
6
  import { isTimeoutError } from "@milaboratories/pl-middle-layer";
7
+ import { deriveDataFromStorage } from "@platforma-sdk/model";
7
8
  // src/tools/await.ts
8
9
  function registerAwaitTools(server, ctx) {
9
10
  server.registerTool("await_block_done", {
11
+ title: "Wait for Block",
12
+ annotations: hints.read,
10
13
  description: "Wait for a block to finish computation and outputs to stabilize. Returns block status, data, and concise output summary with token estimates. Use `transform` to extract specific data server-side on completion.",
11
- inputSchema: {
12
- projectId: z.string().describe("Project ID"),
13
- blockId: z.string().describe("Block ID to wait for"),
14
+ inputSchema: z.object({
15
+ projectId: projectIdInput.describe("Project ID"),
16
+ blockId: blockIdInput.describe("Block ID to wait for"),
14
17
  timeout: z.number().optional().default(12e4).describe("Timeout in ms (default 120000)"),
15
18
  transform: z.string().optional().describe("JS expression evaluated server-side when block completes. Available variables: `data` (block args), `outputs` (raw outputs), `block` (status info). Omit for default concise summary."),
16
19
  transformTimeout: z.number().optional().default(5e3).describe("Timeout in ms for transform evaluation (default 5000).")
17
- }
20
+ })
18
21
  }, async ({ projectId, blockId, timeout, transform, transformTimeout }) => {
19
22
  const project = await ctx.getOpenedProject(projectId);
20
23
  const deadline = Date.now() + timeout;
@@ -1 +1 @@
1
- {"version":3,"file":"await.js","names":[],"sources":["../../src/tools/await.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { isTimeoutError } from \"@milaboratories/pl-middle-layer\";\nimport { deriveDataFromStorage } from \"@platforma-sdk/model\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { summarizeOutputs } from \"./tokens\";\nimport { safeEval } from \"./sandbox\";\nimport { errorResult, textResult } from \"./types\";\n\nexport function registerAwaitTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"await_block_done\",\n {\n description:\n \"Wait for a block to finish computation and outputs to stabilize. \" +\n \"Returns block status, data, and concise output summary with token estimates. \" +\n \"Use `transform` to extract specific data server-side on completion.\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID\"),\n blockId: z.string().describe(\"Block ID to wait for\"),\n timeout: z.number().optional().default(120000).describe(\"Timeout in ms (default 120000)\"),\n transform: z\n .string()\n .optional()\n .describe(\n \"JS expression evaluated server-side when block completes. \" +\n \"Available variables: `data` (block args), `outputs` (raw outputs), `block` (status info). \" +\n \"Omit for default concise summary.\",\n ),\n transformTimeout: z\n .number()\n .optional()\n .default(5000)\n .describe(\"Timeout in ms for transform evaluation (default 5000).\"),\n },\n },\n async ({ projectId, blockId, timeout, transform, transformTimeout }) => {\n const project = await ctx.getOpenedProject(projectId);\n const deadline = Date.now() + timeout;\n\n while (Date.now() < deadline) {\n const overview = await project.overview.getValue();\n if (!overview) continue;\n const block = overview.blocks.find((b) => b.id === blockId);\n if (!block)\n return errorResult(\n `Block ${blockId} not found in project ${projectId}.`,\n \"Use get_project_overview to list all block IDs in this project.\",\n );\n\n // Terminal error states — return immediately\n if (block.calculationStatus === \"Limbo\") {\n return errorResult(\n \"Block entered Limbo state (upstream failed or was stopped).\",\n \"Check upstream blocks with get_project_overview. Fix or re-run the failed upstream, then retry.\",\n );\n }\n\n if (block.calculationStatus === \"NotCalculated\") {\n return errorResult(\n \"Block has not been started.\",\n \"Use run_block to start it first, then call await_block_done.\",\n );\n }\n\n if (block.calculationStatus === \"Done\") {\n // Await stable block state with remaining time budget\n const remaining = Math.max(deadline - Date.now(), 1000);\n let state;\n try {\n state = await project\n .getBlockState(blockId)\n .awaitStableValue(AbortSignal.timeout(remaining));\n } catch (e: unknown) {\n if (isTimeoutError(e)) {\n return textResult({\n timedOut: true,\n status: \"Done\",\n note: \"Computation done but outputs did not stabilize in time. Retry with a longer timeout.\",\n });\n }\n return errorResult(\n `Failed to get block state: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n\n const data = deriveDataFromStorage(state.blockStorage);\n\n const blockInfo = {\n id: block.id,\n title: block.title ?? block.label,\n calculationStatus: block.calculationStatus,\n canRun: block.canRun,\n stale: block.stale,\n outputErrors: block.outputErrors,\n };\n\n if (transform) {\n try {\n const result = await safeEval(\n transform,\n {\n data,\n outputs: state.outputs,\n block: blockInfo,\n },\n transformTimeout,\n );\n return textResult({ status: \"Done\", block: blockInfo, result });\n } catch (e: unknown) {\n return errorResult(\n `Transform failed: ${e instanceof Error ? e.message : String(e)}`,\n \"Check your JS expression syntax. Available variables: data, outputs, block.\",\n );\n }\n }\n\n return textResult({\n status: \"Done\",\n block: blockInfo,\n data,\n outputs: summarizeOutputs(state.outputs as Record<string, unknown> | undefined),\n });\n }\n\n // Still running — wait up to 5s for overview to change, then re-poll.\n // Minimum 500ms delay to avoid busy-looping if awaitChange resolves immediately.\n const pollStart = Date.now();\n try {\n const result = await project.overview.getFullValue();\n await project.overview.awaitChange(AbortSignal.timeout(5000), result.uTag);\n } catch {\n // timeout or abort — just re-poll\n }\n const elapsed = Date.now() - pollStart;\n if (elapsed < 500) {\n await new Promise((r) => setTimeout(r, 500 - elapsed));\n }\n }\n\n // Timed out while running\n const overview = await project.overview.getValue();\n const block = overview?.blocks.find((b) => b.id === blockId);\n return textResult({\n timedOut: true,\n status: block?.calculationStatus ?? \"Unknown\",\n hint: \"The block is still running. Call await_block_done again with a longer timeout.\",\n });\n },\n );\n}\n"],"mappings":";;;;;;;AASA,SAAgB,mBAAmB,QAAmB,KAAwB;CAC5E,OAAO,aACL,oBACA;EACE,aACE;EAGF,aAAa;GACX,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,YAAY;GAC3C,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,sBAAsB;GACnD,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAM,CAAC,CAAC,SAAS,gCAAgC;GACxF,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,uLAGF;GACF,kBAAkB,EACf,OAAO,CAAC,CACR,SAAS,CAAC,CACV,QAAQ,GAAI,CAAC,CACb,SAAS,wDAAwD;EACtE;CACF,GACA,OAAO,EAAE,WAAW,SAAS,SAAS,WAAW,uBAAuB;EACtE,MAAM,UAAU,MAAM,IAAI,iBAAiB,SAAS;EACpD,MAAM,WAAW,KAAK,IAAI,IAAI;EAE9B,OAAO,KAAK,IAAI,IAAI,UAAU;GAC5B,MAAM,WAAW,MAAM,QAAQ,SAAS,SAAS;GACjD,IAAI,CAAC,UAAU;GACf,MAAM,QAAQ,SAAS,OAAO,MAAM,MAAM,EAAE,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,OAAO,YACL,SAAS,QAAQ,wBAAwB,UAAU,IACnD,iEACF;GAGF,IAAI,MAAM,sBAAsB,SAC9B,OAAO,YACL,+DACA,iGACF;GAGF,IAAI,MAAM,sBAAsB,iBAC9B,OAAO,YACL,+BACA,8DACF;GAGF,IAAI,MAAM,sBAAsB,QAAQ;IAEtC,MAAM,YAAY,KAAK,IAAI,WAAW,KAAK,IAAI,GAAG,GAAI;IACtD,IAAI;IACJ,IAA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AQ,OAAO,qBAAqB;GACpC,MAAM;EACR,CAAC;CACH,CACF;AACF"}
1
+ {"version":3,"file":"await.js","names":[],"sources":["../../src/tools/await.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { isTimeoutError } from \"@milaboratories/pl-middle-layer\";\nimport { deriveDataFromStorage } from \"@platforma-sdk/model\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { summarizeOutputs } from \"./tokens\";\nimport { safeEval } from \"./sandbox\";\nimport { errorResult, hints, textResult } from \"./types\";\n\nexport function registerAwaitTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"await_block_done\",\n {\n title: \"Wait for Block\",\n annotations: hints.read,\n description:\n \"Wait for a block to finish computation and outputs to stabilize. \" +\n \"Returns block status, data, and concise output summary with token estimates. \" +\n \"Use `transform` to extract specific data server-side on completion.\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID\"),\n blockId: blockIdInput.describe(\"Block ID to wait for\"),\n timeout: z.number().optional().default(120000).describe(\"Timeout in ms (default 120000)\"),\n transform: z\n .string()\n .optional()\n .describe(\n \"JS expression evaluated server-side when block completes. \" +\n \"Available variables: `data` (block args), `outputs` (raw outputs), `block` (status info). \" +\n \"Omit for default concise summary.\",\n ),\n transformTimeout: z\n .number()\n .optional()\n .default(5000)\n .describe(\"Timeout in ms for transform evaluation (default 5000).\"),\n }),\n },\n async ({ projectId, blockId, timeout, transform, transformTimeout }) => {\n const project = await ctx.getOpenedProject(projectId);\n const deadline = Date.now() + timeout;\n\n while (Date.now() < deadline) {\n const overview = await project.overview.getValue();\n if (!overview) continue;\n const block = overview.blocks.find((b) => b.id === blockId);\n if (!block)\n return errorResult(\n `Block ${blockId} not found in project ${projectId}.`,\n \"Use get_project_overview to list all block IDs in this project.\",\n );\n\n // Terminal error states — return immediately\n if (block.calculationStatus === \"Limbo\") {\n return errorResult(\n \"Block entered Limbo state (upstream failed or was stopped).\",\n \"Check upstream blocks with get_project_overview. Fix or re-run the failed upstream, then retry.\",\n );\n }\n\n if (block.calculationStatus === \"NotCalculated\") {\n return errorResult(\n \"Block has not been started.\",\n \"Use run_block to start it first, then call await_block_done.\",\n );\n }\n\n if (block.calculationStatus === \"Done\") {\n // Await stable block state with remaining time budget\n const remaining = Math.max(deadline - Date.now(), 1000);\n let state;\n try {\n state = await project\n .getBlockState(blockId)\n .awaitStableValue(AbortSignal.timeout(remaining));\n } catch (e: unknown) {\n if (isTimeoutError(e)) {\n return textResult({\n timedOut: true,\n status: \"Done\",\n note: \"Computation done but outputs did not stabilize in time. Retry with a longer timeout.\",\n });\n }\n return errorResult(\n `Failed to get block state: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n\n const data = deriveDataFromStorage(state.blockStorage);\n\n const blockInfo = {\n id: block.id,\n title: block.title ?? block.label,\n calculationStatus: block.calculationStatus,\n canRun: block.canRun,\n stale: block.stale,\n outputErrors: block.outputErrors,\n };\n\n if (transform) {\n try {\n const result = await safeEval(\n transform,\n {\n data,\n outputs: state.outputs,\n block: blockInfo,\n },\n transformTimeout,\n );\n return textResult({ status: \"Done\", block: blockInfo, result });\n } catch (e: unknown) {\n return errorResult(\n `Transform failed: ${e instanceof Error ? e.message : String(e)}`,\n \"Check your JS expression syntax. Available variables: data, outputs, block.\",\n );\n }\n }\n\n return textResult({\n status: \"Done\",\n block: blockInfo,\n data,\n outputs: summarizeOutputs(state.outputs as Record<string, unknown> | undefined),\n });\n }\n\n // Still running — wait up to 5s for overview to change, then re-poll.\n // Minimum 500ms delay to avoid busy-looping if awaitChange resolves immediately.\n const pollStart = Date.now();\n try {\n const result = await project.overview.getFullValue();\n await project.overview.awaitChange(AbortSignal.timeout(5000), result.uTag);\n } catch {\n // timeout or abort — just re-poll\n }\n const elapsed = Date.now() - pollStart;\n if (elapsed < 500) {\n await new Promise((r) => setTimeout(r, 500 - elapsed));\n }\n }\n\n // Timed out while running\n const overview = await project.overview.getValue();\n const block = overview?.blocks.find((b) => b.id === blockId);\n return textResult({\n timedOut: true,\n status: block?.calculationStatus ?? \"Unknown\",\n hint: \"The block is still running. Call await_block_done again with a longer timeout.\",\n });\n },\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,mBAAmB,QAAmB,KAAwB;CAC5E,OAAO,aACL,oBACA;EACE,OAAO;EACP,aAAa,MAAM;EACnB,aACE;EAGF,aAAa,EAAE,OAAO;GACpB,WAAW,eAAe,SAAS,YAAY;GAC/C,SAAS,aAAa,SAAS,sBAAsB;GACrD,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAM,CAAC,CAAC,SAAS,gCAAgC;GACxF,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,uLAGF;GACF,kBAAkB,EACf,OAAO,CAAC,CACR,SAAS,CAAC,CACV,QAAQ,GAAI,CAAC,CACb,SAAS,wDAAwD;EACtE,CAAC;CACH,GACA,OAAO,EAAE,WAAW,SAAS,SAAS,WAAW,uBAAuB;EACtE,MAAM,UAAU,MAAM,IAAI,iBAAiB,SAAS;EACpD,MAAM,WAAW,KAAK,IAAI,IAAI;EAE9B,OAAO,KAAK,IAAI,IAAI,UAAU;GAC5B,MAAM,WAAW,MAAM,QAAQ,SAAS,SAAS;GACjD,IAAI,CAAC,UAAU;GACf,MAAM,QAAQ,SAAS,OAAO,MAAM,MAAM,EAAE,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,OAAO,YACL,SAAS,QAAQ,wBAAwB,UAAU,IACnD,iEACF;GAGF,IAAI,MAAM,sBAAsB,SAC9B,OAAO,YACL,+DACA,iGACF;GAGF,IAAI,MAAM,sBAAsB,iBAC9B,OAAO,YACL,+BACA,8DACF;GAGF,IAAI,MAAM,sBAAsB,QAAQ;IAEtC,MAAM,YAAY,KAAK,IAAI,WAAW,KAAK,IAAI,GAAG,GAAI;IACtD,IAAI;IACJ,IAAI;KACF,QAAQ,MAAM,QAC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C,MAAM;EACR,CAAC;CACH,CACF;AACF"}
@@ -1,4 +1,5 @@
1
1
  const require_types = require("./types.cjs");
2
+ const require_ids = require("./ids.cjs");
2
3
  let zod = require("zod");
3
4
  // src/tools/block-action-context.ts
4
5
  /** Finds the node with the context ID in the tree, or undefined. */
@@ -26,15 +27,17 @@ function limitBlockActionContextTree(node, limits) {
26
27
  }
27
28
  function registerBlockActionContextTools(server, ctx) {
28
29
  server.registerTool("get_block_action_context", {
30
+ title: "Get Block Action Context",
31
+ annotations: require_types.hints.read,
29
32
  description: "Get the block action context tree of a block run: one node per template render, each with its baggage (name, block-pack, block-id, run-id), the render it belongs to (resource), its action transition in time order (namespace, reporting resource, state, detail, reason), its readings (namespace, resource, key, value) and its child renders. Use it to see which step a block is in or where it waits. The result is cut to maxDepth levels and the latest maxTransitions per node; a node with childrenOmitted or transitionsOmitted has more. Pass its contextId to read below it. Reads the current state; call again to refresh.",
30
- inputSchema: {
31
- projectId: zod.z.string().describe("Project ID (must be opened)"),
32
- blockId: zod.z.string().describe("Block ID"),
33
+ inputSchema: zod.z.object({
34
+ projectId: require_ids.projectIdInput.describe("Project ID (must be opened)"),
35
+ blockId: require_ids.blockIdInput.describe("Block ID"),
33
36
  mode: zod.z.enum(["prod", "staging"]).optional().describe("Which render of the block: 'prod' (default) or 'staging'"),
34
37
  contextId: zod.z.string().optional().describe("Return the subtree of this action context instead of the root"),
35
38
  maxDepth: zod.z.number().int().min(0).optional().default(3).describe("Levels of child renders to include (default 3)"),
36
39
  maxTransitions: zod.z.number().int().min(0).optional().default(20).describe("Latest transitions to include per node (default 20)")
37
- }
40
+ })
38
41
  }, async ({ projectId, blockId, mode, contextId, maxDepth, maxTransitions }) => {
39
42
  const tree = await (await ctx.getOpenedProject(projectId)).getBlockActionContext(blockId, mode ?? "prod");
40
43
  if (tree === void 0) return require_types.errorResult("Block has no action context tree: it was not rendered yet, or the backend does not support block action context.");
@@ -1 +1 @@
1
- {"version":3,"file":"block-action-context.cjs","names":["z","errorResult","textResult"],"sources":["../../src/tools/block-action-context.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { BlockActionContextNode } from \"@milaboratories/pl-middle-layer\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, textResult } from \"./types\";\n\n/** An action context tree node as the tool returns it: cut to the requested depth and history. */\nexport type LimitedBlockActionContextNode = Omit<BlockActionContextNode, \"children\"> & {\n children: LimitedBlockActionContextNode[];\n /** Older transitions left out of this node. */\n transitionsOmitted?: number;\n /** Child renders left out below the depth limit. Request this node by contextId to see them. */\n childrenOmitted?: number;\n};\n\n/** Options of {@link limitBlockActionContextTree}. */\nexport type BlockActionContextTreeLimits = {\n /** Levels of children to include under the returned node. 0 returns the node only. */\n maxDepth: number;\n /** The latest transitions to keep per node. */\n maxTransitions: number;\n};\n\n/** Finds the node with the context ID in the tree, or undefined. */\nexport function findBlockActionContextNode(\n tree: BlockActionContextNode,\n contextId: string,\n): BlockActionContextNode | undefined {\n if (tree.contextId === contextId) return tree;\n for (const child of tree.children) {\n const found = findBlockActionContextNode(child, contextId);\n if (found !== undefined) return found;\n }\n return undefined;\n}\n\n/** Cuts an action context tree to maxDepth levels of children and the latest maxTransitions per node. */\nexport function limitBlockActionContextTree(\n node: BlockActionContextNode,\n limits: BlockActionContextTreeLimits,\n): LimitedBlockActionContextNode {\n const transitionsOmitted = Math.max(0, node.transitions.length - limits.maxTransitions);\n const limited: LimitedBlockActionContextNode = {\n ...node,\n transitions: node.transitions.slice(transitionsOmitted),\n children:\n limits.maxDepth > 0\n ? node.children.map((child) =>\n limitBlockActionContextTree(child, { ...limits, maxDepth: limits.maxDepth - 1 }),\n )\n : [],\n };\n if (transitionsOmitted > 0) limited.transitionsOmitted = transitionsOmitted;\n if (limits.maxDepth <= 0 && node.children.length > 0)\n limited.childrenOmitted = node.children.length;\n return limited;\n}\n\nexport function registerBlockActionContextTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_action_context\",\n {\n description:\n \"Get the block action context tree of a block run: one node per template render, each with its baggage \" +\n \"(name, block-pack, block-id, run-id), the render it belongs to (resource), its action transition in time order \" +\n \"(namespace, reporting resource, state, detail, reason), its readings (namespace, resource, key, \" +\n \"value) and its child renders. Use it to see which step a block is in or where it waits. \" +\n \"The result is cut to maxDepth levels and the latest maxTransitions per node; a node with \" +\n \"childrenOmitted or transitionsOmitted has more. Pass its contextId to read below it. \" +\n \"Reads the current state; call again to refresh.\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID (must be opened)\"),\n blockId: z.string().describe(\"Block ID\"),\n mode: z\n .enum([\"prod\", \"staging\"])\n .optional()\n .describe(\"Which render of the block: 'prod' (default) or 'staging'\"),\n contextId: z\n .string()\n .optional()\n .describe(\"Return the subtree of this action context instead of the root\"),\n maxDepth: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(3)\n .describe(\"Levels of child renders to include (default 3)\"),\n maxTransitions: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(20)\n .describe(\"Latest transitions to include per node (default 20)\"),\n },\n },\n async ({ projectId, blockId, mode, contextId, maxDepth, maxTransitions }) => {\n const project = await ctx.getOpenedProject(projectId);\n const tree = await project.getBlockActionContext(blockId, mode ?? \"prod\");\n if (tree === undefined)\n return errorResult(\n \"Block has no action context tree: it was not rendered yet, or the backend does not support block action context.\",\n );\n\n const node = contextId === undefined ? tree : findBlockActionContextNode(tree, contextId);\n if (node === undefined)\n return errorResult(\n `Action context ${contextId} is not in the action context tree of the block. Call without contextId to see the tree.`,\n );\n\n return textResult(limitBlockActionContextTree(node, { maxDepth, maxTransitions }));\n },\n );\n}\n"],"mappings":";;;;AAwBA,SAAgB,2BACd,MACA,WACoC;CACpC,IAAI,KAAK,cAAc,WAAW,OAAO;CACzC,KAAK,MAAM,SAAS,KAAK,UAAU;EACjC,MAAM,QAAQ,2BAA2B,OAAO,SAAS;EACzD,IAAI,UAAU,KAAA,GAAW,OAAO;CACl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B,sBAAsB,SAAS,QAAQ,MAAM;EACxE,IAAI,SAAS,KAAA,GACX,OAAOC,cAAAA,YACL,kHACF;EAEF,MAAM,OAAO,cAAc,KAAA,IAAY,OAAO,2BAA2B,MAAM,SAAS;EACxF,IAAI,SAAS,KAAA,GACX,OAAOA,cAAAA,YACL,kBAAkB,UAAU,yFAC9B;EAEF,OAAOC,cAAAA,WAAW,4BAA4B,MAAM;GAAE;GAAU;EAAe,CAAC,CAAC;CACnF,CACF;AACF"}
1
+ {"version":3,"file":"block-action-context.cjs","names":["hints","z","projectIdInput","blockIdInput","errorResult","textResult"],"sources":["../../src/tools/block-action-context.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport type { BlockActionContextNode } from \"@milaboratories/pl-middle-layer\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, hints, textResult } from \"./types\";\n\n/** An action context tree node as the tool returns it: cut to the requested depth and history. */\nexport type LimitedBlockActionContextNode = Omit<BlockActionContextNode, \"children\"> & {\n children: LimitedBlockActionContextNode[];\n /** Older transitions left out of this node. */\n transitionsOmitted?: number;\n /** Child renders left out below the depth limit. Request this node by contextId to see them. */\n childrenOmitted?: number;\n};\n\n/** Options of {@link limitBlockActionContextTree}. */\nexport type BlockActionContextTreeLimits = {\n /** Levels of children to include under the returned node. 0 returns the node only. */\n maxDepth: number;\n /** The latest transitions to keep per node. */\n maxTransitions: number;\n};\n\n/** Finds the node with the context ID in the tree, or undefined. */\nexport function findBlockActionContextNode(\n tree: BlockActionContextNode,\n contextId: string,\n): BlockActionContextNode | undefined {\n if (tree.contextId === contextId) return tree;\n for (const child of tree.children) {\n const found = findBlockActionContextNode(child, contextId);\n if (found !== undefined) return found;\n }\n return undefined;\n}\n\n/** Cuts an action context tree to maxDepth levels of children and the latest maxTransitions per node. */\nexport function limitBlockActionContextTree(\n node: BlockActionContextNode,\n limits: BlockActionContextTreeLimits,\n): LimitedBlockActionContextNode {\n const transitionsOmitted = Math.max(0, node.transitions.length - limits.maxTransitions);\n const limited: LimitedBlockActionContextNode = {\n ...node,\n transitions: node.transitions.slice(transitionsOmitted),\n children:\n limits.maxDepth > 0\n ? node.children.map((child) =>\n limitBlockActionContextTree(child, { ...limits, maxDepth: limits.maxDepth - 1 }),\n )\n : [],\n };\n if (transitionsOmitted > 0) limited.transitionsOmitted = transitionsOmitted;\n if (limits.maxDepth <= 0 && node.children.length > 0)\n limited.childrenOmitted = node.children.length;\n return limited;\n}\n\nexport function registerBlockActionContextTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_action_context\",\n {\n title: \"Get Block Action Context\",\n annotations: hints.read,\n description:\n \"Get the block action context tree of a block run: one node per template render, each with its baggage \" +\n \"(name, block-pack, block-id, run-id), the render it belongs to (resource), its action transition in time order \" +\n \"(namespace, reporting resource, state, detail, reason), its readings (namespace, resource, key, \" +\n \"value) and its child renders. Use it to see which step a block is in or where it waits. \" +\n \"The result is cut to maxDepth levels and the latest maxTransitions per node; a node with \" +\n \"childrenOmitted or transitionsOmitted has more. Pass its contextId to read below it. \" +\n \"Reads the current state; call again to refresh.\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID (must be opened)\"),\n blockId: blockIdInput.describe(\"Block ID\"),\n mode: z\n .enum([\"prod\", \"staging\"])\n .optional()\n .describe(\"Which render of the block: 'prod' (default) or 'staging'\"),\n contextId: z\n .string()\n .optional()\n .describe(\"Return the subtree of this action context instead of the root\"),\n maxDepth: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(3)\n .describe(\"Levels of child renders to include (default 3)\"),\n maxTransitions: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(20)\n .describe(\"Latest transitions to include per node (default 20)\"),\n }),\n },\n async ({ projectId, blockId, mode, contextId, maxDepth, maxTransitions }) => {\n const project = await ctx.getOpenedProject(projectId);\n const tree = await project.getBlockActionContext(blockId, mode ?? \"prod\");\n if (tree === undefined)\n return errorResult(\n \"Block has no action context tree: it was not rendered yet, or the backend does not support block action context.\",\n );\n\n const node = contextId === undefined ? tree : findBlockActionContextNode(tree, contextId);\n if (node === undefined)\n return errorResult(\n `Action context ${contextId} is not in the action context tree of the block. Call without contextId to see the tree.`,\n );\n\n return textResult(limitBlockActionContextTree(node, { maxDepth, maxTransitions }));\n },\n );\n}\n"],"mappings":";;;;;AAyBA,SAAgB,2BACd,MACA,WACoC;CACpC,IAAI,KAAK,cAAc,WAAW,OAAO;CACzC,KAAK,MAAM,SAAS,KAAK,UAAU;EACjC,MAAM,QAAQ,2BAA2B,OAAO,SAAS;EACzD,IAAI,UAAU,KAAA,GAAW,OAAO;CAClC;AAEF;;AAGA,SAAgB,4BACd,MACA,QAC+B;CAC/B,MAAM,qBAAqB,KAAK,IAAI,GAAG,KAAK,YAAY,SAAS,OAAO,cAAc;CACtF,MAAM,UAAyC;EAC7C,GAAG;EACH,aAAa,KAAK,YAAY,MAAM,kBAAkB;EACtD,UACE,OAAO,WAAW,IACd,KAAK,SAAS,KAAK,UACjB,4BAA4B,OAAO;GAAE,GAAG;GAAQ,UAAU,OAAO,WAAW;EAAE,CAAC,CACjF,IACA,CAAC;CACT;CACA,IAAI,qBAAqB,GAAG,QAAQ,qBAAqB;CACzD,IAAI,OAAO,YAAY,KAAK,KAAK,SAAS,SAAS,GACjD,QAAQ,kBAAkB,KAAK,SAAS;CAC1C,OAAO;AACT;AAEA,SAAgB,gCAAgC,QAAmB,KAAwB;CACzF,OAAO,aACL,4BACA;EACE,OAAO;EACP,aAAaA,cAAAA,MAAM;EACnB,aACE;EAOF,aAAaC,IAAAA,EAAE,OAAO;GACpB,WAAWC,YAAAA,eAAe,SAAS,6BAA6B;GAChE,SAASC,YAAAA,aAAa,SAAS,UAAU;GACzC,MAAMF,IAAAA,EACH,KAAK,CAAC,QAAQ,SAAS,CAAC,CAAC,CACzB,SAAS,CAAC,CACV,SAAS,0DAA0D;GACtE,WAAWA,IAAAA,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,+DAA+D;GAC3E,UAAUA,IAAAA,EACP,OAAO,CAAC,CACR,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,SAAS,CAAC,CACV,QAAQ,CAAC,CAAC,CACV,SAAS,gDAAgD;GAC5D,gBAAgBA,IAAAA,EACb,OAAO,CAAC,CACR,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,SAAS,CAAC,CACV,QAAQ,EAAE,CAAC,CACX,SAAS,qDAAqD;EACnE,CAAC;CACH,GACA,OAAO,EAAE,WAAW,SAAS,MAAM,WAAW,UAAU,qBAAqB;EAE3E,MAAM,OAAO,OAAM,MADG,IAAI,iBAAiB,SAAS,EAAA,CACzB,sBAAsB,SAAS,QAAQ,MAAM;EACxE,IAAI,SAAS,KAAA,GACX,OAAOG,cAAAA,YACL,kHACF;EAEF,MAAM,OAAO,cAAc,KAAA,IAAY,OAAO,2BAA2B,MAAM,SAAS;EACxF,IAAI,SAAS,KAAA,GACX,OAAOA,cAAAA,YACL,kBAAkB,UAAU,yFAC9B;EAEF,OAAOC,cAAAA,WAAW,4BAA4B,MAAM;GAAE;GAAU;EAAe,CAAC,CAAC;CACnF,CACF;AACF"}
@@ -1,4 +1,5 @@
1
- import { errorResult, textResult } from "./types.js";
1
+ import { errorResult, hints, textResult } from "./types.js";
2
+ import { blockIdInput, projectIdInput } from "./ids.js";
2
3
  import { z } from "zod";
3
4
  // src/tools/block-action-context.ts
4
5
  /** Finds the node with the context ID in the tree, or undefined. */
@@ -26,15 +27,17 @@ function limitBlockActionContextTree(node, limits) {
26
27
  }
27
28
  function registerBlockActionContextTools(server, ctx) {
28
29
  server.registerTool("get_block_action_context", {
30
+ title: "Get Block Action Context",
31
+ annotations: hints.read,
29
32
  description: "Get the block action context tree of a block run: one node per template render, each with its baggage (name, block-pack, block-id, run-id), the render it belongs to (resource), its action transition in time order (namespace, reporting resource, state, detail, reason), its readings (namespace, resource, key, value) and its child renders. Use it to see which step a block is in or where it waits. The result is cut to maxDepth levels and the latest maxTransitions per node; a node with childrenOmitted or transitionsOmitted has more. Pass its contextId to read below it. Reads the current state; call again to refresh.",
30
- inputSchema: {
31
- projectId: z.string().describe("Project ID (must be opened)"),
32
- blockId: z.string().describe("Block ID"),
33
+ inputSchema: z.object({
34
+ projectId: projectIdInput.describe("Project ID (must be opened)"),
35
+ blockId: blockIdInput.describe("Block ID"),
33
36
  mode: z.enum(["prod", "staging"]).optional().describe("Which render of the block: 'prod' (default) or 'staging'"),
34
37
  contextId: z.string().optional().describe("Return the subtree of this action context instead of the root"),
35
38
  maxDepth: z.number().int().min(0).optional().default(3).describe("Levels of child renders to include (default 3)"),
36
39
  maxTransitions: z.number().int().min(0).optional().default(20).describe("Latest transitions to include per node (default 20)")
37
- }
40
+ })
38
41
  }, async ({ projectId, blockId, mode, contextId, maxDepth, maxTransitions }) => {
39
42
  const tree = await (await ctx.getOpenedProject(projectId)).getBlockActionContext(blockId, mode ?? "prod");
40
43
  if (tree === void 0) return errorResult("Block has no action context tree: it was not rendered yet, or the backend does not support block action context.");
@@ -1 +1 @@
1
- {"version":3,"file":"block-action-context.js","names":[],"sources":["../../src/tools/block-action-context.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { BlockActionContextNode } from \"@milaboratories/pl-middle-layer\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, textResult } from \"./types\";\n\n/** An action context tree node as the tool returns it: cut to the requested depth and history. */\nexport type LimitedBlockActionContextNode = Omit<BlockActionContextNode, \"children\"> & {\n children: LimitedBlockActionContextNode[];\n /** Older transitions left out of this node. */\n transitionsOmitted?: number;\n /** Child renders left out below the depth limit. Request this node by contextId to see them. */\n childrenOmitted?: number;\n};\n\n/** Options of {@link limitBlockActionContextTree}. */\nexport type BlockActionContextTreeLimits = {\n /** Levels of children to include under the returned node. 0 returns the node only. */\n maxDepth: number;\n /** The latest transitions to keep per node. */\n maxTransitions: number;\n};\n\n/** Finds the node with the context ID in the tree, or undefined. */\nexport function findBlockActionContextNode(\n tree: BlockActionContextNode,\n contextId: string,\n): BlockActionContextNode | undefined {\n if (tree.contextId === contextId) return tree;\n for (const child of tree.children) {\n const found = findBlockActionContextNode(child, contextId);\n if (found !== undefined) return found;\n }\n return undefined;\n}\n\n/** Cuts an action context tree to maxDepth levels of children and the latest maxTransitions per node. */\nexport function limitBlockActionContextTree(\n node: BlockActionContextNode,\n limits: BlockActionContextTreeLimits,\n): LimitedBlockActionContextNode {\n const transitionsOmitted = Math.max(0, node.transitions.length - limits.maxTransitions);\n const limited: LimitedBlockActionContextNode = {\n ...node,\n transitions: node.transitions.slice(transitionsOmitted),\n children:\n limits.maxDepth > 0\n ? node.children.map((child) =>\n limitBlockActionContextTree(child, { ...limits, maxDepth: limits.maxDepth - 1 }),\n )\n : [],\n };\n if (transitionsOmitted > 0) limited.transitionsOmitted = transitionsOmitted;\n if (limits.maxDepth <= 0 && node.children.length > 0)\n limited.childrenOmitted = node.children.length;\n return limited;\n}\n\nexport function registerBlockActionContextTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_action_context\",\n {\n description:\n \"Get the block action context tree of a block run: one node per template render, each with its baggage \" +\n \"(name, block-pack, block-id, run-id), the render it belongs to (resource), its action transition in time order \" +\n \"(namespace, reporting resource, state, detail, reason), its readings (namespace, resource, key, \" +\n \"value) and its child renders. Use it to see which step a block is in or where it waits. \" +\n \"The result is cut to maxDepth levels and the latest maxTransitions per node; a node with \" +\n \"childrenOmitted or transitionsOmitted has more. Pass its contextId to read below it. \" +\n \"Reads the current state; call again to refresh.\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID (must be opened)\"),\n blockId: z.string().describe(\"Block ID\"),\n mode: z\n .enum([\"prod\", \"staging\"])\n .optional()\n .describe(\"Which render of the block: 'prod' (default) or 'staging'\"),\n contextId: z\n .string()\n .optional()\n .describe(\"Return the subtree of this action context instead of the root\"),\n maxDepth: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(3)\n .describe(\"Levels of child renders to include (default 3)\"),\n maxTransitions: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(20)\n .describe(\"Latest transitions to include per node (default 20)\"),\n },\n },\n async ({ projectId, blockId, mode, contextId, maxDepth, maxTransitions }) => {\n const project = await ctx.getOpenedProject(projectId);\n const tree = await project.getBlockActionContext(blockId, mode ?? \"prod\");\n if (tree === undefined)\n return errorResult(\n \"Block has no action context tree: it was not rendered yet, or the backend does not support block action context.\",\n );\n\n const node = contextId === undefined ? tree : findBlockActionContextNode(tree, contextId);\n if (node === undefined)\n return errorResult(\n `Action context ${contextId} is not in the action context tree of the block. Call without contextId to see the tree.`,\n );\n\n return textResult(limitBlockActionContextTree(node, { maxDepth, maxTransitions }));\n },\n );\n}\n"],"mappings":";;;;AAwBA,SAAgB,2BACd,MACA,WACoC;CACpC,IAAI,KAAK,cAAc,WAAW,OAAO;CACzC,KAAK,MAAM,SAAS,KAAK,UAAU;EACjC,MAAM,QAAQ,2BAA2B,OAAO,SAAS;EACzD,IAAI,UAAU,KAAA,GAAW,OAAO;CAClC;AAEF;;AAGA,SAAgB,4BACd,MACA,QAC+B;CAC/B,MAAM,qBAAqB,KAAK,IAAI,GAAG,KAAK,YAAY,SAAS,OAAO,cAAc;CACtF,MAAM,UAAyC;EAC7C,GAAG;EACH,aAAa,KAAK,YAAY,MAAM,kBAAkB;EACtD,UACE,OAAO,WAAW,IACd,KAAK,SAAS,KAAK,UACjB,4BAA4B,OAAO;GAAE,GAAG;GAAQ,UAAU,OAAO,WAAW;EAAE,CAAC,CACjF,IACA,CAAC;CACT;CACA,IAAI,qBAAqB,GAAG,QAAQ,qBAAqB;CACzD,IAAI,OAAO,YAAY,KAAK,KAAK,SAAS,SAAS,GACjD,QAAQ,kBAAkB,KAAK,SAAS;CAC1C,OAAO;AACT;AAEA,SAAgB,gCAAgC,QAAmB,KAAwB;CACzF,OAAO,aACL,4BACA;EACE,aACE;EAOF,aAAa;GACX,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,6BAA6B;GAC5D,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,UAAU;GACvC,MAAM,EACH,KAAK,CAAC,QAAQ,SAAS,CAAC,CAAC,CACzB,SAAS,CAAC,CACV,SAAS,0DAA0D;GACtE,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,+DAA+D;GAC3E,UAAU,EACP,OAAO,CAAC,CACR,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,SAAS,CAAC,CACV,QAAQ,CAAC,CAAC,CACV,SAAS,gDAAgD;GAC5D,gBAAgB,EACb,OAAO,CAAC,CACR,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,SAAS,CAAC,CACV,QAAQ,EAAE,CAAC,CACX,SAAS,qDAAqD;EACnE;CACF,GACA,OAAO,EAAE,WAAW,SAAS,MAAM,WAAW,UAAU,qBAAqB;EAE3E,MAAM,OAAO,OAAM,MADG,IAAI,iBAAiB,SAAS,EAAA,CACzB,sBAAsB,SAAS,QAAQ,MAAM;EACxE,IAAI,SAAS,KAAA,GACX,OAAO,YACL,kHACF;EAEF,MAAM,OAAO,cAAc,KAAA,IAAY,OAAO,2BAA2B,MAAM,SAAS;EACxF,IAAI,SAAS,KAAA,GACX,OAAO,YACL,kBAAkB,UAAU,yFAC9B;EAEF,OAAO,WAAW,4BAA4B,MAAM;GAAE;GAAU;EAAe,CAAC,CAAC;CACnF,CACF;AACF"}
1
+ {"version":3,"file":"block-action-context.js","names":[],"sources":["../../src/tools/block-action-context.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport type { BlockActionContextNode } from \"@milaboratories/pl-middle-layer\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { errorResult, hints, textResult } from \"./types\";\n\n/** An action context tree node as the tool returns it: cut to the requested depth and history. */\nexport type LimitedBlockActionContextNode = Omit<BlockActionContextNode, \"children\"> & {\n children: LimitedBlockActionContextNode[];\n /** Older transitions left out of this node. */\n transitionsOmitted?: number;\n /** Child renders left out below the depth limit. Request this node by contextId to see them. */\n childrenOmitted?: number;\n};\n\n/** Options of {@link limitBlockActionContextTree}. */\nexport type BlockActionContextTreeLimits = {\n /** Levels of children to include under the returned node. 0 returns the node only. */\n maxDepth: number;\n /** The latest transitions to keep per node. */\n maxTransitions: number;\n};\n\n/** Finds the node with the context ID in the tree, or undefined. */\nexport function findBlockActionContextNode(\n tree: BlockActionContextNode,\n contextId: string,\n): BlockActionContextNode | undefined {\n if (tree.contextId === contextId) return tree;\n for (const child of tree.children) {\n const found = findBlockActionContextNode(child, contextId);\n if (found !== undefined) return found;\n }\n return undefined;\n}\n\n/** Cuts an action context tree to maxDepth levels of children and the latest maxTransitions per node. */\nexport function limitBlockActionContextTree(\n node: BlockActionContextNode,\n limits: BlockActionContextTreeLimits,\n): LimitedBlockActionContextNode {\n const transitionsOmitted = Math.max(0, node.transitions.length - limits.maxTransitions);\n const limited: LimitedBlockActionContextNode = {\n ...node,\n transitions: node.transitions.slice(transitionsOmitted),\n children:\n limits.maxDepth > 0\n ? node.children.map((child) =>\n limitBlockActionContextTree(child, { ...limits, maxDepth: limits.maxDepth - 1 }),\n )\n : [],\n };\n if (transitionsOmitted > 0) limited.transitionsOmitted = transitionsOmitted;\n if (limits.maxDepth <= 0 && node.children.length > 0)\n limited.childrenOmitted = node.children.length;\n return limited;\n}\n\nexport function registerBlockActionContextTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_action_context\",\n {\n title: \"Get Block Action Context\",\n annotations: hints.read,\n description:\n \"Get the block action context tree of a block run: one node per template render, each with its baggage \" +\n \"(name, block-pack, block-id, run-id), the render it belongs to (resource), its action transition in time order \" +\n \"(namespace, reporting resource, state, detail, reason), its readings (namespace, resource, key, \" +\n \"value) and its child renders. Use it to see which step a block is in or where it waits. \" +\n \"The result is cut to maxDepth levels and the latest maxTransitions per node; a node with \" +\n \"childrenOmitted or transitionsOmitted has more. Pass its contextId to read below it. \" +\n \"Reads the current state; call again to refresh.\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID (must be opened)\"),\n blockId: blockIdInput.describe(\"Block ID\"),\n mode: z\n .enum([\"prod\", \"staging\"])\n .optional()\n .describe(\"Which render of the block: 'prod' (default) or 'staging'\"),\n contextId: z\n .string()\n .optional()\n .describe(\"Return the subtree of this action context instead of the root\"),\n maxDepth: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(3)\n .describe(\"Levels of child renders to include (default 3)\"),\n maxTransitions: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(20)\n .describe(\"Latest transitions to include per node (default 20)\"),\n }),\n },\n async ({ projectId, blockId, mode, contextId, maxDepth, maxTransitions }) => {\n const project = await ctx.getOpenedProject(projectId);\n const tree = await project.getBlockActionContext(blockId, mode ?? \"prod\");\n if (tree === undefined)\n return errorResult(\n \"Block has no action context tree: it was not rendered yet, or the backend does not support block action context.\",\n );\n\n const node = contextId === undefined ? tree : findBlockActionContextNode(tree, contextId);\n if (node === undefined)\n return errorResult(\n `Action context ${contextId} is not in the action context tree of the block. Call without contextId to see the tree.`,\n );\n\n return textResult(limitBlockActionContextTree(node, { maxDepth, maxTransitions }));\n },\n );\n}\n"],"mappings":";;;;;AAyBA,SAAgB,2BACd,MACA,WACoC;CACpC,IAAI,KAAK,cAAc,WAAW,OAAO;CACzC,KAAK,MAAM,SAAS,KAAK,UAAU;EACjC,MAAM,QAAQ,2BAA2B,OAAO,SAAS;EACzD,IAAI,UAAU,KAAA,GAAW,OAAO;CAClC;AAEF;;AAGA,SAAgB,4BACd,MACA,QAC+B;CAC/B,MAAM,qBAAqB,KAAK,IAAI,GAAG,KAAK,YAAY,SAAS,OAAO,cAAc;CACtF,MAAM,UAAyC;EAC7C,GAAG;EACH,aAAa,KAAK,YAAY,MAAM,kBAAkB;EACtD,UACE,OAAO,WAAW,I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U;EAAe,CAAC,CAAC;CACnF,CACF;AACF"}
@@ -0,0 +1,23 @@
1
+ const require_types = require("./types.cjs");
2
+ let _milaboratories_pl_errors = require("@milaboratories/pl-errors");
3
+ // src/tools/block-api.ts
4
+ /**
5
+ * The block API MCP creates and writes blocks on (BlockModelV3): the model API version a create
6
+ * or an update requires of the block pack.
7
+ */
8
+ const SUPPORTED_BLOCK_API = require("@platforma-sdk/model").BLOCK_STORAGE_FACADE_VERSION;
9
+ /** What a tool answers when the block it would create or write is on another block API. */
10
+ const UNSUPPORTED_BLOCK_API_TEXT = "Blocks on block API 1 are not supported; nothing was changed.";
11
+ /**
12
+ * The guard of every create and write: the error result for `e` when it is the middle layer's
13
+ * refusal of a block on another block API (`ModelAPIVersionMismatchError`), `undefined` for any
14
+ * other error.
15
+ */
16
+ function unsupportedBlockApiResult(e) {
17
+ return e instanceof _milaboratories_pl_errors.ModelAPIVersionMismatchError ? require_types.errorResult(UNSUPPORTED_BLOCK_API_TEXT) : void 0;
18
+ }
19
+ exports.SUPPORTED_BLOCK_API = SUPPORTED_BLOCK_API;
20
+ exports.UNSUPPORTED_BLOCK_API_TEXT = UNSUPPORTED_BLOCK_API_TEXT;
21
+ exports.unsupportedBlockApiResult = unsupportedBlockApiResult;
22
+
23
+ //# sourceMappingURL=block-api.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-api.cjs","names":["BLOCK_STORAGE_FACADE_VERSION","ModelAPIVersionMismatchError","errorResult"],"sources":["../../src/tools/block-api.ts"],"sourcesContent":["import { ModelAPIVersionMismatchError } from \"@milaboratories/pl-errors\";\nimport { BLOCK_STORAGE_FACADE_VERSION } from \"@platforma-sdk/model\";\nimport { errorResult } from \"./types\";\n\n/**\n * The block API MCP creates and writes blocks on (BlockModelV3): the model API version a create\n * or an update requires of the block pack.\n */\nexport const SUPPORTED_BLOCK_API = BLOCK_STORAGE_FACADE_VERSION;\n\n/** What a tool answers when the block it would create or write is on another block API. */\nexport const UNSUPPORTED_BLOCK_API_TEXT =\n \"Blocks on block API 1 are not supported; nothing was changed.\";\n\n/**\n * The guard of every create and write: the error result for `e` when it is the middle layer's\n * refusal of a block on another block API (`ModelAPIVersionMismatchError`), `undefined` for any\n * other error.\n */\nexport function unsupportedBlockApiResult(e: unknown) {\n return e instanceof ModelAPIVersionMismatchError\n ? errorResult(UNSUPPORTED_BLOCK_API_TEXT)\n : undefined;\n}\n"],"mappings":";;;;;;;AAQA,MAAa,sB,8BAAsBA,CAAAA,CAAAA;;AAGnC,MAAa,6BACX;;;;;;AAOF,SAAgB,0BAA0B,GAAY;CACpD,OAAO,aAAaC,0BAAAA,+BAChBC,cAAAA,YAAY,0BAA0B,IACtC,KAAA;AACN"}
@@ -0,0 +1,22 @@
1
+ import { errorResult } from "./types.js";
2
+ import { ModelAPIVersionMismatchError } from "@milaboratories/pl-errors";
3
+ import { BLOCK_STORAGE_FACADE_VERSION } from "@platforma-sdk/model";
4
+ // src/tools/block-api.ts
5
+ /**
6
+ * The block API MCP creates and writes blocks on (BlockModelV3): the model API version a create
7
+ * or an update requires of the block pack.
8
+ */
9
+ const SUPPORTED_BLOCK_API = BLOCK_STORAGE_FACADE_VERSION;
10
+ /** What a tool answers when the block it would create or write is on another block API. */
11
+ const UNSUPPORTED_BLOCK_API_TEXT = "Blocks on block API 1 are not supported; nothing was changed.";
12
+ /**
13
+ * The guard of every create and write: the error result for `e` when it is the middle layer's
14
+ * refusal of a block on another block API (`ModelAPIVersionMismatchError`), `undefined` for any
15
+ * other error.
16
+ */
17
+ function unsupportedBlockApiResult(e) {
18
+ return e instanceof ModelAPIVersionMismatchError ? errorResult(UNSUPPORTED_BLOCK_API_TEXT) : void 0;
19
+ }
20
+ export { SUPPORTED_BLOCK_API, UNSUPPORTED_BLOCK_API_TEXT, unsupportedBlockApiResult };
21
+
22
+ //# sourceMappingURL=block-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-api.js","names":[],"sources":["../../src/tools/block-api.ts"],"sourcesContent":["import { ModelAPIVersionMismatchError } from \"@milaboratories/pl-errors\";\nimport { BLOCK_STORAGE_FACADE_VERSION } from \"@platforma-sdk/model\";\nimport { errorResult } from \"./types\";\n\n/**\n * The block API MCP creates and writes blocks on (BlockModelV3): the model API version a create\n * or an update requires of the block pack.\n */\nexport const SUPPORTED_BLOCK_API = BLOCK_STORAGE_FACADE_VERSION;\n\n/** What a tool answers when the block it would create or write is on another block API. */\nexport const UNSUPPORTED_BLOCK_API_TEXT =\n \"Blocks on block API 1 are not supported; nothing was changed.\";\n\n/**\n * The guard of every create and write: the error result for `e` when it is the middle layer's\n * refusal of a block on another block API (`ModelAPIVersionMismatchError`), `undefined` for any\n * other error.\n */\nexport function unsupportedBlockApiResult(e: unknown) {\n return e instanceof ModelAPIVersionMismatchError\n ? errorResult(UNSUPPORTED_BLOCK_API_TEXT)\n : undefined;\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,sBAAsB;;AAGnC,MAAa,6BACX;;;;;;AAOF,SAAgB,0BAA0B,GAAY;CACpD,OAAO,aAAa,+BAChB,YAAY,0BAA0B,IACtC,KAAA;AACN"}
@@ -0,0 +1,21 @@
1
+ const require_types = require("./types.cjs");
2
+ const require_ids = require("./ids.cjs");
3
+ let zod = require("zod");
4
+ // src/tools/block-params.ts
5
+ function registerBlockParamsTools(server, ctx) {
6
+ server.registerTool("get_block_params", {
7
+ title: "Get Block Params",
8
+ annotations: require_types.hints.read,
9
+ description: "Get a block's configuration as the initialization params of its kind: what a project template stores for this block. The block's own model derives them from its current data. Pass the result as `params` of add_block, with a block of the same kind, to create a block configured the same way. Read-only: params usually leave out view state, so to change an existing block use get_block_state and set_block_data.\n\nReturns `{ kind, params }`. `kind` is absent for a block that declares none.",
10
+ inputSchema: zod.z.object({
11
+ projectId: require_ids.projectIdInput.describe("Project ID (must be opened)"),
12
+ blockId: require_ids.blockIdInput.describe("Block ID")
13
+ })
14
+ }, async ({ projectId, blockId }) => {
15
+ const project = await ctx.getOpenedProject(projectId);
16
+ return require_types.textResult(await project.getBlockInitializationParams(blockId));
17
+ });
18
+ }
19
+ exports.registerBlockParamsTools = registerBlockParamsTools;
20
+
21
+ //# sourceMappingURL=block-params.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-params.cjs","names":["hints","z","projectIdInput","blockIdInput","textResult"],"sources":["../../src/tools/block-params.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { hints, textResult } from \"./types\";\n\nexport function registerBlockParamsTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_params\",\n {\n title: \"Get Block Params\",\n annotations: hints.read,\n description:\n \"Get a block's configuration as the initialization params of its kind: what a project \" +\n \"template stores for this block. The block's own model derives them from its current data. \" +\n \"Pass the result as `params` of add_block, with a block of the same kind, to create a \" +\n \"block configured the same way. Read-only: params usually leave out view state, so to \" +\n \"change an existing block use get_block_state and set_block_data.\\n\\n\" +\n \"Returns `{ kind, params }`. `kind` is absent for a block that declares none.\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID (must be opened)\"),\n blockId: blockIdInput.describe(\"Block ID\"),\n }),\n },\n async ({ projectId, blockId }) => {\n const project = await ctx.getOpenedProject(projectId);\n return textResult(await project.getBlockInitializationParams(blockId));\n },\n );\n}\n"],"mappings":";;;;AAMA,SAAgB,yBAAyB,QAAmB,KAAwB;CAClF,OAAO,aACL,oBACA;EACE,OAAO;EACP,aAAaA,cAAAA,MAAM;EACnB,aACE;EAMF,aAAaC,IAAAA,EAAE,OAAO;GACpB,WAAWC,YAAAA,eAAe,SAAS,6BAA6B;GAChE,SAASC,YAAAA,aAAa,SAAS,UAAU;EAC3C,CAAC;CACH,GACA,OAAO,EAAE,WAAW,cAAc;EAChC,MAAM,UAAU,MAAM,IAAI,iBAAiB,SAAS;EACpD,OAAOC,cAAAA,WAAW,MAAM,QAAQ,6BAA6B,OAAO,CAAC;CACvE,CACF;AACF"}
@@ -0,0 +1,21 @@
1
+ import { hints, textResult } from "./types.js";
2
+ import { blockIdInput, projectIdInput } from "./ids.js";
3
+ import { z } from "zod";
4
+ // src/tools/block-params.ts
5
+ function registerBlockParamsTools(server, ctx) {
6
+ server.registerTool("get_block_params", {
7
+ title: "Get Block Params",
8
+ annotations: hints.read,
9
+ description: "Get a block's configuration as the initialization params of its kind: what a project template stores for this block. The block's own model derives them from its current data. Pass the result as `params` of add_block, with a block of the same kind, to create a block configured the same way. Read-only: params usually leave out view state, so to change an existing block use get_block_state and set_block_data.\n\nReturns `{ kind, params }`. `kind` is absent for a block that declares none.",
10
+ inputSchema: z.object({
11
+ projectId: projectIdInput.describe("Project ID (must be opened)"),
12
+ blockId: blockIdInput.describe("Block ID")
13
+ })
14
+ }, async ({ projectId, blockId }) => {
15
+ const project = await ctx.getOpenedProject(projectId);
16
+ return textResult(await project.getBlockInitializationParams(blockId));
17
+ });
18
+ }
19
+ export { registerBlockParamsTools };
20
+
21
+ //# sourceMappingURL=block-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-params.js","names":[],"sources":["../../src/tools/block-params.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { hints, textResult } from \"./types\";\n\nexport function registerBlockParamsTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_block_params\",\n {\n title: \"Get Block Params\",\n annotations: hints.read,\n description:\n \"Get a block's configuration as the initialization params of its kind: what a project \" +\n \"template stores for this block. The block's own model derives them from its current data. \" +\n \"Pass the result as `params` of add_block, with a block of the same kind, to create a \" +\n \"block configured the same way. Read-only: params usually leave out view state, so to \" +\n \"change an existing block use get_block_state and set_block_data.\\n\\n\" +\n \"Returns `{ kind, params }`. `kind` is absent for a block that declares none.\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID (must be opened)\"),\n blockId: blockIdInput.describe(\"Block ID\"),\n }),\n },\n async ({ projectId, blockId }) => {\n const project = await ctx.getOpenedProject(projectId);\n return textResult(await project.getBlockInitializationParams(blockId));\n },\n );\n}\n"],"mappings":";;;;AAMA,SAAgB,yBAAyB,QAAmB,KAAwB;CAClF,OAAO,aACL,oBACA;EACE,OAAO;EACP,aAAa,MAAM;EACnB,aACE;EAMF,aAAa,EAAE,OAAO;GACpB,WAAW,eAAe,SAAS,6BAA6B;GAChE,SAAS,aAAa,SAAS,UAAU;EAC3C,CAAC;CACH,GACA,OAAO,EAAE,WAAW,cAAc;EAChC,MAAM,UAAU,MAAM,IAAI,iBAAiB,SAAS;EACpD,OAAO,WAAW,MAAM,QAAQ,6BAA6B,OAAO,CAAC;CACvE,CACF;AACF"}
@@ -1,14 +1,17 @@
1
1
  const require_types = require("./types.cjs");
2
+ const require_ids = require("./ids.cjs");
2
3
  const require_tokens = require("./tokens.cjs");
3
4
  const require_sandbox = require("./sandbox.cjs");
4
5
  let zod = require("zod");
5
- let _platforma_sdk_model = require("@platforma-sdk/model");
6
6
  let _milaboratories_pl_errors = require("@milaboratories/pl-errors");
7
+ let _platforma_sdk_model = require("@platforma-sdk/model");
7
8
  // src/tools/block-state.ts
8
9
  function registerBlockStateTools(server, ctx) {
9
10
  server.registerTool("get_project_overview", {
11
+ title: "Get Project Overview",
12
+ annotations: require_types.hints.read,
10
13
  description: "Get project overview with all blocks and their statuses (calculationStatus, canRun, stale, errors, upstreams/downstreams)",
11
- inputSchema: { projectId: zod.z.string().describe("Project ID (must be opened)") }
14
+ inputSchema: zod.z.object({ projectId: require_ids.projectIdInput.describe("Project ID (must be opened)") })
12
15
  }, async ({ projectId }) => {
13
16
  const overview = await (await ctx.getOpenedProject(projectId)).overview.getValue();
14
17
  if (!overview) return require_types.errorResult("Project overview not available yet.");
@@ -28,13 +31,15 @@ function registerBlockStateTools(server, ctx) {
28
31
  });
29
32
  });
30
33
  server.registerTool("get_block_state", {
34
+ title: "Get Block State",
35
+ annotations: require_types.hints.read,
31
36
  description: "Get block state. Returns block args (data) and a concise output summary with token estimates by default. Use `transform` to extract specific data server-side without loading full outputs into context.\n\nDefault: returns `{ data, outputs: [{ key, ok, hasValue, tokensEstimate }] }`\n\nTransform examples:\n- `outputs.logs?.value` — get one specific output value\n- `data` — get only block args\n- `({ preset: outputs.preset?.value, qc: outputs.qc?.value })` — get specific outputs",
32
- inputSchema: {
33
- projectId: zod.z.string().describe("Project ID"),
34
- blockId: zod.z.string().describe("Block ID"),
37
+ inputSchema: zod.z.object({
38
+ projectId: require_ids.projectIdInput.describe("Project ID"),
39
+ blockId: require_ids.blockIdInput.describe("Block ID"),
35
40
  transform: zod.z.string().optional().describe("JS expression evaluated server-side against full block state. Available variables: `data` (block args), `outputs` (raw outputs object). Omit for default concise summary."),
36
41
  transformTimeout: zod.z.number().optional().default(5e3).describe("Timeout in ms for transform evaluation (default 5000).")
37
- }
42
+ })
38
43
  }, async ({ projectId, blockId, transform, transformTimeout }) => {
39
44
  const state = await (await ctx.getOpenedProject(projectId)).getBlockState(blockId).getValue();
40
45
  const data = (0, _platforma_sdk_model.deriveDataFromStorage)(state.blockStorage);
@@ -53,12 +58,14 @@ function registerBlockStateTools(server, ctx) {
53
58
  });
54
59
  });
55
60
  server.registerTool("set_block_data", {
61
+ title: "Set Block Data",
62
+ annotations: require_types.hints.destructive,
56
63
  description: "Set the user-facing data of a block (triggers args derivation and staging)",
57
- inputSchema: {
58
- projectId: zod.z.string().describe("Project ID"),
59
- blockId: zod.z.string().describe("Block ID"),
60
- data: zod.z.record(zod.z.unknown()).describe("Block data object")
61
- }
64
+ inputSchema: zod.z.object({
65
+ projectId: require_ids.projectIdInput.describe("Project ID"),
66
+ blockId: require_ids.blockIdInput.describe("Block ID"),
67
+ data: zod.z.record(zod.z.string(), zod.z.unknown()).describe("Block data object")
68
+ })
62
69
  }, async ({ projectId, blockId, data }) => {
63
70
  const project = await ctx.getOpenedProject(projectId);
64
71
  const value = data.args ?? data;
@@ -1 +1 @@
1
- {"version":3,"file":"block-state.cjs","names":["z","errorResult","textResult","deriveDataFromStorage","safeEval","summarizeOutputs","ModelAPIVersionMismatchError"],"sources":["../../src/tools/block-state.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { deriveDataFromStorage } from \"@platforma-sdk/model\";\nimport { ModelAPIVersionMismatchError } from \"@milaboratories/pl-errors\";\nimport { z } from \"zod\";\nimport type { ToolContext } from \"./types\";\nimport { summarizeOutputs } from \"./tokens\";\nimport { safeEval } from \"./sandbox\";\nimport { errorResult, textResult } from \"./types\";\n\nexport function registerBlockStateTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_project_overview\",\n {\n description:\n \"Get project overview with all blocks and their statuses (calculationStatus, canRun, stale, errors, upstreams/downstreams)\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID (must be opened)\"),\n },\n },\n async ({ projectId }) => {\n const project = await ctx.getOpenedProject(projectId);\n const overview = await project.overview.getValue();\n if (!overview) return errorResult(\"Project overview not available yet.\");\n return textResult({\n label: overview.meta.label,\n blocks: overview.blocks.map((b) => ({\n id: b.id,\n title: b.title ?? b.label,\n calculationStatus: b.calculationStatus,\n canRun: b.canRun,\n stale: b.stale,\n inputsValid: b.inputsValid,\n outputErrors: b.outputErrors,\n upstreams: b.upstreams,\n downstreams: b.downstreams,\n })),\n });\n },\n );\n\n server.registerTool(\n \"get_block_state\",\n {\n description:\n \"Get block state. Returns block args (data) and a concise output summary with token estimates by default. \" +\n \"Use `transform` to extract specific data server-side without loading full outputs into context.\\n\\n\" +\n \"Default: returns `{ data, outputs: [{ key, ok, hasValue, tokensEstimate }] }`\\n\\n\" +\n \"Transform examples:\\n\" +\n \"- `outputs.logs?.value` — get one specific output value\\n\" +\n \"- `data` — get only block args\\n\" +\n \"- `({ preset: outputs.preset?.value, qc: outputs.qc?.value })` — get specific outputs\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID\"),\n blockId: z.string().describe(\"Block ID\"),\n transform: z\n .string()\n .optional()\n .describe(\n \"JS expression evaluated server-side against full block state. \" +\n \"Available variables: `data` (block args), `outputs` (raw outputs object). \" +\n \"Omit for default concise summary.\",\n ),\n transformTimeout: z\n .number()\n .optional()\n .default(5000)\n .describe(\"Timeout in ms for transform evaluation (default 5000).\"),\n },\n },\n async ({ projectId, blockId, transform, transformTimeout }) => {\n const project = await ctx.getOpenedProject(projectId);\n const state = await project.getBlockState(blockId).getValue();\n const data = deriveDataFromStorage(state.blockStorage);\n if (transform) {\n try {\n const result = await safeEval(\n transform,\n { data, outputs: state.outputs },\n transformTimeout,\n );\n return textResult(result);\n } catch (e: unknown) {\n return errorResult(\n `Transform failed: ${e instanceof Error ? e.message : String(e)}`,\n \"Check your JS expression syntax. Available variables: data, outputs.\",\n );\n }\n }\n return textResult({\n data,\n outputs: summarizeOutputs(state.outputs as Record<string, unknown> | undefined),\n });\n },\n );\n\n server.registerTool(\n \"set_block_data\",\n {\n description: \"Set the user-facing data of a block (triggers args derivation and staging)\",\n inputSchema: {\n projectId: z.string().describe(\"Project ID\"),\n blockId: z.string().describe(\"Block ID\"),\n data: z.record(z.unknown()).describe(\"Block data object\"),\n },\n },\n async ({ projectId, blockId, data }) => {\n const project = await ctx.getOpenedProject(projectId);\n\n // V1 state shape: { args, uiState } — callers may pass either the full state\n // or just the args object. Unwrap once for both V2 and V1 paths.\n const value = data.args ?? data;\n\n // Try V2 (BlockModelV3 storage facade) first, fall back to V1 (legacy setBlockArgs).\n try {\n await project.mutateBlockStorage(\n blockId,\n { operation: \"update-block-data\", value },\n ctx.getAuthorMarker(),\n );\n } catch (e: unknown) {\n if (e instanceof ModelAPIVersionMismatchError) {\n await project.setBlockArgs(blockId, value, ctx.getAuthorMarker());\n } else {\n throw e;\n }\n }\n return textResult({ ok: true });\n },\n );\n}\n"],"mappings":";;;;;;;AASA,SAAgB,wBAAwB,QAAmB,KAAwB;CACjF,O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AC1B,SAAS,GAAY;GACnB,OAAOD,cAAAA,YACL,qBAAqB,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,KAC9D,sEACF;EACF;EAEF,OAAOC,cAAAA,WAAW;GAChB;GACA,SAASG,eAAAA,iBAAiB,MAAM,OAA8C;EAChF,CAAC;CACH,CACF;CAEA,OAAO,aACL,kBACA;EACE,aAAa;EACb,aAAa;GACX,WAAWL,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,YAAY;GAC3C,SAASA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,UAAU;GACvC,MAAMA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,mBAAmB;EAC1D;CACF,GACA,OAAO,EAAE,WAAW,SAAS,WAAW;EACtC,MAAM,UAAU,MAAM,IAAI,iBAAiB,SAAS;EAIpD,MAAM,QAAQ,KAAK,QAAQ;EAG3B,IAAI;GACF,MAAM,QAAQ,mBACZ,SACA;IAAE,WAAW;IAAqB;GAAM,GACxC,IAAI,gBAAgB,CACtB;EACF,SAAS,GAAY;GACnB,IAAI,aAAaM,0BAAAA,8BACf,MAAM,QAAQ,aAAa,SAAS,OAAO,IAAI,gBAAgB,CAAC;QAEhE,MAAM;EAEV;EACA,OAAOJ,cAAAA,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;AACF"}
1
+ {"version":3,"file":"block-state.cjs","names":["hints","z","projectIdInput","errorResult","textResult","blockIdInput","deriveDataFromStorage","safeEval","summarizeOutputs","ModelAPIVersionMismatchError"],"sources":["../../src/tools/block-state.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/server\";\nimport { deriveDataFromStorage } from \"@platforma-sdk/model\";\nimport { ModelAPIVersionMismatchError } from \"@milaboratories/pl-errors\";\nimport { z } from \"zod\";\nimport { projectIdInput, blockIdInput } from \"./ids\";\nimport type { ToolContext } from \"./types\";\nimport { summarizeOutputs } from \"./tokens\";\nimport { safeEval } from \"./sandbox\";\nimport { errorResult, hints, textResult } from \"./types\";\n\nexport function registerBlockStateTools(server: McpServer, ctx: ToolContext): void {\n server.registerTool(\n \"get_project_overview\",\n {\n title: \"Get Project Overview\",\n annotations: hints.read,\n description:\n \"Get project overview with all blocks and their statuses (calculationStatus, canRun, stale, errors, upstreams/downstreams)\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID (must be opened)\"),\n }),\n },\n async ({ projectId }) => {\n const project = await ctx.getOpenedProject(projectId);\n const overview = await project.overview.getValue();\n if (!overview) return errorResult(\"Project overview not available yet.\");\n return textResult({\n label: overview.meta.label,\n blocks: overview.blocks.map((b) => ({\n id: b.id,\n title: b.title ?? b.label,\n calculationStatus: b.calculationStatus,\n canRun: b.canRun,\n stale: b.stale,\n inputsValid: b.inputsValid,\n outputErrors: b.outputErrors,\n upstreams: b.upstreams,\n downstreams: b.downstreams,\n })),\n });\n },\n );\n\n server.registerTool(\n \"get_block_state\",\n {\n title: \"Get Block State\",\n annotations: hints.read,\n description:\n \"Get block state. Returns block args (data) and a concise output summary with token estimates by default. \" +\n \"Use `transform` to extract specific data server-side without loading full outputs into context.\\n\\n\" +\n \"Default: returns `{ data, outputs: [{ key, ok, hasValue, tokensEstimate }] }`\\n\\n\" +\n \"Transform examples:\\n\" +\n \"- `outputs.logs?.value` — get one specific output value\\n\" +\n \"- `data` — get only block args\\n\" +\n \"- `({ preset: outputs.preset?.value, qc: outputs.qc?.value })` — get specific outputs\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID\"),\n blockId: blockIdInput.describe(\"Block ID\"),\n transform: z\n .string()\n .optional()\n .describe(\n \"JS expression evaluated server-side against full block state. \" +\n \"Available variables: `data` (block args), `outputs` (raw outputs object). \" +\n \"Omit for default concise summary.\",\n ),\n transformTimeout: z\n .number()\n .optional()\n .default(5000)\n .describe(\"Timeout in ms for transform evaluation (default 5000).\"),\n }),\n },\n async ({ projectId, blockId, transform, transformTimeout }) => {\n const project = await ctx.getOpenedProject(projectId);\n const state = await project.getBlockState(blockId).getValue();\n const data = deriveDataFromStorage(state.blockStorage);\n if (transform) {\n try {\n const result = await safeEval(\n transform,\n { data, outputs: state.outputs },\n transformTimeout,\n );\n return textResult(result);\n } catch (e: unknown) {\n return errorResult(\n `Transform failed: ${e instanceof Error ? e.message : String(e)}`,\n \"Check your JS expression syntax. Available variables: data, outputs.\",\n );\n }\n }\n return textResult({\n data,\n outputs: summarizeOutputs(state.outputs as Record<string, unknown> | undefined),\n });\n },\n );\n\n server.registerTool(\n \"set_block_data\",\n {\n title: \"Set Block Data\",\n annotations: hints.destructive,\n description: \"Set the user-facing data of a block (triggers args derivation and staging)\",\n inputSchema: z.object({\n projectId: projectIdInput.describe(\"Project ID\"),\n blockId: blockIdInput.describe(\"Block ID\"),\n data: z.record(z.string(), z.unknown()).describe(\"Block data object\"),\n }),\n },\n async ({ projectId, blockId, data }) => {\n const project = await ctx.getOpenedProject(projectId);\n\n // V1 state shape: { args, uiState } — callers may pass either the full state\n // or just the args object. Unwrap once for both V2 and V1 paths.\n const value = data.args ?? data;\n\n // Try V2 (BlockModelV3 storage facade) first, fall back to V1 (legacy setBlockArgs).\n try {\n await project.mutateBlockStorage(\n blockId,\n { operation: \"update-block-data\", value },\n ctx.getAuthorMarker(),\n );\n } catch (e: unknown) {\n if (e instanceof ModelAPIVersionMismatchError) {\n await project.setBlockArgs(blockId, value, ctx.getAuthorMarker());\n } else {\n throw e;\n }\n }\n return textResult({ ok: true });\n },\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,wBAAwB,QAAmB,KAAwB;CACjF,OAAO,aACL,wBACA;EACE,OAAO;EACP,aAAaA,cAAAA,MAAM;EACnB,aACE;EACF,aAAaC,IAAAA,EAAE,OAAO,EACpB,WAAWC,YAAAA,eAAe,SAAS,6BAA6B,EAClE,CAAC;CACH,GACA,OAAO,EAAE,gBAAgB;EAEvB,MAAM,WAAW,OAAM,MADD,IAAI,iBAAiB,SAAS,EAAA,CACrB,SA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,MAAM,OAA8C;EAChF,CAAC;CACH,CACF;CAEA,OAAO,aACL,kBACA;EACE,OAAO;EACP,aAAaR,cAAAA,MAAM;EACnB,aAAa;EACb,aAAaC,IAAAA,EAAE,OAAO;GACpB,WAAWC,YAAAA,eAAe,SAAS,YAAY;GAC/C,SAASG,YAAAA,aAAa,SAAS,UAAU;GACzC,MAAMJ,IAAAA,EAAE,OAAOA,IAAAA,EAAE,OAAO,GAAGA,IAAAA,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,mBAAmB;EACtE,CAAC;CACH,GACA,OAAO,EAAE,WAAW,SAAS,WAAW;EACtC,MAAM,UAAU,MAAM,IAAI,iBAAiB,SAAS;EAIpD,MAAM,QAAQ,KAAK,QAAQ;EAG3B,IAAI;GACF,MAAM,QAAQ,mBACZ,SACA;IAAE,WAAW;IAAqB;GAAM,GACxC,IAAI,gBAAgB,CACtB;EACF,SAAS,GAAY;GACnB,IAAI,aAAaQ,0BAAAA,8BACf,MAAM,QAAQ,aAAa,SAAS,OAAO,IAAI,gBAAgB,CAAC;QAEhE,MAAM;EAEV;EACA,OAAOL,cAAAA,WAAW,EAAE,IAAI,KAAK,CAAC;CAChC,CACF;AACF"}
@@ -1,14 +1,17 @@
1
- import { errorResult, textResult } from "./types.js";
1
+ import { errorResult, hints, textResult } from "./types.js";
2
+ import { blockIdInput, projectIdInput } from "./ids.js";
2
3
  import { summarizeOutputs } from "./tokens.js";
3
4
  import { safeEval } from "./sandbox.js";
4
5
  import { z } from "zod";
5
- import { deriveDataFromStorage } from "@platforma-sdk/model";
6
6
  import { ModelAPIVersionMismatchError } from "@milaboratories/pl-errors";
7
+ import { deriveDataFromStorage } from "@platforma-sdk/model";
7
8
  // src/tools/block-state.ts
8
9
  function registerBlockStateTools(server, ctx) {
9
10
  server.registerTool("get_project_overview", {
11
+ title: "Get Project Overview",
12
+ annotations: hints.read,
10
13
  description: "Get project overview with all blocks and their statuses (calculationStatus, canRun, stale, errors, upstreams/downstreams)",
11
- inputSchema: { projectId: z.string().describe("Project ID (must be opened)") }
14
+ inputSchema: z.object({ projectId: projectIdInput.describe("Project ID (must be opened)") })
12
15
  }, async ({ projectId }) => {
13
16
  const overview = await (await ctx.getOpenedProject(projectId)).overview.getValue();
14
17
  if (!overview) return errorResult("Project overview not available yet.");
@@ -28,13 +31,15 @@ function registerBlockStateTools(server, ctx) {
28
31
  });
29
32
  });
30
33
  server.registerTool("get_block_state", {
34
+ title: "Get Block State",
35
+ annotations: hints.read,
31
36
  description: "Get block state. Returns block args (data) and a concise output summary with token estimates by default. Use `transform` to extract specific data server-side without loading full outputs into context.\n\nDefault: returns `{ data, outputs: [{ key, ok, hasValue, tokensEstimate }] }`\n\nTransform examples:\n- `outputs.logs?.value` — get one specific output value\n- `data` — get only block args\n- `({ preset: outputs.preset?.value, qc: outputs.qc?.value })` — get specific outputs",
32
- inputSchema: {
33
- projectId: z.string().describe("Project ID"),
34
- blockId: z.string().describe("Block ID"),
37
+ inputSchema: z.object({
38
+ projectId: projectIdInput.describe("Project ID"),
39
+ blockId: blockIdInput.describe("Block ID"),
35
40
  transform: z.string().optional().describe("JS expression evaluated server-side against full block state. Available variables: `data` (block args), `outputs` (raw outputs object). Omit for default concise summary."),
36
41
  transformTimeout: z.number().optional().default(5e3).describe("Timeout in ms for transform evaluation (default 5000).")
37
- }
42
+ })
38
43
  }, async ({ projectId, blockId, transform, transformTimeout }) => {
39
44
  const state = await (await ctx.getOpenedProject(projectId)).getBlockState(blockId).getValue();
40
45
  const data = deriveDataFromStorage(state.blockStorage);
@@ -53,12 +58,14 @@ function registerBlockStateTools(server, ctx) {
53
58
  });
54
59
  });
55
60
  server.registerTool("set_block_data", {
61
+ title: "Set Block Data",
62
+ annotations: hints.destructive,
56
63
  description: "Set the user-facing data of a block (triggers args derivation and staging)",
57
- inputSchema: {
58
- projectId: z.string().describe("Project ID"),
59
- blockId: z.string().describe("Block ID"),
60
- data: z.record(z.unknown()).describe("Block data object")
61
- }
64
+ inputSchema: z.object({
65
+ projectId: projectIdInput.describe("Project ID"),
66
+ blockId: blockIdInput.describe("Block ID"),
67
+ data: z.record(z.string(), z.unknown()).describe("Block data object")
68
+ })
62
69
  }, async ({ projectId, blockId, data }) => {
63
70
  const project = await ctx.getOpenedProject(projectId);
64
71
  const value = data.args ?? data;