MCPcopy
hub / github.com/codeaashu/claude-code / handleInboundMessage

Function handleInboundMessage

src/hooks/useReplBridge.tsx:180–221  ·  view source on GitHub ↗
(msg: SDKMessage)

Source from the content-addressed store, hash-verified

178 // await — messages with attachments just land in the queue slightly
179 // later, which is fine (web messages aren't rapid-fire).
180 async function handleInboundMessage(msg: SDKMessage): Promise<void> {
181 try {
182 const fields = extractInboundMessageFields(msg);
183 if (!fields) return;
184 const {
185 uuid
186 } = fields;
187
188 // Dynamic import keeps the bridge code out of non-BRIDGE_MODE builds.
189 const {
190 resolveAndPrepend
191 } = await import('../bridge/inboundAttachments.js');
192 let sanitized = fields.content;
193 if (feature('KAIROS_GITHUB_WEBHOOKS')) {
194 /* eslint-disable @typescript-eslint/no-require-imports */
195 const {
196 sanitizeInboundWebhookContent
197 } = require('../bridge/webhookSanitizer.js') as typeof import('../bridge/webhookSanitizer.js');
198 /* eslint-enable @typescript-eslint/no-require-imports */
199 sanitized = sanitizeInboundWebhookContent(fields.content);
200 }
201 const content = await resolveAndPrepend(msg, sanitized);
202 const preview = typeof content === 'string' ? content.slice(0, 80) : `[${content.length} content blocks]`;
203 logForDebugging(`[bridge:repl] Injecting inbound user message: ${preview}${uuid ? ` uuid=${uuid}` : ''}`);
204 enqueue({
205 value: content,
206 mode: 'prompt' as const,
207 uuid,
208 // skipSlashCommands stays true as defense-in-depth —
209 // processUserInputBase overrides it internally when bridgeOrigin
210 // is set AND the resolved command passes isBridgeSafeCommand.
211 // This keeps exit-word suppression and immediate-command blocks
212 // intact for any code path that checks skipSlashCommands directly.
213 skipSlashCommands: true,
214 bridgeOrigin: true
215 });
216 } catch (e) {
217 logForDebugging(`[bridge:repl] handleInboundMessage failed: ${e}`, {
218 level: 'error'
219 });
220 }
221 }
222
223 // State change callback — maps bridge lifecycle events to AppState.
224 function handleStateChange(state: BridgeState, detail_0?: string): void {

Callers

nothing calls this directly

Calls 5

featureFunction · 0.85
resolveAndPrependFunction · 0.85
logForDebuggingFunction · 0.85
enqueueFunction · 0.85

Tested by

no test coverage detected