totem-llm 0.11.1 → 0.13.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.
Files changed (23) hide show
  1. package/package.json +4 -2
  2. package/server/endpoints/telegram.js +14 -11
  3. package/server/jobs/handle-telegram-chat.js +2 -0
  4. package/server/public/assets/{RunDetailPage-1f31e7a9.js → RunDetailPage-200185a7.js} +1 -1
  5. package/server/public/assets/{RunHistoryPage-ad807d5e.js → RunHistoryPage-96d3c809.js} +1 -1
  6. package/server/public/assets/{files-552bd51c.js → files-202b5d45.js} +1 -1
  7. package/server/public/assets/{index-c493e3e5.js → index-362a6966.js} +1 -1
  8. package/server/public/assets/{index-b6046b8c.js → index-44382a03.js} +42 -42
  9. package/server/public/assets/{index-e7572a76.js → index-5ce31135.js} +1 -1
  10. package/server/public/assets/{index-f1520ab9.js → index-89d4b041.js} +1 -1
  11. package/server/public/assets/{index-2757c3d3.js → index-93f21048.js} +1 -1
  12. package/server/public/assets/{index-e7cfd6f7.js → index-eeddac0e.js} +1 -1
  13. package/server/public/assets/{purify-bb71c5e8.js → purify-5067c4b9.js} +1 -1
  14. package/server/public/index.js +49 -49
  15. package/server/utils/helpers/updateENV.js +14 -2
  16. package/server/utils/telegramBot/chat/stream.js +196 -76
  17. package/server/utils/telegramBot/constants.js +21 -2
  18. package/server/utils/telegramBot/index.js +197 -33
  19. package/server/utils/telegramBot/utils/commands/handlers/groupManagement.js +257 -0
  20. package/server/utils/telegramBot/utils/commands/index.js +20 -0
  21. package/server/utils/telegramBot/utils/index.js +112 -0
  22. package/server/utils/telegramBot/utils/navigation/index.js +6 -2
  23. package/server/utils/telegramBot/utils/verification.js +57 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totem-llm",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "description": "Totem LLM – Your Private AI. Run a self-hosted AI assistant locally on Linux, macOS, or Windows.",
5
5
  "main": "bin/totem-llm.js",
6
6
  "type": "module",
@@ -63,6 +63,8 @@
63
63
  "devDependencies": {
64
64
  "@babel/core": "^8.0.1",
65
65
  "@babel/preset-env": "^8.0.2",
66
+ "@commitlint/cli": "^21.2.1",
67
+ "@commitlint/config-conventional": "^21.2.0",
66
68
  "@langchain/textsplitters": "^1.0.1",
67
69
  "babel-jest": "^30.4.1",
68
70
  "concurrently": "^9.1.2",
@@ -73,10 +75,10 @@
73
75
  "lodash": "^4.18.1",
74
76
  "pg": "^8.22.0",
75
77
  "slugify": "^1.6.9",
78
+ "standard-version": "^9.5.0",
76
79
  "uuid": "^14.0.1"
77
80
  },
78
81
  "dependencies": {
79
82
  "qrcode-terminal": "^0.12.0"
80
83
  }
81
84
  }
82
-
@@ -3,7 +3,10 @@ const {
3
3
  } = require("../models/externalCommunicationConnector");
4
4
  const { TelegramBotService } = require("../utils/telegramBot");
5
5
  const { validatedRequest } = require("../utils/middleware/validatedRequest");
6
- const { isSingleUserMode } = require("../utils/middleware/multiUserProtected");
6
+ const {
7
+ flexUserRoleValid,
8
+ ROLES,
9
+ } = require("../utils/middleware/multiUserProtected");
7
10
  const { reqBody } = require("../utils/http");
8
11
  const { EventLogs } = require("../models/eventLogs");
9
12
  const { Workspace } = require("../models/workspace");
@@ -15,7 +18,7 @@ function telegramEndpoints(app) {
15
18
 
16
19
  app.get(
17
20
  "/telegram/config",
18
- [validatedRequest, isSingleUserMode],
21
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
19
22
  async (_request, response) => {
20
23
  try {
21
24
  const connector = await ExternalCommunicationConnector.get("telegram");
@@ -73,7 +76,7 @@ function telegramEndpoints(app) {
73
76
  */
74
77
  app.post(
75
78
  "/telegram/connect",
76
- [validatedRequest, isSingleUserMode],
79
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
77
80
  async (request, response) => {
78
81
  try {
79
82
  const { bot_token, default_workspace = null } = reqBody(request);
@@ -158,7 +161,7 @@ function telegramEndpoints(app) {
158
161
 
159
162
  app.post(
160
163
  "/telegram/disconnect",
161
- [validatedRequest, isSingleUserMode],
164
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
162
165
  async (_request, response) => {
163
166
  try {
164
167
  const service = new TelegramBotService();
@@ -175,7 +178,7 @@ function telegramEndpoints(app) {
175
178
 
176
179
  app.get(
177
180
  "/telegram/status",
178
- [validatedRequest, isSingleUserMode],
181
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
179
182
  async (_request, response) => {
180
183
  try {
181
184
  const connector = await ExternalCommunicationConnector.get("telegram");
@@ -193,7 +196,7 @@ function telegramEndpoints(app) {
193
196
 
194
197
  app.get(
195
198
  "/telegram/pending-users",
196
- [validatedRequest, isSingleUserMode],
199
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
197
200
  async (_request, response) => {
198
201
  try {
199
202
  const service = new TelegramBotService();
@@ -209,7 +212,7 @@ function telegramEndpoints(app) {
209
212
 
210
213
  app.get(
211
214
  "/telegram/approved-users",
212
- [validatedRequest, isSingleUserMode],
215
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
213
216
  async (_request, response) => {
214
217
  try {
215
218
  const connector = await ExternalCommunicationConnector.get("telegram");
@@ -224,7 +227,7 @@ function telegramEndpoints(app) {
224
227
 
225
228
  app.post(
226
229
  "/telegram/approve-user",
227
- [validatedRequest, isSingleUserMode],
230
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
228
231
  async (request, response) => {
229
232
  try {
230
233
  const { chatId } = reqBody(request);
@@ -246,7 +249,7 @@ function telegramEndpoints(app) {
246
249
 
247
250
  app.post(
248
251
  "/telegram/deny-user",
249
- [validatedRequest, isSingleUserMode],
252
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
250
253
  async (request, response) => {
251
254
  try {
252
255
  const { chatId } = reqBody(request);
@@ -268,7 +271,7 @@ function telegramEndpoints(app) {
268
271
 
269
272
  app.post(
270
273
  "/telegram/revoke-user",
271
- [validatedRequest, isSingleUserMode],
274
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
272
275
  async (request, response) => {
273
276
  try {
274
277
  const { chatId } = reqBody(request);
@@ -290,7 +293,7 @@ function telegramEndpoints(app) {
290
293
 
291
294
  app.post(
292
295
  "/telegram/update-config",
293
- [validatedRequest, isSingleUserMode],
296
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
294
297
  async (request, response) => {
295
298
  try {
296
299
  const { voice_response_mode } = reqBody(request);
@@ -14,6 +14,7 @@ process.on("message", async (payload) => {
14
14
  const {
15
15
  botToken,
16
16
  chatId,
17
+ messageThreadId,
17
18
  workspaceSlug,
18
19
  threadSlug,
19
20
  message,
@@ -46,6 +47,7 @@ process.on("message", async (payload) => {
46
47
  await streamResponse({
47
48
  ctx,
48
49
  chatId,
50
+ messageThreadId,
49
51
  workspace,
50
52
  thread,
51
53
  message,
@@ -1 +1 @@
1
- import{r as o,j as t,ad as G,aG as $,aO as X,V as C,u as y,aM as I,s as q,a7 as K,a6 as U,bL as V,ca as B,c as j,l as Y,b as W,Y as f,p as T,a2 as Q,i as Z,a$ as ee,bH as te,av 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{u as re}from"./usePolling-3b229af5.js";import{c as ie,S as oe,T as J,a as de,b as ce,r as _}from"./files-552bd51c.js";import{C as ue}from"./Copy-d323e545.js";import{H as xe,D as S}from"./purify-bb71c5e8.js";import{t as L}from"./truncate-e484143c.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),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:[K(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}=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: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(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: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: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,ad as G,aG as $,aO as X,V as C,u as y,aM as I,s as q,a7 as K,a6 as U,bL as V,cb as B,c as j,l as Y,b as W,Y as f,p as T,a2 as Q,i as Z,a$ as ee,bH as te,av 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{u as re}from"./usePolling-3b229af5.js";import{c as ie,S as oe,T as J,a as de,b as ce,r as _}from"./files-202b5d45.js";import{C as ue}from"./Copy-d323e545.js";import{H as xe,D as S}from"./purify-5067c4b9.js";import{t as L}from"./truncate-e484143c.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),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:[K(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}=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: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(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: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: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 +1 @@
1
- import{u as h,j as t,b as j,r as d,p as N,c9 as z,bH as H,Y as x,c,l as R,a2 as S,i as k,a$ as A}from"../index.js";import{u as q}from"./usePolling-3b229af5.js";import{R as C}from"./Stop-4b47ae05.js";import{h as y}from"./moment-49fc1b76.js";import{h as T}from"./cron-db080d69.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 H(l.asSeconds())}function $({run:e,jobId:l,onKilled:s}){const{t:a}=h(),n=j(),[m,o]=d.useState(!1),g=!e.readAt&&!["running","queued"].includes(e.status),p=["running","queued"].includes(e.status),u=async f=>{f.stopPropagation(),o(!0);const{success:r,error:b}=await x.killRun(e.id);if(o(!1),!r){c(b||a("scheduledJobs.toast.killFailed"),"error");return}c(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}=R(),[s,a]=d.useState(null),[n,m]=d.useState([]),[o,g]=d.useState(!0),[p,u]=d.useState(!1),f=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 b=async()=>{u(!0);const{success:i,skipped:v,error:J}=await x.trigger(l);if(u(!1),!i){c(J||e("scheduledJobs.toast.triggerFailed"),"error");return}v?c(e("scheduledJobs.toast.triggerSkipped","A run is already in progress for this job"),"info"):c(e("scheduledJobs.toast.triggered"),"success"),r()};return o?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:b,disabled:p||f,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(S,{}),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
+ import{u as h,j as t,b as j,r as d,p as N,ca as z,bH as H,Y as x,c,l as R,a2 as S,i as k,a$ as A}from"../index.js";import{u as q}from"./usePolling-3b229af5.js";import{R as C}from"./Stop-4b47ae05.js";import{h as y}from"./moment-49fc1b76.js";import{h as T}from"./cron-db080d69.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 H(l.asSeconds())}function $({run:e,jobId:l,onKilled:s}){const{t:a}=h(),n=j(),[m,o]=d.useState(!1),g=!e.readAt&&!["running","queued"].includes(e.status),p=["running","queued"].includes(e.status),u=async f=>{f.stopPropagation(),o(!0);const{success:r,error:b}=await x.killRun(e.id);if(o(!1),!r){c(b||a("scheduledJobs.toast.killFailed"),"error");return}c(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}=R(),[s,a]=d.useState(null),[n,m]=d.useState([]),[o,g]=d.useState(!0),[p,u]=d.useState(!1),f=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 b=async()=>{u(!0);const{success:i,skipped:v,error:J}=await x.trigger(l);if(u(!1),!i){c(J||e("scheduledJobs.toast.triggerFailed"),"error");return}v?c(e("scheduledJobs.toast.triggerSkipped","A run is already in progress for this job"),"info"):c(e("scheduledJobs.toast.triggered"),"success"),r()};return o?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:b,disabled:p||f,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(S,{}),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};