mtxuilib 0.1.119 → 0.1.121
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/dist/components/chat-share-dialog.d.ts +1 -1
- package/dist/components/chat.d.ts +1 -1
- package/dist/components/dev-bot/DevBot.d.ts +1 -1
- package/dist/components/dev-bot/DevBotActions.d.ts +1 -1
- package/dist/components/dev-bot/DevBotActions.js +14 -4
- package/dist/components/external-link.js +1 -1
- package/dist/components/footer.d.ts +0 -1
- package/dist/components/prompt-form.js +1 -1
- package/dist/mtedtior/extensions/index.d.ts +2 -2
- package/dist/mtedtior/tw_extensions.d.ts +1 -1
- package/dist/tools/devTools/bash.d.ts +14 -0
- package/dist/tools/devTools/bash.js +29 -0
- package/dist/tools/devTools/cloudflareTunnel.d.ts +17 -0
- package/dist/tools/devTools/cloudflareTunnel.js +44 -0
- package/dist/tools/devTools/getIp.d.ts +14 -0
- package/dist/tools/devTools/getIp.js +30 -0
- package/dist/tools/devTools/installOsPackages.d.ts +8 -0
- package/dist/tools/devTools/installOsPackages.js +30 -0
- package/dist/tools/devTools/vncServer.d.ts +14 -0
- package/dist/tools/devTools/vncServer.js +168 -0
- package/dist/ui/menubar.d.ts +3 -1
- package/dist/ui-vamp/dropdown.d.ts +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DialogProps } from "@radix-ui/react-dialog";
|
|
2
|
-
import {
|
|
2
|
+
import type { Chat, ServerActionResult } from "../lib/types";
|
|
3
3
|
interface ChatShareDialogProps extends DialogProps {
|
|
4
4
|
chat: Pick<Chat, "id" | "title" | "messages">;
|
|
5
5
|
shareChat: (id: string) => ServerActionResult<Chat>;
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import "server-only";
|
|
3
3
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
4
|
-
import { createAI, createStreamableValue, getAIState, getMutableAIState, streamUI } from "ai/rsc";
|
|
4
|
+
import { createAI, createStreamableValue, getAIState, getMutableAIState, streamUI, } from "ai/rsc";
|
|
5
5
|
import { BotMessage, SpinnerMessage } from "mtxuilib/components/stocks/message";
|
|
6
6
|
import { nanoid } from "mtxuilib/lib/utils";
|
|
7
7
|
import { auth } from "../../lib/auth/auth";
|
|
8
|
-
import { getUIStateFromAIState } from "../../lib/chat/actions";
|
|
8
|
+
import { getUIStateFromAIState, } from "../../lib/chat/actions";
|
|
9
9
|
import { saveChat } from "../../lib/chat/chatActions";
|
|
10
10
|
import { countDownTool } from "../../tools/countDown";
|
|
11
|
+
import { bashTool } from "../../tools/devTools/bash";
|
|
11
12
|
import { diskSpaceReleaseTool } from "../../tools/devTools/clean";
|
|
13
|
+
import { netTunnelTool } from "../../tools/devTools/cloudflareTunnel";
|
|
12
14
|
import { dockerComposeTool } from "../../tools/devTools/docker-compose";
|
|
13
15
|
import { dockerBuildMtmTool } from "../../tools/devTools/dockerBuildMtm";
|
|
14
16
|
import { deployMtcfWorkerTool } from "../../tools/devTools/dpMtCfWorkerTool";
|
|
15
17
|
import { deployMtxEdgeTool } from "../../tools/devTools/dpMtxedge";
|
|
18
|
+
import { getExternalIpTool } from "../../tools/devTools/getIp";
|
|
19
|
+
import { installOsPackagesTool } from "../../tools/devTools/installOsPackages";
|
|
16
20
|
import { releasePackagesTool } from "../../tools/devTools/packageRelease";
|
|
17
21
|
import { vcDeployTool } from "../../tools/devTools/vcDeploytool";
|
|
22
|
+
import { vncServerTool } from "../../tools/devTools/vncServer";
|
|
18
23
|
import { genSiteHeaderBarsTool } from "../../tools/genSiteHeaderBarsTool";
|
|
19
24
|
import { helloTool } from "../../tools/hello1Tool";
|
|
20
25
|
import { welcomeAdminUser } from "../../tools/welcomeAdminTool";
|
|
@@ -89,6 +94,11 @@ async function submitUserMessage(content) {
|
|
|
89
94
|
...dockerBuildMtmTool,
|
|
90
95
|
...releasePackagesTool,
|
|
91
96
|
...diskSpaceReleaseTool,
|
|
97
|
+
...bashTool,
|
|
98
|
+
...netTunnelTool,
|
|
99
|
+
...vncServerTool,
|
|
100
|
+
...getExternalIpTool,
|
|
101
|
+
...installOsPackagesTool,
|
|
92
102
|
},
|
|
93
103
|
});
|
|
94
104
|
return {
|
|
@@ -105,7 +115,7 @@ export const AIDev = createAI({
|
|
|
105
115
|
onGetUIState: async () => {
|
|
106
116
|
"use server";
|
|
107
117
|
const session = await auth();
|
|
108
|
-
if (session
|
|
118
|
+
if (session?.user) {
|
|
109
119
|
const aiState = getAIState();
|
|
110
120
|
if (aiState) {
|
|
111
121
|
const uiState = getUIStateFromAIState(aiState);
|
|
@@ -119,7 +129,7 @@ export const AIDev = createAI({
|
|
|
119
129
|
onSetAIState: async ({ state }) => {
|
|
120
130
|
"use server";
|
|
121
131
|
const session = await auth();
|
|
122
|
-
if (session
|
|
132
|
+
if (session?.user) {
|
|
123
133
|
const { chatId, messages } = state;
|
|
124
134
|
const createdAt = new Date();
|
|
125
135
|
const userId = session.user.id;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
export function ExternalLink({ href, children, }) {
|
|
3
|
-
return (_jsxs("a", { href: href, target: "_blank", className: "inline-flex flex-1 justify-center gap-1 leading-4 hover:underline", children: [_jsx("span", { children: children }), _jsx("svg", { "aria-hidden": "true", height: "7", viewBox: "0 0 6 6", width: "7", className: "opacity-70", children: _jsx("path", { d: "M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z", fill: "currentColor" }) })] }));
|
|
3
|
+
return (_jsxs("a", { href: href, target: "_blank", className: "inline-flex flex-1 justify-center gap-1 leading-4 hover:underline", rel: "noreferrer", children: [_jsx("span", { children: children }), _jsx("svg", { "aria-hidden": "true", height: "7", viewBox: "0 0 6 6", width: "7", className: "opacity-70", children: _jsx("path", { d: "M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z", fill: "currentColor" }) })] }));
|
|
4
4
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from "@radix-ui/react-tooltip";
|
|
3
|
+
import { Tooltip, TooltipContent, TooltipTrigger, } from "@radix-ui/react-tooltip";
|
|
4
4
|
import { useActions, useUIState } from "ai/rsc";
|
|
5
5
|
import { nanoid } from "nanoid";
|
|
6
6
|
import { useRouter } from "next/navigation";
|
|
@@ -6,7 +6,7 @@ import { TaskList } from "@tiptap/extension-task-list";
|
|
|
6
6
|
import StarterKit from "@tiptap/starter-kit";
|
|
7
7
|
import { ImageResizer } from "./image-resizer";
|
|
8
8
|
import UpdatedImage from "./updated-image";
|
|
9
|
-
declare const PlaceholderExtension: import("@tiptap/core").Extension<
|
|
10
|
-
declare const simpleExtensions: readonly [import("@tiptap/core").Mark<import("@tiptap/extension-underline").UnderlineOptions, any>, import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any>, import("@tiptap/core").Extension<import("@tiptap/extension-color").ColorOptions, any>, import("@tiptap/core").Mark<
|
|
9
|
+
declare const PlaceholderExtension: import("@tiptap/core").Extension<any, any>;
|
|
10
|
+
declare const simpleExtensions: readonly [import("@tiptap/core").Mark<import("@tiptap/extension-underline").UnderlineOptions, any>, import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any>, import("@tiptap/core").Extension<import("@tiptap/extension-color").ColorOptions, any>, import("@tiptap/core").Mark<any, any>, import("@tiptap/core").Extension<any, any>, import("@tiptap/core").Extension<any, any>, import("@tiptap/core").Extension<any, any>, import("@tiptap/core").Node<any, any>];
|
|
11
11
|
declare const Horizontal: import("@tiptap/core").Node<import("@tiptap/extension-horizontal-rule").HorizontalRuleOptions, any>;
|
|
12
12
|
export { Horizontal as HorizontalRule, ImageResizer, InputRule, PlaceholderExtension as Placeholder, StarterKit, TaskItem, TaskList, TiptapImage, TiptapLink, UpdatedImage, simpleExtensions, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const defaultExtensions: (import("@tiptap/core").Extension<any, any> | import("@tiptap/core").Node<
|
|
1
|
+
export declare const defaultExtensions: (import("@tiptap/core").Extension<any, any> | import("@tiptap/core").Node<any, any> | import("@tiptap/core").Mark<any, any>)[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const bashTool: {
|
|
3
|
+
bashTool: {
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodObject<{
|
|
6
|
+
script: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
script: string;
|
|
9
|
+
}, {
|
|
10
|
+
script: string;
|
|
11
|
+
}>;
|
|
12
|
+
generate: (params: any) => AsyncGenerator<import("react/jsx-runtime").JSX.Element, import("react/jsx-runtime").JSX.Element, unknown>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { exec } from "mtxlib/exec";
|
|
3
|
+
import { projectRoot } from "mtxlib/tasks/deploy/vercelHelper";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { BotCard } from "../../components/stocks";
|
|
6
|
+
import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
|
|
7
|
+
export const bashTool = {
|
|
8
|
+
bashTool: {
|
|
9
|
+
description: "执行bash命令",
|
|
10
|
+
parameters: z.object({
|
|
11
|
+
script: z.string().describe("bash -c %s 这种方式执行"),
|
|
12
|
+
}),
|
|
13
|
+
generate: async function* (params) {
|
|
14
|
+
yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
|
|
15
|
+
try {
|
|
16
|
+
const projectDir = projectRoot();
|
|
17
|
+
yield (_jsx(BotCard, { children: _jsxs("div", { children: ["\u5F00\u59CB\u6267\u884Cbash\u547D\u4EE4 $", params.script] }) }));
|
|
18
|
+
const result = await exec(`${params.script}`, {
|
|
19
|
+
shell: true,
|
|
20
|
+
cwd: projectDir,
|
|
21
|
+
});
|
|
22
|
+
return (_jsxs(BotCard, { children: ["\u547D\u4EE4\u6267\u884C\u5B8C\u6BD5 ", _jsx("pre", { children: JSON.stringify(result, null, 2) })] }));
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
return (_jsxs(BotCard, { children: [_jsx("h3", { children: "\u9519\u8BEF\u6458\u8981\uFF1A" }), _jsx("pre", { children: e.toString() }), _jsx("div", { children: "\u66F4\u5177\u4F53\u7684\u9519\u8BEF\u4FE1\u606F\uFF0C\u8BF7\u5230\u540E\u53F0\u67E5\u770B" })] }));
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const netTunnelTool: {
|
|
3
|
+
netTunnel: {
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodObject<{
|
|
6
|
+
action: z.ZodEnum<["start", "stop"]>;
|
|
7
|
+
token: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
action: "stop" | "start";
|
|
10
|
+
token?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
action: "stop" | "start";
|
|
13
|
+
token?: string | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
generate: (params: any) => AsyncGenerator<import("react/jsx-runtime").JSX.Element, import("react/jsx-runtime").JSX.Element, unknown>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { exec } from "mtxlib/exec";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { BotCard } from "../../components/stocks";
|
|
5
|
+
import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
|
|
6
|
+
export const netTunnelTool = {
|
|
7
|
+
netTunnel: {
|
|
8
|
+
description: "启动或者停止网络通道,将调用 cloudflared 命令",
|
|
9
|
+
parameters: z.object({
|
|
10
|
+
action: z.enum(["start", "stop"]),
|
|
11
|
+
token: z.string().optional().describe("token of cloudflared tunnel"),
|
|
12
|
+
}),
|
|
13
|
+
generate: async function* (params) {
|
|
14
|
+
yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
|
|
15
|
+
try {
|
|
16
|
+
yield (_jsx(BotCard, { children: _jsxs("div", { children: ["\u8C03\u7528 cloudflare \u52A8\u4F5C\uFF1A", params.action] }) }));
|
|
17
|
+
const result = await cftunnel_gitpod(params.action);
|
|
18
|
+
return (_jsxs(BotCard, { children: ["\u901A\u9053\u64CD\u4F5C\u5B8C\u6BD5 ", _jsx("pre", { children: JSON.stringify(result, null, 2) })] }));
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
return (_jsxs(BotCard, { children: [_jsx("h3", { children: "\u9519\u8BEF\u6458\u8981\uFF1A" }), _jsx("pre", { children: e.toString() }), _jsx("div", { children: "\u66F4\u5177\u4F53\u7684\u9519\u8BEF\u4FE1\u606F\uFF0C\u8BF7\u5230\u540E\u53F0\u67E5\u770B" })] }));
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
async function cftunnel_gitpod(action) {
|
|
27
|
+
if (action === "start") {
|
|
28
|
+
console.log("启动 cftunnel_gitpod");
|
|
29
|
+
await exec(`command -v cloudflared || (curl -o /usr/bin/cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 \
|
|
30
|
+
&& chmod +x /usr/bin/cloudflared)`, {
|
|
31
|
+
shell: true,
|
|
32
|
+
env: { ...process.env },
|
|
33
|
+
});
|
|
34
|
+
const cloudflareTunnelToken = "eyJhIjoiNjIzZmFmNzJlZTBkMmFmM2U1ODZlN2NkOWRhZGI3MmIiLCJ0IjoiNmUyMWMwNjAtZjRkOC00NmJjLTk2NjEtODA1M2M0ZGE0MzRlIiwicyI6Ill6TmpPREpoWWpVdE5EWTRNUzAwTVdSbExUazVZbVl0TXpGalpHSmlNRE14WXpOaSJ9";
|
|
35
|
+
exec(`cloudflared tunnel --no-autoupdate run --token ${cloudflareTunnelToken}`, {
|
|
36
|
+
shell: true,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
await exec("pkill cloudflared", {
|
|
41
|
+
shell: true,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const getExternalIpTool: {
|
|
3
|
+
getExternalIp: {
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodObject<{
|
|
6
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
provider?: string | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
provider?: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
generate: (params: any) => AsyncGenerator<import("react/jsx-runtime").JSX.Element, import("react/jsx-runtime").JSX.Element, unknown>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { BotCard } from "../../components/stocks";
|
|
4
|
+
import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
|
|
5
|
+
export const getExternalIpTool = {
|
|
6
|
+
getExternalIp: {
|
|
7
|
+
description: "通过请问第三方api 获取当前服务器对外请求的公网IP",
|
|
8
|
+
parameters: z.object({
|
|
9
|
+
provider: z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("ip 查询供应商名称,一般可以不填"),
|
|
13
|
+
}),
|
|
14
|
+
generate: async function* (params) {
|
|
15
|
+
yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
|
|
16
|
+
try {
|
|
17
|
+
yield _jsx(BotCard, { children: "\u5F00\u59CB\u8BF7\u6C42\u5916\u7F51\uFF0C\u63A2\u6D4B\u5F53\u524D\u670D\u52A1\u5668\u7684IP" });
|
|
18
|
+
const ipInfo = await getIp();
|
|
19
|
+
return (_jsxs(BotCard, { children: ["\u63A2\u6D4B\u5B8C\u6210\uFF0C\u4FE1\u606F\uFF1A ", _jsx("pre", { children: JSON.stringify(ipInfo, null, 2) })] }));
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
return (_jsxs(BotCard, { children: [_jsx("h3", { children: "\u9519\u8BEF\u6458\u8981\uFF1A" }), _jsx("pre", { children: e.toString() }), _jsx("div", { children: "\u66F4\u5177\u4F53\u7684\u9519\u8BEF\u4FE1\u606F\uFF0C\u8BF7\u5230\u540E\u53F0\u67E5\u770B" })] }));
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
async function getIp() {
|
|
28
|
+
const ipInfo = await fetch("https://ifconfig.me/all.json").then((x) => x.json());
|
|
29
|
+
return ipInfo;
|
|
30
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const installOsPackagesTool: {
|
|
3
|
+
installOsPackages: {
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
6
|
+
generate: (params: any) => AsyncGenerator<import("react/jsx-runtime").JSX.Element, import("react/jsx-runtime").JSX.Element, unknown>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { exec } from "mtxlib/exec";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { BotCard } from "../../components/stocks";
|
|
5
|
+
import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
|
|
6
|
+
export const installOsPackagesTool = {
|
|
7
|
+
installOsPackages: {
|
|
8
|
+
description: "在当前 linux 系统,安装常用的工具软件,内部将使用 类似 apt get install -y git curl 的方式安装管理员已经预先指定的软件包",
|
|
9
|
+
parameters: z
|
|
10
|
+
.object({})
|
|
11
|
+
.optional(),
|
|
12
|
+
generate: async function* (params) {
|
|
13
|
+
yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
|
|
14
|
+
try {
|
|
15
|
+
yield _jsx(BotCard, { children: "\u5F00\u59CB\u8BF7\u6C42\u5916\u7F51\uFF0C\u63A2\u6D4B\u5F53\u524D\u670D\u52A1\u5668\u7684IP" });
|
|
16
|
+
const result = await installOsPackages();
|
|
17
|
+
return (_jsxs(BotCard, { children: ["\u6267\u884C\u5B8C\u6BD5", _jsx("pre", { children: JSON.stringify(result, null, 2) })] }));
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
return (_jsxs(BotCard, { children: [_jsx("h3", { children: "\u9519\u8BEF\u6458\u8981\uFF1A" }), _jsx("pre", { children: e.toString() }), _jsx("div", { children: "\u66F4\u5177\u4F53\u7684\u9519\u8BEF\u4FE1\u606F\uFF0C\u8BF7\u5230\u540E\u53F0\u67E5\u770B" })] }));
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
async function installOsPackages() {
|
|
26
|
+
await exec(` if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
|
|
27
|
+
echo "Running apt-get update..."
|
|
28
|
+
sudo apt update
|
|
29
|
+
fi`, { shell: true });
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const vncServerTool: {
|
|
3
|
+
vncServer: {
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodObject<{
|
|
6
|
+
action: z.ZodEnum<["start", "stop"]>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
action: "stop" | "start";
|
|
9
|
+
}, {
|
|
10
|
+
action: "stop" | "start";
|
|
11
|
+
}>;
|
|
12
|
+
generate: (params: any) => AsyncGenerator<import("react/jsx-runtime").JSX.Element, import("react/jsx-runtime").JSX.Element, unknown>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { commandExistAsync, exec } from "mtxlib/exec";
|
|
6
|
+
import { isUbuntu, setupOsUser } from "mtxlib/mtos";
|
|
7
|
+
import { isGitpod } from "mtxlib/utils";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { BotCard } from "../../components/stocks";
|
|
10
|
+
import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
|
|
11
|
+
export const vncServerTool = {
|
|
12
|
+
vncServer: {
|
|
13
|
+
description: "启动或停止本地的 vncserver 服务",
|
|
14
|
+
parameters: z.object({
|
|
15
|
+
action: z.enum(["start", "stop"]),
|
|
16
|
+
}),
|
|
17
|
+
generate: async function* (params) {
|
|
18
|
+
yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
|
|
19
|
+
try {
|
|
20
|
+
yield (_jsx(BotCard, { children: _jsxs("div", { children: ["\u5F00\u59CB\u542F\u52A8vnc\uFF1A", params.action] }) }));
|
|
21
|
+
const result = await startKasmVnc();
|
|
22
|
+
return (_jsxs(BotCard, { children: ["\u542F\u52A8vnc \u5B8C\u6210 ", _jsx("pre", { children: JSON.stringify(result, null, 2) })] }));
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
return (_jsxs(BotCard, { children: [_jsx("h3", { children: "\u9519\u8BEF\u6458\u8981\uFF1A" }), _jsx("pre", { children: e.toString() }), _jsx("div", { children: "\u66F4\u5177\u4F53\u7684\u9519\u8BEF\u4FE1\u606F\uFF0C\u8BF7\u5230\u540E\u53F0\u67E5\u770B" })] }));
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
async function startKasmVnc() {
|
|
31
|
+
const DEFAULT_PASSWORD = "feihuo321";
|
|
32
|
+
const DEFAULT_KASM_USER = "mt";
|
|
33
|
+
if (!commandExistAsync("vncserver")) {
|
|
34
|
+
console.log("vncserver 命令不存在,安装");
|
|
35
|
+
await installKasmVnc();
|
|
36
|
+
}
|
|
37
|
+
if (!commandExistAsync("vncpasswd")) {
|
|
38
|
+
exec(`sudo apt install -y vncpasswd`);
|
|
39
|
+
}
|
|
40
|
+
if (!(await commandExistAsync("xterm"))) {
|
|
41
|
+
console.log("缺少基本的桌面组件,现在安装");
|
|
42
|
+
await setupRdp();
|
|
43
|
+
}
|
|
44
|
+
if (isGitpod()) {
|
|
45
|
+
setupOsUser("gitpod", DEFAULT_PASSWORD);
|
|
46
|
+
}
|
|
47
|
+
const tlsKeyPath = `${os.homedir()}/.certs/ssl-cert-snakeoil.key`;
|
|
48
|
+
const tlsCertPath = `${os.homedir()}/.certs/ssl-cert-snakeoil.pem`;
|
|
49
|
+
if (!existsSync(tlsKeyPath)) {
|
|
50
|
+
mkdirSync(join(os.homedir(), ".certs"), { recursive: true });
|
|
51
|
+
await exec(`openssl req -subj '/CN=example.com/O=My Company Name LTD./C=US' -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout ${tlsKeyPath} -out ${tlsCertPath}`);
|
|
52
|
+
}
|
|
53
|
+
const kasmVncConfigPath = join(os.homedir(), ".vnc/kasmvnc.yaml");
|
|
54
|
+
if (!existsSync(kasmVncConfigPath)) {
|
|
55
|
+
const config = `
|
|
56
|
+
network:
|
|
57
|
+
protocol: http
|
|
58
|
+
interface: 0.0.0.0
|
|
59
|
+
websocket_port: auto
|
|
60
|
+
use_ipv4: true
|
|
61
|
+
use_ipv6: true
|
|
62
|
+
udp:
|
|
63
|
+
public_ip: auto
|
|
64
|
+
port: auto
|
|
65
|
+
stun_server: auto
|
|
66
|
+
ssl:
|
|
67
|
+
require_ssl: false
|
|
68
|
+
pem_certificate: ${os.homedir()}/.certs/ssl-cert-snakeoil.pem
|
|
69
|
+
pem_key: ${os.homedir()}/.certs/ssl-cert-snakeoil.key
|
|
70
|
+
`;
|
|
71
|
+
mkdirSync(dirname(kasmVncConfigPath), { recursive: true });
|
|
72
|
+
writeFileSync(kasmVncConfigPath, config);
|
|
73
|
+
}
|
|
74
|
+
const xstartupScriptFile = join(os.homedir(), ".vnc/xstartup");
|
|
75
|
+
if (!existsSync(xstartupScriptFile)) {
|
|
76
|
+
mkdirSync(dirname(xstartupScriptFile), { recursive: true });
|
|
77
|
+
writeFileSync(xstartupScriptFile, `#!/bin/sh
|
|
78
|
+
set -x
|
|
79
|
+
xfce4-terminal &
|
|
80
|
+
exec xfce4-session
|
|
81
|
+
`);
|
|
82
|
+
exec(`sudo chmod +x ${xstartupScriptFile}`, { shell: true });
|
|
83
|
+
}
|
|
84
|
+
await exec(`sudo echo -e "${DEFAULT_PASSWORD}\n${DEFAULT_PASSWORD}\n" | vncpasswd -u ${DEFAULT_KASM_USER} -ow ~/.kasmpasswd`);
|
|
85
|
+
const vnvServerLogPath = resolve(".vol/vncserver.log");
|
|
86
|
+
console.log({
|
|
87
|
+
message: "启动 kasm vncserver",
|
|
88
|
+
vnvServerLogPath,
|
|
89
|
+
kasmVncConfigPath,
|
|
90
|
+
DEFAULT_PASSWORD,
|
|
91
|
+
DEFAULT_KASM_USER,
|
|
92
|
+
});
|
|
93
|
+
exec("touch $HOME/.vnc/.de-was-selected && vncserver -autokill -disableBasicAuth", {
|
|
94
|
+
logPath: vnvServerLogPath,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async function setupRdp() {
|
|
98
|
+
if (!commandExistAsync("xrdp")) {
|
|
99
|
+
await exec(`# 这几行是为了跳过选择键盘布局的交互。具体那行代码发挥作用暂时不清楚。不过确实生效了。
|
|
100
|
+
echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
|
|
101
|
+
sudo apt install -y debconf-utils
|
|
102
|
+
export DEBIAN_FRONTEND=noninteractive
|
|
103
|
+
sudo apt-get install -y keyboard-configuration
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y --no-install-recommends \
|
|
107
|
+
dbus-x11 \
|
|
108
|
+
locales \
|
|
109
|
+
pavucontrol \
|
|
110
|
+
pulseaudio \
|
|
111
|
+
pulseaudio-utils \
|
|
112
|
+
x11-xserver-utils \
|
|
113
|
+
xfce4 \
|
|
114
|
+
xfce4-goodies \
|
|
115
|
+
xfce4-pulseaudio-plugin \
|
|
116
|
+
xorgxrdp \
|
|
117
|
+
xrdp
|
|
118
|
+
# 删除明显不需要的组件
|
|
119
|
+
sudo apt remove -y xfce4-power-manager
|
|
120
|
+
`, {
|
|
121
|
+
shell: true,
|
|
122
|
+
env: {
|
|
123
|
+
...process.env,
|
|
124
|
+
DEBIAN_FRONTEND: "noninteractive",
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
console.log("linux 桌面组件阶段2");
|
|
129
|
+
await exec(`sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y --no-install-recommends \
|
|
130
|
+
pciutils \
|
|
131
|
+
bash-completion \
|
|
132
|
+
xorg xfce4 xrdp dbus dbus-x11 \
|
|
133
|
+
x11-utils \
|
|
134
|
+
x11-xserver-utils \
|
|
135
|
+
xdg-utils \
|
|
136
|
+
fbautostart \
|
|
137
|
+
at-spi2-core \
|
|
138
|
+
xterm \
|
|
139
|
+
eterm \
|
|
140
|
+
tilix
|
|
141
|
+
`, {
|
|
142
|
+
shell: true,
|
|
143
|
+
env: {
|
|
144
|
+
...process.env,
|
|
145
|
+
DEBIAN_FRONTEND: "noninteractive",
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
console.log("第三阶段(字体)");
|
|
149
|
+
await exec(`DEBIAN_FRONTEND=noninteractive sudo apt -y install --no-install-recommends xfonts-intl-chinese ttf-wqy-microhei xfonts-intl-chinese xfonts-wqy`, {
|
|
150
|
+
shell: true,
|
|
151
|
+
env: {
|
|
152
|
+
...process.env,
|
|
153
|
+
DEBIAN_FRONTEND: "noninteractive",
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async function installKasmVnc() {
|
|
158
|
+
let downloadUrl = "https://github.com/kasmtech/KasmVNC/releases/download/v1.3.1/kasmvncserver_jammy_1.3.1_amd64.deb";
|
|
159
|
+
if (!(await isUbuntu())) {
|
|
160
|
+
downloadUrl =
|
|
161
|
+
"https://github.com/kasmtech/KasmVNC/releases/download/v1.3.1/kasmvncserver_bullseye_1.3.1_amd64.deb";
|
|
162
|
+
}
|
|
163
|
+
await exec(`curl -sSL -o /tmp/kasmvncserver.deb ${downloadUrl}
|
|
164
|
+
sudo apt install -y /tmp/kasmvncserver.deb
|
|
165
|
+
rm -rdf /tmp/kasmvncserver.deb
|
|
166
|
+
`, { shell: true });
|
|
167
|
+
await exec("sudo addgroup $USER ssl-cert", { shell: true });
|
|
168
|
+
}
|
package/dist/ui/menubar.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
declare const MenubarMenu: {
|
|
4
|
-
(props: MenubarPrimitive.
|
|
4
|
+
(props: MenubarPrimitive.MenubarMenuProps & {
|
|
5
|
+
__scopeMenubar?: import("@radix-ui/react-context").Scope;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
5
7
|
displayName: string;
|
|
6
8
|
};
|
|
7
9
|
declare const MenubarGroup: React.ForwardRefExoticComponent<MenubarPrimitive.MenubarGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -5,7 +5,7 @@ export declare function DropdownMenu({ ...props }: DropdownMenuProps): import("r
|
|
|
5
5
|
export declare namespace DropdownMenu {
|
|
6
6
|
var Trigger: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
7
7
|
var Portal: React.FC<DropdownMenuPrimitive.DropdownMenuPortalProps>;
|
|
8
|
-
var Content: React.ForwardRefExoticComponent<
|
|
8
|
+
var Content: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.MenuContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
9
|
var Item: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
10
|
var Separator: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuSeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mtxuilib",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.121",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -210,8 +210,8 @@
|
|
|
210
210
|
"next": "14.2.4",
|
|
211
211
|
"next-themes": "^0.3.0",
|
|
212
212
|
"openai": "^4.52.2",
|
|
213
|
-
"react": "^
|
|
214
|
-
"react-dom": "^
|
|
213
|
+
"react": "^19.0.0-rc-8971381549-20240625",
|
|
214
|
+
"react-dom": "^19.0.0-rc-8971381549-20240625",
|
|
215
215
|
"react-intersection-observer": "^9.10.3",
|
|
216
216
|
"react-syntax-highlighter": "^15.5.0",
|
|
217
217
|
"react-textarea-autosize": "^8.5.3",
|
|
@@ -278,8 +278,8 @@
|
|
|
278
278
|
"autoprefixer": "^10.4.19",
|
|
279
279
|
"cross-env": "^7.0.3",
|
|
280
280
|
"css-loader": "^6.10.0",
|
|
281
|
-
"eslint": "^
|
|
282
|
-
"eslint-config-next": "^
|
|
281
|
+
"eslint": "^9.7.0",
|
|
282
|
+
"eslint-config-next": "^15.0.0-rc.0",
|
|
283
283
|
"eslint-config-prettier": "latest",
|
|
284
284
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
285
285
|
"eslint-plugin-import": "^2.26.0",
|