@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.
Files changed (78) hide show
  1. package/WebMcpProvider.js +1 -1
  2. package/WebMcpProvider.mjs +84 -80
  3. package/adapters/button.d.ts +1 -1
  4. package/adapters/button.js +1 -1
  5. package/adapters/button.mjs +12 -17
  6. package/adapters/{dashboard.d.ts → checkbox.d.ts} +5 -6
  7. package/adapters/checkbox.js +8 -0
  8. package/adapters/checkbox.mjs +60 -0
  9. package/adapters/dropdowntree.js +1 -1
  10. package/adapters/dropdowntree.mjs +78 -51
  11. package/adapters/editor.d.ts +0 -1
  12. package/adapters/editor.js +1 -1
  13. package/adapters/editor.mjs +38 -46
  14. package/adapters/form.d.ts +1 -0
  15. package/adapters/form.js +3 -3
  16. package/adapters/form.mjs +75 -49
  17. package/adapters/gantt.d.ts +2 -0
  18. package/adapters/gantt.js +1 -1
  19. package/adapters/gantt.mjs +188 -140
  20. package/adapters/grid.d.ts +0 -1
  21. package/adapters/grid.js +1 -1
  22. package/adapters/grid.mjs +52 -60
  23. package/adapters/multicolumncombobox.d.ts +20 -0
  24. package/adapters/multicolumncombobox.js +8 -0
  25. package/adapters/multicolumncombobox.mjs +75 -0
  26. package/adapters/multiselect.d.ts +2 -0
  27. package/adapters/multiselect.js +1 -1
  28. package/adapters/multiselect.mjs +46 -30
  29. package/adapters/notification.js +1 -1
  30. package/adapters/notification.mjs +14 -14
  31. package/adapters/pivotgrid.js +1 -1
  32. package/adapters/pivotgrid.mjs +39 -47
  33. package/adapters/scheduler.js +1 -1
  34. package/adapters/scheduler.mjs +137 -92
  35. package/adapters/spreadsheet.js +1 -1
  36. package/adapters/spreadsheet.mjs +3 -3
  37. package/adapters/switch.js +1 -1
  38. package/adapters/switch.mjs +29 -19
  39. package/adapters/treeview.js +2 -2
  40. package/adapters/treeview.mjs +79 -113
  41. package/adapters/window.d.ts +0 -2
  42. package/adapters/window.js +1 -1
  43. package/adapters/window.mjs +29 -63
  44. package/commands/form.d.ts +4 -1
  45. package/commands/form.js +1 -1
  46. package/commands/form.mjs +11 -7
  47. package/commands/gantt.js +1 -1
  48. package/commands/gantt.mjs +14 -10
  49. package/commands/grid.d.ts +0 -4
  50. package/commands/grid.js +1 -1
  51. package/commands/grid.mjs +18 -24
  52. package/commands/index.d.ts +0 -1
  53. package/commands/pivotgrid.d.ts +0 -4
  54. package/commands/pivotgrid.js +1 -1
  55. package/commands/pivotgrid.mjs +6 -12
  56. package/commands/scheduler.d.ts +10 -0
  57. package/commands/scheduler.js +1 -1
  58. package/commands/scheduler.mjs +16 -4
  59. package/commands/window.d.ts +0 -8
  60. package/commands/window.js +1 -1
  61. package/commands/window.mjs +8 -18
  62. package/dist/cdn/js/kendo-react-webmcp.js +1 -1
  63. package/index.d.mts +2 -1
  64. package/index.d.ts +2 -1
  65. package/index.js +1 -1
  66. package/index.mjs +248 -249
  67. package/package.json +3 -3
  68. package/schemas/gantt.d.ts +4 -0
  69. package/schemas/gantt.js +1 -1
  70. package/schemas/gantt.mjs +93 -8
  71. package/schemas/scheduler.d.ts +2 -0
  72. package/schemas/scheduler.js +1 -1
  73. package/schemas/scheduler.mjs +21 -5
  74. package/adapters/dashboard.js +0 -8
  75. package/adapters/dashboard.mjs +0 -41
  76. package/commands/dashboard.d.ts +0 -19
  77. package/commands/dashboard.js +0 -8
  78. 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 y } from "../commands/notification.mjs";
9
- const w = {
8
+ import { NotificationCommands as i, getNotificationToolSchema as x } from "../commands/notification.mjs";
9
+ const g = {
10
10
  componentSuffix: "notification",
11
- createTools(p, a, c, d) {
12
- const r = [], u = (t) => `${c.groupName}_${t}`, m = [
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
- ], o = a.current.webMcp, l = typeof o == "object" && o !== null && typeof o.tools == "function" ? o.tools : void 0, f = l ? l(m) : m, h = async (t, s) => {
26
- var n, e;
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 (e = (n = a.current).onClose) == null || e.call(n, { syntheticEvent: null, target: p }), { content: [{ type: "text", text: "Notification dismissed." }] };
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 f) {
36
+ for (const t of y) {
37
37
  if (!t.enabled)
38
38
  continue;
39
- const s = y(t.commandType), n = t.commandType;
39
+ const s = x(t.commandType), n = t.commandType, o = t.execute;
40
40
  try {
41
- r.push(
41
+ m.push(
42
42
  d.registerTool({
43
- name: u(t.name),
43
+ name: f(t.name),
44
44
  description: t.description,
45
45
  inputSchema: s,
46
- execute: async (e) => h(n, e || {})
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 r;
52
+ return m;
53
53
  }
54
54
  };
55
55
  export {
56
- w as notificationAdapter
56
+ g as notificationAdapter
57
57
  };
@@ -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 t=require("../commands/pivotgrid.js"),E={componentSuffix:"pivotgrid",createTools(d,i,o,h){const m=[],P=n=>`${o.groupName}_${n}`,l=[{name:"set_rows",description:`Set the row fields of the ${o.dataName} pivot grid`,commandType:t.PivotGridCommands.SetRows,enabled:!0},{name:"set_columns",description:`Set the column fields of the ${o.dataName} pivot grid`,commandType:t.PivotGridCommands.SetColumns,enabled:!0},{name:"set_measures",description:`Set the measure fields of the ${o.dataName} pivot grid`,commandType:t.PivotGridCommands.SetMeasures,enabled:!0},{name:"expand",description:`Expand a row or column header in the ${o.dataName} pivot grid`,commandType:t.PivotGridCommands.Expand,enabled:!0},{name:"collapse",description:`Collapse a row or column header in the ${o.dataName} pivot grid`,commandType:t.PivotGridCommands.Collapse,enabled:!0},{name:"export_pdf",description:`Export the ${o.dataName} pivot grid to PDF`,commandType:t.PivotGridCommands.ExportPDF,enabled:!0}],r=i.current.webMcp,c=typeof r=="object"&&r!==null&&typeof r.tools=="function"?r.tools:void 0,S=c?c(l):l,$=async(n,e)=>{var a,s,u,p,v,y,x,f,C,g;switch(n){case t.PivotGridCommands.SetRows:return(s=(a=i.current).onConfigChange)==null||s.call(a,{type:"rows",fields:e.fields,syntheticEvent:null,target:d}),{content:[{type:"text",text:`Pivot grid rows set to: ${JSON.stringify(e.fields)}.`}]};case t.PivotGridCommands.SetColumns:return(p=(u=i.current).onConfigChange)==null||p.call(u,{type:"columns",fields:e.fields,syntheticEvent:null,target:d}),{content:[{type:"text",text:`Pivot grid columns set to: ${JSON.stringify(e.fields)}.`}]};case t.PivotGridCommands.SetMeasures:return(y=(v=i.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 t.PivotGridCommands.Expand:return(f=(x=i.current).onExpandChange)==null||f.call(x,{field:e.field,value:e.value,expanded:!0,syntheticEvent:null,target:d}),{content:[{type:"text",text:`Expanded "${String(e.field)}: ${String(e.value)}".`}]};case t.PivotGridCommands.Collapse:return(g=(C=i.current).onExpandChange)==null||g.call(C,{field:e.field,value:e.value,expanded:!1,syntheticEvent:null,target:d}),{content:[{type:"text",text:`Collapsed "${String(e.field)}: ${String(e.value)}".`}]};case t.PivotGridCommands.ExportPDF:return{content:[{type:"text",text:"Pivot grid PDF export initiated."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const n of S){if(!n.enabled)continue;const e=t.getPivotGridToolSchema(n.commandType),a=n.commandType;try{m.push(h.registerTool({name:P(n.name),description:n.description,inputSchema:e,execute:async s=>$(a,s||{})}))}catch{}}return m}};exports.pivotgridAdapter=E;
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;
@@ -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 t, getPivotGridToolSchema as w } from "../commands/pivotgrid.mjs";
8
+ import { PivotGridCommands as n, getPivotGridToolSchema as E } from "../commands/pivotgrid.mjs";
9
9
  const b = {
10
10
  componentSuffix: "pivotgrid",
11
- createTools(a, i, o, g) {
12
- const l = [], C = (n) => `${o.groupName}_${n}`, c = [
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 ${o.dataName} pivot grid`,
16
- commandType: t.SetRows,
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 ${o.dataName} pivot grid`,
22
- commandType: t.SetColumns,
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 ${o.dataName} pivot grid`,
28
- commandType: t.SetMeasures,
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 ${o.dataName} pivot grid`,
34
- commandType: t.Expand,
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 ${o.dataName} pivot grid`,
40
- commandType: t.Collapse,
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
- ], r = i.current.webMcp, u = typeof r == "object" && r !== null && typeof r.tools == "function" ? r.tools : void 0, $ = u ? u(c) : c, E = async (n, e) => {
50
- var d, s, p, m, x, y, f, v, h, S;
51
- switch (n) {
52
- case t.SetRows:
53
- return (s = (d = i.current).onConfigChange) == null || s.call(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: a
51
+ target: r
58
52
  }), {
59
53
  content: [{ type: "text", text: `Pivot grid rows set to: ${JSON.stringify(e.fields)}.` }]
60
54
  };
61
- case t.SetColumns:
62
- return (m = (p = i.current).onConfigChange) == null || m.call(p, {
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: a
60
+ target: r
67
61
  }), {
68
62
  content: [{ type: "text", text: `Pivot grid columns set to: ${JSON.stringify(e.fields)}.` }]
69
63
  };
70
- case t.SetMeasures:
71
- return (y = (x = i.current).onConfigChange) == null || y.call(x, {
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: a
69
+ target: r
76
70
  }), {
77
71
  content: [{ type: "text", text: `Pivot grid measures set to: ${JSON.stringify(e.fields)}.` }]
78
72
  };
79
- case t.Expand:
80
- return (v = (f = i.current).onExpandChange) == null || v.call(f, {
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: a
79
+ target: r
86
80
  }), {
87
81
  content: [{ type: "text", text: `Expanded "${String(e.field)}: ${String(e.value)}".` }]
88
82
  };
89
- case t.Collapse:
90
- return (S = (h = i.current).onExpandChange) == null || S.call(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: a
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: ${n}` }], isError: !0 };
94
+ return { content: [{ type: "text", text: `Unknown command: ${t}` }], isError: !0 };
103
95
  }
104
96
  };
105
- for (const n of $) {
106
- if (!n.enabled)
97
+ for (const t of $) {
98
+ if (!t.enabled)
107
99
  continue;
108
- const e = w(n.commandType), d = n.commandType;
100
+ const e = t.inputSchema || E(t.commandType), d = t.commandType, s = t.execute;
109
101
  try {
110
102
  l.push(
111
- g.registerTool({
112
- name: C(n.name),
113
- description: n.description,
103
+ C.registerTool({
104
+ name: g(t.name),
105
+ description: t.description,
114
106
  inputSchema: e,
115
- execute: async (s) => E(d, s || {})
107
+ execute: s ? async (a) => await s(a || {}) : async (a) => w(d, a || {})
116
108
  })
117
109
  );
118
110
  } catch {
@@ -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 w=require("react"),s=require("../commands/scheduler.js"),h=require("./utils.js");function D(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 x=D(w);function g(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 x.Children.forEach(n,t=>{if(x.isValidElement(t)){const r=t.props.name;r&&e.push(r)}}),e}function b(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 o=e.current;return o.onDateChange&&o.onDateChange({value:r}),{content:[{type:"text",text:`Navigated to ${r.toISOString().split("T")[0]}.`}]}}function T(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 $(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=g(t),o=n.title||"New Event",d=n.start,a=n.end;if(!d||!a)return{content:[{type:"text",text:"Missing required arguments: start and end (ISO strings)"}],isError:!0};const i=new Date(d),u=new Date(a);if(Number.isNaN(i.getTime())||Number.isNaN(u.getTime()))return{content:[{type:"text",text:"Invalid start or end date."}],isError:!0};const c={[r.id]:Date.now(),[r.title]:o,[r.start]:i,[r.end]:u,[r.isAllDay]:n.isAllDay===!0};return n.description&&(c[r.description]=n.description),t.onDataChange({created:[c],updated:[],deleted:[]}),{content:[{type:"text",text:`Created event "${o}" from ${d} to ${a}.`}]}}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=g(t),o=n.title;if(!o)return{content:[{type:"text",text:"Missing required argument: title"}],isError:!0};const d=t.data||[],a=n.start,i=d.find(u=>{if(h.toText(u[r.title])!==o)return!1;if(a){const c=u[r.start];return(c instanceof Date?c.toISOString():h.toText(c)).startsWith(a)}return!0});return i?(t.onDataChange({created:[],updated:[],deleted:[i]}),{content:[{type:"text",text:`Deleted event "${h.toText(i[r.title])}".`}]}):{content:[{type:"text",text:`Event "${o}" not found.`}],isError:!0}}function O(n,e,t){switch(n){case s.SchedulerCommands.Navigate:return b(e,t);case s.SchedulerCommands.View:return T(e,t);case s.SchedulerCommands.Create:return $(e,t);case s.SchedulerCommands.Delete:return E(e,t);default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}}const M={componentSuffix:"scheduler",createTools(n,e,t,r){const o=[],d=l=>`${t.groupName}_${l}`,a=e.current,i=N(a.children),u=i.length>0?` Available views: ${i.join(", ")}.`:"",c=[{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.${u}`,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:"delete_event",description:`Delete an event from the ${t.dataName} scheduler.`,commandType:s.SchedulerCommands.Delete,enabled:!!a.onDataChange}],m=e.current.webMcp,p=typeof m=="object"&&m!==null&&typeof m.tools=="function"?m.tools:void 0,C={tname:d,data:a.data},S=p?p(c,C):c;for(const l of S){if(!l.enabled)continue;const f=s.getSchedulerToolSchema(l.commandType),y=l.commandType;try{o.push(r.registerTool({name:d(l.name),description:l.description,inputSchema:f,execute:async v=>O(y,v||{},e)}))}catch{}}return o}};exports.schedulerAdapter=M;
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;
@@ -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 x from "react";
9
- import { SchedulerCommands as d, getSchedulerToolSchema as f } from "../commands/scheduler.mjs";
10
- import { toText as p } from "./utils.mjs";
11
- function w(r) {
12
- const e = r.modelFields;
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: (e == null ? void 0 : e.id) || "id",
15
- title: (e == null ? void 0 : e.title) || "title",
16
- start: (e == null ? void 0 : e.start) || "start",
17
- end: (e == null ? void 0 : e.end) || "end",
18
- isAllDay: (e == null ? void 0 : e.isAllDay) || "isAllDay",
19
- description: (e == null ? void 0 : e.description) || "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 S(r) {
23
- const e = [];
24
- return x.Children.forEach(r, (t) => {
25
- if (x.isValidElement(t)) {
26
- const n = t.props.name;
27
- n && e.push(n);
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
- }), e;
29
+ }), t;
30
30
  }
31
- function N(r, e) {
32
- const t = r.date;
33
- if (!t)
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 n = new Date(t);
36
- if (Number.isNaN(n.getTime()))
37
- return { content: [{ type: "text", text: `Invalid date: ${t}` }], isError: !0 };
38
- const o = e.current;
39
- return o.onDateChange && o.onDateChange({ value: n }), { content: [{ type: "text", text: `Navigated to ${n.toISOString().split("T")[0]}.` }] };
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 $(r, e) {
42
- const t = r.view;
43
- if (!t)
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 n = e.current;
46
- return n.onViewChange && n.onViewChange({ value: t }), { content: [{ type: "text", text: `Switched to ${t} view.` }] };
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 b(r, e) {
49
- const t = e.current;
50
- if (!t.onDataChange)
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 n = w(t), o = r.title || "New Event", s = r.start, a = r.end;
56
- if (!s || !a)
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 i = new Date(s), u = new Date(a);
62
- if (Number.isNaN(i.getTime()) || Number.isNaN(u.getTime()))
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 c = {
65
- [n.id]: Date.now(),
66
- [n.title]: o,
67
- [n.start]: i,
68
- [n.end]: u,
69
- [n.isAllDay]: r.isAllDay === !0
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 r.description && (c[n.description] = r.description), t.onDataChange({ created: [c], updated: [], deleted: [] }), {
72
- content: [{ type: "text", text: `Created event "${o}" from ${s} to ${a}.` }]
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 T(r, e) {
76
- const t = e.current;
77
- if (!t.onDataChange)
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 n = w(t), o = r.title;
83
- if (!o)
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 s = t.data || [], a = r.start, i = s.find((u) => {
86
- if (p(u[n.title]) !== o)
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 c = u[n.start];
90
- return (c instanceof Date ? c.toISOString() : p(c)).startsWith(a);
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 i ? (t.onDataChange({ created: [], updated: [], deleted: [i] }), {
95
- content: [{ type: "text", text: `Deleted event "${p(i[n.title])}".` }]
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 "${o}" not found.` }],
97
+ content: [{ type: "text", text: `Event "${i}" not found.` }],
98
98
  isError: !0
99
99
  };
100
100
  }
101
- function E(r, e, t) {
102
- switch (r) {
103
- case d.Navigate:
104
- return N(e, t);
105
- case d.View:
106
- return $(e, t);
107
- case d.Create:
108
- return b(e, t);
109
- case d.Delete:
110
- return T(e, t);
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: ${r}` }], isError: !0 };
151
+ return { content: [{ type: "text", text: `Unknown command: ${n}` }], isError: !0 };
113
152
  }
114
153
  }
115
- const M = {
154
+ const V = {
116
155
  componentSuffix: "scheduler",
117
- createTools(r, e, t, n) {
118
- const o = [], s = (l) => `${t.groupName}_${l}`, a = e.current, i = S(a.children), u = i.length > 0 ? ` Available views: ${i.join(", ")}.` : "", c = [
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 ${t.dataName} scheduler to a specific date.`,
122
- commandType: d.Navigate,
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 ${t.dataName} scheduler view.${u}`,
128
- commandType: d.View,
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 ${t.dataName} scheduler.`,
134
- commandType: d.Create,
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 ${t.dataName} scheduler.`,
140
- commandType: d.Delete,
184
+ description: `Delete an event from the ${e.dataName} scheduler.`,
185
+ commandType: l.Delete,
141
186
  enabled: !!a.onDataChange
142
187
  }
143
- ], m = e.current.webMcp, h = typeof m == "object" && m !== null && typeof m.tools == "function" ? m.tools : void 0, v = { tname: s, data: a.data }, y = h ? h(c, v) : c;
144
- for (const l of y) {
145
- if (!l.enabled)
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 g = f(l.commandType), C = l.commandType;
192
+ const y = C(m.commandType), v = m.commandType;
148
193
  try {
149
- o.push(
150
- n.registerTool({
151
- name: s(l.name),
152
- description: l.description,
153
- inputSchema: g,
154
- execute: async (D) => E(C, D || {}, e)
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 o;
205
+ return i;
161
206
  }
162
207
  };
163
208
  export {
164
- M as schedulerAdapter
209
+ V as schedulerAdapter
165
210
  };
@@ -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:!0},{name:"get_data",description:`Get the full workbook data from the ${e.dataName} spreadsheet as JSON.`,commandType:n.SpreadsheetCommands.GetData,enabled:!0},{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:!0},{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=_;
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=_;