MCPcopy Create free account
hub / github.com/anus-dev/ANUS / prompt

Method prompt

packages/cli/src/zed-integration/zedIntegration.ts:207–302  ·  view source on GitHub ↗
(params: acp.PromptRequest)

Source from the content-addressed store, hash-verified

205 }
206
207 async prompt(params: acp.PromptRequest): Promise<acp.PromptResponse> {
208 this.pendingPrompt?.abort();
209 const pendingSend = new AbortController();
210 this.pendingPrompt = pendingSend;
211
212 const promptId = Math.random().toString(16).slice(2);
213 const chat = this.chat;
214
215 const parts = await this.#resolvePrompt(params.prompt, pendingSend.signal);
216
217 let nextMessage: Content | null = { role: 'user', parts };
218
219 while (nextMessage !== null) {
220 if (pendingSend.signal.aborted) {
221 chat.addHistory(nextMessage);
222 return { stopReason: 'cancelled' };
223 }
224
225 const functionCalls: FunctionCall[] = [];
226
227 try {
228 const responseStream = await chat.sendMessageStream(
229 {
230 message: nextMessage?.parts ?? [],
231 config: {
232 abortSignal: pendingSend.signal,
233 },
234 },
235 promptId,
236 );
237 nextMessage = null;
238
239 for await (const resp of responseStream) {
240 if (pendingSend.signal.aborted) {
241 return { stopReason: 'cancelled' };
242 }
243
244 if (resp.candidates && resp.candidates.length > 0) {
245 const candidate = resp.candidates[0];
246 for (const part of candidate.content?.parts ?? []) {
247 if (!part.text) {
248 continue;
249 }
250
251 const content: acp.ContentBlock = {
252 type: 'text',
253 text: part.text,
254 };
255
256 this.sendUpdate({
257 sessionUpdate: part.thought
258 ? 'agent_thought_chunk'
259 : 'agent_message_chunk',
260 content,
261 });
262 }
263 }
264

Callers

nothing calls this directly

Calls 6

#resolvePromptMethod · 0.95
sendUpdateMethod · 0.95
runToolMethod · 0.95
getErrorStatusFunction · 0.85
addHistoryMethod · 0.45
sendMessageStreamMethod · 0.45

Tested by

no test coverage detected