MCPcopy Index your code
hub / github.com/agent0ai/agent-zero / request

Method request

webui/js/websocket.js:469–505  ·  view source on GitHub ↗
(eventType, data, options = {})

Source from the content-addressed store, hash-verified

467 }
468
469 async request(eventType, data, options = {}) {
470 const correlationId =
471 normalizeCorrelationId(options?.correlationId) ||
472 createCorrelationId("request");
473 const payload = this.buildPayload(data);
474 payload.correlationId = correlationId;
475
476 const timeoutMs = Number(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
477 this.debugLog("request", { eventType, correlationId, timeoutMs });
478 if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
479 throw new Error("timeoutMs must be a non-negative number");
480 }
481 this.ensurePayloadSize(payload);
482 await this.connect();
483 if (!this.isConnected()) {
484 throw new Error("Not connected");
485 }
486
487 return new Promise((resolve, reject) => {
488 if (timeoutMs > 0) {
489 this.socket
490 .timeout(timeoutMs)
491 .emit(eventType, payload, (err, response) => {
492 if (err) {
493 reject(new Error("Request timeout"));
494 return;
495 }
496 resolve(this.normalizeRequestResponse(response));
497 });
498 return;
499 }
500
501 this.socket.emit(eventType, payload, (response) => {
502 resolve(this.normalizeRequestResponse(response));
503 });
504 });
505 }
506
507 normalizeRequestResponse(response) {
508 if (!response || typeof response !== "object") {

Callers 15

fetch_httpMethod · 0.80
requestEditorFunction · 0.80
refreshFunction · 0.80
refreshBrowserSessionsFunction · 0.80
connectViewerFunction · 0.80
commandFunction · 0.80
createAnnotationDraftFunction · 0.80
sendMouseFunction · 0.80
sendClipboardFunction · 0.80
requestOfficeFunction · 0.80
request_codexFunction · 0.80
_subscribeFunction · 0.80

Calls 9

buildPayloadMethod · 0.95
debugLogMethod · 0.95
ensurePayloadSizeMethod · 0.95
connectMethod · 0.95
isConnectedMethod · 0.95
normalizeCorrelationIdFunction · 0.85
createCorrelationIdFunction · 0.85
emitMethod · 0.45

Tested by

no test coverage detected