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
+70
View File
@@ -1190,6 +1190,17 @@ definitions:
type: string
type: array
type: object
handlers.CacheStats:
properties:
cache_hit_rate:
type: number
cache_read_tokens:
type: integer
cache_write_tokens:
type: integer
total_input_tokens:
type: integer
type: object
handlers.ChannelMeta:
properties:
capabilities:
@@ -1207,6 +1218,13 @@ definitions:
user_config_schema:
$ref: '#/definitions/channel.ConfigSchema'
type: object
handlers.ContextUsage:
properties:
context_window:
type: integer
used_tokens:
type: integer
type: object
handlers.CreateContainerRequest:
properties:
image:
@@ -1503,6 +1521,19 @@ definitions:
version:
type: integer
type: object
handlers.SessionInfoResponse:
properties:
cache_stats:
$ref: '#/definitions/handlers.CacheStats'
context_usage:
$ref: '#/definitions/handlers.ContextUsage'
message_count:
type: integer
skills:
items:
type: string
type: array
type: object
handlers.SkillItem:
properties:
content:
@@ -5655,6 +5686,45 @@ paths:
summary: Update a session
tags:
- sessions
/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
parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Session ID
in: path
name: session_id
required: true
type: string
- description: Optional model UUID override for context window
in: query
name: model_id
type: string
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'
summary: Get session info
tags:
- sessions
/bots/{bot_id}/settings:
delete:
description: Remove agent settings for current user