style: auto-fix ESLint issues (curly braces and formatting)
- Add curly braces to all if/else/for/while statements - Fix indentation and trailing spaces - Auto-fixed 372 linting errors using eslint --fix - Remaining issues are warnings only (non-null assertions, explicit any types)
This commit is contained in:
@@ -89,10 +89,10 @@ export class BedrockClient implements ModelClient {
|
||||
|
||||
// Map stop reason
|
||||
let stopReason: string = 'end_turn';
|
||||
if (response.stopReason === 'max_tokens') stopReason = 'max_tokens';
|
||||
else if (response.stopReason === 'tool_use') stopReason = 'tool_use';
|
||||
else if (response.stopReason === 'end_turn') stopReason = 'end_turn';
|
||||
else if (response.stopReason) stopReason = response.stopReason;
|
||||
if (response.stopReason === 'max_tokens') {stopReason = 'max_tokens';}
|
||||
else if (response.stopReason === 'tool_use') {stopReason = 'tool_use';}
|
||||
else if (response.stopReason === 'end_turn') {stopReason = 'end_turn';}
|
||||
else if (response.stopReason) {stopReason = response.stopReason;}
|
||||
|
||||
return {
|
||||
content,
|
||||
|
||||
@@ -27,12 +27,12 @@ function makeResponse(parts: unknown[], finishReason = 'STOP', usage = { promptT
|
||||
usageMetadata: usage,
|
||||
text: () => {
|
||||
const textParts = parts.filter((p: unknown) => typeof p === 'object' && p !== null && 'text' in p);
|
||||
if (textParts.length === 0) throw new Error('No text parts');
|
||||
if (textParts.length === 0) {throw new Error('No text parts');}
|
||||
return textParts.map((p: unknown) => (p as { text: string }).text).join('');
|
||||
},
|
||||
functionCalls: () => {
|
||||
const fcParts = parts.filter((p: unknown) => typeof p === 'object' && p !== null && 'functionCall' in p);
|
||||
if (fcParts.length === 0) return undefined;
|
||||
if (fcParts.length === 0) {return undefined;}
|
||||
return fcParts.map((p: unknown) => (p as { functionCall: { name: string; args: object } }).functionCall);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -72,7 +72,7 @@ export class GitHubModelsClient implements ModelClient {
|
||||
* callback is provided, invoke it to obtain a token (e.g. via OAuth device flow).
|
||||
*/
|
||||
private async ensureToken(): Promise<void> {
|
||||
if (this.tokenResolved) return;
|
||||
if (this.tokenResolved) {return;}
|
||||
|
||||
// Try resolving again (user might have logged in via /login since construction)
|
||||
const token = getGitHubToken();
|
||||
@@ -85,7 +85,7 @@ export class GitHubModelsClient implements ModelClient {
|
||||
if (this.onLoginRequired) {
|
||||
const newToken = await this.onLoginRequired();
|
||||
this.rebuildClient(newToken);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// No token and no callback — the API call will fail with an auth error
|
||||
|
||||
@@ -115,7 +115,7 @@ export function normalizeMessagesForLlamaCpp(
|
||||
} else if (block.type === 'tool_use') {
|
||||
const name = block.name as string;
|
||||
const id = block.id as string;
|
||||
if (id) toolNameMap.set(id, name);
|
||||
if (id) {toolNameMap.set(id, name);}
|
||||
let argsStr: string;
|
||||
try {
|
||||
argsStr = JSON.stringify(block.input);
|
||||
@@ -321,7 +321,7 @@ export class LlamaCppClient implements ModelClient {
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
if (done) {break;}
|
||||
|
||||
buffer += decoder.decode(value, { stream: true });
|
||||
const lines = buffer.split('\n');
|
||||
@@ -329,10 +329,10 @@ export class LlamaCppClient implements ModelClient {
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed || !trimmed.startsWith('data: ')) continue;
|
||||
if (!trimmed || !trimmed.startsWith('data: ')) {continue;}
|
||||
|
||||
const data = trimmed.slice(6);
|
||||
if (data === '[DONE]') continue;
|
||||
if (data === '[DONE]') {continue;}
|
||||
|
||||
try {
|
||||
const chunk = JSON.parse(data) as LlamaCppStreamChunk;
|
||||
@@ -352,8 +352,8 @@ export class LlamaCppClient implements ModelClient {
|
||||
});
|
||||
}
|
||||
const acc = toolCallAccumulators.get(tc.index)!;
|
||||
if (tc.function?.name) acc.name = tc.function.name;
|
||||
if (tc.function?.arguments) acc.arguments += tc.function.arguments;
|
||||
if (tc.function?.name) {acc.name = tc.function.name;}
|
||||
if (tc.function?.arguments) {acc.arguments += tc.function.arguments;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ export function normalizeMessagesForOllama(
|
||||
} else if (block.type === 'tool_use') {
|
||||
const name = block.name as string;
|
||||
const id = block.id as string;
|
||||
if (id) toolNameMap.set(id, name);
|
||||
if (id) {toolNameMap.set(id, name);}
|
||||
toolCalls.push({
|
||||
function: {
|
||||
name,
|
||||
@@ -135,7 +135,7 @@ export class OllamaClient implements ModelClient {
|
||||
* true (optimistic — let the server decide).
|
||||
*/
|
||||
private async checkToolSupport(): Promise<boolean> {
|
||||
if (this._supportsTools !== null) return this._supportsTools;
|
||||
if (this._supportsTools !== null) {return this._supportsTools;}
|
||||
try {
|
||||
const info = await this.client.show({ model: this.model });
|
||||
const caps: string[] = (info as any).capabilities ?? [];
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ export function normalizeMessagesForLocal(
|
||||
|
||||
for (const msg of messages) {
|
||||
const text = getMessageTextWithTools(msg);
|
||||
if (!text) continue; // drop empty messages
|
||||
if (!text) {continue;} // drop empty messages
|
||||
|
||||
const last = result.length > 0 ? result[result.length - 1] : undefined;
|
||||
if (last && last.role === msg.role) {
|
||||
|
||||
@@ -134,7 +134,7 @@ describe('withRetry', () => {
|
||||
let callCount = 0;
|
||||
const fn = vi.fn().mockImplementation(() => {
|
||||
callCount++;
|
||||
if (callCount < 3) return Promise.reject(new Error('fail'));
|
||||
if (callCount < 3) {return Promise.reject(new Error('fail'));}
|
||||
return Promise.resolve('ok');
|
||||
});
|
||||
|
||||
@@ -166,7 +166,7 @@ describe('withRetry', () => {
|
||||
|
||||
const fn = vi.fn().mockImplementation(() => {
|
||||
timestamps.push(Date.now());
|
||||
if (timestamps.length < 3) return Promise.reject(new Error('fail'));
|
||||
if (timestamps.length < 3) {return Promise.reject(new Error('fail'));}
|
||||
return Promise.resolve('ok');
|
||||
});
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('ModelRouter', () => {
|
||||
|
||||
const response = await router.chat(
|
||||
{ messages: [{ role: 'user', content: 'Hi' }] },
|
||||
'fast'
|
||||
'fast',
|
||||
);
|
||||
|
||||
expect(response.content).toBe('Response from fast');
|
||||
|
||||
@@ -41,9 +41,9 @@ export class ModelRouter implements ModelClient {
|
||||
}
|
||||
|
||||
this.clients.set('default', config.default);
|
||||
if (config.fast) this.clients.set('fast', config.fast);
|
||||
if (config.complex) this.clients.set('complex', config.complex);
|
||||
if (config.local) this.clients.set('local', config.local);
|
||||
if (config.fast) {this.clients.set('fast', config.fast);}
|
||||
if (config.complex) {this.clients.set('complex', config.complex);}
|
||||
if (config.local) {this.clients.set('local', config.local);}
|
||||
|
||||
if (config.labels) {
|
||||
for (const tier of ['fast', 'default', 'complex', 'local'] as ModelTier[]) {
|
||||
@@ -145,7 +145,7 @@ export class ModelRouter implements ModelClient {
|
||||
yield event;
|
||||
}
|
||||
|
||||
if (!hasError) return;
|
||||
if (!hasError) {return;}
|
||||
} else {
|
||||
primaryError = 'Primary client does not support streaming';
|
||||
}
|
||||
@@ -154,7 +154,7 @@ export class ModelRouter implements ModelClient {
|
||||
const tierFallbackList = this.tierFallbacks.get(useTier) ?? [];
|
||||
for (let i = 0; i < tierFallbackList.length; i++) {
|
||||
const fallbackClient = tierFallbackList[i];
|
||||
if (!fallbackClient.chatStream) continue;
|
||||
if (!fallbackClient.chatStream) {continue;}
|
||||
|
||||
const reason = `Primary model failed (${primaryError}), using tier fallback #${i + 1}`;
|
||||
logger.debug(reason);
|
||||
@@ -170,13 +170,13 @@ export class ModelRouter implements ModelClient {
|
||||
yield event;
|
||||
}
|
||||
|
||||
if (!hasError) return;
|
||||
if (!hasError) {return;}
|
||||
}
|
||||
|
||||
// Then try global fallback chain
|
||||
for (let i = 0; i < this.fallbackChain.length; i++) {
|
||||
const fallbackClient = this.fallbackChain[i];
|
||||
if (!fallbackClient.chatStream) continue;
|
||||
if (!fallbackClient.chatStream) {continue;}
|
||||
|
||||
const reason = `Primary model failed (${primaryError}), using global fallback #${i + 1}`;
|
||||
logger.debug(reason);
|
||||
@@ -192,7 +192,7 @@ export class ModelRouter implements ModelClient {
|
||||
yield event;
|
||||
}
|
||||
|
||||
if (!hasError) return;
|
||||
if (!hasError) {return;}
|
||||
}
|
||||
|
||||
yield { type: 'error', error: new Error('All streaming providers failed') };
|
||||
|
||||
Reference in New Issue
Block a user