mtxuilib 0.1.119 → 0.1.122
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/auth/LoginDlg.d.ts +0 -0
- package/dist/components/auth/LoginDlg.js +1 -0
- package/dist/components/chat-share-dialog.d.ts +1 -1
- package/dist/components/chat.d.ts +1 -1
- package/dist/components/chat.js +3 -1
- package/dist/components/dev-bot/DevBot.d.ts +1 -1
- package/dist/components/dev-bot/DevBot.js +1 -1
- package/dist/components/dev-bot/DevBotActions.d.ts +13 -1
- package/dist/components/dev-bot/DevBotActions.js +25 -5
- package/dist/components/{chat-list.d.ts → dev-bot/chat-list.d.ts} +2 -2
- package/dist/components/dev-bot/chat-panel.d.ts +1 -1
- package/dist/components/dev-bot/chat-panel.js +9 -7
- package/dist/components/{prompt-form.js → dev-bot/prompt-form.js} +5 -5
- package/dist/components/external-link.js +1 -1
- package/dist/components/{stocks/message.d.ts → message.d.ts} +1 -1
- package/dist/components/{stocks/message.js → message.js} +4 -4
- package/dist/components/{stocks/spinner.js → spinner.js} +1 -1
- package/dist/components/tool-ui/BlogHomePage.z.d.ts +2 -2
- package/dist/lib/chat/chatActions.d.ts +1 -1
- package/dist/lib/chat/chatActions.js +4 -2
- package/dist/mtedtior/extensions/index.d.ts +2 -2
- package/dist/mtedtior/tw_extensions.d.ts +1 -1
- package/dist/tools/countDown.d.ts +1 -1
- package/dist/tools/countDown.js +4 -5
- package/dist/tools/devTools/bash.d.ts +14 -0
- package/dist/tools/devTools/bash.js +28 -0
- package/dist/tools/devTools/clean.js +2 -3
- package/dist/tools/devTools/cloudflareTunnel.d.ts +17 -0
- package/dist/tools/devTools/cloudflareTunnel.js +43 -0
- package/dist/tools/devTools/docker-compose.js +2 -3
- package/dist/tools/devTools/dockerBuildMtm.js +3 -4
- package/dist/tools/devTools/dpMtCfWorkerTool.js +2 -3
- package/dist/tools/devTools/dpMtxedge.js +6 -7
- package/dist/tools/devTools/getIp.d.ts +14 -0
- package/dist/tools/devTools/getIp.js +29 -0
- package/dist/tools/devTools/installOsPackages.d.ts +8 -0
- package/dist/tools/devTools/installOsPackages.js +29 -0
- package/dist/tools/devTools/packageRelease.js +5 -6
- package/dist/tools/devTools/vcDeploytool.js +4 -5
- package/dist/tools/devTools/vncServer.d.ts +14 -0
- package/dist/tools/devTools/vncServer.js +167 -0
- package/dist/tools/genSiteHeaderBarsTool.js +2 -3
- package/dist/tools/hello1Tool.js +2 -3
- package/dist/tools/webbot/callAdminBot.d.ts +8 -0
- package/dist/tools/webbot/callAdminBot.js +14 -0
- package/dist/tools/welcomeAdminTool.js +2 -3
- package/dist/ui/menubar.d.ts +3 -1
- package/dist/ui-vamp/dropdown.d.ts +1 -1
- package/package.json +5 -5
- package/dist/components/bloggenBot/BlogGenBot.d.ts +0 -8
- package/dist/components/bloggenBot/BlogGenBot.js +0 -43
- package/dist/components/bloggenBot/BlogGenBotActions.d.ts +0 -20
- package/dist/components/bloggenBot/BlogGenBotActions.js +0 -179
- package/dist/components/bloggenBot/chat-panel.d.ts +0 -9
- package/dist/components/bloggenBot/chat-panel.js +0 -41
- package/dist/components/chat-panel.d.ts +0 -9
- package/dist/components/chat-panel.js +0 -41
- package/dist/components/footer.d.ts +0 -2
- package/dist/components/footer.js +0 -6
- package/dist/components/stocks/events-skeleton.d.ts +0 -1
- package/dist/components/stocks/events-skeleton.js +0 -11
- package/dist/components/stocks/events.d.ts +0 -9
- package/dist/components/stocks/events.js +0 -5
- package/dist/components/stocks/index.js +0 -25
- package/dist/components/stocks/stock-purchase.d.ts +0 -10
- package/dist/components/stocks/stock-purchase.js +0 -35
- package/dist/components/stocks/stock-skeleton.d.ts +0 -1
- package/dist/components/stocks/stock-skeleton.js +0 -4
- package/dist/components/stocks/stock.d.ts +0 -9
- package/dist/components/stocks/stock.js +0 -90
- package/dist/components/stocks/stocks-skeleton.d.ts +0 -1
- package/dist/components/stocks/stocks-skeleton.js +0 -4
- package/dist/components/stocks/stocks.d.ts +0 -9
- package/dist/components/stocks/stocks.js +0 -11
- package/dist/components/testingBot/TestingBot.d.ts +0 -8
- package/dist/components/testingBot/TestingBot.js +0 -43
- package/dist/components/testingBot/TestingBotActions.d.ts +0 -16
- package/dist/components/testingBot/TestingBotActions.js +0 -122
- package/dist/components/testingBot/chat-panel.d.ts +0 -9
- package/dist/components/testingBot/chat-panel.js +0 -41
- package/dist/components/testingBot/empty-screen.d.ts +0 -1
- package/dist/components/testingBot/empty-screen.js +0 -4
- package/dist/lib/chat/actions.d.ts +0 -20
- package/dist/lib/chat/actions.js +0 -136
- /package/dist/components/{chat-list.js → dev-bot/chat-list.js} +0 -0
- /package/dist/components/{prompt-form.d.ts → dev-bot/prompt-form.d.ts} +0 -0
- /package/dist/components/{stocks/spinner.d.ts → spinner.d.ts} +0 -0
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -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>;
|
package/dist/components/chat.js
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useAIState, useUIState } from "ai/rsc";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
|
+
import { ChatList } from "./chat-list";
|
|
5
6
|
import dynamic from "next/dynamic";
|
|
6
7
|
import { usePathname, useRouter } from "next/navigation";
|
|
7
8
|
import { toast } from "sonner";
|
|
8
9
|
import { useLocalStorage } from "usehooks-ts";
|
|
9
10
|
import { useScrollAnchor } from "../hooks/use-scroll-anchor";
|
|
10
11
|
import { cn } from "../lib/utils";
|
|
12
|
+
import { ChatPanel } from "./chat-panel";
|
|
11
13
|
import { EmptyScreen } from "./empty-screen";
|
|
12
14
|
const LzChatPanel = dynamic(() => import("./chat-panel").then((x) => x.ChatPanel), {
|
|
13
15
|
ssr: false,
|
|
@@ -44,5 +46,5 @@ export function Chat({ id, className, session, missingKeys }) {
|
|
|
44
46
|
});
|
|
45
47
|
}, [missingKeys]);
|
|
46
48
|
const { messagesRef, scrollRef, visibilityRef, isAtBottom, scrollToBottom } = useScrollAnchor();
|
|
47
|
-
return (_jsxs("div", { className: "group w-full overflow-auto pl-0 peer-[[data-state=open]]:lg:pl-[250px] peer-[[data-state=open]]:xl:pl-[300px]", ref: scrollRef, children: [_jsxs("div", { className: cn("pb-[200px] pt-4 md:pt-10", className), ref: messagesRef, children: [messages.length ? (_jsx(
|
|
49
|
+
return (_jsxs("div", { className: "group w-full overflow-auto pl-0 peer-[[data-state=open]]:lg:pl-[250px] peer-[[data-state=open]]:xl:pl-[300px]", ref: scrollRef, children: [_jsxs("div", { className: cn("pb-[200px] pt-4 md:pt-10", className), ref: messagesRef, children: [messages.length ? (_jsx(ChatList, { messages: messages, isShared: false, session: session })) : (_jsx(EmptyScreen, {})), _jsx("div", { className: "w-full h-px", ref: visibilityRef })] }), _jsx(ChatPanel, { id: id, input: input, setInput: setInput, isAtBottom: isAtBottom, scrollToBottom: scrollToBottom })] }));
|
|
48
50
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useAIState, useUIState } from "ai/rsc";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
|
-
import { ChatList } from "../chat-list";
|
|
6
5
|
import { usePathname, useRouter } from "next/navigation";
|
|
7
6
|
import { toast } from "sonner";
|
|
8
7
|
import { useLocalStorage } from "usehooks-ts";
|
|
9
8
|
import { useScrollAnchor } from "../../hooks/use-scroll-anchor";
|
|
10
9
|
import { cn } from "../../lib/utils";
|
|
11
10
|
import { EmptyScreen } from "../empty-screen";
|
|
11
|
+
import { ChatList } from "./chat-list";
|
|
12
12
|
import { DevChatPanel } from "./chat-panel";
|
|
13
13
|
export function DevBot({ id, className, session, missingKeys }) {
|
|
14
14
|
const router = useRouter();
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import "server-only";
|
|
2
|
-
import {
|
|
2
|
+
import type { Chat, Message } from "mtxuilib/lib/types";
|
|
3
|
+
export type AIState = {
|
|
4
|
+
chatId: string;
|
|
5
|
+
messages: Message[];
|
|
6
|
+
};
|
|
7
|
+
export type UIState = {
|
|
8
|
+
id: string;
|
|
9
|
+
display: React.ReactNode;
|
|
10
|
+
}[];
|
|
3
11
|
export declare const AIDev: (props: {
|
|
4
12
|
children: React.ReactNode;
|
|
5
13
|
initialAIState?: AIState | undefined;
|
|
6
14
|
initialUIState?: UIState | undefined;
|
|
7
15
|
$ActionTypes?: {} | undefined;
|
|
8
16
|
}) => Promise<React.ReactElement>;
|
|
17
|
+
export declare const getUIStateFromAIState: (aiState: Chat) => {
|
|
18
|
+
id: string;
|
|
19
|
+
display: import("react/jsx-runtime").JSX.Element | (import("react/jsx-runtime").JSX.Element | null)[] | null;
|
|
20
|
+
}[];
|
|
@@ -1,23 +1,27 @@
|
|
|
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";
|
|
5
|
-
import { BotMessage, SpinnerMessage } from "mtxuilib/components/stocks/message";
|
|
4
|
+
import { createAI, createStreamableValue, getAIState, getMutableAIState, streamUI, } from "ai/rsc";
|
|
6
5
|
import { nanoid } from "mtxuilib/lib/utils";
|
|
7
6
|
import { auth } from "../../lib/auth/auth";
|
|
8
|
-
import { getUIStateFromAIState } from "../../lib/chat/actions";
|
|
9
7
|
import { saveChat } from "../../lib/chat/chatActions";
|
|
10
8
|
import { countDownTool } from "../../tools/countDown";
|
|
9
|
+
import { bashTool } from "../../tools/devTools/bash";
|
|
11
10
|
import { diskSpaceReleaseTool } from "../../tools/devTools/clean";
|
|
11
|
+
import { netTunnelTool } from "../../tools/devTools/cloudflareTunnel";
|
|
12
12
|
import { dockerComposeTool } from "../../tools/devTools/docker-compose";
|
|
13
13
|
import { dockerBuildMtmTool } from "../../tools/devTools/dockerBuildMtm";
|
|
14
14
|
import { deployMtcfWorkerTool } from "../../tools/devTools/dpMtCfWorkerTool";
|
|
15
15
|
import { deployMtxEdgeTool } from "../../tools/devTools/dpMtxedge";
|
|
16
|
+
import { getExternalIpTool } from "../../tools/devTools/getIp";
|
|
17
|
+
import { installOsPackagesTool } from "../../tools/devTools/installOsPackages";
|
|
16
18
|
import { releasePackagesTool } from "../../tools/devTools/packageRelease";
|
|
17
19
|
import { vcDeployTool } from "../../tools/devTools/vcDeploytool";
|
|
20
|
+
import { vncServerTool } from "../../tools/devTools/vncServer";
|
|
18
21
|
import { genSiteHeaderBarsTool } from "../../tools/genSiteHeaderBarsTool";
|
|
19
22
|
import { helloTool } from "../../tools/hello1Tool";
|
|
20
23
|
import { welcomeAdminUser } from "../../tools/welcomeAdminTool";
|
|
24
|
+
import { BotCard, BotMessage, SpinnerMessage, UserMessage } from "../message";
|
|
21
25
|
async function submitUserMessage(content) {
|
|
22
26
|
"use server";
|
|
23
27
|
const aiState = getMutableAIState();
|
|
@@ -89,6 +93,11 @@ async function submitUserMessage(content) {
|
|
|
89
93
|
...dockerBuildMtmTool,
|
|
90
94
|
...releasePackagesTool,
|
|
91
95
|
...diskSpaceReleaseTool,
|
|
96
|
+
...bashTool,
|
|
97
|
+
...netTunnelTool,
|
|
98
|
+
...vncServerTool,
|
|
99
|
+
...getExternalIpTool,
|
|
100
|
+
...installOsPackagesTool,
|
|
92
101
|
},
|
|
93
102
|
});
|
|
94
103
|
return {
|
|
@@ -105,7 +114,7 @@ export const AIDev = createAI({
|
|
|
105
114
|
onGetUIState: async () => {
|
|
106
115
|
"use server";
|
|
107
116
|
const session = await auth();
|
|
108
|
-
if (session
|
|
117
|
+
if (session?.user) {
|
|
109
118
|
const aiState = getAIState();
|
|
110
119
|
if (aiState) {
|
|
111
120
|
const uiState = getUIStateFromAIState(aiState);
|
|
@@ -119,7 +128,7 @@ export const AIDev = createAI({
|
|
|
119
128
|
onSetAIState: async ({ state }) => {
|
|
120
129
|
"use server";
|
|
121
130
|
const session = await auth();
|
|
122
|
-
if (session
|
|
131
|
+
if (session?.user) {
|
|
123
132
|
const { chatId, messages } = state;
|
|
124
133
|
const createdAt = new Date();
|
|
125
134
|
const userId = session.user.id;
|
|
@@ -141,3 +150,14 @@ export const AIDev = createAI({
|
|
|
141
150
|
}
|
|
142
151
|
},
|
|
143
152
|
});
|
|
153
|
+
export const getUIStateFromAIState = (aiState) => {
|
|
154
|
+
return aiState.messages
|
|
155
|
+
.filter((message) => message.role !== "system")
|
|
156
|
+
.map((message, index) => ({
|
|
157
|
+
id: `${aiState.chatId}-${index}`,
|
|
158
|
+
display: message.role === "tool" ? (message.content.map((tool) => {
|
|
159
|
+
return tool.toolName === "listStocks" ? (_jsx(BotCard, { children: "TODO show listStocks:" }, tool.toolCallId)) : tool.toolName === "showStockPurchase" ? (_jsx(BotCard, { children: "todo" }, tool.toolCallId)) : null;
|
|
160
|
+
})) : message.role === "user" ? (_jsx(UserMessage, { children: message.content })) : message.role === "assistant" &&
|
|
161
|
+
typeof message.content === "string" ? (_jsx(BotMessage, { content: message.content })) : null,
|
|
162
|
+
}));
|
|
163
|
+
};
|
|
@@ -6,4 +6,4 @@ export interface ChatPanelProps {
|
|
|
6
6
|
isAtBottom: boolean;
|
|
7
7
|
scrollToBottom: () => void;
|
|
8
8
|
}
|
|
9
|
-
export declare function DevChatPanel({ id, title, input, setInput, isAtBottom, scrollToBottom }: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function DevChatPanel({ id, title, input, setInput, isAtBottom, scrollToBottom, }: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,10 +7,9 @@ import { shareChat } from "../../lib/chat/chatActions";
|
|
|
7
7
|
import { Button } from "../../ui/button";
|
|
8
8
|
import { ButtonScrollToBottom } from "../button-scroll-to-bottom";
|
|
9
9
|
import { ChatShareDialog } from "../chat-share-dialog";
|
|
10
|
-
import {
|
|
11
|
-
import { PromptForm } from "
|
|
12
|
-
|
|
13
|
-
export function DevChatPanel({ id, title, input, setInput, isAtBottom, scrollToBottom }) {
|
|
10
|
+
import { UserMessage } from "../message";
|
|
11
|
+
import { PromptForm } from "./prompt-form";
|
|
12
|
+
export function DevChatPanel({ id, title, input, setInput, isAtBottom, scrollToBottom, }) {
|
|
14
13
|
const [aiState] = useAIState();
|
|
15
14
|
const [messages, setMessages] = useUIState();
|
|
16
15
|
const { submitUserMessage } = useActions();
|
|
@@ -19,7 +18,7 @@ export function DevChatPanel({ id, title, input, setInput, isAtBottom, scrollToB
|
|
|
19
18
|
{
|
|
20
19
|
heading: "部署前端到vercel",
|
|
21
20
|
subheading: "",
|
|
22
|
-
message:
|
|
21
|
+
message: "调用工具中的 dpMtxcli 函数",
|
|
23
22
|
},
|
|
24
23
|
];
|
|
25
24
|
return (_jsxs("div", { className: "fixed inset-x-0 bottom-0 w-full bg-gradient-to-b from-muted/30 from-0% to-muted/30 to-50% duration-300 ease-in-out animate-in dark:from-background/10 dark:from-10% dark:to-background/80 peer-[[data-state=open]]:group-[]:lg:pl-[250px] peer-[[data-state=open]]:group-[]:xl:pl-[300px]", children: [_jsx(ButtonScrollToBottom, { isAtBottom: isAtBottom, scrollToBottom: scrollToBottom }), _jsxs("div", { className: "mx-auto sm:max-w-2xl sm:px-4", children: [_jsx("div", { className: "mb-4 grid grid-cols-2 gap-2 px-4 sm:px-0", children: messages.length === 0 &&
|
|
@@ -32,10 +31,13 @@ export function DevChatPanel({ id, title, input, setInput, isAtBottom, scrollToB
|
|
|
32
31
|
},
|
|
33
32
|
]);
|
|
34
33
|
const responseMessage = await submitUserMessage(example.message);
|
|
35
|
-
setMessages((currentMessages) => [
|
|
34
|
+
setMessages((currentMessages) => [
|
|
35
|
+
...currentMessages,
|
|
36
|
+
responseMessage,
|
|
37
|
+
]);
|
|
36
38
|
}, children: [_jsx("div", { className: "text-sm font-semibold", children: example.heading }), _jsx("div", { className: "text-sm text-zinc-600", children: example.subheading })] }, example.heading))) }), messages?.length >= 2 ? (_jsx("div", { className: "flex h-12 items-center justify-center", children: _jsx("div", { className: "flex space-x-2", children: id && title ? (_jsxs(_Fragment, { children: [_jsxs(Button, { variant: "outline", onClick: () => setShareDialogOpen(true), children: [_jsx(IconShare, { className: "mr-2" }), "Share"] }), _jsx(ChatShareDialog, { open: shareDialogOpen, onOpenChange: setShareDialogOpen, onCopy: () => setShareDialogOpen(false), shareChat: shareChat, chat: {
|
|
37
39
|
id,
|
|
38
40
|
title,
|
|
39
41
|
messages: aiState.messages,
|
|
40
|
-
} })] })) : null }) })) : null,
|
|
42
|
+
} })] })) : null }) })) : null, _jsx("div", { className: "space-y-4 border-t bg-background px-4 py-2 shadow-lg sm:rounded-t-xl sm:border md:py-4", children: _jsx(PromptForm, { input: input, setInput: setInput }) })] })] }));
|
|
41
43
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
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
|
+
import { UserMessage } from "mtxuilib/components/message";
|
|
6
|
+
import { useEnterSubmit } from "mtxuilib/hooks/use-enter-submit";
|
|
7
|
+
import { IconArrowElbow, IconPlus } from "mtxuilib/icons/icons-ai";
|
|
8
|
+
import { Button } from "mtxuilib/ui/button";
|
|
5
9
|
import { nanoid } from "nanoid";
|
|
6
10
|
import { useRouter } from "next/navigation";
|
|
7
11
|
import * as React from "react";
|
|
8
12
|
import Textarea from "react-textarea-autosize";
|
|
9
|
-
import { useEnterSubmit } from "../hooks/use-enter-submit";
|
|
10
|
-
import { IconArrowElbow, IconPlus } from "../icons/icons-ai";
|
|
11
|
-
import { Button } from "../ui/button";
|
|
12
|
-
import { UserMessage } from "./stocks/message";
|
|
13
13
|
export function PromptForm({ input, setInput, }) {
|
|
14
14
|
const router = useRouter();
|
|
15
15
|
const { formRef, onKeyDown } = useEnterSubmit();
|
|
@@ -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
|
}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { MemoizedReactMarkdown } from "mtxuilib/common/markdown";
|
|
4
4
|
import { useStreamableText } from "mtxuilib/hooks/use-streamable-text";
|
|
5
|
+
import { IconOpenAI, IconUser } from "mtxuilib/icons/icons-ai";
|
|
5
6
|
import { cn } from "mtxuilib/lib/utils";
|
|
6
7
|
import { CodeBlock } from "mtxuilib/ui/codeblock";
|
|
7
8
|
import remarkGfm from "remark-gfm";
|
|
8
9
|
import remarkMath from "remark-math";
|
|
9
|
-
import { IconOpenAI, IconUser } from "../../icons/icons-ai";
|
|
10
10
|
import { spinner } from "./spinner";
|
|
11
11
|
export function UserMessage({ children }) {
|
|
12
12
|
return (_jsxs("div", { className: "group relative flex items-start md:-ml-12", children: [_jsx("div", { className: "flex size-[25px] shrink-0 select-none items-center justify-center rounded-md border bg-background shadow-sm", children: _jsx(IconUser, {}) }), _jsx("div", { className: "ml-4 flex-1 space-y-2 overflow-hidden pl-2", children: children })] }));
|
|
@@ -19,8 +19,8 @@ export function BotMessage({ content, className, }) {
|
|
|
19
19
|
},
|
|
20
20
|
code({ node, inline, className, children, ...props }) {
|
|
21
21
|
if (children.length) {
|
|
22
|
-
if (children[0]
|
|
23
|
-
return _jsx("span", { className: "mt-1 animate-pulse cursor-default", children: "\u258D" });
|
|
22
|
+
if (children[0] === "▍") {
|
|
23
|
+
return (_jsx("span", { className: "mt-1 animate-pulse cursor-default", children: "\u258D" }));
|
|
24
24
|
}
|
|
25
25
|
children[0] = children[0].replace("`▍`", "▍");
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ export function BotMessage({ content, className, }) {
|
|
|
28
28
|
if (inline) {
|
|
29
29
|
return (_jsx("code", { className: className, ...props, children: children }));
|
|
30
30
|
}
|
|
31
|
-
return (_jsx(CodeBlock, { language:
|
|
31
|
+
return (_jsx(CodeBlock, { language: match?.[1] || "", value: String(children).replace(/\n$/, ""), ...props }, Math.random()));
|
|
32
32
|
},
|
|
33
33
|
}, children: text }) })] }));
|
|
34
34
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
export const spinner = (_jsx("svg", { fill: "none", stroke: "currentColor", strokeWidth: "1.5", viewBox: "0 0 24 24", strokeLinecap: "round", strokeLinejoin: "round", xmlns: "http://www.w3.org/2000/svg", className: "size-5 animate-spin stroke-zinc-400", children: _jsx("path", { d: "M12 3v3m6.366-.366-2.12 2.12M21 12h-3m.366 6.366-2.12-2.12M12 21v-3m-6.366.366 2.12-2.12M3 12h3m-.366-6.366 2.12 2.12" }) }));
|
|
@@ -31,11 +31,11 @@ export declare const homePageSchema: z.ZodObject<{
|
|
|
31
31
|
footHtml: z.ZodString;
|
|
32
32
|
}, "strip", z.ZodTypeAny, {
|
|
33
33
|
theme: string;
|
|
34
|
-
htmlTitle: string;
|
|
35
34
|
categories: {
|
|
36
35
|
label: string;
|
|
37
36
|
href: string;
|
|
38
37
|
}[];
|
|
38
|
+
htmlTitle: string;
|
|
39
39
|
blogCardItems: {
|
|
40
40
|
summary: string;
|
|
41
41
|
title: string;
|
|
@@ -45,11 +45,11 @@ export declare const homePageSchema: z.ZodObject<{
|
|
|
45
45
|
footHtml: string;
|
|
46
46
|
}, {
|
|
47
47
|
theme: string;
|
|
48
|
-
htmlTitle: string;
|
|
49
48
|
categories: {
|
|
50
49
|
label: string;
|
|
51
50
|
href: string;
|
|
52
51
|
}[];
|
|
52
|
+
htmlTitle: string;
|
|
53
53
|
blogCardItems: {
|
|
54
54
|
summary: string;
|
|
55
55
|
title: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Chat } from "mtxuilib/lib/types";
|
|
2
2
|
export declare function getChats(userId?: string | null): Promise<Chat[]>;
|
|
3
3
|
export declare function getChat(id: string, userId: string): Promise<Chat | null>;
|
|
4
4
|
export declare function removeChat({ id, path }: {
|
|
@@ -96,7 +96,7 @@ export async function shareChat(id) {
|
|
|
96
96
|
}
|
|
97
97
|
export async function saveChat(chat) {
|
|
98
98
|
const session = await auth();
|
|
99
|
-
if (session
|
|
99
|
+
if (session?.user) {
|
|
100
100
|
const pipeline = kv.pipeline();
|
|
101
101
|
pipeline.hmset(`chat:${chat.id}`, chat);
|
|
102
102
|
pipeline.zadd(`user:chat:${chat.userId}`, {
|
|
@@ -114,5 +114,7 @@ export async function refreshHistory(path) {
|
|
|
114
114
|
}
|
|
115
115
|
export async function getMissingKeys() {
|
|
116
116
|
const keysRequired = ["OPENAI_API_KEY"];
|
|
117
|
-
return keysRequired
|
|
117
|
+
return keysRequired
|
|
118
|
+
.map((key) => (process.env[key] ? "" : key))
|
|
119
|
+
.filter((key) => key !== "");
|
|
118
120
|
}
|
|
@@ -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>)[];
|
|
@@ -21,7 +21,7 @@ export declare const countDownTool: {
|
|
|
21
21
|
startValue?: number | undefined;
|
|
22
22
|
endValue?: number | undefined;
|
|
23
23
|
}>;
|
|
24
|
-
generate: ({ stepValue, startValue, endValue, stepLabel, endMessage }: {
|
|
24
|
+
generate: ({ stepValue, startValue, endValue, stepLabel, endMessage, }: {
|
|
25
25
|
stepValue: any;
|
|
26
26
|
startValue: any;
|
|
27
27
|
endValue: any;
|
package/dist/tools/countDown.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { BotCard } from "../components/
|
|
4
|
-
import { StocksSkeleton } from "../components/stocks/stocks-skeleton";
|
|
3
|
+
import { BotCard } from "../components/message";
|
|
5
4
|
import { sleep } from "../lib/utils";
|
|
6
5
|
export const countDownTool = {
|
|
7
6
|
countDown: {
|
|
@@ -15,9 +14,9 @@ export const countDownTool = {
|
|
|
15
14
|
endValue: z.number().min(0).max(100).default(11).describe("结束值"),
|
|
16
15
|
endMessage: z.string().describe("倒数结束后,显示给用户看的一句话"),
|
|
17
16
|
}),
|
|
18
|
-
generate: async function* ({ stepValue, startValue, endValue, stepLabel, endMessage }) {
|
|
17
|
+
generate: async function* ({ stepValue, startValue, endValue, stepLabel, endMessage, }) {
|
|
19
18
|
console.log("计数:", startValue, endValue, stepLabel, endMessage);
|
|
20
|
-
yield (_jsx(BotCard, { children:
|
|
19
|
+
yield (_jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" }));
|
|
21
20
|
let _start = startValue;
|
|
22
21
|
let _end = endValue;
|
|
23
22
|
if (startValue > endValue) {
|
|
@@ -25,7 +24,7 @@ export const countDownTool = {
|
|
|
25
24
|
_end = startValue;
|
|
26
25
|
}
|
|
27
26
|
let curr = _end;
|
|
28
|
-
while (curr
|
|
27
|
+
while (curr !== _start) {
|
|
29
28
|
curr += stepValue;
|
|
30
29
|
await sleep(1000);
|
|
31
30
|
yield (_jsxs(BotCard, { children: [stepLabel, " ", curr] }));
|
|
@@ -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,28 @@
|
|
|
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/message";
|
|
6
|
+
export const bashTool = {
|
|
7
|
+
bashTool: {
|
|
8
|
+
description: "执行bash命令",
|
|
9
|
+
parameters: z.object({
|
|
10
|
+
script: z.string().describe("bash -c %s 这种方式执行"),
|
|
11
|
+
}),
|
|
12
|
+
generate: async function* (params) {
|
|
13
|
+
yield (_jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" }));
|
|
14
|
+
try {
|
|
15
|
+
const projectDir = projectRoot();
|
|
16
|
+
yield (_jsx(BotCard, { children: _jsxs("div", { children: ["\u5F00\u59CB\u6267\u884Cbash\u547D\u4EE4 $", params.script] }) }));
|
|
17
|
+
const result = await exec(`${params.script}`, {
|
|
18
|
+
shell: true,
|
|
19
|
+
cwd: projectDir,
|
|
20
|
+
});
|
|
21
|
+
return (_jsxs(BotCard, { children: ["\u547D\u4EE4\u6267\u884C\u5B8C\u6BD5 ", _jsx("pre", { children: JSON.stringify(result, null, 2) })] }));
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
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" })] }));
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -2,14 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { exec } from "mtxlib/exec";
|
|
3
3
|
import { projectRoot } from "mtxlib/tasks/deploy/vercelHelper";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { BotCard } from "../../components/
|
|
6
|
-
import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
|
|
5
|
+
import { BotCard } from "../../components/message";
|
|
7
6
|
export const diskSpaceReleaseTool = {
|
|
8
7
|
diskSpaceReleaseMtm: {
|
|
9
8
|
description: "释放本地磁盘空间,自动调用相关 bash 安全第将已知可以删除的文件删除",
|
|
10
9
|
parameters: z.any(),
|
|
11
10
|
generate: async function* (params) {
|
|
12
|
-
yield
|
|
11
|
+
yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
|
|
13
12
|
try {
|
|
14
13
|
const projectDir = projectRoot();
|
|
15
14
|
yield (_jsx(BotCard, { children: _jsx("div", { children: "\u6B63\u5728 \u91CA\u653Edocker \u78C1\u76D8\u7A7A\u95F4" }) }));
|
|
@@ -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,43 @@
|
|
|
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/message";
|
|
5
|
+
export const netTunnelTool = {
|
|
6
|
+
netTunnel: {
|
|
7
|
+
description: "启动或者停止网络通道,将调用 cloudflared 命令",
|
|
8
|
+
parameters: z.object({
|
|
9
|
+
action: z.enum(["start", "stop"]),
|
|
10
|
+
token: z.string().optional().describe("token of cloudflared tunnel"),
|
|
11
|
+
}),
|
|
12
|
+
generate: async function* (params) {
|
|
13
|
+
yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
|
|
14
|
+
try {
|
|
15
|
+
yield (_jsx(BotCard, { children: _jsxs("div", { children: ["\u8C03\u7528 cloudflare \u52A8\u4F5C\uFF1A", params.action] }) }));
|
|
16
|
+
const result = await cftunnel_gitpod(params.action);
|
|
17
|
+
return (_jsxs(BotCard, { children: ["\u901A\u9053\u64CD\u4F5C\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 cftunnel_gitpod(action) {
|
|
26
|
+
if (action === "start") {
|
|
27
|
+
console.log("启动 cftunnel_gitpod");
|
|
28
|
+
await exec(`command -v cloudflared || (curl -o /usr/bin/cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 \
|
|
29
|
+
&& chmod +x /usr/bin/cloudflared)`, {
|
|
30
|
+
shell: true,
|
|
31
|
+
env: { ...process.env },
|
|
32
|
+
});
|
|
33
|
+
const cloudflareTunnelToken = "eyJhIjoiNjIzZmFmNzJlZTBkMmFmM2U1ODZlN2NkOWRhZGI3MmIiLCJ0IjoiNmUyMWMwNjAtZjRkOC00NmJjLTk2NjEtODA1M2M0ZGE0MzRlIiwicyI6Ill6TmpPREpoWWpVdE5EWTRNUzAwTVdSbExUazVZbVl0TXpGalpHSmlNRE14WXpOaSJ9";
|
|
34
|
+
exec(`cloudflared tunnel --no-autoupdate run --token ${cloudflareTunnelToken}`, {
|
|
35
|
+
shell: true,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
await exec("pkill cloudflared", {
|
|
40
|
+
shell: true,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { BotCard } from "../../components/
|
|
4
|
-
import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
|
|
3
|
+
import { BotCard } from "../../components/message";
|
|
5
4
|
import { DpMtCfWorker } from "../../components/tool-ui/DpCfWorker";
|
|
6
5
|
import { DpMtxEdge } from "../../components/tool-ui/DpMtxEdge";
|
|
7
6
|
import { VcDeploy } from "../../components/tool-ui/vcDeploy";
|
|
@@ -10,7 +9,7 @@ export const dockerComposeTool = {
|
|
|
10
9
|
description: "调用 docker-compose up",
|
|
11
10
|
parameters: z.any(),
|
|
12
11
|
generate: async function* (params) {
|
|
13
|
-
yield
|
|
12
|
+
yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
|
|
14
13
|
return (_jsx(BotCard, { children: _jsxs("div", { className: "bg-blue-100 p-2 flex gap-2", children: [_jsx(VcDeploy, {}), _jsx(DpMtCfWorker, {}), _jsx(DpMtxEdge, {})] }) }));
|
|
15
14
|
},
|
|
16
15
|
},
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { exec } from "mtxlib/exec";
|
|
3
|
-
import { projectRoot } from "mtxlib/tasks/deploy/vercelHelper";
|
|
3
|
+
import { projectRoot, } from "mtxlib/tasks/deploy/vercelHelper";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { BotCard } from "../../components/
|
|
6
|
-
import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
|
|
5
|
+
import { BotCard } from "../../components/message";
|
|
7
6
|
export const dockerBuildMtmTool = {
|
|
8
7
|
dockerBuildMtm: {
|
|
9
8
|
description: "构建本地 docker 镜像,使用 docker 命令 构建 名称为 mtm 的 docker 镜像, 当用户输入“docker build mtm”之类的命令时,优先调用这个工具",
|
|
10
9
|
parameters: z.any(),
|
|
11
10
|
generate: async function* (params) {
|
|
12
|
-
yield
|
|
11
|
+
yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
|
|
13
12
|
try {
|
|
14
13
|
const projectDir = projectRoot();
|
|
15
14
|
const vercelToken = process.env.VERCEL_TOKEN;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { BotCard } from "../../components/
|
|
4
|
-
import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
|
|
3
|
+
import { BotCard } from "../../components/message";
|
|
5
4
|
import { DpMtCfWorker } from "../../components/tool-ui/DpCfWorker";
|
|
6
5
|
export const deployMtcfWorkerTool = {
|
|
7
6
|
deployMtcfWorker: {
|
|
8
7
|
description: "调用本地脚本,将 mtcf 项目部署到 cloudflared worker",
|
|
9
8
|
parameters: z.any(),
|
|
10
9
|
generate: async function* (params) {
|
|
11
|
-
yield
|
|
10
|
+
yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
|
|
12
11
|
return (_jsx(BotCard, { children: _jsx("div", { className: "bg-blue-100 p-2 flex gap-2", children: _jsx(DpMtCfWorker, {}) }) }));
|
|
13
12
|
},
|
|
14
13
|
},
|