@nuwax-ai/openui-mcp 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -1
- package/dist/server/contracts.d.ts +13 -0
- package/dist/server/contracts.d.ts.map +1 -1
- package/dist/server/contracts.js +22 -4
- package/dist/server/contracts.js.map +1 -1
- package/dist/server/http.js +0 -0
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +71 -4
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/openui-reference.d.ts +4 -0
- package/dist/server/openui-reference.d.ts.map +1 -0
- package/dist/server/openui-reference.js +14 -0
- package/dist/server/openui-reference.js.map +1 -0
- package/dist/server/stdio.js +0 -0
- package/package.json +19 -17
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ one process and one sidecar port:
|
|
|
91
91
|
"mcpServers": {
|
|
92
92
|
"nuwax-openui": {
|
|
93
93
|
"command": "npx",
|
|
94
|
-
"args": ["-y", "@nuwax-ai/openui-mcp@0.1.
|
|
94
|
+
"args": ["-y", "@nuwax-ai/openui-mcp@0.1.3"],
|
|
95
95
|
"env": {
|
|
96
96
|
"NUWAX_OPENUI_HOST": "127.0.0.1",
|
|
97
97
|
"NUWAX_OPENUI_PORT": "8787",
|
|
@@ -161,6 +161,38 @@ schemaVersion = nuwax.openui/v1
|
|
|
161
161
|
|
|
162
162
|
Do not infer UI from arbitrary MCP tool results.
|
|
163
163
|
|
|
164
|
+
## Agent authoring guidance
|
|
165
|
+
|
|
166
|
+
The server publishes the DSL contract through multiple MCP capabilities so an
|
|
167
|
+
Agent does not need to guess syntax or inspect installed package files:
|
|
168
|
+
|
|
169
|
+
| Capability | Name / URI | Purpose |
|
|
170
|
+
| ---------- | ------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
171
|
+
| Tool | `nuwax_get_openui_reference` | Returns authoritative syntax, component signatures, actions, bindings, and examples |
|
|
172
|
+
| Prompt | `nuwax_openui_authoring` | Starts an authoring flow with a `basic`, `dashboard`, `form`, or `all` focus |
|
|
173
|
+
| Resource | `nuwax://openui/schema/v0.5` | Complete JSON Schema generated from the renderer's current component library |
|
|
174
|
+
| Resource | `nuwax://openui/authoring-guide/v0.5` | Complete generated OpenUI Lang authoring guide |
|
|
175
|
+
|
|
176
|
+
`nuwax_render_openui` also includes trigger guidance and a minimal valid example
|
|
177
|
+
in its tool description and input schema. Agents should use it when the user
|
|
178
|
+
asks for a visual card, dashboard, chart, table, report, form, status panel, or
|
|
179
|
+
other structured interface even if the user does not explicitly mention
|
|
180
|
+
OpenUI.
|
|
181
|
+
|
|
182
|
+
For a complex interface, call `nuwax_get_openui_reference` with the closest
|
|
183
|
+
profile before rendering. OpenUI Lang is assignment-based and is not XML,
|
|
184
|
+
HTML, or JSX:
|
|
185
|
+
|
|
186
|
+
```text
|
|
187
|
+
root = Stack([title, status])
|
|
188
|
+
title = TextContent("Deployment", "large-heavy")
|
|
189
|
+
status = Callout("success", "Ready", "Deployment completed successfully.")
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The JSON Schema and guide are generated from the exact OpenUI renderer library
|
|
193
|
+
used by this package, preventing the authoring contract from drifting away from
|
|
194
|
+
runtime behavior.
|
|
195
|
+
|
|
164
196
|
## Host integration
|
|
165
197
|
|
|
166
198
|
For inline mode, mount the OpenUI renderer inside the existing tool block:
|
|
@@ -2,6 +2,18 @@ import { z } from 'zod';
|
|
|
2
2
|
export declare const OPENUI_SCHEMA_VERSION: "nuwax.openui/v1";
|
|
3
3
|
export declare const OPENUI_LANG_VERSION: "0.5";
|
|
4
4
|
export declare const OPENUI_TOOL_NAME: "nuwax_render_openui";
|
|
5
|
+
export declare const OPENUI_REFERENCE_TOOL_NAME: "nuwax_get_openui_reference";
|
|
6
|
+
export declare const OPENUI_AUTHORING_PROMPT_NAME: "nuwax_openui_authoring";
|
|
7
|
+
export declare const OPENUI_SCHEMA_RESOURCE_URI: "nuwax://openui/schema/v0.5";
|
|
8
|
+
export declare const OPENUI_GUIDE_RESOURCE_URI: "nuwax://openui/authoring-guide/v0.5";
|
|
9
|
+
export declare const openUiReferenceInputSchema: z.ZodObject<{
|
|
10
|
+
profile: z.ZodDefault<z.ZodEnum<{
|
|
11
|
+
basic: "basic";
|
|
12
|
+
dashboard: "dashboard";
|
|
13
|
+
form: "form";
|
|
14
|
+
all: "all";
|
|
15
|
+
}>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
5
17
|
declare const bindingSchema: z.ZodObject<{
|
|
6
18
|
serverId: z.ZodString;
|
|
7
19
|
toolName: z.ZodString;
|
|
@@ -89,6 +101,7 @@ export declare const openUiArtifactSchema: z.ZodObject<{
|
|
|
89
101
|
expiresAt: z.ZodString;
|
|
90
102
|
}, z.core.$strip>;
|
|
91
103
|
export type RenderOpenUiInput = z.infer<typeof renderOpenUiInputSchema>;
|
|
104
|
+
export type OpenUiReferenceInput = z.infer<typeof openUiReferenceInputSchema>;
|
|
92
105
|
export type OpenUiArtifact = z.infer<typeof openUiArtifactSchema>;
|
|
93
106
|
export type OpenUiBinding = z.infer<typeof bindingSchema>;
|
|
94
107
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,qBAAqB,EAAG,iBAA0B,CAAC;AAChE,eAAO,MAAM,mBAAmB,EAAG,KAAc,CAAC;AAClD,eAAO,MAAM,gBAAgB,EAAG,qBAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,qBAAqB,EAAG,iBAA0B,CAAC;AAChE,eAAO,MAAM,mBAAmB,EAAG,KAAc,CAAC;AAClD,eAAO,MAAM,gBAAgB,EAAG,qBAA8B,CAAC;AAC/D,eAAO,MAAM,0BAA0B,EAAG,4BAAqC,CAAC;AAChF,eAAO,MAAM,4BAA4B,EAAG,wBAAiC,CAAC;AAC9E,eAAO,MAAM,0BAA0B,EAAG,4BAAqC,CAAC;AAChF,eAAO,MAAM,yBAAyB,EACpC,qCAA8C,CAAC;AAEjD,eAAO,MAAM,0BAA0B;;;;;;;iBAOrC,CAAC;AAEH,QAAA,MAAM,aAAa;;;;;;;iBAIjB,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmClC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+B/B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
package/dist/server/contracts.js
CHANGED
|
@@ -2,23 +2,41 @@ import { z } from 'zod';
|
|
|
2
2
|
export const OPENUI_SCHEMA_VERSION = 'nuwax.openui/v1';
|
|
3
3
|
export const OPENUI_LANG_VERSION = '0.5';
|
|
4
4
|
export const OPENUI_TOOL_NAME = 'nuwax_render_openui';
|
|
5
|
+
export const OPENUI_REFERENCE_TOOL_NAME = 'nuwax_get_openui_reference';
|
|
6
|
+
export const OPENUI_AUTHORING_PROMPT_NAME = 'nuwax_openui_authoring';
|
|
7
|
+
export const OPENUI_SCHEMA_RESOURCE_URI = 'nuwax://openui/schema/v0.5';
|
|
8
|
+
export const OPENUI_GUIDE_RESOURCE_URI = 'nuwax://openui/authoring-guide/v0.5';
|
|
9
|
+
export const openUiReferenceInputSchema = z.object({
|
|
10
|
+
profile: z
|
|
11
|
+
.enum(['basic', 'dashboard', 'form', 'all'])
|
|
12
|
+
.default('basic')
|
|
13
|
+
.describe('Component reference to return: basic for cards/content, dashboard for tables/charts, form for inputs/actions, all only when the other profiles are insufficient.'),
|
|
14
|
+
});
|
|
5
15
|
const bindingSchema = z.object({
|
|
6
16
|
serverId: z.string().trim().min(1).max(128),
|
|
7
17
|
toolName: z.string().trim().min(1).max(128),
|
|
8
18
|
access: z.enum(['query', 'mutation']),
|
|
9
19
|
});
|
|
10
20
|
export const renderOpenUiInputSchema = z.object({
|
|
11
|
-
schemaVersion: z
|
|
12
|
-
|
|
21
|
+
schemaVersion: z
|
|
22
|
+
.literal(OPENUI_SCHEMA_VERSION)
|
|
23
|
+
.describe('Always use nuwax.openui/v1.'),
|
|
24
|
+
title: z.string().trim().min(1).max(160).describe('Visible UI title.'),
|
|
13
25
|
presentation: z.object({
|
|
14
|
-
mode: z
|
|
26
|
+
mode: z
|
|
27
|
+
.enum(['inline', 'sidecar'])
|
|
28
|
+
.describe('Use inline for cards, forms, tables, and compact dashboards in chat. Use sidecar only for a full-page experience.'),
|
|
15
29
|
preferredWidth: z.enum(['compact', 'normal', 'wide']).optional(),
|
|
16
30
|
autoOpen: z.boolean().default(false),
|
|
17
31
|
}),
|
|
18
32
|
document: z.object({
|
|
19
33
|
language: z.literal('openui-lang'),
|
|
20
34
|
specVersion: z.literal(OPENUI_LANG_VERSION),
|
|
21
|
-
source: z
|
|
35
|
+
source: z
|
|
36
|
+
.string()
|
|
37
|
+
.min(1)
|
|
38
|
+
.max(100_000)
|
|
39
|
+
.describe('OpenUI Lang assignment syntax, NEVER XML/HTML/JSX. The first line must define root = Stack(...); arguments are positional. Minimal valid example: root = Stack([title])\\ntitle = TextContent("Ready", "large-heavy"). Call nuwax_get_openui_reference before authoring a complex document or whenever a signature is uncertain.'),
|
|
22
40
|
}),
|
|
23
41
|
bindings: z
|
|
24
42
|
.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAA0B,CAAC;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAc,CAAC;AAClD,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAA0B,CAAC;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAc,CAAC;AAClD,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAA8B,CAAC;AAC/D,MAAM,CAAC,MAAM,0BAA0B,GAAG,4BAAqC,CAAC;AAChF,MAAM,CAAC,MAAM,4BAA4B,GAAG,wBAAiC,CAAC;AAC9E,MAAM,CAAC,MAAM,0BAA0B,GAAG,4BAAqC,CAAC;AAChF,MAAM,CAAC,MAAM,yBAAyB,GACpC,qCAA8C,CAAC;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,OAAO,EAAE,CAAC;SACP,IAAI,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;SAC3C,OAAO,CAAC,OAAO,CAAC;SAChB,QAAQ,CACP,kKAAkK,CACnK;CACJ,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAA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AAuB,CAAC;KAClD,CAAC;IACF,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC;KAC9B,CAAC;IACF,IAAI,EAAE,CAAC;SACJ,MAAM,CAAC;QACN,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;QACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAChC,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;KAC/C,CAAC;SACD,QAAQ,EAAE;IACb,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;KACrB,CAAC;IACF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC"}
|
package/dist/server/http.js
CHANGED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../src/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../src/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAepE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,mBAAmB,GACjC,SAAS,CA8IX"}
|
|
@@ -1,17 +1,79 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { OPENUI_TOOL_NAME, openUiArtifactSchema, renderOpenUiInputSchema, } from './contracts.js';
|
|
3
|
+
import { OPENUI_AUTHORING_PROMPT_NAME, OPENUI_GUIDE_RESOURCE_URI, OPENUI_REFERENCE_TOOL_NAME, OPENUI_SCHEMA_RESOURCE_URI, OPENUI_TOOL_NAME, openUiReferenceInputSchema, openUiArtifactSchema, renderOpenUiInputSchema, } from './contracts.js';
|
|
4
|
+
import { getOpenUiDslSchema, getOpenUiReference } from './openui-reference.js';
|
|
4
5
|
import { OpenUiPolicyError } from './policy.js';
|
|
5
6
|
export function createOpenUiMcpServer(renderService) {
|
|
6
7
|
const server = new McpServer({
|
|
7
8
|
name: 'nuwax-openui-mcp',
|
|
8
|
-
version: '0.1.
|
|
9
|
+
version: '0.1.3',
|
|
9
10
|
});
|
|
11
|
+
server.registerResource('nuwax-openui-dsl-schema', OPENUI_SCHEMA_RESOURCE_URI, {
|
|
12
|
+
title: 'Nuwax OpenUI Lang v0.5 JSON Schema',
|
|
13
|
+
description: 'Authoritative component and property schema generated from the exact OpenUI renderer library used by Nuwax.',
|
|
14
|
+
mimeType: 'application/schema+json',
|
|
15
|
+
}, (uri) => ({
|
|
16
|
+
contents: [
|
|
17
|
+
{
|
|
18
|
+
uri: uri.href,
|
|
19
|
+
mimeType: 'application/schema+json',
|
|
20
|
+
text: getOpenUiDslSchema(),
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
}));
|
|
24
|
+
server.registerResource('nuwax-openui-authoring-guide', OPENUI_GUIDE_RESOURCE_URI, {
|
|
25
|
+
title: 'Nuwax OpenUI Lang v0.5 Authoring Guide',
|
|
26
|
+
description: 'Syntax rules, component signatures, actions, bindings, and examples generated from the current renderer library.',
|
|
27
|
+
mimeType: 'text/plain',
|
|
28
|
+
}, (uri) => ({
|
|
29
|
+
contents: [
|
|
30
|
+
{
|
|
31
|
+
uri: uri.href,
|
|
32
|
+
mimeType: 'text/plain',
|
|
33
|
+
text: getOpenUiReference('all'),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
}));
|
|
37
|
+
server.registerPrompt(OPENUI_AUTHORING_PROMPT_NAME, {
|
|
38
|
+
title: 'Author a Nuwax OpenUI interface',
|
|
39
|
+
description: 'Load the authoritative DSL syntax, component schema, and examples before creating a Nuwax visual interface.',
|
|
40
|
+
argsSchema: openUiReferenceInputSchema.shape,
|
|
41
|
+
}, ({ profile }) => ({
|
|
42
|
+
description: `OpenUI ${profile} authoring instructions`,
|
|
43
|
+
messages: [
|
|
44
|
+
{
|
|
45
|
+
role: 'user',
|
|
46
|
+
content: {
|
|
47
|
+
type: 'text',
|
|
48
|
+
text: `${getOpenUiReference(profile)}\n\nAfter authoring the document, call ${OPENUI_TOOL_NAME} to validate and publish it.`,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
}));
|
|
53
|
+
server.registerTool(OPENUI_REFERENCE_TOOL_NAME, {
|
|
54
|
+
title: 'Get Nuwax OpenUI authoring reference',
|
|
55
|
+
description: 'Get the authoritative OpenUI Lang syntax and component signatures before creating a complex Nuwax UI. Use this instead of guessing syntax or searching local package files. Choose dashboard for tables/charts, form for inputs, basic for cards/content, and all only as a fallback.',
|
|
56
|
+
inputSchema: openUiReferenceInputSchema,
|
|
57
|
+
annotations: {
|
|
58
|
+
readOnlyHint: true,
|
|
59
|
+
destructiveHint: false,
|
|
60
|
+
idempotentHint: true,
|
|
61
|
+
openWorldHint: false,
|
|
62
|
+
},
|
|
63
|
+
}, async ({ profile }) => ({
|
|
64
|
+
content: [{ type: 'text', text: getOpenUiReference(profile) }],
|
|
65
|
+
}));
|
|
10
66
|
server.registerTool(OPENUI_TOOL_NAME, {
|
|
11
67
|
title: 'Render Nuwax OpenUI',
|
|
12
|
-
description: '
|
|
68
|
+
description: 'Create and publish visual UI in a Nuwax Agent conversation. Use this whenever the user asks to show, render, visualize, preview, or build a card, dashboard, chart, table, report, form, status panel, or other structured interface—even if they do not mention OpenUI. Do not use it for prose-only or code-only answers. OpenUI Lang is assignment-based and is NEVER XML/HTML/JSX: start with root = Stack(...), use positional arguments, and reference every defined variable. A minimal valid source is root = Stack([title]) followed by title = TextContent("Ready", "large-heavy"). For complex UI or uncertain component signatures, call nuwax_get_openui_reference first; never guess or search local package files. Use inline for compact conversation UI and sidecar only for a full page.',
|
|
13
69
|
inputSchema: renderOpenUiInputSchema,
|
|
14
70
|
outputSchema: openUiArtifactSchema,
|
|
71
|
+
annotations: {
|
|
72
|
+
readOnlyHint: false,
|
|
73
|
+
destructiveHint: false,
|
|
74
|
+
idempotentHint: false,
|
|
75
|
+
openWorldHint: false,
|
|
76
|
+
},
|
|
15
77
|
}, async (input) => {
|
|
16
78
|
try {
|
|
17
79
|
const artifact = await renderService.render(input);
|
|
@@ -35,7 +97,12 @@ export function createOpenUiMcpServer(renderService) {
|
|
|
35
97
|
: 'Unknown OpenUI validation error.';
|
|
36
98
|
return {
|
|
37
99
|
isError: true,
|
|
38
|
-
content: [
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: 'text',
|
|
103
|
+
text: `${message}\nOpenUI Lang is not XML/HTML/JSX. Call ${OPENUI_REFERENCE_TOOL_NAME} with the closest profile, then retry once using root = Stack(...) and positional arguments.`,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
39
106
|
_meta: error instanceof OpenUiPolicyError
|
|
40
107
|
? { code: error.code }
|
|
41
108
|
: { code: 'invalid-openui-document' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../src/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,UAAU,qBAAqB,CACnC,aAAkC;IAEl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AAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openui-reference.d.ts","sourceRoot":"","sources":["../../src/openui-reference.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAW3D,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,GACvC,MAAM,CAER;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { openuiLibrary } from '@openuidev/react-ui/genui-lib';
|
|
2
|
+
const PROFILE_FOCUS = {
|
|
3
|
+
basic: 'Focus on Stack, Card, CardHeader, TextContent, Callout, TagBlock, Buttons, and Separator.',
|
|
4
|
+
dashboard: 'Focus on Table/Col, chart components, KPI Cards, Tabs, and shared data arrays.',
|
|
5
|
+
form: 'Focus on Form, FormControl, input components, Buttons/Action, validation rules, bindings, and Modal.',
|
|
6
|
+
all: 'Use any documented component, but prefer the smallest set that satisfies the request.',
|
|
7
|
+
};
|
|
8
|
+
export function getOpenUiReference(profile) {
|
|
9
|
+
return `Authoring profile: ${profile}. ${PROFILE_FOCUS[profile]}\nDo not emit XML, HTML, JSX, markdown fences, or explanations inside document.source.\n\n${openuiLibrary.prompt({})}`;
|
|
10
|
+
}
|
|
11
|
+
export function getOpenUiDslSchema() {
|
|
12
|
+
return JSON.stringify(openuiLibrary.toJSONSchema(), null, 2);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=openui-reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openui-reference.js","sourceRoot":"","sources":["../../src/openui-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAI9D,MAAM,aAAa,GAAoD;IACrE,KAAK,EACH,2FAA2F;IAC7F,SAAS,EACP,gFAAgF;IAClF,IAAI,EAAE,sGAAsG;IAC5G,GAAG,EAAE,uFAAuF;CAC7F,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAChC,OAAwC;IAExC,OAAO,sBAAsB,OAAO,KAAK,aAAa,CAAC,OAAO,CAAC,6FAA6F,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;AACzL,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/server/stdio.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuwax-ai/openui-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "OpenUI over MCP for Nuwax, with inline and sidecar rendering contracts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,6 +34,22 @@
|
|
|
34
34
|
"README.md",
|
|
35
35
|
"LICENSE"
|
|
36
36
|
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "pnpm build:server && pnpm build:web",
|
|
39
|
+
"build:server": "tsc -p tsconfig.server.json",
|
|
40
|
+
"build:web": "vite build",
|
|
41
|
+
"dev:http": "tsx watch src/http.ts",
|
|
42
|
+
"dev:stdio": "tsx src/stdio.ts",
|
|
43
|
+
"format": "prettier --write .",
|
|
44
|
+
"format:check": "prettier --check .",
|
|
45
|
+
"lint": "eslint .",
|
|
46
|
+
"start": "node dist/server/http.js",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:watch": "vitest",
|
|
49
|
+
"typecheck": "tsc -p tsconfig.server.json --noEmit && tsc -p tsconfig.web.json --noEmit",
|
|
50
|
+
"verify": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build",
|
|
51
|
+
"prepublishOnly": "pnpm verify"
|
|
52
|
+
},
|
|
37
53
|
"publishConfig": {
|
|
38
54
|
"access": "public",
|
|
39
55
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -70,19 +86,5 @@
|
|
|
70
86
|
"engines": {
|
|
71
87
|
"node": ">=20"
|
|
72
88
|
},
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
"build:server": "tsc -p tsconfig.server.json",
|
|
76
|
-
"build:web": "vite build",
|
|
77
|
-
"dev:http": "tsx watch src/http.ts",
|
|
78
|
-
"dev:stdio": "tsx src/stdio.ts",
|
|
79
|
-
"format": "prettier --write .",
|
|
80
|
-
"format:check": "prettier --check .",
|
|
81
|
-
"lint": "eslint .",
|
|
82
|
-
"start": "node dist/server/http.js",
|
|
83
|
-
"test": "vitest run",
|
|
84
|
-
"test:watch": "vitest",
|
|
85
|
-
"typecheck": "tsc -p tsconfig.server.json --noEmit && tsc -p tsconfig.web.json --noEmit",
|
|
86
|
-
"verify": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
+
"packageManager": "pnpm@10.30.3"
|
|
90
|
+
}
|