Skip to content

Agent Zero AI framework

continued log+rendering refactor

frdelc4846e7e9d1e
diff --git a/initialize.py b/initialize.py
index ec26227fa..cc4550ab6 100644
--- a/initialize.py
+++ b/initialize.py
@@ -109,7 +109,7 @@ def initialize_agent(override_settings: dict | None = None):
# if first_context:
# (
# first_context.log
- # .log(type="warning", content=f"Failed to update MCP settings: {e}", temp=False)
+ # .log(type="warning", content=f"Failed to update MCP settings: {e}")
# )
# (
# print_style_helper.PrintStyle(background_color="black", font_color="red", padding=True)
diff --git a/python/extensions/monologue_end/_50_memorize_fragments.py b/python/extensions/monologue_end/_50_memorize_fragments.py
index 932c7bf06..9dbf91dae 100644
--- a/python/extensions/monologue_end/_50_memorize_fragments.py
+++ b/python/extensions/monologue_end/_50_memorize_fragments.py
@@ -114,7 +114,6 @@ class MemorizeMemories(Extension):
# memory_log = self.agent.context.log.log(
# type="util",
# heading=f"Processing memory fragment: {txt[:50]}...",
- # temp=False,
# update_progress="none" # Don't affect status bar
# )
@@ -133,7 +132,6 @@ class MemorizeMemories(Extension):
memory_log.update(
result="Fragment processed successfully",
heading=f"Memory fragment completed: {txt[:50]}...",
- temp=False, # Show completion message
update_progress="none" # Show briefly then disappear
)
else:
@@ -141,7 +139,6 @@ class MemorizeMemories(Extension):
memory_log.update(
result="Fragment processing failed",
heading=f"Memory fragment failed: {txt[:50]}...",
- temp=False, # Show completion message
update_progress="none" # Show briefly then disappear
)
total_processed += 1
diff --git a/python/extensions/monologue_end/_51_memorize_solutions.py b/python/extensions/monologue_end/_51_memorize_solutions.py
index a66cd4e15..d3969bb02 100644
--- a/python/extensions/monologue_end/_51_memorize_solutions.py
+++ b/python/extensions/monologue_end/_51_memorize_solutions.py
@@ -121,7 +121,6 @@ class MemorizeSolutions(Extension):
# solution_log = self.agent.context.log.log(
# type="util",
# heading=f"Processing solution: {txt[:50]}...",
- # temp=False,
# update_progress="none" # Don't affect status bar
# )
@@ -140,7 +139,6 @@ class MemorizeSolutions(Extension):
solution_log.update(
result="Solution processed successfully",
heading=f"Solution completed: {txt[:50]}...",
- temp=False, # Show completion message
update_progress="none" # Show briefly then disappear
)
else:
@@ -148,7 +146,6 @@ class MemorizeSolutions(Extension):
solution_log.update(
result="Solution processing failed",
heading=f"Solution failed: {txt[:50]}...",
- temp=False, # Show completion message
update_progress="none" # Show briefly then disappear
)
total_processed += 1
diff --git a/python/helpers/docker.py b/python/helpers/docker.py
index b71651954..dc1852bb3 100644
--- a/python/helpers/docker.py
+++ b/python/helpers/docker.py
@@ -73,7 +73,7 @@ class DockerContainerManager:
if existing_container:
if existing_container.status != 'running':
PrintStyle.standard(f"Starting existing container: {self.name} for safe code execution...")
- if self.logger: self.logger.log(type="info", content=f"Starting existing container: {self.name} for safe code execution...", temp=True)
+ if self.logger: self.logger.log(type="info", content=f"Starting existing container: {self.name} for safe code execution...")
existing_container.start()
self.container = existing_container
@@ -84,7 +84,7 @@ class DockerContainerManager:
# PrintStyle.standard(f"Container with name '{self.name}' is already running with ID: {existing_container.id}")
else:
PrintStyle.standard(f"Initializing docker container {self.name} for safe code execution...")
- if self.logger: self.logger.log(type="info", content=f"Initializing docker container {self.name} for safe code execution...", temp=True)
+ if self.logger: self.logger.log(type="info", content=f"Initializing docker container {self.name} for safe code execution...")
self.container = self.client.containers.run(
self.image,
diff --git a/python/helpers/fasta2a_server.py b/python/helpers/fasta2a_server.py
index 000c5a39d..83ed30650 100644
--- a/python/helpers/fasta2a_server.py
+++ b/python/helpers/fasta2a_server.py
@@ -98,7 +98,6 @@ class AgentZeroWorker(Worker): # type: ignore[misc]
heading="Remote user message",
content=agent_message.message,
kvps={"from": "A2A"},
- temp=False,
)
# Process message through Agent Zero (includes response)
diff --git a/python/helpers/log.py b/python/helpers/log.py
index d231810d2..a59919dd9 100644
--- a/python/helpers/log.py
+++ b/python/helpers/log.py
@@ -127,14 +127,12 @@ class LogItem:
type: Type
heading: str = ""
content: str = ""
- temp: bool = False
update_progress: Optional[ProgressUpdate] = "persistent"
kvps: Optional[OrderedDict] = None # Use OrderedDict for kvps
id: Optional[str] = None # Add id field
guid: str = ""
timestamp: float = 0.0
- duration_ms: Optional[int] = None
- agent_number: int = 0
+ agentno: int = 0
def __post_init__(self):
self.guid = self.log.guid
@@ -146,7 +144,6 @@ class LogItem:
heading: str | None = None,
content: str | None = None,
kvps: dict | None = None,
- temp: bool | None = None,
update_progress: ProgressUpdate | None = None,
**kwargs,
):
@@ -157,7 +154,6 @@ class LogItem:
heading=heading,
content=content,
kvps=kvps,
- temp=temp,
update_progress=update_progress,
**kwargs,
)
@@ -184,11 +180,9 @@ class LogItem:
"type": self.type,
"heading": self.heading,
"content": self.content,
- "temp": self.temp,
"kvps": self.kvps,
"timestamp": self.timestamp,
- "duration_ms": self.duration_ms,
- "agent_number": self.agent_number,
+ "agentno": self.agentno,
}
@@ -207,7 +201,6 @@ class Log:
heading: str | None = None,
content: str | None = None,
kvps: dict | None = None,
- temp: bool | None = None,
update_progress: ProgressUpdate | None = None,
id: Optional[str] = None,
**kwargs,
@@ -215,20 +208,19 @@ class Log:
# add a minimal item to the log
# Determine agent number from streaming agent
- agent_number = 0
+ agentno = 0
if self.context and self.context.streaming_agent:
- agent_number = self.context.streaming_agent.number
+ agentno = self.context.streaming_agent.number
item = LogItem(
log=self,
no=len(self.logs),
type=type,
- agent_number=agent_number,
+ agentno=agentno,
)
# Set duration on previous item and mark it as updated
if self.logs:
prev = self.logs[-1]
- prev.duration_ms = int((item.timestamp - prev.timestamp) * 1000)
self.updates += [prev.no]
self.logs.append(item)
@@ -239,7 +231,6 @@ class Log:
heading=heading,
content=content,
kvps=kvps,
- temp=temp,
update_progress=update_progress,
id=id,
**kwargs,
@@ -253,7 +244,6 @@ class Log:
heading: str | None = None,
content: str | None = None,
kvps: dict | None = None,
- temp: bool | None = None,
update_progress: ProgressUpdate | None = None,
id: Optional[str] = None,
**kwargs,
@@ -266,9 +256,6 @@ class Log:
if type is not None:
item.type = type
- if temp is not None:
- item.temp = temp
-
if update_progress is not None:
item.update_progress = update_progress
diff --git a/python/helpers/mcp_handler.py b/python/helpers/mcp_handler.py
index 1a16acb49..5936f4864 100644
--- a/python/helpers/mcp_handler.py
+++ b/python/helpers/mcp_handler.py
@@ -90,7 +90,6 @@ def initialize_mcp(mcp_servers_config: str):
AgentContext.log_to_all(
type="warning",
content=f"Failed to update MCP settings: {e}",
- temp=False,
)
PrintStyle(
diff --git a/python/helpers/memory_consolidation.py b/python/helpers/memory_consolidation.py
index 6a100d8f4..244ebbc8d 100644
--- a/python/helpers/memory_consolidation.py
+++ b/python/helpers/memory_consolidation.py
@@ -130,7 +130,6 @@ class MemoryConsolidator:
if log_item:
log_item.update(
progress="No similar memories found, inserting new memory",
- temp=True
)
try:
db = await Memory.get(self.agent)
@@ -153,7 +152,6 @@ class MemoryConsolidator:
if log_item:
log_item.update(
progress=f"Found {len(similar_memories)} similar memories, analyzing...",
- temp=True,
similar_memories_count=len(similar_memories)
)
@@ -174,7 +172,6 @@ class MemoryConsolidator:
if log_item:
log_item.update(
progress=f"Filtered out {deleted_count} deleted memories, {len(valid_similar_memories)} remain for analysis",
- temp=True,
race_condition_detected=True,
deleted_similar_memories_count=deleted_count
)
@@ -185,7 +182,6 @@ class MemoryConsolidator:
if log_item:
log_item.update(
progress="No valid similar memories remain, inserting new memory",
- temp=True
)
try:
db = await Memory.get(self.agent)
@@ -220,7 +216,6 @@ class MemoryConsolidator:
if log_item:
log_item.update(
progress="LLM analysis suggests skipping consolidation",
- temp=True
)
try:
db = await Memory.get(self.agent)
diff --git a/python/helpers/persist_chat.py b/python/helpers/persist_chat.py
index 9e4c20b6c..7fb958627 100644
--- a/python/helpers/persist_chat.py
+++ b/python/helpers/persist_chat.py
@@ -269,11 +269,9 @@ def _deserialize_log(data: dict[str, Any]) -> "Log":
heading=item_data.get("heading", ""),
content=item_data.get("content", ""),
kvps=OrderedDict(item_data["kvps"]) if item_data["kvps"] else None,
- temp=item_data.get("temp", False),
- # Pass metrics directly to constructor
timestamp=item_data.get("timestamp", 0.0),
- duration_ms=item_data.get("duration_ms"),
- agent_number=item_data.get("agent_number", 0),
+ agentno=item_data.get("agentno", 0),
+ id=item_data.get("id"),
))
log.updates.append(i)
i += 1
diff --git a/python/helpers/shell_ssh.py b/python/helpers/shell_ssh.py
index bafcdbea0..71faf9eb1 100644
--- a/python/helpers/shell_ssh.py
+++ b/python/helpers/shell_ssh.py
@@ -82,7 +82,6 @@ class SSHInteractiveSession:
self.logger.log(
type="info",
content=f"SSH Connection attempt {errors}...",
- temp=True,
)
time.sleep(5)
else:
diff --git a/webui/components/messages/process-group/process-group.css b/webui/components/messages/process-group/process-group.css
index 8ce29d159..5d5b0725d 100644
--- a/webui/components/messages/process-group/process-group.css
+++ b/webui/components/messages/process-group/process-group.css
@@ -145,87 +145,83 @@
/* GEN - agent type (blue/cyan) */
.status-gen {
--step-accent: #38bdf8;
- color: var(--step-accent);
}
/* END - response/done type (green) */
.status-end {
--step-accent: #22c55e;
- color: var(--step-accent);
}
/* USE - tool usage (amber/yellow) */
.status-tool {
--step-accent: #fbbf24;
- color: var(--step-accent);
}
/* MCP - mcp type (amber/yellow) */
.status-mcp {
--step-accent: #fbbf24;
- color: var(--step-accent);
}
/* SUB - subagent type (teal) */
.status-sub {
--step-accent: #14b8a6;
- color: var(--step-accent);
}
/* EXE - code_exe type (magenta/purple) */
.status-exe {
--step-accent: #ba68c8;
- color: var(--step-accent);
}
/* WWW - browser type (indigo) */
.status-www {
--step-accent: #818cf8;
- color: var(--step-accent);
}
/* WAIT - progress type (slate) */
.status-wait {
--step-accent: #94a3b8;
- color: var(--step-accent);
}
/* INF - info type (gray) */
.status-inf {
--step-accent: #94a3b8;
- color: var(--step-accent);
}
/* HNT - hint type (yellow-green) */
.status-hnt {
--step-accent: #a3e635;
- color: var(--step-accent);
}
/* WRN - warning type (orange) */
.status-wrn {
--step-accent: #f97316;
- color: var(--step-accent);
}
/* ERR - error type (red) */
.status-err {
--step-accent: var(--color-error-text);
- color: var(--step-accent);
}
/* UTL - util type (gray-blue) */
.status-utl {
--step-accent: #64748b;
- color: var(--step-accent);
}
/* USR - user type (sky) */
.status-usr {
--step-accent: #38bdf8;
+}
+
+
+.process-step .status-badge{
+ color: var(--step-accent);
+}
+
+.process-step .kvps-key{
color: var(--step-accent);
}
+
/* Completed process group styling */
.process-group-completed {
opacity: 0.95;
@@ -302,7 +298,7 @@
/* Process Group Content - Animated expand/collapse */
.process-group-content {
- display: grid;
+ /* display: grid; */
grid-template-rows: 0fr;
opacity: 0;
margin-top: 0;
@@ -321,7 +317,7 @@
}
.process-group.expanded .process-group-content {
- grid-template-rows: 1fr;
+ /* grid-template-rows: 1fr; */
opacity: 1;
margin-top: var(--spacing-xs);
padding-top: var(--spacing-xs);
@@ -791,10 +787,6 @@
display: none;
}
-.process-step.message-util.show-util {
- display: flex;
-}
-
/* Thoughts KVP row */
.step-kvp.msg-thoughts {
display: none;
diff --git a/webui/css/messages.css b/webui/css/messages.css
index b72c6bbfb..9fc8d6437 100644
--- a/webui/css/messages.css
+++ b/webui/css/messages.css
@@ -17,7 +17,7 @@
scrollbar-color: #555 transparent;
padding-left: var(--spacing-sm);
padding-right: var(--spacing-sm);
- padding-bottom:5em;
+ padding-bottom: 5em;
}
#chat-history > *:first-child {
@@ -70,7 +70,6 @@
margin: 0;
}
-
.message.message-user {
text-align: end;
margin-bottom: var(--spacing-md);
@@ -117,13 +116,11 @@
color: #2e2e2e;
} */
-
.message-center {
align-self: center;
/* border-bottom-left-radius: unset; */
}
-
.message-followup .message {
border-radius: 0;
/* border-top-left-radius: var(--spacing-xxs); */
@@ -333,7 +330,9 @@
border-width: 4px 0 4px 6px;
border-color: transparent transparent transparent #ef4444;
opacity: 0.7;
- transition: transform 0.2s ease, opacity 0.15s ease;
+ transition:
+ transform 0.2s ease,
+ opacity 0.15s ease;
flex-shrink: 0;
font-size: 0;
margin-right: 2px;
@@ -375,10 +374,11 @@
opacity: 0;
margin-top: 0;
padding-top: 0;
- transition: grid-template-rows 0.25s ease-out,
- opacity 0.2s ease-out,
- margin-top 0.25s ease-out,
- padding-top 0.25s ease-out;
+ transition:
+ grid-template-rows 0.25s ease-out,
+ opacity 0.2s ease-out,
+ margin-top 0.25s ease-out,
+ padding-top 0.25s ease-out;
overflow: hidden;
}
@@ -415,7 +415,6 @@
scrollbar-color: var(--color-error-text) transparent;
}
-
/* Terminal styling moved to new terminal block above */
/* Agent and AI Info */
@@ -433,21 +432,24 @@
width: 100%;
}
+.kvps-val{
+ font-size: 0.75rem;
+}
+
.kvps-val pre {
white-space: pre-wrap; /* keep \n, collapse no spaces, allow wrapping */
word-break: break-word; /* optional – forces really long “words” to break */
font-family: var(--font-family-code);
font-optical-sizing: auto;
-webkit-font-optical-sizing: auto;
- font-size: 0.75rem;
}
.msg-kvps th,
.msg-kvps td {
- align-content: center;
+ align-content: start;
padding: 0.25rem;
padding-left: 0;
- text-align: left;
+ /* text-align: left; */
}
.msg-kvps th {
@@ -510,12 +512,19 @@
.kvps-key {
font-weight: 500;
font-size: var(--font-size-small);
- min-width: 7em;
+ /* min-width: 7em; */
+ max-width: 10em;
+ text-align: right;
+}
+
+.kvps-key .material-symbols-outlined{
+ font-size: var(--font-size-smaller);
}
.kvps-val {
/* margin: 0.65rem 0 0.65rem 0.4rem; */
white-space: pre-wrap;
+ font-size: var(--font-size-small);
}
.kvps-img {
@@ -531,18 +540,6 @@
width: 100%;
}
-.msg-json {
- display: none;
-}
-
-.msg-thoughts {
- display: auto;
-}
-
-.msg-thoughts .kvps-val {
- max-height: 20em;
- overflow: auto;
-}
.msg-content {
margin-bottom: 0;
@@ -550,13 +547,6 @@
overflow: hidden;
}
-.message-temp {
- display: none;
-}
-
-.message-temp:not([style*="display: none"]):last-of-type {
- display: block; /* or any style you want for visibility */
-}
/* Math (KaTeX) */
.katex {
@@ -568,8 +558,14 @@
/* Chat width controlled by --chat-max-width CSS variable (set via preferences, default 55em) */
@media (min-width: 1025px) {
#chat-history {
- padding-left: max(var(--spacing-sm), calc((100% - var(--chat-max-width, 55em)) / 2)) !important;
- padding-right: max(var(--spacing-sm), calc((100% - var(--chat-max-width, 55em)) / 2)) !important;
+ padding-left: max(
+ var(--spacing-sm),
+ calc((100% - var(--chat-max-width, 55em)) / 2)
+ ) !important;
+ padding-right: max(
+ var(--spacing-sm),
+ calc((100% - var(--chat-max-width, 55em)) / 2)
+ ) !important;
}
}
@@ -628,7 +624,6 @@
border-bottom: none;
}
-
.light-mode .message-user {
color: #4e4e4e;
}
@@ -647,14 +642,17 @@
max-width: 25em;
max-height: 25em;
border-radius: var(--border-radius);
- background: repeating-linear-gradient(45deg, var(--color-panel) 0 10px, var(--color-chat-background) 10px 20px);
+ background: repeating-linear-gradient(
+ 45deg,
+ var(--color-panel) 0 10px,
+ var(--color-chat-background) 10px 20px
+ );
}
-.message-agent-response .msg-content .message-markdown-image-wrap img:hover{
+.message-agent-response .msg-content .message-markdown-image-wrap img:hover {
transform: translateY(-2px);
}
-
.msg-content h1 {
font-size: 1.25em;
font-weight: 800;
@@ -767,7 +765,7 @@
width: 100%;
justify-content: end;
margin-top: 4em;
- margin-bottom:4em;
+ margin-bottom: 4em;
}
.message-container {
diff --git a/webui/index.css b/webui/index.css
index b3769d1ee..46574b8f2 100644
--- a/webui/index.css
+++ b/webui/index.css
@@ -1099,45 +1099,6 @@ input:checked + .slider:before {
}
}
-@media (max-width: 768px) {
- /* .copy-button {
- display: none !important;
- } */
-
- /* .msg-content span,
- .kvps-val,
- .message-text span {
- cursor: pointer;
- position: relative;
- } */
-
- /* .msg-thoughts span::after,
- .msg-content span::after,
- .kvps-val::after,
- .message-text::after {
- content: "Copied!";
- position: absolute;
- opacity: 0;
- font-family: "Rubik", Arial, Helvetica, sans-serif;
- font-size: 0.7rem;
- padding: 6px var(--spacing-sm);
- -webkit-transition: opacity var(--transition-speed) ease-in-out;
- transition: opacity var(--transition-speed) ease-in-out;
- right: 0px;
- top: 0px;
- background-color: var(--color-background);
- border: none;
- border-radius: 5px;
- color: inherit;
- } */
-
- /* .msg-thoughts span.copied::after,
- .msg-content span.copied::after,
- .kvps-val.copied::after,
- .message-text.copied::after {
- opacity: 1;
- } */
-}
@media (max-height: 600px) {
/* consistent font sizing */
diff --git a/webui/index.js b/webui/index.js
index 648848ad7..3f11e9e9b 100644
--- a/webui/index.js
+++ b/webui/index.js
@@ -66,9 +66,9 @@ export async function sendMessage() {
: "";
// Render user message with attachments
- setMessage(messageId, "user", heading, message, {
+ setMessage({ id: messageId, type: "user", heading, content: message, kvps: {
// attachments: attachmentsWithUrls, // skip here, let the backend properly log them
- });
+ }});
// sleep one frame to render the message before upload starts - better UX
sleep(0);
@@ -200,8 +200,8 @@ async function updateUserTime() {
updateUserTime();
setInterval(updateUserTime, 1000);
-function setMessage(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, /* tokensIn = 0, tokensOut = 0, */ agentNumber = 0) {
- const result = msgs.setMessage(id, type, heading, content, kvps, timestamp, durationMs, /* tokensIn, tokensOut, */ agentNumber);
+function setMessage(...params) {
+ const result = msgs.setMessage(...params);
const chatHistoryEl = document.getElementById("chat-history");
if (preferencesStore.autoScroll && chatHistoryEl) {
chatHistoryEl.scrollTop = chatHistoryEl.scrollHeight;
@@ -317,19 +317,7 @@ export async function poll() {
if (lastLogVersion != response.log_version) {
updated = true;
for (const log of response.logs) {
- const messageId = log.id || log.no; // Use log.id if available
- setMessage(
- messageId,
- log.type,
- log.heading,
- log.content,
- log.kvps,
- log.timestamp,
- log.duration_ms,
- // log.tokens_in,
- // log.tokens_out,
- log.agent_number || 0 // Agent number for identifying main/subordinate agents
- );
+ setMessage(log);
}
afterMessagesUpdate(response.logs);
applyModeSteps(preferencesStore.detailMode, preferencesStore.showUtils);
diff --git a/webui/js/messages.js b/webui/js/messages.js
index 24f41343b..fc5fa1217 100644
--- a/webui/js/messages.js
+++ b/webui/js/messages.js
@@ -73,7 +73,7 @@ const TYPE_STATUS_CLASSES = {
done: "status-end"
};
-const chatHistory = document.getElementById("chat-history");
+let chatHistory = null;
// handlers for log message rendering
export function getMessageHandler(type) {
@@ -124,7 +124,7 @@ function setActiveProcessGroup(group) {
if (group.classList.contains("active")) return;
// Clear active + shiny from all other groups
- document.querySelectorAll(".process-group.active").forEach(g => {
+ getChatHistoryEl().querySelectorAll(".process-group.active").forEach(g => {
if (g !== group) {
g.classList.remove("active");
g.querySelectorAll(".step-title.shiny-text").forEach(el => el.classList.remove("shiny-text"));
@@ -137,13 +137,14 @@ function setActiveProcessGroup(group) {
export function clearActiveStepShine() {
// Clear all shiny step titles in process steps
- document.querySelectorAll(".process-step .step-title.shiny-text").forEach((el) => {
+ getChatHistoryEl().querySelectorAll(".process-step .step-title.shiny-text").forEach((el) => {
el.classList.remove("shiny-text");
});
}
function getChatHistoryEl() {
- return chatHistory || document.getElementById("chat-history");
+ if(!chatHistory) chatHistory = document.getElementById("chat-history");
+ return chatHistory;
}
function getLastMessageContainer() {
@@ -224,9 +225,11 @@ function updateBadgeText(badge, newCode) {
// entrypoint called from poll/WS communication, this is how all messages are rendered and updated
-export function setMessage(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+// input is raw log format
+export function setMessage({ no, id, type, heading, content, kvps, timestamp, agentno, ...additional }) {
const handler = getMessageHandler(type);
- return handler(id, type, heading, content, kvps, timestamp, durationMs, agentNumber);
+ // prefer log ID if set to match user message created on frontend with backend updates
+ return handler({ id: id || no, type, heading, content, kvps, timestamp, agentno, ...additional });
}
function getOrCreateMessageContainer(id, position, containerClasses = [], forceNewGroup = false) {
@@ -287,8 +290,7 @@ function buildDetailPayload(stepData) {
content: stepData.content,
kvps: stepData.kvps,
timestamp: stepData.timestamp,
- durationMs: stepData.durationMs,
- agentNumber: stepData.agentNumber,
+ agentno: stepData.agentno,
toolName: stepData.toolName,
statusCode: stepData.statusCode,
statusClass: stepData.statusClass
@@ -310,17 +312,24 @@ function buildStepCopyContent(stepData) {
return parts.join("\n\n");
}
-function drawProcessStep(id, title, statusClass, statusCode, kvps = null, detailHandler = null, copyContent = null, speakContent = null, options = {}) {
- const {
- type = "agent",
- heading = null,
- content = null,
- timestamp = null,
- durationMs = null,
- agentNumber = 0,
- toolName = null,
- detailPayload = null
- } = options;
+function drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps = null,
+ detailHandler = null,
+ copyContent = null,
+ speakContent = null,
+ type = "agent",
+ heading = null,
+ content = null,
+ timestamp = null,
+ agentno = 0,
+ toolName = null,
+ detailPayload = null,
+ ...additional
+}) {
const group = getOrCreateProcessGroup(id);
const stepId = `process-step-${id}`;
@@ -332,8 +341,7 @@ function drawProcessStep(id, title, statusClass, statusCode, kvps = null, detail
content,
kvps,
timestamp,
- durationMs,
- agentNumber,
+ agentno,
toolName,
statusCode,
statusClass
@@ -344,12 +352,10 @@ function drawProcessStep(id, title, statusClass, statusCode, kvps = null, detail
const copyText = copyContent ?? buildStepCopyContent(stepData);
const speakText = speakContent ?? copyText;
- if (step) {
+ if (step)
updateProcessStep(step, stepData, detailData, copyText, speakText, detailHandler);
- return step;
- }
-
- step = addProcessStep(group, stepData, detailData, copyText, speakText, detailHandler);
+ else
+ step = addProcessStep(group, stepData, detailData, copyText, speakText, detailHandler);
return step;
}
@@ -537,7 +543,7 @@ export function addBlankTargetsToLinks(str) {
return doc.body.innerHTML;
}
-export function drawMessageDefault(id, type, heading, content, kvps = null) {
+export function drawMessageDefault({ id, heading, content, kvps = null, ...additional }) {
return drawStandaloneMessage(id, heading, content, {
position: "left",
containerClasses: ["ai-container"],
@@ -548,37 +554,44 @@ export function drawMessageDefault(id, type, heading, content, kvps = null) {
});
}
-export function drawMessageAgent(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+export function drawMessageAgent({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type);
const statusClass = getStatusClass(type);
const toolName = kvps?.tool_name || null;
+ let displayKvps = { "icon://lightbulb": kvps?.thoughts, "icon://step": heading, "icon school":"dummy" }
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps: displayKvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber,
+ agentno,
toolName
});
}
-export function drawMessageResponse(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
- if (agentNumber && agentNumber > 0) {
+export function drawMessageResponse({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
+ if (agentno && agentno > 0) {
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type);
const statusClass = getStatusClass(type);
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber
+ agentno
});
}
@@ -599,7 +612,7 @@ export function drawMessageResponse(id, type, heading, content, kvps = null, tim
}
-export function drawMessageUser(id, type, heading, content, kvps = null) {
+export function drawMessageUser({ id, heading, content, kvps = null, ...additional }) {
const messageContainer = getOrCreateMessageContainer(id, "right", ["user-container"], true);
// Find existing message div or create new one
@@ -707,92 +720,107 @@ export function drawMessageUser(id, type, heading, content, kvps = null) {
addActionButtonsToElement(messageDiv, { copyContent: content || "", speakContent: content || "" });
}
-export function drawMessageTool(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+export function drawMessageTool({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
const toolName = kvps?.tool_name || null;
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type, toolName);
const statusClass = getStatusClass(type, toolName);
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber,
+ agentno,
toolName
});
}
-export function drawMessageCodeExe(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+export function drawMessageCodeExe({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type);
const statusClass = getStatusClass(type);
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber
+ agentno
});
}
-export function drawMessageBrowser(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+export function drawMessageBrowser({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type);
const statusClass = getStatusClass(type);
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber
+ agentno
});
}
-export function drawMessageMcp(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+export function drawMessageMcp({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
const toolName = kvps?.tool_name || null;
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type, toolName);
const statusClass = getStatusClass(type, toolName);
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber,
+ agentno,
toolName
});
}
-export function drawMessageSubagent(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+export function drawMessageSubagent({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type);
const statusClass = getStatusClass(type);
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber
+ agentno
});
}
-export function drawMessageInfo(id, type, heading, content, kvps = null) {
+export function drawMessageInfo({ id, heading, content, kvps = null, ...additional }) {
return drawStandaloneMessage(id, heading, content, {
position: "mid",
containerClasses: ["ai-container", "center-container"],
@@ -801,55 +829,64 @@ export function drawMessageInfo(id, type, heading, content, kvps = null) {
});
}
-export function drawMessageUtil(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+export function drawMessageUtil({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type);
const statusClass = getStatusClass(type);
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber
+ agentno
});
}
-export function drawMessageHint(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+export function drawMessageHint({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type);
const statusClass = getStatusClass(type);
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber
+ agentno
});
}
-export function drawMessageProgress(id, type, heading, content, kvps = null, timestamp = null, durationMs = null, agentNumber = 0) {
+export function drawMessageProgress({ id, type, heading, content, kvps = null, timestamp = null, agentno = 0, ...additional }) {
const title = getStepTitle(heading, kvps, type);
const statusCode = getStatusCode(type);
const statusClass = getStatusClass(type);
- return drawProcessStep(id, title, statusClass, statusCode, kvps, null, null, null, {
+ return drawProcessStep({
+ id,
+ title,
+ statusClass,
+ statusCode,
+ kvps,
type,
heading,
content,
- kvps,
timestamp,
- durationMs,
- agentNumber
+ agentno
});
}
-export function drawMessageWarning(id, type, heading, content, kvps = null) {
+export function drawMessageWarning({ id, heading, content, kvps = null, ...additional }) {
return drawStandaloneMessage(id, heading, content, {
position: "mid",
containerClasses: ["ai-container", "center-container"],
@@ -858,7 +895,7 @@ export function drawMessageWarning(id, type, heading, content, kvps = null) {
});
}
-export function drawMessageError(id, type, heading, content, kvps = null) {
+export function drawMessageError({ id, heading, content, kvps = null, ...additional }) {
const messageContainer = getOrCreateMessageContainer(id, "mid", ["ai-container", "center-container"]);
// Create or get the message div
@@ -1010,9 +1047,6 @@ function drawKvpsIncremental(container, kvps, latex) {
// Update row classes
row.className = "kvps-row";
- if (key === "thoughts") {
- row.classList.add("msg-thoughts");
- }
// Handle key cell
let th = row.querySelector(".kvps-key");
@@ -1083,11 +1117,12 @@ function drawKvpsIncremental(container, kvps, latex) {
imageViewerStore.open(imgElement.src, { refreshInterval: 1000 });
});
} else {
- const pre = document.createElement("pre");
+ // const pre = document.createElement("pre");
const span = document.createElement("span");
span.innerHTML = convertHTML(value);
- pre.appendChild(span);
- tdiv.appendChild(pre);
+ // pre.appendChild(span);
+ // tdiv.appendChild(pre);
+ tdiv.appendChild(span)
// Add action buttons to the row
// const row = tdiv.closest(".kvps-row");
@@ -1430,13 +1465,13 @@ function addStepCollapseInteractionHandlers(stepElement) {
/**
* Find parent delegation step for nested agents (DOM-first, reverse scan).
*/
-function findParentDelegationStep(group, agentNumber) {
- if (!group || agentNumber <= 0) return null;
+function findParentDelegationStep(group, agentno) {
+ if (!group || agentno <= 0) return null;
const steps = group.querySelectorAll(".process-step");
for (let i = steps.length - 1; i >= 0; i -= 1) {
const step = steps[i];
const stepAgent = Number(step.getAttribute("data-agent-number"));
- if (stepAgent === agentNumber - 1 && step.getAttribute("data-tool-name") === "call_subordinate") {
+ if (stepAgent === agentno - 1 && step.getAttribute("data-tool-name") === "call_subordinate") {
return step;
}
}
@@ -1455,8 +1490,7 @@ function addProcessStep(group, stepData, detailPayload, copyContent, speakConten
content,
kvps,
timestamp,
- durationMs,
- agentNumber,
+ agentno,
toolName,
statusCode,
statusClass
@@ -1471,7 +1505,7 @@ function addProcessStep(group, stepData, detailPayload, copyContent, speakConten
step.classList.add("process-step");
step.setAttribute("data-type", type);
step.setAttribute("data-step-id", id);
- step.setAttribute("data-agent-number", agentNumber);
+ step.setAttribute("data-agent-number", agentno);
if (toolName) {
step.setAttribute("data-tool-name", toolName);
@@ -1495,19 +1529,14 @@ function addProcessStep(group, stepData, detailPayload, copyContent, speakConten
}
}
- // Store duration from backend (used for final duration calculation)
- if (durationMs != null) {
- step.setAttribute("data-duration-ms", durationMs);
- }
-
- // Add message-util class for utility/info types (controlled by showUtils preference)
- if (type === "util" || type === "info" || type === "hint") {
- step.classList.add("message-util");
- // Apply current preference state
- if (preferencesStore.showUtils) {
- step.classList.add("show-util");
- }
- }
+ // // Add message-util class for utility/info types (controlled by showUtils preference)
+ // if (type === "util" || type === "info" || type === "hint") {
+ // step.classList.add("message-util");
+ // // Apply current preference state
+ // if (preferencesStore.showUtils) {
+ // step.classList.add("show-util");
+ // }
+ // }
// Determine if this new step should be expanded
const detailMode = preferencesStore.detailMode;
@@ -1608,7 +1637,7 @@ function addProcessStep(group, stepData, detailPayload, copyContent, speakConten
let appendTarget = stepsContainer;
// Check if this step belongs to a subordinate agent
- const parentStep = findParentDelegationStep(group, agentNumber);
+ const parentStep = findParentDelegationStep(group, agentno);
if (parentStep) {
appendTarget = getNestedContainer(parentStep);
step.classList.add("nested-step");
@@ -1655,8 +1684,7 @@ function updateProcessStep(stepElement, stepData, detailPayload, copyContent, sp
content,
kvps,
timestamp,
- durationMs,
- agentNumber,
+ agentno,
toolName,
statusCode,
statusClass
@@ -1672,12 +1700,8 @@ function updateProcessStep(stepElement, stepData, detailPayload, copyContent, sp
stepElement.setAttribute("data-timestamp", timestamp);
}
- if (durationMs != null) {
- stepElement.setAttribute("data-duration-ms", durationMs);
- }
-
- if (agentNumber !== undefined) {
- stepElement.setAttribute("data-agent-number", agentNumber);
+ if (agentno !== undefined) {
+ stepElement.setAttribute("data-agent-number", agentno);
}
const toolNameToUse = resolveToolName(type, kvps, stepElement) || toolName;
@@ -1837,6 +1861,8 @@ function cleanStepTitle(text, maxLength) {
function renderStepDetailContent(container, content, kvps, type = null) {
container.innerHTML = "";
+ drawKvpsIncremental(container, kvps)
+
// Special handling for response type - show content as markdown (for subordinate responses)
if (type === "response" && content && content.trim()) {
const responseDiv = document.createElement("div");
@@ -2121,25 +2147,14 @@ function updateProcessGroupHeader(group) {
// Update duration metric
const durationMetricEl = metricsEl?.querySelector(".metric-duration .metric-value");
if (durationMetricEl && steps.length > 0) {
- // Calculate accumulated duration from backend data
- let accumulatedMs = 0;
- steps.forEach(step => {
- accumulatedMs += parseInt(step.getAttribute("data-duration-ms") || "0", 10);
- });
-
- // Check if last step is still in progress (no duration_ms set yet)
+ const firstTimestampMs = parseInt(steps[0]?.getAttribute("data-timestamp") || "0", 10);
+
const lastStep = steps[steps.length - 1];
- const lastStepDuration = lastStep.getAttribute("data-duration-ms");
- const lastStepTimestamp = lastStep.getAttribute("data-timestamp");
-
- if (lastStepDuration == null && lastStepTimestamp) {
- // Last step is in progress - add live elapsed time for this step only
- const lastStepStartMs = parseFloat(lastStepTimestamp) * 1000;
- const liveElapsedMs = Math.max(0, Date.now() - lastStepStartMs);
- accumulatedMs += liveElapsedMs;
- }
-
- durationMetricEl.textContent = formatDuration(accumulatedMs);
+ const lastTimestampMs = parseInt(lastStep.getAttribute("data-timestamp") || "0", 10);
+
+ const totalDurationMs = Math.max(0, lastTimestampMs - firstTimestampMs);
+
+ durationMetricEl.textContent = formatDuration(totalDurationMs);
}
if (steps.length > 0) {
@@ -2226,13 +2241,11 @@ function markProcessGroupComplete(group, responseTitle) {
});
}
- // Calculate final duration from backend data (sum of all step durations)
+ // Calculate final duration from backend data (difference between first and last timestamps)
const steps = group.querySelectorAll(".process-step");
- let totalDurationMs = 0;
- steps.forEach(step => {
- const durationMs = parseInt(step.getAttribute("data-duration-ms") || "0", 10);
- totalDurationMs += durationMs;
- });
+ const firstTimestampMs = parseInt(steps[0]?.getAttribute("data-timestamp") || "0", 10);
+ const lastTimestampMs = parseInt(steps[steps.length - 1]?.getAttribute("data-timestamp") || "0", 10);
+ const totalDurationMs = Math.max(0, lastTimestampMs - firstTimestampMs);
// Update duration metric with final value from backend
const metricsEl = group.querySelector(".group-metrics");