MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / onApprovalRequested

Method onApprovalRequested

packages/server-e2e/src/client.ts:557–575  ·  view source on GitHub ↗

* Install a handler invoked on every `event.approval.requested` frame. * The handler's return value is POSTed to `/sessions/{sid}/approvals/{aid}`. * Returns an unsubscribe handle (also auto-disposed by `close()`).

(
    handler: (req: ApprovalRequest) => Promise<ApprovalResponse> | ApprovalResponse,
  )

Source from the content-addressed store, hash-verified

555 * Returns an unsubscribe handle (also auto-disposed by `close()`).
556 */
557 onApprovalRequested(
558 handler: (req: ApprovalRequest) => Promise<ApprovalResponse> | ApprovalResponse,
559 ): () => void {
560 const ws = this._requireWs();
561 const unsubscribe = installReverseRpcHandler<ApprovalRequest, ApprovalResponse>(ws, {
562 requestEventType: 'event.approval.requested',
563 idField: 'approval_id',
564 buildPath: (sid, aid) => `/sessions/${sid}/approvals/${aid}`,
565 handler,
566 postResolve: (sid, aid, body) => this.http.resolveApproval(sid, aid, body),
567 logger: this._logger,
568 });
569 this._disposers.push(unsubscribe);
570 return () => {
571 const idx = this._disposers.indexOf(unsubscribe);
572 if (idx >= 0) this._disposers.splice(idx, 1);
573 unsubscribe();
574 };
575 }
576
577 /**
578 * Install a handler invoked on every `event.question.requested` frame.

Callers 1

mainFunction · 0.95

Calls 4

_requireWsMethod · 0.95
installReverseRpcHandlerFunction · 0.85
resolveApprovalMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected