totem-llm 0.3.5 → 0.4.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/lib/formatter.js +206 -0
- package/lib/launcher.js +64 -28
- package/lib/setup.js +1 -1
- package/package.json +1 -1
- package/server/public/_index.html +7 -7
- package/server/public/assets/{404-56d107aa.js → 404-b9e84316.js} +1 -1
- package/server/public/assets/{RunDetailPage-da6aa377.js → RunDetailPage-f74368e1.js} +1 -1
- package/server/public/assets/{RunHistoryPage-2fcb4325.js → RunHistoryPage-432358df.js} +1 -1
- package/server/public/assets/{Trans-820f1dad.js → Trans-308f36d6.js} +1 -1
- package/server/public/assets/{cron-307d3fc6.js → cron-dfd47d9d.js} +1 -1
- package/server/public/assets/{files-676613ed.js → files-40998f84.js} +1 -1
- package/server/public/assets/{index-65184421.js → index-04b8b272.js} +1 -1
- package/server/public/assets/{index-ec3efa1e.js → index-0e2cd529.js} +1 -1
- package/server/public/assets/{index-671239cd.js → index-14be6ea8.js} +1 -1
- package/server/public/assets/{index-2aac91d0.js → index-1ee26989.js} +3 -3
- package/server/public/assets/{index-f9305828.js → index-202992ed.js} +1 -1
- package/server/public/assets/{index-df293c50.js → index-21157170.js} +1 -1
- package/server/public/assets/{index-72544df5.js → index-2317e7bf.js} +1 -1
- package/server/public/assets/{index-44ab5f11.js → index-28476ae3.js} +1 -1
- package/server/public/assets/{index-4750915e.js → index-2a122ffc.js} +1 -1
- package/server/public/assets/{index-5033e1e2.js → index-2c473fd8.js} +2 -2
- package/server/public/assets/{index-d29fdeda.js → index-305b79a5.js} +1 -1
- package/server/public/assets/{index-d54b0575.js → index-34fe9c27.js} +1 -1
- package/server/public/assets/{index-3cb59d82.js → index-36acf56a.js} +1 -1
- package/server/public/assets/{index-a2978aa0.js → index-387c6117.js} +2 -2
- package/server/public/assets/{index-2d84e5fe.js → index-41afab73.js} +1 -1
- package/server/public/assets/{index-841db586.js → index-449280b3.js} +1 -1
- package/server/public/assets/{index-e035f9fa.js → index-45bcde52.js} +2 -2
- package/server/public/assets/{index-80edec8f.js → index-4aa70062.js} +1 -1
- package/server/public/assets/{index-cd6bc090.js → index-5911cdab.js} +1 -1
- package/server/public/assets/{index-efee6d1f.js → index-620c8910.js} +1 -1
- package/server/public/assets/{index-33ded078.js → index-6615fb87.js} +1 -1
- package/server/public/assets/{index-b49f94f1.js → index-69339b2c.js} +1 -1
- package/server/public/assets/{index-631fc042.js → index-70110b81.js} +1 -1
- package/server/public/assets/{index-574ed823.js → index-72879f52.js} +2 -2
- package/server/public/assets/{index-882e468e.js → index-7a4311ac.js} +1 -1
- package/server/public/assets/{index-fce187ac.js → index-823d8660.js} +1 -1
- package/server/public/assets/{index-1fe43260.js → index-874c0495.js} +1 -1
- package/server/public/assets/{index-6679334a.js → index-895c8c16.js} +1 -1
- package/server/public/assets/{index-6d56c896.js → index-93558484.js} +2 -2
- package/server/public/assets/{index-ed9034ac.js → index-988da2b0.js} +1 -1
- package/server/public/assets/{index-4e8689f1.js → index-99f75391.js} +1 -1
- package/server/public/assets/{index-01932fa1.js → index-a14b4fe3.js} +1 -1
- package/server/public/assets/{index-0bf4fb6b.js → index-a8fe483a.js} +1 -1
- package/server/public/assets/{index-ae4f557d.js → index-aca9b702.js} +2 -2
- package/server/public/assets/{index-1c653bbf.js → index-b31c3faf.js} +2 -2
- package/server/public/assets/{index-4277cf52.js → index-c712996e.js} +1 -1
- package/server/public/assets/{index-6bd7928a.js → index-ed14fe75.js} +1 -1
- package/server/public/assets/{index-e58bf860.js → index-f696a7cf.js} +1 -1
- package/server/public/assets/{index-27cc497c.js → index-fc994fe1.js} +1 -1
- package/server/public/assets/{main-0b9e408b.js → main-34958ff6.js} +1 -1
- package/server/public/assets/{mcpServers-1686e782.js → mcpServers-9495fe60.js} +1 -1
- package/server/public/assets/{moment-75486807.js → moment-49fc1b76.js} +1 -1
- package/server/public/assets/{purify-eb750cf4.js → purify-17c89583.js} +1 -1
- package/server/public/assets/{react-beautiful-dnd.esm-bb85eef1.js → react-beautiful-dnd.esm-149a7a55.js} +1 -1
- package/server/public/assets/{truncate-06273256.js → truncate-dd7b0c29.js} +1 -1
- package/server/public/index.js +27 -27
- package/totem.features.cjs +1 -1
package/lib/formatter.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting utilities for professional, modern CLI output using ANSI color codes.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// ANSI color codes
|
|
6
|
+
const colors = {
|
|
7
|
+
reset: "\x1b[0m",
|
|
8
|
+
bold: "\x1b[1m",
|
|
9
|
+
dim: "\x1b[2m",
|
|
10
|
+
bright: "\x1b[1m",
|
|
11
|
+
|
|
12
|
+
// Foreground colors
|
|
13
|
+
black: "\x1b[30m",
|
|
14
|
+
red: "\x1b[31m",
|
|
15
|
+
green: "\x1b[32m",
|
|
16
|
+
yellow: "\x1b[33m",
|
|
17
|
+
blue: "\x1b[34m",
|
|
18
|
+
magenta: "\x1b[35m",
|
|
19
|
+
cyan: "\x1b[36m",
|
|
20
|
+
white: "\x1b[37m",
|
|
21
|
+
gray: "\x1b[90m",
|
|
22
|
+
|
|
23
|
+
// Bright foreground colors
|
|
24
|
+
brightRed: "\x1b[91m",
|
|
25
|
+
brightGreen: "\x1b[92m",
|
|
26
|
+
brightYellow: "\x1b[93m",
|
|
27
|
+
brightBlue: "\x1b[94m",
|
|
28
|
+
brightMagenta: "\x1b[95m",
|
|
29
|
+
brightCyan: "\x1b[96m",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Symbols
|
|
33
|
+
const symbols = {
|
|
34
|
+
dot: "●",
|
|
35
|
+
arrow: "→",
|
|
36
|
+
check: "✓",
|
|
37
|
+
cross: "✕",
|
|
38
|
+
dash: "─",
|
|
39
|
+
pipe: "│",
|
|
40
|
+
corner: "└",
|
|
41
|
+
tee: "├",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Format text with color and styling
|
|
46
|
+
* @param {string} text - Text to format
|
|
47
|
+
* @param {string} color - Color key from colors object
|
|
48
|
+
* @param {string} style - Optional style: 'bold', 'dim'
|
|
49
|
+
* @returns {string}
|
|
50
|
+
*/
|
|
51
|
+
export function colorize(text, color = "white", style) {
|
|
52
|
+
const colorCode = colors[color] || colors.white;
|
|
53
|
+
const styleCode = style === "bold" ? colors.bold : style === "dim" ? colors.dim : "";
|
|
54
|
+
return `${styleCode}${colorCode}${text}${colors.reset}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Format a section header
|
|
59
|
+
* @param {string} title - Header text
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
export function header(title) {
|
|
63
|
+
const line = symbols.dash.repeat(70);
|
|
64
|
+
return `\n${colorize(line, "cyan")}\n${colorize(title, "cyan", "bold")}\n${colorize(line, "cyan")}\n`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Format a status line with label and value
|
|
69
|
+
* @param {string} label - Label text
|
|
70
|
+
* @param {string} value - Value text
|
|
71
|
+
* @param {string} valueColor - Color for value
|
|
72
|
+
* @returns {string}
|
|
73
|
+
*/
|
|
74
|
+
export function statusLine(label, value, valueColor = "brightGreen") {
|
|
75
|
+
const paddedLabel = label.padEnd(25);
|
|
76
|
+
return ` ${colorize(paddedLabel, "gray")} ${colorize(value, valueColor)}\n`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Format a section with a title and items
|
|
81
|
+
* @param {string} title - Section title
|
|
82
|
+
* @param {string[]} items - Array of items to display
|
|
83
|
+
* @returns {string}
|
|
84
|
+
*/
|
|
85
|
+
export function section(title, items = []) {
|
|
86
|
+
let output = `\n${colorize(`${symbols.tee} ${title}`, "brightCyan", "bold")}\n`;
|
|
87
|
+
items.forEach((item, index) => {
|
|
88
|
+
const isLast = index === items.length - 1;
|
|
89
|
+
const prefix = isLast ? symbols.corner : symbols.tee;
|
|
90
|
+
output += ` ${colorize(prefix, "cyan")} ${item}\n`;
|
|
91
|
+
});
|
|
92
|
+
return output;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Format a highlighted box around text
|
|
97
|
+
* @param {string} text - Text to highlight
|
|
98
|
+
* @param {string} color - Color for the box
|
|
99
|
+
* @returns {string}
|
|
100
|
+
*/
|
|
101
|
+
export function highlightBox(text, color = "brightYellow") {
|
|
102
|
+
const width = Math.max(text.split("\n").map((l) => l.length).reduce((a, b) => Math.max(a, b), 0)) + 4;
|
|
103
|
+
const line = colorize(symbols.dash.repeat(width), color);
|
|
104
|
+
const paddedText = text
|
|
105
|
+
.split("\n")
|
|
106
|
+
.map((l) => ` ${l}`)
|
|
107
|
+
.join("\n");
|
|
108
|
+
|
|
109
|
+
return `\n${line}\n${colorize(paddedText, color, "bold")}\n${line}\n`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Format a clickable/highlighted URL
|
|
114
|
+
* @param {string} url - The URL
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
export function urlStyle(url) {
|
|
118
|
+
return colorize(url, "brightBlue", "bold");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Format a success message with icon
|
|
123
|
+
* @param {string} message - Message text
|
|
124
|
+
* @returns {string}
|
|
125
|
+
*/
|
|
126
|
+
export function success(message) {
|
|
127
|
+
return `${colorize(symbols.check, "brightGreen", "bold")} ${colorize(message, "brightGreen")}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Format an info message with icon
|
|
132
|
+
* @param {string} message - Message text
|
|
133
|
+
* @returns {string}
|
|
134
|
+
*/
|
|
135
|
+
export function info(message) {
|
|
136
|
+
return `${colorize(symbols.dot, "brightBlue")} ${colorize(message, "white")}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Format a warning message
|
|
141
|
+
* @param {string} message - Message text
|
|
142
|
+
* @returns {string}
|
|
143
|
+
*/
|
|
144
|
+
export function warning(message) {
|
|
145
|
+
return `${colorize(symbols.cross, "brightYellow")} ${colorize(message, "brightYellow")}`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Format an error message
|
|
150
|
+
* @param {string} message - Message text
|
|
151
|
+
* @returns {string}
|
|
152
|
+
*/
|
|
153
|
+
export function error(message) {
|
|
154
|
+
return `${colorize(symbols.cross, "brightRed")} ${colorize(message, "brightRed")}`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Create a formatted table row
|
|
159
|
+
* @param {string[]} cells - Array of cell contents
|
|
160
|
+
* @param {number[]} widths - Array of column widths
|
|
161
|
+
* @returns {string}
|
|
162
|
+
*/
|
|
163
|
+
export function tableRow(cells, widths) {
|
|
164
|
+
return cells
|
|
165
|
+
.map((cell, i) => {
|
|
166
|
+
const width = widths[i] || 20;
|
|
167
|
+
return String(cell).padEnd(width);
|
|
168
|
+
})
|
|
169
|
+
.join(" ");
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Format application startup banner
|
|
174
|
+
* @param {string} version - App version
|
|
175
|
+
* @param {string} environment - Environment name
|
|
176
|
+
* @returns {string}
|
|
177
|
+
*/
|
|
178
|
+
export function startupBanner(version, environment) {
|
|
179
|
+
const banner = `
|
|
180
|
+
████████╗ ██████╗ ████████╗███████╗███╗ ███╗ ██╗ ██╗ ███╗ ███╗
|
|
181
|
+
╚══██╔══╝██╔═══██╗╚══██╔══╝██╔════╝████╗ ████║ ██║ ██║ ████╗ ████║
|
|
182
|
+
██║ ██║ ██║ ██║ █████╗ ██╔████╔██║ ██║ ██║ ██╔████╔██║
|
|
183
|
+
██║ ██║ ██║ ██║ ██╔══╝ ██║╚██╔╝██║ ██║ ██║ ██║╚██╔╝██║
|
|
184
|
+
██║ ╚██████╔╝ ██║ ███████╗██║ ╚═╝ ██║ ███████╗███████╗██║ ╚═╝ ██║
|
|
185
|
+
╚═╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚══════╝╚══════╝╚═╝ ╚═╝
|
|
186
|
+
`;
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
colorize(banner, "cyan") +
|
|
190
|
+
`\n ${colorize("Your Private AI", "brightCyan", "bold")}\n` +
|
|
191
|
+
` ${colorize("v" + version, "dim")}\n` +
|
|
192
|
+
(environment ? ` Environment: ${colorize(environment, "yellow")}\n` : "") +
|
|
193
|
+
"\n"
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Format a divider line
|
|
199
|
+
* @param {string} color - Color for the divider
|
|
200
|
+
* @returns {string}
|
|
201
|
+
*/
|
|
202
|
+
export function divider(color = "cyan") {
|
|
203
|
+
return colorize(symbols.dash.repeat(80), color) + "\n";
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { colors, symbols };
|
package/lib/launcher.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { appendFileSync, mkdirSync, writeFileSync } from "fs";
|
|
4
|
-
import { getEnv } from "./config.js";
|
|
4
|
+
import { getEnv, getStorageDir } from "./config.js";
|
|
5
5
|
import { getPackageVersion } from "./version.js";
|
|
6
|
+
import {
|
|
7
|
+
startupBanner,
|
|
8
|
+
header,
|
|
9
|
+
statusLine,
|
|
10
|
+
section,
|
|
11
|
+
highlightBox,
|
|
12
|
+
urlStyle,
|
|
13
|
+
success,
|
|
14
|
+
info,
|
|
15
|
+
warning,
|
|
16
|
+
error,
|
|
17
|
+
divider,
|
|
18
|
+
} from "./formatter.js";
|
|
6
19
|
|
|
7
20
|
/**
|
|
8
21
|
* Spawn a Node.js service and prefix every log line with a fixed-width label.
|
|
@@ -65,29 +78,52 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
|
|
|
65
78
|
const collectorDir = join(packageRoot, "collector");
|
|
66
79
|
|
|
67
80
|
// Initialize session log file - clear on each startup
|
|
68
|
-
|
|
81
|
+
// Logs go into the user's storage directory (~/totem-llm/logs) not the npm package
|
|
82
|
+
const logsDir = join(getStorageDir(), "logs");
|
|
69
83
|
mkdirSync(logsDir, { recursive: true });
|
|
70
84
|
const sessionLogFile = join(logsDir, "totem-session.log");
|
|
71
|
-
writeFileSync(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
writeFileSync(
|
|
86
|
+
sessionLogFile,
|
|
87
|
+
`${"=".repeat(80)}\nSession started: ${new Date().toISOString()}\n${"=".repeat(80)}\n`
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// Display startup banner with professional formatting
|
|
91
|
+
process.stdout.write("\n");
|
|
92
|
+
process.stdout.write(startupBanner(appVersion, "production"));
|
|
93
|
+
|
|
94
|
+
// Display service configuration
|
|
95
|
+
process.stdout.write(
|
|
96
|
+
section("Services", [
|
|
97
|
+
`${info("Server")} running on port ${urlStyle(serverPort)}`,
|
|
98
|
+
collectorPort ? `${info("Collector")} running on port ${urlStyle(collectorPort)}` : warning("Collector disabled"),
|
|
99
|
+
])
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Display UI access information
|
|
103
|
+
process.stdout.write(
|
|
104
|
+
highlightBox(
|
|
105
|
+
`Open UI in browser:\n${urlStyle(`http://localhost:${serverPort}/`)}`,
|
|
106
|
+
"brightGreen"
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// Display logs information
|
|
111
|
+
process.stdout.write(
|
|
112
|
+
section("Configuration", [
|
|
113
|
+
`Logs: ${urlStyle(sessionLogFile)}`,
|
|
114
|
+
`Storage: ${urlStyle(getStorageDir())}`,
|
|
115
|
+
])
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// Display help information
|
|
119
|
+
process.stdout.write(
|
|
120
|
+
section("Keyboard Shortcuts", [
|
|
121
|
+
`${info("Ctrl+C")} Stop all services`,
|
|
122
|
+
`${info("Check logs")} for errors and service status`,
|
|
123
|
+
])
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
process.stdout.write(divider());
|
|
91
127
|
|
|
92
128
|
const serverProc = spawnService(nodeExe, serverDir, env, "[server]", sessionLogFile);
|
|
93
129
|
|
|
@@ -103,9 +139,9 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
|
|
|
103
139
|
if (shuttingDown) return;
|
|
104
140
|
shuttingDown = true;
|
|
105
141
|
|
|
106
|
-
const shutdownMsg = `\nShutting down (${signal})
|
|
142
|
+
const shutdownMsg = warning(`\nShutting down (${signal})…`);
|
|
107
143
|
process.stdout.write(`${shutdownMsg}\n`);
|
|
108
|
-
appendFileSync(sessionLogFile,
|
|
144
|
+
appendFileSync(sessionLogFile, `Shutting down (${signal})…\n`);
|
|
109
145
|
|
|
110
146
|
serverProc.kill("SIGTERM");
|
|
111
147
|
if (collectorProc) collectorProc.kill("SIGTERM");
|
|
@@ -126,9 +162,9 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
|
|
|
126
162
|
// Exit this process when the server exits unexpectedly
|
|
127
163
|
serverProc.on("close", (code) => {
|
|
128
164
|
if (!shuttingDown && code !== null && code !== 0) {
|
|
129
|
-
const errMsg = `
|
|
165
|
+
const errMsg = error(`Server exited unexpectedly with code ${code}`);
|
|
130
166
|
process.stderr.write(`${errMsg}\n`);
|
|
131
|
-
appendFileSync(sessionLogFile,
|
|
167
|
+
appendFileSync(sessionLogFile, `Server exited unexpectedly with code ${code}\n`);
|
|
132
168
|
shutdown("server-exit");
|
|
133
169
|
setTimeout(() => process.exit(1), 500);
|
|
134
170
|
}
|
|
@@ -137,9 +173,9 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
|
|
|
137
173
|
if (collectorProc) {
|
|
138
174
|
collectorProc.on("close", (code) => {
|
|
139
175
|
if (!shuttingDown && code !== null && code !== 0) {
|
|
140
|
-
const errMsg = `
|
|
176
|
+
const errMsg = warning(`Collector exited with code ${code} — document ingestion unavailable`);
|
|
141
177
|
process.stderr.write(`${errMsg}\n`);
|
|
142
|
-
appendFileSync(sessionLogFile,
|
|
178
|
+
appendFileSync(sessionLogFile, `Collector exited with code ${code} — document ingestion unavailable\n`);
|
|
143
179
|
}
|
|
144
180
|
});
|
|
145
181
|
}
|
package/lib/setup.js
CHANGED
|
@@ -139,7 +139,7 @@ export async function setup({ packageRoot, force = false }) {
|
|
|
139
139
|
// 3. Feature flags config (copy default if not already present in storage dir)
|
|
140
140
|
const __filename = fileURLToPath(import.meta.url);
|
|
141
141
|
const __dirname = dirname(__filename);
|
|
142
|
-
const featuresConfigDest = join(storageDir, 'totem.features.json');
|
|
142
|
+
const featuresConfigDest = join(storageDir, '.totem.features.json');
|
|
143
143
|
const featuresConfigSrc = join(__dirname, '..', 'config', 'totem.features.json');
|
|
144
144
|
if (!existsSync(featuresConfigDest) && existsSync(featuresConfigSrc)) {
|
|
145
145
|
copyFileSync(featuresConfigSrc, featuresConfigDest);
|
package/package.json
CHANGED
|
@@ -5,24 +5,24 @@
|
|
|
5
5
|
<meta charset="UTF-8" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
|
-
<title>Totem LLM | Your
|
|
8
|
+
<title>Totem LLM | Your Private AI</title>
|
|
9
9
|
|
|
10
|
-
<meta name="title" content="Totem LLM | Your
|
|
11
|
-
<meta name="description" content="Totem LLM | Your
|
|
10
|
+
<meta name="title" content="Totem LLM | Your Private AI">
|
|
11
|
+
<meta name="description" content="Totem LLM | Your Private AI">
|
|
12
12
|
|
|
13
13
|
<!-- Facebook -->
|
|
14
14
|
<meta property="og:type" content="website">
|
|
15
15
|
<meta property="og:url" content="https://github.com/fred-terzi/totem-llm">
|
|
16
|
-
<meta property="og:title" content="Totem LLM | Your
|
|
17
|
-
<meta property="og:description" content="Totem LLM | Your
|
|
16
|
+
<meta property="og:title" content="Totem LLM | Your Private AI">
|
|
17
|
+
<meta property="og:description" content="Totem LLM | Your Private AI">
|
|
18
18
|
<meta property="og:image"
|
|
19
19
|
content="https://raw.githubusercontent.com/fred-terzi/totem-llm/main/images/totem_logo.png">
|
|
20
20
|
|
|
21
21
|
<!-- Twitter -->
|
|
22
22
|
<meta property="twitter:card" content="summary_large_image">
|
|
23
23
|
<meta property="twitter:url" content="https://github.com/fred-terzi/totem-llm">
|
|
24
|
-
<meta property="twitter:title" content="Totem LLM | Your
|
|
25
|
-
<meta property="twitter:description" content="Totem LLM | Your
|
|
24
|
+
<meta property="twitter:title" content="Totem LLM | Your Private AI">
|
|
25
|
+
<meta property="twitter:description" content="Totem LLM | Your Private AI">
|
|
26
26
|
<meta property="twitter:image"
|
|
27
27
|
content="https://raw.githubusercontent.com/fred-terzi/totem-llm/main/images/totem_logo.png">
|
|
28
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,K as t,X as s,
|
|
1
|
+
import{j as e,K as t,X as s,a4 as a}from"../index.js";function l(){return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-screen bg-theme-bg-primary text-theme-text-primary gap-4 p-4 md:p-8 w-full",children:[e.jsx(t,{className:"w-16 h-16 text-theme-text-secondary"}),e.jsx("h1",{className:"text-xl md:text-2xl font-bold text-center",children:"404 - Page Not Found"}),e.jsx("p",{className:"text-theme-text-secondary text-center px-4",children:"The page you're looking for doesn't exist or has been moved."}),e.jsx("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 mt-4 w-full md:w-auto",children:e.jsxs(s,{to:"/",className:"flex items-center justify-center gap-2 px-4 py-2 bg-theme-bg-secondary text-theme-text-primary rounded-lg hover:bg-theme-sidebar-item-hover transition-all duration-300 w-full md:w-auto",children:[e.jsx(a,{className:"w-4 h-4"}),"Go Home"]})})]})}export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as t,ab as G,aE as $,aM as K,V as C,u as y,aK as I,s as X,a5 as q,a4 as U,bK as V,b$ as B,c as j,l as W,b as Y,p as T,a1 as Z,i as Q,aZ as ee,bG as te,at as D}from"../index.js";import{I as se}from"./Brain-24e386d5.js";import{w as le}from"./ChatText-35275002.js";import{I as ne}from"./File-b92df2f3.js";import{R as ae}from"./Stop-4b47ae05.js";import{S as f,u as re}from"./usePolling-417bb099.js";import{c as ie,S as oe,T as J,a as de,b as ce,r as _}from"./files-676613ed.js";import{C as ue}from"./Copy-d323e545.js";import{H as xe,D as S}from"./purify-eb750cf4.js";import{t as E}from"./truncate-06273256.js";import{h as L}from"./moment-75486807.js";/* empty css */function w({title:e,icon:s,children:l,defaultOpen:n=!1,copyableContent:a=null}){const[i,r]=o.useState(n);return t.jsxs("div",{className:"border border-zinc-700 light:border-slate-400 rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("button",{type:"button",onClick:()=>r(!i),className:"border-none flex-1 h-12 flex items-center gap-2 px-[18px] hover:bg-white/5 light:hover:bg-slate-100 transition-colors text-left",children:[i?t.jsx(G,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}):t.jsx($,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}),t.jsx(s,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}),t.jsx("span",{className:"text-sm font-medium text-zinc-50 light:text-slate-950",children:e})]}),a&&t.jsx(he,{content:a})]}),i&&t.jsx("div",{className:"px-[18px] py-3 border-t border-zinc-700 light:border-slate-400",children:l})]})}function he({content:e}){const[s,l]=o.useState(!1),n=async()=>{await ie(e),l(!0),setTimeout(()=>l(!1),2e3)};return t.jsx("button",{type:"button",onClick:n,disabled:s,className:"h-12 px-4 flex items-center hover:bg-white/5 light:hover:bg-slate-100 transition-colors",children:s?t.jsx(K,{size:20,className:"text-green-500"}):t.jsx(ue,{size:20,className:"text-zinc-50 light:text-slate-950"})})}const F=5e3;function H(e){return e?"github":"github-dark"}function O(e){const s=typeof e=="string"?X(e,e):e;if(typeof s!="object"||s===null)return null;const l=JSON.stringify(s,null,2),n=E(l,F),a=xe.highlight(n,{language:"json"}).value;return{__html:S.sanitize(a)}}function me({toolCall:e}){const[s,l]=o.useState(!1);return t.jsxs("div",{className:"border border-white/5 rounded-lg p-3 bg-theme-bg-primary/30",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(C,{className:"h-3.5 w-3.5 text-blue-400"}),t.jsx("span",{className:"text-sm font-medium text-theme-text-primary",children:e.toolName})]}),t.jsx(ge,{toolCall:e})]}),t.jsx(pe,{toolCall:e}),t.jsx(be,{toolCall:e,showResult:s,setShowResult:l})]})}function ge({toolCall:e}){return e.timestamp?t.jsx("span",{className:"text-xs text-theme-text-secondary",children:L(e.timestamp).format("LTS")}):null}function pe({toolCall:e}){const{t:s}=y(),{isLight:l}=I();if(!e.arguments)return null;const n=O(e.arguments);return t.jsxs("div",{className:"mb-2",children:[t.jsx("span",{className:"text-xs text-theme-text-secondary",children:s("scheduledJobs.toolCall.arguments")}),n?t.jsx("pre",{className:`text-xs rounded-lg p-2 mt-1 overflow-x-auto white-scrollbar tool-call-scrollbar hljs ${H(l)}`,dangerouslySetInnerHTML:n}):t.jsx("pre",{className:"text-xs text-theme-text-primary bg-theme-bg-primary/50 rounded p-2 mt-1 overflow-x-auto white-scrollbar tool-call-scrollbar",children:typeof e.arguments=="string"?e.arguments:JSON.stringify(e.arguments,null,2)})]})}function be({toolCall:e,showResult:s,setShowResult:l}){const{t:n}=y(),{isLight:a}=I();if(!e.result)return null;const i=typeof e.result=="string"?e.result:JSON.stringify(e.result,null,2),r=E(i,F),d=O(i);return i?t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>l(!s),className:"border-none text-xs text-blue-400 hover:text-blue-300 transition-colors",children:n(s?"scheduledJobs.toolCall.hideResult":"scheduledJobs.toolCall.showResult")}),s&&(d?t.jsx("pre",{className:`text-xs rounded-lg p-2 mt-1 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap white-scrollbar tool-call-scrollbar hljs ${H(a)}`,dangerouslySetInnerHTML:d}):t.jsx("pre",{className:"text-xs text-theme-text-primary bg-theme-bg-primary/50 rounded p-2 mt-1 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap white-scrollbar tool-call-scrollbar",children:r}))]}):null}const R={pptx:{badge:"PPT",bg:"bg-orange-100",text:"text-orange-800",label:e=>e("scheduledJobs.file.types.powerpoint")},ppt:{badge:"PPT",bg:"bg-orange-100",text:"text-orange-800",label:e=>e("scheduledJobs.file.types.powerpoint")},pdf:{badge:"PDF",bg:"bg-red-100",text:"text-red-800",label:e=>e("scheduledJobs.file.types.pdf")},doc:{badge:"DOC",bg:"bg-blue-100",text:"text-blue-800",label:e=>e("scheduledJobs.file.types.word")},docx:{badge:"DOC",bg:"bg-blue-100",text:"text-blue-800",label:e=>e("scheduledJobs.file.types.word")},xls:{badge:"XLS",bg:"bg-green-100",text:"text-green-800",label:e=>e("scheduledJobs.file.types.spreadsheet")},xlsx:{badge:"XLS",bg:"bg-green-100",text:"text-green-800",label:e=>e("scheduledJobs.file.types.spreadsheet")},csv:{badge:"CSV",bg:"bg-green-100",text:"text-green-800",label:e=>e("scheduledJobs.file.types.spreadsheet")},default:{badge:"FILE",bg:"bg-zinc-200",text:"text-zinc-800",label:e=>e("scheduledJobs.file.types.generic")}};function fe(e,s){var a,i;const l=((i=(a=e==null?void 0:e.split("."))==null?void 0:a.pop())==null?void 0:i.toLowerCase())??"txt",n=R[l]||R.default;return{...n,type:n.label(s)}}function je({file:e}){const{t:s}=y(),[l,n]=o.useState(!1),{badge:a,bg:i,text:r,type:d}=fe(e.filename,s),u=async()=>{if(!(l||!e.storageFilename)){n(!0);try{const h=await oe.download(e.storageFilename);if(!h)throw new Error("Failed to download file");const{saveAs:m}=await B(()=>import("../index.js").then(g=>g.F),["index.js","index.css"]);m(h,e.filename||e.storageFilename)}catch{j(s("scheduledJobs.file.downloadFailed"),"error")}finally{n(!1)}}};return t.jsxs("div",{className:"flex items-center justify-between bg-zinc-800 light:bg-slate-100 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("div",{className:`${i} ${r} rounded-lg flex items-center justify-center shrink-0 h-10 w-10 text-xs font-semibold`,children:a}),t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsx("p",{className:"text-sm text-white light:text-slate-950 truncate",children:e.filename||s("scheduledJobs.file.unknown")}),t.jsxs("p",{className:"text-sm text-zinc-400 light:text-slate-600",children:[q(e.fileSize,!0,1),e.fileSize&&d?" · ":"",d]})]})]}),t.jsx("button",{type:"button",onClick:u,disabled:l,title:s("scheduledJobs.file.download"),"aria-label":s("scheduledJobs.file.download"),className:"border-none text-zinc-400 light:text-slate-600 hover:text-zinc-50 light:hover:text-slate-950 transition-colors shrink-0 ml-4 disabled:opacity-50",children:l?t.jsx(U,{size:16,weight:"bold",className:"animate-spin"}):t.jsx(V,{size:16,weight:"bold"})})]})}function Me(){const{t:e}=y(),{id:s,runId:l}=W(),n=Y(),[a,i]=o.useState(!0),[r,d]=o.useState(null),[u,h]=o.useState(null),[m,g]=o.useState(!1),[N,p]=o.useState(!1);o.useEffect(()=>{v()},[l]);const v=async()=>{const c=await f.getRun(l);d(c.run),h(c.job),i(!1),c.run&&!c.run.readAt&&f.markRunRead(l)},P=(r==null?void 0:r.status)==="running"||(r==null?void 0:r.status)==="queued";re(v,3e3,P);const M=async()=>{g(!0);const{workspaceSlug:c,threadSlug:b,error:k}=await f.continueInThread(l);if(k||!c||!b){j(k||e("scheduledJobs.runDetail.threadFailed"),"error"),g(!1);return}n(T.workspace.thread(c,b))},A=async()=>{p(!0);const{success:c,error:b}=await f.killRun(l);if(p(!1),!c){j(b||e("scheduledJobs.toast.killFailed"),"error");return}j(e("scheduledJobs.toast.killed"),"success"),v()};if(a)return t.jsx(z,{children:t.jsx("p",{className:"text-zinc-400 light:text-slate-600 text-sm",children:e("scheduledJobs.runDetail.loading")})});if(!r)return t.jsx(z,{children:t.jsx("p",{className:"text-zinc-400 light:text-slate-600 text-sm",children:e("scheduledJobs.runDetail.notFound")})});const x=r.result||{};return t.jsxs(z,{children:[t.jsx(ye,{t:e,job:u,run:r,result:x,continuing:m,killing:N,onBack:()=>n(T.settings.scheduledJobRuns(s)),onContinueInThread:M,onKillRun:A}),t.jsxs("div",{className:"mt-6 space-y-4",children:[t.jsx(we,{t:e,prompt:u==null?void 0:u.prompt}),t.jsx(Ne,{t:e,error:r==null?void 0:r.error}),t.jsx(ve,{t:e,result:x}),t.jsx(Je,{t:e,result:x}),t.jsx(ze,{t:e,result:x}),t.jsx(Se,{t:e,result:x}),t.jsx(ke,{t:e,metrics:x==null?void 0:x.metrics})]})]})}function z({children:e}){return t.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[t.jsx(Z,{}),t.jsx("div",{style:{height:Q?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:t.jsx("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:e})})]})}function ye({t:e,job:s,run:l,result:n,continuing:a,killing:i,onBack:r,onContinueInThread:d,onKillRun:u}){function h(){return{completed:{text:e("scheduledJobs.status.completed"),style:"text-green-400 light:text-green-600"},failed:{text:e("scheduledJobs.status.failed"),style:"text-red-400 light:text-red-600"},timed_out:{text:e("scheduledJobs.status.timed_out"),style:"text-orange-400 light:text-orange-600"},running:{text:e("scheduledJobs.status.running"),style:"text-yellow-400 light:text-yellow-600"},queued:{text:e("scheduledJobs.status.queued"),style:"text-blue-400 light:text-blue-600"},default:{text:"—",style:"text-zinc-400 light:text-slate-600"}}}const m=h(),{text:g,style:N}=m[l.status]||m.default,p=["running","queued"].includes(l.status);return t.jsxs("div",{className:"w-full flex items-end justify-between gap-x-4 pb-6 border-white/10 light:border-zinc-300 border-b-2",children:[t.jsxs("div",{className:"flex flex-col gap-y-2",children:[t.jsxs("button",{type:"button",onClick:r,className:"border-none flex items-center gap-2 text-zinc-400 light:text-slate-600 hover:text-zinc-50 light:hover:text-slate-950 text-sm transition-colors w-fit",children:[t.jsx(ee,{className:"h-4 w-4"}),e("scheduledJobs.runDetail.back")]}),t.jsx("p",{className:"text-lg leading-7 font-semibold text-zinc-50 light:text-slate-950",children:e("scheduledJobs.runDetail.runHeading",{name:(s==null?void 0:s.name)||e("scheduledJobs.runDetail.unknownJob"),id:l.id})}),t.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:N,children:g}),t.jsx("span",{className:"text-zinc-400 light:text-slate-600",children:L(l.startedAt).format("LTS")}),n.duration&&t.jsx("span",{className:"text-zinc-400 light:text-slate-600",children:e("scheduledJobs.runDetail.duration",{value:te(n.duration/1e3)})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[p&&t.jsxs("button",{type:"button",onClick:u,disabled:i,title:e("scheduledJobs.runDetail.stopJob"),className:"border-none h-9 px-5 rounded-lg bg-red-500/20 text-red-400 light:bg-red-100 light:text-red-600 text-sm font-medium hover:bg-red-500/30 light:hover:bg-red-200 transition-colors disabled:opacity-50 shrink-0 flex items-center gap-2",children:[t.jsx(ae,{className:"h-4 w-4",weight:"bold"}),e(i?"scheduledJobs.runDetail.killing":"scheduledJobs.runDetail.stopJob")]}),l.status==="completed"&&t.jsx("button",{type:"button",onClick:d,disabled:a,className:"border-none h-9 px-5 rounded-lg bg-zinc-50 text-zinc-950 light:bg-slate-900 light:text-white text-sm font-medium hover:bg-zinc-200 light:hover:bg-slate-800 transition-colors disabled:opacity-50 shrink-0",children:e(a?"scheduledJobs.runDetail.creating":"scheduledJobs.runDetail.continueInThread")})]})]})}function we({t:e,prompt:s}){return t.jsxs("div",{className:"border border-zinc-700 light:border-slate-400 rounded-lg p-[18px]",children:[t.jsx("p",{className:"text-sm font-medium text-white light:text-slate-950 uppercase tracking-[1.4px] mb-1",children:e("scheduledJobs.runDetail.sections.prompt")}),t.jsx("p",{className:"text-sm text-zinc-400 light:text-slate-600 whitespace-pre-wrap",children:s||"—"})]})}function Ne({t:e,error:s}){return s?t.jsxs("div",{className:"border border-red-500/20 light:border-red-300 rounded-lg p-[18px] bg-red-500/5 light:bg-red-50",children:[t.jsx("p",{className:"text-sm font-medium text-red-400 light:text-red-600 uppercase tracking-[1.4px] mb-1",children:e("scheduledJobs.runDetail.sections.error")}),t.jsx("p",{className:"text-sm text-red-300 light:text-red-700",children:s})]}):null}function ve({t:e,result:s}){return!s.thoughts||s.thoughts.length===0?null:t.jsx(w,{title:e("scheduledJobs.runDetail.sections.thinking",{count:s.thoughts.length}),icon:se,children:t.jsx("div",{className:"space-y-2",children:s.thoughts.map((l,n)=>t.jsxs("div",{className:"flex items-start gap-2 text-sm text-theme-text-secondary",children:[t.jsxs("span",{className:"text-xs text-theme-text-secondary/50 mt-0.5 min-w-[20px]",children:[n+1,"."]}),t.jsx("span",{children:l})]},n))})})}function Je({t:e,result:s}){return!s.toolCalls||s.toolCalls.length===0?null:t.jsx(w,{title:e("scheduledJobs.runDetail.sections.toolCalls",{count:s.toolCalls.length}),icon:C,children:t.jsx("div",{className:"space-y-3",children:s.toolCalls.map((l,n)=>t.jsx(me,{toolCall:l},n))})})}function ze({t:e,result:s}){const l=s.outputs||[];return l.length===0?null:t.jsx(w,{title:e("scheduledJobs.runDetail.sections.files",{count:l.length}),icon:ne,defaultOpen:!0,children:t.jsx("div",{className:"space-y-2",children:l.map((n,a)=>t.jsx(je,{file:n.payload,type:n.type},a))})})}function Se({t:e,result:s}){var a;if(!s.text)return null;let l=null,n=s.text;return s.text.match(J)&&(l=(a=s.text.match(J))==null?void 0:a[0],l&&(l=l.replace(de,"").replace(ce,"").trim()),n=s.text.replace(J,"")),t.jsxs(w,{title:e("scheduledJobs.runDetail.sections.response"),icon:le,defaultOpen:!0,copyableContent:n,children:[l&&t.jsx("div",{className:"text-sm text-zinc-50/50 light:text-slate-950/50 markdown border-l-2 border-zinc-700 light:border-slate-400 pl-2 mb-4",children:t.jsx("span",{dangerouslySetInnerHTML:{__html:S.sanitize(_(l))}})}),t.jsx("div",{className:"text-sm text-zinc-50 light:text-slate-950 markdown",dangerouslySetInnerHTML:{__html:S.sanitize(_(n))}})]})}function ke({t:e,metrics:s}){if(!s||Object.keys(s).length===0||!s.prompt_tokens||!s.completion_tokens)return null;function l(n){return n.model?t.jsxs("span",{className:"font-mono text-xs font-normal text-zinc-50/50 light:text-slate-950/50",children:["(",n.model,")"]}):null}return t.jsxs("div",{className:"border border-zinc-700 light:border-slate-400 rounded-lg p-[18px]",children:[t.jsxs("p",{className:"text-sm font-semibold text-zinc-400 light:text-slate-600 uppercase tracking-[1.4px] mb-1",children:[e("scheduledJobs.runDetail.sections.metrics")," ",l(s)]}),t.jsxs("div",{className:"flex gap-6 text-sm text-zinc-400 light:text-slate-600",children:[s.prompt_tokens!=null&&t.jsxs("span",{children:[e("scheduledJobs.runDetail.metrics.promptTokens")," ",t.jsx("span",{className:"text-zinc-50 light:text-slate-950",children:D(s.prompt_tokens)})]}),s.completion_tokens!=null&&t.jsxs("span",{children:[e("scheduledJobs.runDetail.metrics.completionTokens")," ",t.jsx("span",{className:"text-zinc-50 light:text-slate-950",children:D(s.completion_tokens)})]})]})]})}export{Me as default};
|
|
1
|
+
import{r as o,j as t,ac as G,aF as $,aN as X,V as C,u as y,aL as I,s as q,a6 as K,a5 as U,bL as V,c0 as B,c as j,l as W,b as Y,p as T,a1 as Q,i as Z,a_ as ee,bH as te,au as D}from"../index.js";import{I as se}from"./Brain-24e386d5.js";import{w as le}from"./ChatText-35275002.js";import{I as ne}from"./File-b92df2f3.js";import{R as ae}from"./Stop-4b47ae05.js";import{S as f,u as re}from"./usePolling-417bb099.js";import{c as ie,S as oe,T as J,a as ce,b as de,r as _}from"./files-40998f84.js";import{C as ue}from"./Copy-d323e545.js";import{H as xe,D as S}from"./purify-17c89583.js";import{t as L}from"./truncate-dd7b0c29.js";import{h as E}from"./moment-49fc1b76.js";/* empty css */function w({title:e,icon:s,children:l,defaultOpen:n=!1,copyableContent:a=null}){const[i,r]=o.useState(n);return t.jsxs("div",{className:"border border-zinc-700 light:border-slate-400 rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("button",{type:"button",onClick:()=>r(!i),className:"border-none flex-1 h-12 flex items-center gap-2 px-[18px] hover:bg-white/5 light:hover:bg-slate-100 transition-colors text-left",children:[i?t.jsx(G,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}):t.jsx($,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}),t.jsx(s,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}),t.jsx("span",{className:"text-sm font-medium text-zinc-50 light:text-slate-950",children:e})]}),a&&t.jsx(he,{content:a})]}),i&&t.jsx("div",{className:"px-[18px] py-3 border-t border-zinc-700 light:border-slate-400",children:l})]})}function he({content:e}){const[s,l]=o.useState(!1),n=async()=>{await ie(e),l(!0),setTimeout(()=>l(!1),2e3)};return t.jsx("button",{type:"button",onClick:n,disabled:s,className:"h-12 px-4 flex items-center hover:bg-white/5 light:hover:bg-slate-100 transition-colors",children:s?t.jsx(X,{size:20,className:"text-green-500"}):t.jsx(ue,{size:20,className:"text-zinc-50 light:text-slate-950"})})}const F=5e3;function H(e){return e?"github":"github-dark"}function O(e){const s=typeof e=="string"?q(e,e):e;if(typeof s!="object"||s===null)return null;const l=JSON.stringify(s,null,2),n=L(l,F),a=xe.highlight(n,{language:"json"}).value;return{__html:S.sanitize(a)}}function me({toolCall:e}){const[s,l]=o.useState(!1);return t.jsxs("div",{className:"border border-white/5 rounded-lg p-3 bg-theme-bg-primary/30",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(C,{className:"h-3.5 w-3.5 text-blue-400"}),t.jsx("span",{className:"text-sm font-medium text-theme-text-primary",children:e.toolName})]}),t.jsx(ge,{toolCall:e})]}),t.jsx(pe,{toolCall:e}),t.jsx(be,{toolCall:e,showResult:s,setShowResult:l})]})}function ge({toolCall:e}){return e.timestamp?t.jsx("span",{className:"text-xs text-theme-text-secondary",children:E(e.timestamp).format("LTS")}):null}function pe({toolCall:e}){const{t:s}=y(),{isLight:l}=I();if(!e.arguments)return null;const n=O(e.arguments);return t.jsxs("div",{className:"mb-2",children:[t.jsx("span",{className:"text-xs text-theme-text-secondary",children:s("scheduledJobs.toolCall.arguments")}),n?t.jsx("pre",{className:`text-xs rounded-lg p-2 mt-1 overflow-x-auto white-scrollbar tool-call-scrollbar hljs ${H(l)}`,dangerouslySetInnerHTML:n}):t.jsx("pre",{className:"text-xs text-theme-text-primary bg-theme-bg-primary/50 rounded p-2 mt-1 overflow-x-auto white-scrollbar tool-call-scrollbar",children:typeof e.arguments=="string"?e.arguments:JSON.stringify(e.arguments,null,2)})]})}function be({toolCall:e,showResult:s,setShowResult:l}){const{t:n}=y(),{isLight:a}=I();if(!e.result)return null;const i=typeof e.result=="string"?e.result:JSON.stringify(e.result,null,2),r=L(i,F),c=O(i);return i?t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>l(!s),className:"border-none text-xs text-blue-400 hover:text-blue-300 transition-colors",children:n(s?"scheduledJobs.toolCall.hideResult":"scheduledJobs.toolCall.showResult")}),s&&(c?t.jsx("pre",{className:`text-xs rounded-lg p-2 mt-1 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap white-scrollbar tool-call-scrollbar hljs ${H(a)}`,dangerouslySetInnerHTML:c}):t.jsx("pre",{className:"text-xs text-theme-text-primary bg-theme-bg-primary/50 rounded p-2 mt-1 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap white-scrollbar tool-call-scrollbar",children:r}))]}):null}const R={pptx:{badge:"PPT",bg:"bg-orange-100",text:"text-orange-800",label:e=>e("scheduledJobs.file.types.powerpoint")},ppt:{badge:"PPT",bg:"bg-orange-100",text:"text-orange-800",label:e=>e("scheduledJobs.file.types.powerpoint")},pdf:{badge:"PDF",bg:"bg-red-100",text:"text-red-800",label:e=>e("scheduledJobs.file.types.pdf")},doc:{badge:"DOC",bg:"bg-blue-100",text:"text-blue-800",label:e=>e("scheduledJobs.file.types.word")},docx:{badge:"DOC",bg:"bg-blue-100",text:"text-blue-800",label:e=>e("scheduledJobs.file.types.word")},xls:{badge:"XLS",bg:"bg-green-100",text:"text-green-800",label:e=>e("scheduledJobs.file.types.spreadsheet")},xlsx:{badge:"XLS",bg:"bg-green-100",text:"text-green-800",label:e=>e("scheduledJobs.file.types.spreadsheet")},csv:{badge:"CSV",bg:"bg-green-100",text:"text-green-800",label:e=>e("scheduledJobs.file.types.spreadsheet")},default:{badge:"FILE",bg:"bg-zinc-200",text:"text-zinc-800",label:e=>e("scheduledJobs.file.types.generic")}};function fe(e,s){var a,i;const l=((i=(a=e==null?void 0:e.split("."))==null?void 0:a.pop())==null?void 0:i.toLowerCase())??"txt",n=R[l]||R.default;return{...n,type:n.label(s)}}function je({file:e}){const{t:s}=y(),[l,n]=o.useState(!1),{badge:a,bg:i,text:r,type:c}=fe(e.filename,s),u=async()=>{if(!(l||!e.storageFilename)){n(!0);try{const h=await oe.download(e.storageFilename);if(!h)throw new Error("Failed to download file");const{saveAs:m}=await B(()=>import("../index.js").then(g=>g.F),["index.js","index.css"]);m(h,e.filename||e.storageFilename)}catch{j(s("scheduledJobs.file.downloadFailed"),"error")}finally{n(!1)}}};return t.jsxs("div",{className:"flex items-center justify-between bg-zinc-800 light:bg-slate-100 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("div",{className:`${i} ${r} rounded-lg flex items-center justify-center shrink-0 h-10 w-10 text-xs font-semibold`,children:a}),t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsx("p",{className:"text-sm text-white light:text-slate-950 truncate",children:e.filename||s("scheduledJobs.file.unknown")}),t.jsxs("p",{className:"text-sm text-zinc-400 light:text-slate-600",children:[K(e.fileSize,!0,1),e.fileSize&&c?" · ":"",c]})]})]}),t.jsx("button",{type:"button",onClick:u,disabled:l,title:s("scheduledJobs.file.download"),"aria-label":s("scheduledJobs.file.download"),className:"border-none text-zinc-400 light:text-slate-600 hover:text-zinc-50 light:hover:text-slate-950 transition-colors shrink-0 ml-4 disabled:opacity-50",children:l?t.jsx(U,{size:16,weight:"bold",className:"animate-spin"}):t.jsx(V,{size:16,weight:"bold"})})]})}function Me(){const{t:e}=y(),{id:s,runId:l}=W(),n=Y(),[a,i]=o.useState(!0),[r,c]=o.useState(null),[u,h]=o.useState(null),[m,g]=o.useState(!1),[N,p]=o.useState(!1);o.useEffect(()=>{v()},[l]);const v=async()=>{const d=await f.getRun(l);c(d.run),h(d.job),i(!1),d.run&&!d.run.readAt&&f.markRunRead(l)},P=(r==null?void 0:r.status)==="running"||(r==null?void 0:r.status)==="queued";re(v,3e3,P);const M=async()=>{g(!0);const{workspaceSlug:d,threadSlug:b,error:k}=await f.continueInThread(l);if(k||!d||!b){j(k||e("scheduledJobs.runDetail.threadFailed"),"error"),g(!1);return}n(T.workspace.thread(d,b))},A=async()=>{p(!0);const{success:d,error:b}=await f.killRun(l);if(p(!1),!d){j(b||e("scheduledJobs.toast.killFailed"),"error");return}j(e("scheduledJobs.toast.killed"),"success"),v()};if(a)return t.jsx(z,{children:t.jsx("p",{className:"text-zinc-400 light:text-slate-600 text-sm",children:e("scheduledJobs.runDetail.loading")})});if(!r)return t.jsx(z,{children:t.jsx("p",{className:"text-zinc-400 light:text-slate-600 text-sm",children:e("scheduledJobs.runDetail.notFound")})});const x=r.result||{};return t.jsxs(z,{children:[t.jsx(ye,{t:e,job:u,run:r,result:x,continuing:m,killing:N,onBack:()=>n(T.settings.scheduledJobRuns(s)),onContinueInThread:M,onKillRun:A}),t.jsxs("div",{className:"mt-6 space-y-4",children:[t.jsx(we,{t:e,prompt:u==null?void 0:u.prompt}),t.jsx(Ne,{t:e,error:r==null?void 0:r.error}),t.jsx(ve,{t:e,result:x}),t.jsx(Je,{t:e,result:x}),t.jsx(ze,{t:e,result:x}),t.jsx(Se,{t:e,result:x}),t.jsx(ke,{t:e,metrics:x==null?void 0:x.metrics})]})]})}function z({children:e}){return t.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[t.jsx(Q,{}),t.jsx("div",{style:{height:Z?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:t.jsx("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:e})})]})}function ye({t:e,job:s,run:l,result:n,continuing:a,killing:i,onBack:r,onContinueInThread:c,onKillRun:u}){function h(){return{completed:{text:e("scheduledJobs.status.completed"),style:"text-green-400 light:text-green-600"},failed:{text:e("scheduledJobs.status.failed"),style:"text-red-400 light:text-red-600"},timed_out:{text:e("scheduledJobs.status.timed_out"),style:"text-orange-400 light:text-orange-600"},running:{text:e("scheduledJobs.status.running"),style:"text-yellow-400 light:text-yellow-600"},queued:{text:e("scheduledJobs.status.queued"),style:"text-blue-400 light:text-blue-600"},default:{text:"—",style:"text-zinc-400 light:text-slate-600"}}}const m=h(),{text:g,style:N}=m[l.status]||m.default,p=["running","queued"].includes(l.status);return t.jsxs("div",{className:"w-full flex items-end justify-between gap-x-4 pb-6 border-white/10 light:border-zinc-300 border-b-2",children:[t.jsxs("div",{className:"flex flex-col gap-y-2",children:[t.jsxs("button",{type:"button",onClick:r,className:"border-none flex items-center gap-2 text-zinc-400 light:text-slate-600 hover:text-zinc-50 light:hover:text-slate-950 text-sm transition-colors w-fit",children:[t.jsx(ee,{className:"h-4 w-4"}),e("scheduledJobs.runDetail.back")]}),t.jsx("p",{className:"text-lg leading-7 font-semibold text-zinc-50 light:text-slate-950",children:e("scheduledJobs.runDetail.runHeading",{name:(s==null?void 0:s.name)||e("scheduledJobs.runDetail.unknownJob"),id:l.id})}),t.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:N,children:g}),t.jsx("span",{className:"text-zinc-400 light:text-slate-600",children:E(l.startedAt).format("LTS")}),n.duration&&t.jsx("span",{className:"text-zinc-400 light:text-slate-600",children:e("scheduledJobs.runDetail.duration",{value:te(n.duration/1e3)})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[p&&t.jsxs("button",{type:"button",onClick:u,disabled:i,title:e("scheduledJobs.runDetail.stopJob"),className:"border-none h-9 px-5 rounded-lg bg-red-500/20 text-red-400 light:bg-red-100 light:text-red-600 text-sm font-medium hover:bg-red-500/30 light:hover:bg-red-200 transition-colors disabled:opacity-50 shrink-0 flex items-center gap-2",children:[t.jsx(ae,{className:"h-4 w-4",weight:"bold"}),e(i?"scheduledJobs.runDetail.killing":"scheduledJobs.runDetail.stopJob")]}),l.status==="completed"&&t.jsx("button",{type:"button",onClick:c,disabled:a,className:"border-none h-9 px-5 rounded-lg bg-zinc-50 text-zinc-950 light:bg-slate-900 light:text-white text-sm font-medium hover:bg-zinc-200 light:hover:bg-slate-800 transition-colors disabled:opacity-50 shrink-0",children:e(a?"scheduledJobs.runDetail.creating":"scheduledJobs.runDetail.continueInThread")})]})]})}function we({t:e,prompt:s}){return t.jsxs("div",{className:"border border-zinc-700 light:border-slate-400 rounded-lg p-[18px]",children:[t.jsx("p",{className:"text-sm font-medium text-white light:text-slate-950 uppercase tracking-[1.4px] mb-1",children:e("scheduledJobs.runDetail.sections.prompt")}),t.jsx("p",{className:"text-sm text-zinc-400 light:text-slate-600 whitespace-pre-wrap",children:s||"—"})]})}function Ne({t:e,error:s}){return s?t.jsxs("div",{className:"border border-red-500/20 light:border-red-300 rounded-lg p-[18px] bg-red-500/5 light:bg-red-50",children:[t.jsx("p",{className:"text-sm font-medium text-red-400 light:text-red-600 uppercase tracking-[1.4px] mb-1",children:e("scheduledJobs.runDetail.sections.error")}),t.jsx("p",{className:"text-sm text-red-300 light:text-red-700",children:s})]}):null}function ve({t:e,result:s}){return!s.thoughts||s.thoughts.length===0?null:t.jsx(w,{title:e("scheduledJobs.runDetail.sections.thinking",{count:s.thoughts.length}),icon:se,children:t.jsx("div",{className:"space-y-2",children:s.thoughts.map((l,n)=>t.jsxs("div",{className:"flex items-start gap-2 text-sm text-theme-text-secondary",children:[t.jsxs("span",{className:"text-xs text-theme-text-secondary/50 mt-0.5 min-w-[20px]",children:[n+1,"."]}),t.jsx("span",{children:l})]},n))})})}function Je({t:e,result:s}){return!s.toolCalls||s.toolCalls.length===0?null:t.jsx(w,{title:e("scheduledJobs.runDetail.sections.toolCalls",{count:s.toolCalls.length}),icon:C,children:t.jsx("div",{className:"space-y-3",children:s.toolCalls.map((l,n)=>t.jsx(me,{toolCall:l},n))})})}function ze({t:e,result:s}){const l=s.outputs||[];return l.length===0?null:t.jsx(w,{title:e("scheduledJobs.runDetail.sections.files",{count:l.length}),icon:ne,defaultOpen:!0,children:t.jsx("div",{className:"space-y-2",children:l.map((n,a)=>t.jsx(je,{file:n.payload,type:n.type},a))})})}function Se({t:e,result:s}){var a;if(!s.text)return null;let l=null,n=s.text;return s.text.match(J)&&(l=(a=s.text.match(J))==null?void 0:a[0],l&&(l=l.replace(ce,"").replace(de,"").trim()),n=s.text.replace(J,"")),t.jsxs(w,{title:e("scheduledJobs.runDetail.sections.response"),icon:le,defaultOpen:!0,copyableContent:n,children:[l&&t.jsx("div",{className:"text-sm text-zinc-50/50 light:text-slate-950/50 markdown border-l-2 border-zinc-700 light:border-slate-400 pl-2 mb-4",children:t.jsx("span",{dangerouslySetInnerHTML:{__html:S.sanitize(_(l))}})}),t.jsx("div",{className:"text-sm text-zinc-50 light:text-slate-950 markdown",dangerouslySetInnerHTML:{__html:S.sanitize(_(n))}})]})}function ke({t:e,metrics:s}){if(!s||Object.keys(s).length===0||!s.prompt_tokens||!s.completion_tokens)return null;function l(n){return n.model?t.jsxs("span",{className:"font-mono text-xs font-normal text-zinc-50/50 light:text-slate-950/50",children:["(",n.model,")"]}):null}return t.jsxs("div",{className:"border border-zinc-700 light:border-slate-400 rounded-lg p-[18px]",children:[t.jsxs("p",{className:"text-sm font-semibold text-zinc-400 light:text-slate-600 uppercase tracking-[1.4px] mb-1",children:[e("scheduledJobs.runDetail.sections.metrics")," ",l(s)]}),t.jsxs("div",{className:"flex gap-6 text-sm text-zinc-400 light:text-slate-600",children:[s.prompt_tokens!=null&&t.jsxs("span",{children:[e("scheduledJobs.runDetail.metrics.promptTokens")," ",t.jsx("span",{className:"text-zinc-50 light:text-slate-950",children:D(s.prompt_tokens)})]}),s.completion_tokens!=null&&t.jsxs("span",{children:[e("scheduledJobs.runDetail.metrics.completionTokens")," ",t.jsx("span",{className:"text-zinc-50 light:text-slate-950",children:D(s.completion_tokens)})]})]})]})}export{Me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as h,j as t,b as j,r as d,p as N,
|
|
1
|
+
import{u as h,j as t,b as j,r as d,p as N,b$ as z,bH as S,c as o,l as H,a1 as R,i as k,a_ as A}from"../index.js";import{S as x,u as q}from"./usePolling-417bb099.js";import{R as C}from"./Stop-4b47ae05.js";import{h as y}from"./moment-49fc1b76.js";import{h as T}from"./cron-dfd47d9d.js";function D(e){return{completed:{text:e("scheduledJobs.status.completed"),style:"font-medium text-white light:text-slate-950"},failed:{text:e("scheduledJobs.status.failed"),style:"text-red-400 light:text-red-600"},timed_out:{text:e("scheduledJobs.status.timed_out"),style:"text-red-400 light:text-red-600"},running:{text:e("scheduledJobs.status.running"),style:"italic text-zinc-400 light:text-slate-600"},queued:{text:e("scheduledJobs.status.queued"),style:"italic text-zinc-400 light:text-slate-600"},default:{text:"—",style:"text-zinc-400 light:text-slate-600"}}}function I({status:e}){const{t:l}=h(),s=D(l),{text:a,style:n}=s[e]||s.default;return t.jsx("span",{className:`text-sm ${n}`,children:a})}function P(e){if(!e.completedAt||!e.startedAt)return"—";const l=y.duration(y(e.completedAt).diff(y(e.startedAt)));return S(l.asSeconds())}function _({run:e,jobId:l,onKilled:s}){const{t:a}=h(),n=j(),[m,c]=d.useState(!1),g=!e.readAt&&!["running","queued"].includes(e.status),p=["running","queued"].includes(e.status),u=async b=>{b.stopPropagation(),c(!0);const{success:r,error:f}=await x.killRun(e.id);if(c(!1),!r){o(f||a("scheduledJobs.toast.killFailed"),"error");return}o(a("scheduledJobs.toast.killed"),"success"),s==null||s()};return t.jsxs("button",{type:"button",onClick:()=>n(N.settings.scheduledJobRunDetail(l,e.id)),className:"border-none flex items-center px-4 h-14 hover:bg-white/5 light:hover:bg-slate-200 transition-colors text-left w-full",children:[t.jsxs("div",{className:"w-[200px] flex items-center gap-2 relative",children:[g&&t.jsx(z,{weight:"fill",className:"h-2 w-2 text-blue-400 light:text-blue-600 absolute -left-4"}),p&&t.jsx("button",{type:"button",onClick:u,disabled:m,title:a("scheduledJobs.runHistory.stopJob"),className:"border-none ml-2 p-1.5 rounded bg-red-500/20 text-red-400 light:bg-red-100 light:text-red-600 hover:bg-red-500/30 light:hover:bg-red-200 transition-colors disabled:opacity-50",children:t.jsx(C,{className:"h-3.5 w-3.5",weight:"bold"})}),t.jsx(I,{status:e.status})]}),t.jsx("span",{className:"w-[260px] text-sm font-medium text-white light:text-slate-950 truncate",children:new Date(e.startedAt).toLocaleString()}),t.jsx("span",{className:"w-[160px] text-sm font-medium text-white light:text-slate-950 truncate",children:P(e)}),t.jsx("span",{className:`flex-1 text-sm truncate pr-4 ${e.error?"text-red-400 light:text-red-600 italic":"font-medium text-white light:text-slate-950"}`,children:e.error||"—"})]})}function B(){const{t:e}=h(),{id:l}=H(),[s,a]=d.useState(null),[n,m]=d.useState([]),[c,g]=d.useState(!0),[p,u]=d.useState(!1),b=n.some(i=>i.status==="queued"||i.status==="running"),r=async()=>{const{runs:i}=await x.runs(l);m(i||[]),g(!1)};d.useEffect(()=>{x.get(l).then(({job:i})=>a(i)),r()},[l]),q(r,5e3);const f=async()=>{u(!0);const{success:i,skipped:v,error:J}=await x.trigger(l);if(u(!1),!i){o(J||e("scheduledJobs.toast.triggerFailed"),"error");return}v?o(e("scheduledJobs.toast.triggerSkipped","A run is already in progress for this job"),"info"):o(e("scheduledJobs.toast.triggered"),"success"),r()};return c?t.jsx(w,{job:s,children:t.jsx("div",{className:"flex flex-col items-center justify-center gap-8 py-24 text-center",children:t.jsx("p",{className:"text-zinc-400 light:text-slate-600 text-sm",children:e("scheduledJobs.loading")})})}):t.jsx(w,{job:s,children:t.jsxs("div",{className:"pt-8",children:[t.jsxs("div",{className:"flex items-center px-4 pb-[18px] text-xs font-semibold uppercase tracking-[1.4px] text-zinc-400 light:text-slate-600",children:[t.jsx("span",{className:"w-[200px]",children:e("scheduledJobs.runHistory.table.status")}),t.jsx("span",{className:"w-[260px]",children:e("scheduledJobs.runHistory.table.started")}),t.jsx("span",{className:"w-[160px]",children:e("scheduledJobs.runHistory.table.duration")}),t.jsx("span",{className:"flex-1",children:e("scheduledJobs.runHistory.table.error")})]}),t.jsx("div",{className:"h-px w-full bg-white/10 light:bg-slate-300"}),n.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center gap-8 py-24 text-center",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("p",{className:"text-base font-semibold text-zinc-50 light:text-slate-950",children:e("scheduledJobs.runHistory.emptyTitle")}),t.jsx("p",{className:"text-sm font-medium text-zinc-400 light:text-slate-600",children:e("scheduledJobs.runHistory.emptySubtitle")})]}),t.jsx("button",{type:"button",onClick:f,disabled:p||b,className:"border-none h-9 px-5 rounded-lg bg-zinc-50 text-zinc-950 light:bg-slate-900 light:text-white text-sm font-medium hover:bg-zinc-200 light:hover:bg-slate-800 transition-colors disabled:opacity-50",children:e("scheduledJobs.runHistory.runNow")})]}):t.jsx("div",{className:"flex flex-col divide-y divide-white/5 light:divide-slate-200",children:n.map(i=>t.jsx(_,{run:i,jobId:s==null?void 0:s.id,onKilled:r},i.id))})]})})}function w({job:e,children:l}){const{t:s,i18n:a}=h(),n=j();return t.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[t.jsx(R,{}),t.jsx("div",{style:{height:k?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:t.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[t.jsxs("div",{className:"w-full flex flex-col gap-y-2 pb-6 border-white/10 light:border-slate-300 border-b-2",children:[t.jsxs("button",{type:"button",onClick:()=>n(N.settings.scheduledJobs()),className:"border-none flex items-center gap-2 text-zinc-400 light:text-slate-600 hover:text-zinc-50 light:hover:text-slate-950 text-sm transition-colors w-fit",children:[t.jsx(A,{className:"h-4 w-4"}),s("scheduledJobs.runHistory.back")]}),t.jsx("p",{className:"text-lg leading-7 font-semibold text-zinc-50 light:text-slate-950",children:s("scheduledJobs.runHistory.title",{name:(e==null?void 0:e.name)||"..."})}),t.jsxs("p",{className:"text-xs text-zinc-400 light:text-slate-600",children:[s("scheduledJobs.runHistory.schedule")," ",t.jsx("code",{children:T(e==null?void 0:e.schedule,a.language)||"—"})]})]}),l]})})]})}export{B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aT as M,bz as J,bA as U,r as x,bB as D,bC as B,bD as V,bE as L,bF as X}from"../index.js";var Y={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0};const Z=M(Y);var q=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function S(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Z[n[1]]||e.charAt(e.length-2)==="/")&&(t.voidElement=!0),t.name.startsWith("!--"))){var i=e.indexOf("-->");return{type:"comment",comment:i!==-1?e.slice(4,i):""}}for(var f=new RegExp(q),r=null;(r=f.exec(e))!==null;)if(r[0].trim())if(r[1]){var c=r[1].trim(),l=[c,""];c.indexOf("=")>-1&&(l=c.split("=")),t.attrs[l[0]]=l[1],f.lastIndex--}else r[2]&&(t.attrs[r[2]]=r[3].trim().substring(1,r[3].length-1));return t}var G=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Q=/^\s*$/,_=Object.create(null);function W(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(n){var i=[];for(var f in n)i.push(f+'="'+n[f]+'"');return i.length?" "+i.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(W,"")+"</"+t.name+">";case"comment":return e+"<!--"+t.comment+"-->"}}var R={parse:function(e,t){t||(t={}),t.components||(t.components=_);var n,i=[],f=[],r=-1,c=!1;if(e.indexOf("<")!==0){var l=e.indexOf("<");i.push({type:"text",content:l===-1?e:e.substring(0,l)})}return e.replace(G,function(u,m){if(c){if(u!=="</"+n.name+">")return;c=!1}var v,b=u.charAt(1)!=="/",A=u.startsWith("<!--"),E=m+u.length,$=e.charAt(E);if(A){var h=S(u);return r<0?(i.push(h),i):((v=f[r]).children.push(h),i)}if(b&&(r++,(n=S(u)).type==="tag"&&t.components[n.name]&&(n.type="component",c=!0),n.voidElement||c||!$||$==="<"||n.children.push({type:"text",content:e.slice(E,e.indexOf("<",E))}),r===0&&i.push(n),(v=f[r-1])&&v.children.push(n),f[r]=n),(!b||n.voidElement)&&(r>-1&&(n.voidElement||n.name===u.slice(2,-1))&&(r--,n=r===-1?i:f[r]),!c&&$!=="<"&&$)){v=r===-1?i:f[r].children;var p=e.indexOf("<",E),o=e.slice(E,p===-1?void 0:p);Q.test(o)&&(o=" "),(p>-1&&r+v.length>=0||o!==" ")&&v.push({type:"text",content:o})}}),i},stringify:function(e){return e.reduce(function(t,n){return t+W("",n)},"")}};const H=(e,t)=>{if(!e)return!1;const n=e.props?e.props.children:e.children;return t?n.length>0:!!n},I=e=>{if(!e)return[];const t=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?P(t):t},ee=e=>Array.isArray(e)&&e.every(x.isValidElement),P=e=>Array.isArray(e)?e:[e],te=(e,t)=>{const n={...t};return n.props=Object.assign(e.props,t.props),n},z=(e,t)=>{if(!e)return"";let n="";const i=P(e),f=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return i.forEach((r,c)=>{if(D(r))n+=`${r}`;else if(x.isValidElement(r)){const{props:l,type:u}=r,m=Object.keys(l).length,v=f.indexOf(u)>-1,b=l.children;if(!b&&v&&!m)n+=`<${u}/>`;else if(!b&&(!v||m)||l.i18nIsDynamicList)n+=`<${c}></${c}>`;else if(v&&m===1&&D(b))n+=`<${u}>${b}</${u}>`;else{const A=z(b,t);n+=`<${c}>${A}</${c}>`}}else if(r===null)B("Trans: the passed in value is invalid - seems you passed in a null child.");else if(V(r)){const{format:l,...u}=r,m=Object.keys(u);if(m.length===1){const v=l?`${m[0]}, ${l}`:m[0];n+=`{{${v}}}`}else B("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else B("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",r)}),n},ne=(e,t,n,i,f,r)=>{if(t==="")return[];const c=i.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(c.map(p=>`<${p}`).join("|")).test(t);if(!e&&!l&&!r)return[t];const u={},m=p=>{P(p).forEach(a=>{D(a)||(H(a)?m(I(a)):V(a)&&!x.isValidElement(a)&&Object.assign(u,a))})};m(e);const v=R.parse(`<0>${t}</0>`),b={...u,...f},A=(p,o,a)=>{const g=I(p),C=$(g,o.children,a);return ee(g)&&C.length===0||p.props&&p.props.i18nIsDynamicList?g:C},E=(p,o,a,g,C)=>{p.dummy?(p.children=o,a.push(x.cloneElement(p,{key:g},C?void 0:o))):a.push(...x.Children.map([p],d=>{const s={...d.props};return delete s.i18nIsDynamicList,x.createElement(d.type,{...s,key:g,ref:d.ref},C?null:o)}))},$=(p,o,a)=>{const g=P(p);return P(o).reduce((d,s,T)=>{const N=s.children&&s.children[0]&&s.children[0].content&&n.services.interpolator.interpolate(s.children[0].content,b,n.language);if(s.type==="tag"){let k=g[parseInt(s.name,10)];a.length===1&&!k&&(k=a[0][s.name]),k||(k={});const y=Object.keys(s.attrs).length!==0?te({props:s.attrs},k):k,F=x.isValidElement(y),j=F&&H(s,!0)&&!s.voidElement,w=l&&V(y)&&y.dummy&&!F,K=V(e)&&Object.hasOwnProperty.call(e,s.name);if(D(y)){const O=n.services.interpolator.interpolate(y,b,n.language);d.push(O)}else if(H(y)||j){const O=A(y,s,a);E(y,O,d,T)}else if(w){const O=$(g,s.children,a);E(y,O,d,T)}else if(Number.isNaN(parseFloat(s.name)))if(K){const O=A(y,s,a);E(y,O,d,T,s.voidElement)}else if(i.transSupportBasicHtmlNodes&&c.indexOf(s.name)>-1)if(s.voidElement)d.push(x.createElement(s.name,{key:`${s.name}-${T}`}));else{const O=$(g,s.children,a);d.push(x.createElement(s.name,{key:`${s.name}-${T}`},O))}else if(s.voidElement)d.push(`<${s.name} />`);else{const O=$(g,s.children,a);d.push(`<${s.name}>${O}</${s.name}>`)}else if(V(y)&&!F){const O=s.children[0]?N:null;O&&d.push(O)}else E(y,N,d,T,s.children.length!==1||!N)}else if(s.type==="text"){const k=i.transWrapTextNodes,y=r?i.unescape(n.services.interpolator.interpolate(s.content,b,n.language)):n.services.interpolator.interpolate(s.content,b,n.language);k?d.push(x.createElement(k,{key:`${s.name}-${T}`},y)):d.push(y)}return d},[])},h=$([{dummy:!0,children:e||[]}],v,P(e||[]));return I(h[0])};function se(e){let{children:t,count:n,parent:i,i18nKey:f,context:r,tOptions:c={},values:l,defaults:u,components:m,ns:v,i18n:b,t:A,shouldUnescape:E,...$}=e;const h=b||L();if(!h)return J("You will need to pass in an i18next instance by using i18nextReactModule"),t;const p=A||h.t.bind(h)||(j=>j),o={...U(),...h.options&&h.options.react};let a=v||p.ns||h.options&&h.options.defaultNS;a=D(a)?[a]:a||["translation"];const g=z(t,o),C=u||g||o.transEmptyNodeValue||f,{hashTransKey:d}=o,s=f||(d?d(g||C):g||C);h.options&&h.options.interpolation&&h.options.interpolation.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...h.options.interpolation.defaultVariables}:{...h.options.interpolation.defaultVariables});const T=l||n!==void 0||!t?c.interpolation:{interpolation:{...c.interpolation,prefix:"#$?",suffix:"?$#"}},N={...c,context:r||c.context,count:n,...l,...T,defaultValue:C,ns:a},k=s?p(s,N):C;m&&Object.keys(m).forEach(j=>{const w=m[j];if(typeof w.type=="function"||!w.props||!w.props.children||k.indexOf(`${j}/>`)<0&&k.indexOf(`${j} />`)<0)return;function K(){return x.createElement(x.Fragment,null,w)}m[j]=x.createElement(K)});const y=ne(m||t,k,h,o,N,E),F=i!==void 0?i:o.defaultTransParent;return F?x.createElement(F,$,y):y}function ae(e){let{children:t,count:n,parent:i,i18nKey:f,context:r,tOptions:c={},values:l,defaults:u,components:m,ns:v,i18n:b,t:A,shouldUnescape:E,...$}=e;const{i18n:h,defaultNS:p}=x.useContext(X)||{},o=b||h||L(),a=A||o&&o.t.bind(o);return se({children:t,count:n,parent:i,i18nKey:f,context:r,tOptions:c,values:l,defaults:u,components:m,ns:v||a&&a.ns||p||o&&o.options&&o.options.defaultNS,i18n:o,t:A,shouldUnescape:E,...$})}export{ae as T};
|