MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / handleRequest

Method handleRequest

src/runtime/adapters/ipc.ts:161–434  ·  view source on GitHub ↗
(request: IpcRequest)

Source from the content-addressed store, hash-verified

159 }
160
161 private async handleRequest(request: IpcRequest): Promise<void> {
162 if (!this.agent || !this.conversationService) {
163 this.replyError(request.id, "IPC adapter is not ready yet");
164 return;
165 }
166
167 try {
168 switch (request.type) {
169 case "get_conversations": {
170 const activeChannels = new Set(this.agent.getActiveChannelIds());
171 for (const channelId of this.createdChannels) {
172 activeChannels.add(channelId);
173 }
174 const conversations = this.conversationService.listConversations(
175 activeChannels,
176 {
177 includeDefaultWeb: true,
178 includeLegacyWeb: false,
179 },
180 );
181 this.reply(request.id, conversations);
182 return;
183 }
184
185 case "create_conversation": {
186 const channelId = DEFAULT_WEB_CHANNEL_ID;
187 this.createdChannels.add(channelId);
188 this.reply(request.id, { channelId });
189 return;
190 }
191
192 case "get_messages": {
193 if (!request.channelId || typeof request.channelId !== "string") {
194 this.replyError(request.id, "channelId is required");
195 return;
196 }
197 const messages = this.conversationService.getMessages(
198 request.channelId,
199 request.limit ?? 100,
200 );
201 this.reply(request.id, messages);
202 return;
203 }
204
205 case "send_message": {
206 if (!request.channelId || typeof request.channelId !== "string") {
207 this.replyError(request.id, "channelId is required");
208 return;
209 }
210 if (typeof request.text !== "string") {
211 this.replyError(request.id, "text is required");
212 return;
213 }
214
215 const platform = this.detectPlatform(request.channelId);
216 const attachments = this.normalizeAttachments(request.attachments);
217 this.createdChannels.add(request.channelId);
218

Callers 2

startMethod · 0.95

Calls 15

replyErrorMethod · 0.95
replyMethod · 0.95
detectPlatformMethod · 0.95
normalizeAttachmentsMethod · 0.95
broadcastAgentEventMethod · 0.95
getSchedulerAdapterMethod · 0.95
resolveCommandFunction · 0.85
isMessageSenderFunction · 0.85
listConversationsMethod · 0.80
getMessagesMethod · 0.80
getConfigMethod · 0.80
saveMethod · 0.80

Tested by

no test coverage detected