MCPcopy Create free account
hub / github.com/Noumena-Network/code / call

Function call

src/tools/SendMessageTool/SendMessageTool.ts:790–962  ·  view source on GitHub ↗
(input, context, canUseTool, assistantMessage)

Source from the content-addressed store, hash-verified

788 },
789
790 async call(input, context, canUseTool, assistantMessage) {
791 if (feature('UDS_INBOX') && typeof input.message === 'string') {
792 const addr = parseAddress(input.to)
793 if (addr.scheme === 'bridge') {
794 // Re-check handle — checkPermissions blocks on user approval (can be
795 // minutes). validateInput's check is stale if the bridge dropped
796 // during the prompt wait; without this, from="unknown" ships.
797 // Also re-check isReplBridgeActive for outbound-only mode.
798 if (!getReplBridgeHandle() || !isReplBridgeActive()) {
799 return {
800 data: {
801 success: false,
802 message: `Remote Control disconnected before send — cannot deliver to ${input.to}`,
803 },
804 }
805 }
806 /* eslint-disable @typescript-eslint/no-require-imports */
807 const { postInterClaudeMessage } =
808 require('../../bridge/peerSessions.js') as typeof import('../../bridge/peerSessions.js')
809 /* eslint-enable @typescript-eslint/no-require-imports */
810 const result = await postInterClaudeMessage(
811 addr.target,
812 input.message,
813 )
814 const preview = input.summary || truncate(input.message, 50)
815 return {
816 data: {
817 success: result.ok,
818 message: result.ok
819 ? `“${preview}” → ${input.to}`
820 : `Failed to send to ${input.to}: ${result.error ?? 'unknown'}`,
821 },
822 }
823 }
824 if (addr.scheme === 'uds') {
825 /* eslint-disable @typescript-eslint/no-require-imports */
826 const { sendToUdsSocket } =
827 require('../../utils/udsClient.js') as typeof import('../../utils/udsClient.js')
828 /* eslint-enable @typescript-eslint/no-require-imports */
829 try {
830 await sendToUdsSocket(addr.target, input.message)
831 const preview = input.summary || truncate(input.message, 50)
832 return {
833 data: {
834 success: true,
835 message: `“${preview}” → ${input.to}`,
836 },
837 }
838 } catch (e) {
839 return {
840 data: {
841 success: false,
842 message: `Failed to send to ${input.to}: ${errorMessage(e)}`,
843 },
844 }
845 }
846 }
847 }

Callers

nothing calls this directly

Calls 15

parseAddressFunction · 0.85
getReplBridgeHandleFunction · 0.85
isReplBridgeActiveFunction · 0.85
postInterClaudeMessageFunction · 0.85
sendToUdsSocketFunction · 0.85
toAgentIdFunction · 0.85
isMainSessionTaskFunction · 0.85
resumeAgentBackgroundFunction · 0.85
handleBroadcastFunction · 0.85
handleMessageFunction · 0.85
handleShutdownRequestFunction · 0.85
handleShutdownApprovalFunction · 0.85

Tested by

no test coverage detected