feat(container): add current container metrics view

Expose a dedicated container metrics endpoint and surface current CPU, memory, and root filesystem usage in the bot container view. This gives operators a quick health snapshot while degrading cleanly on unsupported backends.
This commit is contained in:
Acbox
2026-04-24 15:10:47 +08:00
parent 8136ef6ed6
commit e4aca0db13
20 changed files with 1198 additions and 6 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+68
View File
@@ -882,10 +882,39 @@ export type HandlersChannelMeta = {
user_config_schema?: ChannelConfigSchema;
};
export type HandlersContainerCpuMetricsResponse = {
kernel_nanoseconds?: number;
usage_nanoseconds?: number;
usage_percent?: number;
user_nanoseconds?: number;
};
export type HandlersContainerGpuRequest = {
devices?: Array<string>;
};
export type HandlersContainerMemoryMetricsResponse = {
limit_bytes?: number;
usage_bytes?: number;
usage_percent?: number;
};
export type HandlersContainerMetricsPayloadResponse = {
cpu?: HandlersContainerCpuMetricsResponse;
memory?: HandlersContainerMemoryMetricsResponse;
storage?: HandlersContainerStorageMetricsResponse;
};
export type HandlersContainerMetricsStatusResponse = {
exists?: boolean;
task_running?: boolean;
};
export type HandlersContainerStorageMetricsResponse = {
path?: string;
used_bytes?: number;
};
export type HandlersContextUsage = {
context_window?: number;
used_tokens?: number;
@@ -979,6 +1008,15 @@ export type HandlersFsWriteRequest = {
path?: string;
};
export type HandlersGetContainerMetricsResponse = {
backend?: string;
metrics?: HandlersContainerMetricsPayloadResponse;
sampled_at?: string;
status?: HandlersContainerMetricsStatusResponse;
supported?: boolean;
unsupported_reason?: string;
};
export type HandlersGetContainerResponse = {
cdi_devices?: Array<string>;
container_id?: string;
@@ -3038,6 +3076,36 @@ export type PostBotsByBotIdContainerFsWriteResponses = {
export type PostBotsByBotIdContainerFsWriteResponse = PostBotsByBotIdContainerFsWriteResponses[keyof PostBotsByBotIdContainerFsWriteResponses];
export type GetBotsByBotIdContainerMetricsData = {
body?: never;
path: {
/**
* Bot ID
*/
bot_id: string;
};
query?: never;
url: '/bots/{bot_id}/container/metrics';
};
export type GetBotsByBotIdContainerMetricsErrors = {
/**
* Internal Server Error
*/
500: HandlersErrorResponse;
};
export type GetBotsByBotIdContainerMetricsError = GetBotsByBotIdContainerMetricsErrors[keyof GetBotsByBotIdContainerMetricsErrors];
export type GetBotsByBotIdContainerMetricsResponses = {
/**
* OK
*/
200: HandlersGetContainerMetricsResponse;
};
export type GetBotsByBotIdContainerMetricsResponse = GetBotsByBotIdContainerMetricsResponses[keyof GetBotsByBotIdContainerMetricsResponses];
export type DeleteBotsByBotIdContainerSkillsData = {
/**
* Delete skills payload