@seed-ship/mcp-ui-solid 1.1.0 → 1.2.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 (57) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +94 -3
  3. package/dist/components/FooterRenderer.cjs +75 -0
  4. package/dist/components/FooterRenderer.cjs.map +1 -0
  5. package/dist/components/FooterRenderer.js +75 -0
  6. package/dist/components/FooterRenderer.js.map +1 -0
  7. package/dist/components/GridRenderer.cjs +82 -0
  8. package/dist/components/GridRenderer.cjs.map +1 -0
  9. package/dist/components/GridRenderer.d.ts +49 -0
  10. package/dist/components/GridRenderer.d.ts.map +1 -0
  11. package/dist/components/GridRenderer.js +82 -0
  12. package/dist/components/GridRenderer.js.map +1 -0
  13. package/dist/components/UIResourceRenderer.cjs +88 -36
  14. package/dist/components/UIResourceRenderer.cjs.map +1 -1
  15. package/dist/components/UIResourceRenderer.d.ts.map +1 -1
  16. package/dist/components/UIResourceRenderer.js +90 -38
  17. package/dist/components/UIResourceRenderer.js.map +1 -1
  18. package/dist/context/MCPActionContext.cjs +149 -0
  19. package/dist/context/MCPActionContext.cjs.map +1 -0
  20. package/dist/context/MCPActionContext.d.ts +158 -0
  21. package/dist/context/MCPActionContext.d.ts.map +1 -0
  22. package/dist/context/MCPActionContext.js +149 -0
  23. package/dist/context/MCPActionContext.js.map +1 -0
  24. package/dist/context/index.d.ts +8 -0
  25. package/dist/context/index.d.ts.map +1 -0
  26. package/dist/hooks/index.d.ts +2 -0
  27. package/dist/hooks/index.d.ts.map +1 -1
  28. package/dist/hooks/useAction.cjs +49 -0
  29. package/dist/hooks/useAction.cjs.map +1 -0
  30. package/dist/hooks/useAction.d.ts +79 -0
  31. package/dist/hooks/useAction.d.ts.map +1 -0
  32. package/dist/hooks/useAction.js +49 -0
  33. package/dist/hooks/useAction.js.map +1 -0
  34. package/dist/hooks.cjs +3 -0
  35. package/dist/hooks.cjs.map +1 -1
  36. package/dist/hooks.d.ts +2 -0
  37. package/dist/hooks.js +4 -1
  38. package/dist/hooks.js.map +1 -1
  39. package/dist/index.cjs +8 -0
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.ts +5 -3
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +8 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/types/index.d.ts +41 -2
  46. package/dist/types/index.d.ts.map +1 -1
  47. package/dist/types.d.ts +41 -2
  48. package/package.json +1 -1
  49. package/src/components/GridRenderer.tsx +140 -0
  50. package/src/components/UIResourceRenderer.tsx +65 -25
  51. package/src/context/MCPActionContext.tsx +350 -0
  52. package/src/context/index.ts +19 -0
  53. package/src/hooks/index.ts +4 -0
  54. package/src/hooks/useAction.ts +138 -0
  55. package/src/index.ts +14 -1
  56. package/src/types/index.ts +48 -1
  57. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,79 @@
1
+ /**
2
+ * useAction - Hook for executing MCP actions from components
3
+ * Phase 5.0: Quick Wins - Simplified API for ActionRenderer and custom components
4
+ */
5
+ import { Accessor } from 'solid-js';
6
+ import { ActionRequest, ActionResult } from '../context/MCPActionContext';
7
+ /**
8
+ * Return type for useAction hook
9
+ */
10
+ export interface UseActionReturn {
11
+ /**
12
+ * Execute a tool action
13
+ */
14
+ execute: (toolName: string, params?: Record<string, any>) => Promise<ActionResult>;
15
+ /**
16
+ * Full execute with ActionRequest
17
+ */
18
+ executeAction: (request: ActionRequest) => Promise<ActionResult>;
19
+ /**
20
+ * Whether an action is currently executing
21
+ */
22
+ isExecuting: Accessor<boolean>;
23
+ /**
24
+ * Last result from action execution
25
+ */
26
+ lastResult: Accessor<ActionResult | undefined>;
27
+ /**
28
+ * Last error (if any)
29
+ */
30
+ lastError: Accessor<string | undefined>;
31
+ }
32
+ /**
33
+ * Hook for executing MCP actions
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * function MyButton() {
38
+ * const { execute, isExecuting, lastError } = useAction()
39
+ *
40
+ * const handleClick = async () => {
41
+ * const result = await execute('search.hub', { query: 'test' })
42
+ * if (result.success) {
43
+ * console.log('Data:', result.data)
44
+ * }
45
+ * }
46
+ *
47
+ * return (
48
+ * <button onClick={handleClick} disabled={isExecuting()}>
49
+ * {isExecuting() ? 'Loading...' : 'Search'}
50
+ * </button>
51
+ * )
52
+ * }
53
+ * ```
54
+ */
55
+ export declare function useAction(): UseActionReturn;
56
+ /**
57
+ * Hook for binding action to a specific tool
58
+ *
59
+ * @example
60
+ * ```tsx
61
+ * function SearchButton() {
62
+ * const { execute, isExecuting } = useToolAction('search.hub')
63
+ *
64
+ * return (
65
+ * <button onClick={() => execute({ query: 'test' })} disabled={isExecuting()}>
66
+ * Search
67
+ * </button>
68
+ * )
69
+ * }
70
+ * ```
71
+ */
72
+ export declare function useToolAction(toolName: string): {
73
+ execute: (params?: Record<string, any>) => Promise<ActionResult>;
74
+ isExecuting: Accessor<boolean>;
75
+ lastResult: Accessor<ActionResult | undefined>;
76
+ lastError: Accessor<string | undefined>;
77
+ };
78
+ export type { ActionRequest, ActionResult };
79
+ //# sourceMappingURL=useAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAction.d.ts","sourceRoot":"","sources":["../../src/hooks/useAction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,QAAQ,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAoB,aAAa,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE3F;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;IAElF;;OAEG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;IAEhE;;OAEG;IACH,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAE9B;;OAEG;IACH,UAAU,EAAE,QAAQ,CAAC,YAAY,GAAG,SAAS,CAAC,CAAA;IAE9C;;OAEG;IACH,SAAS,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,IAAI,eAAe,CAsC3C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG;IAC/C,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;IAChE,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC9B,UAAU,EAAE,QAAQ,CAAC,YAAY,GAAG,SAAS,CAAC,CAAA;IAC9C,SAAS,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CACxC,CAaA;AAED,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,CAAA"}
@@ -0,0 +1,49 @@
1
+ import { createSignal } from "solid-js";
2
+ import { useMCPActionSafe } from "../context/MCPActionContext.js";
3
+ function useAction() {
4
+ const context = useMCPActionSafe();
5
+ const [lastError, setLastError] = createSignal();
6
+ const execute = async (toolName, params) => {
7
+ setLastError(void 0);
8
+ const result = await context.executeAction({
9
+ toolName,
10
+ params
11
+ });
12
+ if (!result.success && result.error) {
13
+ setLastError(result.error);
14
+ }
15
+ return result;
16
+ };
17
+ const executeAction = async (request) => {
18
+ setLastError(void 0);
19
+ const result = await context.executeAction(request);
20
+ if (!result.success && result.error) {
21
+ setLastError(result.error);
22
+ }
23
+ return result;
24
+ };
25
+ return {
26
+ execute,
27
+ executeAction,
28
+ isExecuting: context.isExecuting,
29
+ lastResult: context.lastResult,
30
+ lastError
31
+ };
32
+ }
33
+ function useToolAction(toolName) {
34
+ const { execute: baseExecute, isExecuting, lastResult, lastError } = useAction();
35
+ const execute = async (params) => {
36
+ return baseExecute(toolName, params);
37
+ };
38
+ return {
39
+ execute,
40
+ isExecuting,
41
+ lastResult,
42
+ lastError
43
+ };
44
+ }
45
+ export {
46
+ useAction,
47
+ useToolAction
48
+ };
49
+ //# sourceMappingURL=useAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAction.js","sources":["../../src/hooks/useAction.ts"],"sourcesContent":["/**\n * useAction - Hook for executing MCP actions from components\n * Phase 5.0: Quick Wins - Simplified API for ActionRenderer and custom components\n */\n\nimport { createSignal, Accessor } from 'solid-js'\nimport { useMCPActionSafe, ActionRequest, ActionResult } from '../context/MCPActionContext'\n\n/**\n * Return type for useAction hook\n */\nexport interface UseActionReturn {\n /**\n * Execute a tool action\n */\n execute: (toolName: string, params?: Record<string, any>) => Promise<ActionResult>\n\n /**\n * Full execute with ActionRequest\n */\n executeAction: (request: ActionRequest) => Promise<ActionResult>\n\n /**\n * Whether an action is currently executing\n */\n isExecuting: Accessor<boolean>\n\n /**\n * Last result from action execution\n */\n lastResult: Accessor<ActionResult | undefined>\n\n /**\n * Last error (if any)\n */\n lastError: Accessor<string | undefined>\n}\n\n/**\n * Hook for executing MCP actions\n *\n * @example\n * ```tsx\n * function MyButton() {\n * const { execute, isExecuting, lastError } = useAction()\n *\n * const handleClick = async () => {\n * const result = await execute('search.hub', { query: 'test' })\n * if (result.success) {\n * console.log('Data:', result.data)\n * }\n * }\n *\n * return (\n * <button onClick={handleClick} disabled={isExecuting()}>\n * {isExecuting() ? 'Loading...' : 'Search'}\n * </button>\n * )\n * }\n * ```\n */\nexport function useAction(): UseActionReturn {\n const context = useMCPActionSafe()\n const [lastError, setLastError] = createSignal<string>()\n\n const execute = async (toolName: string, params?: Record<string, any>): Promise<ActionResult> => {\n setLastError(undefined)\n\n const result = await context.executeAction({\n toolName,\n params,\n })\n\n if (!result.success && result.error) {\n setLastError(result.error)\n }\n\n return result\n }\n\n const executeAction = async (request: ActionRequest): Promise<ActionResult> => {\n setLastError(undefined)\n\n const result = await context.executeAction(request)\n\n if (!result.success && result.error) {\n setLastError(result.error)\n }\n\n return result\n }\n\n return {\n execute,\n executeAction,\n isExecuting: context.isExecuting,\n lastResult: context.lastResult,\n lastError,\n }\n}\n\n/**\n * Hook for binding action to a specific tool\n *\n * @example\n * ```tsx\n * function SearchButton() {\n * const { execute, isExecuting } = useToolAction('search.hub')\n *\n * return (\n * <button onClick={() => execute({ query: 'test' })} disabled={isExecuting()}>\n * Search\n * </button>\n * )\n * }\n * ```\n */\nexport function useToolAction(toolName: string): {\n execute: (params?: Record<string, any>) => Promise<ActionResult>\n isExecuting: Accessor<boolean>\n lastResult: Accessor<ActionResult | undefined>\n lastError: Accessor<string | undefined>\n} {\n const { execute: baseExecute, isExecuting, lastResult, lastError } = useAction()\n\n const execute = async (params?: Record<string, any>): Promise<ActionResult> => {\n return baseExecute(toolName, params)\n }\n\n return {\n execute,\n isExecuting,\n lastResult,\n lastError,\n }\n}\n\nexport type { ActionRequest, ActionResult }\n"],"names":[],"mappings":";;AA6DO,SAAS,YAA6B;AAC3C,QAAM,UAAU,iBAAA;AAChB,QAAM,CAAC,WAAW,YAAY,IAAI,aAAA;AAElC,QAAM,UAAU,OAAO,UAAkB,WAAwD;AAC/F,iBAAa,MAAS;AAEtB,UAAM,SAAS,MAAM,QAAQ,cAAc;AAAA,MACzC;AAAA,MACA;AAAA,IAAA,CACD;AAED,QAAI,CAAC,OAAO,WAAW,OAAO,OAAO;AACnC,mBAAa,OAAO,KAAK;AAAA,IAC3B;AAEA,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,OAAO,YAAkD;AAC7E,iBAAa,MAAS;AAEtB,UAAM,SAAS,MAAM,QAAQ,cAAc,OAAO;AAElD,QAAI,CAAC,OAAO,WAAW,OAAO,OAAO;AACnC,mBAAa,OAAO,KAAK;AAAA,IAC3B;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,aAAa,QAAQ;AAAA,IACrB,YAAY,QAAQ;AAAA,IACpB;AAAA,EAAA;AAEJ;AAkBO,SAAS,cAAc,UAK5B;AACA,QAAM,EAAE,SAAS,aAAa,aAAa,YAAY,UAAA,IAAc,UAAA;AAErE,QAAM,UAAU,OAAO,WAAwD;AAC7E,WAAO,YAAY,UAAU,MAAM;AAAA,EACrC;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
package/dist/hooks.cjs CHANGED
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const useStreamingUI = require("./hooks/useStreamingUI.cjs");
4
+ const useAction = require("./hooks/useAction.cjs");
4
5
  exports.useStreamingUI = useStreamingUI.useStreamingUI;
6
+ exports.useAction = useAction.useAction;
7
+ exports.useToolAction = useAction.useToolAction;
5
8
  //# sourceMappingURL=hooks.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"hooks.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
package/dist/hooks.d.ts CHANGED
@@ -5,4 +5,6 @@
5
5
  */
6
6
  export { useStreamingUI } from './useStreamingUI';
7
7
  export type { UseStreamingUIOptions, StreamingUIState, StreamProgress, StreamError, CompleteMetadata, } from './useStreamingUI';
8
+ export { useAction, useToolAction } from './useAction';
9
+ export type { UseActionReturn, ActionRequest, ActionResult } from './useAction';
8
10
  //# sourceMappingURL=index.d.ts.map
package/dist/hooks.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import { useStreamingUI } from "./hooks/useStreamingUI.js";
2
+ import { useAction, useToolAction } from "./hooks/useAction.js";
2
3
  export {
3
- useStreamingUI
4
+ useAction,
5
+ useStreamingUI,
6
+ useToolAction
4
7
  };
5
8
  //# sourceMappingURL=hooks.js.map
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
package/dist/index.cjs CHANGED
@@ -4,12 +4,20 @@ const UIResourceRenderer = require("./components/UIResourceRenderer.cjs");
4
4
  const StreamingUIRenderer = require("./components/StreamingUIRenderer.cjs");
5
5
  const GenerativeUIErrorBoundary = require("./components/GenerativeUIErrorBoundary.cjs");
6
6
  const useStreamingUI = require("./hooks/useStreamingUI.cjs");
7
+ const useAction = require("./hooks/useAction.cjs");
8
+ const MCPActionContext = require("./context/MCPActionContext.cjs");
7
9
  const validation = require("./services/validation.cjs");
8
10
  const componentRegistry = require("./services/component-registry.cjs");
9
11
  exports.UIResourceRenderer = UIResourceRenderer.UIResourceRenderer;
10
12
  exports.StreamingUIRenderer = StreamingUIRenderer.StreamingUIRenderer;
11
13
  exports.GenerativeUIErrorBoundary = GenerativeUIErrorBoundary.GenerativeUIErrorBoundary;
12
14
  exports.useStreamingUI = useStreamingUI.useStreamingUI;
15
+ exports.useAction = useAction.useAction;
16
+ exports.useToolAction = useAction.useToolAction;
17
+ exports.MCPActionContext = MCPActionContext.MCPActionContext;
18
+ exports.MCPActionProvider = MCPActionContext.MCPActionProvider;
19
+ exports.useMCPAction = MCPActionContext.useMCPAction;
20
+ exports.useMCPActionSafe = MCPActionContext.useMCPActionSafe;
13
21
  exports.DEFAULT_RESOURCE_LIMITS = validation.DEFAULT_RESOURCE_LIMITS;
14
22
  exports.validateComponent = validation.validateComponent;
15
23
  exports.validateLayout = validation.validateLayout;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -29,8 +29,10 @@
29
29
  */
30
30
  export { UIResourceRenderer, StreamingUIRenderer, GenerativeUIErrorBoundary } from './components';
31
31
  export type { UIResourceRendererProps, StreamingUIRendererProps, GenerativeUIErrorBoundaryProps, } from './components';
32
- export { useStreamingUI } from './hooks';
33
- export type { UseStreamingUIOptions, StreamingUIState, StreamProgress, StreamError, CompleteMetadata, } from './hooks';
34
- export type { UIComponent, UILayout, GridPosition, ComponentType, RendererError, ChartComponentParams, TableComponentParams, MetricComponentParams, TextComponentParams, } from './types';
32
+ export { useStreamingUI, useAction, useToolAction } from './hooks';
33
+ export type { UseStreamingUIOptions, StreamingUIState, StreamProgress, StreamError, CompleteMetadata, UseActionReturn, } from './hooks';
34
+ export { MCPActionProvider, MCPActionContext, useMCPAction, useMCPActionSafe } from './context';
35
+ export type { MCPActionContextValue, MCPActionProviderProps, ActionRequest, ActionResult, } from './context';
36
+ export type { UIComponent, UILayout, GridPosition, ComponentType, RendererError, ChartComponentParams, TableComponentParams, MetricComponentParams, TextComponentParams, ActionComponentParams, GridComponentParams, } from './types';
35
37
  export { validateComponent, validateLayout, DEFAULT_RESOURCE_LIMITS, ComponentRegistry, } from './services';
36
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAEjG,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC,YAAY,EACV,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,gBAAgB,GACjB,MAAM,SAAS,CAAA;AAGhB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAEjG,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAElE,YAAY,EACV,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE/F,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,YAAY,GACb,MAAM,WAAW,CAAA;AAGlB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -2,15 +2,23 @@ import { UIResourceRenderer } from "./components/UIResourceRenderer.js";
2
2
  import { StreamingUIRenderer } from "./components/StreamingUIRenderer.js";
3
3
  import { GenerativeUIErrorBoundary } from "./components/GenerativeUIErrorBoundary.js";
4
4
  import { useStreamingUI } from "./hooks/useStreamingUI.js";
5
+ import { useAction, useToolAction } from "./hooks/useAction.js";
6
+ import { MCPActionContext, MCPActionProvider, useMCPAction, useMCPActionSafe } from "./context/MCPActionContext.js";
5
7
  import { DEFAULT_RESOURCE_LIMITS, validateComponent, validateLayout } from "./services/validation.js";
6
8
  import { ComponentRegistry } from "./services/component-registry.js";
7
9
  export {
8
10
  ComponentRegistry,
9
11
  DEFAULT_RESOURCE_LIMITS,
10
12
  GenerativeUIErrorBoundary,
13
+ MCPActionContext,
14
+ MCPActionProvider,
11
15
  StreamingUIRenderer,
12
16
  UIResourceRenderer,
17
+ useAction,
18
+ useMCPAction,
19
+ useMCPActionSafe,
13
20
  useStreamingUI,
21
+ useToolAction,
14
22
  validateComponent,
15
23
  validateLayout
16
24
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -7,7 +7,7 @@
7
7
  /**
8
8
  * Component types supported by the renderer
9
9
  */
10
- export type ComponentType = 'chart' | 'table' | 'metric' | 'text' | 'grid' | 'iframe' | 'image' | 'link' | 'action';
10
+ export type ComponentType = 'chart' | 'table' | 'metric' | 'text' | 'grid' | 'iframe' | 'image' | 'link' | 'action' | 'footer' | 'carousel' | 'artifact';
11
11
  /**
12
12
  * Chart types (powered by Quickchart)
13
13
  */
@@ -133,6 +133,33 @@ export interface ActionComponentParams {
133
133
  icon?: string;
134
134
  disabled?: boolean;
135
135
  }
136
+ /**
137
+ * Grid component parameters (Phase 5.0)
138
+ * Enables nested CSS Grid layouts for template builder
139
+ */
140
+ export interface GridComponentParams {
141
+ /**
142
+ * Number of columns (default: 12)
143
+ */
144
+ columns?: number;
145
+ /**
146
+ * Gap between grid items (default: '1rem')
147
+ */
148
+ gap?: string;
149
+ /**
150
+ * Minimum row height (optional)
151
+ */
152
+ minRowHeight?: string;
153
+ /**
154
+ * CSS Grid template areas for named regions
155
+ * Example: [['header', 'header'], ['sidebar', 'main'], ['footer', 'footer']]
156
+ */
157
+ areas?: string[][];
158
+ /**
159
+ * Child components to render within the grid
160
+ */
161
+ children: UIComponent[];
162
+ }
136
163
  /**
137
164
  * UI Component definition (generated by LLM)
138
165
  */
@@ -152,7 +179,7 @@ export interface UIComponent {
152
179
  /**
153
180
  * Component parameters (type-specific)
154
181
  */
155
- params: ChartComponentParams | TableComponentParams | MetricComponentParams | TextComponentParams | ActionComponentParams;
182
+ params: ChartComponentParams | TableComponentParams | MetricComponentParams | TextComponentParams | ActionComponentParams | GridComponentParams;
156
183
  /**
157
184
  * Metadata for observability
158
185
  */
@@ -191,6 +218,18 @@ export interface UILayout {
191
218
  generatedAt: string;
192
219
  llmModel?: string;
193
220
  totalComponents: number;
221
+ /**
222
+ * Execution time in milliseconds (Phase 5.0)
223
+ */
224
+ executionTime?: number;
225
+ /**
226
+ * Number of sources used (Phase 5.0)
227
+ */
228
+ sourceCount?: number;
229
+ /**
230
+ * Hide auto-injected footer (Phase 5.0)
231
+ */
232
+ hideFooter?: boolean;
194
233
  };
195
234
  }
196
235
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,OAAO,GACP,QAAQ,GACR,MAAM,GACN,MAAM,GACN,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,CAAA;AAEZ;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAA;AAEjF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ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O,GACP,UAAU,CAAA;AAEd;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,eAAe,CAAA;IACtB,IAAI,EAAE,GAAG,CAAA;IACT,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB"}
package/dist/types.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  /**
8
8
  * Component types supported by the renderer
9
9
  */
10
- export type ComponentType = 'chart' | 'table' | 'metric' | 'text' | 'grid' | 'iframe' | 'image' | 'link' | 'action';
10
+ export type ComponentType = 'chart' | 'table' | 'metric' | 'text' | 'grid' | 'iframe' | 'image' | 'link' | 'action' | 'footer' | 'carousel' | 'artifact';
11
11
  /**
12
12
  * Chart types (powered by Quickchart)
13
13
  */
@@ -133,6 +133,33 @@ export interface ActionComponentParams {
133
133
  icon?: string;
134
134
  disabled?: boolean;
135
135
  }
136
+ /**
137
+ * Grid component parameters (Phase 5.0)
138
+ * Enables nested CSS Grid layouts for template builder
139
+ */
140
+ export interface GridComponentParams {
141
+ /**
142
+ * Number of columns (default: 12)
143
+ */
144
+ columns?: number;
145
+ /**
146
+ * Gap between grid items (default: '1rem')
147
+ */
148
+ gap?: string;
149
+ /**
150
+ * Minimum row height (optional)
151
+ */
152
+ minRowHeight?: string;
153
+ /**
154
+ * CSS Grid template areas for named regions
155
+ * Example: [['header', 'header'], ['sidebar', 'main'], ['footer', 'footer']]
156
+ */
157
+ areas?: string[][];
158
+ /**
159
+ * Child components to render within the grid
160
+ */
161
+ children: UIComponent[];
162
+ }
136
163
  /**
137
164
  * UI Component definition (generated by LLM)
138
165
  */
@@ -152,7 +179,7 @@ export interface UIComponent {
152
179
  /**
153
180
  * Component parameters (type-specific)
154
181
  */
155
- params: ChartComponentParams | TableComponentParams | MetricComponentParams | TextComponentParams | ActionComponentParams;
182
+ params: ChartComponentParams | TableComponentParams | MetricComponentParams | TextComponentParams | ActionComponentParams | GridComponentParams;
156
183
  /**
157
184
  * Metadata for observability
158
185
  */
@@ -191,6 +218,18 @@ export interface UILayout {
191
218
  generatedAt: string;
192
219
  llmModel?: string;
193
220
  totalComponents: number;
221
+ /**
222
+ * Execution time in milliseconds (Phase 5.0)
223
+ */
224
+ executionTime?: number;
225
+ /**
226
+ * Number of sources used (Phase 5.0)
227
+ */
228
+ sourceCount?: number;
229
+ /**
230
+ * Hide auto-injected footer (Phase 5.0)
231
+ */
232
+ hideFooter?: boolean;
194
233
  };
195
234
  }
196
235
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-ship/mcp-ui-solid",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "SolidJS components for rendering MCP-generated UI resources",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -0,0 +1,140 @@
1
+ /**
2
+ * GridRenderer - CSS Grid layout component for nested layouts
3
+ * Phase 5.0: Quick Wins - Enables template builder layouts
4
+ */
5
+
6
+ import { Component, For, createMemo } from 'solid-js'
7
+ import type { UIComponent, GridPosition } from '../types'
8
+ import { UIResourceRenderer } from './UIResourceRenderer'
9
+
10
+ /**
11
+ * Parameters for GridRenderer component
12
+ */
13
+ export interface GridComponentParams {
14
+ /**
15
+ * Number of columns (default: 12)
16
+ */
17
+ columns?: number
18
+
19
+ /**
20
+ * Gap between grid items (default: '1rem')
21
+ */
22
+ gap?: string
23
+
24
+ /**
25
+ * Minimum row height (optional)
26
+ */
27
+ minRowHeight?: string
28
+
29
+ /**
30
+ * CSS Grid template areas for named regions
31
+ * Example: [['header', 'header'], ['sidebar', 'main'], ['footer', 'footer']]
32
+ */
33
+ areas?: string[][]
34
+
35
+ /**
36
+ * Child components to render within the grid
37
+ */
38
+ children: UIComponent[]
39
+ }
40
+
41
+ export interface GridRendererProps {
42
+ /**
43
+ * Grid component with params
44
+ */
45
+ component: UIComponent
46
+
47
+ /**
48
+ * Error callback
49
+ */
50
+ onError?: (error: any) => void
51
+ }
52
+
53
+ /**
54
+ * Convert grid position to CSS style string
55
+ */
56
+ function getGridItemStyle(position: GridPosition | undefined, areas?: string[][]): string {
57
+ // Default to full width if no position specified
58
+ if (!position) {
59
+ return 'grid-column: 1 / -1; grid-row: auto'
60
+ }
61
+
62
+ const { colStart, colSpan, rowStart, rowSpan = 1 } = position
63
+
64
+ // If using named areas and component has area name, use grid-area
65
+ // Otherwise use explicit grid-column/grid-row
66
+ let style = `grid-column: ${colStart} / span ${colSpan}`
67
+
68
+ if (rowStart) {
69
+ style += `; grid-row: ${rowStart} / span ${rowSpan}`
70
+ } else {
71
+ style += '; grid-row: auto'
72
+ }
73
+
74
+ return style
75
+ }
76
+
77
+ /**
78
+ * Build CSS grid-template-areas string from areas array
79
+ */
80
+ function buildGridTemplateAreas(areas: string[][]): string {
81
+ return areas.map((row) => `"${row.join(' ')}"`).join(' ')
82
+ }
83
+
84
+ /**
85
+ * GridRenderer Component
86
+ * Renders a CSS Grid container with nested UIComponents
87
+ */
88
+ export const GridRenderer: Component<GridRendererProps> = (props) => {
89
+ // Extract params with defaults
90
+ const params = createMemo(() => {
91
+ const p = props.component.params as GridComponentParams
92
+ return {
93
+ columns: p.columns ?? 12,
94
+ gap: p.gap ?? '1rem',
95
+ minRowHeight: p.minRowHeight,
96
+ areas: p.areas,
97
+ children: p.children ?? [],
98
+ }
99
+ })
100
+
101
+ // Build grid container style
102
+ const gridContainerStyle = createMemo(() => {
103
+ const p = params()
104
+ let style = `display: grid; grid-template-columns: repeat(${p.columns}, 1fr); gap: ${p.gap}`
105
+
106
+ if (p.minRowHeight) {
107
+ style += `; grid-auto-rows: minmax(${p.minRowHeight}, auto)`
108
+ }
109
+
110
+ if (p.areas && p.areas.length > 0) {
111
+ style += `; grid-template-areas: ${buildGridTemplateAreas(p.areas)}`
112
+ }
113
+
114
+ return style
115
+ })
116
+
117
+ return (
118
+ <div
119
+ class="w-full h-full bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden"
120
+ data-component-type="grid"
121
+ data-component-id={props.component.id}
122
+ >
123
+ <div class="p-4 h-full" style={gridContainerStyle()}>
124
+ <For each={params().children}>
125
+ {(child) => (
126
+ <div
127
+ style={getGridItemStyle(child.position, params().areas)}
128
+ class="min-w-0 h-full"
129
+ >
130
+ {/* Use UIResourceRenderer for recursive rendering */}
131
+ <UIResourceRenderer content={child} onError={props.onError} />
132
+ </div>
133
+ )}
134
+ </For>
135
+ </div>
136
+ </div>
137
+ )
138
+ }
139
+
140
+ export default GridRenderer