@progress/kendo-react-webmcp 15.0.1-develop.3 → 15.0.1-develop.4
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/WebMcpProvider.js +1 -1
- package/WebMcpProvider.mjs +84 -80
- package/adapters/button.d.ts +1 -1
- package/adapters/button.js +1 -1
- package/adapters/button.mjs +12 -17
- package/adapters/{dashboard.d.ts → checkbox.d.ts} +5 -6
- package/adapters/checkbox.js +8 -0
- package/adapters/checkbox.mjs +60 -0
- package/adapters/dropdowntree.js +1 -1
- package/adapters/dropdowntree.mjs +78 -51
- package/adapters/editor.d.ts +0 -1
- package/adapters/editor.js +1 -1
- package/adapters/editor.mjs +38 -46
- package/adapters/form.d.ts +1 -0
- package/adapters/form.js +3 -3
- package/adapters/form.mjs +75 -49
- package/adapters/gantt.d.ts +2 -0
- package/adapters/gantt.js +1 -1
- package/adapters/gantt.mjs +188 -140
- package/adapters/grid.d.ts +0 -1
- package/adapters/grid.js +1 -1
- package/adapters/grid.mjs +52 -60
- package/adapters/multicolumncombobox.d.ts +20 -0
- package/adapters/multicolumncombobox.js +8 -0
- package/adapters/multicolumncombobox.mjs +75 -0
- package/adapters/multiselect.d.ts +2 -0
- package/adapters/multiselect.js +1 -1
- package/adapters/multiselect.mjs +46 -30
- package/adapters/notification.js +1 -1
- package/adapters/notification.mjs +14 -14
- package/adapters/pivotgrid.js +1 -1
- package/adapters/pivotgrid.mjs +39 -47
- package/adapters/scheduler.js +1 -1
- package/adapters/scheduler.mjs +137 -92
- package/adapters/spreadsheet.js +1 -1
- package/adapters/spreadsheet.mjs +3 -3
- package/adapters/switch.js +1 -1
- package/adapters/switch.mjs +29 -19
- package/adapters/treeview.js +2 -2
- package/adapters/treeview.mjs +79 -113
- package/adapters/window.d.ts +0 -2
- package/adapters/window.js +1 -1
- package/adapters/window.mjs +29 -63
- package/commands/form.d.ts +4 -1
- package/commands/form.js +1 -1
- package/commands/form.mjs +11 -7
- package/commands/gantt.js +1 -1
- package/commands/gantt.mjs +14 -10
- package/commands/grid.d.ts +0 -4
- package/commands/grid.js +1 -1
- package/commands/grid.mjs +18 -24
- package/commands/index.d.ts +0 -1
- package/commands/pivotgrid.d.ts +0 -4
- package/commands/pivotgrid.js +1 -1
- package/commands/pivotgrid.mjs +6 -12
- package/commands/scheduler.d.ts +10 -0
- package/commands/scheduler.js +1 -1
- package/commands/scheduler.mjs +16 -4
- package/commands/window.d.ts +0 -8
- package/commands/window.js +1 -1
- package/commands/window.mjs +8 -18
- package/dist/cdn/js/kendo-react-webmcp.js +1 -1
- package/index.d.mts +2 -1
- package/index.d.ts +2 -1
- package/index.js +1 -1
- package/index.mjs +248 -249
- package/package.json +3 -3
- package/schemas/gantt.d.ts +4 -0
- package/schemas/gantt.js +1 -1
- package/schemas/gantt.mjs +93 -8
- package/schemas/scheduler.d.ts +2 -0
- package/schemas/scheduler.js +1 -1
- package/schemas/scheduler.mjs +21 -5
- package/adapters/dashboard.js +0 -8
- package/adapters/dashboard.mjs +0 -41
- package/commands/dashboard.d.ts +0 -19
- package/commands/dashboard.js +0 -8
- package/commands/dashboard.mjs +0 -21
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { NotificationCommands as i, getNotificationToolSchema as
|
|
9
|
-
const
|
|
8
|
+
import { NotificationCommands as i, getNotificationToolSchema as x } from "../commands/notification.mjs";
|
|
9
|
+
const g = {
|
|
10
10
|
componentSuffix: "notification",
|
|
11
|
-
createTools(p,
|
|
12
|
-
const
|
|
11
|
+
createTools(p, r, c, d) {
|
|
12
|
+
const m = [], f = (t) => `${c.groupName}_${t}`, u = [
|
|
13
13
|
{
|
|
14
14
|
name: "show",
|
|
15
15
|
description: `Show a notification in the ${c.dataName} notification group.`,
|
|
@@ -22,36 +22,36 @@ const w = {
|
|
|
22
22
|
commandType: i.Dismiss,
|
|
23
23
|
enabled: !0
|
|
24
24
|
}
|
|
25
|
-
],
|
|
26
|
-
var n,
|
|
25
|
+
], e = r.current.webMcp, l = typeof e == "object" && e !== null && typeof e.tools == "function" ? e.tools : void 0, y = l ? l(u) : u, h = async (t, s) => {
|
|
26
|
+
var n, o;
|
|
27
27
|
switch (t) {
|
|
28
28
|
case i.Show:
|
|
29
29
|
return { content: [{ type: "text", text: `Notification shown: "${String(s.message)}".` }] };
|
|
30
30
|
case i.Dismiss:
|
|
31
|
-
return (
|
|
31
|
+
return (o = (n = r.current).onClose) == null || o.call(n, { syntheticEvent: null, target: p }), { content: [{ type: "text", text: "Notification dismissed." }] };
|
|
32
32
|
default:
|
|
33
33
|
return { content: [{ type: "text", text: `Unknown command: ${t}` }], isError: !0 };
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
for (const t of
|
|
36
|
+
for (const t of y) {
|
|
37
37
|
if (!t.enabled)
|
|
38
38
|
continue;
|
|
39
|
-
const s =
|
|
39
|
+
const s = x(t.commandType), n = t.commandType, o = t.execute;
|
|
40
40
|
try {
|
|
41
|
-
|
|
41
|
+
m.push(
|
|
42
42
|
d.registerTool({
|
|
43
|
-
name:
|
|
43
|
+
name: f(t.name),
|
|
44
44
|
description: t.description,
|
|
45
45
|
inputSchema: s,
|
|
46
|
-
execute: async (
|
|
46
|
+
execute: o ? async (a) => await o(a) : async (a) => h(n, a || {})
|
|
47
47
|
})
|
|
48
48
|
);
|
|
49
49
|
} catch {
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return m;
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
export {
|
|
56
|
-
|
|
56
|
+
g as notificationAdapter
|
|
57
57
|
};
|
package/adapters/pivotgrid.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../commands/pivotgrid.js"),w={componentSuffix:"pivotgrid",createTools(d,o,i,S){const l=[],g=t=>`${i.groupName}_${t}`,m=[{name:"set_rows",description:`Set the row fields of the ${i.dataName} pivot grid`,commandType:n.PivotGridCommands.SetRows,enabled:!0},{name:"set_columns",description:`Set the column fields of the ${i.dataName} pivot grid`,commandType:n.PivotGridCommands.SetColumns,enabled:!0},{name:"set_measures",description:`Set the measure fields of the ${i.dataName} pivot grid`,commandType:n.PivotGridCommands.SetMeasures,enabled:!0},{name:"expand",description:`Expand a row or column header in the ${i.dataName} pivot grid`,commandType:n.PivotGridCommands.Expand,enabled:!0},{name:"collapse",description:`Collapse a row or column header in the ${i.dataName} pivot grid`,commandType:n.PivotGridCommands.Collapse,enabled:!0}],s=o.current.webMcp,u=typeof s=="object"&&s!==null&&typeof s.tools=="function"?s.tools:void 0,P=u?u(m):m,$=async(t,e)=>{var c,r,a,p,v,y,f,C,x,h;switch(t){case n.PivotGridCommands.SetRows:return(r=(c=o.current).onConfigChange)==null||r.call(c,{type:"rows",fields:e.fields,syntheticEvent:null,target:d}),{content:[{type:"text",text:`Pivot grid rows set to: ${JSON.stringify(e.fields)}.`}]};case n.PivotGridCommands.SetColumns:return(p=(a=o.current).onConfigChange)==null||p.call(a,{type:"columns",fields:e.fields,syntheticEvent:null,target:d}),{content:[{type:"text",text:`Pivot grid columns set to: ${JSON.stringify(e.fields)}.`}]};case n.PivotGridCommands.SetMeasures:return(y=(v=o.current).onConfigChange)==null||y.call(v,{type:"measures",fields:e.fields,syntheticEvent:null,target:d}),{content:[{type:"text",text:`Pivot grid measures set to: ${JSON.stringify(e.fields)}.`}]};case n.PivotGridCommands.Expand:return(C=(f=o.current).onExpandChange)==null||C.call(f,{field:e.field,value:e.value,expanded:!0,syntheticEvent:null,target:d}),{content:[{type:"text",text:`Expanded "${String(e.field)}: ${String(e.value)}".`}]};case n.PivotGridCommands.Collapse:return(h=(x=o.current).onExpandChange)==null||h.call(x,{field:e.field,value:e.value,expanded:!1,syntheticEvent:null,target:d}),{content:[{type:"text",text:`Collapsed "${String(e.field)}: ${String(e.value)}".`}]};default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const t of P){if(!t.enabled)continue;const e=t.inputSchema||n.getPivotGridToolSchema(t.commandType),c=t.commandType,r=t.execute;try{l.push(S.registerTool({name:g(t.name),description:t.description,inputSchema:e,execute:r?async a=>await r(a||{}):async a=>$(c,a||{})}))}catch{}}return l}};exports.pivotgridAdapter=w;
|
package/adapters/pivotgrid.mjs
CHANGED
|
@@ -5,114 +5,106 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { PivotGridCommands as
|
|
8
|
+
import { PivotGridCommands as n, getPivotGridToolSchema as E } from "../commands/pivotgrid.mjs";
|
|
9
9
|
const b = {
|
|
10
10
|
componentSuffix: "pivotgrid",
|
|
11
|
-
createTools(
|
|
12
|
-
const l = [],
|
|
11
|
+
createTools(r, o, i, C) {
|
|
12
|
+
const l = [], g = (t) => `${i.groupName}_${t}`, u = [
|
|
13
13
|
{
|
|
14
14
|
name: "set_rows",
|
|
15
|
-
description: `Set the row fields of the ${
|
|
16
|
-
commandType:
|
|
15
|
+
description: `Set the row fields of the ${i.dataName} pivot grid`,
|
|
16
|
+
commandType: n.SetRows,
|
|
17
17
|
enabled: !0
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
name: "set_columns",
|
|
21
|
-
description: `Set the column fields of the ${
|
|
22
|
-
commandType:
|
|
21
|
+
description: `Set the column fields of the ${i.dataName} pivot grid`,
|
|
22
|
+
commandType: n.SetColumns,
|
|
23
23
|
enabled: !0
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
name: "set_measures",
|
|
27
|
-
description: `Set the measure fields of the ${
|
|
28
|
-
commandType:
|
|
27
|
+
description: `Set the measure fields of the ${i.dataName} pivot grid`,
|
|
28
|
+
commandType: n.SetMeasures,
|
|
29
29
|
enabled: !0
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
name: "expand",
|
|
33
|
-
description: `Expand a row or column header in the ${
|
|
34
|
-
commandType:
|
|
33
|
+
description: `Expand a row or column header in the ${i.dataName} pivot grid`,
|
|
34
|
+
commandType: n.Expand,
|
|
35
35
|
enabled: !0
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
name: "collapse",
|
|
39
|
-
description: `Collapse a row or column header in the ${
|
|
40
|
-
commandType:
|
|
41
|
-
enabled: !0
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: "export_pdf",
|
|
45
|
-
description: `Export the ${o.dataName} pivot grid to PDF`,
|
|
46
|
-
commandType: t.ExportPDF,
|
|
39
|
+
description: `Collapse a row or column header in the ${i.dataName} pivot grid`,
|
|
40
|
+
commandType: n.Collapse,
|
|
47
41
|
enabled: !0
|
|
48
42
|
}
|
|
49
|
-
],
|
|
50
|
-
var d, s,
|
|
51
|
-
switch (
|
|
52
|
-
case
|
|
53
|
-
return (s = (d =
|
|
43
|
+
], c = o.current.webMcp, m = typeof c == "object" && c !== null && typeof c.tools == "function" ? c.tools : void 0, $ = m ? m(u) : u, w = async (t, e) => {
|
|
44
|
+
var d, s, a, p, f, y, x, v, h, S;
|
|
45
|
+
switch (t) {
|
|
46
|
+
case n.SetRows:
|
|
47
|
+
return (s = (d = o.current).onConfigChange) == null || s.call(d, {
|
|
54
48
|
type: "rows",
|
|
55
49
|
fields: e.fields,
|
|
56
50
|
syntheticEvent: null,
|
|
57
|
-
target:
|
|
51
|
+
target: r
|
|
58
52
|
}), {
|
|
59
53
|
content: [{ type: "text", text: `Pivot grid rows set to: ${JSON.stringify(e.fields)}.` }]
|
|
60
54
|
};
|
|
61
|
-
case
|
|
62
|
-
return (
|
|
55
|
+
case n.SetColumns:
|
|
56
|
+
return (p = (a = o.current).onConfigChange) == null || p.call(a, {
|
|
63
57
|
type: "columns",
|
|
64
58
|
fields: e.fields,
|
|
65
59
|
syntheticEvent: null,
|
|
66
|
-
target:
|
|
60
|
+
target: r
|
|
67
61
|
}), {
|
|
68
62
|
content: [{ type: "text", text: `Pivot grid columns set to: ${JSON.stringify(e.fields)}.` }]
|
|
69
63
|
};
|
|
70
|
-
case
|
|
71
|
-
return (y = (
|
|
64
|
+
case n.SetMeasures:
|
|
65
|
+
return (y = (f = o.current).onConfigChange) == null || y.call(f, {
|
|
72
66
|
type: "measures",
|
|
73
67
|
fields: e.fields,
|
|
74
68
|
syntheticEvent: null,
|
|
75
|
-
target:
|
|
69
|
+
target: r
|
|
76
70
|
}), {
|
|
77
71
|
content: [{ type: "text", text: `Pivot grid measures set to: ${JSON.stringify(e.fields)}.` }]
|
|
78
72
|
};
|
|
79
|
-
case
|
|
80
|
-
return (v = (
|
|
73
|
+
case n.Expand:
|
|
74
|
+
return (v = (x = o.current).onExpandChange) == null || v.call(x, {
|
|
81
75
|
field: e.field,
|
|
82
76
|
value: e.value,
|
|
83
77
|
expanded: !0,
|
|
84
78
|
syntheticEvent: null,
|
|
85
|
-
target:
|
|
79
|
+
target: r
|
|
86
80
|
}), {
|
|
87
81
|
content: [{ type: "text", text: `Expanded "${String(e.field)}: ${String(e.value)}".` }]
|
|
88
82
|
};
|
|
89
|
-
case
|
|
90
|
-
return (S = (h =
|
|
83
|
+
case n.Collapse:
|
|
84
|
+
return (S = (h = o.current).onExpandChange) == null || S.call(h, {
|
|
91
85
|
field: e.field,
|
|
92
86
|
value: e.value,
|
|
93
87
|
expanded: !1,
|
|
94
88
|
syntheticEvent: null,
|
|
95
|
-
target:
|
|
89
|
+
target: r
|
|
96
90
|
}), {
|
|
97
91
|
content: [{ type: "text", text: `Collapsed "${String(e.field)}: ${String(e.value)}".` }]
|
|
98
92
|
};
|
|
99
|
-
case t.ExportPDF:
|
|
100
|
-
return { content: [{ type: "text", text: "Pivot grid PDF export initiated." }] };
|
|
101
93
|
default:
|
|
102
|
-
return { content: [{ type: "text", text: `Unknown command: ${
|
|
94
|
+
return { content: [{ type: "text", text: `Unknown command: ${t}` }], isError: !0 };
|
|
103
95
|
}
|
|
104
96
|
};
|
|
105
|
-
for (const
|
|
106
|
-
if (!
|
|
97
|
+
for (const t of $) {
|
|
98
|
+
if (!t.enabled)
|
|
107
99
|
continue;
|
|
108
|
-
const e =
|
|
100
|
+
const e = t.inputSchema || E(t.commandType), d = t.commandType, s = t.execute;
|
|
109
101
|
try {
|
|
110
102
|
l.push(
|
|
111
|
-
|
|
112
|
-
name:
|
|
113
|
-
description:
|
|
103
|
+
C.registerTool({
|
|
104
|
+
name: g(t.name),
|
|
105
|
+
description: t.description,
|
|
114
106
|
inputSchema: e,
|
|
115
|
-
execute: async (s) =>
|
|
107
|
+
execute: s ? async (a) => await s(a || {}) : async (a) => w(d, a || {})
|
|
116
108
|
})
|
|
117
109
|
);
|
|
118
110
|
} catch {
|
package/adapters/scheduler.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),s=require("../commands/scheduler.js"),h=require("./utils.js");function g(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const S=g(v);function x(n){const e=n.modelFields;return{id:(e==null?void 0:e.id)||"id",title:(e==null?void 0:e.title)||"title",start:(e==null?void 0:e.start)||"start",end:(e==null?void 0:e.end)||"end",isAllDay:(e==null?void 0:e.isAllDay)||"isAllDay",description:(e==null?void 0:e.description)||"description"}}function N(n){const e=[];return S.Children.forEach(n,t=>{if(S.isValidElement(t)){const r=t.props.name;r&&e.push(r)}}),e}function T(n,e){const t=n.date;if(!t)return{content:[{type:"text",text:"Missing required argument: date"}],isError:!0};const r=new Date(t);if(Number.isNaN(r.getTime()))return{content:[{type:"text",text:`Invalid date: ${t}`}],isError:!0};const i=e.current;return i.onDateChange&&i.onDateChange({value:r}),{content:[{type:"text",text:`Navigated to ${r.toISOString().split("T")[0]}.`}]}}function b(n,e){const t=n.view;if(!t)return{content:[{type:"text",text:"Missing required argument: view"}],isError:!0};const r=e.current;return r.onViewChange&&r.onViewChange({value:t}),{content:[{type:"text",text:`Switched to ${t} view.`}]}}function E(n,e){const t=e.current;if(!t.onDataChange)return{content:[{type:"text",text:"Scheduler is not editable (no onDataChange handler)."}],isError:!0};const r=x(t),i=n.title||"New Event",u=n.start,a=n.end;if(!u||!a)return{content:[{type:"text",text:"Missing required arguments: start and end (ISO strings)"}],isError:!0};const d=new Date(u),o=new Date(a);if(Number.isNaN(d.getTime())||Number.isNaN(o.getTime()))return{content:[{type:"text",text:"Invalid start or end date."}],isError:!0};const l={[r.id]:Date.now(),[r.title]:i,[r.start]:d,[r.end]:o,[r.isAllDay]:n.isAllDay===!0};return n.description&&(l[r.description]=n.description),t.onDataChange({created:[l],updated:[],deleted:[]}),{content:[{type:"text",text:`Created event "${i}" from ${u} to ${a}.`}]}}function $(n,e){const t=e.current;if(!t.onDataChange)return{content:[{type:"text",text:"Scheduler is not editable (no onDataChange handler)."}],isError:!0};const r=x(t),i=n.title;if(!i)return{content:[{type:"text",text:"Missing required argument: title"}],isError:!0};const u=t.data||[],a=n.start,d=u.find(o=>{if(h.toText(o[r.title])!==i)return!1;if(a){const l=o[r.start];return(l instanceof Date?l.toISOString():h.toText(l)).startsWith(a)}return!0});return d?(t.onDataChange({created:[],updated:[],deleted:[d]}),{content:[{type:"text",text:`Deleted event "${h.toText(d[r.title])}".`}]}):{content:[{type:"text",text:`Event "${i}" not found.`}],isError:!0}}function A(n,e){const t=e.current;if(!t.onDataChange)return{content:[{type:"text",text:"Scheduler is not editable (no onDataChange handler)."}],isError:!0};const r=x(t),i=n.title;if(!i)return{content:[{type:"text",text:"Missing required argument: title"}],isError:!0};const u=t.data||[],a=n.start,d=u.find(c=>{if(h.toText(c[r.title])!==i)return!1;if(a){const p=c[r.start];return(p instanceof Date?p.toISOString():h.toText(p)).startsWith(a)}return!0});if(!d)return{content:[{type:"text",text:`Event "${i}" not found.`}],isError:!0};const o={...d};if(n.newTitle&&(o[r.title]=n.newTitle),n.newStart){const c=new Date(n.newStart);Number.isNaN(c.getTime())||(o[r.start]=c)}if(n.newEnd){const c=new Date(n.newEnd);Number.isNaN(c.getTime())||(o[r.end]=c)}return n.isAllDay!==void 0&&(o[r.isAllDay]=n.isAllDay===!0),n.description!==void 0&&(o[r.description]=n.description),t.onDataChange({created:[],updated:[o],deleted:[]}),{content:[{type:"text",text:`Updated event "${h.toText(o[r.title])}".`}]}}function O(n,e,t){switch(n){case s.SchedulerCommands.Navigate:return T(e,t);case s.SchedulerCommands.View:return b(e,t);case s.SchedulerCommands.Create:return E(e,t);case s.SchedulerCommands.Update:return A(e,t);case s.SchedulerCommands.Delete:return $(e,t);default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}}const M={componentSuffix:"scheduler",createTools(n,e,t,r){const i=[],u=m=>`${t.groupName}_${m}`,a=e.current,d=N(a.children),o=d.length>0?` Available views: ${d.join(", ")}.`:"",l=[{name:"navigate",description:`Navigate the ${t.dataName} scheduler to a specific date.`,commandType:s.SchedulerCommands.Navigate,enabled:!!a.onDateChange},{name:"set_view",description:`Switch the ${t.dataName} scheduler view.${o}`,commandType:s.SchedulerCommands.View,enabled:!!a.onViewChange},{name:"create_event",description:`Create a new event in the ${t.dataName} scheduler.`,commandType:s.SchedulerCommands.Create,enabled:!!a.onDataChange},{name:"update_event",description:`Update an existing event in the ${t.dataName} scheduler.`,commandType:s.SchedulerCommands.Update,enabled:!!a.onDataChange},{name:"delete_event",description:`Delete an event from the ${t.dataName} scheduler.`,commandType:s.SchedulerCommands.Delete,enabled:!!a.onDataChange}],c=e.current.webMcp,p=typeof c=="object"&&c!==null&&typeof c.tools=="function"?c.tools:void 0,f={tname:u,data:a.data},w=p?p(l,f):l;for(const m of w){if(!m.enabled)continue;const y=s.getSchedulerToolSchema(m.commandType),C=m.commandType;try{i.push(r.registerTool({name:u(m.name),description:m.description,inputSchema:y,execute:async D=>O(C,D||{},e)}))}catch{}}return i}};exports.schedulerAdapter=M;
|
package/adapters/scheduler.mjs
CHANGED
|
@@ -5,161 +5,206 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import { SchedulerCommands as
|
|
10
|
-
import { toText as
|
|
11
|
-
function
|
|
12
|
-
const
|
|
8
|
+
import * as w from "react";
|
|
9
|
+
import { SchedulerCommands as l, getSchedulerToolSchema as C } from "../commands/scheduler.mjs";
|
|
10
|
+
import { toText as h } from "./utils.mjs";
|
|
11
|
+
function x(n) {
|
|
12
|
+
const t = n.modelFields;
|
|
13
13
|
return {
|
|
14
|
-
id: (
|
|
15
|
-
title: (
|
|
16
|
-
start: (
|
|
17
|
-
end: (
|
|
18
|
-
isAllDay: (
|
|
19
|
-
description: (
|
|
14
|
+
id: (t == null ? void 0 : t.id) || "id",
|
|
15
|
+
title: (t == null ? void 0 : t.title) || "title",
|
|
16
|
+
start: (t == null ? void 0 : t.start) || "start",
|
|
17
|
+
end: (t == null ? void 0 : t.end) || "end",
|
|
18
|
+
isAllDay: (t == null ? void 0 : t.isAllDay) || "isAllDay",
|
|
19
|
+
description: (t == null ? void 0 : t.description) || "description"
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
|
|
22
|
+
function N(n) {
|
|
23
|
+
const t = [];
|
|
24
|
+
return w.Children.forEach(n, (e) => {
|
|
25
|
+
if (w.isValidElement(e)) {
|
|
26
|
+
const r = e.props.name;
|
|
27
|
+
r && t.push(r);
|
|
28
28
|
}
|
|
29
|
-
}),
|
|
29
|
+
}), t;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
31
|
+
function g(n, t) {
|
|
32
|
+
const e = n.date;
|
|
33
|
+
if (!e)
|
|
34
34
|
return { content: [{ type: "text", text: "Missing required argument: date" }], isError: !0 };
|
|
35
|
-
const
|
|
36
|
-
if (Number.isNaN(
|
|
37
|
-
return { content: [{ type: "text", text: `Invalid date: ${
|
|
38
|
-
const
|
|
39
|
-
return
|
|
35
|
+
const r = new Date(e);
|
|
36
|
+
if (Number.isNaN(r.getTime()))
|
|
37
|
+
return { content: [{ type: "text", text: `Invalid date: ${e}` }], isError: !0 };
|
|
38
|
+
const i = t.current;
|
|
39
|
+
return i.onDateChange && i.onDateChange({ value: r }), { content: [{ type: "text", text: `Navigated to ${r.toISOString().split("T")[0]}.` }] };
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
41
|
+
function T(n, t) {
|
|
42
|
+
const e = n.view;
|
|
43
|
+
if (!e)
|
|
44
44
|
return { content: [{ type: "text", text: "Missing required argument: view" }], isError: !0 };
|
|
45
|
-
const
|
|
46
|
-
return
|
|
45
|
+
const r = t.current;
|
|
46
|
+
return r.onViewChange && r.onViewChange({ value: e }), { content: [{ type: "text", text: `Switched to ${e} view.` }] };
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
48
|
+
function E(n, t) {
|
|
49
|
+
const e = t.current;
|
|
50
|
+
if (!e.onDataChange)
|
|
51
51
|
return {
|
|
52
52
|
content: [{ type: "text", text: "Scheduler is not editable (no onDataChange handler)." }],
|
|
53
53
|
isError: !0
|
|
54
54
|
};
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
55
|
+
const r = x(e), i = n.title || "New Event", d = n.start, a = n.end;
|
|
56
|
+
if (!d || !a)
|
|
57
57
|
return {
|
|
58
58
|
content: [{ type: "text", text: "Missing required arguments: start and end (ISO strings)" }],
|
|
59
59
|
isError: !0
|
|
60
60
|
};
|
|
61
|
-
const
|
|
62
|
-
if (Number.isNaN(
|
|
61
|
+
const s = new Date(d), o = new Date(a);
|
|
62
|
+
if (Number.isNaN(s.getTime()) || Number.isNaN(o.getTime()))
|
|
63
63
|
return { content: [{ type: "text", text: "Invalid start or end date." }], isError: !0 };
|
|
64
|
-
const
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
69
|
-
[
|
|
64
|
+
const u = {
|
|
65
|
+
[r.id]: Date.now(),
|
|
66
|
+
[r.title]: i,
|
|
67
|
+
[r.start]: s,
|
|
68
|
+
[r.end]: o,
|
|
69
|
+
[r.isAllDay]: n.isAllDay === !0
|
|
70
70
|
};
|
|
71
|
-
return
|
|
72
|
-
content: [{ type: "text", text: `Created event "${
|
|
71
|
+
return n.description && (u[r.description] = n.description), e.onDataChange({ created: [u], updated: [], deleted: [] }), {
|
|
72
|
+
content: [{ type: "text", text: `Created event "${i}" from ${d} to ${a}.` }]
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
75
|
+
function $(n, t) {
|
|
76
|
+
const e = t.current;
|
|
77
|
+
if (!e.onDataChange)
|
|
78
78
|
return {
|
|
79
79
|
content: [{ type: "text", text: "Scheduler is not editable (no onDataChange handler)." }],
|
|
80
80
|
isError: !0
|
|
81
81
|
};
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
82
|
+
const r = x(e), i = n.title;
|
|
83
|
+
if (!i)
|
|
84
84
|
return { content: [{ type: "text", text: "Missing required argument: title" }], isError: !0 };
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
85
|
+
const d = e.data || [], a = n.start, s = d.find((o) => {
|
|
86
|
+
if (h(o[r.title]) !== i)
|
|
87
87
|
return !1;
|
|
88
88
|
if (a) {
|
|
89
|
-
const
|
|
90
|
-
return (
|
|
89
|
+
const u = o[r.start];
|
|
90
|
+
return (u instanceof Date ? u.toISOString() : h(u)).startsWith(a);
|
|
91
91
|
}
|
|
92
92
|
return !0;
|
|
93
93
|
});
|
|
94
|
-
return
|
|
95
|
-
content: [{ type: "text", text: `Deleted event "${
|
|
94
|
+
return s ? (e.onDataChange({ created: [], updated: [], deleted: [s] }), {
|
|
95
|
+
content: [{ type: "text", text: `Deleted event "${h(s[r.title])}".` }]
|
|
96
96
|
}) : {
|
|
97
|
-
content: [{ type: "text", text: `Event "${
|
|
97
|
+
content: [{ type: "text", text: `Event "${i}" not found.` }],
|
|
98
98
|
isError: !0
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
function b(n, t) {
|
|
102
|
+
const e = t.current;
|
|
103
|
+
if (!e.onDataChange)
|
|
104
|
+
return {
|
|
105
|
+
content: [{ type: "text", text: "Scheduler is not editable (no onDataChange handler)." }],
|
|
106
|
+
isError: !0
|
|
107
|
+
};
|
|
108
|
+
const r = x(e), i = n.title;
|
|
109
|
+
if (!i)
|
|
110
|
+
return { content: [{ type: "text", text: "Missing required argument: title" }], isError: !0 };
|
|
111
|
+
const d = e.data || [], a = n.start, s = d.find((c) => {
|
|
112
|
+
if (h(c[r.title]) !== i)
|
|
113
|
+
return !1;
|
|
114
|
+
if (a) {
|
|
115
|
+
const p = c[r.start];
|
|
116
|
+
return (p instanceof Date ? p.toISOString() : h(p)).startsWith(a);
|
|
117
|
+
}
|
|
118
|
+
return !0;
|
|
119
|
+
});
|
|
120
|
+
if (!s)
|
|
121
|
+
return {
|
|
122
|
+
content: [{ type: "text", text: `Event "${i}" not found.` }],
|
|
123
|
+
isError: !0
|
|
124
|
+
};
|
|
125
|
+
const o = { ...s };
|
|
126
|
+
if (n.newTitle && (o[r.title] = n.newTitle), n.newStart) {
|
|
127
|
+
const c = new Date(n.newStart);
|
|
128
|
+
Number.isNaN(c.getTime()) || (o[r.start] = c);
|
|
129
|
+
}
|
|
130
|
+
if (n.newEnd) {
|
|
131
|
+
const c = new Date(n.newEnd);
|
|
132
|
+
Number.isNaN(c.getTime()) || (o[r.end] = c);
|
|
133
|
+
}
|
|
134
|
+
return n.isAllDay !== void 0 && (o[r.isAllDay] = n.isAllDay === !0), n.description !== void 0 && (o[r.description] = n.description), e.onDataChange({ created: [], updated: [o], deleted: [] }), {
|
|
135
|
+
content: [{ type: "text", text: `Updated event "${h(o[r.title])}".` }]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function A(n, t, e) {
|
|
139
|
+
switch (n) {
|
|
140
|
+
case l.Navigate:
|
|
141
|
+
return g(t, e);
|
|
142
|
+
case l.View:
|
|
143
|
+
return T(t, e);
|
|
144
|
+
case l.Create:
|
|
145
|
+
return E(t, e);
|
|
146
|
+
case l.Update:
|
|
147
|
+
return b(t, e);
|
|
148
|
+
case l.Delete:
|
|
149
|
+
return $(t, e);
|
|
111
150
|
default:
|
|
112
|
-
return { content: [{ type: "text", text: `Unknown command: ${
|
|
151
|
+
return { content: [{ type: "text", text: `Unknown command: ${n}` }], isError: !0 };
|
|
113
152
|
}
|
|
114
153
|
}
|
|
115
|
-
const
|
|
154
|
+
const V = {
|
|
116
155
|
componentSuffix: "scheduler",
|
|
117
|
-
createTools(
|
|
118
|
-
const
|
|
156
|
+
createTools(n, t, e, r) {
|
|
157
|
+
const i = [], d = (m) => `${e.groupName}_${m}`, a = t.current, s = N(a.children), o = s.length > 0 ? ` Available views: ${s.join(", ")}.` : "", u = [
|
|
119
158
|
{
|
|
120
159
|
name: "navigate",
|
|
121
|
-
description: `Navigate the ${
|
|
122
|
-
commandType:
|
|
160
|
+
description: `Navigate the ${e.dataName} scheduler to a specific date.`,
|
|
161
|
+
commandType: l.Navigate,
|
|
123
162
|
enabled: !!a.onDateChange
|
|
124
163
|
},
|
|
125
164
|
{
|
|
126
165
|
name: "set_view",
|
|
127
|
-
description: `Switch the ${
|
|
128
|
-
commandType:
|
|
166
|
+
description: `Switch the ${e.dataName} scheduler view.${o}`,
|
|
167
|
+
commandType: l.View,
|
|
129
168
|
enabled: !!a.onViewChange
|
|
130
169
|
},
|
|
131
170
|
{
|
|
132
171
|
name: "create_event",
|
|
133
|
-
description: `Create a new event in the ${
|
|
134
|
-
commandType:
|
|
172
|
+
description: `Create a new event in the ${e.dataName} scheduler.`,
|
|
173
|
+
commandType: l.Create,
|
|
174
|
+
enabled: !!a.onDataChange
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "update_event",
|
|
178
|
+
description: `Update an existing event in the ${e.dataName} scheduler.`,
|
|
179
|
+
commandType: l.Update,
|
|
135
180
|
enabled: !!a.onDataChange
|
|
136
181
|
},
|
|
137
182
|
{
|
|
138
183
|
name: "delete_event",
|
|
139
|
-
description: `Delete an event from the ${
|
|
140
|
-
commandType:
|
|
184
|
+
description: `Delete an event from the ${e.dataName} scheduler.`,
|
|
185
|
+
commandType: l.Delete,
|
|
141
186
|
enabled: !!a.onDataChange
|
|
142
187
|
}
|
|
143
|
-
],
|
|
144
|
-
for (const
|
|
145
|
-
if (!
|
|
188
|
+
], c = t.current.webMcp, p = typeof c == "object" && c !== null && typeof c.tools == "function" ? c.tools : void 0, f = { tname: d, data: a.data }, D = p ? p(u, f) : u;
|
|
189
|
+
for (const m of D) {
|
|
190
|
+
if (!m.enabled)
|
|
146
191
|
continue;
|
|
147
|
-
const
|
|
192
|
+
const y = C(m.commandType), v = m.commandType;
|
|
148
193
|
try {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
name:
|
|
152
|
-
description:
|
|
153
|
-
inputSchema:
|
|
154
|
-
execute: async (
|
|
194
|
+
i.push(
|
|
195
|
+
r.registerTool({
|
|
196
|
+
name: d(m.name),
|
|
197
|
+
description: m.description,
|
|
198
|
+
inputSchema: y,
|
|
199
|
+
execute: async (S) => A(v, S || {}, t)
|
|
155
200
|
})
|
|
156
201
|
);
|
|
157
202
|
} catch {
|
|
158
203
|
}
|
|
159
204
|
}
|
|
160
|
-
return
|
|
205
|
+
return i;
|
|
161
206
|
}
|
|
162
207
|
};
|
|
163
208
|
export {
|
|
164
|
-
|
|
209
|
+
V as schedulerAdapter
|
|
165
210
|
};
|
package/adapters/spreadsheet.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../commands/spreadsheet.js");function l(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.ref;if(!e)return{content:[{type:"text",text:'Missing required argument: ref (e.g. "A1")'}],isError:!0};const a=r.activeSheet();return a?(a.range(e).value(t.value),{content:[{type:"text",text:`Set ${e} = ${JSON.stringify(t.value)}.`}]}):{content:[{type:"text",text:"No active sheet."}],isError:!0}}function f(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.cells;if(!Array.isArray(e)||e.length===0)return{content:[{type:"text",text:"Missing required argument: cells (array of {ref, value})"}],isError:!0};const a=r.activeSheet();if(!a)return{content:[{type:"text",text:"No active sheet."}],isError:!0};for(const s of e)s.ref&&a.range(s.ref).value(s.value);return{content:[{type:"text",text:`Set ${e.length} cell(s).`}]}}function y(t,r){if(!r)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.name;if(!e)return{content:[{type:"text",text:"Missing required argument: name"}],isError:!0};const s=r.sheets().find(o=>o.name()===e);return s?(r.activeSheet(s),{content:[{type:"text",text:`Switched to sheet "${e}".`}]}):{content:[{type:"text",text:`Sheet "${e}" not found.`}],isError:!0}}function v(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=r.instance;if(e.insertSheet){const o=t.name;e.insertSheet(o?{name:o}:void 0)}const a=t.name;return{content:[{type:"text",text:a?'Sheet "'+a+'" added.':"Sheet added."}]}}function C(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.name;if(!e)return{content:[{type:"text",text:"Missing required argument: name"}],isError:!0};const a=r.activeSheet();if(!a)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const s=r.instance;if(s.renameSheet)s.renameSheet(a,e);else return{content:[{type:"text",text:"Rename sheet is not supported by this instance."}],isError:!0};return{content:[{type:"text",text:`Sheet renamed to "${e}".`}]}}function b(t){return t!=null&&t.instance?(t.saveAsExcel({}),{content:[{type:"text",text:"Export triggered."}]}):{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0}}function E(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.ref;if(!e)return{content:[{type:"text",text:'Missing required argument: ref (e.g. "A1")'}],isError:!0};const a=r.activeSheet();if(!a)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const s=a.range(e).value();return{content:[{type:"text",text:JSON.stringify(s)}]}}function N(t){if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const r=t.toJSON();return{content:[{type:"text",text:JSON.stringify(r)}]}}function g(t,r){if(!r)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.data;return!e||typeof e!="object"?{content:[{type:"text",text:"Missing required argument: data (object)"}],isError:!0}:(r.fromJSON(e),{content:[{type:"text",text:"Workbook data loaded."}]})}function T(t){if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.sheets().map(a=>a.name());return{content:[{type:"text",text:JSON.stringify(e)}]}}const $={bold:!0,italic:!0,underline:!0};function w(t,r){var a,s;if(!r)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.command;if(!e)return{content:[{type:"text",text:"Missing required argument: command"}],isError:!0};if($[e]){const o=r.activeSheet();if(!o)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const u=o.activeCell(),m=u?(s=(a=o.range(u))[e])==null?void 0:s.call(a):!1;r.executeCommand({command:"PropertyChangeCommand",options:{property:e,value:!m}})}else{const o=t.options||void 0;r.executeCommand(o?{command:e,...o}:{command:e})}return{content:[{type:"text",text:`Command "${e}" executed.`}]}}const _={componentSuffix:"spreadsheet",createTools(t,r,e,a){const s=[],o=c=>`${e.groupName}_${c}`,u=[{name:"set_cell",description:`Set a cell value in the ${e.dataName} spreadsheet.`,commandType:n.SpreadsheetCommands.SetCell,enabled:!0},{name:"set_cells",description:`Set multiple cell values at once in the ${e.dataName} spreadsheet. Preferred over multiple set_cell calls.`,commandType:n.SpreadsheetCommands.SetCells,enabled:!0},{name:"get_cell",description:`Get the value of a cell in the ${e.dataName} spreadsheet.`,commandType:n.SpreadsheetCommands.GetCell,enabled:!
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../commands/spreadsheet.js");function l(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.ref;if(!e)return{content:[{type:"text",text:'Missing required argument: ref (e.g. "A1")'}],isError:!0};const a=r.activeSheet();return a?(a.range(e).value(t.value),{content:[{type:"text",text:`Set ${e} = ${JSON.stringify(t.value)}.`}]}):{content:[{type:"text",text:"No active sheet."}],isError:!0}}function f(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.cells;if(!Array.isArray(e)||e.length===0)return{content:[{type:"text",text:"Missing required argument: cells (array of {ref, value})"}],isError:!0};const a=r.activeSheet();if(!a)return{content:[{type:"text",text:"No active sheet."}],isError:!0};for(const s of e)s.ref&&a.range(s.ref).value(s.value);return{content:[{type:"text",text:`Set ${e.length} cell(s).`}]}}function y(t,r){if(!r)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.name;if(!e)return{content:[{type:"text",text:"Missing required argument: name"}],isError:!0};const s=r.sheets().find(o=>o.name()===e);return s?(r.activeSheet(s),{content:[{type:"text",text:`Switched to sheet "${e}".`}]}):{content:[{type:"text",text:`Sheet "${e}" not found.`}],isError:!0}}function v(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=r.instance;if(e.insertSheet){const o=t.name;e.insertSheet(o?{name:o}:void 0)}const a=t.name;return{content:[{type:"text",text:a?'Sheet "'+a+'" added.':"Sheet added."}]}}function C(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.name;if(!e)return{content:[{type:"text",text:"Missing required argument: name"}],isError:!0};const a=r.activeSheet();if(!a)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const s=r.instance;if(s.renameSheet)s.renameSheet(a,e);else return{content:[{type:"text",text:"Rename sheet is not supported by this instance."}],isError:!0};return{content:[{type:"text",text:`Sheet renamed to "${e}".`}]}}function b(t){return t!=null&&t.instance?(t.saveAsExcel({}),{content:[{type:"text",text:"Export triggered."}]}):{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0}}function E(t,r){if(!(r!=null&&r.instance))return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.ref;if(!e)return{content:[{type:"text",text:'Missing required argument: ref (e.g. "A1")'}],isError:!0};const a=r.activeSheet();if(!a)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const s=a.range(e).value();return{content:[{type:"text",text:JSON.stringify(s)}]}}function N(t){if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const r=t.toJSON();return{content:[{type:"text",text:JSON.stringify(r)}]}}function g(t,r){if(!r)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.data;return!e||typeof e!="object"?{content:[{type:"text",text:"Missing required argument: data (object)"}],isError:!0}:(r.fromJSON(e),{content:[{type:"text",text:"Workbook data loaded."}]})}function T(t){if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.sheets().map(a=>a.name());return{content:[{type:"text",text:JSON.stringify(e)}]}}const $={bold:!0,italic:!0,underline:!0};function w(t,r){var a,s;if(!r)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const e=t.command;if(!e)return{content:[{type:"text",text:"Missing required argument: command"}],isError:!0};if($[e]){const o=r.activeSheet();if(!o)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const u=o.activeCell(),m=u?(s=(a=o.range(u))[e])==null?void 0:s.call(a):!1;r.executeCommand({command:"PropertyChangeCommand",options:{property:e,value:!m}})}else{const o=t.options||void 0;r.executeCommand(o?{command:e,...o}:{command:e})}return{content:[{type:"text",text:`Command "${e}" executed.`}]}}const _={componentSuffix:"spreadsheet",createTools(t,r,e,a){const s=[],o=c=>`${e.groupName}_${c}`,u=[{name:"set_cell",description:`Set a cell value in the ${e.dataName} spreadsheet.`,commandType:n.SpreadsheetCommands.SetCell,enabled:!0},{name:"set_cells",description:`Set multiple cell values at once in the ${e.dataName} spreadsheet. Preferred over multiple set_cell calls.`,commandType:n.SpreadsheetCommands.SetCells,enabled:!0},{name:"get_cell",description:`Get the value of a cell in the ${e.dataName} spreadsheet.`,commandType:n.SpreadsheetCommands.GetCell,enabled:!1},{name:"get_data",description:`Get the full workbook data from the ${e.dataName} spreadsheet as JSON.`,commandType:n.SpreadsheetCommands.GetData,enabled:!1},{name:"set_data",description:`Load workbook data into the ${e.dataName} spreadsheet from a JSON object.`,commandType:n.SpreadsheetCommands.SetData,enabled:!0},{name:"get_sheets",description:`Get the names of all sheets in the ${e.dataName} spreadsheet.`,commandType:n.SpreadsheetCommands.GetSheets,enabled:!1},{name:"switch_sheet",description:`Switch the active sheet in the ${e.dataName} spreadsheet by name.`,commandType:n.SpreadsheetCommands.SwitchSheet,enabled:!0},{name:"navigate_sheet",description:`Switch the active sheet in the ${e.dataName} spreadsheet.`,commandType:n.SpreadsheetCommands.NavigateSheet,enabled:!0},{name:"add_sheet",description:`Add a new sheet to the ${e.dataName} spreadsheet.`,commandType:n.SpreadsheetCommands.AddSheet,enabled:!0},{name:"rename_sheet",description:`Rename the active sheet in the ${e.dataName} spreadsheet.`,commandType:n.SpreadsheetCommands.RenameSheet,enabled:!0},{name:"export",description:`Export the ${e.dataName} spreadsheet (triggers Excel download).`,commandType:n.SpreadsheetCommands.Export,enabled:!0},{name:"execute_command",description:`Execute a command (e.g. bold, italic, underline, undo, redo) on the selected cells in the ${e.dataName} spreadsheet.`,commandType:n.SpreadsheetCommands.ExecuteCommand,enabled:!0}],m=r.current.webMcp,d=typeof m=="object"&&m!==null&&typeof m.tools=="function"?m.tools:void 0,p=d?d(u):u,x=async(c,i)=>{switch(c){case n.SpreadsheetCommands.SetCell:return l(i,t);case n.SpreadsheetCommands.SetCells:return f(i,t);case n.SpreadsheetCommands.GetCell:return E(i,t);case n.SpreadsheetCommands.GetData:return N(t);case n.SpreadsheetCommands.SetData:return g(i,t);case n.SpreadsheetCommands.GetSheets:return T(t);case n.SpreadsheetCommands.SwitchSheet:case n.SpreadsheetCommands.NavigateSheet:return y(i,t);case n.SpreadsheetCommands.AddSheet:return v(i,t);case n.SpreadsheetCommands.RenameSheet:return C(i,t);case n.SpreadsheetCommands.ExecuteCommand:return w(i,t);case n.SpreadsheetCommands.Export:return b(t);default:return{content:[{type:"text",text:`Unknown command: ${c}`}],isError:!0}}};for(const c of p){if(!c.enabled)continue;const i=n.getSpreadsheetToolSchema(c.commandType),S=c.commandType;try{s.push(a.registerTool({name:o(c.name),description:c.description,inputSchema:i,execute:async h=>x(S,h||{})}))}catch{}}return s}};exports.spreadsheetAdapter=_;
|