MCPcopy Create free account
hub / github.com/clawbot7/cli-gateway / PermReqRpc

Class PermReqRpc

test/bindingRuntime.misc.test.ts:37–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37class PermReqRpc implements StdioProcess {
38 private handlers: Array<(m: JsonRpcMessage) => void> = [];
39 written: JsonRpcMessage[] = [];
40
41 write(message: JsonRpcMessage): void {
42 this.written.push(message);
43
44 if ('method' in message) {
45 const req = message as JsonRpcRequest;
46 if (req.method === 'initialize') {
47 queueMicrotask(() =>
48 this.emit({
49 jsonrpc: '2.0',
50 id: req.id,
51 result: { protocolVersion: 1, agentCapabilities: {} },
52 } as any),
53 );
54 }
55 if (req.method === 'session/new') {
56 queueMicrotask(() =>
57 this.emit({
58 jsonrpc: '2.0',
59 id: req.id,
60 result: { sessionId: 'sess' },
61 } as any),
62 );
63 }
64 if (req.method === 'session/prompt') {
65 queueMicrotask(() => {
66 this.emit({
67 jsonrpc: '2.0',
68 id: 999,
69 method: 'session/request_permission',
70 params: {
71 sessionId: 'sess',
72 toolCall: { title: 'terminal/create', kind: 'execute' },
73 options: [
74 { optionId: 'a1', name: 'Allow once', kind: 'allow_once' },
75 { optionId: 'r1', name: 'Reject once', kind: 'reject_once' },
76 ],
77 },
78 } as any);
79
80 this.emit({
81 jsonrpc: '2.0',
82 id: req.id,
83 result: { stopReason: 'end' },
84 } as any);
85 });
86 }
87 }
88 }
89
90 onMessage(cb: (message: JsonRpcMessage) => void): void {
91 this.handlers.push(cb);
92 }
93
94 onStderr(): void {}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected