fix: resolve TypeScript type errors in event and trace handlers

This commit is contained in:
MrAvalonApple 2026-04-06 17:30:20 +03:00
parent 44f2ad2fe4
commit bad083f48c
2 changed files with 11 additions and 11 deletions

View File

@ -4,7 +4,7 @@ import { Agent } from '../src/agent/agent.js'
import { AgentRunner } from '../src/agent/runner.js'
import { ToolRegistry } from '../src/tool/framework.js'
import { ToolExecutor } from '../src/tool/executor.js'
import type { AgentConfig, AgentRunResult, LLMAdapter, LLMMessage, LLMResponse } from '../src/types.js'
import type { AgentConfig, AgentRunResult, LLMAdapter, LLMMessage, LLMResponse, StreamEvent } from '../src/types.js'
// ---------------------------------------------------------------------------
// Mock helpers
@ -243,7 +243,7 @@ describe('Agent hooks — beforeRun / afterRun', () => {
}
const { agent, calls } = buildMockAgent(config, 'streamed')
const events = []
const events: StreamEvent[] = []
for await (const event of agent.stream('original')) {
events.push(event)
}
@ -263,7 +263,7 @@ describe('Agent hooks — beforeRun / afterRun', () => {
}
const { agent } = buildMockAgent(config, 'original')
const events = []
const events: StreamEvent[] = []
for await (const event of agent.stream('hi')) {
events.push(event)
}
@ -280,7 +280,7 @@ describe('Agent hooks — beforeRun / afterRun', () => {
}
const { agent } = buildMockAgent(config, 'unreachable')
const events = []
const events: StreamEvent[] = []
for await (const event of agent.stream('hi')) {
events.push(event)
}
@ -297,7 +297,7 @@ describe('Agent hooks — beforeRun / afterRun', () => {
}
const { agent } = buildMockAgent(config, 'streamed output')
const events = []
const events: StreamEvent[] = []
for await (const event of agent.stream('hi')) {
events.push(event)
}

View File

@ -186,7 +186,7 @@ describe('AgentRunner trace events', () => {
})
const runOptions: RunOptions = {
onTrace: (e) => traces.push(e),
onTrace: (e) => { traces.push(e) },
runId: 'run-1',
traceAgent: 'test-agent',
}
@ -234,7 +234,7 @@ describe('AgentRunner trace events', () => {
await runner.run(
[{ role: 'user', content: [{ type: 'text', text: 'test' }] }],
{ onTrace: (e) => traces.push(e), runId: 'run-2', traceAgent: 'tooler' },
{ onTrace: (e) => { traces.push(e) }, runId: 'run-2', traceAgent: 'tooler' },
)
const toolTraces = traces.filter(t => t.type === 'tool_call')
@ -273,7 +273,7 @@ describe('AgentRunner trace events', () => {
await runner.run(
[{ role: 'user', content: [{ type: 'text', text: 'test' }] }],
{ onTrace: (e) => traces.push(e), runId: 'run-3', traceAgent: 'err-agent' },
{ onTrace: (e) => { traces.push(e) }, runId: 'run-3', traceAgent: 'err-agent' },
)
const toolTraces = traces.filter(t => t.type === 'tool_call')
@ -316,7 +316,7 @@ describe('Agent trace events', () => {
const agent = buildMockAgent(config, [textResponse('Hello world')])
const runOptions: Partial<RunOptions> = {
onTrace: (e) => traces.push(e),
onTrace: (e) => { traces.push(e) },
runId: 'run-agent-1',
traceAgent: 'my-agent',
}
@ -367,7 +367,7 @@ describe('Agent trace events', () => {
const runId = 'shared-run-id'
await agent.run('test', {
onTrace: (e) => traces.push(e),
onTrace: (e) => { traces.push(e) },
runId,
traceAgent: 'multi-trace-agent',
})
@ -436,7 +436,7 @@ describe('Agent trace events', () => {
await runner.run(
[{ role: 'user', content: [{ type: 'text', text: 'go' }] }],
{ onTrace: (e) => traces.push(e), runId: 'run-tok', traceAgent: 'token-agent' },
{ onTrace: (e) => { traces.push(e) }, runId: 'run-tok', traceAgent: 'token-agent' },
)
const llmTraces = traces.filter(t => t.type === 'llm_call')