mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-22 09:47:47 +00:00
# 🚀 Sync Gemini CLI v0.2.1 - Major Feature Update (#483)
This commit is contained in:
@@ -34,6 +34,7 @@ import {
|
||||
logUserPrompt,
|
||||
logToolCall,
|
||||
logFlashFallback,
|
||||
logChatCompression,
|
||||
} from './loggers.js';
|
||||
import { ToolCallDecision } from './tool-call-decision.js';
|
||||
import {
|
||||
@@ -43,12 +44,15 @@ import {
|
||||
ToolCallEvent,
|
||||
UserPromptEvent,
|
||||
FlashFallbackEvent,
|
||||
makeChatCompressionEvent,
|
||||
} from './types.js';
|
||||
import * as metrics from './metrics.js';
|
||||
import * as sdk from './sdk.js';
|
||||
import { vi, describe, beforeEach, it, expect } from 'vitest';
|
||||
import { GenerateContentResponseUsageMetadata } from '@google/genai';
|
||||
import * as uiTelemetry from './uiTelemetry.js';
|
||||
import { makeFakeConfig } from '../test-utils/config.js';
|
||||
import { QwenLogger } from './qwen-logger/qwen-logger.js';
|
||||
|
||||
describe('loggers', () => {
|
||||
const mockLogger = {
|
||||
@@ -68,6 +72,45 @@ describe('loggers', () => {
|
||||
vi.setSystemTime(new Date('2025-01-01T00:00:00.000Z'));
|
||||
});
|
||||
|
||||
describe('logChatCompression', () => {
|
||||
beforeEach(() => {
|
||||
vi.spyOn(metrics, 'recordChatCompressionMetrics');
|
||||
vi.spyOn(QwenLogger.prototype, 'logChatCompressionEvent');
|
||||
});
|
||||
|
||||
it('logs the chat compression event to QwenLogger', () => {
|
||||
const mockConfig = makeFakeConfig();
|
||||
|
||||
const event = makeChatCompressionEvent({
|
||||
tokens_before: 9001,
|
||||
tokens_after: 9000,
|
||||
});
|
||||
|
||||
logChatCompression(mockConfig, event);
|
||||
|
||||
expect(QwenLogger.prototype.logChatCompressionEvent).toHaveBeenCalledWith(
|
||||
event,
|
||||
);
|
||||
});
|
||||
|
||||
it('records the chat compression event to OTEL', () => {
|
||||
const mockConfig = makeFakeConfig();
|
||||
|
||||
logChatCompression(
|
||||
mockConfig,
|
||||
makeChatCompressionEvent({
|
||||
tokens_before: 9001,
|
||||
tokens_after: 9000,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(metrics.recordChatCompressionMetrics).toHaveBeenCalledWith(
|
||||
mockConfig,
|
||||
{ tokens_before: 9001, tokens_after: 9000 },
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('logCliConfiguration', () => {
|
||||
it('should log the cli configuration', () => {
|
||||
const mockConfig = {
|
||||
@@ -484,6 +527,7 @@ describe('loggers', () => {
|
||||
success: true,
|
||||
decision: ToolCallDecision.ACCEPT,
|
||||
prompt_id: 'prompt-id-1',
|
||||
tool_type: 'native',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -493,6 +537,7 @@ describe('loggers', () => {
|
||||
100,
|
||||
true,
|
||||
ToolCallDecision.ACCEPT,
|
||||
'native',
|
||||
);
|
||||
|
||||
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
||||
@@ -547,6 +592,7 @@ describe('loggers', () => {
|
||||
success: false,
|
||||
decision: ToolCallDecision.REJECT,
|
||||
prompt_id: 'prompt-id-2',
|
||||
tool_type: 'native',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -556,6 +602,7 @@ describe('loggers', () => {
|
||||
100,
|
||||
false,
|
||||
ToolCallDecision.REJECT,
|
||||
'native',
|
||||
);
|
||||
|
||||
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
||||
@@ -613,6 +660,7 @@ describe('loggers', () => {
|
||||
success: true,
|
||||
decision: ToolCallDecision.MODIFY,
|
||||
prompt_id: 'prompt-id-3',
|
||||
tool_type: 'native',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -622,6 +670,7 @@ describe('loggers', () => {
|
||||
100,
|
||||
true,
|
||||
ToolCallDecision.MODIFY,
|
||||
'native',
|
||||
);
|
||||
|
||||
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
||||
@@ -677,6 +726,7 @@ describe('loggers', () => {
|
||||
duration_ms: 100,
|
||||
success: true,
|
||||
prompt_id: 'prompt-id-4',
|
||||
tool_type: 'native',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -686,6 +736,7 @@ describe('loggers', () => {
|
||||
100,
|
||||
true,
|
||||
undefined,
|
||||
'native',
|
||||
);
|
||||
|
||||
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
||||
@@ -746,6 +797,7 @@ describe('loggers', () => {
|
||||
error_type: ToolErrorType.UNKNOWN,
|
||||
'error.type': ToolErrorType.UNKNOWN,
|
||||
prompt_id: 'prompt-id-5',
|
||||
tool_type: 'native',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -755,6 +807,7 @@ describe('loggers', () => {
|
||||
100,
|
||||
false,
|
||||
undefined,
|
||||
'native',
|
||||
);
|
||||
|
||||
expect(mockUiEvent.addEvent).toHaveBeenCalledWith({
|
||||
|
||||
Reference in New Issue
Block a user