mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
Adds centralized support to log slash commands + sub commands (#5128)
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
FlashFallbackEvent,
|
||||
LoopDetectedEvent,
|
||||
FlashDecidedToContinueEvent,
|
||||
SlashCommandEvent,
|
||||
} from '../types.js';
|
||||
import { EventMetadataKey } from './event-metadata-key.js';
|
||||
import { Config } from '../../config/config.js';
|
||||
@@ -40,6 +41,7 @@ const end_session_event_name = 'end_session';
|
||||
const flash_fallback_event_name = 'flash_fallback';
|
||||
const loop_detected_event_name = 'loop_detected';
|
||||
const flash_decided_to_continue_event_name = 'flash_decided_to_continue';
|
||||
const slash_command_event_name = 'slash_command';
|
||||
|
||||
export interface LogResponse {
|
||||
nextRequestWaitMs?: number;
|
||||
@@ -528,6 +530,25 @@ export class ClearcutLogger {
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
logSlashCommandEvent(event: SlashCommandEvent): void {
|
||||
const data = [
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_SLASH_COMMAND_NAME,
|
||||
value: JSON.stringify(event.command),
|
||||
},
|
||||
];
|
||||
|
||||
if (event.subcommand) {
|
||||
data.push({
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_SLASH_COMMAND_SUBCOMMAND,
|
||||
value: JSON.stringify(event.subcommand),
|
||||
});
|
||||
}
|
||||
|
||||
this.enqueueLogEvent(this.createLogEvent(slash_command_event_name, data));
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
logEndSessionEvent(event: EndSessionEvent): void {
|
||||
const data = [
|
||||
{
|
||||
|
||||
@@ -163,6 +163,16 @@ export enum EventMetadataKey {
|
||||
|
||||
// Logs the type of loop detected.
|
||||
GEMINI_CLI_LOOP_DETECTED_TYPE = 38,
|
||||
|
||||
// ==========================================================================
|
||||
// Slash Command Event Keys
|
||||
// ===========================================================================
|
||||
|
||||
// Logs the name of the slash command.
|
||||
GEMINI_CLI_SLASH_COMMAND_NAME = 41,
|
||||
|
||||
// Logs the subcommand of the slash command.
|
||||
GEMINI_CLI_SLASH_COMMAND_SUBCOMMAND = 42,
|
||||
}
|
||||
|
||||
export function getEventMetadataKey(
|
||||
|
||||
Reference in New Issue
Block a user