cue-console 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +33 -0
- package/bin/cue-console.js +82 -0
- package/components.json +22 -0
- package/next-env.d.ts +6 -0
- package/next.config.ts +11 -0
- package/package.json +61 -0
- package/postcss.config.mjs +7 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/next.svg +1 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +304 -0
- package/src/app/layout.tsx +36 -0
- package/src/app/page.tsx +109 -0
- package/src/components/chat-composer.tsx +493 -0
- package/src/components/chat-view.tsx +1463 -0
- package/src/components/conversation-list.tsx +525 -0
- package/src/components/create-group-dialog.tsx +220 -0
- package/src/components/markdown-renderer.tsx +53 -0
- package/src/components/payload-card.tsx +275 -0
- package/src/components/ui/avatar.tsx +53 -0
- package/src/components/ui/badge.tsx +46 -0
- package/src/components/ui/button.tsx +63 -0
- package/src/components/ui/collapsible.tsx +46 -0
- package/src/components/ui/dialog.tsx +143 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/scroll-area.tsx +59 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/lib/actions.ts +300 -0
- package/src/lib/db.ts +581 -0
- package/src/lib/types.ts +89 -0
- package/src/lib/utils.ts +135 -0
- package/tsconfig.json +34 -0
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { clsx, type ClassValue } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
|
|
4
|
+
export function cn(...inputs: ClassValue[]) {
|
|
5
|
+
return twMerge(clsx(inputs));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Agent name parsing
|
|
9
|
+
export function parseAgentName(name: string): {
|
|
10
|
+
adjective: string;
|
|
11
|
+
animal: string;
|
|
12
|
+
number: string;
|
|
13
|
+
} {
|
|
14
|
+
const parts = name.split("-");
|
|
15
|
+
if (parts.length >= 3) {
|
|
16
|
+
return {
|
|
17
|
+
adjective: parts[0],
|
|
18
|
+
animal: parts[1],
|
|
19
|
+
number: parts[2],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return { adjective: "", animal: name, number: "" };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Map animal name -> emoji
|
|
26
|
+
const animalEmojis: Record<string, string> = {
|
|
27
|
+
fox: "ðĶ",
|
|
28
|
+
deer: "ðĶ",
|
|
29
|
+
owl: "ðĶ",
|
|
30
|
+
wolf: "ðš",
|
|
31
|
+
bear: "ðŧ",
|
|
32
|
+
eagle: "ðĶ
",
|
|
33
|
+
lynx: "ðą",
|
|
34
|
+
hawk: "ðĶ
",
|
|
35
|
+
lion: "ðĶ",
|
|
36
|
+
tiger: "ðŊ",
|
|
37
|
+
panda: "ðž",
|
|
38
|
+
koala: "ðĻ",
|
|
39
|
+
rabbit: "ð°",
|
|
40
|
+
cat: "ðą",
|
|
41
|
+
dog: "ð",
|
|
42
|
+
horse: "ðī",
|
|
43
|
+
dolphin: "ðŽ",
|
|
44
|
+
whale: "ð",
|
|
45
|
+
shark: "ðĶ",
|
|
46
|
+
octopus: "ð",
|
|
47
|
+
penguin: "ð§",
|
|
48
|
+
flamingo: "ðĶĐ",
|
|
49
|
+
peacock: "ðĶ",
|
|
50
|
+
swan: "ðĶĒ",
|
|
51
|
+
parrot: "ðĶ",
|
|
52
|
+
dragon: "ð",
|
|
53
|
+
unicorn: "ðĶ",
|
|
54
|
+
butterfly: "ðĶ",
|
|
55
|
+
bee: "ð",
|
|
56
|
+
ant: "ð",
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export function getAgentEmoji(name: string): string {
|
|
60
|
+
const { animal } = parseAgentName(name);
|
|
61
|
+
return animalEmojis[animal.toLowerCase()] || "ðĪ";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Time formatting - convert UTC time to Asia/Shanghai
|
|
65
|
+
export function formatTime(dateStr: string): string {
|
|
66
|
+
// The database stores UTC time
|
|
67
|
+
const date = new Date(dateStr + "Z");
|
|
68
|
+
const now = new Date();
|
|
69
|
+
const diff = now.getTime() - date.getTime();
|
|
70
|
+
|
|
71
|
+
if (diff < 60000) {
|
|
72
|
+
return "just now";
|
|
73
|
+
}
|
|
74
|
+
if (diff < 3600000) {
|
|
75
|
+
return `${Math.floor(diff / 60000)}m ago`;
|
|
76
|
+
}
|
|
77
|
+
if (diff < 86400000) {
|
|
78
|
+
return date.toLocaleTimeString("en-US", {
|
|
79
|
+
hour: "2-digit",
|
|
80
|
+
minute: "2-digit",
|
|
81
|
+
hour12: false,
|
|
82
|
+
timeZone: "Asia/Shanghai",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return date.toLocaleDateString("en-US", {
|
|
86
|
+
month: "2-digit",
|
|
87
|
+
day: "2-digit",
|
|
88
|
+
timeZone: "Asia/Shanghai",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function formatFullTime(dateStr: string): string {
|
|
93
|
+
const date = new Date(dateStr + "Z");
|
|
94
|
+
return date.toLocaleString("en-US", {
|
|
95
|
+
month: "2-digit",
|
|
96
|
+
day: "2-digit",
|
|
97
|
+
hour: "2-digit",
|
|
98
|
+
minute: "2-digit",
|
|
99
|
+
second: "2-digit",
|
|
100
|
+
hour12: false,
|
|
101
|
+
timeZone: "Asia/Shanghai",
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Waiting duration
|
|
106
|
+
export function getWaitingDuration(dateStr: string): string {
|
|
107
|
+
const date = new Date(dateStr + "Z");
|
|
108
|
+
const now = new Date();
|
|
109
|
+
const diff = now.getTime() - date.getTime();
|
|
110
|
+
|
|
111
|
+
const minutes = Math.floor(diff / 60000);
|
|
112
|
+
const seconds = Math.floor((diff % 60000) / 1000);
|
|
113
|
+
|
|
114
|
+
if (minutes > 0) {
|
|
115
|
+
return `${minutes}m${seconds}s`;
|
|
116
|
+
}
|
|
117
|
+
return `${seconds}s`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Truncate text
|
|
121
|
+
export function truncateText(text: string, maxLength: number = 30): string {
|
|
122
|
+
if (text.length <= maxLength) return text;
|
|
123
|
+
return text.slice(0, maxLength) + "...";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// @ mention parsing
|
|
127
|
+
export function parseAtMentions(text: string): string[] {
|
|
128
|
+
const regex = /@([\w-]+)/g;
|
|
129
|
+
const matches = text.matchAll(regex);
|
|
130
|
+
return [...matches].map((m) => m[1]);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function removeAtMentions(text: string): string {
|
|
134
|
+
return text.replace(/@[\w-]+\s*/g, "").trim();
|
|
135
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2017",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "react-jsx",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [
|
|
17
|
+
{
|
|
18
|
+
"name": "next"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["./src/*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"include": [
|
|
26
|
+
"next-env.d.ts",
|
|
27
|
+
"**/*.ts",
|
|
28
|
+
"**/*.tsx",
|
|
29
|
+
".next/types/**/*.ts",
|
|
30
|
+
".next/dev/types/**/*.ts",
|
|
31
|
+
"**/*.mts"
|
|
32
|
+
],
|
|
33
|
+
"exclude": ["node_modules"]
|
|
34
|
+
}
|