@seastudio/sdk 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +108 -0
  2. package/bin/seastudio.js +3 -0
  3. package/dist/chunk-4ITOR5QE.js +901 -0
  4. package/dist/chunk-5QAINQWV.js +94 -0
  5. package/dist/chunk-6USQFZRH.js +291 -0
  6. package/dist/chunk-AGBZJGTY.cjs +1311 -0
  7. package/dist/chunk-ANWOL7SM.js +566 -0
  8. package/dist/chunk-BWG45ZWF.cjs +305 -0
  9. package/dist/chunk-CVF4QHS6.cjs +436 -0
  10. package/dist/chunk-DDVRUPMZ.js +1293 -0
  11. package/dist/chunk-DSOSHJH2.js +643 -0
  12. package/dist/chunk-FLATZQA2.js +174 -0
  13. package/dist/chunk-HJJTBVKQ.cjs +909 -0
  14. package/dist/chunk-ISI2OLPI.cjs +179 -0
  15. package/dist/chunk-MYURVLGP.cjs +165 -0
  16. package/dist/chunk-N33Y5NY7.cjs +105 -0
  17. package/dist/chunk-QD4KISXM.js +160 -0
  18. package/dist/chunk-SNGU4SHO.cjs +654 -0
  19. package/dist/chunk-TFOJLA2F.cjs +588 -0
  20. package/dist/chunk-Z7LV7DCO.js +429 -0
  21. package/dist/develop-tool/cli/index.cjs +1138 -0
  22. package/dist/develop-tool/cli/index.d.cts +1 -0
  23. package/dist/develop-tool/cli/index.d.ts +1 -0
  24. package/dist/develop-tool/cli/index.js +1127 -0
  25. package/dist/index.cjs +370 -0
  26. package/dist/index.d.cts +11 -0
  27. package/dist/index.d.ts +11 -0
  28. package/dist/index.js +9 -0
  29. package/dist/mcp/core/index.cjs +90 -0
  30. package/dist/mcp/core/index.d.cts +124 -0
  31. package/dist/mcp/core/index.d.ts +124 -0
  32. package/dist/mcp/core/index.js +1 -0
  33. package/dist/mcp/index.cjs +317 -0
  34. package/dist/mcp/index.d.cts +123 -0
  35. package/dist/mcp/index.d.ts +123 -0
  36. package/dist/mcp/index.js +8 -0
  37. package/dist/mcp/plugin-editor/index.cjs +47 -0
  38. package/dist/mcp/plugin-editor/index.d.cts +98 -0
  39. package/dist/mcp/plugin-editor/index.d.ts +98 -0
  40. package/dist/mcp/plugin-editor/index.js +2 -0
  41. package/dist/mcp/plugin-excel/index.cjs +31 -0
  42. package/dist/mcp/plugin-excel/index.d.cts +86 -0
  43. package/dist/mcp/plugin-excel/index.d.ts +86 -0
  44. package/dist/mcp/plugin-excel/index.js +2 -0
  45. package/dist/mcp/plugin-preview/index.cjs +23 -0
  46. package/dist/mcp/plugin-preview/index.d.cts +109 -0
  47. package/dist/mcp/plugin-preview/index.d.ts +109 -0
  48. package/dist/mcp/plugin-preview/index.js +2 -0
  49. package/dist/mcp/plugin-seaflow/index.cjs +35 -0
  50. package/dist/mcp/plugin-seaflow/index.d.cts +318 -0
  51. package/dist/mcp/plugin-seaflow/index.d.ts +318 -0
  52. package/dist/mcp/plugin-seaflow/index.js +2 -0
  53. package/dist/mcp/seastudio/index.cjs +75 -0
  54. package/dist/mcp/seastudio/index.d.cts +341 -0
  55. package/dist/mcp/seastudio/index.d.ts +341 -0
  56. package/dist/mcp/seastudio/index.js +2 -0
  57. package/dist/tools-LMW67LIY.js +2 -0
  58. package/dist/tools-TU7PBMDO.cjs +23 -0
  59. package/dist/types-Clgf5gBf.d.cts +107 -0
  60. package/dist/types-Clgf5gBf.d.ts +107 -0
  61. package/dist/ui/index.cjs +58 -0
  62. package/dist/ui/index.d.cts +142 -0
  63. package/dist/ui/index.d.ts +142 -0
  64. package/dist/ui/index.js +1 -0
  65. package/package.json +115 -0
  66. package/src/develop-tool/templates/plugin/README.md.tmpl +36 -0
  67. package/src/develop-tool/templates/plugin/frontend/index.html.tmpl +12 -0
  68. package/src/develop-tool/templates/plugin/frontend/package.json.tmpl +30 -0
  69. package/src/develop-tool/templates/plugin/frontend/postcss.config.js +6 -0
  70. package/src/develop-tool/templates/plugin/frontend/src/App.css +43 -0
  71. package/src/develop-tool/templates/plugin/frontend/src/App.tsx.tmpl +43 -0
  72. package/src/develop-tool/templates/plugin/frontend/src/main.tsx +10 -0
  73. package/src/develop-tool/templates/plugin/frontend/src/vite-env.d.ts +1 -0
  74. package/src/develop-tool/templates/plugin/frontend/tsconfig.json +20 -0
  75. package/src/develop-tool/templates/plugin/frontend/vite.config.ts +12 -0
  76. package/src/develop-tool/templates/plugin/seastudio.config.json.tmpl +14 -0
  77. package/src/ui/cosmos.css +407 -0
@@ -0,0 +1,94 @@
1
+ import { allTools as allTools$3 } from './chunk-Z7LV7DCO.js';
2
+ import { allTools } from './chunk-DDVRUPMZ.js';
3
+ import { tools as tools$1 } from './chunk-FLATZQA2.js';
4
+ import { allTools as allTools$1 } from './chunk-DSOSHJH2.js';
5
+ import { tools } from './chunk-QD4KISXM.js';
6
+ import { allTools as allTools$2 } from './chunk-4ITOR5QE.js';
7
+ import { normalizeMCPTool, normalizeMCPToolObjectSchema } from './chunk-ANWOL7SM.js';
8
+
9
+ // src/mcp/index.ts
10
+ async function loadPlugin(pluginName) {
11
+ switch (pluginName) {
12
+ case "seastudio":
13
+ return import('./mcp/seastudio/index.js');
14
+ case "plugin-editor":
15
+ case "editor":
16
+ return import('./mcp/plugin-editor/index.js');
17
+ case "plugin-preview":
18
+ case "preview":
19
+ return import('./mcp/plugin-preview/index.js');
20
+ case "plugin-seaflow":
21
+ case "seaflow":
22
+ return import('./mcp/plugin-seaflow/index.js');
23
+ case "plugin-shell":
24
+ case "shell":
25
+ return import('./tools-LMW67LIY.js');
26
+ case "plugin-excel":
27
+ case "excel":
28
+ return import('./mcp/plugin-excel/index.js');
29
+ default:
30
+ throw new Error(`Unknown plugin: ${pluginName}`);
31
+ }
32
+ }
33
+ var MCP_PACKAGES = [
34
+ { id: "seastudio", name: "SeaStudio", description: "\u6587\u4EF6/Shell/Git \u57FA\u7840\u80FD\u529B", tools: allTools },
35
+ { id: "codeEditor", name: "Code Editor", description: "\u4EE3\u7801\u7F16\u8F91\u5668\u80FD\u529B", tools: allTools$1 },
36
+ { id: "preview", name: "Preview", description: "\u9884\u89C8\u5668\u80FD\u529B", tools },
37
+ { id: "seaflow", name: "SeaFlow", description: "\u6D41\u7A0B\u753B\u5E03\u6267\u884C\u4E0E\u7F16\u6392\u80FD\u529B", tools: allTools$2 },
38
+ { id: "shell", name: "Shell", description: "Shell \u4F1A\u8BDD\u4E0E\u547D\u4EE4\u6267\u884C\u80FD\u529B", tools: tools$1 },
39
+ { id: "excel", name: "Excel", description: "Excel \u7535\u5B50\u8868\u683C\u64CD\u4F5C\u80FD\u529B", tools: allTools$3 }
40
+ ];
41
+ function mcpToolToOpenAI(tool) {
42
+ const normalizedTool = normalizeMCPTool(tool);
43
+ const outputSchema = normalizedTool.outputSchema ? normalizeMCPToolObjectSchema(normalizedTool.outputSchema) : void 0;
44
+ return {
45
+ type: "function",
46
+ ...normalizedTool.annotations ? { annotations: { ...normalizedTool.annotations } } : {},
47
+ ...outputSchema ? { outputSchema } : {},
48
+ function: {
49
+ name: normalizedTool.name,
50
+ description: normalizedTool.description,
51
+ parameters: normalizeMCPToolObjectSchema(normalizedTool.inputSchema),
52
+ ...outputSchema ? { outputSchema } : {}
53
+ }
54
+ };
55
+ }
56
+ function listAllTools() {
57
+ const tools7 = [];
58
+ for (const pkg of MCP_PACKAGES) {
59
+ tools7.push(...pkg.tools);
60
+ }
61
+ return tools7;
62
+ }
63
+ var listAvailableTools = listAllTools;
64
+ var MCP_TOOL_PACKAGE_INDEX = new Map(
65
+ MCP_PACKAGES.flatMap((pkg) => pkg.tools.map((tool) => [tool.name, pkg.id]))
66
+ );
67
+ function getMCPToolPackageIndex() {
68
+ return new Map(MCP_TOOL_PACKAGE_INDEX);
69
+ }
70
+ function getMCPPackageIdForTool(toolName) {
71
+ return MCP_TOOL_PACKAGE_INDEX.get(toolName) ?? null;
72
+ }
73
+ function listAvailableToolsForLLM() {
74
+ return listAvailableTools().map(mcpToolToOpenAI);
75
+ }
76
+ function getMCPPackages() {
77
+ return MCP_PACKAGES.map((pkg) => ({
78
+ id: pkg.id,
79
+ name: pkg.name,
80
+ description: pkg.description,
81
+ toolCount: pkg.tools.length
82
+ }));
83
+ }
84
+ function getToolsForLLM(disabledPackages) {
85
+ const tools7 = [];
86
+ for (const pkg of MCP_PACKAGES) {
87
+ if (!disabledPackages.has(pkg.id)) {
88
+ tools7.push(...pkg.tools.map(mcpToolToOpenAI));
89
+ }
90
+ }
91
+ return tools7;
92
+ }
93
+
94
+ export { MCP_PACKAGES, getMCPPackageIdForTool, getMCPPackages, getMCPToolPackageIndex, getToolsForLLM, listAllTools, listAvailableTools, listAvailableToolsForLLM, loadPlugin, mcpToolToOpenAI };
@@ -0,0 +1,291 @@
1
+ import { X } from 'lucide-react';
2
+ import { clsx } from 'clsx';
3
+ import { twMerge } from 'tailwind-merge';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+
6
+ // src/ui/Tab.tsx
7
+ function cn(...inputs) {
8
+ return twMerge(clsx(inputs));
9
+ }
10
+ function Tab({
11
+ isActive,
12
+ onClick,
13
+ onClose,
14
+ icon,
15
+ title,
16
+ className,
17
+ disabled = false
18
+ }) {
19
+ return /* @__PURE__ */ jsxs(
20
+ "div",
21
+ {
22
+ onClick: () => {
23
+ if (!disabled) {
24
+ onClick();
25
+ }
26
+ },
27
+ className: cn(
28
+ "group flex items-center gap-2 px-3 h-7",
29
+ "transition-colors duration-150",
30
+ disabled ? isActive ? "text-muted-foreground bg-transparent border-b-2 border-muted-foreground/50 cursor-not-allowed" : "text-muted-foreground/50 bg-transparent border-b-2 border-transparent cursor-not-allowed" : isActive ? "text-foreground bg-muted border-b-2 border-primary cursor-pointer" : "text-muted-foreground hover:text-foreground hover:bg-muted/50 border-b-2 border-transparent cursor-pointer",
31
+ className
32
+ ),
33
+ children: [
34
+ icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: icon }),
35
+ title && /* @__PURE__ */ jsx("span", { className: "text-sm truncate max-w-[120px]", children: title }),
36
+ onClose && /* @__PURE__ */ jsx(
37
+ "button",
38
+ {
39
+ onClick: (e) => {
40
+ e.stopPropagation();
41
+ if (!disabled) {
42
+ onClose();
43
+ }
44
+ },
45
+ disabled,
46
+ className: cn(
47
+ "p-0.5 transition-all flex-shrink-0",
48
+ "opacity-0 group-hover:opacity-100",
49
+ isActive && "opacity-60",
50
+ !disabled && "hover:bg-foreground/10",
51
+ disabled && "cursor-not-allowed opacity-0"
52
+ ),
53
+ title: "\u5173\u95ED",
54
+ children: /* @__PURE__ */ jsx(X, { className: "w-3 h-3 text-muted-foreground/70" })
55
+ }
56
+ )
57
+ ]
58
+ }
59
+ );
60
+ }
61
+ function MenuContainer({
62
+ children,
63
+ className
64
+ }) {
65
+ return /* @__PURE__ */ jsx(
66
+ "div",
67
+ {
68
+ className: cn(
69
+ "bg-popover border border-border rounded-md shadow-lg py-1 min-w-[140px]",
70
+ className
71
+ ),
72
+ children
73
+ }
74
+ );
75
+ }
76
+ function MenuItem({
77
+ label,
78
+ icon,
79
+ shortcut,
80
+ disabled,
81
+ danger,
82
+ onClick,
83
+ className
84
+ }) {
85
+ return /* @__PURE__ */ jsx("div", { className: "px-1", children: /* @__PURE__ */ jsxs(
86
+ "button",
87
+ {
88
+ onClick: () => {
89
+ if (!disabled) {
90
+ onClick();
91
+ }
92
+ },
93
+ disabled,
94
+ className: cn(
95
+ "w-full flex items-center gap-2 px-2 py-1.5 text-xs text-left transition-colors rounded-md",
96
+ disabled ? "text-muted-foreground/50 cursor-not-allowed" : "hover:bg-muted",
97
+ danger && !disabled && "text-red-500",
98
+ className
99
+ ),
100
+ children: [
101
+ icon && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 w-3.5 h-3.5", children: icon }),
102
+ /* @__PURE__ */ jsx("span", { className: "flex-1 whitespace-nowrap", children: label }),
103
+ shortcut && /* @__PURE__ */ jsx("span", { className: "ml-auto text-muted-foreground text-[10px] whitespace-nowrap", children: shortcut })
104
+ ]
105
+ }
106
+ ) });
107
+ }
108
+ function MenuSeparator({
109
+ className
110
+ }) {
111
+ return /* @__PURE__ */ jsx("div", { className: cn("border-t border-border my-1", className) });
112
+ }
113
+ function MenuEmpty({
114
+ children,
115
+ className
116
+ }) {
117
+ return /* @__PURE__ */ jsx("div", { className: cn("px-3 py-2 text-xs text-muted-foreground", className), children });
118
+ }
119
+
120
+ // src/ui/context-menu.ts
121
+ var CONTEXT_MENU_TIMEOUT_MS = 3e4;
122
+ function canUseHostBridge() {
123
+ if (typeof window === "undefined") return false;
124
+ return !!window.parent && window.parent !== window;
125
+ }
126
+ function createRequestId() {
127
+ return `sdk-cm-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
128
+ }
129
+ function isContextMenuResultMessage(data) {
130
+ return typeof data === "object" && data !== null && data.type === "context_menu_result" && typeof data.id === "string";
131
+ }
132
+ async function showHostContextMenu(x, y, items) {
133
+ if (!canUseHostBridge()) {
134
+ return { supported: false, selectedId: null };
135
+ }
136
+ const requestId = createRequestId();
137
+ return new Promise((resolve) => {
138
+ let settled = false;
139
+ const timeoutId = setTimeout(() => {
140
+ if (settled) return;
141
+ settled = true;
142
+ window.removeEventListener("message", onMessage);
143
+ resolve({ supported: true, selectedId: null });
144
+ }, CONTEXT_MENU_TIMEOUT_MS);
145
+ const onMessage = (event) => {
146
+ if (event.source !== window.parent) return;
147
+ if (!isContextMenuResultMessage(event.data)) return;
148
+ if (event.data.id !== requestId) return;
149
+ if (settled) return;
150
+ settled = true;
151
+ clearTimeout(timeoutId);
152
+ window.removeEventListener("message", onMessage);
153
+ resolve({ supported: true, selectedId: event.data.itemId ?? null });
154
+ };
155
+ window.addEventListener("message", onMessage);
156
+ const message = {
157
+ type: "context_menu_show",
158
+ id: requestId,
159
+ x,
160
+ y,
161
+ items
162
+ };
163
+ window.parent.postMessage(message, "*");
164
+ });
165
+ }
166
+ function DialogOverlay({
167
+ children,
168
+ onClose,
169
+ className
170
+ }) {
171
+ return /* @__PURE__ */ jsxs(
172
+ "div",
173
+ {
174
+ className: cn(
175
+ "fixed inset-0 z-[100] flex items-center justify-center",
176
+ className
177
+ ),
178
+ children: [
179
+ /* @__PURE__ */ jsx(
180
+ "div",
181
+ {
182
+ className: "absolute inset-0 bg-black/50",
183
+ onClick: onClose
184
+ }
185
+ ),
186
+ children
187
+ ]
188
+ }
189
+ );
190
+ }
191
+ function DialogContainer({
192
+ children,
193
+ width = "md",
194
+ className
195
+ }) {
196
+ const widthClass = typeof width === "number" ? void 0 : {
197
+ sm: "w-[320px]",
198
+ md: "w-[400px]",
199
+ lg: "w-[520px]"
200
+ }[width];
201
+ const widthStyle = typeof width === "number" ? { width } : void 0;
202
+ return /* @__PURE__ */ jsx(
203
+ "div",
204
+ {
205
+ className: cn(
206
+ "relative bg-popover border border-border rounded-lg shadow-xl max-w-[90vw]",
207
+ widthClass,
208
+ className
209
+ ),
210
+ style: widthStyle,
211
+ onClick: (e) => e.stopPropagation(),
212
+ children
213
+ }
214
+ );
215
+ }
216
+ function DialogHeader({
217
+ title,
218
+ onClose,
219
+ className
220
+ }) {
221
+ return /* @__PURE__ */ jsxs(
222
+ "div",
223
+ {
224
+ className: cn(
225
+ "flex items-center justify-between h-12 px-4 border-b border-border",
226
+ className
227
+ ),
228
+ children: [
229
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: title }),
230
+ onClose && /* @__PURE__ */ jsx(
231
+ "button",
232
+ {
233
+ onClick: onClose,
234
+ className: "p-1 hover:bg-muted rounded transition-colors",
235
+ children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4 text-muted-foreground" })
236
+ }
237
+ )
238
+ ]
239
+ }
240
+ );
241
+ }
242
+ function DialogBody({
243
+ children,
244
+ className
245
+ }) {
246
+ return /* @__PURE__ */ jsx("div", { className: cn("p-4", className), children });
247
+ }
248
+ function DialogFooter({
249
+ children,
250
+ className
251
+ }) {
252
+ return /* @__PURE__ */ jsx(
253
+ "div",
254
+ {
255
+ className: cn(
256
+ "flex items-center justify-end gap-2 h-14 px-4 border-t border-border",
257
+ className
258
+ ),
259
+ children
260
+ }
261
+ );
262
+ }
263
+ function DialogButton({
264
+ children,
265
+ variant = "secondary",
266
+ disabled,
267
+ onClick,
268
+ className
269
+ }) {
270
+ const variantClasses = {
271
+ primary: "bg-primary text-primary-foreground hover:bg-primary/90",
272
+ secondary: "text-muted-foreground hover:text-foreground hover:bg-muted",
273
+ danger: "bg-red-500 text-white hover:bg-red-600"
274
+ };
275
+ return /* @__PURE__ */ jsx(
276
+ "button",
277
+ {
278
+ onClick,
279
+ disabled,
280
+ className: cn(
281
+ "h-8 px-4 text-sm rounded transition-colors",
282
+ variantClasses[variant],
283
+ disabled && "opacity-50 cursor-not-allowed",
284
+ className
285
+ ),
286
+ children
287
+ }
288
+ );
289
+ }
290
+
291
+ export { DialogBody, DialogButton, DialogContainer, DialogFooter, DialogHeader, DialogOverlay, MenuContainer, MenuEmpty, MenuItem, MenuSeparator, Tab, cn, showHostContextMenu };