refactor: remove unnecessary assertion (#2579)
This commit is contained in:
parent
65a58c3b03
commit
9ae2595bfd
|
@ -43,7 +43,6 @@ import stripJsonComments from 'strip-json-comments'; // Will be mocked separatel
|
||||||
|
|
||||||
// These imports will get the versions from the vi.mock('./settings.js', ...) factory.
|
// These imports will get the versions from the vi.mock('./settings.js', ...) factory.
|
||||||
import {
|
import {
|
||||||
LoadedSettings,
|
|
||||||
loadSettings,
|
loadSettings,
|
||||||
USER_SETTINGS_PATH, // This IS the mocked path.
|
USER_SETTINGS_PATH, // This IS the mocked path.
|
||||||
SETTINGS_DIRECTORY_NAME, // This is from the original module, but used by the mock.
|
SETTINGS_DIRECTORY_NAME, // This is from the original module, but used by the mock.
|
||||||
|
@ -595,7 +594,7 @@ describe('Settings Loading and Merging', () => {
|
||||||
describe('LoadedSettings class', () => {
|
describe('LoadedSettings class', () => {
|
||||||
it('setValue should update the correct scope and recompute merged settings', () => {
|
it('setValue should update the correct scope and recompute merged settings', () => {
|
||||||
(mockFsExistsSync as Mock).mockReturnValue(false);
|
(mockFsExistsSync as Mock).mockReturnValue(false);
|
||||||
const loadedSettings = loadSettings(MOCK_WORKSPACE_DIR) as LoadedSettings;
|
const loadedSettings = loadSettings(MOCK_WORKSPACE_DIR);
|
||||||
|
|
||||||
vi.mocked(fs.writeFileSync).mockImplementation(() => {});
|
vi.mocked(fs.writeFileSync).mockImplementation(() => {});
|
||||||
// mkdirSync is mocked in beforeEach to return undefined, which is fine for void usage
|
// mkdirSync is mocked in beforeEach to return undefined, which is fine for void usage
|
||||||
|
|
|
@ -127,10 +127,7 @@ export const useSlashCommandProcessor = (
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
historyItemContent = {
|
historyItemContent = {
|
||||||
type: message.type as
|
type: message.type,
|
||||||
| MessageType.INFO
|
|
||||||
| MessageType.ERROR
|
|
||||||
| MessageType.USER,
|
|
||||||
text: message.content,
|
text: message.content,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,21 +282,9 @@ export class CoreToolScheduler {
|
||||||
|
|
||||||
// currentCall is a non-terminal state here and should have startTime and tool.
|
// currentCall is a non-terminal state here and should have startTime and tool.
|
||||||
const existingStartTime = currentCall.startTime;
|
const existingStartTime = currentCall.startTime;
|
||||||
const toolInstance = (
|
const toolInstance = currentCall.tool;
|
||||||
currentCall as
|
|
||||||
| ValidatingToolCall
|
|
||||||
| ScheduledToolCall
|
|
||||||
| ExecutingToolCall
|
|
||||||
| WaitingToolCall
|
|
||||||
).tool;
|
|
||||||
|
|
||||||
const outcome = (
|
const outcome = currentCall.outcome;
|
||||||
currentCall as
|
|
||||||
| ValidatingToolCall
|
|
||||||
| ScheduledToolCall
|
|
||||||
| ExecutingToolCall
|
|
||||||
| WaitingToolCall
|
|
||||||
).outcome;
|
|
||||||
|
|
||||||
switch (newStatus) {
|
switch (newStatus) {
|
||||||
case 'success': {
|
case 'success': {
|
||||||
|
@ -579,7 +567,7 @@ export class CoreToolScheduler {
|
||||||
callsToExecute.forEach((toolCall) => {
|
callsToExecute.forEach((toolCall) => {
|
||||||
if (toolCall.status !== 'scheduled') return;
|
if (toolCall.status !== 'scheduled') return;
|
||||||
|
|
||||||
const scheduledCall = toolCall as ScheduledToolCall;
|
const scheduledCall = toolCall;
|
||||||
const { callId, name: toolName } = scheduledCall.request;
|
const { callId, name: toolName } = scheduledCall.request;
|
||||||
this.setStatusInternal(callId, 'executing');
|
this.setStatusInternal(callId, 'executing');
|
||||||
|
|
||||||
|
@ -591,7 +579,7 @@ export class CoreToolScheduler {
|
||||||
}
|
}
|
||||||
this.toolCalls = this.toolCalls.map((tc) =>
|
this.toolCalls = this.toolCalls.map((tc) =>
|
||||||
tc.request.callId === callId && tc.status === 'executing'
|
tc.request.callId === callId && tc.status === 'executing'
|
||||||
? { ...(tc as ExecutingToolCall), liveOutput: outputChunk }
|
? { ...tc, liveOutput: outputChunk }
|
||||||
: tc,
|
: tc,
|
||||||
);
|
);
|
||||||
this.notifyToolCallsUpdate();
|
this.notifyToolCallsUpdate();
|
||||||
|
|
|
@ -542,7 +542,7 @@ export class GeminiChat {
|
||||||
automaticFunctionCallingHistory.length > 0
|
automaticFunctionCallingHistory.length > 0
|
||||||
) {
|
) {
|
||||||
this.history.push(
|
this.history.push(
|
||||||
...extractCuratedHistory(automaticFunctionCallingHistory!),
|
...extractCuratedHistory(automaticFunctionCallingHistory),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.history.push(userInput);
|
this.history.push(userInput);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { GroundingMetadata } from '@google/genai';
|
|
||||||
import { SchemaValidator } from '../utils/schemaValidator.js';
|
import { SchemaValidator } from '../utils/schemaValidator.js';
|
||||||
import {
|
import {
|
||||||
BaseTool,
|
BaseTool,
|
||||||
|
@ -255,9 +254,7 @@ ${textContent}
|
||||||
|
|
||||||
let responseText = getResponseText(response) || '';
|
let responseText = getResponseText(response) || '';
|
||||||
const urlContextMeta = response.candidates?.[0]?.urlContextMetadata;
|
const urlContextMeta = response.candidates?.[0]?.urlContextMetadata;
|
||||||
const groundingMetadata = response.candidates?.[0]?.groundingMetadata as
|
const groundingMetadata = response.candidates?.[0]?.groundingMetadata;
|
||||||
| GroundingMetadata
|
|
||||||
| undefined;
|
|
||||||
const sources = groundingMetadata?.groundingChunks as
|
const sources = groundingMetadata?.groundingChunks as
|
||||||
| GroundingChunkItem[]
|
| GroundingChunkItem[]
|
||||||
| undefined;
|
| undefined;
|
||||||
|
|
|
@ -75,10 +75,7 @@ export function allowEditorTypeInSandbox(editor: EditorType): boolean {
|
||||||
*/
|
*/
|
||||||
export function isEditorAvailable(editor: string | undefined): boolean {
|
export function isEditorAvailable(editor: string | undefined): boolean {
|
||||||
if (editor && isValidEditorType(editor)) {
|
if (editor && isValidEditorType(editor)) {
|
||||||
return (
|
return checkHasEditorType(editor) && allowEditorTypeInSandbox(editor);
|
||||||
checkHasEditorType(editor as EditorType) &&
|
|
||||||
allowEditorTypeInSandbox(editor as EditorType)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue