Intelligent agent remote operation system and method

By using read/write separation of Web sockets and HTTP services, and dynamic threshold-based block file transfer, the problems of large file transfer and resource isolation in remote operation of intelligent agents are solved, achieving efficient, low-latency file transfer and resource management, and reducing network burden and maintenance costs.

CN121967392APending Publication Date: 2026-05-01HANGZHOU NETEASE ZHIQI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU NETEASE ZHIQI TECH CO LTD
Filing Date
2025-12-29
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing remote operation solutions for intelligent agents suffer from problems such as high memory consumption for large file transfers, file transfer limits, high connection overhead, low real-time transmission performance, and inadequate resource isolation. These issues lead to heavy network load, high latency, excessively wide file change monitoring scope, inconsistent tool integration, and chaotic resource management.

Method used

It adopts Web socket service and HTTP service to achieve read and write separation, supports bidirectional communication and real-time feedback on transmission progress through dynamic threshold block file transfer, dynamically calculates working directory for resource isolation, provides filtered file monitoring and standardized tool names, and adopts tree termination mechanism for resource cleanup.

Benefits of technology

It enables high-concurrency, low-latency large file transfer, reduces connection burden and network overhead, supports multiple projects concurrently, reduces resource consumption and maintenance costs, improves transmission efficiency and accuracy, and avoids resource waste and monitoring interference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121967392A_ABST
    Figure CN121967392A_ABST
Patent Text Reader

Abstract

The invention relates to an agent remote operation system and method in the technical field of agents. A communication layer of the system comprises Web socket service and HTTP service, and a service layer comprises a file management module and a local file system. The Web socket service is used for responding to a Web socket connection request of the intelligent agent client and dynamically calculating a working directory so as to establish Web socket connection with isolated working areas; the file management module responds to a write-in request initiated by the intelligent agent client through the Web socket service, and executes dynamic threshold value block type file write-in to a local file system through Web socket connection; and the file management module is also used for responding to a static reading request initiated by the intelligent agent client through the HTTP service, and executing dynamic threshold block type file reading from the local file system through the HTTP connection. According to the scheme, the read-write separated dynamic threshold value is transmitted in a blocking manner, so that the transmission requirement is flexibly met; and a working directory is dynamically calculated to realize working area resource isolation.
Need to check novelty before this filing date? Find Prior Art

Description

Remote Operation System and Method for Intelligent Agents Technical Field

[0001] The embodiments of this disclosure relate to the field of intelligent agent technology, and more specifically, to intelligent agent remote operation systems, intelligent agent remote operation methods, computer-readable media, and electronic devices. Background Technology

[0002] This section is intended to provide background or context for the embodiments of this disclosure set forth in the claims, and the description herein is not acknowledged as prior art simply because it is included in this section.

[0003] Intelligent agents, also known as artificial intelligence agents (AI agents), can perceive the environment, make autonomous decisions and execute instructions, support long-term memory, task and problem decomposition and logical analysis, and provide more complex intelligent services.

[0004] Currently, remotely configured agent runtime environments can be accessed via clients to perform file transfers, command execution, tool invocation, and inference analysis, eliminating the need for local configuration. Conventional remote agent runtime solutions suffer from several issues. For example, the commonly used File Transfer Protocol (FTP) and Secure File Transfer Protocol (SFTP) suffer from high memory consumption for large file transfers, file transfer limits, and significant connection overhead. Furthermore, the dynamic nature of file transfers requires active client polling, resulting in low real-time performance, heavy network load, and high latency. Summary of the Invention

[0005] In this context, embodiments of the present disclosure are intended to provide an agent remote operation system, an agent remote operation method, a computer-readable medium, and an electronic device.

[0006] According to a first aspect of the present disclosure, a remote operation system for an intelligent agent is provided. The system includes a Web socket service and an HTTP service at the communication layer, a file management module at the service layer, and a local file system. The Web socket service is used to dynamically calculate a working directory and establish a workspace-isolated Web socket connection based on the working directory in response to a Web socket connection request from an intelligent agent client. The file management module is used to perform dynamic threshold-based block file writing to the local file system via a Web socket connection in response to a write request initiated by the intelligent agent client through the Web socket service. The file management module is also used to perform dynamic threshold-based block file reading from the local file system via an HTTP connection in response to a static read request initiated by the intelligent agent client through the HTTP service.

[0007] According to a second aspect of the present disclosure, a method for remote operation of an intelligent agent is provided. The method may include: dynamically calculating a working directory in response to a Web socket connection request from an intelligent agent client; establishing a working-area isolated Web socket connection based on the working directory; performing dynamic threshold-based block file writing via the Web socket connection in response to a write request initiated by the intelligent agent client; and performing dynamic threshold-based block file reading via an HTTP connection in response to a static read request initiated by the intelligent agent client.

[0008] According to a third aspect of the present disclosure, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described method for remote operation of an intelligent agent.

[0009] According to the intelligent agent remote operation system and the intelligent agent remote operation method implemented based on the present disclosure, the system includes a Web socket service and an HTTP service at the communication layer, a file management module and a local file system at the service layer; wherein, the Web socket service can dynamically calculate the working directory and establish a working area isolated Web socket connection based on the working directory in response to the Web socket connection request of the intelligent agent client; the file management module can perform dynamic threshold block file writing to the local file system via Web socket connection in response to the write request initiated by the intelligent agent client through the Web socket service; the file management module can also perform dynamic threshold block file reading from the local file system via HTTP connection in response to the static read request initiated by the intelligent agent client through the HTTP service. This solution employs a dynamic threshold-based block file transfer with read-write separation. Web sockets handle file writing, enabling bidirectional communication and real-time progress feedback. HTTP handles file reading, effectively achieving high-concurrency, low-latency large file transfers and supporting resumeable interruptions. This dual-protocol separation flexibly adapts to file transfer needs, reducing connection burden and network overhead. Furthermore, the solution dynamically calculates the working directory, isolating Web socket connections and maintaining independent resources for different working directories, avoiding interference from multiple projects and supporting multi-project concurrency within a single instance. Attached Figure Description

[0010] The above and other objects, features, and advantages of exemplary embodiments of the present disclosure will become readily apparent upon reading the following detailed description with reference to the accompanying drawings. Several embodiments of the present disclosure are illustrated in the drawings by way of example and not limitation, wherein: Figure 1 shows one of the schematic architectural diagrams of an intelligent agent remote operation system according to an embodiment of the present disclosure.

[0011] Figure 2 shows a schematic diagram of file transfer data flow according to an embodiment of the present disclosure.

[0012] Figure 3 shows a second schematic diagram of the architecture of the intelligent agent remote operation system according to an embodiment of the present disclosure.

[0013] Figure 4 illustrates a schematic diagram of the rule parsing process according to an embodiment of this disclosure.

[0014] Figure 5 shows the third schematic diagram of the architecture of the intelligent agent remote operation system according to an embodiment of the present disclosure.

[0015] Figure 6 illustrates a schematic diagram of the tool invocation matching process according to an embodiment of this disclosure.

[0016] Figure 7 shows the fourth schematic diagram of the architecture of the intelligent agent remote operation system according to an embodiment of the present disclosure.

[0017] Figure 8 shows a schematic diagram of the workspace mode architecture of an embodiment of this disclosure.

[0018] Figure 9 shows the fifth schematic diagram of the architecture of the intelligent agent remote operation system according to an embodiment of the present disclosure.

[0019] Figure 10 illustrates the file writing process provided by the agent remote operation method according to an embodiment of this disclosure.

[0020] Figure 11 illustrates one of the file reading processes provided by the agent remote operation method according to an embodiment of this disclosure.

[0021] Figure 12 illustrates a second file reading process provided by the agent remote operation method according to an embodiment of this disclosure.

[0022] Figure 13 illustrates the file monitoring process provided by the agent remote operation method according to an embodiment of this disclosure.

[0023] Figure 14 illustrates the tool invocation flow provided by the agent remote operation method of this disclosure.

[0024] Figure 15 illustrates the command execution and process management flow provided by the intelligent agent remote operation method according to an embodiment of the present disclosure.

[0025] Figure 16 illustrates the port monitoring process provided by the agent remote operation method according to an embodiment of this disclosure.

[0026] Figure 17 illustrates one of the resource cleanup processes provided by the agent remote operation method according to an embodiment of the present disclosure.

[0027] Figure 18 illustrates a second resource cleanup process provided by the agent remote operation method according to an embodiment of this disclosure.

[0028] Figure 19 shows a schematic diagram of a computer-readable medium according to an embodiment of the present disclosure. Detailed Implementation

[0029] The principles and spirit of this disclosure will now be described with reference to several exemplary embodiments. It should be understood that these embodiments are given merely to enable those skilled in the art to better understand and implement this disclosure, and are not intended to limit the scope of this disclosure in any way. Rather, these embodiments are provided to make this disclosure more thorough and complete, and to fully convey the scope of this disclosure to those skilled in the art. Those skilled in the art will recognize that embodiments of this disclosure can be implemented as a system, apparatus, device, method, or computer program product. Therefore, this disclosure can be embodied in the following forms: entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.

[0030] According to embodiments of this disclosure, a method and apparatus for remote operation of an intelligent agent are provided. In this document, the number of any element in the accompanying drawings is for illustrative purposes only and not for limitation, and any naming is for distinction only and has no limiting meaning. The principles and spirit of this disclosure are described in detail below with reference to several representative embodiments.

[0031] In traditional AI remote operation solutions, remote file access typically uses FTP, SFTP, etc., where reading and writing share the same transmission channel, leading to mutual blocking and limited concurrency capabilities, resulting in certain performance issues. For example, loading the file into memory all at once can cause excessive memory consumption, or even memory overflow and connection interruption, during the transfer of multiple or large files. There are also limitations on the size of files that can be processed, especially gigabyte (GB) level files, and the need to establish a connection for each operation leads to high network overhead. There are also some real-time issues, requiring the client to actively poll to determine the file change status, resulting in high network load and high latency.

[0032] In the embodiments disclosed herein, the AI ​​remote agent remote operation system and the AI ​​remote operation method implemented based on the system use Web socket service and HTTP service to achieve read-write separation. The two-way communication of Web socket service supports real-time write progress feedback, and the HTTP service supports file reading without occupying the Web socket connection queue. It can also achieve high-concurrency access and breakpoint resume. On this basis, by performing dynamic threshold block file transfer, it can flexibly adapt to the transmission requirements of different file sizes, avoid excessive resource consumption by large files, and also expand the upper limit of file transmission size.

[0033] In traditional solutions, resource isolation for running multiple projects is often inadequate, which may lead to interference between projects. When different projects are configured with independent containers, resource consumption is high, startup time is long, configuration is complex, and maintenance costs are high.

[0034] In one embodiment of this disclosure, when establishing a Web socket connection, workspace isolation is performed based on the working directory to isolate resources and configurations between different projects. This solution eliminates the need for independent container configuration, reducing resource consumption and startup time. It flexibly supports resource isolation and sharing between multiple projects when different projects point to different working directories, reducing configuration difficulty and maintenance costs.

[0035] Traditional solutions typically monitor file changes globally, resulting in an excessively broad monitoring scope, a lack of contextual awareness of directories, and the generation of numerous useless events that can disrupt normal system operation. Furthermore, it is usually necessary to maintain an independent monitoring instance for each client, leading to redundant resource consumption and the potential for triggering multiple intermediate events during file transfers, resulting in wasted bandwidth. Additionally, there may be some cross-platform compatibility issues.

[0036] In one embodiment of this disclosure, a scheme for filtered file monitoring via monitoring instances corresponding to the working directory is also provided. This scheme flexibly adjusts the monitoring scope through filtered monitoring, effectively avoiding interference from useless events. Furthermore, since monitoring instances are obtained based on the working directory, they can be reused among requests pointing to the same working directory, avoiding redundant consumption of monitoring resources. It also avoids the problem of multiple triggering of intermediate events caused by multiple monitoring instances monitoring the working directory, reducing bandwidth waste. In addition, cross-platform path standardization is provided to ensure compatibility with file monitoring on different platforms, avoiding monitoring failures caused by inconsistent cross-platform path processing.

[0037] In traditional solutions, the integration of artificial intelligence tools suffers from inconsistent protocols, resulting in high integration costs and difficulty in expansion. In multi-tool scenarios, there may also be conflicts such as duplicate or non-standard tool names.

[0038] In one embodiment of this disclosure, when integrating multiple Model Context Protocol (MCP) servers, server names and tool names are standardized, and a routing mapping based on tool name prefix matching is established. This enables efficient integration of multi-protocol tools through the MCP. Furthermore, by standardizing server names and tool names and adding prefixes, call failures caused by duplicate or non-standard tool names can be avoided, improving the accuracy and effectiveness of tool calls.

[0039] Traditional solutions often suffer from chaotic management of connections, instances, processes, or other resources, lacking a proper way to shut down and clean up. This can lead to problems such as connection leaks, resource waste, and cleanup of remnants. For example, child processes may remain after the parent process terminates, socket connections may remain when a service exits abnormally, ports may not be released when a connection is closed, or data may be lost due to abnormal shutdown.

[0040] In one embodiment of this disclosure, a tree-based termination mechanism can be used when a process is closed to avoid child process remnants.

[0041] In one embodiment of this disclosure, a hierarchical resource cleanup scheme can also be adopted, which performs hierarchical and orderly resource cleanup at the socket level, service level, etc.; furthermore, resource release verification can also be performed to effectively avoid problems such as connection leakage and resource cleanup residue.

[0042] In addition, in one embodiment of this disclosure, port status can be recursively polled for detection, and automatic port allocation can be performed. This solution can provide real-time feedback on port status changes, and dynamically allocate and release ports in a timely manner to adapt to changes in port requirements within the system.

[0043] Based on this, in one embodiment of the present disclosure, the artificial intelligence remote agent remote operation system can integrate the technical solutions of the above-mentioned different implementation methods, thereby fully realizing the above-mentioned effects.

[0044] After introducing the basic principles of the present invention, various non-limiting embodiments of the present invention will be described in detail below.

[0045] Exemplary application scenarios

[0046] It should be noted that the following application scenarios are shown only to facilitate understanding of the spirit and principles of the present invention, and the embodiments of this disclosure are not limited in any way. On the contrary, the embodiments of this disclosure can be applied to any applicable scenario.

[0047] The intelligent agent remote operation system and the intelligent agent remote operation method implemented based on the intelligent agent remote operation system disclosed herein can be applied to various application scenarios involving intelligent agent remote operation. In one application scenario, it can be software development implemented by an intelligent agent. The intelligent agent client can remotely connect to the system to create corresponding projects, perform project configuration, environment deployment, etc., and then realize application processes such as tool invocation and command execution. Thus, based on the business requirements of software development, the intelligent agent can build, orchestrate, and execute tasks such as development requirements analysis, software function design, code generation and updating, test case generation, and automated testing. Alternatively, similarly, it can also involve scenarios such as manufacturing, remote office, customer service marketing, financial risk control, and internet content creation implemented by intelligent agents. This disclosure does not impose specific limitations on these scenarios.

[0048] Exemplary System

[0049] The following description, in conjunction with the above application scenarios and with reference to FIG1, describes an intelligent agent remote operation system according to an exemplary embodiment of the present disclosure. FIG1 shows one of the architectural schematic diagrams of an intelligent agent remote operation system 100 according to an exemplary embodiment of the present disclosure. The system 100 may include a Web socket service 111 and an HTTP service 112 in the communication layer 110, a file management module 121 in the service layer 120 of the system 100, and a local file system 130 in the system.

[0050] In this embodiment, the system 100 can provide communication services corresponding to WebSocket and HTTP (Hypertext Transfer Protocol) protocols to the intelligent agent client at the Communication Layer 110. Specifically, the WebSocket service 111 can perform request-response, data transmission, and command distribution conforming to the WebSocket protocol, while the HTTP service 112 can perform request-response and data transmission conforming to the HTTP protocol. Depending on the type of request initiated by the intelligent agent client, the Communication Layer 110 can respond with the corresponding type of service to flexibly adapt to the actual business needs of the intelligent agent client.

[0051] In this embodiment of the disclosure, the system 100 may provide a file management module 121 in the service layer 120 to support file change management. The file management module 121 may respond to a file transfer request transmitted from the communication layer 110 by the agent client to perform file writing to or file reading from the local file system.

[0052] In this embodiment of the disclosure, the system 100 further includes a local file system 130, which supports the structured storage of file data written by the file management module 121, and provides file data query and reading services to the file management module 121.

[0053] Specifically, in this system 100, the Web socket service 111 is used to respond to the Web socket connection request from the intelligent agent client, dynamically calculate the working directory, and establish a workspace-isolated Web socket connection based on the working directory.

[0054] In this embodiment, the intelligent agent client can be directed to a user or other intelligent agent, converting the user's natural language instructions or the output of other intelligent agents into requests, commands, etc., that the system 100 can understand and respond to, in order to invoke the intelligent agent functions and services provided by the system 100. For example, the intelligent agent client can initiate the aforementioned Web socket connection request, or it can initiate other file transfer requests, tool call requests, etc. The system 100 can provide task processing, analysis, calculation, or other capabilities, which, when invoked by the intelligent agent client, automatically respond to requests and execute commands in a remote operating environment and provide feedback to the intelligent agent client. The intelligent agent client can select the corresponding SDK (Software Development Kit) for creation, testing, and deployment according to actual needs. For example, in the business scenario of software project development, the intelligent agent client can use an IDE (Integrated Development Environment) to integrate the client, so as to invoke the intelligent agent services provided by the system 100 in the development environment. In other business scenarios such as manufacturing, remote office, customer service marketing, financial risk control, and Internet content creation, those skilled in the art can also choose a suitable intelligent agent client according to their needs, and this embodiment does not impose specific limitations on this. The intelligent agent client can remotely operate and interact with the system 100 through the communication layer 110.

[0055] In this embodiment, system 100 can receive WebSocket connection requests initiated by an agent client to establish corresponding WebSocket connections. The working directory (workDir) can specify the storage path and location corresponding to the WebSocket connection in the local file system 130, and can be automatically created if the corresponding storage path and location do not exist. The working directory can be calculated by the WebSocket service 111 based on the information transmitted in the WebSocket connection request. For example, in a project development scenario, the agent client can transmit information such as project ID and workspace ID based on the WebSocket connection request. The WebSocket service 111 can then dynamically calculate the corresponding working directory based on the project ID and workspace ID, and establish workspace-isolated WebSocket connections based on this working directory. Requests from different projects can be distinguished by the project ID. Performing workspace isolation through the working directory avoids the high costs of container startup and maintenance, and also allows for flexible adjustment of resource isolation and sharing dimensions, supports resource reuse within the same working directory, reduces redundant resource consumption, and minimizes resource usage.

[0056] Specifically, in the system 100, the file management module 121 is used to respond to the write request initiated by the intelligent agent client through the Web socket service 111, and perform dynamic threshold block-based file writing to the local file system 130 via the Web socket connection.

[0057] In this embodiment of the disclosure, during file writing and transmission, a write request initiated by an intelligent agent client through the WebSocket service 111 can be received. This write request instructs the corresponding file data to be written to the local file system 130 via a WebSocket connection. Writing via a WebSocket connection allows for real-time feedback of file transfer progress using bidirectional communication, making it suitable for interactive operation. It also enables automatic cleanup when the connection is lost. Furthermore, the use of dynamic threshold block-based file writing allows for dynamic selection of whether to transmit in blocks or adjust the block size based on the file size, thus flexibly adapting to different transmission needs for small and large files.

[0058] Specifically, in the system 100, the file management module 121 is also used to respond to a static read request initiated by the intelligent agent client through an HTTP service, and to perform dynamic threshold block-based file reading from the local file system 130 via an HTTP connection.

[0059] In this embodiment of the disclosure, during file reading and transmission, the file management module 121 can receive a static read request initiated by the intelligent agent client through the HTTP service 112. This static read request indicates access to and reading of static file resources in the local file system 130 via an HTTP connection. Reading via an HTTP connection does not consume the limited number of WebSocket connections, supports concurrent access, and has higher unidirectional transmission efficiency. Furthermore, the HTTP protocol is natively supported by browsers, requiring no additional encapsulation, and also supports features such as specified endpoints for resuming transmission within a specified reading range using Range requests. Based on this, a dynamic threshold-based block-based file reading method is adopted, which can dynamically select whether to transmit in blocks or adjust the block size according to the file size, thereby flexibly adapting to different transmission needs for small and large files.

[0060] Therefore, the file management module 121 and other possible functional modules in system 100 can support multiple transmission protocols such as WebSocket and HTTP with the local file system 130, thereby achieving read-write separation through different transmission protocols. In an optional system embodiment of this disclosure, a transmission layer can be set up in the interaction between the local file system and other functional modules. The transmission layer may include, for example, a file write channel corresponding to the WebSocket protocol, a file read channel corresponding to HTTP, etc., to implement multiple transmission protocols.

[0061] Based on the aforementioned Figure 1, in an optional system embodiment of this disclosure, the file management module 121 is configured to respond to a write request initiated by the intelligent agent client through the Web socket service 111, and when the write file is less than the write threshold, write the write file to the local file system 130 in a single transmission via the Web socket connection; the file management module 121 is also configured to respond to a write request initiated by the intelligent agent client through the Web socket service 111, and when the write file is greater than or equal to the write threshold, divide the write file into data blocks and write them to the local file system 130 via streaming transmission via the Web socket connection.

[0062] In this embodiment, dynamic threshold-based block-based file writing dynamically selects the file transfer method based on the write threshold and the size of the file to be written. The file to be written can be the file data specified by the intelligent agent client through a write request initiated by the WebSocket service 111. When the file size is smaller than the threshold, data block-based writing can be skipped, and the file can be directly written to local storage in a single transmission via the WebSocket connection. When the file size is greater than or equal to the write threshold, data block-based writing can be performed, and the file can be written to the local file system 130 via a streaming block-based transmission via the WebSocket connection. The write threshold can be set according to factors such as transmission performance and business requirements; it can be statically set or adaptively adjusted. The size of the data block can be referenced to the write threshold or set separately; this embodiment does not impose specific limitations on this. Thus, the memory usage of the write stream is constant, achieving decoupling between memory usage and file size.

[0063] For example, taking a write threshold of 5MB as an example, when the file to be written is less than 5MB, it is directly written to the local file system 130 in a single transmission; when the file to be written is greater than or equal to 5MB, the file to be written can be divided into data blocks so that each block is less than or equal to 5MB, and then the file can be written to the local file system 130 in a streaming manner.

[0064] In an optional system embodiment of this disclosure, the write request corresponds to at least one of a file upload operation and a file modification operation.

[0065] In this embodiment of the disclosure, the write request can be initiated by the intelligent agent client when performing file-related operations such as file upload or file modification. Depending on the operation type, writing to the local file system 130 can involve adding files or modifying and overwriting existing files.

[0066] In one optional system embodiment of this disclosure, errors may still occur during the file writing process, such as channel errors at the file writing task level or WebSocket connection drops. Appropriate handling methods can be adopted for different errors.

[0067] Based on Figure 1 above, in an optional system embodiment of this disclosure, the file management module 121 is configured to, in response to a static read request initiated by the agent client through HTTP service 112, provide the static read file in the local file system 130 to the agent client via a single transmission using an HTTP connection when the static read file is less than the static read threshold; the file management module 121 is also configured to, in response to a static read request initiated by the agent client through HTTP service 112, divide the static read file into data blocks and provide them to the agent client via streaming transmission using an HTTP connection when the static read file is greater than or equal to the static read threshold.

[0068] In this embodiment, the dynamic threshold-based block-based file reading of static read requests can dynamically select the file transfer method based on the static read threshold and the size of the static read file. The static read file can be the file data specified in the static read request initiated by the intelligent agent client to the HTTP service 112, and static reading is performed by the file management module 121. When the static read file is smaller than the static read threshold, data block-based reading can be omitted, and the static read file can be read from the local file system 130 in a single transmission via an HTTP connection. When the static read file is greater than or equal to the static read threshold, data block-based reading can be performed on the static read file, and the static read file can be read from the local file system 130 through streaming block-based transmission. The static read threshold can be set according to factors such as transmission performance and business requirements. It can be set statically or adaptively. The size of the data block can be referenced to the write threshold or set separately. This embodiment does not impose specific limitations on this.

[0069] For example, taking a static read threshold of 5MB as an example, when the static read file is less than 5MB, it is read directly from the local file system 130 in a single transfer; when the static read file is greater than or equal to 5MB, it is read from the local file system 130 based on data blocks using streaming transfer.

[0070] In an optional system embodiment of this disclosure, the file management module 121 is further configured to, in response to a static read request initiated by the agent client via HTTP service 112, determine the read range of the target file in the local file system 130; specifically, the file management module 121 is further configured to, when the read range is less than the static read threshold, provide the static read file to the agent client via a single transmission using an HTTP connection based on the read range of the target file; specifically, the file management module 121 is further configured to, when the read range is greater than or equal to the static read threshold, divide the static read file into data blocks based on the read range of the target file and provide them to the agent client via streaming transmission using an HTTP connection.

[0071] In this embodiment, based on the characteristics of the HTTP protocol, the reading range of the target file in the local file system 130 can also be specified through a Range request. Specifying the reading range can improve transmission efficiency and reduce bandwidth consumption. The intelligent agent client can also realize functions such as breakpoint resumption, on-demand loading, and streaming media playback. The reading range of the target file is specified by the intelligent agent client through a static reading request initiated by the HTTP service 112. The reading range can be a single continuous byte range or multiple non-contiguous byte ranges. This embodiment does not impose specific limitations on this. Based on this, dynamic threshold block reading can be referred to the foregoing relevant descriptions, and will not be repeated here to avoid repetition. At this time, the statically read file corresponds to the target file within the reading range.

[0072] In an optional system embodiment of this disclosure, the file management module 121 is specifically used to determine the reading range of the target file when the target file exists in the local file system 130 in response to a static read request initiated by the intelligent agent client through the HTTP service 112; the file management module 121 is also specifically used to prompt the intelligent agent client with a read error when the target file does not exist in the local file system 130 in response to a static read request initiated by the intelligent agent client through the HTTP service.

[0073] In this embodiment of the disclosure, during static file reading, reading errors may occur, such as the specified target file not existing or the specified reading range not existing. In this case, in response to the static read request, the specified object can be verified. For example, if the target file exists in the local file system 130, the specified reading range on the target file can be further determined; if the target file does not exist, a reading error message can be returned to the intelligent agent client. The above-mentioned reading errors are merely examples, and those skilled in the art can design corresponding handling schemes for other possible errors.

[0074] In this embodiment, the HTTP connection does not occupy the limited connection resources in the WebSocket queue, breaking through the limitation that each WebSocket connection needs to maintain a heartbeat and event queue. It can achieve concurrent requests in a stateless manner, and release the connection after reading without needing to maintain it, thus not occupying long-term connection resources. At the same time, it can also utilize the characteristics of the HTTP protocol to achieve automatic Koa-send processing, including breakpoint resumption, ETag (entity tag) cache verification, last-modified (last modified time) caching, Gzip compression, Brotli compression, and automatic MIME (Multipurpose Internet Mail Extensions) recognition. On this basis, it can also obtain native browser support to achieve concurrent downloads, automatic cache management, preloading, and pre-connection.

[0075] Based on the aforementioned Figure 1, in an optional system embodiment of this disclosure, the file management module 121 is further configured to respond to an interactive read request initiated by the intelligent agent client through the Web socket service 111, and perform dynamic threshold block-based file reading from the local file system 130 via a Web socket connection.

[0076] In this embodiment of the disclosure, during file reading and transmission, the file management module 121 can also respond to an interactive read request initiated by the smart agent client to the WebSocket service 111. This interactive read request indicates that interactive file resources in the local file system 130 be read via a WebSocket connection. For example, interactive files may include configuration files, code files, packaged files, media files, database files, etc. Dynamic threshold-based block file reading can be referred to the foregoing related descriptions; to avoid repetition, it will not be repeated here.

[0077] In an optional system embodiment of this disclosure, the file management module 121 is further configured to, in response to an interactive read request initiated by the agent client through the Web socket service, provide the interactive read file in the local file system 130 to the agent client via a single transmission using a Web socket connection when the interactive read file is less than the interactive read threshold; the file management module 121 is further configured to, in response to an interactive read request initiated by the agent client through the Web socket service, divide the interactive read file into data blocks and provide them to the agent client via streaming transmission using a Web socket connection when the interactive read file is greater than or equal to the interactive read threshold.

[0078] In this embodiment, dynamic threshold-based block file reading dynamically selects the file transfer method based on the interactive reading threshold and the size of the interactive reading file. The interactive reading file can be the file data specified in the read request initiated by the intelligent agent client to the WebSocket service 111, and the interactive reading is performed by the file management module 121. When the interactive reading file is smaller than the interactive reading threshold, data block reading can be omitted, and the interactive reading file can be read from the local file system 130 in a single transmission via the WebSocket connection. When the interactive reading file is greater than or equal to the interactive reading threshold, data block reading can be performed on the interactive reading file, and the interactive reading file can be read from the local file system 130 through streaming block transmission. The interactive reading threshold can be set according to factors such as transmission performance and business requirements. It can be statically set or adaptively adjusted. The size of the data block can be referenced to the write threshold or set separately. This embodiment does not impose specific limitations on this.

[0079] For example, taking an interactive read threshold of 5MB as an example, when the interactive read file is less than 5MB, it is read directly from the local file system 130 in a single transfer; when the interactive read file is greater than or equal to 5MB, it is read from the local file system 130 based on data blocks using streaming transfer.

[0080] Figure 2 shows a schematic diagram of file transfer data flow in an exemplary embodiment of this disclosure. When the intelligent agent client initiates a file transfer request, it performs corresponding processing according to the operation type.

[0081] When the operation type is file write, the file is written to the local file system in a dynamically thresholded chunked manner using a WebSocket connection; when the operation type is file read and it is interactive read, the file is read from the local file system in a dynamically thresholded chunked manner using a WebSocket connection; when the operation type is file read and it is static read, the file is read from the local file system in a dynamically thresholded chunked manner using an HTTP connection.

[0082] When writing via WebSocket connection, corresponding write tasks can be created to achieve task-level write management; when reading via HTTP connection, it supports resuming interrupted downloads of HTTP Range requests, as well as other file download functions. For details, please refer to the relevant explanation in Figure 1 above; to avoid repetition, it will not be repeated here.

[0083] Therefore, the file transfer strategy of reading and writing separation can effectively optimize memory, provide concurrency support, reduce congestion and improve transmission efficiency. In addition, the ability to flexibly select the corresponding protocol to perform file transfer according to the instructions of the intelligent agent client can make full use of the characteristics and advantages of different protocols to adapt to different transmission needs and has a wider range of applications.

[0084] Figure 3 shows a second schematic diagram of the architecture of the intelligent agent remote operation system 300 according to an exemplary embodiment of this disclosure. The system 300 may include a Web socket service 311 and an HTTP service 312 in the communication layer 310, a file management module 321 in the service layer 320, and a local file system 330.

[0085] Web socket service 311 is used to respond to Web socket connection requests from intelligent agent clients, dynamically calculate the working directory, and establish Web socket connections with workspace isolation based on the working directory; file management module 321 is used to respond to write requests initiated by intelligent agent clients through Web socket service 311, and perform dynamic threshold block-based file writing to local file system 330 through Web socket connections; file management module 321 is also used to respond to static read requests initiated by intelligent agent clients through HTTP service 312, and perform dynamic threshold block-based file reading from local file system 330 through HTTP connections.

[0086] In this embodiment of the disclosure, system 300 can be referred to in the relevant description of system 100 above, and will not be repeated here to avoid repetition. For example, WebSocket service 311 can be implemented based on Socket.IO Server (WebSocket protocol library), and HTTP service 312 can be implemented based on koa HTTP Server (HTTP middleware framework).

[0087] In this embodiment of the disclosure, the system 300 may further include a file monitoring module 322 in the service layer 320, which is used to obtain monitoring instances based on the working directory to perform filtered file monitoring.

[0088] In this embodiment, to monitor file data change events in the local file system 330, a corresponding monitoring instance can be obtained based on the working directory, and then filtered file monitoring can be performed on the file data in the working directory based on the monitoring instance. The local file system can organize file data in a structured directory format, and the working directory specifies the storage path and location corresponding to the WebSocket connection. Based on this, the monitoring instance corresponding to the working directory can monitor file change events in the working directory and promptly report back to the corresponding agent client. Therefore, a new monitoring instance can be created when a new working directory is created, or a new monitoring instance can be created if no monitoring instance exists in the working directory. If a monitoring instance already exists in the working directory, it can be directly obtained and reused. When multiple agent clients correspond to the same working directory, a single monitoring instance can be reused. The monitoring instance can then push the file change events monitored in the working directory to multiple agent clients subscribed to that file directory, thereby reducing CPU and memory usage and significantly saving resource consumption. For example, file change events can include adding a file, modifying file content, adding a directory, deleting a file, and deleting a directory.

[0089] In this embodiment, the monitoring instance can perform filtered file monitoring on the working directory to adjust the scope of file monitoring, avoid focusing on unnecessary files, and prevent excessive intermediate events from interfering with business operations. The filtering scope can be set according to business needs, such as specifying the file name, file type, or directory where the file is located, etc., and this embodiment does not impose specific limitations on this.

[0090] In an optional system embodiment of this disclosure, the file monitoring module 322 is specifically used to recursively search for file directories containing filtering rules from the working directory to the subdirectories in the file directory of the local file system, and to search for the first file directory containing filtering rules in the parent directory of the working directory, and to create an independent file filtering instance for each file directory containing filtering rules.

[0091] In this embodiment, the local file system can organize file data in a hierarchical file directory structure. A parent-child inheritance relationship exists within the file directories; each parent directory can include several subdirectories, and each parent directory can also be a subdirectory of its parent. The working directory, within this hierarchical file directory structure, can be either a parent directory of a subdirectory or a subdirectory of its parent. The file monitoring module 322 can provide bidirectional filtering rule parsing, starting from the working directory and recursively searching downwards through subdirectories to identify file directories containing filtering rules; and upwards through parent directories to identify the first file directory containing filtering rules. Based on this, an independent file filtering instance (ignore instance) is created for each file directory containing filtering rules. Therefore, when monitoring file change events in the working directory, targeted filtering monitoring can be performed on file change events in associated subdirectories and parent directories to adjust the monitoring scope. For example, filtering rules can be placed in the corresponding file directory as .gitignore files.

[0092] Building upon this, file filter instances allow for targeted and selective monitoring of file change events. Specifically, file data can be matched hierarchically within file directories, such as calling file filter instances level by level to match filtering rules. If a rule is matched, the file data is ignored; if no rule is matched up to the root directory, the file data continues to be monitored.

[0093] In an optional system embodiment of this disclosure, the file monitoring module 322 is further configured to perform cross-platform normalization processing on the storage path of the file directory.

[0094] In this embodiment of the disclosure, the file monitoring module 322 performs cross-platform standardization processing on the storage path of the file directory, which may include format unification, character type unification, and redundant information cleaning, such as unifying the path separator to " / ", character conversion to lowercase, and removing redundant ". / " and ".. / ", thereby achieving cross-platform compatibility.

[0095] In an optional embodiment of this disclosure, the local file system 330 may be configured with a rule parsing engine (not shown in Figure 3) for traversing the file directory. As shown in Figure 4, which is a schematic diagram of the rule parsing process of an exemplary embodiment of this disclosure, the rule parsing engine (FileFilter) is initialized when it starts up. When executed, it traverses the subdirectories in the local file system 330 from the working directory downwards, and determines the file directory containing the filtering rules in the subdirectories.

[0096] After traversing the subdirectories, search upwards level by level for the parent directories. If no filtering rules exist in the parent directory, move to the parent directory above the parent directory and search until the root directory, or stop searching if filtering rules exist in the parent directory.

[0097] Create a file filtering instance for each file directory that contains filtering rules.

[0098] In the rule parsing process shown in Figure 4 above, filtering rules for different file directories can be added to the rule list to merge records, which facilitates the generation, management and invocation of file filtering instances.

[0099] Figure 5 shows a third schematic diagram of the architecture of the intelligent agent remote operation system 500 according to an exemplary embodiment of this disclosure. The system 500 may include a Web socket service 511 and an HTTP service 512 in the communication layer 510, a file management module 521 in the service layer 520, and a local file system 530.

[0100] Web socket service 511 is used to respond to Web socket connection requests from intelligent agent clients, dynamically calculate the working directory, and establish workspace-isolated Web socket connections based on the working directory; file management module 521 is used to respond to write requests initiated by intelligent agent clients through Web socket service 511, and perform dynamic threshold-based block file writing to the local file system 530 via Web socket connection; file management module 521 is also used to respond to static read requests initiated by intelligent agent clients through HTTP service 512, and perform dynamic threshold-based block file reading from the local file system 530 via HTTP connection.

[0101] In this embodiment of the disclosure, system 500 can be referred to in the relevant description of the aforementioned system 100, and will not be repeated here to avoid repetition. For example, WebSocket service 511 can be implemented based on Socket.IO Server (WebSocket protocol library), and HTTP service 512 can be implemented based on koa HTTP Server (HTTP middleware framework).

[0102] In this embodiment of the disclosure, the system 500 may further include a model context protocol management module 522 in the service layer 520, which is used to respond to the model context protocol initialization request initiated by the agent client through the Web socket service 511, establish a model context protocol connection with at least one model context protocol server, and establish a prefix matching route mapping based on the server name of the model context protocol server to obtain the canonical tool name.

[0103] In this embodiment of the disclosure, to address the issue of potentially duplicate or non-standard tool names provided by different MCP (Model Context Protocol) servers, the MCP management module 522 of the service layer 520 can perform name normalization processing on the connected MCP servers. Specifically, in response to an MCP initialization request initiated by the agent client via the WebSocket service 511, the MCP management module 522 establishes an MCP connection with at least one MCP server to register the calling tool corresponding to the MCP server. During the tool registration process, a prefix-matching route mapping can be established based on the server name of the MCP server to obtain the standardized tool name for registration. For example, if the MCP server provides an original tool name that may have name conflicts, a prefix-matching mechanism can be established based on the server name of the MCP server, allowing the standardized tool name to distinguish the calling tools provided by different MCP servers by using the server name as a prefix. Thus, efficient tool invocation can be achieved through route mapping based on the server name.

[0104] In an optional system embodiment of this disclosure, the server name can also be standardized, such as through format conversion, character unification, and symbol cleaning, to avoid the impact of non-standard names on matching efficiency and accuracy.

[0105] For example, the MCP server "my server@v1.0" provides the original tool name "read_file" for invoking the tool. The server name is cleaned to obtain "my_server_v1_0", and then a prefix-matching route mapping is established for the original tool name to obtain the canonical tool name "my_server_v1_0_read_file". Based on this, the original tool name used when invoking the tool can be determined through the mapping relationship between the canonical tool name and the original tool name, or it can be obtained from the part after the prefix in the canonical tool name.

[0106] In this embodiment of the disclosure, the model context protocol management module 522 is further configured to perform prefix matching in response to a tool call request initiated by the agent client through the Web socket service 511, execute the tool call based on the matching result by connecting the model context protocol with the standardized tool name, and return the tool execution result.

[0107] In this embodiment, the MCP management module 522 can provide all the obtained standardized tool names to the agent client, so that the agent client can indicate the standardized tool name when invoking a tool. Specifically, in response to a tool invocation request initiated by the agent client, the standardized tool name indicated by the agent client is prefixed with the server name. If the server name matches successfully, the original tool name is extracted using the standardized tool name, and the tool invocation is executed through the MCP connection. Based on this, the MCP management module 522 can return the tool execution result to the agent client.

[0108] In an optional system embodiment of this disclosure, the model context protocol management module 522 is specifically configured to obtain the canonical tool name to be invoked in response to a tool invocation request initiated by the agent client through the Web socket service 511, and to perform prefix matching between the canonical tool name to be invoked and the server name; the model context protocol management module 522 is further configured to execute the tool invocation of the corresponding model context protocol server based on the canonical tool name through the model context protocol connection when the canonical tool name to be invoked successfully matches the server name, and to return the tool execution result to the agent client; the model context protocol management module 522 is further configured to execute the tool invocation of the corresponding model context protocol server based on the default canonical tool name through the model context protocol connection when the canonical tool name to be invoked fails to match the server name, and to return the tool execution result to the agent client.

[0109] In this embodiment, the canonical tool name requested by the agent client can be obtained in response to the tool call request. The MCP management module can then perform prefix matching between the requested canonical tool name and the service names of the registered MCP servers. If the requested canonical tool name matches a server name successfully (meaning any server name matches the prefix of the requested canonical tool name), then the requested canonical tool name fails to match a server name (meaning none of the server names match the prefix of the requested canonical tool name). Based on this, if the match is successful, the original tool name can be extracted from the matched canonical tool name, thereby accurately calling the corresponding tool and returning the tool execution result to the agent client. If the match fails, the tool call can be executed using a default MCP server. The default MCP server can correspond to the first MCP server matched by the original tool name, the last MCP server, or any other server. The default MCP server can also be arbitrarily specified among all MCP servers; this embodiment does not impose specific limitations on this.

[0110] In an optional system embodiment of this disclosure, the model context protocol management module 522 is specifically used to sort the server names in descending order based on character length, and to perform prefix matching between the requested canonical tool name and the sorted server names.

[0111] In this embodiment of the disclosure, during the prefix matching process, the server names can be sorted in descending order based on their character length, so that the longer the server name is, the earlier it appears in the prefix order. During prefix matching, the server names can be matched in descending order, thus prioritizing longer server names and avoiding incorrect matching between shorter server names and longer prefixes, effectively improving the accuracy of prefix matching.

[0112] In this embodiment, the MCP management module 522 can write corresponding file data to or read from the local file system 530. The interaction between the MCP management module 522 and the local file system 530 can be achieved through a transport layer. The transport layer can provide the Stido transport protocol to communicate with the local MCP server via Stdin / Stdout; it can also provide the SSE transport protocol to communicate with a remote MCP server via a persistent HTTP connection, thus supporting multiple transport protocols.

[0113] Figure 6 illustrates the tool invocation matching process of an exemplary embodiment of this disclosure. In response to a tool invocation request initiated by the agent client, the MCP management module parses and obtains the standardized tool name to be invoked, and then retrieves all server names after standardization and sorts them in descending order. Based on this, it performs a sequential match between the standardized tool name and the descendingly sorted server names. If a match is successful, the original tool name is extracted from the standardized tool name, the tool invocation is executed, and the tool execution result is returned. If a match fails, the tool invocation is executed using the original tool name corresponding to the default MCP server, and the tool execution result is returned.

[0114] In an optional system embodiment of this disclosure, if there is no MCP server available to be invoked, or if it is determined that the invoked MCP server is unavailable, a corresponding error message, such as "No MCP servers available", can be thrown for operation and maintenance processing.

[0115] Figure 7 shows the fourth schematic diagram of the architecture of the intelligent agent remote operation system 700 according to an exemplary embodiment of this disclosure. The system 700 may include a Web socket service 711 and an HTTP service 712 in the communication layer 710, a file management module 721 in the service layer 720, and a local file system 730.

[0116] Web socket service 711 is used to respond to Web socket connection requests from intelligent agent clients, dynamically calculate the working directory, and establish Web socket connections with workspace isolation based on the working directory; file management module 721 is used to respond to write requests initiated by intelligent agent clients through Web socket service 711, and perform dynamic threshold block file writing to local file system 730 through Web socket connections; file management module 721 is also used to respond to static read requests initiated by intelligent agent clients through HTTP service 712, and perform dynamic threshold block file reading from local file system 730 through HTTP connections.

[0117] In this embodiment of the disclosure, system 700 can be referred to in the relevant description of the aforementioned system 100, and will not be repeated here to avoid repetition. For example, WebSocket service 711 can be implemented based on Socket.IO Server (WebSocket protocol library), and HTTP service 712 can be implemented based on koa HTTP Server (HTTP middleware framework).

[0118] In an optional system embodiment of this disclosure, the system 700 may further include a command execution module 722 in the service layer 720, which is used to create a command process in response to a command execution request and to manage the command process.

[0119] In this embodiment, the command execution module 722, based on the established WebSocket connection, can respond to command execution requests initiated by the agent client via the WebSocket service 711 by creating an execution context and generating a corresponding command process. It can also manage the lifecycle of the command process. Based on this command process, it can execute commands submitted by the agent client and return the command execution results to the agent client via the WebSocket service 711. Each command process can have corresponding process information, such as SessionID (session identifier) ​​and PID (process identifier), facilitating targeted process management by the command execution module. The generation and execution of the command process can be implemented in the local file system 730.

[0120] In an optional system embodiment of this disclosure, the command execution module is further configured to employ a tree-shaped termination mechanism for the command process.

[0121] In this embodiment of the disclosure, a tree-based termination mechanism can be used for the command process when its lifecycle ends or when it terminates in other ways, such as when the connection is interrupted or the system shuts down abnormally. Tree-based termination is set up based on a process tree with the main process and child processes as the foundation. The main process and all child processes created by it are terminated by treekill, thereby avoiding process remnants.

[0122] In an optional system embodiment of this disclosure, the system may further include a resource management layer, which can cache relevant resources of other functional modules and support resource reuse and resource isolation of corresponding functional modules through a caching mechanism. In one implementation, the resource management layer can be implemented based on a local file system, creating and managing corresponding caches in the local file system, or it can be implemented through other cache configurations; this disclosure does not impose specific limitations on this.

[0123] Taking the system 300 shown in Figure 3 above as an example, the system 300 includes a monitoring instance cache in the resource management layer. The monitoring instance is written into the monitoring instance cache with the working directory as the cache key. The monitoring instance cache is used to reuse the monitoring instance and to perform work area isolation on the monitoring instance based on the working directory.

[0124] In this embodiment, system 300 includes a file monitoring module 322, and the corresponding resource management layer may include a monitoring instance cache. Therefore, the created monitoring instance can be written to the monitoring instance cache using the working directory as the cache key, allowing the corresponding monitoring instance to be retrieved from the monitoring instance cache based on the working directory. The monitoring instance cache can be represented as a Map.<workdir, FileWatcher> This refers to the mapping between the working directory and monitoring instances. Based on the monitoring instance cache, it supports reusing existing monitoring instances using the working directory, as well as isolating different monitoring instances based on the working directory.

[0125] In an optional system embodiment of this disclosure, the file monitoring module 322 is specifically used to query the monitoring instance cache based on the working directory when monitoring of the working directory begins, and to create a monitoring instance corresponding to the working directory to perform filtered file monitoring if the query fails to find the target. The file monitoring module 322 is also specifically used to query the monitoring instance cache based on the working directory when monitoring of the working directory begins, and to reuse the monitoring instance corresponding to the working directory to perform filtered file monitoring if the query finds the target.

[0126] In this embodiment, the monitoring instance can be obtained when monitoring of the working directory corresponding to the WebSocket connection of the agent client begins. Based on the working directory, a cache key can be queried and matched within the monitoring instance. If the query matches, it means that a corresponding monitoring instance already exists in the working directory, executing the filtered file monitoring corresponding to the WebSocket connection of the agent client. Therefore, the monitoring instance can be reused without repeated creation. Alternatively, if the query does not match, it means that a corresponding monitoring instance does not exist in the working directory. This could be because the working directory is a newly created file directory, or because the monitoring instance corresponding to the working directory has been destroyed. In this case, a corresponding monitoring instance can be created for that file directory to execute the filtered file monitoring corresponding to the WebSocket connection of the agent client. The created monitoring instance can also be reused in the WebSocket connections of other agent clients.

[0127] In an optional system embodiment of this disclosure, the monitoring instance cache further includes a socket set corresponding to the monitoring instance, the socket set being used to record the Web socket connection corresponding to the monitoring instance; the file monitoring module 322 is further used to remove the Web socket connection corresponding to the monitoring stop request from the socket set when the monitoring instance stops monitoring the working directory; the file monitoring module 322 is further used to delete the monitoring instance when the socket set is empty.

[0128] In this embodiment of the disclosure, a corresponding socket set can also be maintained for each monitoring instance in the monitoring instance cache, which can be exemplarily represented as a Set.<socket>The socket set can record the WebSocket connections corresponding to the monitoring instances. After each agent client connects to system 300 via a WebSocket connection, system 300 can monitor file change events in the working directory through the monitoring instance. Since different agent clients may correspond to the same working directory, the same monitoring instance may be subscribed to by different agent clients. In this case, maintaining a socket set in the monitoring instance cache, providing and maintaining the WebSocket connections subscribed to that monitoring instance, can support pushing detected file change events in the working directory to different associated agent clients, and can also support lifecycle management of the monitoring instance.

[0129] In this embodiment, the socket set can create and record corresponding WebSocket connections when the monitoring instance is created, and then add corresponding WebSocket connections when the monitoring instance is reused. Furthermore, when the monitoring instance stops monitoring the working directory, the corresponding WebSocket connection can be removed from the socket set according to the monitoring stop request. Specifically, if the monitoring stop request indicates one WebSocket connection, then one WebSocket connection is removed from the socket set; if the monitoring stop request indicates multiple WebSocket connections, then multiple WebSocket connections are removed from the socket set. Further, the socket set can be checked for emptiness. If the socket set is not empty, it indicates that at least one agent client has subscribed to file change events in the working directory, and the monitoring instance can continue to perform filtered file monitoring; or, if the socket set is empty, it indicates that no agent client has subscribed to file change events in the working directory, and the monitoring instance no longer needs to perform filtered file monitoring, so the monitoring instance can be deleted, thus achieving lifecycle management of the monitoring instance.

[0130] For example, the Socket collection can be managed using reference counting. The necessity of an instance is determined by tracking the number of references to it. The reference count is incremented by 1 whenever a new WebSocket connection references the instance, and decremented by 1 whenever a WebSocket connection references the instance is removed. When the reference count is 0, it means that there are no more WebSocket connections referencing the instance, thus allowing the resources occupied by the instance to be safely released.

[0131] Taking the system 500 shown in Figure 5 above as an example, the system 500 includes a model context protocol connection cache in the resource management layer, which is used to reuse model context protocol connections and perform workspace isolation on model context protocol connections based on the working directory.

[0132] In this embodiment, system 500 includes an MCP management module 522, and the corresponding resource management layer may include an MCP connection cache. Therefore, created MCP connections can be written to the MCP connection cache using the working directory as the cache key, allowing the corresponding MCP connection to be retrieved from the MCP connection cache based on the working directory. The format of this MCP connection cache can be represented as a Map.<workdir, MCPClient> This refers to the mapping between the working directory and MCP connections. Based on the MCP connection cache, it supports reusing existing MCP connections using the working directory and isolating different MCP connections based on the working directory. Furthermore, it supports lifecycle management of MCP connections, allowing the parallel closure of different MCP connections during resource shutdown.

[0133] Taking the system 700 shown in Figure 7 above as an example, the system 700 includes an execution context cache in the resource management layer, which is used to reuse the execution context of the command process and to isolate the execution work area of ​​the command process based on the working directory.

[0134] In this embodiment, system 700 includes a command execution module 722, and the corresponding resource management layer may include an execution context cache. Therefore, the created execution context can be written to the execution context cache using the working directory as the cache key, allowing the corresponding execution context to be retrieved from the execution context cache based on the working directory. The execution context cache can be represented as a Map.<workdir, Exec Context> This refers to the mapping between the working directory and the execution context. Based on the execution context cache, it supports reusing existing execution contexts using the working directory, as well as isolating different execution contexts based on the working directory.

[0135] In an optional embodiment of this disclosure, resource isolation may include one or more of monitoring instances, MCP connections, command execution, etc., and file monitoring, tool invocation, command execution, etc. are performed in the context of workspace isolation based on dynamically calculated working directories.

[0136] Therefore, based on the working directory, resources can be created, reused, and managed for lifecycle using the working directory as a cache key. For example, each project can maintain an independent monitoring instance to perform filtered file monitoring, maintain MCP connection pools and configurations, and maintain independent CWD (current working directory) and stage variables for command execution. Furthermore, different projects can share resources in the HTTP service, and projects can be distinguished through events in the WebSocket service, thus achieving concurrency for multiple projects within a single instance. Moreover, adjustable resource isolation between projects can be achieved without building a container, reducing the risk of project interference, and memory consumption is effectively reduced through resource reuse.

[0137] Figure 8 illustrates the workspace mode architecture of an exemplary embodiment of this disclosure. Based on a single server instance of the HTTP service, corresponding workspaces are divided according to the working directory corresponding to the project identifier. In the example in Figure 8, the HTTP service instance identifier is 3030, which can include the concurrent execution of projects A, B, and C. The working directory corresponding to project A can be represented as workdir: workspace / project_A, including FileWatcher A, MCP Client A, Exec Context A, etc., representing resources such as the monitoring instance, MCP connection, and execution context corresponding to project A. The working directory corresponding to project B can be represented as workdir: workspace / project_B, including FileWatcher B, MCP Client B, Exec Context B, etc., representing resources such as the monitoring instance, MCP connection, and execution context corresponding to project B. The working directory corresponding to project C can be represented as workdir: workspace / project_C, including FileWatcher C, MCP Client C, ExecContext C, etc., representing resources such as the monitoring instance, MCP connection, and execution context corresponding to project C. The above-mentioned projects A, B, and C implement resource isolation in the working mode, thereby supporting single-instance multi-project concurrency.

[0138] In an optional system embodiment of this disclosure, the system further includes a port management module, which is used to perform recursive polling detection of port status and perform automatic port allocation in response to a port monitoring request.

[0139] In this embodiment, any one of the aforementioned systems 100, 300, 500, and 700 may further include a port management module for recursively polling and detecting the port status of the HTTP server's ports via the HTTP service, and for automatically allocating ports. Specifically, the recursive polling monitoring can involve the port management module responding to a port monitoring request by adding the corresponding HTTP server port to the monitoring list and performing recursive polling within the list. The list is updated each time the port status changes, and the intelligent agent client is notified of the port status change event. Furthermore, in response to a request from the intelligent agent client to stop port monitoring, the monitoring list can be cleared, and the recursive polling detection can be stopped. For example, a port is considered available when all network interfaces (default interface, 0.0.0.0, 127.0.0.1, localhost, etc.) are detected as available; there are also handling cases where a listening port is occupied, leading to an EADDRNOTAVAIL error, such as changing the IP address or port number. The polling period can be set according to actual business needs, and the number of monitored ports can be dynamically expanded.

[0140] In this embodiment of the disclosure, the port management module can also perform automatic port allocation. Based on the results of recursive polling detection of port status, it can automatically skip occupied ports and allocate multiple ports.

[0141] Figure 9 shows the fifth schematic diagram of the architecture of the intelligent agent remote operation system 900 according to an exemplary embodiment of this disclosure. The system 900 includes a Web socket service 911 and an HTTP service 912 in the communication layer 910, a file management module 921 in the service layer 920, and a local file system 930. The Web socket service 911 is used to dynamically calculate the working directory and establish a workspace-isolated Web socket connection based on the working directory in response to a Web socket connection request from an intelligent agent client. The file management module 921 is used to perform dynamic threshold-based block file writing to the local file system 930 via a Web socket connection in response to a write request initiated by the intelligent agent client through the Web socket service 911. The file management module 921 is also used to perform dynamic threshold-based block file reading from the local file system 930 via an HTTP connection in response to a static read request initiated by the intelligent agent client through the HTTP service 912.

[0142] System 900 also includes a file monitoring module 922 in the service layer 920, which is used to obtain monitoring instances based on the working directory to perform filtered file monitoring.

[0143] System 900 also includes a Model Context Protocol Management Module 923 in the service layer 920, which is used to respond to the Model Context Protocol initialization request initiated by the agent client through the Web socket service 911, establish a Model Context Protocol connection with at least one Model Context Protocol server, and establish a prefix matching route mapping based on the server name of the Model Context Protocol server to obtain the canonical tool name; Model Context Protocol Management Module 923 is also used to respond to the tool call request initiated by the agent client through the Web socket service 911, perform prefix matching, execute the tool call based on the matching result through the canonical tool name and the Model Context Protocol connection, and return the tool execution result.

[0144] System 900 also includes a command execution module 924 for creating a command process in response to a command execution request and for managing the command process.

[0145] System 900 includes a monitoring instance cache in the resource management layer 940. Monitoring instances are written to the monitoring instance cache with the working directory as the cache key. The monitoring instance cache is used to reuse monitoring instances and to perform workspace isolation on monitoring instances based on the working directory.

[0146] System 900 includes a Model Context Protocol (MCP) connection cache in the resource management layer 940 for reusing MCP connections and performing workspace isolation on MCP connections based on the working directory.

[0147] System 900 includes an execution context cache in the resource management layer 940 for reusing the execution context of command processes and isolating the execution workspace of command processes based on the working directory.

[0148] System 900 also includes a port management module 925, which responds to port monitoring requests, performs recursive polling checks on port status, and performs automatic port allocation.

[0149] System 900 may also include a transport layer 950, which supports various transport protocols for functional modules, such as WebSocket, HTTP, Stdio transport, SSE transport, etc.

[0150] In one optional system embodiment of this disclosure, hierarchical resource cleanup can be adopted, which includes at least the socket level and the service level.

[0151] The different functional modules in the aforementioned system 900 can be referred to the relevant descriptions of the aforementioned systems 100, 300, 500, and 700. To avoid repetition, they will not be described again here.

[0152] In this embodiment of the disclosure, any one of the aforementioned systems 100, 300, 500, 700, and 900 can adopt a hierarchical resource cleanup scheme, that is, perform resource cleanup separately at the socket level, service layer 920, etc. For example, at the socket level, related resources can be cleaned up when a WebSocket connection disconnection event occurs, such as file write tasks related to WebSocket connections, socket sets, command processes, etc., depending on the actual system configuration. At the service layer 920 level, related resources can be cleaned up in response to the SIGINT signal, such as monitoring instances, MCP connections, WebSocket services, HTTP services, etc., depending on the actual system configuration. Furthermore, resource cleanup at different levels can also be triggered upon abnormal exit.

[0153] In an optional system embodiment of this disclosure, the system also performs resource release verification.

[0154] In this embodiment of the disclosure, in addition to performing hierarchical resource cleanup, resource release verification can also be performed to avoid resource residue. For example, for cleanup of resources related to the closure of monitoring instances and MCP connections in the service layer, it can be verified whether the stored MAP (map) is empty; for cleanup of resources related to the WebSocket service in the service layer, it can be verified whether there are any residual processes; for cleanup of resources related to the HTTP service in the service layer, it can be verified whether there is any port occupation. The above examples are for illustration only, and those skilled in the art can perform corresponding resource release verification according to actual needs. This embodiment of the disclosure does not impose specific limitations on this.

[0155] According to the intelligent agent remote operation system of this disclosure, the system includes a Web socket service and an HTTP service at the communication layer, a file management module and a local file system at the service layer; wherein, the Web socket service can respond to the Web socket connection request of the intelligent agent client, dynamically calculate the working directory, and establish a working area isolated Web socket connection based on the working directory; the file management module can respond to the write request initiated by the intelligent agent client through the Web socket service, and perform dynamic threshold block file writing to the local file system through the Web socket connection; the HTTP service can also respond to the static read request initiated by the intelligent agent client, and perform dynamic threshold block file reading from the local file system through the HTTP connection. This solution employs a dynamic threshold-based, chunked file transfer mechanism with read / write separation. Web sockets handle file writing, enabling bidirectional communication and real-time progress feedback. HTTP handles file reading, effectively achieving high-concurrency, low-latency large file transfers and supporting resumeable interruptions. This dual-protocol separation flexibly adapts to file transfer needs, reducing connection burden and network overhead. Furthermore, the solution dynamically calculates the working directory, isolating Web socket connections and maintaining independent resources for different working directories, avoiding interference from multiple projects and supporting multi-project concurrency with a single instance. The service layer also includes a file monitoring module, allowing for filtered monitoring of the working directory to flexibly adjust the monitoring scope, effectively avoiding interference from useless events. Monitoring instances are acquired based on the working directory, supporting reuse among intelligent agent clients pointing to the same working directory, avoiding redundant consumption of monitoring resources. It also avoids the problem of multiple triggers of intermediate events caused by multiple monitoring instances monitoring the working directory, reducing bandwidth waste. In addition, the system provides cross-platform path standardization to ensure compatibility with file monitoring across different platforms, preventing monitoring failures caused by inconsistent cross-platform path processing. The system's service layer can also include a model context protocol management module. When integrating multiple model context protocol servers, this module standardizes server and tool names and establishes routing mappings based on tool name prefix matching, enabling efficient integration of multi-protocol tools through the model context protocol. Furthermore, by standardizing server and tool names and adding prefixes, it avoids call failures caused by duplicate or non-standard tool names, improving the accuracy and effectiveness of tool calls. The system's service layer can also include a command execution module, employing a tree-structured termination mechanism to prevent child process remnants when processes are closed. The system can also employ hierarchical resource cleanup, performing layered and orderly resource cleanup at the socket and service levels; furthermore, it can perform resource release verification, effectively preventing connection leaks and resource cleanup residues.

[0156] It should be noted that although several modules or units of the intelligent agent remote operation system have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0157] Exemplary methods

[0158] Having introduced the agent remote operation system according to exemplary embodiments of the present disclosure, the agent remote operation method according to exemplary embodiments of the present disclosure will now be described.

[0159] One of the steps of the agent remote operation method according to the exemplary embodiments of this disclosure may include: step A1, dynamically calculating the working directory in response to a Web socket connection request from the agent client; step A2, establishing a workspace-isolated Web socket connection based on the working directory; step A3, performing dynamic threshold-based block file writing via the Web socket connection in response to a write request initiated by the agent client; and step A4, performing dynamic threshold-based block file reading via an HTTP connection in response to a static read request initiated by the agent client.

[0160] In an optional method embodiment of this disclosure, the aforementioned step A3 may include: Step A31, in response to a write request initiated by the agent client, when the file to be written is less than the write threshold, writing the file in a single transmission using a Web socket connection; Step A32, in response to a write request initiated by the agent client, when the file to be written is greater than or equal to the write threshold, dividing the file into data blocks and writing them via streaming transmission using a Web socket connection.

[0161] In one optional embodiment of the method disclosed herein, the write request corresponds to at least one of a file upload operation and a file modification operation.

[0162] In an optional method embodiment of this disclosure, the aforementioned step A4 may include: step A41, in response to a static read request initiated by the agent client, when the static read file is less than the static read threshold, providing the static read file to the agent client via a single transmission using an HTTP connection; step A42, in response to a static read request initiated by the agent client, when the static read file is greater than or equal to the static read threshold, dividing the static read file into data blocks and providing them to the agent client via streaming transmission using an HTTP connection.

[0163] In an optional embodiment of the method disclosed herein, step A4 may further include: step A43, in response to a static read request initiated by the agent client, determining the read range of the target file; step A44, when the read range is less than a read threshold, providing the static read file to the agent client via a single transmission using an HTTP connection based on the read range of the target file; step A45, when the read range is greater than or equal to the read threshold, dividing the static read file into data blocks based on the read range of the target file and providing it to the agent client via streaming transmission using an HTTP connection.

[0164] In an optional embodiment of the method disclosed herein, step A4 may further include: step A46, in response to a static read request initiated by the agent client, determining the read range of the target file if the target file exists in the local file system. Step A47, in response to a static read request initiated by the agent client, prompting the agent client with a read error message if the target file does not exist in the local file system.

[0165] In an optional embodiment of the method disclosed herein, step A2 may be followed by step A5: responding to an interactive read request initiated by the agent client, performing dynamic threshold chunked file reading via a Web socket connection.

[0166] In an optional embodiment of the method disclosed herein, the aforementioned step A5 may include: step A51, in response to an interactive read request initiated by the agent client, when the interactive read file is less than the interactive read threshold, providing the interactive read file to the agent client via a Web socket connection using a single transmission; step A52, in response to an interactive read request initiated by the client, when the interactive read file is greater than or equal to the interactive read threshold, dividing the interactive read file into data blocks and providing them to the agent client via a Web socket connection through streaming transmission.

[0167] For example, taking a project development scenario as an example, in the steps of the intelligent agent remote operation method, when the intelligent agent client and the system transfer files, Figure 10 shows the file writing process provided by the intelligent agent remote operation method of this exemplary embodiment, including: Step 1001, the intelligent agent client sends a file writing start (writeFileStart) instruction to the WebSocket service, which also includes the file path to be written (filePath); Step 1002, the WebSocket service instructs the file management module to create a corresponding file writing task; Step 1003, the file management module creates a corresponding write stream (writeStream) in the local file system; Step 1004, the file management module generates...

[0168] Step 1005: The WebSocket service returns the task ID corresponding to the file writing task to the agent client. Step 1006: The agent client sends an instruction to the WebSocket service to write a file data block (writeFileChunk), which also includes the task ID and the data block. Step 1007: The WebSocket service locates the file writing task based on the task ID and instructs the file management module to execute the file writing task to write the data block. Step 1008: The file management module writes the data block to the local file system through the write stream and updates the cumulative number of bytes received. Step 1009: The file management module sends an instruction to the WebSocket service to write the file data block. The WebSocket service confirms that the data block has been successfully written; Step 1010: The WebSocket service reports the file writing progress to the agent client; Step 1011: The agent client sends a write file complete (writeFileEnd) instruction to the WebSocket service, which also includes a task identifier; Step 1012: The WebSocket service locates the file writing task based on the task identifier and instructs the file management module to end the file writing task; Step 1013: The file management module closes the write stream corresponding to the file writing task and clears the cache of the file writing task; Step 1014: The file management module reports the write complete to the WebSocket service; Step 1015: The WebSocket service reports the write success to the agent client.

[0169] In this embodiment of the disclosure, when the file being written by the agent client is less than the writing threshold, steps 1006 to 1010 can be executed once to complete the file transmission; when the file being written by the agent client is greater than the writing threshold, steps 1006 to 1010 can be executed repeatedly to transmit the file in data blocks in a streaming manner until the agent client confirms that the writing progress has reached the expected level.

[0170] In this embodiment of the disclosure, steps 1001 to 1015 illustrate a process example of the intelligent agent client and the system writing files in a project development scenario, which can be applied to file upload operations and file modification operations, such as the file transfer process during the project file creation stage.

[0171] For example, taking a project development scenario as an example, in the steps of the intelligent agent remote operation method, when the intelligent agent client and the system transfer files, Figure 11 shows one of the file reading processes provided by the intelligent agent remote operation method of this exemplary embodiment, including: Step 1101, the intelligent agent client sends an instruction to the WebSocket service to start reading a file, the instruction including the file path to be read; Step 1102, the WebSocket service instructs the file management module to read the interactive file under the file path; Step 1103, the file management module queries the local file system to obtain the file information (filesize) of the interactive file under the file path, and generates a task identifier for the interactive file reading task; Step 1104, the file management module returns the task identifier and file information to the WebSocket service; Step 1105, the WebSocket service returns the task identifier and file information to the intelligent agent client; Step 1106, when the interactive file is less than the interactive reading threshold, the file management module performs file reading (readFile) to the local file system to request the complete interactive file; Step 1107, the local file system... Step 1108: The file management module returns the complete interactive read file to the WebSocket service. Step 1109: The WebSocket service returns an indication of read file data (readFileChunk) to the agent client, which includes the task identifier and the interactive read file. Step 1110: The WebSocket service returns an indication of read file completion (readFileEnd) to the agent client, which includes the task identifier. Alternatively, Step 1111: When the target file is greater than or equal to the interactive read threshold, the file management module creates a read stream to the local file system and reads the interactive read file through data block streaming. Step 1112: The file management module returns the data blocks of the interactive read file to the WebSocket service. Step 1113: The WebSocket service returns an indication of read file data to the agent client, which includes the task identifier and the data blocks of the interactive read file. Step 1114: The WebSocket service returns an indication of read file completion to the agent client, which includes the task identifier.

[0172] In this embodiment of the disclosure, steps 1111 to 1113 can be executed cyclically, transmitting the interactive file through data block streaming until the interactive file is completely read. For example, taking a project development scenario as an example, when the agent client and the system transfer files in the steps of the agent remote operation method, Figure 12 shows the second file reading process provided by the agent remote operation method of this exemplary embodiment, including: Step 1201, the agent client sends an instruction to the HTTP service to read the file, the instruction including the file path; for example, the instruction can be represented as a GET request. / fb / path / to / file?projectId=xxx; Step 1202: The HTTP service parses the instruction to obtain the file path and project identifier, as well as the dynamically calculated working directory; Step 1203: The HTTP service instructs the file management module to read the statically read file under the working directory; Step 1204: If the statically read file does not exist, the file management module prompts the HTTP service with a file read error; for example, the file read error can be a 404 error; Step 1205: The HTTP service returns an error message status code to the agent client; for example, the error message status code can be 404 Not Found; Step 1206: If the statically read file exists, the file management module queries the local file system to obtain the file status of the statically read file; Step 1207: When the statically read file is less than the statically read threshold, the file management module creates a read stream corresponding to the statically read file; Step 1208: The file management module returns the complete statically read file to the HTTP service; Step 1209: The HTTP service provides the complete statically read file and a request response success status code to the agent client; for example, the request response success status code can be 200. OK; Step 1210: The file management module creates a read stream corresponding to the data block of the static read file when the static file is greater than or equal to the static read threshold; Step 1211: The file management module provides the data block of the static read file to the HTTP service in a data block streaming manner; Step 1212: The HTTP service provides the data block of the static read file to the intelligent agent client; Step 1213: The file management module creates a read stream according to the read range specified by the static read file; Step 1214: The file management module provides the file data corresponding to the read range to the HTTP service; Step 1215: The HTTP service provides the file data corresponding to the read range to the intelligent agent client, as well as the request response partial success status code; For example, the request response partial success status code can be 206 Partial Content; In this embodiment of the disclosure, steps 1209 to 1212 can be executed cyclically until the static read file is completely read.

[0173] In an optional embodiment of the method disclosed herein, the aforementioned remote operation method for intelligent agents may further include step A6: obtaining monitoring instances based on the working directory to perform filtered file monitoring.

[0174] In an optional embodiment of this disclosure, step A6 specifically includes: recursively searching for file directories containing filtering rules from the working directory to the subdirectories in the file directory, searching for the first file directory containing filtering rules in the parent directory of the working directory, and creating an independent file filtering instance for each file directory containing filtering rules.

[0175] In an optional implementation of this disclosure, a monitoring instance is written into the monitoring instance cache using the working directory as the cache key. The monitoring instance cache is used to reuse the monitoring instance and to perform workspace isolation on the monitoring instance based on the working directory.

[0176] In an optional embodiment of the method disclosed herein, step A6 may include: step A61, when monitoring the working directory begins, querying the monitoring instance cache based on the working directory, and if the query fails, creating the monitoring instance corresponding to the working directory to perform filtered file monitoring; step A62, when monitoring the working directory begins, querying the monitoring instance cache based on the working directory, and if the query succeeds, reusing the monitoring instance corresponding to the working directory to perform filtered file monitoring.

[0177] In an optional embodiment of the method disclosed herein, the monitoring instance cache further includes a socket set corresponding to the monitoring instance, and the aforementioned step A62 may further include: step A63, when the monitoring instance stops monitoring the working directory, removing the Web socket connection corresponding to the monitoring stop request from the socket set; step A64, when the socket set is empty, deleting the monitoring instance.

[0178] In an optional embodiment of the method disclosed herein, the aforementioned remote operation method for intelligent agents may further include step A7, performing cross-platform normalization processing on the storage path of the file directory.

[0179] For example, taking a project development scenario as an example, in the steps of the agent remote operation method, when the agent client and the system perform file monitoring, Figure 13 shows the file monitoring process provided by the agent remote operation method of this exemplary embodiment. It may include the acquisition of monitoring instances during the project initialization and connection establishment phases, and the monitoring and notification process of file change events based on the monitoring instances. This may include: Step 1301, the agent client sends a WebSocket connection request to the WebSocket service, which includes an indication of the project identifier and the workspace mode; Step 1302, the WebSocket service calculates the working directory based on the workspace mode indication and the project identifier, and requests file filtering monitoring from the file monitoring module; Step 1303, the file monitoring module reuses the monitoring instance if it exists in the working directory, creates the monitoring instance if it does not exist, and performs bidirectional parsing of filtering rules in the local file system based on the working directory to obtain the file directory containing the filtering rules. Step 1304: Create a file filtering instance; Step 1305: The file monitoring module returns the monitoring instance and the file filtering instance to the WebSocket service; Step 1306: The WebSocket service confirms the successful connection to the agent client; Step 1307: When the file monitoring module detects a file change event (FileChange event) in the working directory based on the monitoring instance, it executes a hierarchical matching algorithm based on the file filtering instance. If the file change event matches any filtering rule, it ignores the file change event; if the file change event does not match any filtering rule, it broadcasts the file change event to the WebSocket connection corresponding to the monitoring instance in the WebSocket service; Step 1308: The WebSocket service notifies the agent client corresponding to the WebSocket connection of the file change event.

[0180] In an optional embodiment of the method disclosed herein, the aforementioned remote operation method for an intelligent agent may further include step A8: in response to a model context protocol initialization request initiated by the intelligent agent client, establishing a model context protocol connection with at least one model context protocol server, and establishing a prefix matching route mapping based on the server name of the model context protocol server to obtain a canonical tool name; step A9: in response to a tool call request initiated by the intelligent agent client, performing prefix matching, executing a tool call based on the matching result through the canonical tool name and the model context protocol connection, and returning the tool execution result.

[0181] In an optional embodiment of the method disclosed herein, step A9 may include: step A91, obtaining the canonical tool name to be invoked in response to a tool invocation request initiated by the agent client, and performing prefix matching between the canonical tool name to be invoked and the server name. Step A92, when the canonical tool name to be invoked successfully matches the server name, executing the tool invocation of the corresponding Model Context Protocol server based on the canonical tool name via a Model Context Protocol connection, and returning the tool execution result to the agent client; step A93, when the canonical tool name to be invoked fails to match the server name, executing the tool invocation of the corresponding Model Context Protocol server based on the default canonical tool name via a Model Context Protocol connection, and returning the tool execution result to the agent client.

[0182] In an optional embodiment of the method disclosed herein, the aforementioned step A91 specifically includes: sorting the server names in descending order based on character length, and performing prefix matching between the canonical tool name requested and the sorted server names.

[0183] In an optional embodiment of the method disclosed herein, a model context protocol connection cache is further included for reusing the model context protocol connection and performing workspace isolation on the model context protocol connection based on the working directory.

[0184] For example, taking a project development scenario as an example, in the steps of the agent remote operation method, when the agent client calls the system for tools, Figure 14 shows the tool call flow provided by the agent remote operation method of this exemplary embodiment. It can include MCP tool registration and initialization, as well as the call request and response based on this, and can include: Step 1401, the agent client sends an MCP initialization request to the WebSocket service; Step 1402, the WebSocket service instructs the MCP protocol management module to initialize the MCP client; Step 1403, the MCP protocol management module establishes MCP connections with multiple MCP services, and establishes a prefix-matching route mapping based on the server name to obtain the canonical tool name; wherein, the format of the canonical tool name can be "server name - original tool name (server-tool)"; Step 1404, the MCP protocol management module returns the canonical tool name to the WebSocket service; Step 1405, the WebSocket service returns the canonical tool name to the agent client; Step 1406, the agent client sends the tool to the WebSocket service. The tool invocation request includes the canonical tool name to be invoked; Step 1407: The WebSocket service requests a prefix matching route from the MCP management module based on the canonical tool name in the tool invocation request; Step 1408: If the match is successful, the MCP protocol management module extracts the original tool from the canonical tool name and routes it to the MCP server using the original tool name; Step 1409: The MCP protocol management module executes the tool invocation based on the MCP connection corresponding to the MCP server and obtains the tool execution result; Step 1410: The MCP protocol management module returns the tool execution result to the WebSocket service; Step 1411: The WebSocket service returns the tool execution result to the agent client.

[0185] In this embodiment of the disclosure, the tool execution results of the MCP server can be stored in the local file system, so that the MCP protocol management module can obtain them from the local file system, and the transmission protocol can be flexibly selected according to the local or remote deployment type of the MCP server.

[0186] In an optional embodiment of the method disclosed herein, the aforementioned remote operation method for an intelligent agent may further include: step A10, creating a command process in response to a command execution request, and managing the command process.

[0187] In an optional embodiment of the method disclosed herein, the aforementioned remote operation method for intelligent agents may further include step A11, employing a tree-shaped termination mechanism for the command process.

[0188] In an optional embodiment of the method disclosed herein, an execution context cache is further included for reusing the execution context of the command process and isolating the execution workspace of the command process based on the working directory.

[0189] For example, taking a project development scenario as an example, in the steps of the intelligent agent remote operation method, when the intelligent agent client and the system execute commands, Figure 15 shows the command execution and process management flow provided by the intelligent agent remote operation method of this exemplary embodiment. This can include MCP tool registration and initialization, and on this basis, call requests and responses, including: Step 1501, the intelligent agent client sends a command execution request to the WebSocket service; for example, the command execution request can be an execution request for the exec command; Step 1502, the WebSocket service creates an execution context corresponding to the command execution request for the command execution module; Step 1503, the command execution module creates a child process with a working directory and obtains a process identifier; Step 1504, the command execution module records the session identifier and process identifier of the child process, and starts executing the child process based on the WebSocket service; Step 1505, the WebSocket service provides the execution result of the child process to the intelligent agent client; In this embodiment, the working directory can be dynamically calculated based on the connection request initiated by the intelligent agent client during project initialization, pointing to the storage path corresponding to the project-related files in the local file system.

[0190] In an optional embodiment of the method disclosed herein, the aforementioned remote operation method for intelligent agents may further include step A12: responding to a port monitoring request, performing recursive polling detection on the port status, and performing automatic port allocation.

[0191] For example, taking a project development scenario as an example, in the steps of the intelligent agent remote operation method, when the intelligent agent client and the system perform port monitoring, Figure 16 shows the port monitoring process provided by the intelligent agent remote operation method of this exemplary embodiment, which may include: Step 1601, the intelligent agent client instructs the WebSocket service to start port monitoring (startPortWatch) and instructs the port number; for example, the port number may include 8080, 8081, etc.; Step 1602, the WebSocket service instructs the port management module to add the port number indicated by the intelligent agent client to the port monitoring list; Step 1603, the port management module uses recursive polling to traverse the port status corresponding to each port number in the port monitoring list in each cycle; Step 1604, when the port status changes, the port management module sends a port status change (portStatusChange) event to the WebSocket service; Step 1605, the WebSocket service prompts the intelligent agent client for port status update. In this embodiment of the disclosure, the port status detected in the past can be stored in the local file system, so that the changes in the current detection result and the historical detection result can be compared during traversal, thereby determining the changes in the port status; for example, the period can be 5 seconds.

[0192] In an optional embodiment of the method disclosed herein, the aforementioned remote operation method for intelligent agents may further include step A13, employing hierarchical resource cleanup, wherein hierarchical resource cleanup includes at least socket level and service level.

[0193] For example, taking a project development scenario as an example, in the steps of the intelligent agent remote operation method, when the intelligent agent client and the system perform resource cleanup, Figure 17 shows one of the resource cleanup processes provided by the intelligent agent remote operation method of this exemplary embodiment. Resource cleanup may include process termination, and may include: Step 1701, the intelligent agent client instructs the WebSocket service to terminate command execution, which may include the corresponding session identifier; for example, the abort function can be used to instruct the termination of the exec command execution; Step 1702, the WebSocket service instructs the command execution module to terminate the command process corresponding to the session identifier; Step 1703, the command execution module obtains the process identifier based on the session identifier, and performs tree-like process termination based on the process identifier; Step 1704, the command execution module deletes the record when the process termination is completed, and prompts the WebSocket service that resource cleanup was successful; Step 1705, the WebSocket service responds to the intelligent agent client that execution abort was successful.

[0194] For example, taking a project development scenario as an example, in the steps of the intelligent agent remote operation method, when the intelligent agent client and the system perform resource cleanup, as shown in Figure 18, which is the second resource cleanup process provided by the intelligent agent remote operation method of this exemplary embodiment, when the WebSocket connection between the intelligent agent client and the WebSocket service is disconnected, it may include the following: Step 1801, the WebSocket service instructs the file management module to clean up the write task; Step 1802, the file management module closes the write stream corresponding to the file write task and cleans up the cache of the file write task; Step 1803, the file management module reports to the WebSocket service that the write task has been cleaned up; Step 1804, The WebSocket service instructs the command execution module to terminate the command process; Step 1805: The command execution module terminates the tree-like process; Step 1806: The command execution module deletes the record upon completion of process termination and notifies the WebSocket service of successful resource cleanup; Step 1807: The WebSocket service instructs the file monitoring module to remove the monitoring instance of the WebSocket connection and decrement the reference count of the monitoring instance by 1; Step 1808: The file monitoring module destroys the monitoring instance when the Socket set is empty and notifies the WebSocket service of successful resource cleanup; Step 1809: The WebSocket service cleans up the Socket resources corresponding to the agent client.

[0195] In this embodiment of the disclosure, the WebSocket service may use a task identifier to instruct the file management module to clean up the corresponding file writing task; in this embodiment of the disclosure, the WebSocket service may use a session identifier to instruct the command execution module to terminate the corresponding command process.

[0196] Further details of various embodiments of the intelligent agent remote operation method of this disclosure have been described in detail in the functional modules of the above-described intelligent agent remote operation system, and will not be repeated here.

[0197] Exemplary computer-readable media

[0198] In this exemplary embodiment, referring to FIG19, a program product 1900 for implementing the above-described method according to an exemplary embodiment of the present disclosure is described. This product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a device such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, a computer-readable medium may be any tangible medium containing or storing a program that may be used by or in connection with an instruction execution system, apparatus, or device.

[0199] The program product 1900 can take the form of any combination of one or more readable media. The readable media can be a readable signal medium or a computer-readable medium. Computer-readable media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0200] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a computer-readable medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0201] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RE, etc., or any suitable combination thereof.

[0202] Program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (FAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).< / socket>

Claims

1. A remote operation system for an intelligent agent, characterized in that, The system includes a Web socket service and an HTTP service at the communication layer, a file management module at the service layer, and a local file system at the system. The Web socket service is used to respond to Web socket connection requests from intelligent agent clients, dynamically calculate the working directory, and establish workspace-isolated Web socket connections based on the working directory. The file management module is configured to respond to a write request initiated by the agent client through the Web socket service, and perform dynamic threshold-based block file writing to the local file system via the Web socket connection; the file management module is also configured to respond to a static read request initiated by the agent client through the HTTP service, and perform dynamic threshold-based block file reading from the local file system via an HTTP connection.

2. The system according to claim 1, characterized in that, The file management module is used to respond to a write request initiated by the intelligent agent client through the Web socket service, and when the write file is less than the write threshold, write the write file to the local file system in a single transmission using the Web socket connection. The file management module is also used to respond to a write request initiated by the intelligent agent client through the Web socket service, and when the write file is greater than or equal to the write threshold, to divide the write file into data blocks and write it to the local file system via streaming transmission through the Web socket connection.

3. The system according to claim 2, characterized in that, The write request corresponds to at least one of a file upload operation and a file modification operation.

4. The system according to claim 1, characterized in that, The file management module is specifically used to respond to a static read request initiated by the agent client through the HTTP service, and when the static read file is less than the static read threshold, to provide the static read file in the local file system to the agent client through the HTTP connection in a single transmission. The file management module is also used to respond to a static read request initiated by the agent client through the HTTP service, and when the static read file is greater than or equal to the static read threshold, to divide the static read file into data blocks and provide them to the agent client via streaming transmission through the HTTP connection.

5. The system according to claim 4, characterized in that, The file management module is further configured to, in response to a static read request initiated by the agent client through the HTTP service, determine the read range of the target file in the local file system; specifically, the file management module is further configured to, when the read range is less than the read threshold, provide the static read file to the agent client via the HTTP connection in a single transmission based on the read range of the target file; The file management module is further configured to, when the reading range is greater than or equal to the reading threshold, divide the static reading file into data blocks based on the reading range of the target file and provide them to the intelligent agent client via the HTTP connection through streaming transmission.

6. The system according to claim 5, characterized in that, The file management module is specifically used to respond to a static read request initiated by the agent client through the HTTP service, and determine the read range of the target file when the target file exists in the local file system; the file management module is also specifically used to respond to a static read request initiated by the agent client through the HTTP service, and prompt a read error to the agent client when the target file does not exist in the local file system.

7. The system according to claim 1, characterized in that, The file management module is also configured to respond to an interactive read request initiated by the intelligent agent client through the Web socket service, and perform dynamic threshold block-based file reading from the local file system via the Web socket connection.

8. The system according to claim 7, characterized in that, The file management module is also used to respond to an interactive read request initiated by the agent client through the Web socket service, and when the interactive read file is less than the interactive read threshold, to provide the interactive read file in the local file system to the agent client in a single transmission via the Web socket connection; The file management module is also used to respond to an interactive read request initiated by the agent client through the Web socket service, and when the interactive read file is greater than or equal to the interactive read threshold, to divide the interactive read file into data blocks and provide them to the agent client through streaming transmission via the Web socket connection.

9. A method for remote operation of an intelligent agent, characterized in that, The method includes: dynamically calculating a working directory in response to a Web socket connection request from an agent client; establishing a workspace-isolated Web socket connection based on the working directory; performing dynamic threshold-based block file writing using the Web socket connection in response to a write request initiated by the agent client; and performing dynamic threshold-based block file reading using an HTTP connection in response to a static read request initiated by the agent client.

10. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the remote operation method of the intelligent agent according to claim 9.