totem-llm 0.1.5 → 0.1.6
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/README.md +2 -28
- package/bin/totem-llm.js +8 -0
- package/lib/__tests__/version.test.js +17 -0
- package/lib/launcher.js +7 -0
- package/lib/version.js +14 -0
- package/package.json +1 -1
- package/server/.env +2 -1
- package/server/jobs/helpers/scheduled-job-helper.js +1 -1
- package/server/public/assets/{404-aca8e9d6.js → 404-b5c6b0dc.js} +1 -1
- package/server/public/assets/{RunDetailPage-edfdbd4d.js → RunDetailPage-74b1e63a.js} +1 -1
- package/server/public/assets/{RunHistoryPage-732dae26.js → RunHistoryPage-9609436a.js} +1 -1
- package/server/public/assets/{Trans-36b04c7b.js → Trans-ca8f9cfe.js} +1 -1
- package/server/public/assets/{cron-2ad9194f.js → cron-1f15870f.js} +1 -1
- package/server/public/assets/{files-493643b0.js → files-e19b0187.js} +1 -1
- package/server/public/assets/{index-18267c12.js → index-1f741737.js} +1 -1
- package/server/public/assets/{index-f32a1eca.js → index-2419056d.js} +2 -2
- package/server/public/assets/{index-5c320a5d.js → index-2f526c2a.js} +1 -1
- package/server/public/assets/{index-d69f2e09.js → index-39899779.js} +1 -1
- package/server/public/assets/{index-d59c6d7f.js → index-3a2c5fd7.js} +1 -1
- package/server/public/assets/{index-e5b911ea.js → index-51f23c79.js} +1 -1
- package/server/public/assets/{index-c22f7da1.js → index-6710499a.js} +1 -1
- package/server/public/assets/{index-7b0ea06b.js → index-6cdecde9.js} +1 -1
- package/server/public/assets/{index-e5ab4499.js → index-6e74fc6d.js} +1 -1
- package/server/public/assets/index-73aba4c6.js +3 -0
- package/server/public/assets/{index-4b5e1c76.js → index-9cc77cb6.js} +1 -1
- package/server/public/assets/{index-3761d55d.js → index-a6e642d7.js} +1 -1
- package/server/public/assets/{index-71027183.js → index-ac4d4b42.js} +1 -1
- package/server/public/assets/{index-0bf8ea25.js → index-c391a2fa.js} +1 -1
- package/server/public/assets/{index-72832304.js → index-dad0fb8d.js} +1 -1
- package/server/public/assets/{index-a6ac5511.js → index-dd210692.js} +1 -1
- package/server/public/assets/{index-fd922432.js → index-e28b0ead.js} +1 -1
- package/server/public/assets/{mcpServers-957b1f1c.js → mcpServers-a175e8cf.js} +1 -1
- package/server/public/assets/{moment-3ad2e1a6.js → moment-8a59df1b.js} +1 -1
- package/server/public/assets/{purify-6b86d6dc.js → purify-fbc9e8e2.js} +1 -1
- package/server/public/assets/{react-beautiful-dnd.esm-86e87aba.js → react-beautiful-dnd.esm-45ea8487.js} +1 -1
- package/server/public/index.js +19 -19
- package/server/utils/AiProviders/ollama/index.js +20 -10
- package/server/utils/agents/aibitat/plugins/filesystem/lib.js +10 -3
- package/server/utils/agents/aibitat/plugins/websocket.js +1 -2
- package/server/yarn.lock +1606 -415
- package/totem.features.cjs +39 -16
- package/server/public/assets/index-aa687cfe.js +0 -3
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Totem LLM is a sovereign AI solution, aimed at optimizing for consumer hardware and ensuring data privacy. It is designed to run efficiently on consumer-grade hardware, such as laptops and desktops, without the need for cloud-based processing. This allows users to have full control over their data and AI interactions, without relying on third-party services.
|
|
4
4
|
|
|
5
|
+
While local AI is the core focus, Totem LLM supports both local and cloud-based LLM providers, giving users the flexibility to choose based on their needs and preferences. The system is built with a modular architecture, allowing for easy integration of new features and providers over time.
|
|
6
|
+
|
|
5
7
|
## Install Quick Start Package
|
|
6
8
|
|
|
7
9
|
### Prerequisites
|
|
@@ -88,34 +90,6 @@ This starts the server (port `3001`), collector (port `8888`), and frontend dev
|
|
|
88
90
|
|
|
89
91
|
> Alternatively, run each service in its own terminal: `yarn dev:server`, `yarn dev:collector`, `yarn dev:frontend`.
|
|
90
92
|
|
|
91
|
-
### 5. Build for production
|
|
92
|
-
|
|
93
|
-
Choose a build profile and run the frontend build + deploy script:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
# Available profiles: npm | desktop-free | desktop-premium | source
|
|
97
|
-
TOTEM_BUILD_PROFILE=source node scripts/build-frontend.mjs
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
This builds the Vite frontend and copies the output into `server/public/`. Then start the server:
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
node bin/totem-llm.js start
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
The app will be available at [http://localhost:3001](http://localhost:3001).
|
|
107
|
-
|
|
108
|
-
#### Build profiles
|
|
109
|
-
|
|
110
|
-
| Profile | Community Hub | Model Router | LLM Providers | Branding & Whitelabeling |
|
|
111
|
-
|---|---|---|---|---|
|
|
112
|
-
| `npm` | ✗ | ✗ | Ollama, OpenRouter only | ✗ |
|
|
113
|
-
| `desktop-free` | ✗ | ✓ | All | ✗ |
|
|
114
|
-
| `desktop-premium` | ✓ | ✓ | All | ✓ |
|
|
115
|
-
| `source` | ✓ | ✓ | All | ✓ |
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
93
|
## Thanks
|
|
120
94
|
|
|
121
95
|
Massive thank you and appreciation to AnythingLLM. Totem LLM is a fork of AnythingLLM, and we are grateful for the foundation they have provided. We will continue to build on their work and contribute back to the community.
|
package/bin/totem-llm.js
CHANGED
|
@@ -3,6 +3,7 @@ import { fileURLToPath } from "url";
|
|
|
3
3
|
import { dirname, join } from "path";
|
|
4
4
|
import { setup } from "../lib/setup.js";
|
|
5
5
|
import { launch } from "../lib/launcher.js";
|
|
6
|
+
import { getPackageVersion } from "../lib/version.js";
|
|
6
7
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
9
|
const __dirname = dirname(__filename);
|
|
@@ -10,6 +11,7 @@ const packageRoot = join(__dirname, "..");
|
|
|
10
11
|
|
|
11
12
|
const args = process.argv.slice(2);
|
|
12
13
|
const isHelp = args.includes("--help") || args.includes("-h");
|
|
14
|
+
const isVersion = args.some((a) => a === "--version" || a === "-v");
|
|
13
15
|
const command = isHelp
|
|
14
16
|
? "help"
|
|
15
17
|
: (args.find((a) => !a.startsWith("--")) ?? "start");
|
|
@@ -18,6 +20,11 @@ const portArg = args.find((a) => a.startsWith("--port="));
|
|
|
18
20
|
const port = portArg ? portArg.split("=")[1] : undefined;
|
|
19
21
|
|
|
20
22
|
async function main() {
|
|
23
|
+
if (isVersion) {
|
|
24
|
+
console.log(getPackageVersion(packageRoot));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
switch (command) {
|
|
22
29
|
case "start":
|
|
23
30
|
await setup({ packageRoot });
|
|
@@ -59,6 +66,7 @@ Commands:
|
|
|
59
66
|
Options:
|
|
60
67
|
--no-collector Start without the document collector (skips Puppeteer/ffmpeg)
|
|
61
68
|
--port=<port> Override the server port (default: 3001)
|
|
69
|
+
--version, -v Print Totem LLM version and exit
|
|
62
70
|
--force (setup only) Regenerate configuration even if it already exists
|
|
63
71
|
|
|
64
72
|
Environment Variables:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolve, dirname } from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import { getPackageVersion } from "../version.js";
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = dirname(__filename);
|
|
7
|
+
const packageRoot = resolve(__dirname, "../..");
|
|
8
|
+
|
|
9
|
+
describe("getPackageVersion", () => {
|
|
10
|
+
test("returns the root package.json version", () => {
|
|
11
|
+
const version = getPackageVersion(packageRoot);
|
|
12
|
+
|
|
13
|
+
expect(version).toBeDefined();
|
|
14
|
+
expect(typeof version).toBe("string");
|
|
15
|
+
expect(version).toMatch(/^\d+\.\d+\.\d+(?:[-+].*)?$/);
|
|
16
|
+
});
|
|
17
|
+
});
|
package/lib/launcher.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { getEnv } from "./config.js";
|
|
4
|
+
import { getPackageVersion } from "./version.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Spawn a Node.js service and prefix every log line with a fixed-width label.
|
|
@@ -46,6 +47,11 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
|
|
|
46
47
|
const env = getEnv();
|
|
47
48
|
if (port) env.SERVER_PORT = port;
|
|
48
49
|
|
|
50
|
+
let appVersion = "unknown";
|
|
51
|
+
try {
|
|
52
|
+
appVersion = getPackageVersion(packageRoot) ?? "unknown";
|
|
53
|
+
} catch {}
|
|
54
|
+
|
|
49
55
|
const serverPort = env.SERVER_PORT ?? "3001";
|
|
50
56
|
const collectorPort = env.COLLECTOR_PORT ?? "8888";
|
|
51
57
|
const nodeExe = process.execPath; // cross-platform: always the right Node binary
|
|
@@ -54,6 +60,7 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
|
|
|
54
60
|
const collectorDir = join(packageRoot, "collector");
|
|
55
61
|
|
|
56
62
|
console.log("Starting Totem LLM…");
|
|
63
|
+
console.log(` Version → ${appVersion}`);
|
|
57
64
|
console.log(` Server → http://localhost:${serverPort}`);
|
|
58
65
|
if (!noCollector) {
|
|
59
66
|
console.log(` Collector → http://localhost:${collectorPort}`);
|
package/lib/version.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
|
|
4
|
+
export function getPackageVersion(packageRoot) {
|
|
5
|
+
const packageJsonPath = join(packageRoot, "package.json");
|
|
6
|
+
const raw = readFileSync(packageJsonPath, "utf8");
|
|
7
|
+
const pkg = JSON.parse(raw);
|
|
8
|
+
|
|
9
|
+
if (!pkg?.version) {
|
|
10
|
+
throw new Error(`Version not found in ${packageJsonPath}`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return pkg.version;
|
|
14
|
+
}
|
package/package.json
CHANGED
package/server/.env
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
SERVER_PORT=3001
|
|
2
|
+
DATABASE_URL="file:../storage/anythingllm.db"
|
|
2
3
|
JWT_SECRET="my-random-string-for-seeding" # Please generate random string at least 12 chars long.
|
|
3
4
|
# JWT_EXPIRY="30d" # (optional) https://docs.anythingllm.com/configuration#custom-ttl-for-sessions
|
|
4
5
|
SIG_KEY='passphrase' # Please generate random string at least 32 chars long.
|
|
@@ -44,7 +45,7 @@ OLLAMA_BASE_PATH='http://127.0.0.1:11434'
|
|
|
44
45
|
OLLAMA_MODEL_PREF='qwen3.5:2b'
|
|
45
46
|
OLLAMA_MODEL_TOKEN_LIMIT=4096
|
|
46
47
|
OLLAMA_AUTH_TOKEN='your-ollama-auth-token-here (optional, only for ollama running behind auth - Bearer token)'
|
|
47
|
-
OLLAMA_RESPONSE_TIMEOUT=
|
|
48
|
+
OLLAMA_RESPONSE_TIMEOUT=72000000 # Optional response timeout in ms for Ollama API calls. Must be at least 5 minutes (300000ms) to prevent unintended termination of long-running requests. Default is no timeout.
|
|
48
49
|
|
|
49
50
|
# LLM_PROVIDER='togetherai'
|
|
50
51
|
# TOGETHER_AI_API_KEY='my-together-ai-key'
|
|
@@ -6,7 +6,7 @@ const { stripThinkingFromText } = require("./index.js");
|
|
|
6
6
|
* @type {number}
|
|
7
7
|
*/
|
|
8
8
|
const SCHEDULED_JOB_TIMEOUT_MS =
|
|
9
|
-
Number(process.env.SCHEDULED_JOB_TIMEOUT_MS) ||
|
|
9
|
+
Number(process.env.SCHEDULED_JOB_TIMEOUT_MS) || 60 * 60 * 1000;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Create a callback function for the agent action.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,J as t,U as s,
|
|
1
|
+
import{j as e,J as t,U as s,b_ 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,a9 as $,aC as G,aK as X,T as R,u as y,aI as I,s as K,a3 as q,a2 as U,bH as B,bY as V,c as j,l as Y,b as W,p as k,$ as Q,i as Z,aX as ee,bD as te,ar 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-493643b0.js";import{C as ue}from"./Copy-d323e545.js";import{H as xe,D as S}from"./purify-6b86d6dc.js";import{t as E}from"./truncate-352eb33b.js";import{h as L}from"./moment-3ad2e1a6.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($,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}):t.jsx(G,{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"?K(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(R,{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 C={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=C[l]||C.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 V(()=>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(B,{size:16,weight:"bold"})})]})}function Me(){const{t:e}=y(),{id:s,runId:l}=Y(),n=W(),[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:T}=await f.continueInThread(l);if(T||!c||!b){j(T||e("scheduledJobs.runDetail.threadFailed"),"error"),g(!1);return}n(k.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(k.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(Te,{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: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:R,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 Te({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,a9 as $,aC as G,aK as X,T as R,u as y,aI as I,s as K,a3 as q,a2 as U,bI as B,bZ as V,c as j,l as W,b as Y,p as k,$ as Z,i as Q,aX as ee,bE as te,ar 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-e19b0187.js";import{C as ue}from"./Copy-d323e545.js";import{H as xe,D as S}from"./purify-fbc9e8e2.js";import{t as E}from"./truncate-352eb33b.js";import{h as L}from"./moment-8a59df1b.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($,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}):t.jsx(G,{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"?K(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(R,{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 C={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=C[l]||C.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 V(()=>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(B,{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:T}=await f.continueInThread(l);if(T||!c||!b){j(T||e("scheduledJobs.runDetail.threadFailed"),"error"),g(!1);return}n(k.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(k.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(Te,{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:R,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 Te({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,bY as z,bE as S,c as o,l as R,$ as k,i as H,aX 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-8a59df1b.js";import{h as T}from"./cron-1f15870f.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 E({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 I(e){if(!e.completedAt||!e.startedAt)return"—";const l=y.duration(y(e.completedAt).diff(y(e.startedAt)));return S(l.asSeconds())}function P({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(E,{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:I(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}=R(),[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(P,{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(k,{}),t.jsx("div",{style:{height:H?"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{aQ as M,
|
|
1
|
+
import{aQ as M,bw as J,bx as Q,r as x,by as K,bz as D,bA as V,bB as L,bC as U}from"../index.js";var X={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 Y=M(X);var Z=/\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],(Y[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(Z),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 q=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,G=/^\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(q,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);G.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(K(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&&K(b))n+=`<${u}>${b}</${u}>`;else{const A=z(b,t);n+=`<${c}>${A}</${c}>`}}else if(r===null)D("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 D("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else D("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=>{K(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,w=x.isValidElement(y),j=w&&H(s,!0)&&!s.voidElement,F=l&&V(y)&&y.dummy&&!w,B=V(e)&&Object.hasOwnProperty.call(e,s.name);if(K(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(F){const O=$(g,s.children,a);E(y,O,d,T)}else if(Number.isNaN(parseFloat(s.name)))if(B){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)&&!w){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={...Q(),...h.options&&h.options.react};let a=v||p.ns||h.options&&h.options.defaultNS;a=K(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 F=m[j];if(typeof F.type=="function"||!F.props||!F.props.children||k.indexOf(`${j}/>`)<0&&k.indexOf(`${j} />`)<0)return;function B(){return x.createElement(x.Fragment,null,F)}m[j]=x.createElement(B)});const y=ne(m||t,k,h,o,N,E),w=i!==void 0?i:o.defaultTransParent;return w?x.createElement(w,$,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(U)||{},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};
|