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

Function handleInboundMessage

src/hooks/useReplBridge.tsx:180–223  ·  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 if (typeof fields.content === 'string') {
200 sanitized = sanitizeInboundWebhookContent(fields.content);
201 }
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 6

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

Tested by

no test coverage detected