@json-layout/core 2.4.0 → 2.5.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 (41) hide show
  1. package/package.json +8 -1
  2. package/src/i18n/de.js +0 -19
  3. package/src/i18n/en.js +0 -19
  4. package/src/i18n/fr.js +0 -19
  5. package/src/i18n/nl.js +0 -19
  6. package/src/i18n/types.ts +0 -19
  7. package/src/state/state-tree.js +10 -1
  8. package/src/webmcp/index.js +283 -0
  9. package/src/webmcp/project.js +148 -0
  10. package/src/webmcp/resolve.js +25 -0
  11. package/src/webmcp/tools/describe-state.js +74 -0
  12. package/src/webmcp/tools/fill-form-skill.js +67 -0
  13. package/src/webmcp/tools/get-data.js +36 -0
  14. package/src/webmcp/tools/get-field-suggestions.js +84 -0
  15. package/src/webmcp/tools/set-data.js +56 -0
  16. package/src/webmcp/tools/set-field-value.js +71 -0
  17. package/types/i18n/de.d.ts +0 -19
  18. package/types/i18n/en.d.ts +0 -19
  19. package/types/i18n/fr.d.ts +0 -19
  20. package/types/i18n/nl.d.ts +0 -19
  21. package/types/i18n/types.d.ts +0 -19
  22. package/types/i18n/types.d.ts.map +1 -1
  23. package/types/state/state-tree.d.ts.map +1 -1
  24. package/types/webmcp/index.d.ts +78 -0
  25. package/types/webmcp/index.d.ts.map +1 -0
  26. package/types/webmcp/project.d.ts +59 -0
  27. package/types/webmcp/project.d.ts.map +1 -0
  28. package/types/webmcp/resolve.d.ts +11 -0
  29. package/types/webmcp/resolve.d.ts.map +1 -0
  30. package/types/webmcp/tools/describe-state.d.ts +70 -0
  31. package/types/webmcp/tools/describe-state.d.ts.map +1 -0
  32. package/types/webmcp/tools/fill-form-skill.d.ts +24 -0
  33. package/types/webmcp/tools/fill-form-skill.d.ts.map +1 -0
  34. package/types/webmcp/tools/get-data.d.ts +31 -0
  35. package/types/webmcp/tools/get-data.d.ts.map +1 -0
  36. package/types/webmcp/tools/get-field-suggestions.d.ts +66 -0
  37. package/types/webmcp/tools/get-field-suggestions.d.ts.map +1 -0
  38. package/types/webmcp/tools/set-data.d.ts +65 -0
  39. package/types/webmcp/tools/set-data.d.ts.map +1 -0
  40. package/types/webmcp/tools/set-field-value.d.ts +73 -0
  41. package/types/webmcp/tools/set-field-value.d.ts.map +1 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @file describeState tool
3
+ */
4
+
5
+ import { projectStateTree, projectNode, collectErrors } from '../project.js'
6
+ import { resolveNode } from '../resolve.js'
7
+
8
+ export const inputSchema = {
9
+ type: 'object',
10
+ properties: {
11
+ path: {
12
+ type: 'string',
13
+ description: 'Path to a specific node (e.g. "/address/city"). Omit for full tree.'
14
+ }
15
+ }
16
+ }
17
+
18
+ export const outputSchema = {
19
+ type: 'object',
20
+ properties: {
21
+ state: {
22
+ type: 'object',
23
+ description: 'Projected state tree or single node'
24
+ },
25
+ valid: {
26
+ type: 'boolean'
27
+ },
28
+ errors: {
29
+ type: 'array',
30
+ items: {
31
+ type: 'object',
32
+ properties: {
33
+ path: { type: 'string' },
34
+ message: { type: 'string' }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @param {string} dataTitle
43
+ * @returns {string}
44
+ */
45
+ export function getDescription (dataTitle) {
46
+ return `Describe the current "${dataTitle}" state tree. Optionally focus on a subtree by path to reduce output size.`
47
+ }
48
+
49
+ /**
50
+ * @param {import('../../state/index.js').StatefulLayout} statefulLayout
51
+ * @param {{ path?: string }} args
52
+ * @returns {{state: ReturnType<typeof projectStateTree>|ReturnType<typeof projectNode>, valid: boolean, errors: Array<{path: string, message: string}>}}
53
+ */
54
+ export function execute (statefulLayout, args) {
55
+ const errors = collectErrors(statefulLayout.stateTree.root)
56
+
57
+ if (args.path) {
58
+ const node = resolveNode(statefulLayout.stateTree.root, args.path)
59
+ if (!node) {
60
+ throw new Error(`node not found at path: ${args.path}`)
61
+ }
62
+ return {
63
+ state: projectNode(node, statefulLayout),
64
+ valid: statefulLayout.valid,
65
+ errors
66
+ }
67
+ }
68
+
69
+ return {
70
+ state: projectStateTree(statefulLayout.stateTree, statefulLayout),
71
+ valid: statefulLayout.valid,
72
+ errors
73
+ }
74
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @file fillFormSkill tool
3
+ */
4
+
5
+ export const outputSchema = {
6
+ type: 'object',
7
+ properties: {
8
+ content: { type: 'string' }
9
+ }
10
+ }
11
+
12
+ /**
13
+ * @param {string} dataTitle
14
+ * @returns {string}
15
+ */
16
+ export function getDescription (dataTitle) {
17
+ return `Get guidance on how to interact with the form "${dataTitle}" using the available tools.`
18
+ }
19
+
20
+ /**
21
+ * Generate skill content with dataTitle injected
22
+ * @param {string} dataTitle
23
+ * @param {string} prefixName
24
+ * @param {boolean} hasSchema
25
+ * @param {import('../../state/index.js').StatefulLayout} statefulLayout
26
+ * @returns {string}
27
+ */
28
+ export function generateSkill (dataTitle, prefixName, hasSchema, statefulLayout) {
29
+ /** @type {"small" | "medium" | "large"} */
30
+ let complexity = 'small'
31
+ const nbNormalizedLayouts = Object.keys(statefulLayout.compiledLayout.normalizedLayouts).length
32
+ if (nbNormalizedLayouts > 15) complexity = 'medium'
33
+ if (nbNormalizedLayouts > 50) complexity = 'large'
34
+ let skill = `# JSON ${dataTitle.charAt(0).toUpperCase() + dataTitle.slice(1)} Form-Filling Guide
35
+
36
+ This guide teaches you how to use tools to fill the data of a form in the user's page.
37
+
38
+ Always start by getting the current data using ${prefixName}getData.
39
+ `
40
+
41
+ if (complexity === 'small') {
42
+ skill += `
43
+ Given the small complexity of this form you should start by reading the full schema definition using ${prefixName}${hasSchema ? 'getSchema' : 'describeState'} and attempt updating the whole data using ${prefixName}setData.
44
+ Only use ${prefixName}describeState and iterate with ${prefixName}setFieldValue if you encounter some difficulties with ${prefixName}setData.
45
+ `
46
+ }
47
+
48
+ if (complexity === 'small') {
49
+ skill += `
50
+ Given the medium complexity of this form you should start by reading the full schema definition using ${prefixName}${hasSchema ? 'getSchema' : 'describeState'}, if you have a satisfying understanding of the schema you can attempt updating the whole data using ${prefixName}setData at least once.
51
+ Then use ${prefixName}describeState and iterate with ${prefixName}setFieldValue.
52
+ `
53
+ }
54
+
55
+ if (complexity === 'large') {
56
+ skill += `
57
+ Given the large complexity of this form you should avoid reading the full schema definition using ${prefixName}${hasSchema ? 'getSchema' : 'describeState'}.
58
+ Prefer using ${prefixName}describeState and iterating with ${prefixName}setFieldValue.
59
+ `
60
+ }
61
+
62
+ skill += `
63
+ If you encounter getItems definitions in the schema or getSuggestions flags in the state. You must use ${prefixName}getFieldSuggestions to fetch the accepted values.
64
+ `
65
+
66
+ return skill
67
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @file getData tool
3
+ */
4
+
5
+ export const inputSchema = {
6
+ type: 'object',
7
+ properties: {}
8
+ }
9
+
10
+ export const outputSchema = {
11
+ type: 'object',
12
+ properties: {
13
+ data: {},
14
+ valid: { type: 'boolean' }
15
+ }
16
+ }
17
+
18
+ /**
19
+ * @param {string} dataTitle
20
+ * @returns {string}
21
+ */
22
+ export function getDescription (dataTitle) {
23
+ return `Get the current "${dataTitle}" data and validity status.`
24
+ }
25
+
26
+ /**
27
+ * @param {import('../../state/index.js').StatefulLayout} statefulLayout
28
+ * @param {{}} _args
29
+ * @returns {{ data: unknown, valid: boolean }}
30
+ */
31
+ export function execute (statefulLayout, _args) {
32
+ return {
33
+ data: statefulLayout.data,
34
+ valid: statefulLayout.valid
35
+ }
36
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @file getFieldSuggestions tool
3
+ */
4
+
5
+ import { resolveNode } from '../resolve.js'
6
+
7
+ export const inputSchema = {
8
+ type: 'object',
9
+ properties: {
10
+ path: {
11
+ type: 'string',
12
+ description: 'Path to the field'
13
+ },
14
+ query: {
15
+ type: 'string',
16
+ description: 'Search query to filter suggestions'
17
+ }
18
+ },
19
+ required: ['path']
20
+ }
21
+
22
+ export const outputSchema = {
23
+ type: 'object',
24
+ properties: {
25
+ items: {
26
+ type: 'array',
27
+ items: {
28
+ type: 'object',
29
+ properties: {
30
+ value: {},
31
+ title: { type: 'string' },
32
+ key: { type: 'string' }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ /**
40
+ * @param {string} dataTitle
41
+ * @returns {string}
42
+ */
43
+ export function getDescription (dataTitle) {
44
+ return `Get available options for a select/autocomplete/combobox field of form "${dataTitle}". Supports query-based filtering.`
45
+ }
46
+
47
+ /**
48
+ * @param {import('../../state/index.js').StatefulLayout} statefulLayout
49
+ * @param {{ path: string, query?: string }} args
50
+ * @returns {Promise<{items: Array<{value: unknown, title: string, key?: string}>}>}
51
+ */
52
+ export async function execute (statefulLayout, args) {
53
+ const node = resolveNode(statefulLayout.stateTree.root, args.path)
54
+ if (!node) {
55
+ throw new Error(`node not found at path: ${args.path}`)
56
+ }
57
+
58
+ if (node.layout.comp === 'one-of-select') {
59
+ const layout = /** @type {Record<string, unknown>} */(node.layout)
60
+ const oneOfItems = /** @type {Array<{header?: boolean, key: number, title: string}>|undefined} */(layout.oneOfItems)
61
+ const items = (oneOfItems || [])
62
+ .filter((item) => !item.header)
63
+ .map((item) => ({ value: item.key, title: item.title }))
64
+ return { items }
65
+ }
66
+
67
+ const rawItems = await statefulLayout.getItems(node, args.query)
68
+
69
+ const items = rawItems
70
+ .filter((item) => !item.header)
71
+ .map((item) => {
72
+ /** @type {{value: unknown, title: string, key?: string}} */
73
+ const result = {
74
+ value: item.value,
75
+ title: item.title
76
+ }
77
+ if (/** @type {unknown} */(item.key) !== item.title) {
78
+ result.key = /** @type {string} */(item.key)
79
+ }
80
+ return result
81
+ })
82
+
83
+ return { items }
84
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @file setData tool
3
+ */
4
+
5
+ import { projectStateTree, collectErrors } from '../project.js'
6
+
7
+ export const inputSchema = {
8
+ type: 'object',
9
+ properties: {
10
+ data: {
11
+ description: 'The form data object to set'
12
+ }
13
+ },
14
+ required: ['data']
15
+ }
16
+
17
+ export const outputSchema = {
18
+ type: 'object',
19
+ properties: {
20
+ state: { type: 'object' },
21
+ valid: { type: 'boolean' },
22
+ errors: {
23
+ type: 'array',
24
+ items: {
25
+ type: 'object',
26
+ properties: {
27
+ path: { type: 'string' },
28
+ message: { type: 'string' }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @param {string} dataTitle
37
+ * @returns {string}
38
+ */
39
+ export function getDescription (dataTitle) {
40
+ return `Bulk-set the "${dataTitle}" data. Use for initial fill or replacing all data at once.`
41
+ }
42
+
43
+ /**
44
+ * @param {import('../../state/index.js').StatefulLayout} statefulLayout
45
+ * @param {{ data: unknown }} args
46
+ * @returns {{ state: ReturnType<typeof projectStateTree>, valid: boolean, errors: Array<{path: string, message: string}> }}
47
+ */
48
+ export function execute (statefulLayout, args) {
49
+ statefulLayout.data = args.data
50
+
51
+ return {
52
+ state: projectStateTree(statefulLayout.stateTree, statefulLayout),
53
+ valid: statefulLayout.valid,
54
+ errors: collectErrors(statefulLayout.stateTree.root)
55
+ }
56
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @file setFieldValue tool
3
+ */
4
+
5
+ import { projectStateTree, collectErrors } from '../project.js'
6
+ import { resolveNode } from '../resolve.js'
7
+
8
+ export const inputSchema = {
9
+ type: 'object',
10
+ properties: {
11
+ path: {
12
+ type: 'string',
13
+ description: 'Path to the field (e.g. "/name", "/items/0/quantity")'
14
+ },
15
+ value: {
16
+ description: 'The value to set'
17
+ }
18
+ },
19
+ required: ['path', 'value']
20
+ }
21
+
22
+ export const outputSchema = {
23
+ type: 'object',
24
+ properties: {
25
+ state: { type: 'object' },
26
+ valid: { type: 'boolean' },
27
+ errors: {
28
+ type: 'array',
29
+ items: {
30
+ type: 'object',
31
+ properties: {
32
+ path: { type: 'string' },
33
+ message: { type: 'string' }
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+
40
+ /**
41
+ * @param {string} dataTitle
42
+ * @returns {string}
43
+ */
44
+ export function getDescription (dataTitle) {
45
+ return `Set the value of a specific field of "${dataTitle}" by path. For oneOf nodes, pass the variant index as value to switch variants.`
46
+ }
47
+
48
+ /**
49
+ * @param {import('../../state/index.js').StatefulLayout} statefulLayout
50
+ * @param {{ path: string, value: unknown }} args
51
+ * @returns {{ state: ReturnType<typeof projectStateTree>, valid: boolean, errors: Array<{path: string, message: string}> }}
52
+ */
53
+ export function execute (statefulLayout, args) {
54
+ const node = resolveNode(statefulLayout.stateTree.root, args.path)
55
+ if (!node) {
56
+ throw new Error(`node not found at path: ${args.path}`)
57
+ }
58
+
59
+ if (node.key === '$oneOf' && typeof args.value === 'number') {
60
+ statefulLayout.activateItem(node, args.value)
61
+ } else {
62
+ statefulLayout.input(node, args.value)
63
+ statefulLayout.blur(node)
64
+ }
65
+
66
+ return {
67
+ state: projectStateTree(statefulLayout.stateTree, statefulLayout),
68
+ valid: statefulLayout.valid,
69
+ errors: collectErrors(statefulLayout.stateTree.root)
70
+ }
71
+ }
@@ -13,25 +13,6 @@ declare const _default: {
13
13
  up: string;
14
14
  down: string;
15
15
  showHelp: string;
16
- mdeLink1: string;
17
- mdeLink2: string;
18
- mdeImg1: string;
19
- mdeImg2: string;
20
- mdeTable1: string;
21
- mdeTable2: string;
22
- bold: string;
23
- italic: string;
24
- heading: string;
25
- quote: string;
26
- unorderedList: string;
27
- orderedList: string;
28
- createLink: string;
29
- insertImage: string;
30
- createTable: string;
31
- preview: string;
32
- mdeGuide: string;
33
- undo: string;
34
- redo: string;
35
16
  default: string;
36
17
  name: string;
37
18
  examples: string;
@@ -13,25 +13,6 @@ declare const _default: {
13
13
  up: string;
14
14
  down: string;
15
15
  showHelp: string;
16
- mdeLink1: string;
17
- mdeLink2: string;
18
- mdeImg1: string;
19
- mdeImg2: string;
20
- mdeTable1: string;
21
- mdeTable2: string;
22
- bold: string;
23
- italic: string;
24
- heading: string;
25
- quote: string;
26
- unorderedList: string;
27
- orderedList: string;
28
- createLink: string;
29
- insertImage: string;
30
- createTable: string;
31
- preview: string;
32
- mdeGuide: string;
33
- undo: string;
34
- redo: string;
35
16
  default: string;
36
17
  name: string;
37
18
  examples: string;
@@ -13,25 +13,6 @@ declare const _default: {
13
13
  up: string;
14
14
  down: string;
15
15
  showHelp: string;
16
- mdeLink1: string;
17
- mdeLink2: string;
18
- mdeImg1: string;
19
- mdeImg2: string;
20
- mdeTable1: string;
21
- mdeTable2: string;
22
- bold: string;
23
- italic: string;
24
- heading: string;
25
- quote: string;
26
- unorderedList: string;
27
- orderedList: string;
28
- createLink: string;
29
- insertImage: string;
30
- createTable: string;
31
- preview: string;
32
- mdeGuide: string;
33
- undo: string;
34
- redo: string;
35
16
  default: string;
36
17
  name: string;
37
18
  examples: string;
@@ -13,25 +13,6 @@ declare const _default: {
13
13
  up: string;
14
14
  down: string;
15
15
  showHelp: string;
16
- mdeLink1: string;
17
- mdeLink2: string;
18
- mdeImg1: string;
19
- mdeImg2: string;
20
- mdeTable1: string;
21
- mdeTable2: string;
22
- bold: string;
23
- italic: string;
24
- heading: string;
25
- quote: string;
26
- unorderedList: string;
27
- orderedList: string;
28
- createLink: string;
29
- insertImage: string;
30
- createTable: string;
31
- preview: string;
32
- mdeGuide: string;
33
- undo: string;
34
- redo: string;
35
16
  default: string;
36
17
  name: string;
37
18
  examples: string;
@@ -16,25 +16,6 @@ export interface StateOptionsMessages {
16
16
  up: string;
17
17
  down: string;
18
18
  showHelp: string;
19
- mdeLink1: string;
20
- mdeLink2: string;
21
- mdeImg1: string;
22
- mdeImg2: string;
23
- mdeTable1: string;
24
- mdeTable2: string;
25
- bold: string;
26
- italic: string;
27
- heading: string;
28
- quote: string;
29
- unorderedList: string;
30
- orderedList: string;
31
- createLink: string;
32
- insertImage: string;
33
- createTable: string;
34
- preview: string;
35
- mdeGuide: string;
36
- undo: string;
37
- redo: string;
38
19
  keyboardDate: string;
39
20
  keyboardDateTime: string;
40
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,sBAAsB,GAAG,oBAAoB,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,sBAAsB,GAAG,oBAAoB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"state-tree.d.ts","sourceRoot":"","sources":["../../src/state/state-tree.js"],"names":[],"mappings":"AA8BA;;;;;;;;;;GAUG;AACH,yCAVW,OAAO,YAAY,EAAE,sBAAsB,WAC3C,OAAO,YAAY,EAAE,qBAAqB,kBAC1C,OAAO,aAAa,EAAE,cAAc,YACpC,OAAO,aAAa,EAAE,YAAY,WAClC,OAAO,oBAAoB,EAAE,OAAO,QACpC,OAAO,mBACP,OAAO,YAAY,EAAE,eAAe,oBACpC,OAAO,YAAY,EAAE,SAAS,GAC5B,OAAO,YAAY,EAAE,SAAS,CAwE1C"}
1
+ {"version":3,"file":"state-tree.d.ts","sourceRoot":"","sources":["../../src/state/state-tree.js"],"names":[],"mappings":"AA8BA;;;;;;;;;;GAUG;AACH,yCAVW,OAAO,YAAY,EAAE,sBAAsB,WAC3C,OAAO,YAAY,EAAE,qBAAqB,kBAC1C,OAAO,aAAa,EAAE,cAAc,YACpC,OAAO,aAAa,EAAE,YAAY,WAClC,OAAO,oBAAoB,EAAE,OAAO,QACpC,OAAO,mBACP,OAAO,YAAY,EAAE,eAAe,oBACpC,OAAO,YAAY,EAAE,SAAS,GAC5B,OAAO,YAAY,EAAE,SAAS,CAiF1C"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @typedef {object} WebMCPOptions
3
+ * @property {string} [prefixName] - Prefix for all tool names
4
+ * @property {string} [dataTitle] - Title used in descriptions (default: 'form')
5
+ * @property {object} [schema] - The original JSON schema
6
+ */
7
+ /**
8
+ * WebMCP class that provides MCP tool descriptors for a StatefulLayout instance
9
+ */
10
+ export class WebMCP {
11
+ /**
12
+ * @param {import('../state/index.js').StatefulLayout} statefulLayout
13
+ * @param {WebMCPOptions} [options]
14
+ */
15
+ constructor(statefulLayout: import("../state/index.js").StatefulLayout, options?: WebMCPOptions);
16
+ /**
17
+ * @readonly
18
+ * @type {import('../state/index.js').StatefulLayout}
19
+ */
20
+ readonly _statefulLayout: import("../state/index.js").StatefulLayout;
21
+ /**
22
+ * @readonly
23
+ * @type {string}
24
+ */
25
+ readonly _prefixName: string;
26
+ /**
27
+ * @readonly
28
+ * @type {string}
29
+ */
30
+ readonly _dataTitle: string;
31
+ /**
32
+ * @readonly
33
+ * @type {string}
34
+ */
35
+ readonly _skill: string;
36
+ /**
37
+ * @readonly
38
+ * @type {object | null}
39
+ */
40
+ readonly _schema: object | null;
41
+ /**
42
+ * @type {string[]}
43
+ */
44
+ _registeredTools: string[];
45
+ /**
46
+ * @param {string} name
47
+ * @returns {string}
48
+ */
49
+ _toolName(name: string): string;
50
+ /**
51
+ * @returns {ToolDescriptor[]}
52
+ */
53
+ getTools(): ToolDescriptor[];
54
+ /**
55
+ * @returns {Promise<void>}
56
+ */
57
+ registerTools(): Promise<void>;
58
+ /**
59
+ * @returns {Promise<void>}
60
+ */
61
+ unregisterTools(): Promise<void>;
62
+ }
63
+ export type ToolDescriptor = import("@mcp-b/webmcp-types").ToolDescriptor;
64
+ export type WebMCPOptions = {
65
+ /**
66
+ * - Prefix for all tool names
67
+ */
68
+ prefixName?: string | undefined;
69
+ /**
70
+ * - Title used in descriptions (default: 'form')
71
+ */
72
+ dataTitle?: string | undefined;
73
+ /**
74
+ * - The original JSON schema
75
+ */
76
+ schema?: object | undefined;
77
+ };
78
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webmcp/index.js"],"names":[],"mappings":"AAkBA;;;;;GAKG;AAEH;;GAEG;AACH;IAoCE;;;OAGG;IACH,4BAHW,OAAO,mBAAmB,EAAE,cAAc,YAC1C,aAAa,EAQvB;IA7CD;;;OAGG;IACH,0BAFU,OAAO,mBAAmB,EAAE,cAAc,CAErC;IAEf;;;OAGG;IACH,sBAFU,MAAM,CAEL;IAEX;;;OAGG;IACH,qBAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,iBAFU,MAAM,CAEV;IAEN;;;OAGG;IACH,kBAFU,MAAM,GAAG,IAAI,CAET;IAEd;;OAEG;IACH,kBAFU,MAAM,EAAE,CAEG;IAcrB;;;OAGG;IACH,gBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;OAEG;IACH,YAFa,cAAc,EAAE,CAoK5B;IAED;;OAEG;IACH,iBAFa,OAAO,CAAC,IAAI,CAAC,CAczB;IAED;;OAEG;IACH,mBAFa,OAAO,CAAC,IAAI,CAAC,CAYzB;CACF;6BA5Qa,OAAO,qBAAqB,EAAE,cAAc"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @param {import('../state/types.js').StateNode} node
3
+ * @param {import('../state/index.js').StatefulLayout} statefulLayout
4
+ * @returns {{
5
+ * key: string|number,
6
+ * path: string,
7
+ * comp: string,
8
+ * data: unknown,
9
+ * title?: string,
10
+ * label?: string,
11
+ * help?: string,
12
+ * error?: string,
13
+ * childError?: boolean,
14
+ * required?: boolean,
15
+ * readOnly?: boolean,
16
+ * constraints?: Record<string, unknown>,
17
+ * oneOfItems?: Array<{key: number, title: string}>,
18
+ * children?: Array<any>
19
+ * getSuffections?: boolean
20
+ * }}
21
+ */
22
+ export function projectNode(node: import("../state/types.js").StateNode, statefulLayout: import("../state/index.js").StatefulLayout): {
23
+ key: string | number;
24
+ path: string;
25
+ comp: string;
26
+ data: unknown;
27
+ title?: string;
28
+ label?: string;
29
+ help?: string;
30
+ error?: string;
31
+ childError?: boolean;
32
+ required?: boolean;
33
+ readOnly?: boolean;
34
+ constraints?: Record<string, unknown>;
35
+ oneOfItems?: Array<{
36
+ key: number;
37
+ title: string;
38
+ }>;
39
+ children?: Array<any>;
40
+ getSuffections?: boolean;
41
+ };
42
+ /**
43
+ * @param {import('../state/types.js').StateTree} stateTree
44
+ * @param {import('../state/index.js').StatefulLayout} statefulLayout
45
+ * @returns {{ root: ReturnType<typeof projectNode>, valid: boolean }}
46
+ */
47
+ export function projectStateTree(stateTree: import("../state/types.js").StateTree, statefulLayout: import("../state/index.js").StatefulLayout): {
48
+ root: ReturnType<typeof projectNode>;
49
+ valid: boolean;
50
+ };
51
+ /**
52
+ * @param {import('../state/types.js').StateNode} node
53
+ * @returns {Array<{path: string, message: string}>}
54
+ */
55
+ export function collectErrors(node: import("../state/types.js").StateNode): Array<{
56
+ path: string;
57
+ message: string;
58
+ }>;
59
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/webmcp/project.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,kCApBW,OAAO,mBAAmB,EAAE,SAAS,kBACrC,OAAO,mBAAmB,EAAE,cAAc,GACxC;IACR,GAAG,EAAE,MAAM,GAAC,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IACrB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAiEH;AAED;;;;GAIG;AACH,4CAJW,OAAO,mBAAmB,EAAE,SAAS,kBACrC,OAAO,mBAAmB,EAAE,cAAc,GACxC;IAAE,IAAI,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAOpE;AAED;;;GAGG;AACH,oCAHW,OAAO,mBAAmB,EAAE,SAAS,GACnC,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CAOlD"}