fix(comment-checker): defer CLI download and cleanup scheduler to first tool call
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
|||||||
stopPendingCallCleanup,
|
stopPendingCallCleanup,
|
||||||
takePendingCall,
|
takePendingCall,
|
||||||
} from "./pending-calls"
|
} from "./pending-calls"
|
||||||
|
import { ensureCommentCheckerInitialization } from "./initialization-gate"
|
||||||
|
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
import { tmpdir } from "os"
|
import { tmpdir } from "os"
|
||||||
@@ -48,14 +49,16 @@ function debugLog(...args: unknown[]) {
|
|||||||
export function createCommentCheckerHooks(config?: CommentCheckerConfig) {
|
export function createCommentCheckerHooks(config?: CommentCheckerConfig) {
|
||||||
debugLog("createCommentCheckerHooks called", { config })
|
debugLog("createCommentCheckerHooks called", { config })
|
||||||
|
|
||||||
startPendingCallCleanup()
|
|
||||||
initializeCommentCheckerCli(debugLog)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"tool.execute.before": async (
|
"tool.execute.before": async (
|
||||||
input: { tool: string; sessionID: string; callID: string },
|
input: { tool: string; sessionID: string; callID: string },
|
||||||
output: { args: Record<string, unknown> },
|
output: { args: Record<string, unknown> },
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
ensureCommentCheckerInitialization(() => {
|
||||||
|
startPendingCallCleanup()
|
||||||
|
initializeCommentCheckerCli(debugLog)
|
||||||
|
})
|
||||||
|
|
||||||
debugLog("tool.execute.before:", {
|
debugLog("tool.execute.before:", {
|
||||||
tool: input.tool,
|
tool: input.tool,
|
||||||
callID: input.callID,
|
callID: input.callID,
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
let initialized = false
|
||||||
|
|
||||||
|
export function ensureCommentCheckerInitialization(initializer: () => void): void {
|
||||||
|
if (initialized) return
|
||||||
|
initialized = true
|
||||||
|
initializer()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user