MCPcopy
hub / github.com/coder/mux / requestPromptDetailed

Method requestPromptDetailed

src/node/services/sshPromptService.ts:132–180  ·  view source on GitHub ↗

* Called from SSH pool when a prompt is detected. * Blocks until the user responds or timeout fires. * Responder admission only applies to new prompts; deduped callers can still * join an existing pending prompt even during transient responder gaps.

(params: SshPromptRequestParams)

Source from the content-addressed store, hash-verified

130 * join an existing pending prompt even during transient responder gaps.
131 */
132 async requestPromptDetailed(params: SshPromptRequestParams): Promise<SshPromptResolution> {
133 const dedupeKey = params.kind === "host-key" ? (params.dedupeKey ?? params.host) : null;
134
135 if (dedupeKey) {
136 const joinedPending = this.joinPendingByDedupeKey(dedupeKey);
137 if (joinedPending) {
138 return joinedPending;
139 }
140 }
141
142 if (!this.hasInteractiveResponder()) {
143 return { response: "", reason: "no_responder" };
144 }
145
146 const requestId = crypto.randomUUID();
147 if (dedupeKey) {
148 this.inflightByDedupeKey.set(dedupeKey, requestId);
149 }
150
151 const requestWithoutId =
152 params.kind === "host-key"
153 ? {
154 kind: "host-key" as const,
155 host: params.host,
156 keyType: params.keyType,
157 fingerprint: params.fingerprint,
158 prompt: params.prompt,
159 }
160 : {
161 kind: "credential" as const,
162 prompt: params.prompt,
163 secret: params.secret,
164 };
165
166 return new Promise<SshPromptResolution>((resolve) => {
167 const request: SshPromptRequest = { requestId, ...requestWithoutId };
168 const entry: PendingEntry = {
169 request,
170 dedupeKey,
171 timer: setTimeout(() => {
172 this.finalizeRequest(requestId, { response: "", reason: "timeout" });
173 }, this.timeoutMs),
174 waiters: [resolve],
175 };
176
177 this.pending.set(requestId, entry);
178 this.emit("request", request);
179 });
180 }
181
182 async requestPrompt(params: SshPromptRequestParams): Promise<string> {
183 const resolution = await this.requestPromptDetailed(params);

Callers 2

requestPromptMethod · 0.95

Calls 5

finalizeRequestMethod · 0.95
setMethod · 0.80
emitMethod · 0.65

Tested by

no test coverage detected