feat: add immediate context compaction API, UI button, and /compact slash command

- Add POST /bots/:bot_id/sessions/:session_id/compact endpoint for
  synchronous context compaction with fallback to chat model when no
  dedicated compaction model is configured
- Add "Compact Now" button to session info panel in the web UI
- Add /compact slash command for triggering compaction from chat
- Regenerate OpenAPI spec and TypeScript SDK
This commit is contained in:
Acbox
2026-04-14 21:30:05 +08:00
parent 6328281fc2
commit 27d2b99301
15 changed files with 529 additions and 40 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
+44 -2
View File
@@ -1054,6 +1054,12 @@ export type HandlersTokenUsageResponse = {
schedule?: Array<HandlersDailyTokenUsage>;
};
export type HandlersTriggerCompactResponse = {
message_count?: number;
status?: string;
summary?: string;
};
export type HandlersCreateSessionRequest = {
channel_type?: string;
metadata?: {
@@ -1585,7 +1591,6 @@ export type SettingsSettings = {
compaction_model_id?: string;
compaction_ratio?: number;
compaction_threshold?: number;
context_token_budget?: number;
discuss_probe_model_id?: string;
heartbeat_enabled?: boolean;
heartbeat_interval?: number;
@@ -1610,7 +1615,6 @@ export type SettingsUpsertRequest = {
compaction_model_id?: string;
compaction_ratio?: number;
compaction_threshold?: number;
context_token_budget?: number;
discuss_probe_model_id?: string;
heartbeat_enabled?: boolean;
heartbeat_interval?: number;
@@ -5284,6 +5288,44 @@ export type PatchBotsByBotIdSessionsBySessionIdResponses = {
export type PatchBotsByBotIdSessionsBySessionIdResponse = PatchBotsByBotIdSessionsBySessionIdResponses[keyof PatchBotsByBotIdSessionsBySessionIdResponses];
export type PostBotsByBotIdSessionsBySessionIdCompactData = {
body?: never;
path: {
/**
* Bot ID
*/
bot_id: string;
/**
* Session ID
*/
session_id: string;
};
query?: never;
url: '/bots/{bot_id}/sessions/{session_id}/compact';
};
export type PostBotsByBotIdSessionsBySessionIdCompactErrors = {
/**
* Bad Request
*/
400: HandlersErrorResponse;
/**
* Internal Server Error
*/
500: HandlersErrorResponse;
};
export type PostBotsByBotIdSessionsBySessionIdCompactError = PostBotsByBotIdSessionsBySessionIdCompactErrors[keyof PostBotsByBotIdSessionsBySessionIdCompactErrors];
export type PostBotsByBotIdSessionsBySessionIdCompactResponses = {
/**
* OK
*/
200: HandlersTriggerCompactResponse;
};
export type PostBotsByBotIdSessionsBySessionIdCompactResponse = PostBotsByBotIdSessionsBySessionIdCompactResponses[keyof PostBotsByBotIdSessionsBySessionIdCompactResponses];
export type GetBotsByBotIdSessionsBySessionIdStatusData = {
body?: never;
path: {