MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / handleAsk

Method handleAsk

apps/cli/src/agent/ask-dispatcher.ts:124–181  ·  view source on GitHub ↗

* Handle an ask message. * Routes to the appropriate handler based on ask type. * * @param message - The ClineMessage with type="ask" * @returns Promise

(message: ClineMessage)

Source from the content-addressed store, hash-verified

122 * @returns Promise<AskHandleResult>
123 */
124 async handleAsk(message: ClineMessage): Promise<AskHandleResult> {
125 // Disabled in TUI mode - TUI handles asks directly
126 if (this.disabled) {
127 return { handled: false }
128 }
129
130 const ts = message.ts
131 const ask = message.ask
132 const text = message.text || ""
133
134 // Check if already handled
135 if (this.handledAsks.has(ts)) {
136 return { handled: true }
137 }
138
139 // Must be an ask message
140 if (message.type !== "ask" || !ask) {
141 return { handled: false }
142 }
143
144 // Skip partial messages (wait for complete)
145 if (message.partial) {
146 return { handled: false }
147 }
148
149 // Mark as being handled
150 this.handledAsks.add(ts)
151
152 try {
153 // Route based on ask category
154 if (isNonBlockingAsk(ask)) {
155 return await this.handleNonBlockingAsk(ts, ask, text)
156 }
157
158 if (isIdleAsk(ask)) {
159 return await this.handleIdleAsk(ts, ask, text)
160 }
161
162 if (isResumableAsk(ask)) {
163 return await this.handleResumableAsk(ts, ask, text)
164 }
165
166 if (isInteractiveAsk(ask)) {
167 return await this.handleInteractiveAsk(ts, ask, text)
168 }
169
170 // Unknown ask type - log and handle generically
171 debugLog("[AskDispatcher] Unknown ask type", { ask, ts })
172 return await this.handleUnknownAsk(ts, ask, text)
173 } catch (error) {
174 // Re-allow handling on error
175 this.handledAsks.delete(ts)
176 return {
177 handled: false,
178 error: error instanceof Error ? error : new Error(String(error)),
179 }
180 }
181 }

Callers 1

Calls 13

handleNonBlockingAskMethod · 0.95
handleIdleAskMethod · 0.95
handleResumableAskMethod · 0.95
handleInteractiveAskMethod · 0.95
handleUnknownAskMethod · 0.95
isNonBlockingAskFunction · 0.90
isIdleAskFunction · 0.90
isResumableAskFunction · 0.90
isInteractiveAskFunction · 0.90
hasMethod · 0.65
deleteMethod · 0.65
debugLogFunction · 0.50

Tested by

no test coverage detected