morpheus-cli 0.8.5 → 0.8.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/dist/config/manager.js +3 -1
- package/dist/config/schemas.js +2 -0
- package/dist/http/api.js +21 -0
- package/dist/runtime/memory/sati/index.js +22 -1
- package/dist/runtime/memory/sati/repository.js +2 -1
- package/dist/runtime/oracle.js +37 -13
- package/dist/runtime/tools/time-verify-tools.js +15 -8
- package/dist/types/config.js +2 -0
- package/dist/ui/assets/{Chat-Cx2OgATp.js → Chat-CO15OnaY.js} +7 -7
- package/dist/ui/assets/{Chronos--mut48fM.js → Chronos-CUZDQLh2.js} +1 -1
- package/dist/ui/assets/{ConfirmationModal-MyIaIK_Z.js → ConfirmationModal-Bx-GtD9B.js} +1 -1
- package/dist/ui/assets/{Dashboard-C52jjru9.js → Dashboard-DDyN_X-J.js} +1 -1
- package/dist/ui/assets/{DeleteConfirmationModal-B0nDocEK.js → DeleteConfirmationModal-DIXbckY8.js} +1 -1
- package/dist/ui/assets/{Logs-fDrGC9Lq.js → Logs-dzPLW45U.js} +1 -1
- package/dist/ui/assets/{MCPManager-CtRQzwM8.js → MCPManager-CRHWR4S7.js} +1 -1
- package/dist/ui/assets/{ModelPricing-d4EYrGko.js → ModelPricing-TRBesy0r.js} +1 -1
- package/dist/ui/assets/{Notifications-Dkqug57C.js → Notifications-DMke7Dr7.js} +1 -1
- package/dist/ui/assets/{SatiMemories-DykYVHgi.js → SatiMemories-CaLrgdZV.js} +1 -1
- package/dist/ui/assets/SessionAudit-DedGO5XK.js +9 -0
- package/dist/ui/assets/{Settings-Cgd4dJdc.js → Settings-DNDe62-H.js} +6 -4
- package/dist/ui/assets/{Skills-DSi313oC.js → Skills-KUhW7UXP.js} +1 -1
- package/dist/ui/assets/{Smiths-DLys0BWT.js → Smiths-Btoqw4Ex.js} +1 -1
- package/dist/ui/assets/{Tasks-B1MbPNUQ.js → Tasks-cwA25Hq2.js} +1 -1
- package/dist/ui/assets/{TrinityDatabases-B5SeHOLt.js → TrinityDatabases-CQhettEJ.js} +1 -1
- package/dist/ui/assets/{UsageStats-EEwfbJ6C.js → UsageStats-doBLB7Lc.js} +1 -1
- package/dist/ui/assets/{WebhookManager-CyVUcscY.js → WebhookManager-D3A5pdjC.js} +1 -1
- package/dist/ui/assets/{chronos-BVRpP__j.js → chronos-DlDM2UBT.js} +1 -1
- package/dist/ui/assets/{config-cslLZS3q.js → config-DX3Xb0XE.js} +1 -1
- package/dist/ui/assets/{index-CpVvCthh.js → index-CQIUjucB.js} +2 -2
- package/dist/ui/assets/{index-QQyZIsmH.css → index-DAh3q_hR.css} +1 -1
- package/dist/ui/assets/{mcp-M0iDC0mj.js → mcp-DfhJYN14.js} +1 -1
- package/dist/ui/assets/{skills-BvaaqiOT.js → skills-BPjq0qV7.js} +1 -1
- package/dist/ui/assets/{stats-DALk3GOj.js → stats-DHCRNkJp.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/ui/sw.js +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/SessionAudit-Bk0-DpW0.js +0 -9
package/dist/config/manager.js
CHANGED
|
@@ -151,7 +151,9 @@ export class ConfigManager {
|
|
|
151
151
|
base_url: config.sati.base_url || config.llm.base_url,
|
|
152
152
|
context_window: config.sati.context_window !== undefined ? resolveNumeric('MORPHEUS_SATI_CONTEXT_WINDOW', config.sati.context_window, config.sati.context_window) : llmConfig.context_window,
|
|
153
153
|
memory_limit: config.sati.memory_limit !== undefined ? resolveNumeric('MORPHEUS_SATI_MEMORY_LIMIT', config.sati.memory_limit, config.sati.memory_limit) : undefined,
|
|
154
|
-
enabled_archived_sessions: resolveBoolean('MORPHEUS_SATI_ENABLED_ARCHIVED_SESSIONS', config.sati.enabled_archived_sessions, true)
|
|
154
|
+
enabled_archived_sessions: resolveBoolean('MORPHEUS_SATI_ENABLED_ARCHIVED_SESSIONS', config.sati.enabled_archived_sessions, true),
|
|
155
|
+
similarity_threshold: resolveNumeric('MORPHEUS_SATI_SIMILARITY_THRESHOLD', config.sati.similarity_threshold, 0.9),
|
|
156
|
+
evaluation_interval: resolveNumeric('MORPHEUS_SATI_EVALUATION_INTERVAL', config.sati.evaluation_interval, 1),
|
|
155
157
|
};
|
|
156
158
|
}
|
|
157
159
|
// Apply precedence to Apoc config
|
package/dist/config/schemas.js
CHANGED
|
@@ -21,6 +21,8 @@ export const LLMConfigSchema = z.object({
|
|
|
21
21
|
export const SatiConfigSchema = LLMConfigSchema.extend({
|
|
22
22
|
memory_limit: z.number().int().positive().optional(),
|
|
23
23
|
enabled_archived_sessions: z.boolean().default(true),
|
|
24
|
+
similarity_threshold: z.number().min(0).max(1).default(0.9),
|
|
25
|
+
evaluation_interval: z.number().int().min(1).default(1),
|
|
24
26
|
});
|
|
25
27
|
export const ApocConfigSchema = LLMConfigSchema.extend({
|
|
26
28
|
working_dir: z.string().optional(),
|
package/dist/http/api.js
CHANGED
|
@@ -178,8 +178,29 @@ export function createApiRouter(oracle, chronosWorker) {
|
|
|
178
178
|
duration_ms: row.duration_ms ?? null,
|
|
179
179
|
provider: row.provider ?? null,
|
|
180
180
|
model: row.model ?? null,
|
|
181
|
+
sati_memories_count: null,
|
|
181
182
|
};
|
|
182
183
|
});
|
|
184
|
+
// Enrich AI messages with Sati memory recovery counts from audit events
|
|
185
|
+
const recoveryEvents = AuditRepository.getInstance()
|
|
186
|
+
.getBySession(id, { limit: 10_000 })
|
|
187
|
+
.filter(e => e.event_type === 'memory_recovery')
|
|
188
|
+
.sort((a, b) => a.created_at - b.created_at);
|
|
189
|
+
for (let ri = 0; ri < recoveryEvents.length; ri++) {
|
|
190
|
+
const ev = recoveryEvents[ri];
|
|
191
|
+
const windowEnd = recoveryEvents[ri + 1]?.created_at ?? Infinity;
|
|
192
|
+
const count = ev.metadata ? (JSON.parse(ev.metadata).memories_count ?? 0) : 0;
|
|
193
|
+
if (count === 0)
|
|
194
|
+
continue;
|
|
195
|
+
// Assign to the LAST ai message within this recovery's window
|
|
196
|
+
for (let mi = normalizedMessages.length - 1; mi >= 0; mi--) {
|
|
197
|
+
const m = normalizedMessages[mi];
|
|
198
|
+
if (m.type === 'ai' && m.created_at > ev.created_at && m.created_at < windowEnd) {
|
|
199
|
+
m.sati_memories_count = count;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
183
204
|
// Convert DESC to ASC for UI rendering
|
|
184
205
|
res.json(normalizedMessages.reverse());
|
|
185
206
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AIMessage } from "@langchain/core/messages";
|
|
2
2
|
import { SatiService } from "./service.js";
|
|
3
3
|
import { DisplayManager } from "../../display.js";
|
|
4
|
+
import { AuditRepository } from "../../audit/repository.js";
|
|
4
5
|
const display = DisplayManager.getInstance();
|
|
5
6
|
export class SatiMemoryMiddleware {
|
|
6
7
|
service;
|
|
@@ -14,12 +15,25 @@ export class SatiMemoryMiddleware {
|
|
|
14
15
|
}
|
|
15
16
|
return SatiMemoryMiddleware.instance;
|
|
16
17
|
}
|
|
17
|
-
async beforeAgent(currentMessage, history) {
|
|
18
|
+
async beforeAgent(currentMessage, history, sessionId) {
|
|
19
|
+
const startMs = Date.now();
|
|
18
20
|
try {
|
|
19
21
|
// Extract recent messages content strings for context
|
|
20
22
|
const recentText = history.slice(-10).map(m => m.content.toString());
|
|
21
23
|
display.log(`Searching memories for: "${currentMessage.substring(0, 50)}${currentMessage.length > 50 ? '...' : ''}"`, { source: 'Sati' });
|
|
22
24
|
const result = await this.service.recover(currentMessage, recentText);
|
|
25
|
+
const durationMs = Date.now() - startMs;
|
|
26
|
+
AuditRepository.getInstance().insert({
|
|
27
|
+
session_id: sessionId ?? 'sati-recovery',
|
|
28
|
+
event_type: 'memory_recovery',
|
|
29
|
+
agent: 'sati',
|
|
30
|
+
duration_ms: durationMs,
|
|
31
|
+
status: 'success',
|
|
32
|
+
metadata: {
|
|
33
|
+
memories_count: result.relevant_memories.length,
|
|
34
|
+
memories: result.relevant_memories.map(m => ({ category: m.category, importance: m.importance, summary: m.summary })),
|
|
35
|
+
},
|
|
36
|
+
});
|
|
23
37
|
if (result.relevant_memories.length === 0) {
|
|
24
38
|
display.log('No relevant memories found', { source: 'Sati' });
|
|
25
39
|
return null;
|
|
@@ -36,6 +50,13 @@ export class SatiMemoryMiddleware {
|
|
|
36
50
|
`);
|
|
37
51
|
}
|
|
38
52
|
catch (error) {
|
|
53
|
+
AuditRepository.getInstance().insert({
|
|
54
|
+
session_id: sessionId ?? 'sati-recovery',
|
|
55
|
+
event_type: 'memory_recovery',
|
|
56
|
+
agent: 'sati',
|
|
57
|
+
duration_ms: Date.now() - startMs,
|
|
58
|
+
status: 'error',
|
|
59
|
+
});
|
|
39
60
|
display.log(`Error in beforeAgent: ${error}`, { source: 'Sati' });
|
|
40
61
|
// Fail open: return null so execution continues without memory
|
|
41
62
|
return null;
|
|
@@ -5,6 +5,7 @@ import fs from 'fs-extra';
|
|
|
5
5
|
import { randomUUID } from 'crypto';
|
|
6
6
|
import loadVecExtension from '../sqlite-vec.js';
|
|
7
7
|
import { DisplayManager } from '../../display.js';
|
|
8
|
+
import { ConfigManager } from '../../../config/manager.js';
|
|
8
9
|
const EMBEDDING_DIM = 384;
|
|
9
10
|
export class SatiRepository {
|
|
10
11
|
db = null;
|
|
@@ -208,7 +209,7 @@ export class SatiRepository {
|
|
|
208
209
|
searchUnifiedVector(embedding, limit) {
|
|
209
210
|
if (!this.db)
|
|
210
211
|
return [];
|
|
211
|
-
const SIMILARITY_THRESHOLD = 0.
|
|
212
|
+
const SIMILARITY_THRESHOLD = ConfigManager.getInstance().getSatiConfig().similarity_threshold ?? 0.9;
|
|
212
213
|
const stmt = this.db.prepare(`
|
|
213
214
|
SELECT *
|
|
214
215
|
FROM (
|
package/dist/runtime/oracle.js
CHANGED
|
@@ -28,6 +28,8 @@ export class Oracle {
|
|
|
28
28
|
taskRepository = TaskRepository.getInstance();
|
|
29
29
|
databasePath;
|
|
30
30
|
satiMiddleware = SatiMemoryMiddleware.getInstance();
|
|
31
|
+
/** Turn counter per session — tracks how many chat() calls have occurred per session ID. */
|
|
32
|
+
satiTurnCounters = new Map();
|
|
31
33
|
constructor(config, overrides) {
|
|
32
34
|
this.config = config || ConfigManager.getInstance().get();
|
|
33
35
|
this.databasePath = overrides?.databasePath;
|
|
@@ -212,14 +214,25 @@ You are ${this.config.agent.name}, ${this.config.agent.personality}, the Oracle.
|
|
|
212
214
|
|
|
213
215
|
You are an orchestrator and task router.
|
|
214
216
|
|
|
215
|
-
|
|
216
|
-
(today, tomorrow, this week, next month, in 3 days, etc),
|
|
217
|
-
you **MUST** call the tool "time_verifier" before answering or call another tool **ALWAYS**.
|
|
217
|
+
## Date & Time Resolution — MANDATORY
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
You **MUST** call "time_verifier" before answering or delegating ANY request that depends on the current date or time.
|
|
220
|
+
This includes — but is not limited to — **two categories**:
|
|
220
221
|
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
**Category A — Explicit temporal expressions** (pass the expression itself as 'text'):
|
|
223
|
+
- Examples: "today", "tomorrow", "next week", "in 3 days", "this Friday", "at 20h"
|
|
224
|
+
- PT: "hoje", "amanhã", "próxima semana", "em 3 dias", "na sexta"
|
|
225
|
+
- Pass: '{ text: "<the expression>" }' → get resolved date → include it in the search/delegation
|
|
226
|
+
|
|
227
|
+
**Category B — Implicit temporal intent** (pass "hoje" as 'text' to anchor the search to now):
|
|
228
|
+
- "próximo jogo do Flamengo" → next scheduled event AFTER today
|
|
229
|
+
- "próximo episódio de X" → upcoming release AFTER today
|
|
230
|
+
- "latest version of Y", "resultado mais recente", "quem está liderando agora"
|
|
231
|
+
- Any query whose answer changes depending on what day it is today
|
|
232
|
+
- Pass: '{ text: "hoje" }' → get today's resolved date → include it in the search/delegation
|
|
233
|
+
|
|
234
|
+
**NEVER assume or invent a date. NEVER guess "today is [date]".**
|
|
235
|
+
Always call time_verifier first, then use the resolved date in your tool call or delegation prompt.
|
|
223
236
|
|
|
224
237
|
Rules:
|
|
225
238
|
1. For conversation-only requests (greetings, conceptual explanation, memory follow-up, statements of fact, sharing personal information), answer directly. DO NOT create tasks or delegate for simple statements like "I have two cats" or "My name is John". Sati will automatically memorize facts in the background ( **ALWAYS** use SATI Memories to review or retrieve these facts if needed).
|
|
@@ -326,10 +339,14 @@ ${SmithRegistry.getInstance().getSystemPromptSection()}
|
|
|
326
339
|
// Load existing history from database in reverse order (most recent first)
|
|
327
340
|
let previousMessages = await this.history.getMessages();
|
|
328
341
|
previousMessages = previousMessages.reverse();
|
|
342
|
+
// Propagate current session to Apoc so its token usage lands in the right session
|
|
343
|
+
const currentSessionId = (this.history instanceof SQLiteChatMessageHistory)
|
|
344
|
+
? this.history.currentSessionId
|
|
345
|
+
: undefined;
|
|
329
346
|
// Sati Middleware: Retrieval
|
|
330
347
|
let memoryMessage = null;
|
|
331
348
|
try {
|
|
332
|
-
memoryMessage = await this.satiMiddleware.beforeAgent(message, previousMessages);
|
|
349
|
+
memoryMessage = await this.satiMiddleware.beforeAgent(message, previousMessages, currentSessionId);
|
|
333
350
|
if (memoryMessage) {
|
|
334
351
|
this.display.log('Sati memory retrieved.', { source: 'Sati' });
|
|
335
352
|
}
|
|
@@ -354,10 +371,6 @@ Use it to inform your response and tool selection (if needed), but do not assume
|
|
|
354
371
|
}
|
|
355
372
|
messages.push(...previousMessages);
|
|
356
373
|
messages.push(userMessage);
|
|
357
|
-
// Propagate current session to Apoc so its token usage lands in the right session
|
|
358
|
-
const currentSessionId = (this.history instanceof SQLiteChatMessageHistory)
|
|
359
|
-
? this.history.currentSessionId
|
|
360
|
-
: undefined;
|
|
361
374
|
Apoc.setSessionId(currentSessionId);
|
|
362
375
|
Neo.setSessionId(currentSessionId);
|
|
363
376
|
Trinity.setSessionId(currentSessionId);
|
|
@@ -491,8 +504,19 @@ Use it to inform your response and tool selection (if needed), but do not assume
|
|
|
491
504
|
this.display.log('Response generated.', { source: 'Oracle' });
|
|
492
505
|
// Sati Middleware: skip memory evaluation for delegation-only acknowledgements.
|
|
493
506
|
if (!delegatedThisTurn && !blockedSyntheticDelegationAck) {
|
|
494
|
-
|
|
495
|
-
|
|
507
|
+
const sessionKey = currentSessionId ?? 'default';
|
|
508
|
+
const turnCount = (this.satiTurnCounters.get(sessionKey) ?? 0) + 1;
|
|
509
|
+
this.satiTurnCounters.set(sessionKey, turnCount);
|
|
510
|
+
const satiCfg = ConfigManager.getInstance().getSatiConfig();
|
|
511
|
+
const evalInterval = satiCfg.evaluation_interval ?? 1;
|
|
512
|
+
const contextWindow = this.config.llm?.context_window ?? this.config.memory?.limit ?? 100;
|
|
513
|
+
const effectiveInterval = Math.min(evalInterval, contextWindow);
|
|
514
|
+
const shouldEval = turnCount % effectiveInterval === 0;
|
|
515
|
+
if (shouldEval) {
|
|
516
|
+
this.display.log(`Sati eval triggered (turn ${turnCount}, effective interval ${effectiveInterval})`, { source: 'Sati', level: 'debug' });
|
|
517
|
+
this.satiMiddleware.afterAgent(responseContent, [...previousMessages, userMessage], currentSessionId)
|
|
518
|
+
.catch((e) => this.display.log(`Sati memory evaluation failed: ${e.message}`, { source: 'Sati' }));
|
|
519
|
+
}
|
|
496
520
|
}
|
|
497
521
|
return responseContent;
|
|
498
522
|
}
|
|
@@ -115,17 +115,24 @@ export const timeVerifierTool = tool(async ({ text, timezone }) => {
|
|
|
115
115
|
}, {
|
|
116
116
|
name: "time_verifier",
|
|
117
117
|
description: `
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Use this tool whenever the user mentions words like:
|
|
121
|
-
today, tomorrow, yesterday, this week, next week,
|
|
122
|
-
hoje, amanhã, ontem, próxima semana,
|
|
123
|
-
hoy, mañana, ayer, la próxima semana, etc.
|
|
118
|
+
Resolves temporal expressions into concrete ISO dates anchored to the current date and timezone.
|
|
119
|
+
Use this tool in TWO scenarios:
|
|
124
120
|
|
|
125
|
-
|
|
121
|
+
1. EXPLICIT temporal expression — pass the expression itself as "text":
|
|
122
|
+
- "tomorrow at 9am", "next Friday", "in 3 days", "this week"
|
|
123
|
+
- "amanhã às 9h", "próxima sexta", "em 3 dias", "esta semana"
|
|
124
|
+
|
|
125
|
+
2. IMPLICIT temporal query — the user asks about something whose answer depends on today's date,
|
|
126
|
+
but without stating a date explicitly. Pass "hoje" as text to resolve today's date:
|
|
127
|
+
- "próximo jogo do Flamengo" → you need today's date to search for games AFTER today
|
|
128
|
+
- "próximo episódio de X", "latest release", "resultado mais recente"
|
|
129
|
+
- Any "next", "upcoming", "latest", "current", "recent", "agora" query about real-world events
|
|
130
|
+
|
|
131
|
+
After calling this tool, incorporate the resolved ISO date into your search query or delegation prompt
|
|
132
|
+
so the agent knows the time context (e.g. "find Flamengo games after 2026-03-01").
|
|
126
133
|
`,
|
|
127
134
|
schema: z.object({
|
|
128
|
-
text: z.string().describe("
|
|
135
|
+
text: z.string().describe('Temporal expression to resolve (e.g. "amanhã", "next Friday") — OR pass "hoje" to get today\'s date when the query has implicit temporal intent'),
|
|
129
136
|
timezone: z.string().optional().describe("Optional timezone override. Defaults to system configuration."),
|
|
130
137
|
}),
|
|
131
138
|
});
|
package/dist/types/config.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{j as e,A as $,m as F}from"./vendor-motion-C3CZ8ZlO.js";import{c as L,r as o}from"./vendor-react-DikRIOlj.js";import{r as B,s as
|
|
1
|
+
import{j as e,A as $,m as F}from"./vendor-motion-C3CZ8ZlO.js";import{c as L,r as o}from"./vendor-react-DikRIOlj.js";import{r as B,s as D,t as K,u as G,X as U,v as q,w as H,x as X,y as V,z as Q,p as I,E as P,q as R,F as _,l as Y,M as Z,G as M,U as ee,I as re}from"./vendor-icons-DLvvGkeN.js";import{g as te,i as ae,c as w}from"./index-CQIUjucB.js";import{M as se,r as ie}from"./vendor-markdown-BN_Np5Ta.js";import{C as ne}from"./ConfirmationModal-Bx-GtD9B.js";import"./vendor-utils-D4NnWbOU.js";function oe(r){const s=Date.now()-r;return s<6e4?"just now":s<36e5?`${Math.floor(s/6e4)}m ago`:s<864e5?`${Math.floor(s/36e5)}h ago`:s<6048e5?`${Math.floor(s/864e5)}d ago`:new Date(r).toLocaleDateString()}const le=({sessions:r,activeSessionId:s,onSelectSession:a,onCreateSession:i,onArchiveSession:m,onDeleteSession:l,onRenameSession:d,isOpen:p,toggleSidebar:h})=>{const g=L(),[f,u]=o.useState(null),[n,x]=o.useState(""),k=o.useRef(null);o.useEffect(()=>{f&&k.current&&k.current.focus()},[f]);const v=(c,N)=>{c.stopPropagation(),u(N.id),x(N.title||"Untitled Session")},j=c=>{c?.stopPropagation(),f&&n.trim()&&(d(f,n.trim()),u(null))},z=c=>{c?.stopPropagation(),u(null)},E=c=>{c.key==="Enter"?j():c.key==="Escape"&&z()};return p?e.jsxs("div",{className:"w-72 bg-white dark:bg-black border-r border-gray-300 dark:border-matrix-primary flex flex-col h-full shrink-0 transition-colors duration-300",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-300 dark:border-matrix-primary shrink-0",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-matrix-highlight",children:"Sessions"}),e.jsx("button",{onClick:h,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-400 dark:text-matrix-secondary/60 transition-colors",title:"Collapse sidebar",children:e.jsx(K,{size:16})})]}),e.jsx("div",{className:"px-3 py-2.5 shrink-0",children:e.jsxs("button",{onClick:i,className:"w-full flex items-center justify-center gap-2 bg-azure-primary text-white dark:bg-matrix-highlight dark:text-black py-2 px-4 rounded-xl hover:bg-azure-secondary dark:hover:bg-matrix-secondary transition-colors text-sm font-medium shadow-sm",children:[e.jsx(D,{size:16}),"New Chat"]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-2 pb-3 space-y-0.5",children:[r.length===0&&e.jsx("div",{className:"text-center text-gray-400 dark:text-matrix-secondary/40 mt-12 text-sm px-4",children:"No sessions yet. Start a new chat!"}),r.map(c=>{const N=s===c.id,S=f===c.id;return e.jsxs("div",{onClick:()=>!S&&a(c.id),className:`
|
|
2
2
|
group relative flex items-center gap-2 px-3 py-2.5 rounded-xl cursor-pointer transition-all
|
|
3
3
|
${N?"bg-azure-primary/10 dark:bg-matrix-primary/15 text-azure-primary dark:text-matrix-highlight":"hover:bg-gray-100 dark:hover:bg-matrix-primary/10 text-gray-700 dark:text-matrix-secondary"}
|
|
4
|
-
`,children:[e.jsx("div",{className:"flex-1 min-w-0",children:S?e.jsx("div",{onClick:t=>t.stopPropagation(),children:e.jsx("input",{ref:k,type:"text",value:n,onChange:t=>x(t.target.value),onKeyDown:E,className:"w-full text-sm px-1.5 py-0.5 bg-white dark:bg-black border border-azure-primary dark:border-matrix-highlight rounded-lg focus:outline-none dark:text-matrix-highlight"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-medium truncate leading-snug",children:c.title||"Untitled Session"}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-matrix-secondary/50 mt-0.5",children:ne(c.started_at)})]})}),e.jsx("div",{className:`flex items-center gap-0.5 shrink-0 transition-opacity ${N||S?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:t=>t.stopPropagation(),children:S?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:j,className:"p-1.5 rounded-lg text-emerald-600 hover:bg-emerald-50 dark:text-emerald-400 dark:hover:bg-emerald-900/20 transition-colors",title:"Save",children:e.jsx(G,{size:13})}),e.jsx("button",{onClick:z,className:"p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20 transition-colors",title:"Cancel",children:e.jsx(U,{size:13})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:t=>v(t,c),className:"p-1.5 rounded-lg text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:text-matrix-secondary/50 dark:hover:text-blue-400 dark:hover:bg-blue-900/20 transition-colors",title:"Rename",children:e.jsx(q,{size:13})}),e.jsx("button",{onClick:()=>p(`/sessions/${c.id}/audit`),className:"p-1.5 rounded-lg text-gray-400 hover:text-violet-500 hover:bg-violet-50 dark:text-matrix-secondary/50 dark:hover:text-violet-400 dark:hover:bg-violet-900/20 transition-colors",title:"Audit",children:e.jsx(H,{size:13})}),e.jsx("button",{onClick:()=>m(c.id),className:"p-1.5 rounded-lg text-gray-400 hover:text-amber-500 hover:bg-amber-50 dark:text-matrix-secondary/50 dark:hover:text-amber-400 dark:hover:bg-amber-900/20 transition-colors",title:"Archive",children:e.jsx(X,{size:13})}),e.jsx("button",{onClick:()=>l(c.id),className:"p-1.5 rounded-lg text-gray-400 hover:text-red-500 hover:bg-red-50 dark:text-matrix-secondary/50 dark:hover:text-red-400 dark:hover:bg-red-900/20 transition-colors",title:"Delete",children:e.jsx(V,{size:13})})]})})]},c.id)})]})]}):e.jsxs("div",{className:"w-14 bg-white dark:bg-black border-r border-gray-300 dark:border-matrix-primary flex flex-col items-center py-3 gap-3 shrink-0 transition-colors duration-300",children:[e.jsx("button",{onClick:h,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-400 dark:text-matrix-secondary/60 transition-colors",title:"Expand sidebar",children:e.jsx(B,{size:18})}),e.jsx("div",{className:"w-8 h-px bg-gray-200 dark:bg-matrix-primary/20"}),e.jsx("button",{onClick:i,className:"p-2.5 bg-azure-primary text-white dark:bg-matrix-highlight dark:text-black rounded-xl hover:bg-azure-secondary dark:hover:bg-matrix-secondary shadow-sm transition-colors",title:"New chat",children:e.jsx(_,{size:18})})]})};function A(r){if(r==null)return"";if(typeof r=="string")try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}try{return JSON.stringify(r,null,2)}catch{return String(r)}}const le=({group:r})=>{const[s,a]=o.useState(!1),i=r.result!==null,m=r.result?.content??"",l=m.startsWith("Error")||m.startsWith("❌");return e.jsxs("div",{className:"rounded-lg border border-gray-300 dark:border-matrix-primary/70 bg-white dark:bg-black overflow-hidden text-sm mb-1",children:[e.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors",children:[e.jsx(Q,{size:12,className:"text-amber-500 dark:text-amber-400/80 flex-shrink-0"}),e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-600 dark:text-matrix-secondary/80 truncate",children:r.call.name}),i?l?e.jsx(I,{size:12,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(P,{size:12,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):e.jsx(R,{size:12,className:"text-gray-400 animate-spin flex-shrink-0"}),e.jsx(D,{size:12,className:`text-gray-400 dark:text-matrix-secondary/40 flex-shrink-0 transition-transform duration-200 ${s?"rotate-180":""}`})]}),e.jsx($,{initial:!1,children:s&&e.jsx(F.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"px-3 pb-2.5 pt-1 border-t border-gray-100 dark:border-matrix-primary/20 space-y-2",children:[Object.keys(r.call.args??{}).length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"args"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-gray-50 dark:bg-zinc-900 rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-36 overflow-y-auto",children:A(r.call.args)})]}),i&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"result"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-gray-50 dark:bg-zinc-900 rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-44 overflow-y-auto",children:A(m)})]})]})})})]})},de={apoc_delegate:{label:"Apoc",emoji:"🧑🔬",colorClass:"text-amber-600 dark:text-amber-400",bgClass:"bg-amber-50 dark:bg-amber-900/10"},neo_delegate:{label:"Neo",emoji:"🥷",colorClass:"text-violet-600 dark:text-violet-400",bgClass:"bg-violet-50 dark:bg-violet-900/10"},trinity_delegate:{label:"Trinity",emoji:"👩💻",colorClass:"text-teal-600 dark:text-teal-400",bgClass:"bg-teal-50 dark:bg-teal-900/10"},smith_delegate:{label:"Smith",emoji:"🕶️",colorClass:"text-gray-500 dark:text-gray-400",bgClass:"bg-gray-50 dark:bg-zinc-900"}};function O(r){return r?.task??r?.prompt??""}function ce(r){if(typeof r!="string")return String(r);try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}}const xe=({group:r})=>{const[s,a]=o.useState(!1),i=de[r.call.name]??{label:r.call.name,emoji:"🤖",colorClass:"text-gray-500",bgClass:"bg-gray-50 dark:bg-zinc-900"},m=r.result!==null,l=r.result?.content??"",d=l.startsWith("❌")||l.toLowerCase().startsWith("error"),g=O(r.call.args).slice(0,100),h=r.call.args?.smith??null;return e.jsxs("div",{className:`rounded-lg border border-gray-300 dark:border-matrix-primary/70 overflow-hidden text-sm mb-1 ${i.bgClass}`,children:[e.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:brightness-95 dark:hover:brightness-110 transition-all",children:[e.jsx("span",{className:"text-base flex-shrink-0 leading-none",children:i.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:`text-xs font-semibold ${i.colorClass}`,children:[i.label,h?` · ${h}`:""]}),g&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-matrix-secondary/60 truncate mt-0.5",children:g})]}),m?d?e.jsx(I,{size:14,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(P,{size:14,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):e.jsx(R,{size:14,className:"text-gray-400 animate-spin flex-shrink-0"}),e.jsx(D,{size:13,className:`text-gray-400 dark:text-matrix-secondary/40 flex-shrink-0 transition-transform duration-200 ${s?"rotate-180":""}`})]}),e.jsx($,{initial:!1,children:s&&e.jsx(F.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:"easeInOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"px-3 pb-2.5 pt-1 border-t border-gray-200 dark:border-matrix-primary/20 space-y-2",children:[O(r.call.args)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"task"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-matrix-secondary/80 bg-white dark:bg-black rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 whitespace-pre-wrap",children:O(r.call.args)})]}),m&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"result"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-white dark:bg-black rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-56 overflow-y-auto",children:ce(l)})]})]})})})]})};function me(r){return r==null||r===0?null:r<1e3?`${r}ms`:`${(r/1e3).toFixed(1)}s`}function T(r){return r>=1e3?`${(r/1e3).toFixed(1)}k`:String(r)}const he=({message:r})=>{const s=r.usage_metadata,a=s?.input_tokens??s?.prompt_tokens??0,i=s?.output_tokens??s?.completion_tokens??0,m=a>0||i>0,l=me(r.duration_ms),d=r.model;if(!m&&!l&&!d)return null;const g=d?(d.includes(":")?d.split(":").pop():d)?.split("-").slice(0,4).join("-")??d:null;return e.jsxs("div",{className:"mt-2 pt-1.5 border-t border-gray-100 dark:border-matrix-primary/20 flex flex-wrap items-center gap-x-3 gap-y-0.5",children:[g&&e.jsx("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40 truncate max-w-[180px]",title:d??"",children:g}),m&&e.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40",children:["↑",T(a)," ↓",T(i)]}),l&&e.jsx("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40",children:l})]})};function ge(r){try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}}function pe(r){return r.session_id?.startsWith("sati-evaluation-")===!0||r.tool_name?.toLowerCase().includes("sati")===!0}const ue=({message:r})=>{const[s,a]=o.useState(!1),i=pe(r),m=i?r.tool_name==="sati_evaluation_output"?"Sati · memory update":"Sati · analysis":r.tool_name??"tool result";return e.jsxs("details",{open:s,onToggle:l=>a(l.target.open),className:"w-full",children:[e.jsxs("summary",{className:"list-none cursor-pointer select-none flex items-center gap-2 text-xs text-gray-400 dark:text-matrix-secondary/40 hover:text-gray-500 dark:hover:text-matrix-secondary/60 transition-colors py-0.5",children:[e.jsx("div",{className:"flex-1 h-px bg-gray-200 dark:bg-matrix-primary/20"}),e.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap px-2",children:[e.jsx("span",{children:i?"🧠":"🔧"}),e.jsx("span",{children:m}),e.jsx(D,{size:11,className:`transition-transform duration-200 ${s?"rotate-180":""}`})]}),e.jsx("div",{className:"flex-1 h-px bg-gray-200 dark:bg-matrix-primary/20"})]}),s&&e.jsx("pre",{className:"mt-2 px-3 py-2.5 whitespace-pre-wrap break-all text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 border border-gray-300 dark:border-matrix-primary/60 rounded-lg bg-gray-50 dark:bg-zinc-900 max-h-48 overflow-y-auto",children:ge(r.content)})]})},ye={table:({children:r})=>e.jsx("div",{className:"my-2 overflow-x-auto rounded-lg border border-gray-200 dark:border-matrix-primary/60",children:e.jsx("table",{className:"min-w-full text-xs border-collapse",children:r})}),thead:({children:r})=>e.jsx("thead",{className:"bg-gray-100 dark:bg-zinc-900 text-gray-600 dark:text-matrix-secondary/70",children:r}),tbody:({children:r})=>e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-matrix-primary/20",children:r}),tr:({children:r})=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors",children:r}),th:({children:r})=>e.jsx("th",{className:"px-3 py-2 text-left font-semibold whitespace-nowrap border-b border-gray-200 dark:border-matrix-primary/40",children:r}),td:({children:r})=>e.jsx("td",{className:"px-3 py-2 text-gray-700 dark:text-matrix-secondary align-top",children:r})},be=({messages:r,onSendMessage:s,isLoading:a,activeSessionId:i,activeSession:m,onToggleSidebar:l})=>{const[d,g]=o.useState(""),h=o.useRef(null),p=o.useRef(null);o.useEffect(()=>{h.current?.scrollIntoView({behavior:"smooth"})},[r,a]),o.useEffect(()=>{const n=p.current;n&&(n.style.height="auto",n.style.height=n.scrollHeight+"px")},[d]);const f=()=>{!d.trim()||a||(s(d.trim()),g(""),p.current&&(p.current.style.height="auto"))},u=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),f())};return e.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white dark:bg-black overflow-hidden transition-colors duration-300",children:[l&&e.jsxs("div",{className:"md:hidden flex items-center gap-3 px-4 py-3 shrink-0 bg-white dark:bg-black border-b border-gray-300 dark:border-matrix-primary",children:[e.jsx("button",{onClick:l,className:"p-2 -ml-1 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-500 dark:text-matrix-secondary transition-colors","aria-label":"Open sessions",children:e.jsx(Y,{size:20})}),e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-matrix-highlight truncate flex-1",children:m?.title??(i?"Chat":"Morpheus")})]}),i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-4 py-5 space-y-4",children:[re(r).map(n=>{const{message:x,toolGroups:k}=n;if(x.type==="tool")return e.jsx("div",{className:"px-2 py-0.5",children:e.jsx(ue,{message:x})},n.index);const v=x.type==="human";return e.jsxs("div",{className:`flex items-end gap-2.5 ${v?"justify-end":"justify-start"}`,children:[!v&&e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-azure-primary/10 text-azure-primary dark:bg-matrix-primary/20 dark:text-matrix-highlight mb-0.5",children:e.jsx(M,{size:14})}),e.jsxs("div",{className:`
|
|
4
|
+
`,children:[e.jsx("div",{className:"flex-1 min-w-0",children:S?e.jsx("div",{onClick:t=>t.stopPropagation(),children:e.jsx("input",{ref:k,type:"text",value:n,onChange:t=>x(t.target.value),onKeyDown:E,className:"w-full text-sm px-1.5 py-0.5 bg-white dark:bg-black border border-azure-primary dark:border-matrix-highlight rounded-lg focus:outline-none dark:text-matrix-highlight"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-medium truncate leading-snug",children:c.title||"Untitled Session"}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-matrix-secondary/50 mt-0.5",children:oe(c.started_at)})]})}),e.jsx("div",{className:`flex items-center gap-0.5 shrink-0 transition-opacity ${N||S?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:t=>t.stopPropagation(),children:S?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:j,className:"p-1.5 rounded-lg text-emerald-600 hover:bg-emerald-50 dark:text-emerald-400 dark:hover:bg-emerald-900/20 transition-colors",title:"Save",children:e.jsx(G,{size:13})}),e.jsx("button",{onClick:z,className:"p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20 transition-colors",title:"Cancel",children:e.jsx(U,{size:13})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:t=>v(t,c),className:"p-1.5 rounded-lg text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:text-matrix-secondary/50 dark:hover:text-blue-400 dark:hover:bg-blue-900/20 transition-colors",title:"Rename",children:e.jsx(q,{size:13})}),e.jsx("button",{onClick:()=>g(`/sessions/${c.id}/audit`),className:"p-1.5 rounded-lg text-gray-400 hover:text-violet-500 hover:bg-violet-50 dark:text-matrix-secondary/50 dark:hover:text-violet-400 dark:hover:bg-violet-900/20 transition-colors",title:"Audit",children:e.jsx(H,{size:13})}),e.jsx("button",{onClick:()=>m(c.id),className:"p-1.5 rounded-lg text-gray-400 hover:text-amber-500 hover:bg-amber-50 dark:text-matrix-secondary/50 dark:hover:text-amber-400 dark:hover:bg-amber-900/20 transition-colors",title:"Archive",children:e.jsx(X,{size:13})}),e.jsx("button",{onClick:()=>l(c.id),className:"p-1.5 rounded-lg text-gray-400 hover:text-red-500 hover:bg-red-50 dark:text-matrix-secondary/50 dark:hover:text-red-400 dark:hover:bg-red-900/20 transition-colors",title:"Delete",children:e.jsx(V,{size:13})})]})})]},c.id)})]})]}):e.jsxs("div",{className:"w-14 bg-white dark:bg-black border-r border-gray-300 dark:border-matrix-primary flex flex-col items-center py-3 gap-3 shrink-0 transition-colors duration-300",children:[e.jsx("button",{onClick:h,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-400 dark:text-matrix-secondary/60 transition-colors",title:"Expand sidebar",children:e.jsx(B,{size:18})}),e.jsx("div",{className:"w-8 h-px bg-gray-200 dark:bg-matrix-primary/20"}),e.jsx("button",{onClick:i,className:"p-2.5 bg-azure-primary text-white dark:bg-matrix-highlight dark:text-black rounded-xl hover:bg-azure-secondary dark:hover:bg-matrix-secondary shadow-sm transition-colors",title:"New chat",children:e.jsx(D,{size:18})})]})};function A(r){if(r==null)return"";if(typeof r=="string")try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}try{return JSON.stringify(r,null,2)}catch{return String(r)}}const de=({group:r})=>{const[s,a]=o.useState(!1),i=r.result!==null,m=r.result?.content??"",l=m.startsWith("Error")||m.startsWith("❌");return e.jsxs("div",{className:"rounded-lg border border-gray-300 dark:border-matrix-primary/70 bg-white dark:bg-black overflow-hidden text-sm mb-1",children:[e.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors",children:[e.jsx(Q,{size:12,className:"text-amber-500 dark:text-amber-400/80 flex-shrink-0"}),e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-600 dark:text-matrix-secondary/80 truncate",children:r.call.name}),i?l?e.jsx(I,{size:12,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(P,{size:12,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):e.jsx(R,{size:12,className:"text-gray-400 animate-spin flex-shrink-0"}),e.jsx(_,{size:12,className:`text-gray-400 dark:text-matrix-secondary/40 flex-shrink-0 transition-transform duration-200 ${s?"rotate-180":""}`})]}),e.jsx($,{initial:!1,children:s&&e.jsx(F.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"px-3 pb-2.5 pt-1 border-t border-gray-100 dark:border-matrix-primary/20 space-y-2",children:[Object.keys(r.call.args??{}).length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"args"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-gray-50 dark:bg-zinc-900 rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-36 overflow-y-auto",children:A(r.call.args)})]}),i&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"result"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-gray-50 dark:bg-zinc-900 rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-44 overflow-y-auto",children:A(m)})]})]})})})]})},ce={apoc_delegate:{label:"Apoc",emoji:"🧑🔬",colorClass:"text-amber-600 dark:text-amber-400",bgClass:"bg-amber-50 dark:bg-amber-900/10"},neo_delegate:{label:"Neo",emoji:"🥷",colorClass:"text-violet-600 dark:text-violet-400",bgClass:"bg-violet-50 dark:bg-violet-900/10"},trinity_delegate:{label:"Trinity",emoji:"👩💻",colorClass:"text-teal-600 dark:text-teal-400",bgClass:"bg-teal-50 dark:bg-teal-900/10"},smith_delegate:{label:"Smith",emoji:"🕶️",colorClass:"text-gray-500 dark:text-gray-400",bgClass:"bg-gray-50 dark:bg-zinc-900"}};function O(r){return r?.task??r?.prompt??""}function xe(r){if(typeof r!="string")return String(r);try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}}const me=({group:r})=>{const[s,a]=o.useState(!1),i=ce[r.call.name]??{label:r.call.name,emoji:"🤖",colorClass:"text-gray-500",bgClass:"bg-gray-50 dark:bg-zinc-900"},m=r.result!==null,l=r.result?.content??"",d=l.startsWith("❌")||l.toLowerCase().startsWith("error"),p=O(r.call.args).slice(0,100),h=r.call.args?.smith??null;return e.jsxs("div",{className:`rounded-lg border border-gray-300 dark:border-matrix-primary/70 overflow-hidden text-sm mb-1 ${i.bgClass}`,children:[e.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:brightness-95 dark:hover:brightness-110 transition-all",children:[e.jsx("span",{className:"text-base flex-shrink-0 leading-none",children:i.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:`text-xs font-semibold ${i.colorClass}`,children:[i.label,h?` · ${h}`:""]}),p&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-matrix-secondary/60 truncate mt-0.5",children:p})]}),m?d?e.jsx(I,{size:14,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(P,{size:14,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):e.jsx(R,{size:14,className:"text-gray-400 animate-spin flex-shrink-0"}),e.jsx(_,{size:13,className:`text-gray-400 dark:text-matrix-secondary/40 flex-shrink-0 transition-transform duration-200 ${s?"rotate-180":""}`})]}),e.jsx($,{initial:!1,children:s&&e.jsx(F.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:"easeInOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"px-3 pb-2.5 pt-1 border-t border-gray-200 dark:border-matrix-primary/20 space-y-2",children:[O(r.call.args)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"task"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-matrix-secondary/80 bg-white dark:bg-black rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 whitespace-pre-wrap",children:O(r.call.args)})]}),m&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"result"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-white dark:bg-black rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-56 overflow-y-auto",children:xe(l)})]})]})})})]})};function he(r){return r==null||r===0?null:r<1e3?`${r}ms`:`${(r/1e3).toFixed(1)}s`}function T(r){return r>=1e3?`${(r/1e3).toFixed(1)}k`:String(r)}const pe=({message:r})=>{const s=r.usage_metadata,a=s?.input_tokens??s?.prompt_tokens??0,i=s?.output_tokens??s?.completion_tokens??0,m=a>0||i>0,l=he(r.duration_ms),d=r.model,p=r.sati_memories_count??null;if(!m&&!l&&!d&&p==null)return null;const h=d?(d.includes(":")?d.split(":").pop():d)?.split("-").slice(0,4).join("-")??d:null;return e.jsxs("div",{className:"mt-2 pt-1.5 border-t border-gray-100 dark:border-matrix-primary/20 flex flex-wrap items-center gap-x-3 gap-y-0.5",children:[h&&e.jsx("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40 truncate max-w-[180px]",title:d??"",children:h}),m&&e.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40",children:["↑",T(a)," ↓",T(i)]}),l&&e.jsx("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40",children:l}),p!=null&&p>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-mono text-purple-400 dark:text-purple-400/70",children:[e.jsx(Y,{size:10}),p]})]})};function ge(r){try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}}function ue(r){return r.session_id?.startsWith("sati-evaluation-")===!0||r.tool_name?.toLowerCase().includes("sati")===!0}const ye=({message:r})=>{const[s,a]=o.useState(!1),i=ue(r),m=i?r.tool_name==="sati_evaluation_output"?"Sati · memory update":"Sati · analysis":r.tool_name??"tool result";return e.jsxs("details",{open:s,onToggle:l=>a(l.target.open),className:"w-full",children:[e.jsxs("summary",{className:"list-none cursor-pointer select-none flex items-center gap-2 text-xs text-gray-400 dark:text-matrix-secondary/40 hover:text-gray-500 dark:hover:text-matrix-secondary/60 transition-colors py-0.5",children:[e.jsx("div",{className:"flex-1 h-px bg-gray-200 dark:bg-matrix-primary/20"}),e.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap px-2",children:[e.jsx("span",{children:i?"🧠":"🔧"}),e.jsx("span",{children:m}),e.jsx(_,{size:11,className:`transition-transform duration-200 ${s?"rotate-180":""}`})]}),e.jsx("div",{className:"flex-1 h-px bg-gray-200 dark:bg-matrix-primary/20"})]}),s&&e.jsx("pre",{className:"mt-2 px-3 py-2.5 whitespace-pre-wrap break-all text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 border border-gray-300 dark:border-matrix-primary/60 rounded-lg bg-gray-50 dark:bg-zinc-900 max-h-48 overflow-y-auto",children:ge(r.content)})]})},be={table:({children:r})=>e.jsx("div",{className:"my-2 overflow-x-auto rounded-lg border border-gray-200 dark:border-matrix-primary/60",children:e.jsx("table",{className:"min-w-full text-xs border-collapse",children:r})}),thead:({children:r})=>e.jsx("thead",{className:"bg-gray-100 dark:bg-zinc-900 text-gray-600 dark:text-matrix-secondary/70",children:r}),tbody:({children:r})=>e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-matrix-primary/20",children:r}),tr:({children:r})=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors",children:r}),th:({children:r})=>e.jsx("th",{className:"px-3 py-2 text-left font-semibold whitespace-nowrap border-b border-gray-200 dark:border-matrix-primary/40",children:r}),td:({children:r})=>e.jsx("td",{className:"px-3 py-2 text-gray-700 dark:text-matrix-secondary align-top",children:r})},fe=({messages:r,onSendMessage:s,isLoading:a,activeSessionId:i,activeSession:m,onToggleSidebar:l})=>{const[d,p]=o.useState(""),h=o.useRef(null),g=o.useRef(null);o.useEffect(()=>{h.current?.scrollIntoView({behavior:"smooth"})},[r,a]),o.useEffect(()=>{const n=g.current;n&&(n.style.height="auto",n.style.height=n.scrollHeight+"px")},[d]);const f=()=>{!d.trim()||a||(s(d.trim()),p(""),g.current&&(g.current.style.height="auto"))},u=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),f())};return e.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white dark:bg-black overflow-hidden transition-colors duration-300",children:[l&&e.jsxs("div",{className:"md:hidden flex items-center gap-3 px-4 py-3 shrink-0 bg-white dark:bg-black border-b border-gray-300 dark:border-matrix-primary",children:[e.jsx("button",{onClick:l,className:"p-2 -ml-1 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-500 dark:text-matrix-secondary transition-colors","aria-label":"Open sessions",children:e.jsx(Z,{size:20})}),e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-matrix-highlight truncate flex-1",children:m?.title??(i?"Chat":"Morpheus")})]}),i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-4 py-5 space-y-4",children:[te(r).map(n=>{const{message:x,toolGroups:k}=n;if(x.type==="tool")return e.jsx("div",{className:"px-2 py-0.5",children:e.jsx(ye,{message:x})},n.index);const v=x.type==="human";return e.jsxs("div",{className:`flex items-end gap-2.5 ${v?"justify-end":"justify-start"}`,children:[!v&&e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-azure-primary/10 text-azure-primary dark:bg-matrix-primary/20 dark:text-matrix-highlight mb-0.5",children:e.jsx(M,{size:14})}),e.jsxs("div",{className:`
|
|
5
5
|
max-w-[85%] md:max-w-[72%] min-w-0
|
|
6
|
-
${v?"bg-azure-primary text-white dark:bg-matrix-primary
|
|
7
|
-
`,children:[v&&e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words",children:x.content}),x.type==="ai"&&e.jsxs(e.Fragment,{children:[k&&k.length>0&&e.jsx("div",{className:"mb-2.5 space-y-1",children:k.map(j=>
|
|
6
|
+
${v?"bg-azure-primary text-white dark:text-white/80 dark:bg-matrix-primary rounded-2xl rounded-br-sm px-4 py-2.5":"bg-gray-50 dark:bg-zinc-900 border border-gray-300 dark:border-matrix-primary/60 text-gray-800 dark:text-matrix-secondary rounded-2xl rounded-bl-sm px-4 py-3"}
|
|
7
|
+
`,children:[v&&e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words",children:x.content}),x.type==="ai"&&e.jsxs(e.Fragment,{children:[k&&k.length>0&&e.jsx("div",{className:"mb-2.5 space-y-1",children:k.map(j=>ae(j.call.name)?e.jsx(me,{group:j},j.call.id):e.jsx(de,{group:j},j.call.id))}),x.content&&e.jsx("div",{className:`
|
|
8
8
|
prose prose-sm dark:prose-invert max-w-none
|
|
9
9
|
prose-p:my-1.5 prose-p:leading-relaxed
|
|
10
10
|
prose-headings:my-2 prose-headings:font-semibold
|
|
@@ -19,7 +19,7 @@ import{j as e,A as $,m as F}from"./vendor-motion-C3CZ8ZlO.js";import{c as L,r as
|
|
|
19
19
|
dark:prose-li:text-matrix-secondary
|
|
20
20
|
dark:prose-code:text-matrix-highlight dark:prose-code:bg-black/60
|
|
21
21
|
dark:prose-pre:bg-black dark:prose-pre:border dark:prose-pre:border-matrix-primary/30
|
|
22
|
-
`,children:e.jsx(
|
|
22
|
+
`,children:e.jsx(se,{remarkPlugins:[ie],components:be,children:x.content})}),e.jsx(pe,{message:x})]})]}),v&&e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-gray-200 dark:bg-matrix-primary/30 text-gray-500 dark:text-matrix-secondary mb-0.5",children:e.jsx(ee,{size:14})})]},n.index)}),a&&e.jsxs("div",{className:"flex items-end gap-2.5 justify-start",children:[e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-azure-primary/10 text-azure-primary dark:bg-matrix-primary/20 dark:text-matrix-highlight mb-0.5",children:e.jsx(M,{size:14})}),e.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 border border-gray-300 dark:border-matrix-primary/60 rounded-2xl rounded-bl-sm px-4 py-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-azure-primary dark:bg-matrix-highlight animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-azure-primary dark:bg-matrix-highlight animate-bounce",style:{animationDelay:"160ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-azure-primary dark:bg-matrix-highlight animate-bounce",style:{animationDelay:"320ms"}})]})]}),e.jsx("div",{ref:h})]}),e.jsxs("div",{className:"shrink-0 px-4 pt-3 pb-4 bg-white dark:bg-black border-t border-gray-300 dark:border-matrix-primary",children:[e.jsxs("form",{onSubmit:n=>{n.preventDefault(),f()},className:"max-w-3xl mx-auto flex items-end gap-2",children:[e.jsx("textarea",{ref:g,value:d,onChange:n=>p(n.target.value),onKeyDown:u,placeholder:"Message Morpheus…",rows:1,disabled:a,className:`
|
|
23
23
|
flex-1 resize-none max-h-40 overflow-y-auto
|
|
24
24
|
bg-gray-100 dark:bg-zinc-900
|
|
25
25
|
border border-gray-300 dark:border-matrix-primary/60
|
|
@@ -30,9 +30,9 @@ import{j as e,A as $,m as F}from"./vendor-motion-C3CZ8ZlO.js";import{c as L,r as
|
|
|
30
30
|
focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-transparent
|
|
31
31
|
disabled:opacity-50
|
|
32
32
|
transition-all duration-200
|
|
33
|
-
`}),e.jsx("button",{type:"submit",disabled:!d.trim()||a,className:"flex-shrink-0 p-3 rounded-xl bg-azure-primary text-white dark:bg-matrix-secondary dark:text-black hover:bg-azure-secondary dark:hover:bg-matrix-highlight disabled:opacity-40 disabled:cursor-not-allowed transition-colors shadow-sm",children:e.jsx(
|
|
33
|
+
`}),e.jsx("button",{type:"submit",disabled:!d.trim()||a,className:"flex-shrink-0 p-3 rounded-xl bg-azure-primary text-white dark:bg-matrix-secondary dark:text-black hover:bg-azure-secondary dark:hover:bg-matrix-highlight disabled:opacity-40 disabled:cursor-not-allowed transition-colors shadow-sm",children:e.jsx(re,{size:18})})]}),e.jsx("p",{className:"mt-1.5 text-center text-[11px] text-gray-300 dark:text-matrix-secondary/25 select-none",children:"Enter to send · Shift+Enter for newline"})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-5 p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-azure-primary/10 dark:bg-matrix-primary/10 flex items-center justify-center",children:e.jsx(M,{size:30,className:"text-azure-primary/60 dark:text-matrix-highlight/50"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-700 dark:text-matrix-highlight",children:"Morpheus is ready"}),e.jsx("p",{className:"text-sm text-gray-400 dark:text-matrix-secondary/60 max-w-[240px] leading-relaxed",children:"Select a session from the sidebar or start a new chat."})]})]})]})},ze=()=>{const[r,s]=o.useState([]),[a,i]=o.useState(null),[m,l]=o.useState([]),[d,p]=o.useState(!1),[h,g]=o.useState(()=>typeof window<"u"?window.innerWidth>=768:!0),f=o.useRef(!1);o.useEffect(()=>{f.current=d},[d]),o.useEffect(()=>{if(!a)return;const t=setInterval(async()=>{if(!f.current)try{const b=(await w.getMessages(a)).filter(C=>C.type!=="system");l(C=>{if(b.length!==C.length)return b;const J=b.at(-1)?.created_at??0,W=C.at(-1)?.created_at??0;return J>W?b:C})}catch{}},3e3);return()=>clearInterval(t)},[a]);const[u,n]=o.useState({isOpen:!1,title:"",description:"",onConfirm:()=>{}}),x=async()=>{try{const t=await w.getSessions();s(t)}catch(t){console.error("Failed to load sessions:",t)}};o.useEffect(()=>{x()},[]),o.useEffect(()=>{a?(k(a),sessionStorage.setItem("morpheus.chat.uiSessionId",a)):l([])},[a]);const k=async t=>{try{const y=await w.getMessages(t);l(y.filter(b=>b.type!=="system"))}catch(y){console.error("Failed to load messages:",y)}},v=async()=>{try{const t=await w.createSession();await x(),i(t.id),window.innerWidth<768&&g(!1)}catch(t){console.error("Failed to create session:",t)}},j=t=>{i(t),window.innerWidth<768&&g(!1)},z=async t=>{if(!a)return;const y={type:"human",content:t};l(b=>[...b,y]),p(!0);try{await w.sendMessage(a,t),await k(a),await x()}catch(b){console.error("Failed to send message:",b)}finally{p(!1)}},E=t=>{n({isOpen:!0,title:"Archive Session",description:"Are you sure you want to archive this session? It will be moved to the archives.",confirmJson:"Archive",onConfirm:async()=>{try{await w.archiveSession(t),a===t&&i(null),await x()}catch(y){console.error("Failed to archive session:",y)}}})},c=t=>{n({isOpen:!0,title:"Delete Session",description:"Are you sure you want to DELETE this session? This action cannot be undone.",confirmJson:"Delete",variant:"destructive",onConfirm:async()=>{try{await w.deleteSession(t),a===t&&i(null),await x()}catch(y){console.error("Failed to delete session:",y)}}})},N=async(t,y)=>{try{await w.renameSession(t,y),await x()}catch(b){console.error("Failed to rename session:",b)}},S=r.find(t=>t.id===a)??null;return e.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-white dark:bg-black relative",children:[h&&e.jsx("div",{className:"fixed inset-0 bg-black/40 z-20 md:hidden",onClick:()=>g(!1)}),e.jsx("div",{className:`
|
|
34
34
|
fixed top-16 bottom-0 left-0 z-40 flex
|
|
35
35
|
md:relative md:inset-auto md:z-auto md:translate-x-0
|
|
36
36
|
transition-transform duration-300 ease-out
|
|
37
37
|
${h?"translate-x-0":"-translate-x-full"}
|
|
38
|
-
`,children:e.jsx(
|
|
38
|
+
`,children:e.jsx(le,{sessions:r,activeSessionId:a,onSelectSession:j,onCreateSession:v,onArchiveSession:E,onDeleteSession:c,onRenameSession:N,isOpen:h,toggleSidebar:()=>g(!h)})}),e.jsx("div",{className:"flex-1 flex flex-col h-full overflow-hidden min-w-0",children:e.jsx(fe,{messages:m,onSendMessage:z,isLoading:d,activeSessionId:a,activeSession:S,onToggleSidebar:()=>g(!h)})}),e.jsx(ne,{isOpen:u.isOpen,onClose:()=>n(t=>({...t,isOpen:!1})),onConfirm:u.onConfirm,title:u.title,description:u.description,confirmJson:u.confirmJson,variant:u.variant})]})};export{ze as ChatPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as d}from"./vendor-react-DikRIOlj.js";import{a as P,b as I,c as g,u as O}from"./chronos-BVRpP__j.js";import{D as R}from"./DeleteConfirmationModal-B0nDocEK.js";import{ac as J,ad as M,ae as U,af as B,ag as H,y as W,h as T,X as $,a3 as q}from"./vendor-icons-DLvvGkeN.js";import{m as f}from"./vendor-utils-D4NnWbOU.js";import{T as C,S}from"./SelectInput-KVLsnfra.js";import"./index-CpVvCthh.js";const F={running:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",success:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",failed:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",timeout:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"};function Y({jobId:s}){const{data:i,isLoading:m}=P(s,50);return m?e.jsx("div",{className:"p-4 dark:bg-zinc-900 rounded text-sm dark:text-matrix-secondary animate-pulse",children:"Loading history…"}):!i||i.length===0?e.jsx("div",{className:"p-4 dark:bg-zinc-900 rounded text-sm dark:text-matrix-secondary italic",children:"No executions yet."}):e.jsx("div",{className:"rounded border border-azure-border dark:border-matrix-primary dark:bg-zinc-900 overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Triggered At"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Completed At"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Status"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Error"})]})}),e.jsx("tbody",{children:i.map(r=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 last:border-0",children:[e.jsx("td",{className:"px-3 py-2 dark:text-matrix-secondary",children:new Date(r.triggered_at).toLocaleString()}),e.jsx("td",{className:"px-3 py-2 dark:text-matrix-secondary",children:r.completed_at?new Date(r.completed_at).toLocaleString():"—"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold uppercase ${F[r.status]}`,children:r.status})}),e.jsx("td",{className:"px-3 py-2 dark:text-red-400 max-w-xs truncate",children:r.error??"—"})]},r.id))})]})})}function X({enabled:s}){return e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-bold uppercase ${s?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-500 dark:bg-zinc-800 dark:text-matrix-tertiary"}`,children:s?"Enabled":"Disabled"})}function E(s,i){return s.length>i?`${s.slice(0,i)}…`:s}function _(s){return s?new Date(s).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function Z({onEdit:s}){const{data:i,isLoading:m}=I(),[r,c]=d.useState(null),[u,l]=d.useState(null),[n,h]=d.useState(null),o=async t=>{l(t.id);try{t.enabled?await g.disableJob(t.id):await g.enableJob(t.id),await f(p=>typeof p=="string"&&p.startsWith("/chronos"))}finally{l(null)}},x=async()=>{if(n){l(n.id);try{await g.deleteJob(n.id),await f(t=>typeof t=="string"&&t.startsWith("/chronos"))}finally{l(null),h(null)}}};return m?e.jsx("div",{className:"rounded border border-azure-border dark:border-matrix-primary p-8 text-center dark:text-matrix-secondary animate-pulse",children:"Loading jobs…"}):!i||i.length===0?e.jsxs("div",{className:"rounded border border-azure-border dark:border-matrix-primary p-8 text-center dark:text-matrix-secondary",children:["No Chronos jobs yet. Click ",e.jsx("strong",{className:"dark:text-matrix-highlight",children:"New Job"})," to get started."]}):e.jsxs("div",{className:"rounded border border-azure-border dark:border-matrix-primary overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900",children:[e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium",children:"Prompt"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden md:table-cell",children:"Schedule"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden lg:table-cell",children:"Next Run"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden lg:table-cell",children:"Last Run"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium text-right",children:"Actions"})]})}),e.jsx("tbody",{children:i.map(t=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 last:border-0 hover:bg-azure-hover dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3 dark:text-matrix-secondary max-w-xs",children:[e.jsx("span",{title:t.prompt,children:E(t.prompt,50)}),e.jsx("div",{className:"text-xs text-azure-text-muted dark:text-matrix-tertiary",children:t.created_by})]}),e.jsxs("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden md:table-cell text-xs",children:[e.jsx("div",{className:"capitalize",children:t.schedule_type}),e.jsx("div",{className:"text-azure-text-muted dark:text-matrix-tertiary truncate max-w-[140px]",title:t.schedule_expression,children:t.schedule_expression})]}),e.jsx("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden lg:table-cell text-xs",children:_(t.next_run_at)}),e.jsx("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden lg:table-cell text-xs",children:_(t.last_run_at)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(X,{enabled:t.enabled})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{title:r===t.id?"Hide history":"View history",onClick:()=>c(r===t.id?null:t.id),className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors",children:r===t.id?e.jsx(J,{className:"w-4 h-4"}):e.jsx(M,{className:"w-4 h-4"})}),e.jsx("button",{title:"Edit",onClick:()=>s(t),className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors",children:e.jsx(U,{className:"w-4 h-4"})}),e.jsx("button",{title:t.enabled?"Disable":"Enable",onClick:()=>o(t),disabled:u===t.id,className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors disabled:opacity-40",children:t.enabled?e.jsx(B,{className:"w-4 h-4"}):e.jsx(H,{className:"w-4 h-4"})}),e.jsx("button",{title:"Delete",onClick:()=>h(t),disabled:u===t.id,className:"p-1.5 rounded text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors disabled:opacity-40",children:e.jsx(W,{className:"w-4 h-4"})})]})})]},t.id),r===t.id&&e.jsx("tr",{className:"bg-azure-surface dark:bg-zinc-900/50",children:e.jsxs("td",{colSpan:6,className:"px-4 py-3",children:[e.jsx("div",{className:"text-xs font-bold dark:text-matrix-highlight mb-2",children:"Execution History"}),e.jsx(Y,{jobId:t.id})]})},`${t.id}-history`)]}))})]}),e.jsx(R,{isOpen:!!n,onClose:()=>h(null),onConfirm:x,title:"Delete Chronos Job",message:n?`Delete job "${E(n.prompt,60)}"? This action cannot be undone.`:""})]})}function K({scheduleExpression:s,scheduleType:i,timezone:m}){const[r,c]=d.useState(null),[u,l]=d.useState(null),n=d.useRef(null);if(d.useEffect(()=>{if(!s.trim()){c(null),l(null);return}return n.current&&clearTimeout(n.current),n.current=setTimeout(async()=>{try{const o=await g.preview(s,i,m);c(o),l(null)}catch(o){l(o.message??"Invalid expression"),c(null)}},500),()=>{n.current&&clearTimeout(n.current)}},[s,i,m]),!s.trim())return null;const h=(o,x)=>{try{return new Date(o).toLocaleString("pt-BR",{timeZone:x,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return new Date(o).toLocaleString()}};return e.jsx("div",{className:"mt-2 rounded border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900 p-3 text-sm",children:u?e.jsxs("p",{className:"text-red-500 dark:text-red-400 flex items-center gap-1.5",children:[e.jsx("span",{children:"⚠"})," ",u]}):r?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(T,{className:"w-3.5 h-3.5 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("span",{className:"font-medium dark:text-matrix-highlight",children:"Next run:"}),e.jsx("span",{children:h(r.next_run_at,m||"UTC")})]}),r.human_readable&&e.jsx("p",{className:"text-azure-text-muted dark:text-matrix-secondary/70 pl-5",children:r.human_readable}),r.next_occurrences.length>0&&e.jsx("div",{className:"pl-5 space-y-0.5",children:r.next_occurrences.map((o,x)=>e.jsxs("p",{className:"text-azure-text-muted dark:text-matrix-tertiary text-xs",children:["#",x+2,": ",o]},x))})]}):e.jsx("p",{className:"text-azure-text-muted dark:text-matrix-tertiary italic",children:"Parsing…"})})}const V=["UTC","America/Sao_Paulo","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Mexico_City","America/Buenos_Aires","America/Bogota","America/Lima","America/Santiago","Europe/London","Europe/Paris","Europe/Berlin","Europe/Rome","Europe/Madrid","Europe/Lisbon","Europe/Moscow","Europe/Istanbul","Asia/Dubai","Asia/Kolkata","Asia/Bangkok","Asia/Singapore","Asia/Tokyo","Asia/Shanghai","Asia/Seoul","Asia/Jakarta","Australia/Sydney","Australia/Melbourne","Pacific/Auckland","Africa/Cairo","Africa/Johannesburg","Africa/Lagos"],G=[{value:"telegram",label:"Telegram"},{value:"discord",label:"Discord"}],Q=[{value:"once",label:"Once"},{value:"cron",label:"Recurring (Cron)"},{value:"interval",label:"Recurring (Interval)"}],ee={once:'e.g. "in 30 minutes", "tomorrow at 9am", "2026-03-01T09:00:00"',cron:'e.g. "0 9 * * 1-5" (weekdays at 9am)',interval:'e.g. "every 30 minutes", "every sunday at 9am", "every weekday"'};function te({isOpen:s,onClose:i,onCreated:m,editJob:r}){const c=!!r,{data:u}=O(),[l,n]=d.useState(""),[h,o]=d.useState("once"),[x,t]=d.useState(""),[p,k]=d.useState("UTC"),[N,j]=d.useState([]),[v,b]=d.useState(null),[z,w]=d.useState(!1),A=a=>{j(y=>y.includes(a)?y.filter(L=>L!==a):[...y,a])};d.useEffect(()=>{r?(n(r.prompt),o(r.schedule_type),t(r.schedule_expression),k(r.timezone),j(r.notify_channels??[])):(n(""),o("once"),t(""),k(u?.timezone??"UTC"),j([])),b(null)},[r,s,u?.timezone]);const D=async()=>{if(b(null),!l.trim()){b("Prompt is required");return}if(!x.trim()){b("Schedule expression is required");return}w(!0);try{if(c&&r){const a={prompt:l,schedule_expression:x,timezone:p,notify_channels:N};await g.updateJob(r.id,a)}else{const a={prompt:l,schedule_type:h,schedule_expression:x,timezone:p,notify_channels:N};await g.createJob(a)}await f(a=>typeof a=="string"&&a.startsWith("/chronos")),m(),i()}catch(a){b(a.message??"Failed to save job")}finally{w(!1)}};return s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),e.jsxs("div",{className:"relative z-10 w-full max-w-lg mx-4 rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight font-mono",children:c?"Edit Chronos Job":"New Chronos Job"}),e.jsx("button",{onClick:i,className:"p-1 rounded text-azure-text-muted dark:text-matrix-tertiary hover:text-azure-text-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx($,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(C,{label:"Prompt",value:l,onChange:a=>n(a.target.value),placeholder:"What should the Oracle do when this job triggers?"}),!c&&e.jsx(S,{label:"Schedule Type",value:h,onChange:a=>o(a.target.value),options:Q}),e.jsxs("div",{children:[e.jsx(C,{label:"Schedule Expression",value:x,onChange:a=>t(a.target.value),placeholder:ee[h]}),e.jsx(K,{scheduleExpression:x,scheduleType:h,timezone:p})]}),e.jsx(S,{label:"Timezone",value:p,onChange:a=>k(a.target.value),options:V.map(a=>({value:a,label:a}))}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:["Notify Channels ",e.jsx("span",{className:"text-xs font-normal opacity-60",children:"(empty = all active channels)"})]}),e.jsx("div",{className:"flex gap-4",children:G.map(({value:a,label:y})=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:N.includes(a),onChange:()=>A(a),className:"rounded border-azure-border dark:border-matrix-primary accent-azure-primary dark:accent-matrix-highlight"}),e.jsx("span",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary capitalize",children:y})]},a))})]}),v&&e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v})]}),e.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:i,className:"px-4 py-2 rounded text-sm border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors font-mono",children:"Cancel"}),e.jsx("button",{onClick:D,disabled:z,className:"px-4 py-2 rounded text-sm bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight font-bold hover:opacity-90 disabled:opacity-50 transition-opacity font-mono",children:z?"Saving…":c?"Update":"Create"})]})]})]}):null}function ce(){const[s,i]=d.useState(!1),[m,r]=d.useState(null),c=n=>{r(n),i(!0)},u=()=>{i(!1),r(null)},l=()=>{f(n=>typeof n=="string"&&n.startsWith("/chronos"))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(T,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Chronos"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Temporal Intent Engine — schedule prompts for the Oracle."})]})]}),e.jsxs("button",{onClick:()=>{r(null),i(!0)},className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight text-sm font-medium hover:opacity-90 transition-opacity",children:[e.jsx(q,{className:"w-4 h-4"}),"New Job"]})]}),e.jsx(Z,{onEdit:c}),e.jsx(te,{isOpen:s,onClose:u,onCreated:l,editJob:m})]})}export{ce as ChronosPage};
|
|
1
|
+
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as d}from"./vendor-react-DikRIOlj.js";import{a as P,b as I,c as g,u as O}from"./chronos-DlDM2UBT.js";import{D as R}from"./DeleteConfirmationModal-DIXbckY8.js";import{ac as J,ad as M,ae as U,af as B,ag as H,y as W,h as T,X as $,a3 as q}from"./vendor-icons-DLvvGkeN.js";import{m as f}from"./vendor-utils-D4NnWbOU.js";import{T as C,S}from"./SelectInput-KVLsnfra.js";import"./index-CQIUjucB.js";const F={running:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",success:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",failed:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",timeout:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"};function Y({jobId:s}){const{data:i,isLoading:m}=P(s,50);return m?e.jsx("div",{className:"p-4 dark:bg-zinc-900 rounded text-sm dark:text-matrix-secondary animate-pulse",children:"Loading history…"}):!i||i.length===0?e.jsx("div",{className:"p-4 dark:bg-zinc-900 rounded text-sm dark:text-matrix-secondary italic",children:"No executions yet."}):e.jsx("div",{className:"rounded border border-azure-border dark:border-matrix-primary dark:bg-zinc-900 overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Triggered At"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Completed At"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Status"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Error"})]})}),e.jsx("tbody",{children:i.map(r=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 last:border-0",children:[e.jsx("td",{className:"px-3 py-2 dark:text-matrix-secondary",children:new Date(r.triggered_at).toLocaleString()}),e.jsx("td",{className:"px-3 py-2 dark:text-matrix-secondary",children:r.completed_at?new Date(r.completed_at).toLocaleString():"—"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold uppercase ${F[r.status]}`,children:r.status})}),e.jsx("td",{className:"px-3 py-2 dark:text-red-400 max-w-xs truncate",children:r.error??"—"})]},r.id))})]})})}function X({enabled:s}){return e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-bold uppercase ${s?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-500 dark:bg-zinc-800 dark:text-matrix-tertiary"}`,children:s?"Enabled":"Disabled"})}function E(s,i){return s.length>i?`${s.slice(0,i)}…`:s}function _(s){return s?new Date(s).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function Z({onEdit:s}){const{data:i,isLoading:m}=I(),[r,c]=d.useState(null),[u,l]=d.useState(null),[n,h]=d.useState(null),o=async t=>{l(t.id);try{t.enabled?await g.disableJob(t.id):await g.enableJob(t.id),await f(p=>typeof p=="string"&&p.startsWith("/chronos"))}finally{l(null)}},x=async()=>{if(n){l(n.id);try{await g.deleteJob(n.id),await f(t=>typeof t=="string"&&t.startsWith("/chronos"))}finally{l(null),h(null)}}};return m?e.jsx("div",{className:"rounded border border-azure-border dark:border-matrix-primary p-8 text-center dark:text-matrix-secondary animate-pulse",children:"Loading jobs…"}):!i||i.length===0?e.jsxs("div",{className:"rounded border border-azure-border dark:border-matrix-primary p-8 text-center dark:text-matrix-secondary",children:["No Chronos jobs yet. Click ",e.jsx("strong",{className:"dark:text-matrix-highlight",children:"New Job"})," to get started."]}):e.jsxs("div",{className:"rounded border border-azure-border dark:border-matrix-primary overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900",children:[e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium",children:"Prompt"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden md:table-cell",children:"Schedule"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden lg:table-cell",children:"Next Run"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden lg:table-cell",children:"Last Run"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium text-right",children:"Actions"})]})}),e.jsx("tbody",{children:i.map(t=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 last:border-0 hover:bg-azure-hover dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3 dark:text-matrix-secondary max-w-xs",children:[e.jsx("span",{title:t.prompt,children:E(t.prompt,50)}),e.jsx("div",{className:"text-xs text-azure-text-muted dark:text-matrix-tertiary",children:t.created_by})]}),e.jsxs("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden md:table-cell text-xs",children:[e.jsx("div",{className:"capitalize",children:t.schedule_type}),e.jsx("div",{className:"text-azure-text-muted dark:text-matrix-tertiary truncate max-w-[140px]",title:t.schedule_expression,children:t.schedule_expression})]}),e.jsx("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden lg:table-cell text-xs",children:_(t.next_run_at)}),e.jsx("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden lg:table-cell text-xs",children:_(t.last_run_at)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(X,{enabled:t.enabled})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{title:r===t.id?"Hide history":"View history",onClick:()=>c(r===t.id?null:t.id),className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors",children:r===t.id?e.jsx(J,{className:"w-4 h-4"}):e.jsx(M,{className:"w-4 h-4"})}),e.jsx("button",{title:"Edit",onClick:()=>s(t),className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors",children:e.jsx(U,{className:"w-4 h-4"})}),e.jsx("button",{title:t.enabled?"Disable":"Enable",onClick:()=>o(t),disabled:u===t.id,className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors disabled:opacity-40",children:t.enabled?e.jsx(B,{className:"w-4 h-4"}):e.jsx(H,{className:"w-4 h-4"})}),e.jsx("button",{title:"Delete",onClick:()=>h(t),disabled:u===t.id,className:"p-1.5 rounded text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors disabled:opacity-40",children:e.jsx(W,{className:"w-4 h-4"})})]})})]},t.id),r===t.id&&e.jsx("tr",{className:"bg-azure-surface dark:bg-zinc-900/50",children:e.jsxs("td",{colSpan:6,className:"px-4 py-3",children:[e.jsx("div",{className:"text-xs font-bold dark:text-matrix-highlight mb-2",children:"Execution History"}),e.jsx(Y,{jobId:t.id})]})},`${t.id}-history`)]}))})]}),e.jsx(R,{isOpen:!!n,onClose:()=>h(null),onConfirm:x,title:"Delete Chronos Job",message:n?`Delete job "${E(n.prompt,60)}"? This action cannot be undone.`:""})]})}function K({scheduleExpression:s,scheduleType:i,timezone:m}){const[r,c]=d.useState(null),[u,l]=d.useState(null),n=d.useRef(null);if(d.useEffect(()=>{if(!s.trim()){c(null),l(null);return}return n.current&&clearTimeout(n.current),n.current=setTimeout(async()=>{try{const o=await g.preview(s,i,m);c(o),l(null)}catch(o){l(o.message??"Invalid expression"),c(null)}},500),()=>{n.current&&clearTimeout(n.current)}},[s,i,m]),!s.trim())return null;const h=(o,x)=>{try{return new Date(o).toLocaleString("pt-BR",{timeZone:x,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return new Date(o).toLocaleString()}};return e.jsx("div",{className:"mt-2 rounded border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900 p-3 text-sm",children:u?e.jsxs("p",{className:"text-red-500 dark:text-red-400 flex items-center gap-1.5",children:[e.jsx("span",{children:"⚠"})," ",u]}):r?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(T,{className:"w-3.5 h-3.5 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("span",{className:"font-medium dark:text-matrix-highlight",children:"Next run:"}),e.jsx("span",{children:h(r.next_run_at,m||"UTC")})]}),r.human_readable&&e.jsx("p",{className:"text-azure-text-muted dark:text-matrix-secondary/70 pl-5",children:r.human_readable}),r.next_occurrences.length>0&&e.jsx("div",{className:"pl-5 space-y-0.5",children:r.next_occurrences.map((o,x)=>e.jsxs("p",{className:"text-azure-text-muted dark:text-matrix-tertiary text-xs",children:["#",x+2,": ",o]},x))})]}):e.jsx("p",{className:"text-azure-text-muted dark:text-matrix-tertiary italic",children:"Parsing…"})})}const V=["UTC","America/Sao_Paulo","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Mexico_City","America/Buenos_Aires","America/Bogota","America/Lima","America/Santiago","Europe/London","Europe/Paris","Europe/Berlin","Europe/Rome","Europe/Madrid","Europe/Lisbon","Europe/Moscow","Europe/Istanbul","Asia/Dubai","Asia/Kolkata","Asia/Bangkok","Asia/Singapore","Asia/Tokyo","Asia/Shanghai","Asia/Seoul","Asia/Jakarta","Australia/Sydney","Australia/Melbourne","Pacific/Auckland","Africa/Cairo","Africa/Johannesburg","Africa/Lagos"],G=[{value:"telegram",label:"Telegram"},{value:"discord",label:"Discord"}],Q=[{value:"once",label:"Once"},{value:"cron",label:"Recurring (Cron)"},{value:"interval",label:"Recurring (Interval)"}],ee={once:'e.g. "in 30 minutes", "tomorrow at 9am", "2026-03-01T09:00:00"',cron:'e.g. "0 9 * * 1-5" (weekdays at 9am)',interval:'e.g. "every 30 minutes", "every sunday at 9am", "every weekday"'};function te({isOpen:s,onClose:i,onCreated:m,editJob:r}){const c=!!r,{data:u}=O(),[l,n]=d.useState(""),[h,o]=d.useState("once"),[x,t]=d.useState(""),[p,k]=d.useState("UTC"),[N,j]=d.useState([]),[v,b]=d.useState(null),[z,w]=d.useState(!1),A=a=>{j(y=>y.includes(a)?y.filter(L=>L!==a):[...y,a])};d.useEffect(()=>{r?(n(r.prompt),o(r.schedule_type),t(r.schedule_expression),k(r.timezone),j(r.notify_channels??[])):(n(""),o("once"),t(""),k(u?.timezone??"UTC"),j([])),b(null)},[r,s,u?.timezone]);const D=async()=>{if(b(null),!l.trim()){b("Prompt is required");return}if(!x.trim()){b("Schedule expression is required");return}w(!0);try{if(c&&r){const a={prompt:l,schedule_expression:x,timezone:p,notify_channels:N};await g.updateJob(r.id,a)}else{const a={prompt:l,schedule_type:h,schedule_expression:x,timezone:p,notify_channels:N};await g.createJob(a)}await f(a=>typeof a=="string"&&a.startsWith("/chronos")),m(),i()}catch(a){b(a.message??"Failed to save job")}finally{w(!1)}};return s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),e.jsxs("div",{className:"relative z-10 w-full max-w-lg mx-4 rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight font-mono",children:c?"Edit Chronos Job":"New Chronos Job"}),e.jsx("button",{onClick:i,className:"p-1 rounded text-azure-text-muted dark:text-matrix-tertiary hover:text-azure-text-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx($,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(C,{label:"Prompt",value:l,onChange:a=>n(a.target.value),placeholder:"What should the Oracle do when this job triggers?"}),!c&&e.jsx(S,{label:"Schedule Type",value:h,onChange:a=>o(a.target.value),options:Q}),e.jsxs("div",{children:[e.jsx(C,{label:"Schedule Expression",value:x,onChange:a=>t(a.target.value),placeholder:ee[h]}),e.jsx(K,{scheduleExpression:x,scheduleType:h,timezone:p})]}),e.jsx(S,{label:"Timezone",value:p,onChange:a=>k(a.target.value),options:V.map(a=>({value:a,label:a}))}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:["Notify Channels ",e.jsx("span",{className:"text-xs font-normal opacity-60",children:"(empty = all active channels)"})]}),e.jsx("div",{className:"flex gap-4",children:G.map(({value:a,label:y})=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:N.includes(a),onChange:()=>A(a),className:"rounded border-azure-border dark:border-matrix-primary accent-azure-primary dark:accent-matrix-highlight"}),e.jsx("span",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary capitalize",children:y})]},a))})]}),v&&e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v})]}),e.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:i,className:"px-4 py-2 rounded text-sm border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors font-mono",children:"Cancel"}),e.jsx("button",{onClick:D,disabled:z,className:"px-4 py-2 rounded text-sm bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight font-bold hover:opacity-90 disabled:opacity-50 transition-opacity font-mono",children:z?"Saving…":c?"Update":"Create"})]})]})]}):null}function ce(){const[s,i]=d.useState(!1),[m,r]=d.useState(null),c=n=>{r(n),i(!0)},u=()=>{i(!1),r(null)},l=()=>{f(n=>typeof n=="string"&&n.startsWith("/chronos"))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(T,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Chronos"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Temporal Intent Engine — schedule prompts for the Oracle."})]})]}),e.jsxs("button",{onClick:()=>{r(null),i(!0)},className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight text-sm font-medium hover:opacity-90 transition-opacity",children:[e.jsx(q,{className:"w-4 h-4"}),"New Job"]})]}),e.jsx(Z,{onEdit:c}),e.jsx(te,{isOpen:s,onClose:u,onCreated:l,editJob:m})]})}export{ce as ChronosPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import{D as o,d as x,e as n,j as c,k as g,B as t}from"./index-
|
|
1
|
+
import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import{D as o,d as x,e as n,j as c,k as g,B as t}from"./index-CQIUjucB.js";function p({isOpen:i,onClose:a,onConfirm:s,title:d,description:l,confirmJson:m="Confirm",variant:e="default"}){return r.jsx(o,{open:i,onOpenChange:a,children:r.jsxs(x,{className:"sm:max-w-md bg-azure-surface dark:bg-black border-azure-border dark:border-matrix-primary",children:[r.jsx(n,{children:r.jsx(c,{className:"text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:d})}),r.jsx("div",{className:"py-4",children:r.jsx("p",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:l})}),r.jsxs(g,{className:"flex flex-col sm:flex-row gap-3 sm:justify-end",children:[r.jsx(t,{variant:"outline",onClick:a,className:"dark:border-matrix-primary dark:text-matrix-secondary dark:hover:bg-matrix-primary/20",children:"Cancel"}),r.jsx(t,{variant:e,onClick:()=>{s(),a()},className:e==="destructive"?"dark:bg-red-900/50 dark:text-red-200 dark:hover:bg-red-800/60":"dark:bg-matrix-primary dark:text-black dark:hover:bg-matrix-highlight",children:m})]})]})})}export{p as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,m as d}from"./vendor-motion-C3CZ8ZlO.js";import{u as P,t as z,h as w,f as U}from"./index-CpVvCthh.js";import{u as n}from"./vendor-utils-D4NnWbOU.js";import{s as A}from"./stats-DALk3GOj.js";import{m as E}from"./mcp-M0iDC0mj.js";import{s as R}from"./skills-BvaaqiOT.js";import{L as V,A as F,h as j,k as O,l as J,m as W,i as B,W as G,P as H,H as q,g as X,n as S,o as K,p as Q,q as Y}from"./vendor-icons-DLvvGkeN.js";import{L as C}from"./vendor-react-DikRIOlj.js";const Z={hidden:{opacity:0,y:20},show:{opacity:1,y:0}},k=({title:r,value:a,icon:i,subValue:l})=>e.jsxs(d.div,{variants:Z,className:"border border-azure-border dark:border-matrix-primary bg-azure-surface/50 dark:bg-zinc-950/50 p-6 rounded relative overflow-hidden group hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("h3",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm font-bold uppercase",children:r}),e.jsx(i,{className:"w-6 h-6 text-azure-primary dark:text-matrix-primary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),e.jsx("div",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight mb-1 font-mono tracking-tighter truncate",children:a}),l&&e.jsx("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70 font-mono",children:l})]}),ee={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.07}}},c={hidden:{opacity:0,y:12},show:{opacity:1,y:0}};function m({icon:r,title:a,to:i,children:l,status:o="neutral"}){const h=o==="ok"?"border-emerald-300/60 dark:border-emerald-700/40":o==="warn"?"border-amber-300/60 dark:border-amber-700/40":o==="error"?"border-red-300/60 dark:border-red-700/40":"border-azure-border dark:border-matrix-primary/50";return e.jsxs(C,{to:i,className:`group flex flex-col gap-3 rounded-lg border bg-white dark:bg-black p-4 hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors ${h}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight",children:a})]}),e.jsx(S,{className:"w-3.5 h-3.5 text-azure-text-secondary dark:text-matrix-tertiary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),e.jsx("div",{className:"space-y-1.5",children:l})]})}function s({label:r,value:a,highlight:i}){return e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:r}),e.jsx("span",{className:i?"font-semibold text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary",children:a})]})}function te({status:r}){return r==="completed"?e.jsx(K,{className:"w-3.5 h-3.5 text-emerald-500 shrink-0"}):r==="failed"?e.jsx(Q,{className:"w-3.5 h-3.5 text-red-500 shrink-0"}):r==="running"?e.jsx(Y,{className:"w-3.5 h-3.5 text-blue-500 animate-spin shrink-0"}):e.jsx(j,{className:"w-3.5 h-3.5 text-yellow-500 shrink-0"})}function xe(){const{data:r}=P(),{data:a}=n("/tasks/stats",()=>z.stats(),{refreshInterval:5e3}),{data:i}=n("/api/stats/usage",()=>A.fetchUsageStats(),{refreshInterval:3e4}),{data:l}=n("/api/mcp/stats",()=>E.fetchStats(),{refreshInterval:3e4}),{data:o}=n("/smiths",()=>w.get("/smiths"),{refreshInterval:1e4}),{data:h=[]}=n("/chronos",()=>w.get("/chronos"),{refreshInterval:3e4}),{data:x}=n("/api/skills",()=>R.fetchSkills(),{refreshInterval:6e4}),{data:p=[]}=n(["/tasks",{limit:5}],()=>z.list({limit:5}),{refreshInterval:5e3}),v=(i?.totalInputTokens??0)+(i?.totalOutputTokens??0),f=i?.totalEstimatedCostUsd!=null,T=i?.totalEstimatedCostUsd??0,g=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t),u=h.filter(t=>t.enabled),y=u.filter(t=>t.next_run_at).sort((t,b)=>t.next_run_at-b.next_run_at)[0],N=y?.next_run_at?(()=>{const t=y.next_run_at-Date.now();return t<0?"due now":t<6e4?`${Math.floor(t/1e3)}s`:t<36e5?`${Math.floor(t/6e4)}m`:`${Math.floor(t/36e5)}h`})():null,$=(a?.pending??0)+(a?.running??0),I=a?.failed?"warn":$>0?"ok":"neutral",L=(l?.totalTools??0)>0?"ok":"neutral",_=(o?.online??0)>0?"ok":(o?.total??0)>0?"warn":"neutral",D=u.length>0?"ok":"neutral",M=(x?.enabled??0)>0?"ok":"neutral";return e.jsxs(d.div,{className:"space-y-6",variants:ee,initial:"hidden",animate:"show",children:[e.jsxs(d.div,{variants:c,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(V,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Dashboard"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Overview of the Morpheus agent runtime."})]})]}),e.jsxs(d.div,{variants:c,className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(k,{title:"Agent Status",value:r?.status.toUpperCase()??"CONNECTING...",icon:F,subValue:r?`PID: ${r.pid}`:""}),e.jsx(k,{title:"Uptime",value:r?U(r.uptimeSeconds):"-",icon:j,subValue:r?`${r.uptimeSeconds.toFixed(0)}s elapsed`:""}),e.jsx(k,{title:"Version",value:r?.projectVersion??"-",icon:O,subValue:`Node ${r?.nodeVersion??"-"}`})]}),e.jsxs(d.div,{variants:c,className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Provider"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("p",{className:"text-base font-bold text-azure-text dark:text-matrix-highlight truncate",children:r?.llmProvider?.toUpperCase()??"—"})]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Model"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("p",{className:"text-sm font-bold text-azure-text dark:text-matrix-highlight truncate leading-tight",children:r?.llmModel??"—"})]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Total Tokens"}),e.jsx("p",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:v>0?g(v):"—"}),e.jsxs("p",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:[g(i?.totalInputTokens??0)," in · ",g(i?.totalOutputTokens??0)," out"]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Est. Cost"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{className:"w-4 h-4 text-emerald-500 shrink-0"}),e.jsx("p",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:f?`$${T.toFixed(4)}`:"—"})]}),e.jsx("p",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:f?"accumulated total":"configure pricing to track"})]})]}),e.jsxs(d.div,{variants:c,children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-3",children:"Platform"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4",children:[e.jsxs(m,{icon:G,title:"Skills",to:"/skills",status:M,children:[e.jsx(s,{label:"Enabled",value:x?`${x.enabled} / ${x.total}`:"—",highlight:(x?.enabled??0)>0}),e.jsx(s,{label:"Total",value:x?.total??"—"})]}),e.jsxs(m,{icon:H,title:"MCP Servers",to:"/mcp-servers",status:L,children:[e.jsx(s,{label:"Tools loaded",value:l?.totalTools??"—",highlight:!!l?.totalTools}),e.jsx(s,{label:"Servers",value:l?.servers?.length??"—"}),l?.lastLoadedAt&&e.jsx(s,{label:"Last loaded",value:new Date(l.lastLoadedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]}),e.jsxs(m,{icon:q,title:"Smiths",to:"/smiths",status:_,children:[e.jsx(s,{label:"Online",value:o?`${o.online} / ${o.total}`:"—",highlight:(o?.online??0)>0}),e.jsx(s,{label:"System",value:o?.enabled?"enabled":"disabled"})]}),e.jsxs(m,{icon:X,title:"Tasks",to:"/tasks",status:I,children:[e.jsx(s,{label:"Running",value:a?.running??"—",highlight:!!a?.running}),e.jsx(s,{label:"Pending",value:a?.pending??"—"}),e.jsx(s,{label:"Completed",value:a?.completed??"—"}),(a?.failed??0)>0&&e.jsx(s,{label:"Failed",value:a.failed})]}),e.jsxs(m,{icon:j,title:"Chronos",to:"/chronos",status:D,children:[e.jsx(s,{label:"Active jobs",value:u.length,highlight:u.length>0}),e.jsx(s,{label:"Total jobs",value:h.length}),N&&e.jsx(s,{label:"Next run",value:`in ${N}`})]})]})]}),p.length>0&&e.jsxs(d.div,{variants:c,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:"Recent Tasks"}),e.jsxs(C,{to:"/tasks",className:"flex items-center gap-0.5 text-xs text-azure-primary dark:text-matrix-highlight hover:underline",children:["View all ",e.jsx(S,{className:"w-3 h-3"})]})]}),e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:p.map((t,b)=>e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 ${b<p.length-1?"border-b border-azure-border dark:border-matrix-primary/30":""} hover:bg-azure-surface/60 dark:hover:bg-zinc-900/50 transition-colors`,children:[e.jsx(te,{status:t.status}),e.jsx("span",{className:"font-mono text-[10px] text-azure-text-secondary dark:text-matrix-tertiary w-16 shrink-0",children:t.id.slice(0,8)}),e.jsx("span",{className:"flex-1 text-xs text-azure-text dark:text-matrix-secondary truncate",children:t.input.slice(0,100)}),e.jsx("span",{className:"text-[10px] font-mono uppercase text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:t.agent}),e.jsx("span",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:new Date(t.created_at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]},t.id))})]})]})}export{xe as Dashboard};
|
|
1
|
+
import{j as e,m as d}from"./vendor-motion-C3CZ8ZlO.js";import{u as P,t as z,h as w,f as U}from"./index-CQIUjucB.js";import{u as n}from"./vendor-utils-D4NnWbOU.js";import{s as A}from"./stats-DHCRNkJp.js";import{m as E}from"./mcp-DfhJYN14.js";import{s as R}from"./skills-BPjq0qV7.js";import{L as V,A as F,h as j,k as O,l as J,m as W,i as B,W as G,P as H,H as q,g as X,n as S,o as K,p as Q,q as Y}from"./vendor-icons-DLvvGkeN.js";import{L as C}from"./vendor-react-DikRIOlj.js";const Z={hidden:{opacity:0,y:20},show:{opacity:1,y:0}},k=({title:r,value:a,icon:i,subValue:l})=>e.jsxs(d.div,{variants:Z,className:"border border-azure-border dark:border-matrix-primary bg-azure-surface/50 dark:bg-zinc-950/50 p-6 rounded relative overflow-hidden group hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("h3",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm font-bold uppercase",children:r}),e.jsx(i,{className:"w-6 h-6 text-azure-primary dark:text-matrix-primary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),e.jsx("div",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight mb-1 font-mono tracking-tighter truncate",children:a}),l&&e.jsx("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70 font-mono",children:l})]}),ee={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.07}}},c={hidden:{opacity:0,y:12},show:{opacity:1,y:0}};function m({icon:r,title:a,to:i,children:l,status:o="neutral"}){const h=o==="ok"?"border-emerald-300/60 dark:border-emerald-700/40":o==="warn"?"border-amber-300/60 dark:border-amber-700/40":o==="error"?"border-red-300/60 dark:border-red-700/40":"border-azure-border dark:border-matrix-primary/50";return e.jsxs(C,{to:i,className:`group flex flex-col gap-3 rounded-lg border bg-white dark:bg-black p-4 hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors ${h}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight",children:a})]}),e.jsx(S,{className:"w-3.5 h-3.5 text-azure-text-secondary dark:text-matrix-tertiary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),e.jsx("div",{className:"space-y-1.5",children:l})]})}function s({label:r,value:a,highlight:i}){return e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:r}),e.jsx("span",{className:i?"font-semibold text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary",children:a})]})}function te({status:r}){return r==="completed"?e.jsx(K,{className:"w-3.5 h-3.5 text-emerald-500 shrink-0"}):r==="failed"?e.jsx(Q,{className:"w-3.5 h-3.5 text-red-500 shrink-0"}):r==="running"?e.jsx(Y,{className:"w-3.5 h-3.5 text-blue-500 animate-spin shrink-0"}):e.jsx(j,{className:"w-3.5 h-3.5 text-yellow-500 shrink-0"})}function xe(){const{data:r}=P(),{data:a}=n("/tasks/stats",()=>z.stats(),{refreshInterval:5e3}),{data:i}=n("/api/stats/usage",()=>A.fetchUsageStats(),{refreshInterval:3e4}),{data:l}=n("/api/mcp/stats",()=>E.fetchStats(),{refreshInterval:3e4}),{data:o}=n("/smiths",()=>w.get("/smiths"),{refreshInterval:1e4}),{data:h=[]}=n("/chronos",()=>w.get("/chronos"),{refreshInterval:3e4}),{data:x}=n("/api/skills",()=>R.fetchSkills(),{refreshInterval:6e4}),{data:p=[]}=n(["/tasks",{limit:5}],()=>z.list({limit:5}),{refreshInterval:5e3}),v=(i?.totalInputTokens??0)+(i?.totalOutputTokens??0),f=i?.totalEstimatedCostUsd!=null,T=i?.totalEstimatedCostUsd??0,g=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t),u=h.filter(t=>t.enabled),y=u.filter(t=>t.next_run_at).sort((t,b)=>t.next_run_at-b.next_run_at)[0],N=y?.next_run_at?(()=>{const t=y.next_run_at-Date.now();return t<0?"due now":t<6e4?`${Math.floor(t/1e3)}s`:t<36e5?`${Math.floor(t/6e4)}m`:`${Math.floor(t/36e5)}h`})():null,$=(a?.pending??0)+(a?.running??0),I=a?.failed?"warn":$>0?"ok":"neutral",L=(l?.totalTools??0)>0?"ok":"neutral",_=(o?.online??0)>0?"ok":(o?.total??0)>0?"warn":"neutral",D=u.length>0?"ok":"neutral",M=(x?.enabled??0)>0?"ok":"neutral";return e.jsxs(d.div,{className:"space-y-6",variants:ee,initial:"hidden",animate:"show",children:[e.jsxs(d.div,{variants:c,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(V,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Dashboard"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Overview of the Morpheus agent runtime."})]})]}),e.jsxs(d.div,{variants:c,className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(k,{title:"Agent Status",value:r?.status.toUpperCase()??"CONNECTING...",icon:F,subValue:r?`PID: ${r.pid}`:""}),e.jsx(k,{title:"Uptime",value:r?U(r.uptimeSeconds):"-",icon:j,subValue:r?`${r.uptimeSeconds.toFixed(0)}s elapsed`:""}),e.jsx(k,{title:"Version",value:r?.projectVersion??"-",icon:O,subValue:`Node ${r?.nodeVersion??"-"}`})]}),e.jsxs(d.div,{variants:c,className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Provider"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("p",{className:"text-base font-bold text-azure-text dark:text-matrix-highlight truncate",children:r?.llmProvider?.toUpperCase()??"—"})]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Model"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("p",{className:"text-sm font-bold text-azure-text dark:text-matrix-highlight truncate leading-tight",children:r?.llmModel??"—"})]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Total Tokens"}),e.jsx("p",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:v>0?g(v):"—"}),e.jsxs("p",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:[g(i?.totalInputTokens??0)," in · ",g(i?.totalOutputTokens??0)," out"]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Est. Cost"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{className:"w-4 h-4 text-emerald-500 shrink-0"}),e.jsx("p",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:f?`$${T.toFixed(4)}`:"—"})]}),e.jsx("p",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:f?"accumulated total":"configure pricing to track"})]})]}),e.jsxs(d.div,{variants:c,children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-3",children:"Platform"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4",children:[e.jsxs(m,{icon:G,title:"Skills",to:"/skills",status:M,children:[e.jsx(s,{label:"Enabled",value:x?`${x.enabled} / ${x.total}`:"—",highlight:(x?.enabled??0)>0}),e.jsx(s,{label:"Total",value:x?.total??"—"})]}),e.jsxs(m,{icon:H,title:"MCP Servers",to:"/mcp-servers",status:L,children:[e.jsx(s,{label:"Tools loaded",value:l?.totalTools??"—",highlight:!!l?.totalTools}),e.jsx(s,{label:"Servers",value:l?.servers?.length??"—"}),l?.lastLoadedAt&&e.jsx(s,{label:"Last loaded",value:new Date(l.lastLoadedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]}),e.jsxs(m,{icon:q,title:"Smiths",to:"/smiths",status:_,children:[e.jsx(s,{label:"Online",value:o?`${o.online} / ${o.total}`:"—",highlight:(o?.online??0)>0}),e.jsx(s,{label:"System",value:o?.enabled?"enabled":"disabled"})]}),e.jsxs(m,{icon:X,title:"Tasks",to:"/tasks",status:I,children:[e.jsx(s,{label:"Running",value:a?.running??"—",highlight:!!a?.running}),e.jsx(s,{label:"Pending",value:a?.pending??"—"}),e.jsx(s,{label:"Completed",value:a?.completed??"—"}),(a?.failed??0)>0&&e.jsx(s,{label:"Failed",value:a.failed})]}),e.jsxs(m,{icon:j,title:"Chronos",to:"/chronos",status:D,children:[e.jsx(s,{label:"Active jobs",value:u.length,highlight:u.length>0}),e.jsx(s,{label:"Total jobs",value:h.length}),N&&e.jsx(s,{label:"Next run",value:`in ${N}`})]})]})]}),p.length>0&&e.jsxs(d.div,{variants:c,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:"Recent Tasks"}),e.jsxs(C,{to:"/tasks",className:"flex items-center gap-0.5 text-xs text-azure-primary dark:text-matrix-highlight hover:underline",children:["View all ",e.jsx(S,{className:"w-3 h-3"})]})]}),e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:p.map((t,b)=>e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 ${b<p.length-1?"border-b border-azure-border dark:border-matrix-primary/30":""} hover:bg-azure-surface/60 dark:hover:bg-zinc-900/50 transition-colors`,children:[e.jsx(te,{status:t.status}),e.jsx("span",{className:"font-mono text-[10px] text-azure-text-secondary dark:text-matrix-tertiary w-16 shrink-0",children:t.id.slice(0,8)}),e.jsx("span",{className:"flex-1 text-xs text-azure-text dark:text-matrix-secondary truncate",children:t.input.slice(0,100)}),e.jsx("span",{className:"text-[10px] font-mono uppercase text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:t.agent}),e.jsx("span",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:new Date(t.created_at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]},t.id))})]})]})}export{xe as Dashboard};
|
package/dist/ui/assets/{DeleteConfirmationModal-B0nDocEK.js → DeleteConfirmationModal-DIXbckY8.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{B as d}from"./index-
|
|
1
|
+
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{B as d}from"./index-CQIUjucB.js";const n=({isOpen:a,onClose:r,title:t,children:s,size:i="md"})=>{if(!a)return null;const l={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl"};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:r}),e.jsxs("div",{className:`relative bg-azure-surface dark:bg-black rounded-lg border border-azure-border dark:border-matrix-primary shadow-xl w-full ${l[i]} max-h-[90vh] overflow-hidden flex flex-col`,children:[t&&e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-azure-border dark:border-matrix-primary",children:[t&&e.jsx("h3",{className:"text-lg font-semibold text-azure-text-primary dark:text-matrix-highlight",children:t}),r&&e.jsx("button",{onClick:r,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text-primary dark:hover:text-matrix-highlight",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"overflow-y-auto flex-grow p-6",children:s})]})]})},h=({isOpen:a,onClose:r,onConfirm:t,title:s="Confirm Deletion",message:i="Are you sure you want to delete this item? This action cannot be undone.",confirmButtonText:l="Delete",cancelButtonText:x="Cancel"})=>e.jsx(n,{isOpen:a,onClose:r,title:s,size:"md",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-azure-text-primary dark:text-matrix-secondary",children:i}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"outline",onClick:r,children:x}),e.jsx(d,{variant:"destructive",onClick:()=>{t(),r()},children:l})]})]})});export{h as D,n as M};
|