feat: add session info panel with message count, context usage, cache stats, and skills

Add GET /bots/:bot_id/sessions/:session_id/info API endpoint that returns
per-session message count, latest input token usage with model context window,
aggregated KV cache hit rate, and skills invoked via use_skill tool calls.
Frontend Info tab in the right sidebar now displays this data in a compact
key-value layout with a context usage progress bar and clickable skill links.
This commit is contained in:
Acbox
2026-04-02 03:17:28 +08:00
parent b308c27f74
commit b3c783fb0b
16 changed files with 898 additions and 11 deletions
+105
View File
@@ -4386,6 +4386,63 @@
}
}
},
"/bots/{bot_id}/sessions/{session_id}/info": {
"get": {
"description": "Get aggregated info for a chat session including message count, context usage, cache stats, and used skills",
"tags": [
"sessions"
],
"summary": "Get session info",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Session ID",
"name": "session_id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Optional model UUID override for context window",
"name": "model_id",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.SessionInfoResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{bot_id}/settings": {
"get": {
"description": "Get agent settings for current user",
@@ -10866,6 +10923,23 @@
}
}
},
"handlers.CacheStats": {
"type": "object",
"properties": {
"cache_hit_rate": {
"type": "number"
},
"cache_read_tokens": {
"type": "integer"
},
"cache_write_tokens": {
"type": "integer"
},
"total_input_tokens": {
"type": "integer"
}
}
},
"handlers.ChannelMeta": {
"type": "object",
"properties": {
@@ -10892,6 +10966,17 @@
}
}
},
"handlers.ContextUsage": {
"type": "object",
"properties": {
"context_window": {
"type": "integer"
},
"used_tokens": {
"type": "integer"
}
}
},
"handlers.CreateContainerRequest": {
"type": "object",
"properties": {
@@ -11350,6 +11435,26 @@
}
}
},
"handlers.SessionInfoResponse": {
"type": "object",
"properties": {
"cache_stats": {
"$ref": "#/definitions/handlers.CacheStats"
},
"context_usage": {
"$ref": "#/definitions/handlers.ContextUsage"
},
"message_count": {
"type": "integer"
},
"skills": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"handlers.SkillItem": {
"type": "object",
"properties": {