mtxuilib 0.1.121 → 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.
Files changed (74) hide show
  1. package/dist/components/auth/LoginDlg.d.ts +0 -0
  2. package/dist/components/auth/LoginDlg.js +1 -0
  3. package/dist/components/chat.js +3 -1
  4. package/dist/components/dev-bot/DevBot.js +1 -1
  5. package/dist/components/dev-bot/DevBotActions.d.ts +13 -1
  6. package/dist/components/dev-bot/DevBotActions.js +12 -2
  7. package/dist/components/{chat-list.d.ts → dev-bot/chat-list.d.ts} +2 -2
  8. package/dist/components/dev-bot/chat-panel.d.ts +1 -1
  9. package/dist/components/dev-bot/chat-panel.js +9 -7
  10. package/dist/components/{prompt-form.js → dev-bot/prompt-form.js} +4 -4
  11. package/dist/components/{stocks/message.d.ts → message.d.ts} +1 -1
  12. package/dist/components/{stocks/message.js → message.js} +4 -4
  13. package/dist/components/{stocks/spinner.js → spinner.js} +1 -1
  14. package/dist/components/tool-ui/BlogHomePage.z.d.ts +2 -2
  15. package/dist/lib/chat/chatActions.d.ts +1 -1
  16. package/dist/lib/chat/chatActions.js +4 -2
  17. package/dist/tools/countDown.d.ts +1 -1
  18. package/dist/tools/countDown.js +4 -5
  19. package/dist/tools/devTools/bash.js +2 -3
  20. package/dist/tools/devTools/clean.js +2 -3
  21. package/dist/tools/devTools/cloudflareTunnel.js +2 -3
  22. package/dist/tools/devTools/docker-compose.js +2 -3
  23. package/dist/tools/devTools/dockerBuildMtm.js +3 -4
  24. package/dist/tools/devTools/dpMtCfWorkerTool.js +2 -3
  25. package/dist/tools/devTools/dpMtxedge.js +6 -7
  26. package/dist/tools/devTools/getIp.js +2 -3
  27. package/dist/tools/devTools/installOsPackages.js +2 -3
  28. package/dist/tools/devTools/packageRelease.js +5 -6
  29. package/dist/tools/devTools/vcDeploytool.js +4 -5
  30. package/dist/tools/devTools/vncServer.js +2 -3
  31. package/dist/tools/genSiteHeaderBarsTool.js +2 -3
  32. package/dist/tools/hello1Tool.js +2 -3
  33. package/dist/tools/webbot/callAdminBot.d.ts +8 -0
  34. package/dist/tools/webbot/callAdminBot.js +14 -0
  35. package/dist/tools/welcomeAdminTool.js +2 -3
  36. package/package.json +1 -1
  37. package/dist/components/bloggenBot/BlogGenBot.d.ts +0 -8
  38. package/dist/components/bloggenBot/BlogGenBot.js +0 -43
  39. package/dist/components/bloggenBot/BlogGenBotActions.d.ts +0 -20
  40. package/dist/components/bloggenBot/BlogGenBotActions.js +0 -179
  41. package/dist/components/bloggenBot/chat-panel.d.ts +0 -9
  42. package/dist/components/bloggenBot/chat-panel.js +0 -41
  43. package/dist/components/chat-panel.d.ts +0 -9
  44. package/dist/components/chat-panel.js +0 -41
  45. package/dist/components/footer.d.ts +0 -1
  46. package/dist/components/footer.js +0 -6
  47. package/dist/components/stocks/events-skeleton.d.ts +0 -1
  48. package/dist/components/stocks/events-skeleton.js +0 -11
  49. package/dist/components/stocks/events.d.ts +0 -9
  50. package/dist/components/stocks/events.js +0 -5
  51. package/dist/components/stocks/index.js +0 -25
  52. package/dist/components/stocks/stock-purchase.d.ts +0 -10
  53. package/dist/components/stocks/stock-purchase.js +0 -35
  54. package/dist/components/stocks/stock-skeleton.d.ts +0 -1
  55. package/dist/components/stocks/stock-skeleton.js +0 -4
  56. package/dist/components/stocks/stock.d.ts +0 -9
  57. package/dist/components/stocks/stock.js +0 -90
  58. package/dist/components/stocks/stocks-skeleton.d.ts +0 -1
  59. package/dist/components/stocks/stocks-skeleton.js +0 -4
  60. package/dist/components/stocks/stocks.d.ts +0 -9
  61. package/dist/components/stocks/stocks.js +0 -11
  62. package/dist/components/testingBot/TestingBot.d.ts +0 -8
  63. package/dist/components/testingBot/TestingBot.js +0 -43
  64. package/dist/components/testingBot/TestingBotActions.d.ts +0 -16
  65. package/dist/components/testingBot/TestingBotActions.js +0 -122
  66. package/dist/components/testingBot/chat-panel.d.ts +0 -9
  67. package/dist/components/testingBot/chat-panel.js +0 -41
  68. package/dist/components/testingBot/empty-screen.d.ts +0 -1
  69. package/dist/components/testingBot/empty-screen.js +0 -4
  70. package/dist/lib/chat/actions.d.ts +0 -20
  71. package/dist/lib/chat/actions.js +0 -136
  72. /package/dist/components/{chat-list.js → dev-bot/chat-list.js} +0 -0
  73. /package/dist/components/{prompt-form.d.ts → dev-bot/prompt-form.d.ts} +0 -0
  74. /package/dist/components/{stocks/spinner.d.ts → spinner.d.ts} +0 -0
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -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(LzChatList, { messages: messages, isShared: false, session: session })) : (_jsx(EmptyScreen, {})), _jsx("div", { className: "w-full h-px", ref: visibilityRef })] }), _jsx(LzChatPanel, { id: id, input: input, setInput: setInput, isAtBottom: isAtBottom, scrollToBottom: scrollToBottom })] }));
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 { type AIState, type UIState } from "../../lib/chat/actions";
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
+ }[];
@@ -2,10 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import "server-only";
3
3
  import { createOpenAI } from "@ai-sdk/openai";
4
4
  import { createAI, createStreamableValue, getAIState, getMutableAIState, streamUI, } from "ai/rsc";
5
- import { BotMessage, SpinnerMessage } from "mtxuilib/components/stocks/message";
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";
11
9
  import { bashTool } from "../../tools/devTools/bash";
@@ -23,6 +21,7 @@ import { vncServerTool } from "../../tools/devTools/vncServer";
23
21
  import { genSiteHeaderBarsTool } from "../../tools/genSiteHeaderBarsTool";
24
22
  import { helloTool } from "../../tools/hello1Tool";
25
23
  import { welcomeAdminUser } from "../../tools/welcomeAdminTool";
24
+ import { BotCard, BotMessage, SpinnerMessage, UserMessage } from "../message";
26
25
  async function submitUserMessage(content) {
27
26
  "use server";
28
27
  const aiState = getMutableAIState();
@@ -151,3 +150,14 @@ export const AIDev = createAI({
151
150
  }
152
151
  },
153
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
+ };
@@ -1,5 +1,5 @@
1
- import { UIState } from "../lib/chat/actions";
2
- import { Session } from "../lib/types";
1
+ import type { Session } from "mtxuilib/lib/types";
2
+ import type { UIState } from "./DevBotActions";
3
3
  export interface ChatList {
4
4
  messages: UIState;
5
5
  session?: Session;
@@ -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 { FooterText } from "../footer";
11
- import { PromptForm } from "../prompt-form";
12
- import { UserMessage } from "../stocks/message";
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: `调用工具中的 dpMtxcli 函数`,
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) => [...currentMessages, responseMessage]);
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, _jsxs("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 }), _jsx(FooterText, { className: "hidden sm:block" })] })] })] }));
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
  }
@@ -2,14 +2,14 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
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
- import { StreamableValue } from "ai/rsc";
1
+ import { type StreamableValue } from "ai/rsc";
2
2
  export declare function UserMessage({ children }: {
3
3
  children: React.ReactNode;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -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: (match && match[1]) || "", value: String(children).replace(/\n$/, ""), ...props }, Math.random()));
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
- 'use client';
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 { type Chat } from "mtxuilib/lib/types";
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 && session.user) {
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.map((key) => (process.env[key] ? "" : key)).filter((key) => key !== "");
117
+ return keysRequired
118
+ .map((key) => (process.env[key] ? "" : key))
119
+ .filter((key) => key !== "");
118
120
  }
@@ -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;
@@ -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/stocks";
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: _jsx(StocksSkeleton, {}) }));
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 != _start) {
27
+ while (curr !== _start) {
29
28
  curr += stepValue;
30
29
  await sleep(1000);
31
30
  yield (_jsxs(BotCard, { children: [stepLabel, " ", curr] }));
@@ -2,8 +2,7 @@ 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/stocks";
6
- import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
5
+ import { BotCard } from "../../components/message";
7
6
  export const bashTool = {
8
7
  bashTool: {
9
8
  description: "执行bash命令",
@@ -11,7 +10,7 @@ export const bashTool = {
11
10
  script: z.string().describe("bash -c %s 这种方式执行"),
12
11
  }),
13
12
  generate: async function* (params) {
14
- yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
13
+ yield (_jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" }));
15
14
  try {
16
15
  const projectDir = projectRoot();
17
16
  yield (_jsx(BotCard, { children: _jsxs("div", { children: ["\u5F00\u59CB\u6267\u884Cbash\u547D\u4EE4 $", params.script] }) }));
@@ -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/stocks";
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 (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
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" }) }));
@@ -1,8 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { exec } from "mtxlib/exec";
3
3
  import { z } from "zod";
4
- import { BotCard } from "../../components/stocks";
5
- import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
4
+ import { BotCard } from "../../components/message";
6
5
  export const netTunnelTool = {
7
6
  netTunnel: {
8
7
  description: "启动或者停止网络通道,将调用 cloudflared 命令",
@@ -11,7 +10,7 @@ export const netTunnelTool = {
11
10
  token: z.string().optional().describe("token of cloudflared tunnel"),
12
11
  }),
13
12
  generate: async function* (params) {
14
- yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
13
+ yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
15
14
  try {
16
15
  yield (_jsx(BotCard, { children: _jsxs("div", { children: ["\u8C03\u7528 cloudflare \u52A8\u4F5C\uFF1A", params.action] }) }));
17
16
  const result = await cftunnel_gitpod(params.action);
@@ -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/stocks";
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 (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
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/stocks";
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 (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
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/stocks";
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 (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
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
  },
@@ -1,16 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { join } from "node:path";
3
3
  import { exec } from "mtxlib/exec";
4
- import { genVercelConfig, projectRoot, writeVercelConfig } from "mtxlib/tasks/deploy/vercelHelper";
4
+ import { genVercelConfig, projectRoot, writeVercelConfig, } from "mtxlib/tasks/deploy/vercelHelper";
5
5
  import { z } from "zod";
6
- import { BotCard } from "../../components/stocks";
7
- import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
6
+ import { BotCard } from "../../components/message";
8
7
  export const deployMtxEdgeTool = {
9
8
  deployMtxedge: {
10
9
  description: "部署名为 mtxedge 的项目,到 cloudflare page ",
11
10
  parameters: z.any(),
12
11
  generate: async function* (params) {
13
- yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
12
+ yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
14
13
  try {
15
14
  const cloudflaredPageProjectName = "mtxedge";
16
15
  const projectDir = projectRoot();
@@ -39,7 +38,7 @@ export const deployMtxEdgeTool = {
39
38
  cwd: projectDir,
40
39
  });
41
40
  yield (_jsx(BotCard, { children: _jsx("div", { children: "\u62C9\u53D6vercel \u914D\u7F6E\uFF0C\u5B8C\u6210\uFF0C\u5F00\u59CB\u672C\u5730\u6784\u5EFA" }) }));
42
- await exec(`bunx vercel build --prod --local-config vercel.json`, {
41
+ await exec("bunx vercel build --prod --local-config vercel.json", {
43
42
  shell: true,
44
43
  cwd: projectDir,
45
44
  env: {
@@ -49,7 +48,7 @@ export const deployMtxEdgeTool = {
49
48
  });
50
49
  yield (_jsx(BotCard, { children: _jsx("div", { children: "\u672C\u5730\u6784\u5EFA\u5B8C\u6210\uFF0C\u68C0\u6D4B\u751F\u6210\u89C1\u8FC7\uFF0C\u5E76\u505A\u5FC5\u8981\u7684\u8BBE\u7F6E" }) }));
51
50
  await removeVercelNoneEdgeFunctions(projectDir);
52
- await exec(`bunx @cloudflare/next-on-pages -s`, {
51
+ await exec("bunx @cloudflare/next-on-pages -s", {
53
52
  shell: true,
54
53
  env: process.env,
55
54
  cwd: projectDir,
@@ -71,7 +70,7 @@ export const deployMtxEdgeTool = {
71
70
  async function removeVercelNoneEdgeFunctions(dirBase) {
72
71
  const fs = await import("node:fs");
73
72
  const functionsPath = `${dirBase}/.vercel/output/functions`;
74
- const dirToRmove = ["/api.v1/trpc2", "/admin"];
73
+ const dirToRmove = ["/api/trpc", "/admin"];
75
74
  for (const f of dirToRmove) {
76
75
  if (fs.existsSync(join(functionsPath, f))) {
77
76
  fs.rmSync(join(functionsPath, f), { recursive: true });
@@ -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/stocks";
4
- import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
3
+ import { BotCard } from "../../components/message";
5
4
  export const getExternalIpTool = {
6
5
  getExternalIp: {
7
6
  description: "通过请问第三方api 获取当前服务器对外请求的公网IP",
@@ -12,7 +11,7 @@ export const getExternalIpTool = {
12
11
  .describe("ip 查询供应商名称,一般可以不填"),
13
12
  }),
14
13
  generate: async function* (params) {
15
- yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
14
+ yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
16
15
  try {
17
16
  yield _jsx(BotCard, { children: "\u5F00\u59CB\u8BF7\u6C42\u5916\u7F51\uFF0C\u63A2\u6D4B\u5F53\u524D\u670D\u52A1\u5668\u7684IP" });
18
17
  const ipInfo = await getIp();
@@ -1,8 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { exec } from "mtxlib/exec";
3
3
  import { z } from "zod";
4
- import { BotCard } from "../../components/stocks";
5
- import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
4
+ import { BotCard } from "../../components/message";
6
5
  export const installOsPackagesTool = {
7
6
  installOsPackages: {
8
7
  description: "在当前 linux 系统,安装常用的工具软件,内部将使用 类似 apt get install -y git curl 的方式安装管理员已经预先指定的软件包",
@@ -10,7 +9,7 @@ export const installOsPackagesTool = {
10
9
  .object({})
11
10
  .optional(),
12
11
  generate: async function* (params) {
13
- yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
12
+ yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
14
13
  try {
15
14
  yield _jsx(BotCard, { children: "\u5F00\u59CB\u8BF7\u6C42\u5916\u7F51\uFF0C\u63A2\u6D4B\u5F53\u524D\u670D\u52A1\u5668\u7684IP" });
16
15
  const result = await installOsPackages();
@@ -1,16 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { join, resolve } from "path";
2
+ import { join, resolve } from "node:path";
3
3
  import { exec } from "mtxlib/exec";
4
4
  import { getWorkspacePackages, patchVersion, projectRoot, } from "mtxlib/tasks/deploy/vercelHelper";
5
5
  import { z } from "zod";
6
- import { BotCard } from "../../components/stocks";
7
- import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
6
+ import { BotCard } from "../../components/message";
8
7
  export const releasePackagesTool = {
9
8
  releasePackages: {
10
9
  description: "处于开发环境中,调用对应的脚本 将项目下的 npm packages 项目构建,打包,最后发布到 npm 仓库",
11
10
  parameters: z.any(),
12
11
  generate: async function* (params) {
13
- yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
12
+ yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
14
13
  try {
15
14
  const projectDir = projectRoot();
16
15
  const vercelToken = process.env.VERCEL_TOKEN;
@@ -25,7 +24,7 @@ export const releasePackagesTool = {
25
24
  yield _jsx(BotCard, { children: "\u5F00\u59CB\u53D1\u5E03\u5230 npm \u4ED3\u5E93 " });
26
25
  const mtxcliProjectDir = join(projectDir, "apps/mtxcli");
27
26
  console.log(`bun build: ${mtxcliProjectDir}`);
28
- await exec(`npx run build`, {
27
+ await exec("npx run build", {
29
28
  cwd: mtxcliProjectDir,
30
29
  env: {
31
30
  ...process.env,
@@ -33,7 +32,7 @@ export const releasePackagesTool = {
33
32
  },
34
33
  });
35
34
  patchVersion(resolve(mtxcliProjectDir, "package.json"));
36
- await exec(`npm publish`, { cwd: mtxcliProjectDir });
35
+ await exec("npm publish", { cwd: mtxcliProjectDir });
37
36
  return (_jsx(BotCard, { children: _jsx("div", { children: "\u5B8C\u6210" }) }));
38
37
  }
39
38
  catch (e) {
@@ -1,16 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { resolve } from "path";
2
+ import { resolve } from "node:path";
3
3
  import { exec } from "mtxlib/exec";
4
- import { genVercelConfig, projectRoot, writeVercelConfig } from "mtxlib/tasks/deploy/vercelHelper";
4
+ import { genVercelConfig, projectRoot, writeVercelConfig, } from "mtxlib/tasks/deploy/vercelHelper";
5
5
  import { z } from "zod";
6
- import { BotCard } from "../../components/stocks";
7
- import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
6
+ import { BotCard } from "../../components/message";
8
7
  export const vcDeployTool = {
9
8
  vcDeploy: {
10
9
  description: "部署主项目到vercel",
11
10
  parameters: z.any(),
12
11
  generate: async function* (params) {
13
- yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
12
+ yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
14
13
  try {
15
14
  const projectDir = projectRoot();
16
15
  const vercelToken = process.env.VERCEL_TOKEN;
@@ -6,8 +6,7 @@ import { commandExistAsync, exec } from "mtxlib/exec";
6
6
  import { isUbuntu, setupOsUser } from "mtxlib/mtos";
7
7
  import { isGitpod } from "mtxlib/utils";
8
8
  import { z } from "zod";
9
- import { BotCard } from "../../components/stocks";
10
- import { StocksSkeleton } from "../../components/stocks/stocks-skeleton";
9
+ import { BotCard } from "../../components/message";
11
10
  export const vncServerTool = {
12
11
  vncServer: {
13
12
  description: "启动或停止本地的 vncserver 服务",
@@ -15,7 +14,7 @@ export const vncServerTool = {
15
14
  action: z.enum(["start", "stop"]),
16
15
  }),
17
16
  generate: async function* (params) {
18
- yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
17
+ yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
19
18
  try {
20
19
  yield (_jsx(BotCard, { children: _jsxs("div", { children: ["\u5F00\u59CB\u542F\u52A8vnc\uFF1A", params.action] }) }));
21
20
  const result = await startKasmVnc();
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { z } from "zod";
3
- import { BotCard } from "../components/stocks";
4
- import { StocksSkeleton } from "../components/stocks/stocks-skeleton";
3
+ import { BotCard } from "../components/message";
5
4
  import { DemoCategoryGen } from "../components/tool-ui/DemoCategoryGen";
6
5
  export const genSiteHeaderBarsTool = {
7
6
  genSiteHeaderBars: {
@@ -10,7 +9,7 @@ export const genSiteHeaderBarsTool = {
10
9
  categories: z.string().array(),
11
10
  }),
12
11
  generate: async function* (params) {
13
- yield (_jsx(BotCard, { children: _jsx(StocksSkeleton, {}) }));
12
+ yield _jsx(BotCard, { children: "\u52A0\u8F7D\u4E2D" });
14
13
  return (_jsx(BotCard, { children: _jsx(DemoCategoryGen, { categoryTexts: params.categories }) }));
15
14
  },
16
15
  },