 85bf1341f3
			
		
	
	85bf1341f3
	
	
	
		
			
			Frontend Enhancements: - Complete React TypeScript frontend with modern UI components - Distributed workflows management interface with real-time updates - Socket.IO integration for live agent status monitoring - Agent management dashboard with cluster visualization - Project management interface with metrics and task tracking - Responsive design with proper error handling and loading states Backend Infrastructure: - Distributed coordinator for multi-agent workflow orchestration - Cluster management API with comprehensive agent operations - Enhanced database models for agents and projects - Project service for filesystem-based project discovery - Performance monitoring and metrics collection - Comprehensive API documentation and error handling Documentation: - Complete distributed development guide (README_DISTRIBUTED.md) - Comprehensive development report with architecture insights - System configuration templates and deployment guides The platform now provides a complete web interface for managing the distributed AI cluster with real-time monitoring, workflow orchestration, and agent coordination capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
		
			
				
	
	
		
			131 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			131 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const { isUtf8 } = require('buffer');
 | |
| 
 | |
| //
 | |
| // Allowed token characters:
 | |
| //
 | |
| // '!', '#', '$', '%', '&', ''', '*', '+', '-',
 | |
| // '.', 0-9, A-Z, '^', '_', '`', a-z, '|', '~'
 | |
| //
 | |
| // tokenChars[32] === 0 // ' '
 | |
| // tokenChars[33] === 1 // '!'
 | |
| // tokenChars[34] === 0 // '"'
 | |
| // ...
 | |
| //
 | |
| // prettier-ignore
 | |
| const tokenChars = [
 | |
|   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 15
 | |
|   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 - 31
 | |
|   0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 32 - 47
 | |
|   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48 - 63
 | |
|   0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79
 | |
|   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 80 - 95
 | |
|   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111
 | |
|   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0 // 112 - 127
 | |
| ];
 | |
| 
 | |
| /**
 | |
|  * Checks if a status code is allowed in a close frame.
 | |
|  *
 | |
|  * @param {Number} code The status code
 | |
|  * @return {Boolean} `true` if the status code is valid, else `false`
 | |
|  * @public
 | |
|  */
 | |
| function isValidStatusCode(code) {
 | |
|   return (
 | |
|     (code >= 1000 &&
 | |
|       code <= 1014 &&
 | |
|       code !== 1004 &&
 | |
|       code !== 1005 &&
 | |
|       code !== 1006) ||
 | |
|     (code >= 3000 && code <= 4999)
 | |
|   );
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * Checks if a given buffer contains only correct UTF-8.
 | |
|  * Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by
 | |
|  * Markus Kuhn.
 | |
|  *
 | |
|  * @param {Buffer} buf The buffer to check
 | |
|  * @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`
 | |
|  * @public
 | |
|  */
 | |
| function _isValidUTF8(buf) {
 | |
|   const len = buf.length;
 | |
|   let i = 0;
 | |
| 
 | |
|   while (i < len) {
 | |
|     if ((buf[i] & 0x80) === 0) {
 | |
|       // 0xxxxxxx
 | |
|       i++;
 | |
|     } else if ((buf[i] & 0xe0) === 0xc0) {
 | |
|       // 110xxxxx 10xxxxxx
 | |
|       if (
 | |
|         i + 1 === len ||
 | |
|         (buf[i + 1] & 0xc0) !== 0x80 ||
 | |
|         (buf[i] & 0xfe) === 0xc0 // Overlong
 | |
|       ) {
 | |
|         return false;
 | |
|       }
 | |
| 
 | |
|       i += 2;
 | |
|     } else if ((buf[i] & 0xf0) === 0xe0) {
 | |
|       // 1110xxxx 10xxxxxx 10xxxxxx
 | |
|       if (
 | |
|         i + 2 >= len ||
 | |
|         (buf[i + 1] & 0xc0) !== 0x80 ||
 | |
|         (buf[i + 2] & 0xc0) !== 0x80 ||
 | |
|         (buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80) || // Overlong
 | |
|         (buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0) // Surrogate (U+D800 - U+DFFF)
 | |
|       ) {
 | |
|         return false;
 | |
|       }
 | |
| 
 | |
|       i += 3;
 | |
|     } else if ((buf[i] & 0xf8) === 0xf0) {
 | |
|       // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
 | |
|       if (
 | |
|         i + 3 >= len ||
 | |
|         (buf[i + 1] & 0xc0) !== 0x80 ||
 | |
|         (buf[i + 2] & 0xc0) !== 0x80 ||
 | |
|         (buf[i + 3] & 0xc0) !== 0x80 ||
 | |
|         (buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80) || // Overlong
 | |
|         (buf[i] === 0xf4 && buf[i + 1] > 0x8f) ||
 | |
|         buf[i] > 0xf4 // > U+10FFFF
 | |
|       ) {
 | |
|         return false;
 | |
|       }
 | |
| 
 | |
|       i += 4;
 | |
|     } else {
 | |
|       return false;
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   return true;
 | |
| }
 | |
| 
 | |
| module.exports = {
 | |
|   isValidStatusCode,
 | |
|   isValidUTF8: _isValidUTF8,
 | |
|   tokenChars
 | |
| };
 | |
| 
 | |
| if (isUtf8) {
 | |
|   module.exports.isValidUTF8 = function (buf) {
 | |
|     return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
 | |
|   };
 | |
| } /* istanbul ignore else  */ else if (!process.env.WS_NO_UTF_8_VALIDATE) {
 | |
|   try {
 | |
|     const isValidUTF8 = require('utf-8-validate');
 | |
| 
 | |
|     module.exports.isValidUTF8 = function (buf) {
 | |
|       return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
 | |
|     };
 | |
|   } catch (e) {
 | |
|     // Continue regardless of the error.
 | |
|   }
 | |
| }
 |