chore(lint): reduce warning debt across core adapters and model clients

This commit is contained in:
William Valentin
2026-02-15 23:03:42 -08:00
parent 92da407e22
commit 49b752e8b0
17 changed files with 239 additions and 117 deletions
+14 -6
View File
@@ -1,4 +1,4 @@
import type { ModelClient, Message, ChatRequest, ChatResponse, ModelToolCall, TokenUsage } from '../../models/types.js';
import type { ModelClient, Message, ChatRequest, ChatResponse, TokenUsage } from '../../models/types.js';
import type { ModelRouter, ModelTier } from '../../models/router.js';
import type { Session } from '../../session/index.js';
import type { ToolRegistry } from '../../tools/registry.js';
@@ -8,7 +8,7 @@ import type { ToolPolicyContext } from '../../tools/policy.js';
import { auditLogger } from '../../audit/index.js';
import type { Attachment } from '../../channels/types.js';
import type { OutboundAttachmentCollector } from './attachments.js';
import { buildUserMessage, getMessageText } from '../../models/media.js';
import { buildUserMessage } from '../../models/media.js';
export interface ToolUseEvent {
type: 'start' | 'end';
@@ -142,7 +142,12 @@ export class NativeAgent {
}
private async toolLoop(): Promise<string> {
const tools = this.toolRegistry!.filteredToAnthropicFormat(this._toolPolicyContext);
const toolRegistry = this.toolRegistry;
const toolExecutor = this.toolExecutor;
if (!toolRegistry || !toolExecutor) {
throw new Error('Tool loop requires tool registry and executor');
}
const tools = toolRegistry.filteredToAnthropicFormat(this._toolPolicyContext);
// Track whether untrusted content (web/fetched/tool output) has been introduced
// during this run. Used to harden against prompt injection.
@@ -218,7 +223,10 @@ export class NativeAgent {
}
// Safe to assert non-null — wantsToolUse guarantees toolCalls exists and is non-empty
const toolCalls = response.toolCalls!;
const toolCalls = response.toolCalls;
if (!toolCalls || toolCalls.length === 0) {
continue;
}
// Check for repeated tool calls — build a fingerprint from tool names + args
const fingerprint = toolCalls
@@ -264,7 +272,7 @@ export class NativeAgent {
for (const tc of toolCalls) {
this.throwIfCancelled();
const internalName = this.toolRegistry!.getByApiName(tc.name)?.name ?? tc.name;
const internalName = toolRegistry.getByApiName(tc.name)?.name ?? tc.name;
this.onToolUse?.({ type: 'start', tool: internalName, args: tc.args });
let elevationUntilMs: number | undefined;
@@ -311,7 +319,7 @@ export class NativeAgent {
}
: undefined;
const result = await this.toolExecutor!.execute(internalName, tc.args, perCallContext);
const result = await toolExecutor.execute(internalName, tc.args, perCallContext);
this.onToolUse?.({ type: 'end', tool: internalName, result });