MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / handleInboundMessage

Function handleInboundMessage

source code/hooks/useReplBridge.tsx:182–223  ·  view source on GitHub ↗
(msg: SDKMessage)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

resolveAndPrependFunction · 0.85
logForDebuggingFunction · 0.85
enqueueFunction · 0.85

Tested by

no test coverage detected