feat(gateway): expose context usage and warning events

This commit is contained in:
William Valentin
2026-02-16 15:44:09 -08:00
parent 8758ea8f1c
commit fee8be1de0
11 changed files with 645 additions and 334 deletions
+20
View File
@@ -93,6 +93,7 @@ export type EventType =
| 'content'
| 'tool_start'
| 'tool_end'
| 'context_warning'
| 'attachment'
| 'done'
| 'error';
@@ -115,6 +116,25 @@ export interface ToolEndEventData {
};
}
export interface ContextWarningEventData {
level: 'warning' | 'checkpoint' | 'critical';
message: string;
budget: {
estimatedTokens: number;
contextWindow: number;
remainingTokens: number;
usagePct: number;
thresholdPct: number;
thresholdTokens: number;
shouldCompact: boolean;
};
actions: {
checkpointSaved: boolean;
autoCompacted: boolean;
checkpointNamespace?: string;
};
}
export interface AttachmentEventData {
mimeType: string;
data?: string;