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.
@@ -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
+ }