@frontmcp/sdk 0.6.0 → 0.6.1

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 (96) hide show
  1. package/README.md +1 -0
  2. package/package.json +13 -6
  3. package/src/auth/session/index.d.ts +1 -0
  4. package/src/auth/session/index.js +3 -1
  5. package/src/auth/session/index.js.map +1 -1
  6. package/src/auth/session/vercel-kv-session.store.d.ts +96 -0
  7. package/src/auth/session/vercel-kv-session.store.js +216 -0
  8. package/src/auth/session/vercel-kv-session.store.js.map +1 -0
  9. package/src/common/decorators/front-mcp.decorator.js +14 -17
  10. package/src/common/decorators/front-mcp.decorator.js.map +1 -1
  11. package/src/common/metadata/front-mcp.metadata.d.ts +705 -23
  12. package/src/common/metadata/front-mcp.metadata.js +1 -0
  13. package/src/common/metadata/front-mcp.metadata.js.map +1 -1
  14. package/src/common/metadata/prompt.metadata.d.ts +4 -0
  15. package/src/common/metadata/resource.metadata.d.ts +8 -0
  16. package/src/common/metadata/tool-ui.metadata.d.ts +2 -2
  17. package/src/common/metadata/tool-ui.metadata.js +1 -1
  18. package/src/common/metadata/tool-ui.metadata.js.map +1 -1
  19. package/src/common/metadata/tool.metadata.d.ts +4 -0
  20. package/src/common/schemas/http-output.schema.d.ts +24 -6
  21. package/src/common/tokens/front-mcp.tokens.js +1 -0
  22. package/src/common/tokens/front-mcp.tokens.js.map +1 -1
  23. package/src/common/types/options/redis.options.d.ts +173 -5
  24. package/src/common/types/options/redis.options.js +157 -11
  25. package/src/common/types/options/redis.options.js.map +1 -1
  26. package/src/common/types/options/server-info.options.d.ts +4 -0
  27. package/src/common/types/options/transport.options.d.ts +68 -4
  28. package/src/common/utils/global-config.utils.d.ts +36 -0
  29. package/src/common/utils/global-config.utils.js +44 -0
  30. package/src/common/utils/global-config.utils.js.map +1 -0
  31. package/src/common/utils/index.d.ts +1 -0
  32. package/src/common/utils/index.js +1 -0
  33. package/src/common/utils/index.js.map +1 -1
  34. package/src/completion/flows/complete.flow.d.ts +6 -8
  35. package/src/errors/index.d.ts +1 -1
  36. package/src/errors/index.js +2 -1
  37. package/src/errors/index.js.map +1 -1
  38. package/src/errors/mcp.error.d.ts +9 -0
  39. package/src/errors/mcp.error.js +19 -1
  40. package/src/errors/mcp.error.js.map +1 -1
  41. package/src/front-mcp/front-mcp.providers.d.ts +208 -0
  42. package/src/front-mcp/index.d.ts +1 -0
  43. package/src/front-mcp/index.js +3 -0
  44. package/src/front-mcp/index.js.map +1 -1
  45. package/src/index.d.ts +1 -1
  46. package/src/index.js +2 -1
  47. package/src/index.js.map +1 -1
  48. package/src/logging/flows/set-level.flow.d.ts +6 -8
  49. package/src/prompt/flows/get-prompt.flow.d.ts +14 -8
  50. package/src/prompt/flows/prompts-list.flow.d.ts +8 -7
  51. package/src/resource/flows/read-resource.flow.d.ts +8 -9
  52. package/src/resource/flows/resource-templates-list.flow.d.ts +8 -7
  53. package/src/resource/flows/resources-list.flow.d.ts +8 -7
  54. package/src/resource/flows/subscribe-resource.flow.d.ts +6 -8
  55. package/src/resource/flows/unsubscribe-resource.flow.d.ts +6 -8
  56. package/src/store/adapters/store.vercel-kv.adapter.d.ts +86 -0
  57. package/src/store/adapters/store.vercel-kv.adapter.js +155 -0
  58. package/src/store/adapters/store.vercel-kv.adapter.js.map +1 -0
  59. package/src/store/index.d.ts +2 -0
  60. package/src/store/index.js +2 -0
  61. package/src/store/index.js.map +1 -1
  62. package/src/store/store.factory.d.ts +86 -0
  63. package/src/store/store.factory.js +194 -0
  64. package/src/store/store.factory.js.map +1 -0
  65. package/src/tool/flows/call-tool.flow.d.ts +18 -9
  66. package/src/tool/flows/call-tool.flow.js +2 -2
  67. package/src/tool/flows/call-tool.flow.js.map +1 -1
  68. package/src/tool/flows/tools-list.flow.d.ts +9 -8
  69. package/src/tool/flows/tools-list.flow.js +2 -2
  70. package/src/tool/flows/tools-list.flow.js.map +1 -1
  71. package/src/tool/ui/index.d.ts +4 -4
  72. package/src/tool/ui/index.js +4 -4
  73. package/src/tool/ui/index.js.map +1 -1
  74. package/src/tool/ui/platform-adapters.d.ts +2 -2
  75. package/src/tool/ui/platform-adapters.js +3 -3
  76. package/src/tool/ui/platform-adapters.js.map +1 -1
  77. package/src/tool/ui/template-helpers.d.ts +5 -7
  78. package/src/tool/ui/template-helpers.js +9 -26
  79. package/src/tool/ui/template-helpers.js.map +1 -1
  80. package/src/tool/ui/ui-resource.handler.d.ts +1 -1
  81. package/src/tool/ui/ui-resource.handler.js +5 -5
  82. package/src/tool/ui/ui-resource.handler.js.map +1 -1
  83. package/src/transport/mcp-handlers/complete-request.handler.d.ts +4 -15
  84. package/src/transport/mcp-handlers/get-prompt-request.handler.d.ts +5 -15
  85. package/src/transport/mcp-handlers/index.d.ts +67 -195
  86. package/src/transport/mcp-handlers/list-prompts-request.handler.d.ts +5 -15
  87. package/src/transport/mcp-handlers/list-resource-templates-request.handler.d.ts +5 -15
  88. package/src/transport/mcp-handlers/list-resources-request.handler.d.ts +5 -15
  89. package/src/transport/mcp-handlers/list-tools-request.handler.d.ts +5 -15
  90. package/src/transport/mcp-handlers/logging-set-level-request.handler.d.ts +3 -14
  91. package/src/transport/mcp-handlers/read-resource-request.handler.d.ts +4 -15
  92. package/src/transport/mcp-handlers/subscribe-request.handler.d.ts +3 -14
  93. package/src/transport/mcp-handlers/unsubscribe-request.handler.d.ts +3 -14
  94. package/src/transport/transport.registry.d.ts +5 -1
  95. package/src/transport/transport.registry.js +52 -23
  96. package/src/transport/transport.registry.js.map +1 -1
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Platform Adapters
4
4
  *
5
- * Re-exports platform adapter functions from @frontmcp/ui/adapters for SDK consumers.
5
+ * Re-exports platform adapter functions from @frontmcp/uipack/adapters for SDK consumers.
6
6
  * This provides a single source of truth for platform-specific metadata building
7
7
  * while maintaining backwards compatibility.
8
8
  *
@@ -10,8 +10,8 @@
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.buildOpenAICSP = exports.buildToolDiscoveryMeta = exports.buildUIMeta = void 0;
13
- // Re-export platform adapter types and functions from @frontmcp/ui
14
- var adapters_1 = require("@frontmcp/ui/adapters");
13
+ // Re-export platform adapter types and functions from @frontmcp/uipack
14
+ var adapters_1 = require("@frontmcp/uipack/adapters");
15
15
  Object.defineProperty(exports, "buildUIMeta", { enumerable: true, get: function () { return adapters_1.buildUIMeta; } });
16
16
  Object.defineProperty(exports, "buildToolDiscoveryMeta", { enumerable: true, get: function () { return adapters_1.buildToolDiscoveryMeta; } });
17
17
  Object.defineProperty(exports, "buildOpenAICSP", { enumerable: true, get: function () { return adapters_1.buildOpenAICSP; } });
@@ -1 +1 @@
1
- {"version":3,"file":"platform-adapters.js","sourceRoot":"","sources":["../../../../src/tool/ui/platform-adapters.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,mEAAmE;AACnE,kDAQ+B;AAH7B,uGAAA,WAAW,OAAA;AACX,kHAAA,sBAAsB,OAAA;AACtB,0GAAA,cAAc,OAAA","sourcesContent":["/**\n * Platform Adapters\n *\n * Re-exports platform adapter functions from @frontmcp/ui/adapters for SDK consumers.\n * This provides a single source of truth for platform-specific metadata building\n * while maintaining backwards compatibility.\n *\n * @see {@link https://docs.agentfront.dev/docs/servers/tools#tool-ui | Tool UI Documentation}\n */\n\n// Re-export platform adapter types and functions from @frontmcp/ui\nexport {\n type AIPlatformType,\n type UIMetadata,\n type BuildUIMetaOptions,\n type BuildToolDiscoveryMetaOptions,\n buildUIMeta,\n buildToolDiscoveryMeta,\n buildOpenAICSP,\n} from '@frontmcp/ui/adapters';\n"]}
1
+ {"version":3,"file":"platform-adapters.js","sourceRoot":"","sources":["../../../../src/tool/ui/platform-adapters.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,uEAAuE;AACvE,sDAQmC;AAHjC,uGAAA,WAAW,OAAA;AACX,kHAAA,sBAAsB,OAAA;AACtB,0GAAA,cAAc,OAAA","sourcesContent":["/**\n * Platform Adapters\n *\n * Re-exports platform adapter functions from @frontmcp/uipack/adapters for SDK consumers.\n * This provides a single source of truth for platform-specific metadata building\n * while maintaining backwards compatibility.\n *\n * @see {@link https://docs.agentfront.dev/docs/servers/tools#tool-ui | Tool UI Documentation}\n */\n\n// Re-export platform adapter types and functions from @frontmcp/uipack\nexport {\n type AIPlatformType,\n type UIMetadata,\n type BuildUIMetaOptions,\n type BuildToolDiscoveryMetaOptions,\n buildUIMeta,\n buildToolDiscoveryMeta,\n buildOpenAICSP,\n} from '@frontmcp/uipack/adapters';\n"]}
@@ -1,17 +1,15 @@
1
1
  /**
2
2
  * Template Helpers
3
3
  *
4
- * Re-exports template helper utilities from @frontmcp/ui/runtime.
4
+ * Re-exports template helper utilities from @frontmcp/ui.
5
5
  * Also provides individual helper functions for backwards compatibility.
6
6
  *
7
7
  * @see {@link https://docs.agentfront.dev/docs/servers/tools#tool-ui | Tool UI Documentation}
8
8
  */
9
9
  import type { TemplateHelpers } from '../../common/metadata/tool-ui.metadata';
10
- export { createTemplateHelpers } from '@frontmcp/ui/runtime';
11
- /**
12
- * Escape HTML special characters to prevent XSS.
13
- */
14
- export declare function escapeHtml(str: string): string;
10
+ import { escapeHtml } from '@frontmcp/uipack/utils';
11
+ export { createTemplateHelpers } from '@frontmcp/uipack/runtime';
12
+ export { escapeHtml };
15
13
  /**
16
14
  * Format a date for display.
17
15
  * @param date - Date object or ISO string
@@ -36,7 +34,7 @@ export declare function uniqueId(prefix?: string): string;
36
34
  export declare function jsonEmbed(data: unknown): string;
37
35
  /**
38
36
  * Create a TemplateHelpers object with all helper functions.
39
- * @deprecated Use createTemplateHelpers from @frontmcp/ui/runtime instead
37
+ * @deprecated Use createTemplateHelpers from @frontmcp/uipack/runtime instead
40
38
  */
41
39
  export declare function createTemplateHelpersLocal(): TemplateHelpers;
42
40
  /**
@@ -2,43 +2,26 @@
2
2
  /**
3
3
  * Template Helpers
4
4
  *
5
- * Re-exports template helper utilities from @frontmcp/ui/runtime.
5
+ * Re-exports template helper utilities from @frontmcp/ui.
6
6
  * Also provides individual helper functions for backwards compatibility.
7
7
  *
8
8
  * @see {@link https://docs.agentfront.dev/docs/servers/tools#tool-ui | Tool UI Documentation}
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.createTemplateHelpers = void 0;
12
- exports.escapeHtml = escapeHtml;
11
+ exports.escapeHtml = exports.createTemplateHelpers = void 0;
13
12
  exports.formatDate = formatDate;
14
13
  exports.formatCurrency = formatCurrency;
15
14
  exports.uniqueId = uniqueId;
16
15
  exports.jsonEmbed = jsonEmbed;
17
16
  exports.createTemplateHelpersLocal = createTemplateHelpersLocal;
18
17
  exports.resetIdCounter = resetIdCounter;
19
- // Re-export createTemplateHelpers from @frontmcp/ui
20
- var runtime_1 = require("@frontmcp/ui/runtime");
18
+ // Import escapeHtml from @frontmcp/uipack/utils - single source of truth (no React needed)
19
+ const utils_1 = require("@frontmcp/uipack/utils");
20
+ Object.defineProperty(exports, "escapeHtml", { enumerable: true, get: function () { return utils_1.escapeHtml; } });
21
+ // Re-export createTemplateHelpers from @frontmcp/uipack (no React needed)
22
+ var runtime_1 = require("@frontmcp/uipack/runtime");
21
23
  Object.defineProperty(exports, "createTemplateHelpers", { enumerable: true, get: function () { return runtime_1.createTemplateHelpers; } });
22
- // ============================================
23
- // Individual Helper Functions (Backwards Compatibility)
24
- // ============================================
25
- // These are exported individually for SDK consumers who import them directly.
26
- // For new code, prefer using createTemplateHelpers() instead.
27
24
  let idCounter = 0;
28
- /**
29
- * Escape HTML special characters to prevent XSS.
30
- */
31
- function escapeHtml(str) {
32
- if (typeof str !== 'string') {
33
- return String(str ?? '');
34
- }
35
- return str
36
- .replace(/&/g, '&')
37
- .replace(/</g, '&lt;')
38
- .replace(/>/g, '&gt;')
39
- .replace(/"/g, '&quot;')
40
- .replace(/'/g, '&#039;');
41
- }
42
25
  /**
43
26
  * Format a date for display.
44
27
  * @param date - Date object or ISO string
@@ -91,11 +74,11 @@ function jsonEmbed(data) {
91
74
  }
92
75
  /**
93
76
  * Create a TemplateHelpers object with all helper functions.
94
- * @deprecated Use createTemplateHelpers from @frontmcp/ui/runtime instead
77
+ * @deprecated Use createTemplateHelpers from @frontmcp/uipack/runtime instead
95
78
  */
96
79
  function createTemplateHelpersLocal() {
97
80
  return {
98
- escapeHtml,
81
+ escapeHtml: utils_1.escapeHtml,
99
82
  formatDate,
100
83
  formatCurrency,
101
84
  uniqueId,
@@ -1 +1 @@
1
- {"version":3,"file":"template-helpers.js","sourceRoot":"","sources":["../../../../src/tool/ui/template-helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAkBH,gCAUC;AAOD,gCAgBC;AAOD,wCAKC;AAMD,4BAEC;AAMD,8BAMC;AAMD,gEAQC;AAMD,wCAEC;AArGD,oDAAoD;AACpD,gDAA6D;AAApD,gHAAA,qBAAqB,OAAA;AAE9B,+CAA+C;AAC/C,wDAAwD;AACxD,+CAA+C;AAC/C,8EAA8E;AAC9E,8DAA8D;AAE9D,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB;;GAEG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAAC,IAAmB,EAAE,MAAe;IAC7D,MAAM,CAAC,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,KAAK;YACR,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QACzB,KAAK,MAAM;YACT,OAAO,CAAC,CAAC,kBAAkB,EAAE,CAAC;QAChC,KAAK,UAAU;YACb,OAAO,CAAC,CAAC,cAAc,EAAE,CAAC;QAC5B;YACE,OAAO,CAAC,CAAC,kBAAkB,EAAE,CAAC;IAClC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,QAAQ,GAAG,KAAK;IAC7D,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QACpC,KAAK,EAAE,UAAU;QACjB,QAAQ;KACT,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,MAAM,GAAG,KAAK;IACrC,OAAO,GAAG,MAAM,IAAI,EAAE,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,IAAa;IACrC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,SAAgB,0BAA0B;IACxC,OAAO;QACL,UAAU;QACV,UAAU;QACV,cAAc;QACd,QAAQ;QACR,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc;IAC5B,SAAS,GAAG,CAAC,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Template Helpers\n *\n * Re-exports template helper utilities from @frontmcp/ui/runtime.\n * Also provides individual helper functions for backwards compatibility.\n *\n * @see {@link https://docs.agentfront.dev/docs/servers/tools#tool-ui | Tool UI Documentation}\n */\n\nimport type { TemplateHelpers } from '../../common/metadata/tool-ui.metadata';\n\n// Re-export createTemplateHelpers from @frontmcp/ui\nexport { createTemplateHelpers } from '@frontmcp/ui/runtime';\n\n// ============================================\n// Individual Helper Functions (Backwards Compatibility)\n// ============================================\n// These are exported individually for SDK consumers who import them directly.\n// For new code, prefer using createTemplateHelpers() instead.\n\nlet idCounter = 0;\n\n/**\n * Escape HTML special characters to prevent XSS.\n */\nexport function escapeHtml(str: string): string {\n if (typeof str !== 'string') {\n return String(str ?? '');\n }\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#039;');\n}\n\n/**\n * Format a date for display.\n * @param date - Date object or ISO string\n * @param format - Optional format: 'iso', 'time', 'datetime', or default (localized date)\n */\nexport function formatDate(date: Date | string, format?: string): string {\n const d = typeof date === 'string' ? new Date(date) : date;\n if (isNaN(d.getTime())) {\n return String(date);\n }\n\n switch (format) {\n case 'iso':\n return d.toISOString();\n case 'time':\n return d.toLocaleTimeString();\n case 'datetime':\n return d.toLocaleString();\n default:\n return d.toLocaleDateString();\n }\n}\n\n/**\n * Format a number as currency.\n * @param amount - The numeric amount\n * @param currency - ISO 4217 currency code (default: 'USD')\n */\nexport function formatCurrency(amount: number, currency = 'USD'): string {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n }).format(amount);\n}\n\n/**\n * Generate a unique ID for DOM elements.\n * @param prefix - Optional prefix for the ID\n */\nexport function uniqueId(prefix = 'mcp'): string {\n return `${prefix}-${++idCounter}-${Date.now().toString(36)}`;\n}\n\n/**\n * Safely embed JSON data in HTML.\n * Escapes characters that could break out of script tags or HTML.\n */\nexport function jsonEmbed(data: unknown): string {\n return JSON.stringify(data)\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/'/g, '\\\\u0027');\n}\n\n/**\n * Create a TemplateHelpers object with all helper functions.\n * @deprecated Use createTemplateHelpers from @frontmcp/ui/runtime instead\n */\nexport function createTemplateHelpersLocal(): TemplateHelpers {\n return {\n escapeHtml,\n formatDate,\n formatCurrency,\n uniqueId,\n jsonEmbed,\n };\n}\n\n/**\n * Reset the ID counter (useful for testing).\n * @internal\n */\nexport function resetIdCounter(): void {\n idCounter = 0;\n}\n"]}
1
+ {"version":3,"file":"template-helpers.js","sourceRoot":"","sources":["../../../../src/tool/ui/template-helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAyBH,gCAgBC;AAOD,wCAKC;AAMD,4BAEC;AAMD,8BAMC;AAMD,gEAQC;AAMD,wCAEC;AA5FD,2FAA2F;AAC3F,kDAAoD;AAY3C,2FAZA,kBAAU,OAYA;AAVnB,0EAA0E;AAC1E,oDAAiE;AAAxD,gHAAA,qBAAqB,OAAA;AAW9B,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB;;;;GAIG;AACH,SAAgB,UAAU,CAAC,IAAmB,EAAE,MAAe;IAC7D,MAAM,CAAC,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,KAAK;YACR,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QACzB,KAAK,MAAM;YACT,OAAO,CAAC,CAAC,kBAAkB,EAAE,CAAC;QAChC,KAAK,UAAU;YACb,OAAO,CAAC,CAAC,cAAc,EAAE,CAAC;QAC5B;YACE,OAAO,CAAC,CAAC,kBAAkB,EAAE,CAAC;IAClC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,QAAQ,GAAG,KAAK;IAC7D,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QACpC,KAAK,EAAE,UAAU;QACjB,QAAQ;KACT,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,MAAM,GAAG,KAAK;IACrC,OAAO,GAAG,MAAM,IAAI,EAAE,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,IAAa;IACrC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,SAAgB,0BAA0B;IACxC,OAAO;QACL,UAAU,EAAV,kBAAU;QACV,UAAU;QACV,cAAc;QACd,QAAQ;QACR,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc;IAC5B,SAAS,GAAG,CAAC,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Template Helpers\n *\n * Re-exports template helper utilities from @frontmcp/ui.\n * Also provides individual helper functions for backwards compatibility.\n *\n * @see {@link https://docs.agentfront.dev/docs/servers/tools#tool-ui | Tool UI Documentation}\n */\n\nimport type { TemplateHelpers } from '../../common/metadata/tool-ui.metadata';\n// Import escapeHtml from @frontmcp/uipack/utils - single source of truth (no React needed)\nimport { escapeHtml } from '@frontmcp/uipack/utils';\n\n// Re-export createTemplateHelpers from @frontmcp/uipack (no React needed)\nexport { createTemplateHelpers } from '@frontmcp/uipack/runtime';\n\n// ============================================\n// Individual Helper Functions (Backwards Compatibility)\n// ============================================\n// These are exported individually for SDK consumers who import them directly.\n// For new code, prefer using createTemplateHelpers() instead.\n\n// Re-export escapeHtml for backwards compatibility\nexport { escapeHtml };\n\nlet idCounter = 0;\n\n/**\n * Format a date for display.\n * @param date - Date object or ISO string\n * @param format - Optional format: 'iso', 'time', 'datetime', or default (localized date)\n */\nexport function formatDate(date: Date | string, format?: string): string {\n const d = typeof date === 'string' ? new Date(date) : date;\n if (isNaN(d.getTime())) {\n return String(date);\n }\n\n switch (format) {\n case 'iso':\n return d.toISOString();\n case 'time':\n return d.toLocaleTimeString();\n case 'datetime':\n return d.toLocaleString();\n default:\n return d.toLocaleDateString();\n }\n}\n\n/**\n * Format a number as currency.\n * @param amount - The numeric amount\n * @param currency - ISO 4217 currency code (default: 'USD')\n */\nexport function formatCurrency(amount: number, currency = 'USD'): string {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n }).format(amount);\n}\n\n/**\n * Generate a unique ID for DOM elements.\n * @param prefix - Optional prefix for the ID\n */\nexport function uniqueId(prefix = 'mcp'): string {\n return `${prefix}-${++idCounter}-${Date.now().toString(36)}`;\n}\n\n/**\n * Safely embed JSON data in HTML.\n * Escapes characters that could break out of script tags or HTML.\n */\nexport function jsonEmbed(data: unknown): string {\n return JSON.stringify(data)\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/'/g, '\\\\u0027');\n}\n\n/**\n * Create a TemplateHelpers object with all helper functions.\n * @deprecated Use createTemplateHelpers from @frontmcp/uipack/runtime instead\n */\nexport function createTemplateHelpersLocal(): TemplateHelpers {\n return {\n escapeHtml,\n formatDate,\n formatCurrency,\n uniqueId,\n jsonEmbed,\n };\n}\n\n/**\n * Reset the ID counter (useful for testing).\n * @internal\n */\nexport function resetIdCounter(): void {\n idCounter = 0;\n}\n"]}
@@ -24,7 +24,7 @@
24
24
  */
25
25
  import type { ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';
26
26
  import type { AIPlatformType } from '../../notification/notification.service';
27
- import { type ToolUIRegistry } from '@frontmcp/ui/registry';
27
+ import { type ToolUIRegistry } from '@frontmcp/uipack/registry';
28
28
  /**
29
29
  * Result of handling a UI resource request
30
30
  */
@@ -26,16 +26,16 @@
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.handleUIResourceRead = handleUIResourceRead;
28
28
  exports.createUIResourceHandler = createUIResourceHandler;
29
- const ui_1 = require("@frontmcp/ui");
30
- const registry_1 = require("@frontmcp/ui/registry");
29
+ const base_template_1 = require("@frontmcp/uipack/base-template");
30
+ const registry_1 = require("@frontmcp/uipack/registry");
31
31
  /**
32
32
  * Generate a placeholder widget HTML that reads from window.openai.toolOutput.
33
33
  *
34
- * Delegates to @frontmcp/ui's createDefaultBaseTemplate which provides:
34
+ * Delegates to @frontmcp/uipack's createDefaultBaseTemplate which provides:
35
35
  * - Tailwind CSS with @theme configuration
36
36
  * - Platform polyfills (callTool, detectMcpSession, getToolOutput)
37
37
  * - Polling for toolOutput injection
38
- * - Default JSON renderer (data-type-specific renderers are in @frontmcp/ui)
38
+ * - Default JSON renderer (data-type-specific renderers are in @frontmcp/uipack)
39
39
  *
40
40
  * This is returned when the static widget URI is fetched before the tool is called.
41
41
  * OpenAI caches this HTML, so it must be dynamic (read toolOutput at runtime).
@@ -44,7 +44,7 @@ const registry_1 = require("@frontmcp/ui/registry");
44
44
  * @returns HTML string with a dynamic widget that renders toolOutput
45
45
  */
46
46
  function generatePlaceholderWidget(toolName) {
47
- return (0, ui_1.createDefaultBaseTemplate)({ toolName });
47
+ return (0, base_template_1.createDefaultBaseTemplate)({ toolName });
48
48
  }
49
49
  /**
50
50
  * Handle a UI resource read request
@@ -1 +1 @@
1
- {"version":3,"file":"ui-resource.handler.js","sourceRoot":"","sources":["../../../../src/tool/ui/ui-resource.handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAkEH,oDAgEC;AAkBD,0DAYC;AA5JD,qCAAyD;AACzD,oDAQ+B;AA0B/B;;;;;;;;;;;;;;GAcG;AACH,SAAS,yBAAyB,CAAC,QAAgB;IACjD,OAAO,IAAA,8BAAyB,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAClC,GAAW,EACX,QAAwB,EACxB,YAA6B;IAE7B,qCAAqC;IACrC,IAAI,CAAC,IAAA,0BAAe,EAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,yCAAyC;IACzC,MAAM,QAAQ,GAAG,IAAA,gCAAqB,EAAC,YAAY,CAAC,CAAC;IAErD,sDAAsD;IACtD,2CAA2C;IAC3C,MAAM,YAAY,GAAG,IAAA,yBAAc,EAAC,GAAG,CAAC,CAAC;IACzC,IAAI,YAAY,EAAE,CAAC;QACjB,qEAAqE;QACrE,qFAAqF;QACrF,MAAM,YAAY,GAAG,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACrE,IAAI,YAAY,EAAE,CAAC;YACjB,qEAAqE;YACrE,qEAAqE;YACrE,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE;oBACN,QAAQ,EAAE;wBACR;4BACE,GAAG;4BACH,QAAQ;4BACR,IAAI,EAAE,YAAY;yBACnB;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QAED,sEAAsE;QACtE,uEAAuE;QACvE,oCAAoC;QACpC,EAAE;QACF,uEAAuE;QACvE,kEAAkE;QAClE,MAAM,IAAI,GAAG,yBAAyB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE9D,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE;gBACN,QAAQ,EAAE;oBACR;wBACE,GAAG;wBACH,QAAQ;wBACR,IAAI,EAAE,IAAI;qBACX;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED,iCAAiC;IACjC,OAAO;QACL,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,mCAAmC,GAAG,yCAAyC;KACvF,CAAC;AACJ,CAAC;AAYD;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,OAAiC;IACvE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEtC,OAAO,SAAS,gBAAgB,CAAC,GAAW;QAC1C,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAEnD,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,IAAI,OAAO,EAAE,CAAC;YAC9C,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * UI Resource Handler\n *\n * Handles resources/read requests for ui:// URIs, serving widget HTML\n * from the ToolUIRegistry.\n *\n * Supported URI format:\n * - ui://widget/{toolName}.html - Static widget HTML (pre-compiled at startup)\n *\n * The static widget is registered at server startup for tools with\n * `servingMode: 'static'`. The widget HTML includes the FrontMCP Bridge\n * which reads tool output from the platform context at runtime.\n *\n * @example\n * ```typescript\n * // Client requests widget HTML (OpenAI discovery)\n * const result = await client.readResource({\n * uri: 'ui://widget/get_weather.html'\n * });\n *\n * // Returns pre-compiled widget with FrontMCP Bridge\n * // Widget reads tool output from window.openai.toolOutput at runtime\n * ```\n */\n\nimport type { ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';\nimport type { AIPlatformType } from '../../notification/notification.service';\nimport { createDefaultBaseTemplate } from '@frontmcp/ui';\nimport {\n type ToolUIRegistry,\n UI_RESOURCE_SCHEME,\n isUIResourceUri,\n isStaticWidgetUri,\n parseWidgetUri,\n getUIResourceMimeType,\n type ParsedWidgetUri,\n} from '@frontmcp/ui/registry';\n\n/**\n * Result of handling a UI resource request\n */\nexport interface UIResourceHandleResult {\n /** Whether the URI was handled */\n handled: boolean;\n /** The resource result if handled successfully */\n result?: ReadResourceResult;\n /** Error message if handling failed */\n error?: string;\n}\n\n/**\n * Options for handling a UI resource read request\n */\nexport interface HandleUIResourceOptions {\n /** The UI resource URI */\n uri: string;\n /** The ToolUIRegistry containing cached HTML */\n registry: ToolUIRegistry;\n /** Platform type of the connected client */\n platformType?: AIPlatformType;\n}\n\n/**\n * Generate a placeholder widget HTML that reads from window.openai.toolOutput.\n *\n * Delegates to @frontmcp/ui's createDefaultBaseTemplate which provides:\n * - Tailwind CSS with @theme configuration\n * - Platform polyfills (callTool, detectMcpSession, getToolOutput)\n * - Polling for toolOutput injection\n * - Default JSON renderer (data-type-specific renderers are in @frontmcp/ui)\n *\n * This is returned when the static widget URI is fetched before the tool is called.\n * OpenAI caches this HTML, so it must be dynamic (read toolOutput at runtime).\n *\n * @param toolName - The name of the tool\n * @returns HTML string with a dynamic widget that renders toolOutput\n */\nfunction generatePlaceholderWidget(toolName: string): string {\n return createDefaultBaseTemplate({ toolName });\n}\n\n/**\n * Handle a UI resource read request\n *\n * @param uri - The UI resource URI\n * @param registry - The ToolUIRegistry containing cached HTML\n * @param platformType - Optional platform type for dynamic MIME type selection\n * @returns Handle result with content or error\n */\nexport function handleUIResourceRead(\n uri: string,\n registry: ToolUIRegistry,\n platformType?: AIPlatformType,\n): UIResourceHandleResult {\n // Check if this is a UI resource URI\n if (!isUIResourceUri(uri)) {\n return { handled: false };\n }\n\n // Get the platform-appropriate MIME type\n const mimeType = getUIResourceMimeType(platformType);\n\n // Try static widget URI (ui://widget/{toolName}.html)\n // This is used by OpenAI at discovery time\n const widgetParsed = parseWidgetUri(uri);\n if (widgetParsed) {\n // Check for pre-compiled static widget from the developer's template\n // Static widgets are compiled at server startup for tools with servingMode: 'static'\n const cachedWidget = registry.getStaticWidget(widgetParsed.toolName);\n if (cachedWidget) {\n // Return the developer's actual template (SSR'd React/MDX component)\n // This template includes the FrontMCP Bridge for runtime data access\n return {\n handled: true,\n result: {\n contents: [\n {\n uri,\n mimeType,\n text: cachedWidget,\n },\n ],\n },\n };\n }\n\n // Fallback to dynamic placeholder widget if no pre-compiled template.\n // This is returned when the tool doesn't have a UI template configured\n // or uses a different serving mode.\n //\n // OpenAI caches widget HTML from outputTemplate URI, so we must return\n // a template that reads from window.openai.toolOutput at runtime.\n const html = generatePlaceholderWidget(widgetParsed.toolName);\n\n return {\n handled: true,\n result: {\n contents: [\n {\n uri,\n mimeType,\n text: html,\n },\n ],\n },\n };\n }\n\n // Unknown UI resource URI format\n return {\n handled: true,\n error: `Invalid UI resource URI format: ${uri}. Expected: ui://widget/{toolName}.html`,\n };\n}\n\n/**\n * Options for creating a UI resource handler\n */\nexport interface UIResourceHandlerOptions {\n /** ToolUIRegistry instance */\n registry: ToolUIRegistry;\n /** Optional custom error handler */\n onError?: (error: string, uri: string) => void;\n}\n\n/**\n * Create a UI resource handler function\n *\n * @param options - Handler options\n * @returns Handler function that can be used in the read-resource flow\n */\nexport function createUIResourceHandler(options: UIResourceHandlerOptions) {\n const { registry, onError } = options;\n\n return function handleUIResource(uri: string): UIResourceHandleResult {\n const result = handleUIResourceRead(uri, registry);\n\n if (result.handled && result.error && onError) {\n onError(result.error, uri);\n }\n\n return result;\n };\n}\n"]}
1
+ {"version":3,"file":"ui-resource.handler.js","sourceRoot":"","sources":["../../../../src/tool/ui/ui-resource.handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAkEH,oDAgEC;AAkBD,0DAYC;AA5JD,kEAA2E;AAC3E,wDAQmC;AA0BnC;;;;;;;;;;;;;;GAcG;AACH,SAAS,yBAAyB,CAAC,QAAgB;IACjD,OAAO,IAAA,yCAAyB,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAClC,GAAW,EACX,QAAwB,EACxB,YAA6B;IAE7B,qCAAqC;IACrC,IAAI,CAAC,IAAA,0BAAe,EAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,yCAAyC;IACzC,MAAM,QAAQ,GAAG,IAAA,gCAAqB,EAAC,YAAY,CAAC,CAAC;IAErD,sDAAsD;IACtD,2CAA2C;IAC3C,MAAM,YAAY,GAAG,IAAA,yBAAc,EAAC,GAAG,CAAC,CAAC;IACzC,IAAI,YAAY,EAAE,CAAC;QACjB,qEAAqE;QACrE,qFAAqF;QACrF,MAAM,YAAY,GAAG,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACrE,IAAI,YAAY,EAAE,CAAC;YACjB,qEAAqE;YACrE,qEAAqE;YACrE,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE;oBACN,QAAQ,EAAE;wBACR;4BACE,GAAG;4BACH,QAAQ;4BACR,IAAI,EAAE,YAAY;yBACnB;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QAED,sEAAsE;QACtE,uEAAuE;QACvE,oCAAoC;QACpC,EAAE;QACF,uEAAuE;QACvE,kEAAkE;QAClE,MAAM,IAAI,GAAG,yBAAyB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE9D,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE;gBACN,QAAQ,EAAE;oBACR;wBACE,GAAG;wBACH,QAAQ;wBACR,IAAI,EAAE,IAAI;qBACX;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED,iCAAiC;IACjC,OAAO;QACL,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,mCAAmC,GAAG,yCAAyC;KACvF,CAAC;AACJ,CAAC;AAYD;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,OAAiC;IACvE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEtC,OAAO,SAAS,gBAAgB,CAAC,GAAW;QAC1C,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAEnD,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,IAAI,OAAO,EAAE,CAAC;YAC9C,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * UI Resource Handler\n *\n * Handles resources/read requests for ui:// URIs, serving widget HTML\n * from the ToolUIRegistry.\n *\n * Supported URI format:\n * - ui://widget/{toolName}.html - Static widget HTML (pre-compiled at startup)\n *\n * The static widget is registered at server startup for tools with\n * `servingMode: 'static'`. The widget HTML includes the FrontMCP Bridge\n * which reads tool output from the platform context at runtime.\n *\n * @example\n * ```typescript\n * // Client requests widget HTML (OpenAI discovery)\n * const result = await client.readResource({\n * uri: 'ui://widget/get_weather.html'\n * });\n *\n * // Returns pre-compiled widget with FrontMCP Bridge\n * // Widget reads tool output from window.openai.toolOutput at runtime\n * ```\n */\n\nimport type { ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';\nimport type { AIPlatformType } from '../../notification/notification.service';\nimport { createDefaultBaseTemplate } from '@frontmcp/uipack/base-template';\nimport {\n type ToolUIRegistry,\n UI_RESOURCE_SCHEME,\n isUIResourceUri,\n isStaticWidgetUri,\n parseWidgetUri,\n getUIResourceMimeType,\n type ParsedWidgetUri,\n} from '@frontmcp/uipack/registry';\n\n/**\n * Result of handling a UI resource request\n */\nexport interface UIResourceHandleResult {\n /** Whether the URI was handled */\n handled: boolean;\n /** The resource result if handled successfully */\n result?: ReadResourceResult;\n /** Error message if handling failed */\n error?: string;\n}\n\n/**\n * Options for handling a UI resource read request\n */\nexport interface HandleUIResourceOptions {\n /** The UI resource URI */\n uri: string;\n /** The ToolUIRegistry containing cached HTML */\n registry: ToolUIRegistry;\n /** Platform type of the connected client */\n platformType?: AIPlatformType;\n}\n\n/**\n * Generate a placeholder widget HTML that reads from window.openai.toolOutput.\n *\n * Delegates to @frontmcp/uipack's createDefaultBaseTemplate which provides:\n * - Tailwind CSS with @theme configuration\n * - Platform polyfills (callTool, detectMcpSession, getToolOutput)\n * - Polling for toolOutput injection\n * - Default JSON renderer (data-type-specific renderers are in @frontmcp/uipack)\n *\n * This is returned when the static widget URI is fetched before the tool is called.\n * OpenAI caches this HTML, so it must be dynamic (read toolOutput at runtime).\n *\n * @param toolName - The name of the tool\n * @returns HTML string with a dynamic widget that renders toolOutput\n */\nfunction generatePlaceholderWidget(toolName: string): string {\n return createDefaultBaseTemplate({ toolName });\n}\n\n/**\n * Handle a UI resource read request\n *\n * @param uri - The UI resource URI\n * @param registry - The ToolUIRegistry containing cached HTML\n * @param platformType - Optional platform type for dynamic MIME type selection\n * @returns Handle result with content or error\n */\nexport function handleUIResourceRead(\n uri: string,\n registry: ToolUIRegistry,\n platformType?: AIPlatformType,\n): UIResourceHandleResult {\n // Check if this is a UI resource URI\n if (!isUIResourceUri(uri)) {\n return { handled: false };\n }\n\n // Get the platform-appropriate MIME type\n const mimeType = getUIResourceMimeType(platformType);\n\n // Try static widget URI (ui://widget/{toolName}.html)\n // This is used by OpenAI at discovery time\n const widgetParsed = parseWidgetUri(uri);\n if (widgetParsed) {\n // Check for pre-compiled static widget from the developer's template\n // Static widgets are compiled at server startup for tools with servingMode: 'static'\n const cachedWidget = registry.getStaticWidget(widgetParsed.toolName);\n if (cachedWidget) {\n // Return the developer's actual template (SSR'd React/MDX component)\n // This template includes the FrontMCP Bridge for runtime data access\n return {\n handled: true,\n result: {\n contents: [\n {\n uri,\n mimeType,\n text: cachedWidget,\n },\n ],\n },\n };\n }\n\n // Fallback to dynamic placeholder widget if no pre-compiled template.\n // This is returned when the tool doesn't have a UI template configured\n // or uses a different serving mode.\n //\n // OpenAI caches widget HTML from outputTemplate URI, so we must return\n // a template that reads from window.openai.toolOutput at runtime.\n const html = generatePlaceholderWidget(widgetParsed.toolName);\n\n return {\n handled: true,\n result: {\n contents: [\n {\n uri,\n mimeType,\n text: html,\n },\n ],\n },\n };\n }\n\n // Unknown UI resource URI format\n return {\n handled: true,\n error: `Invalid UI resource URI format: ${uri}. Expected: ui://widget/{toolName}.html`,\n };\n}\n\n/**\n * Options for creating a UI resource handler\n */\nexport interface UIResourceHandlerOptions {\n /** ToolUIRegistry instance */\n registry: ToolUIRegistry;\n /** Optional custom error handler */\n onError?: (error: string, uri: string) => void;\n}\n\n/**\n * Create a UI resource handler function\n *\n * @param options - Handler options\n * @returns Handler function that can be used in the read-resource flow\n */\nexport function createUIResourceHandler(options: UIResourceHandlerOptions) {\n const { registry, onError } = options;\n\n return function handleUIResource(uri: string): UIResourceHandleResult {\n const result = handleUIResourceRead(uri, registry);\n\n if (result.handled && result.error && onError) {\n onError(result.error, uri);\n }\n\n return result;\n };\n}\n"]}
@@ -4,15 +4,11 @@ export default function CompleteRequestHandler({ scope }: McpHandlerOptions): {
4
4
  requestSchema: import("zod").ZodObject<{
5
5
  method: import("zod").ZodLiteral<"completion/complete">;
6
6
  params: import("zod").ZodObject<{
7
- task: import("zod").ZodOptional<import("zod").ZodObject<{
8
- ttl: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodNull]>>;
9
- pollInterval: import("zod").ZodOptional<import("zod").ZodNumber>;
10
- }, import("zod/v4/core").$loose>>;
11
7
  _meta: import("zod").ZodOptional<import("zod").ZodObject<{
12
8
  progressToken: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>>;
13
9
  "io.modelcontextprotocol/related-task": import("zod").ZodOptional<import("zod").ZodObject<{
14
10
  taskId: import("zod").ZodString;
15
- }, import("zod/v4/core").$loose>>;
11
+ }, import("zod/v4/core").$strip>>;
16
12
  }, import("zod/v4/core").$loose>>;
17
13
  ref: import("zod").ZodUnion<readonly [import("zod").ZodObject<{
18
14
  type: import("zod").ZodLiteral<"ref/prompt">;
@@ -28,12 +24,11 @@ export default function CompleteRequestHandler({ scope }: McpHandlerOptions): {
28
24
  context: import("zod").ZodOptional<import("zod").ZodObject<{
29
25
  arguments: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
30
26
  }, import("zod/v4/core").$strip>>;
31
- }, import("zod/v4/core").$loose>;
27
+ }, import("zod/v4/core").$strip>;
32
28
  }, import("zod/v4/core").$strip>;
33
29
  handler: (request: CompleteRequest, ctx: import("./mcp-handlers.types").McpRequestHandler<{
34
30
  method: "completion/complete";
35
31
  params: {
36
- [x: string]: unknown;
37
32
  ref: {
38
33
  type: "ref/prompt";
39
34
  name: string;
@@ -45,16 +40,10 @@ export default function CompleteRequestHandler({ scope }: McpHandlerOptions): {
45
40
  name: string;
46
41
  value: string;
47
42
  };
48
- task?: {
49
- [x: string]: unknown;
50
- ttl?: number | null | undefined;
51
- pollInterval?: number | undefined;
52
- } | undefined;
53
43
  _meta?: {
54
44
  [x: string]: unknown;
55
45
  progressToken?: string | number | undefined;
56
46
  "io.modelcontextprotocol/related-task"?: {
57
- [x: string]: unknown;
58
47
  taskId: string;
59
48
  } | undefined;
60
49
  } | undefined;
@@ -70,8 +59,8 @@ export default function CompleteRequestHandler({ scope }: McpHandlerOptions): {
70
59
  [x: string]: unknown;
71
60
  _meta?: {
72
61
  [x: string]: unknown;
62
+ progressToken?: string | number | undefined;
73
63
  "io.modelcontextprotocol/related-task"?: {
74
- [x: string]: unknown;
75
64
  taskId: string;
76
65
  } | undefined;
77
66
  } | undefined;
@@ -86,8 +75,8 @@ export default function CompleteRequestHandler({ scope }: McpHandlerOptions): {
86
75
  };
87
76
  _meta?: {
88
77
  [x: string]: unknown;
78
+ progressToken?: string | number | undefined;
89
79
  "io.modelcontextprotocol/related-task"?: {
90
- [x: string]: unknown;
91
80
  taskId: string;
92
81
  } | undefined;
93
82
  } | undefined;
@@ -4,35 +4,24 @@ export default function GetPromptRequestHandler({ scope }: McpHandlerOptions): {
4
4
  requestSchema: import("zod").ZodObject<{
5
5
  method: import("zod").ZodLiteral<"prompts/get">;
6
6
  params: import("zod").ZodObject<{
7
- task: import("zod").ZodOptional<import("zod").ZodObject<{
8
- ttl: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodNull]>>;
9
- pollInterval: import("zod").ZodOptional<import("zod").ZodNumber>;
10
- }, import("zod/v4/core").$loose>>;
11
7
  _meta: import("zod").ZodOptional<import("zod").ZodObject<{
12
8
  progressToken: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>>;
13
9
  "io.modelcontextprotocol/related-task": import("zod").ZodOptional<import("zod").ZodObject<{
14
10
  taskId: import("zod").ZodString;
15
- }, import("zod/v4/core").$loose>>;
11
+ }, import("zod/v4/core").$strip>>;
16
12
  }, import("zod/v4/core").$loose>>;
17
13
  name: import("zod").ZodString;
18
14
  arguments: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
19
- }, import("zod/v4/core").$loose>;
15
+ }, import("zod/v4/core").$strip>;
20
16
  }, import("zod/v4/core").$strip>;
21
17
  handler: (request: GetPromptRequest, ctx: import("./mcp-handlers.types").McpRequestHandler<{
22
18
  method: "prompts/get";
23
19
  params: {
24
- [x: string]: unknown;
25
20
  name: string;
26
- task?: {
27
- [x: string]: unknown;
28
- ttl?: number | null | undefined;
29
- pollInterval?: number | undefined;
30
- } | undefined;
31
21
  _meta?: {
32
22
  [x: string]: unknown;
33
23
  progressToken?: string | number | undefined;
34
24
  "io.modelcontextprotocol/related-task"?: {
35
- [x: string]: unknown;
36
25
  taskId: string;
37
26
  } | undefined;
38
27
  } | undefined;
@@ -46,8 +35,8 @@ export default function GetPromptRequestHandler({ scope }: McpHandlerOptions): {
46
35
  [x: string]: unknown;
47
36
  _meta?: {
48
37
  [x: string]: unknown;
38
+ progressToken?: string | number | undefined;
49
39
  "io.modelcontextprotocol/related-task"?: {
50
- [x: string]: unknown;
51
40
  taskId: string;
52
41
  } | undefined;
53
42
  } | undefined;
@@ -103,6 +92,7 @@ export default function GetPromptRequestHandler({ scope }: McpHandlerOptions): {
103
92
  src: string;
104
93
  mimeType?: string | undefined;
105
94
  sizes?: string[] | undefined;
95
+ theme?: "light" | "dark" | undefined;
106
96
  }[] | undefined;
107
97
  title?: string | undefined;
108
98
  } | {
@@ -128,8 +118,8 @@ export default function GetPromptRequestHandler({ scope }: McpHandlerOptions): {
128
118
  }[];
129
119
  _meta?: {
130
120
  [x: string]: unknown;
121
+ progressToken?: string | number | undefined;
131
122
  "io.modelcontextprotocol/related-task"?: {
132
- [x: string]: unknown;
133
123
  taskId: string;
134
124
  } | undefined;
135
125
  } | undefined;