Skip to content

Commit 5837477

Browse files
Refactor read-docs, web-search, and str-replace to pass logger as parameter
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent cda0711 commit 5837477

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

backend/src/tools/batch-str-replace.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ async function executeSingleStrReplace(params: {
358358
toolCall,
359359
requestClientToolCall,
360360
writeToClient: onResponseChunk,
361+
logger,
361362
getLatestState: () => getFileProcessingValues(isolatedState),
362363
state: isolatedState,
363364
})

backend/src/tools/handlers/tool/read-docs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fetchContext7LibraryDocumentation } from '../../../llm-apis/context7-api'
2-
import { logger } from '../../../util/logger'
32

43
import type { CodebuffToolHandlerFunction } from '../handler-function-type'
4+
import type { Logger } from '@codebuff/types/logger'
55
import type {
66
CodebuffToolCall,
77
CodebuffToolOutput,
@@ -10,13 +10,15 @@ import type {
1010
export const handleReadDocs = (({
1111
previousToolCallFinished,
1212
toolCall,
13+
logger,
1314
agentStepId,
1415
clientSessionId,
1516
userInputId,
1617
state,
1718
}: {
1819
previousToolCallFinished: Promise<void>
1920
toolCall: CodebuffToolCall<'read_docs'>
21+
logger: Logger
2022

2123
agentStepId: string
2224
clientSessionId: string

backend/src/tools/handlers/tool/str-replace.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { getFileProcessingValues, postStreamProcessing } from './write-file'
22
import { processStrReplace } from '../../../process-str-replace'
3-
import { logger } from '../../../util/logger'
43
import { requestOptionalFile } from '../../../websockets/websocket-action'
54

65
import type { CodebuffToolHandlerFunction } from '../handler-function-type'
6+
import type { Logger } from '@codebuff/types/logger'
77
import type {
88
FileProcessingState,
99
OptionalFileProcessingState,
@@ -22,6 +22,7 @@ export const handleStrReplace = ((params: {
2222
toolCall: ClientToolCall<'str_replace'>,
2323
) => Promise<CodebuffToolOutput<'str_replace'>>
2424
writeToClient: (chunk: string) => void
25+
logger: Logger
2526

2627
getLatestState: () => FileProcessingState
2728
state: {
@@ -36,6 +37,7 @@ export const handleStrReplace = ((params: {
3637
toolCall,
3738
requestClientToolCall,
3839
writeToClient,
40+
logger,
3941
getLatestState,
4042
state,
4143
} = params

backend/src/tools/handlers/tool/web-search.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { consumeCreditsWithFallback } from '@codebuff/billing'
33
import { getRequestContext } from '../../../context/app-context'
44
import { searchWeb } from '../../../llm-apis/linkup-api'
55
import { PROFIT_MARGIN } from '../../../llm-apis/message-cost-tracker'
6-
import { logger } from '../../../util/logger'
76

87
import type { CodebuffToolHandlerFunction } from '../handler-function-type'
8+
import type { Logger } from '@codebuff/types/logger'
99
import type {
1010
CodebuffToolCall,
1111
CodebuffToolOutput,
@@ -14,6 +14,7 @@ import type {
1414
export const handleWebSearch = ((params: {
1515
previousToolCallFinished: Promise<void>
1616
toolCall: CodebuffToolCall<'web_search'>
17+
logger: Logger
1718

1819
agentStepId: string
1920
clientSessionId: string
@@ -28,6 +29,7 @@ export const handleWebSearch = ((params: {
2829
const {
2930
previousToolCallFinished,
3031
toolCall,
32+
logger,
3133
agentStepId,
3234
clientSessionId,
3335
userInputId,

0 commit comments

Comments
 (0)