agentscope-runtime 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. agentscope_runtime/engine/agents/agentscope_agent/agent.py +1 -0
  2. agentscope_runtime/engine/agents/agno_agent.py +1 -0
  3. agentscope_runtime/engine/agents/autogen_agent.py +245 -0
  4. agentscope_runtime/engine/schemas/agent_schemas.py +1 -1
  5. agentscope_runtime/engine/services/context_manager.py +28 -1
  6. agentscope_runtime/engine/services/memory_service.py +2 -2
  7. agentscope_runtime/engine/services/rag_service.py +101 -0
  8. agentscope_runtime/engine/services/redis_memory_service.py +187 -0
  9. agentscope_runtime/engine/services/redis_session_history_service.py +155 -0
  10. agentscope_runtime/sandbox/box/training_box/env_service.py +1 -1
  11. agentscope_runtime/sandbox/box/training_box/environments/bfcl/bfcl_dataprocess.py +216 -0
  12. agentscope_runtime/sandbox/box/training_box/environments/bfcl/bfcl_env.py +380 -0
  13. agentscope_runtime/sandbox/box/training_box/environments/bfcl/env_handler.py +934 -0
  14. agentscope_runtime/sandbox/box/training_box/training_box.py +139 -9
  15. agentscope_runtime/sandbox/build.py +1 -1
  16. agentscope_runtime/sandbox/custom/custom_sandbox.py +0 -1
  17. agentscope_runtime/sandbox/custom/example.py +0 -1
  18. agentscope_runtime/sandbox/enums.py +2 -0
  19. agentscope_runtime/sandbox/manager/container_clients/__init__.py +2 -0
  20. agentscope_runtime/sandbox/manager/container_clients/docker_client.py +263 -11
  21. agentscope_runtime/sandbox/manager/container_clients/kubernetes_client.py +605 -0
  22. agentscope_runtime/sandbox/manager/sandbox_manager.py +112 -113
  23. agentscope_runtime/sandbox/manager/server/app.py +96 -28
  24. agentscope_runtime/sandbox/manager/server/config.py +28 -16
  25. agentscope_runtime/sandbox/model/__init__.py +1 -5
  26. agentscope_runtime/sandbox/model/container.py +3 -1
  27. agentscope_runtime/sandbox/model/manager_config.py +21 -15
  28. agentscope_runtime/sandbox/tools/tool.py +111 -0
  29. agentscope_runtime/version.py +1 -1
  30. {agentscope_runtime-0.1.0.dist-info → agentscope_runtime-0.1.2.dist-info}/METADATA +79 -13
  31. {agentscope_runtime-0.1.0.dist-info → agentscope_runtime-0.1.2.dist-info}/RECORD +35 -28
  32. agentscope_runtime/sandbox/manager/utils.py +0 -78
  33. {agentscope_runtime-0.1.0.dist-info → agentscope_runtime-0.1.2.dist-info}/WHEEL +0 -0
  34. {agentscope_runtime-0.1.0.dist-info → agentscope_runtime-0.1.2.dist-info}/entry_points.txt +0 -0
  35. {agentscope_runtime-0.1.0.dist-info → agentscope_runtime-0.1.2.dist-info}/licenses/LICENSE +0 -0
  36. {agentscope_runtime-0.1.0.dist-info → agentscope_runtime-0.1.2.dist-info}/top_level.txt +0 -0
@@ -5,10 +5,14 @@ from typing import Optional, Literal, Tuple
5
5
  from pydantic import BaseModel, Field, model_validator
6
6
 
7
7
 
8
+ UUID_LENGTH = 25
9
+
10
+
8
11
  class SandboxManagerEnvConfig(BaseModel):
9
12
  container_prefix_key: str = Field(
10
13
  "runtime_sandbox_container_",
11
14
  description="Prefix for keys related to Container models.",
15
+ max_length=63 - UUID_LENGTH, # Max length for k8s pod name
12
16
  )
13
17
 
14
18
  file_system: Literal["local", "oss"] = Field(
@@ -23,9 +27,10 @@ class SandboxManagerEnvConfig(BaseModel):
23
27
  ...,
24
28
  description="Indicates if Redis is enabled.",
25
29
  )
26
- container_deployment: Literal["docker", "cloud"] = Field(
30
+ container_deployment: Literal["docker", "cloud", "k8s"] = Field(
27
31
  ...,
28
- description="container_deployment: 'docker'.",
32
+ description="Container deployment backend: 'docker', 'cloud', "
33
+ "or 'k8s'.",
29
34
  )
30
35
 
31
36
  default_mount_dir: Optional[str] = Field(
@@ -95,12 +100,22 @@ class SandboxManagerEnvConfig(BaseModel):
95
100
  description="Prefix for Redis keys related to container pool.",
96
101
  )
97
102
 
103
+ # Kubernetes settings
104
+ k8s_namespace: Optional[str] = Field(
105
+ "default",
106
+ description="Kubernetes namespace to deploy pods. Required if "
107
+ "container_deployment is 'k8s'.",
108
+ )
109
+ kubeconfig_path: Optional[str] = Field(
110
+ None,
111
+ description="Path to kubeconfig file. If not set, will try "
112
+ "in-cluster config or default kubeconfig.",
113
+ )
114
+
98
115
  @model_validator(mode="after")
99
116
  def check_settings(cls, self):
100
- if not self.default_mount_dir:
101
- raise ValueError("default_mount_dir must be set")
102
-
103
- os.makedirs(self.default_mount_dir, exist_ok=True)
117
+ if self.default_mount_dir:
118
+ os.makedirs(self.default_mount_dir, exist_ok=True)
104
119
 
105
120
  if self.file_system == "oss":
106
121
  required_oss_fields = [
@@ -147,12 +162,3 @@ class SandboxManagerEnvConfig(BaseModel):
147
162
  )
148
163
 
149
164
  return self
150
-
151
-
152
- DEFAULT_LOCAL_MANAGER_CONFIG = SandboxManagerEnvConfig(
153
- file_system="local",
154
- redis_enabled=False,
155
- container_deployment="docker",
156
- pool_size=0,
157
- default_mount_dir="sessions_mount_dir",
158
- )
@@ -1,5 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # pylint: disable=unused-argument
3
+ import inspect
4
+
3
5
  from abc import ABC, abstractmethod
4
6
  from typing import Optional, Any, Dict
5
7
  from ..enums import SandboxType
@@ -121,3 +123,112 @@ class Tool(ABC):
121
123
  f"sandbox_type='{self.sandbox_type}'"
122
124
  f")"
123
125
  )
126
+
127
+ def make_function(self):
128
+ """Create a function with proper type signatures from schema."""
129
+ tool_call = self.__call__
130
+ parameters = self.schema["function"]["parameters"]
131
+
132
+ # Extract properties and required parameters from the schema
133
+ properties = parameters.get("properties", {})
134
+ required = parameters.get("required", [])
135
+
136
+ # Type mapping from JSON schema types to Python types
137
+ type_mapping = {
138
+ "string": str,
139
+ "integer": int,
140
+ "number": float,
141
+ "boolean": bool,
142
+ "array": list,
143
+ "object": dict,
144
+ }
145
+
146
+ # Build parameter signature
147
+ sig_params = []
148
+ for param_name, param_info in properties.items():
149
+ param_type = type_mapping.get(
150
+ param_info.get("type", "string"),
151
+ str,
152
+ )
153
+
154
+ if param_name in required:
155
+ # Required parameter
156
+ param = inspect.Parameter(
157
+ param_name,
158
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
159
+ annotation=param_type,
160
+ )
161
+ else:
162
+ # Optional parameter with default None
163
+ param = inspect.Parameter(
164
+ param_name,
165
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
166
+ default=None,
167
+ annotation=Optional[param_type],
168
+ )
169
+
170
+ sig_params.append(param)
171
+
172
+ # Create the function signature
173
+ new_signature = inspect.Signature(sig_params, return_annotation=Any)
174
+
175
+ def generated_function(*args, **kwargs):
176
+ """
177
+ Dynamically generated function wrapper for the tool schema.
178
+
179
+ This function is created at runtime to match the tool's parameter
180
+ signature as defined in the schema. It validates arguments and
181
+ forwards them to the tool's call interface.
182
+ """
183
+ # Bind arguments to signature
184
+ bound = new_signature.bind(*args, **kwargs)
185
+ bound.apply_defaults()
186
+
187
+ # Validate required parameters
188
+ missing_required = [
189
+ param_name
190
+ for param_name in required
191
+ if param_name not in bound.arguments
192
+ or bound.arguments[param_name] is None
193
+ ]
194
+
195
+ if missing_required:
196
+ raise TypeError(
197
+ f"Missing required arguments: {set(missing_required)}",
198
+ )
199
+
200
+ # Filter kwargs based on defined properties and remove None
201
+ # values for optional params
202
+ filtered_kwargs = {
203
+ k: v
204
+ for k, v in bound.arguments.items()
205
+ if k in properties and (k in required or v is not None)
206
+ }
207
+
208
+ return tool_call(**filtered_kwargs)
209
+
210
+ # Set the correct signature and metadata
211
+ generated_function.__signature__ = new_signature
212
+ generated_function.__name__ = self.name
213
+
214
+ # Build docstring with parameter information
215
+ doc_parts = []
216
+ for name, info in properties.items():
217
+ required_str = " (required)" if name in required else " (optional)"
218
+ doc_parts.append(
219
+ f" {name}: {info.get('type', 'string')}{required_str} -"
220
+ f" {info.get('description', '')}",
221
+ )
222
+
223
+ generated_function.__doc__ = (
224
+ self.schema["function"]["description"]
225
+ + "\n\nParameters:\n"
226
+ + "\n".join(doc_parts)
227
+ )
228
+
229
+ # Set type annotations for compatibility with typing inspection
230
+ annotations = {param.name: param.annotation for param in sig_params}
231
+ annotations["return"] = Any
232
+ generated_function.__annotations__ = annotations
233
+
234
+ return generated_function
@@ -1,2 +1,2 @@
1
1
  # -*- coding: utf-8 -*-
2
- __version__ = "v0.0.1"
2
+ __version__ = "v0.1.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentscope-runtime
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: A production-ready runtime framework for agent applications, providing secure sandboxed execution environments and scalable deployment solutions with multi-framework support.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -17,14 +17,18 @@ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
17
17
  Requires-Dist: pre-commit>=4.2.0; extra == "dev"
18
18
  Requires-Dist: jupyter-book>=1.0.4.post1; extra == "dev"
19
19
  Requires-Dist: furo>=2025.7.19; extra == "dev"
20
+ Requires-Dist: pytest-cov>=6.2.1; extra == "dev"
21
+ Requires-Dist: fakeredis>=2.31.0; extra == "dev"
22
+ Requires-Dist: sphinx-autoapi>=3.6.0; extra == "dev"
20
23
  Provides-Extra: sandbox
21
24
  Requires-Dist: docker>=7.1.0; extra == "sandbox"
22
25
  Requires-Dist: steel-sdk>=0.1.0; extra == "sandbox"
23
26
  Requires-Dist: redis>=6.0.0b2; extra == "sandbox"
24
27
  Requires-Dist: oss2>=2.19.1; extra == "sandbox"
25
- Requires-Dist: requests>=2.32.4; extra == "sandbox"
26
28
  Requires-Dist: pydantic-settings>=2.9.1; extra == "sandbox"
27
29
  Requires-Dist: dotenv>=0.9.9; extra == "sandbox"
30
+ Requires-Dist: kubernetes>=33.1.0; extra == "sandbox"
31
+ Requires-Dist: shortuuid>=1.0.13; extra == "sandbox"
28
32
  Provides-Extra: agentscope
29
33
  Requires-Dist: agentscope==1.0.0; extra == "agentscope"
30
34
  Provides-Extra: langgraph
@@ -33,17 +37,35 @@ Provides-Extra: agno
33
37
  Requires-Dist: agno>=1.7.5; extra == "agno"
34
38
  Provides-Extra: a2a
35
39
  Requires-Dist: a2a-sdk>=0.3.0; extra == "a2a"
40
+ Provides-Extra: autogen
41
+ Requires-Dist: autogen-agentchat>=0.7.4; extra == "autogen"
42
+ Requires-Dist: autogen-ext[openai]>=0.7.4; extra == "autogen"
43
+ Provides-Extra: langchain-rag
44
+ Requires-Dist: langchain>=0.3.25; extra == "langchain-rag"
45
+ Requires-Dist: pymilvus>=2.6.0; extra == "langchain-rag"
46
+ Requires-Dist: langchain-community>=0.3.27; extra == "langchain-rag"
47
+ Requires-Dist: langchain-milvus>=0.2.1; extra == "langchain-rag"
36
48
  Dynamic: license-file
37
49
 
38
50
  <div align="center">
39
51
 
40
52
  # AgentScope Runtime
41
53
 
42
- [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
43
- [![Version](https://img.shields.io/badge/version-0.1.0-green.svg)](https://github.com/agentscope-ai/agentscope-runtime)
44
- [![License](https://img.shields.io/badge/license-Apache%202.0-yellow.svg)](LICENSE)
45
- [![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
46
-
54
+ [![PyPI](https://img.shields.io/pypi/v/agentscope-runtime?label=PyPI&color=brightgreen&logo=python)](https://pypi.org/project/agentscope-runtime/)
55
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg?logo=python&label=Python)](https://python.org)
56
+ [![License](https://img.shields.io/badge/license-Apache%202.0-red.svg?logo=apache&label=Liscnese)](LICENSE)
57
+ [![Code Style](https://img.shields.io/badge/code%20style-black-black.svg?logo=python&label=CodeStyle)](https://github.com/psf/black)
58
+ [![GitHub Stars](https://img.shields.io/github/stars/agentscope-ai/agentscope-runtime?style=flat&logo=github&color=yellow&label=Stars)](https://github.com/agentscope-ai/agentscope-runtime/stargazers)
59
+ [![GitHub Forks](https://img.shields.io/github/forks/agentscope-ai/agentscope-runtime?style=flat&logo=github&color=purple&label=Forks)](https://github.com/agentscope-ai/agentscope-runtime/network)
60
+ [![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg?logo=githubactions&label=Build)](https://github.com/agentscope-ai/agentscope-runtime/actions)
61
+ [![Cookbook](https://img.shields.io/badge/📚_Cookbook-English|中文-teal.svg)](https://runtime.agentscope.io)
62
+ [![DeepWiki](https://img.shields.io/badge/DeepWiki-agentscope--runtime-navy.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==)](https://deepwiki.com/agentscope-ai/agentscope-runtime)
63
+ [![A2A](https://img.shields.io/badge/A2A-Agent_to_Agent-blue.svg?label=A2A)](https://a2a-protocol.org/)
64
+ [![MCP](https://img.shields.io/badge/MCP-Model_Context_Protocol-purple.svg?logo=plug&label=MCP)](https://modelcontextprotocol.io/)
65
+ [![Discord](https://img.shields.io/badge/Discord-Join_Us-blueviolet.svg?logo=discord)](https://discord.gg/eYMpfnkG8h)
66
+ [![DingTalk](https://img.shields.io/badge/DingTalk-Join_Us-orange.svg)](https://qr.dingtalk.com/action/joingroup?code=v1,k1,OmDlBXpjW+I2vWjKDsjvI9dhcXjGZi3bQiojOq3dlDw=&_dt_no_comment=1&origin=11)
67
+
68
+ [[Cookbook]](https://runtime.agentscope.io/)
47
69
  [[中文README]](README_zh.md)
48
70
 
49
71
  **A Production-Ready Runtime Framework for Intelligent Agent Applications**
@@ -81,7 +103,7 @@ Welcome to join our community on
81
103
 
82
104
  - [🚀 Quick Start](#-quick-start)
83
105
  - [📚 Cookbook](#-cookbook)
84
- - [🔌Agent Framework Integration](#-agent-framework-integration)
106
+ - [🔌 Agent Framework Integration](#-agent-framework-integration)
85
107
  - [🏗️ Deployment](#️-deployment)
86
108
  - [🤝 Contributing](#-contributing)
87
109
  - [📄 License](#-license)
@@ -96,14 +118,30 @@ Welcome to join our community on
96
118
 
97
119
  ### Installation
98
120
 
121
+ From PyPI:
122
+
99
123
  ```bash
100
- # Install dependencies
124
+ # Install core dependencies
101
125
  pip install agentscope-runtime
102
126
 
103
127
  # Install sandbox dependencies
104
128
  pip install "agentscope-runtime[sandbox]"
105
129
  ```
106
130
 
131
+ (Optional) From source:
132
+
133
+ ```bash
134
+ # Pull the source code from GitHub
135
+ git clone -b main https://github.com/agentscope-ai/agentscope-runtime.git
136
+ cd agentscope-runtime
137
+
138
+ # Install core dependencies
139
+ pip install -e .
140
+
141
+ # Install sandbox dependencies
142
+ pip install -e ".[sandbox]"
143
+ ```
144
+
107
145
  ### Basic Agent Usage Example
108
146
 
109
147
  This example demonstrates how to create a simple LLM agent using AgentScope Runtime and stream responses from the Qwen model.
@@ -164,14 +202,19 @@ with BaseSandbox() as box:
164
202
  print(box.run_shell_command(command="echo hello"))
165
203
  ```
166
204
 
205
+ > [!NOTE]
206
+ >
207
+ > Current version requires Docker or Kubernetes to be installed and running on your system. Please refer to [this tutorial](https://runtime.agentscope.io/en/sandbox.html) for more details.
208
+
167
209
  ---
168
210
 
169
211
  ## 📚 Cookbook
170
212
 
171
- - **[📖 Cookbook](/cookbook/en/intro.md)**: Comprehensive tutorials
172
- - **[💡 Concept](/cookbook/en/concept.md)**: Core concepts and architecture overview
173
- - **[🚀 Quick Start](/cookbook/en/quickstart.md)**: Quick start tutorial
174
- - **[🏠 Demo House](/cookbook/en/demohouse.md)**: Rich example projects
213
+ - **[📖 Cookbook](https://runtime.agentscope.io/en/intro.html)**: Comprehensive tutorials
214
+ - **[💡 Concept](https://runtime.agentscope.io/en/concept.html)**: Core concepts and architecture overview
215
+ - **[🚀 Quick Start](https://runtime.agentscope.io/en/quickstart.html)**: Quick start tutorial
216
+ - **[🏠 Demo House](https://runtime.agentscope.io/en/demohouse.html)**: Rich example projects
217
+ - **[📋 API Reference](https://runtime.agentscope.io/en/api/index.html)**: Complete API documentation
175
218
 
176
219
  ---
177
220
 
@@ -180,6 +223,7 @@ with BaseSandbox() as box:
180
223
  ### AgentScope Integration
181
224
 
182
225
  ```python
226
+ # pip install "agentscope-runtime[agentscope]"
183
227
  import os
184
228
 
185
229
  from agentscope.agent import ReActAgent
@@ -202,6 +246,7 @@ agent = AgentScopeAgent(
202
246
  ### Agno Integration
203
247
 
204
248
  ```python
249
+ # pip install "agentscope-runtime[agno]"
205
250
  from agno.agent import Agent
206
251
  from agno.models.openai import OpenAIChat
207
252
  from agentscope_runtime.engine.agents.agno_agent import AgnoAgent
@@ -218,9 +263,30 @@ agent = AgnoAgent(
218
263
  )
219
264
  ```
220
265
 
266
+ ### AutoGen Integration
267
+
268
+ ```python
269
+ # pip install "agentscope-runtime[autogen]"
270
+ from autogen_agentchat.agents import AssistantAgent
271
+ from autogen_ext.models.openai import OpenAIChatCompletionClient
272
+ from agentscope_runtime.engine.agents.autogen_agent import AutogenAgent
273
+
274
+ agent = AutogenAgent(
275
+ name="Friday",
276
+ model=OpenAIChatCompletionClient(
277
+ model="gpt-4",
278
+ ),
279
+ agent_config={
280
+ "system_message": "You're a helpful assistant",
281
+ },
282
+ agent_builder=AssistantAgent,
283
+ )
284
+ ```
285
+
221
286
  ### LangGraph Integration
222
287
 
223
288
  ```python
289
+ # pip install "agentscope-runtime[langgraph]"
224
290
  from typing import TypedDict
225
291
  from langgraph import graph, types
226
292
  from agentscope_runtime.engine.agents.langgraph_agent import LangGraphAgent
@@ -1,14 +1,15 @@
1
1
  agentscope_runtime/__init__.py,sha256=LMAUeUpPo2qzqh3zyZ-JJwc8GrsiT9b-yNhQMxlKmfE,84
2
- agentscope_runtime/version.py,sha256=uH1loJ9Z7js-rzD3AtGaiKy64plJ8DNE5Otkg7-erc8,47
2
+ agentscope_runtime/version.py,sha256=pjOHhrefLzD0n2nmWmav13ebodq8-tis_BR3y2DzMgA,47
3
3
  agentscope_runtime/engine/__init__.py,sha256=jsvYM1LlZVP4EFzsE5uu5ycgBU9CVnug7UyTzBmpX5g,213
4
4
  agentscope_runtime/engine/runner.py,sha256=HhOjfAgao-b5vzSZh6pckVhx0K32qs868dvRE3Z56TA,5686
5
5
  agentscope_runtime/engine/agents/__init__.py,sha256=xHp7FY6QM-nAhQAECi7xzrJkRkYZpAa5_zHRhO6Zogc,54
6
- agentscope_runtime/engine/agents/agno_agent.py,sha256=jw_ZbXL5Y_WiSWom2Q6WqeBE4Q5_TqC1hjQ1cPxKHnw,6674
6
+ agentscope_runtime/engine/agents/agno_agent.py,sha256=c2f575gc5ZOWGvrdjObo7IGSbM1Si0JQGxKpqtMSf14,6716
7
+ agentscope_runtime/engine/agents/autogen_agent.py,sha256=HbtvN8554FnkgMHX418sMgIM-hp7OVCUR2YJybRMKxI,7693
7
8
  agentscope_runtime/engine/agents/base_agent.py,sha256=fGf4MNKmfm_fsU2orTPLpt7TT5HkZZZYR05rhp5s7-E,782
8
9
  agentscope_runtime/engine/agents/langgraph_agent.py,sha256=05Z5js7g9Dxy-MWj0W00jOtFMNnHzSPjlP3WIIVHTtQ,1416
9
10
  agentscope_runtime/engine/agents/llm_agent.py,sha256=0hG_FRtAxmlljmI51GT7ui_7wjjHO03wckx9bNKra8Y,1356
10
11
  agentscope_runtime/engine/agents/agentscope_agent/__init__.py,sha256=lt1NJEDuBWaX1n-bqMbQR6Uol7-fFUuyeuHy8FQrzWk,97
11
- agentscope_runtime/engine/agents/agentscope_agent/agent.py,sha256=76F0Ij3nMR04elkUE4R_L5lbLygLJ_t79rnh3nijgEg,11941
12
+ agentscope_runtime/engine/agents/agentscope_agent/agent.py,sha256=Tp3OJi0r8aU1juXKF8fT9dCfaL2w3_sqQcSBuThndUM,11983
12
13
  agentscope_runtime/engine/agents/agentscope_agent/hooks.py,sha256=iX2xY3UDtiC1ilzvyHL4kLWKB4xH-iQ4o3erh5HVpXo,5444
13
14
  agentscope_runtime/engine/deployers/__init__.py,sha256=2eUo6uvloMt4AstmalkwcBgR7gPyppNqlmjld0Ztpxk,103
14
15
  agentscope_runtime/engine/deployers/base.py,sha256=0bb3zQiVE1jTMG0NCsjhcSeP7lhnbn1KPQRx1H5hues,494
@@ -25,14 +26,17 @@ agentscope_runtime/engine/llms/base_llm.py,sha256=Vvxlqom35qaSLYSyyh3hj-XsoyFxcf
25
26
  agentscope_runtime/engine/llms/qwen_llm.py,sha256=_J-PpwSrKNSmQzO6KNzJlMd5t4m47YVKXp0fl-KYQmA,1271
26
27
  agentscope_runtime/engine/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
28
  agentscope_runtime/engine/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- agentscope_runtime/engine/schemas/agent_schemas.py,sha256=lyYlXLn6EY7Yg_anook7mxG2TynjCmcf7Eja5UFDoHo,14653
29
+ agentscope_runtime/engine/schemas/agent_schemas.py,sha256=N4uPXeL6v6lrCy7EiFo02VbvxgfYv-2fNFAqwU1ohoI,14663
29
30
  agentscope_runtime/engine/schemas/context.py,sha256=Qd2ee4HCYNmD5VHsacrScdpNq8q2aJwsRtsrBZarI9M,1550
30
31
  agentscope_runtime/engine/services/__init__.py,sha256=SAsmwIr8etoUbqz5W1K2pH5ONlFzooXMQ0UFXTXfHwM,271
31
32
  agentscope_runtime/engine/services/base.py,sha256=g2hTc3ivj2MPjnsu5_09m6_MZ3KDHBfiYKu4F2pLA1I,2096
32
- agentscope_runtime/engine/services/context_manager.py,sha256=PaGeq_uK1DqOb75ViMGO_qP32W2vnw70uwY-FP1bubs,4058
33
+ agentscope_runtime/engine/services/context_manager.py,sha256=93U0rBBDC6jwl_rARtCq7K-Q42zoVGxnxD7Xv1f5yo0,4947
33
34
  agentscope_runtime/engine/services/environment_manager.py,sha256=Bd3vmgX5KkN9gTY60o7Pozpsw0S8etpSJns63woSlDU,1347
34
35
  agentscope_runtime/engine/services/manager.py,sha256=r-TcHti8sEMXjZbwPWlG32J8iiMHUXuUJmAiwPvgn_Q,6282
35
- agentscope_runtime/engine/services/memory_service.py,sha256=ztVgjOOH5_udA5bygV1Zep6WxWJCmGILCofDsTUfljo,7881
36
+ agentscope_runtime/engine/services/memory_service.py,sha256=EHsvNPMXsH1B8LZY0zZKzYMvDHzaP18edKv9uimM98k,7889
37
+ agentscope_runtime/engine/services/rag_service.py,sha256=mqcKByt0t7MWA2m86vTyNhO-E49djZcPwAqb3GehQQM,2668
38
+ agentscope_runtime/engine/services/redis_memory_service.py,sha256=2A6ouYghs80jby_MUcwiKfCScmYUbIcYsMlmEMynuqg,5708
39
+ agentscope_runtime/engine/services/redis_session_history_service.py,sha256=Zo7H0QtUZRKXh07JHcvtZfmEqbmidEsTGkhGfk1aLQE,5042
36
40
  agentscope_runtime/engine/services/sandbox_service.py,sha256=IzVg5BtDEfqFrVy7SnE3GDYXVXc0jzv9XIl0mFYHWDk,6082
37
41
  agentscope_runtime/engine/services/session_history_service.py,sha256=CLDMHNja6k7VrTQMkQDf24uP-aSGV5sdBjG5A0t_c64,8044
38
42
  agentscope_runtime/engine/tracing/__init__.py,sha256=DuM6Zp_IJ-ixgTTomtrMbpcYiMJOHMrJHwKIqcLzrfA,1133
@@ -41,9 +45,9 @@ agentscope_runtime/engine/tracing/local_logging_handler.py,sha256=LP-2NX7kRPhEN-
41
45
  agentscope_runtime/engine/tracing/tracing_metric.py,sha256=3qHqBRiTWijqBPLchxyERfPZCstTo8Y5LuL-eCuQas0,2115
42
46
  agentscope_runtime/engine/tracing/wrapper.py,sha256=ioeKSRJDJgcW34OfFmAq7vgE0FNEFXa_4QLSf7kUBfU,11236
43
47
  agentscope_runtime/sandbox/__init__.py,sha256=39NF3OdrBoUOje8gHI--cIgLMfY3ojm0JWYmGsEiWFU,378
44
- agentscope_runtime/sandbox/build.py,sha256=EethoUnT2P8k3UoS3m97VHsiZ8E-6hNTPD7ihOTAmZ0,6436
48
+ agentscope_runtime/sandbox/build.py,sha256=rhcsHbDkcQgS4Hxv8z2Lsjp3LnheQyCCTbm3rkv80Tw,6439
45
49
  agentscope_runtime/sandbox/constant.py,sha256=-CaSZkDPO2XQ70-PVymu4Z5Y7hlvdpPJ3zgP27MLvik,156
46
- agentscope_runtime/sandbox/enums.py,sha256=_2I1pl6sxNKYtxEwqDpJ43ZOP-Y4yWScBNbDLn5_d3A,1838
50
+ agentscope_runtime/sandbox/enums.py,sha256=zGSs3A3SsxjqmSrArn9qEWGO594cYahOHPnG8HHxpYk,1880
47
51
  agentscope_runtime/sandbox/mcp_server.py,sha256=UT3aRZqyeHqEhhm-wZ0Ilhew3eDMHzz9DCN6Qb-eKFk,6012
48
52
  agentscope_runtime/sandbox/registry.py,sha256=E4APDpk1oxhJCh8dEIDjZ1DtQJ-mPaRGYXr3AbTsnmc,4191
49
53
  agentscope_runtime/sandbox/box/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -71,21 +75,23 @@ agentscope_runtime/sandbox/box/shared/routers/runtime_watcher.py,sha256=v4jAGYtJ
71
75
  agentscope_runtime/sandbox/box/shared/routers/workspace.py,sha256=cQMbWNQG7ojHZfWN0xFqEivhlpQO4qEDo3amkhVHUBg,9748
72
76
  agentscope_runtime/sandbox/box/training_box/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
77
  agentscope_runtime/sandbox/box/training_box/base.py,sha256=iUPsfA8oiGDR3BMVU7qisvO-UT8HtCx78ayW67DQ0WQ,3307
74
- agentscope_runtime/sandbox/box/training_box/env_service.py,sha256=oCan3Q4mK8Hz9CiOEmHBp6DLxj8m0lVqOO_Mh--qd9E,22597
78
+ agentscope_runtime/sandbox/box/training_box/env_service.py,sha256=YoMswhQrX8VmE202tpFq-bQo6gOd2oemBhTG_MD9Rwg,22616
75
79
  agentscope_runtime/sandbox/box/training_box/registry.py,sha256=6fTMZvJbakhEqkaO61K-wIfX6uau7g4nFP63bQ7jiNI,1362
76
- agentscope_runtime/sandbox/box/training_box/training_box.py,sha256=pvkzbO5UOP9kgEL6xRjH3nk6inmW1QmRTbHvXT0TB6E,6143
80
+ agentscope_runtime/sandbox/box/training_box/training_box.py,sha256=yM1_Veorn2nwnxgAUB-6GZMp_1UKmus9-LpJQwKATxg,10200
77
81
  agentscope_runtime/sandbox/box/training_box/environments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
78
82
  agentscope_runtime/sandbox/box/training_box/environments/appworld/appworld_env.py,sha256=FJc0eb6bnKL6lxx_4EKWr7kmKLi2jLsykNstecXEqkc,27786
83
+ agentscope_runtime/sandbox/box/training_box/environments/bfcl/bfcl_dataprocess.py,sha256=jkg8wDwDXdZZU7q777tnyqc-C9hRlPF0pffJ4DX5upQ,7352
84
+ agentscope_runtime/sandbox/box/training_box/environments/bfcl/bfcl_env.py,sha256=22hfq1yO5abZocG8FfaabCXD4HGg-RT_8AY1dHbtvxM,11878
85
+ agentscope_runtime/sandbox/box/training_box/environments/bfcl/env_handler.py,sha256=T-W9w4nKI7_BXgF9caqV3KMeX5d6yvdfhQu0o2oWTUE,30114
79
86
  agentscope_runtime/sandbox/box/training_box/src/trajectory.py,sha256=cFr3uVUPq5gHKPa6ALi7QCLBVkgYOyPgyJrOzgBHf3k,7885
80
87
  agentscope_runtime/sandbox/client/__init__.py,sha256=KiNsTToc1jICqCC1BcH762jZgHuOkCPiG32oXGo6dQE,176
81
88
  agentscope_runtime/sandbox/client/http_client.py,sha256=YqITjeq4fySWSDr39DAG80NpRfD0--Ndupr7hMqL7RA,17954
82
89
  agentscope_runtime/sandbox/client/training_client.py,sha256=MYfI06MeyIelwjY4QllVL4exhSCMNpdMudGi2ctVL28,7675
83
90
  agentscope_runtime/sandbox/custom/__init__.py,sha256=wpu0DlzdLohYzOVM9yZloIWid3w_ME6dPtOjCZKbRZ8,463
84
- agentscope_runtime/sandbox/custom/custom_sandbox.py,sha256=3G0xn2654gTUJ65QvB1D-_sFtHDq5arSBJd4uuxIkpM,1023
85
- agentscope_runtime/sandbox/custom/example.py,sha256=NB4mzT7ce8m1qLkImRihCDjC2SifWLJt65F-jKZ44C0,983
91
+ agentscope_runtime/sandbox/custom/custom_sandbox.py,sha256=2-HZRUlZcvv-YZh9NrHBByKamhVowwZ_drGJSAwKM8c,971
92
+ agentscope_runtime/sandbox/custom/example.py,sha256=ycKmuUHghmPTUYfEQW0AyG5SHt1Ggf3_NlAP5Z6OZAQ,931
86
93
  agentscope_runtime/sandbox/manager/__init__.py,sha256=KNHc1uDaUWBH_ZnWjH5NHRBiQM_zDyi9B2xKVNtAWIg,98
87
- agentscope_runtime/sandbox/manager/sandbox_manager.py,sha256=IltdO0Ln3BAhB9543YT6CljdgnpGANrgHRX9LJGKb1c,23056
88
- agentscope_runtime/sandbox/manager/utils.py,sha256=c_Zicb8xnkp7UoPC9SN29m2H7mvREFbCExBM_8sU_Ug,1977
94
+ agentscope_runtime/sandbox/manager/sandbox_manager.py,sha256=CTd5bd8EeRMoiL3PcPCW9HciNIWSU5XCe_5qI6IZjXk,23270
89
95
  agentscope_runtime/sandbox/manager/collections/__init__.py,sha256=teQPF7huMB2yEX_CAFsmIJhQxH7ldHR7gr11W3jlx4o,582
90
96
  agentscope_runtime/sandbox/manager/collections/base_mapping.py,sha256=IIVNwvaGVAiL6XxV0LvUHx-JmDvUc19iOGyRyAccMaI,361
91
97
  agentscope_runtime/sandbox/manager/collections/base_queue.py,sha256=eCwb5eovwzSV83J_Nq3HX_4IQ8rjYw9wdeVRS5sRQHA,424
@@ -96,26 +102,27 @@ agentscope_runtime/sandbox/manager/collections/in_memory_set.py,sha256=7qek5ZB3f
96
102
  agentscope_runtime/sandbox/manager/collections/redis_mapping.py,sha256=CmI_C83gQlbnZWz3vwFe5rySXxND11JnB8-iZbNooxo,688
97
103
  agentscope_runtime/sandbox/manager/collections/redis_queue.py,sha256=4MCIDs7SgSfdngTvqxWWv2H-8XTpFQOmXG4-fxN20ew,792
98
104
  agentscope_runtime/sandbox/manager/collections/redis_set.py,sha256=eRCnMXc4hcDF2qyxFiNnrn2o4QjvtgDb6rEcblmV1o8,654
99
- agentscope_runtime/sandbox/manager/container_clients/__init__.py,sha256=GBHfhh-jxSWIT3XWDWzweMTpHsV3_-FwgH_AkXt0lsg,153
105
+ agentscope_runtime/sandbox/manager/container_clients/__init__.py,sha256=G5TTwLv_UgWUDwtwr6oohJXuGW3gAwxmgD1VhZH3zs8,225
100
106
  agentscope_runtime/sandbox/manager/container_clients/base_client.py,sha256=_uvxRh65lbMNXDcHjq01aYuNUrcxRlNzRtRIPMgWFGc,992
101
- agentscope_runtime/sandbox/manager/container_clients/docker_client.py,sha256=UF2418SULS2oiUgA8Atv13NT_fYVJMZ5JD1g8wt_yhw,5754
107
+ agentscope_runtime/sandbox/manager/container_clients/docker_client.py,sha256=rmm2mUDfot81kQ7H6O5fI0QHXvCDOsepUdlNnC5ouVU,13407
108
+ agentscope_runtime/sandbox/manager/container_clients/kubernetes_client.py,sha256=1LRlE53bfkGIFQxhZ5yGRAjqm9ilajmoNjLavCD8X5E,20884
102
109
  agentscope_runtime/sandbox/manager/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
- agentscope_runtime/sandbox/manager/server/app.py,sha256=PKAD2oIGD1NDUogS64tJ86KkWwGXtY7aK6HsQYH4xoE,5714
104
- agentscope_runtime/sandbox/manager/server/config.py,sha256=_SSuP2uBKsiG2SOTfWuInxqxdbkZeOvm09TqQB_96pI,2078
110
+ agentscope_runtime/sandbox/manager/server/app.py,sha256=JcIF8P8TRuVPkdaM2ibY8izNmBIo7Wv9ivifMYdCUSI,7874
111
+ agentscope_runtime/sandbox/manager/server/config.py,sha256=rIRKI_GHmyt3Wty_ujUya_vSw_ij-rRkerqiQPG_yzU,2423
105
112
  agentscope_runtime/sandbox/manager/server/models.py,sha256=rCibF0HsotFcqsQVTSUoOTJCFQU3oqKvpOiWMWIRLyY,304
106
113
  agentscope_runtime/sandbox/manager/storage/__init__.py,sha256=jGmpfXV1E2X7AqkGeF1xu1EHiSTvbH3TSIviLbKBFh4,210
107
114
  agentscope_runtime/sandbox/manager/storage/data_storage.py,sha256=mGwf7LYbp_fRjLN9BZay6cm3eNziEdU6OlSBeFnIBMQ,475
108
115
  agentscope_runtime/sandbox/manager/storage/local_storage.py,sha256=o6fkV-yUtBihhfZtLEdBUhF1K8_psSl92AWJFtYQxtk,1521
109
116
  agentscope_runtime/sandbox/manager/storage/oss_storage.py,sha256=fIUxgOkOaH_1vlgWBnCM-e4UvD3xS_ycFe2yvSyXzBE,2970
110
- agentscope_runtime/sandbox/model/__init__.py,sha256=H7cAvnLdcZdMd0XYN04vbvdcrBqbygdVP3X13rWVJug,261
117
+ agentscope_runtime/sandbox/model/__init__.py,sha256=WoDOSD_67T-UkZdXOtJzwG4-0E8ABwUBJF6WSCs_sO0,182
111
118
  agentscope_runtime/sandbox/model/api.py,sha256=Sjxw6DHkGa8Sp5dUU5kaajkHPj7eiX1EgFZk-zOPafM,400
112
- agentscope_runtime/sandbox/model/container.py,sha256=cVjzFYJO59kLi5TddA3SPpHY7qx8i9TMzw-XQIe2hJM,1683
113
- agentscope_runtime/sandbox/model/manager_config.py,sha256=PGZ7nbFmc61tcGUnAzv028pNJupXUuNAggV1HBOQ4HM,4862
119
+ agentscope_runtime/sandbox/model/container.py,sha256=w2X970bk0C7lLdpq0bk2BJzanVsEES6Btk1LdXWIp4I,1698
120
+ agentscope_runtime/sandbox/model/manager_config.py,sha256=P2T0lT_uVlyh2tOcTpJo-zsiS9J7eJ5Voipb9GMFHiw,5118
114
121
  agentscope_runtime/sandbox/tools/__init__.py,sha256=ioRqvKFLma8Vq0ePwOR5MekijpcHs2USNYA4Dnr-e6M,287
115
122
  agentscope_runtime/sandbox/tools/function_tool.py,sha256=mH4dq3M26pdk-XqxIm1wtsvQz5i8SXcP4Gz0-7_L7cQ,10309
116
123
  agentscope_runtime/sandbox/tools/mcp_tool.py,sha256=yaEwWLeuLVxlZhhCXVHMxZPCod1bwGHo8W_rNkgKOpI,6063
117
124
  agentscope_runtime/sandbox/tools/sandbox_tool.py,sha256=wHkgixb0dy6DexXbfXVOKUFfLL9QOI2H5oiQ2NntoWM,3067
118
- agentscope_runtime/sandbox/tools/tool.py,sha256=jCcKDnN9ZOjrr9BfoXmXrB2kXCxonDBpTzr65reWblE,3460
125
+ agentscope_runtime/sandbox/tools/tool.py,sha256=f2-14tP1V2Vgw5krr0q-uEM3lOAQUF6GdttqYdZkIdI,7361
119
126
  agentscope_runtime/sandbox/tools/utils.py,sha256=QksPQK-2DszaQsRw4Srug5hEwrf6hothf-Xp8a1056c,2098
120
127
  agentscope_runtime/sandbox/tools/base/__init__.py,sha256=Aboc1tFjgWriw4gqDrX5axpC_Bx469mcn8l8nbNdSXg,143
121
128
  agentscope_runtime/sandbox/tools/base/tool.py,sha256=5rCZ_SdDiRCZyQfdsWC1FPq7jwnSSbnKxyjQQK3PAS8,1347
@@ -123,9 +130,9 @@ agentscope_runtime/sandbox/tools/browser/__init__.py,sha256=gXQx3tXclYqAhPDrXb1-
123
130
  agentscope_runtime/sandbox/tools/browser/tool.py,sha256=EJ-uhHX9oIb4Q-hXQhTS-7VRJ-AdCRWXb9HVdOQ5JAc,19206
124
131
  agentscope_runtime/sandbox/tools/filesystem/__init__.py,sha256=AJK88YU0ceJe99H7T-on2tgaow4ujqGJ1jwv0sd1TtE,607
125
132
  agentscope_runtime/sandbox/tools/filesystem/tool.py,sha256=CPsl4TMf76BOSQtG1dqDcVdymciKhMknIG5FffoI2Eg,9847
126
- agentscope_runtime-0.1.0.dist-info/licenses/LICENSE,sha256=3MckDTgiTJ0E6cxo8FeamFVEFiwz3XJWsriuTtRJzxY,11337
127
- agentscope_runtime-0.1.0.dist-info/METADATA,sha256=zI2P01LcipD4fyzvXh3vZfsxlFJRsBLSXPVaNBTT-70,10291
128
- agentscope_runtime-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
129
- agentscope_runtime-0.1.0.dist-info/entry_points.txt,sha256=SGQZqgozJYj1yJtiyzqiJ2_iYmDvTl2lexxmXENY3wE,223
130
- agentscope_runtime-0.1.0.dist-info/top_level.txt,sha256=0YHketA7WcMmRmF-3lUzedeTOnP7iL77h-ekb-iG720,19
131
- agentscope_runtime-0.1.0.dist-info/RECORD,,
133
+ agentscope_runtime-0.1.2.dist-info/licenses/LICENSE,sha256=3MckDTgiTJ0E6cxo8FeamFVEFiwz3XJWsriuTtRJzxY,11337
134
+ agentscope_runtime-0.1.2.dist-info/METADATA,sha256=DIu328pONBuGKlDk9PQzw74ROl3ab7aqZ1811nOStD0,15012
135
+ agentscope_runtime-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
136
+ agentscope_runtime-0.1.2.dist-info/entry_points.txt,sha256=SGQZqgozJYj1yJtiyzqiJ2_iYmDvTl2lexxmXENY3wE,223
137
+ agentscope_runtime-0.1.2.dist-info/top_level.txt,sha256=0YHketA7WcMmRmF-3lUzedeTOnP7iL77h-ekb-iG720,19
138
+ agentscope_runtime-0.1.2.dist-info/RECORD,,
@@ -1,78 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import socket
3
- import subprocess
4
- import logging
5
-
6
-
7
- logging.basicConfig(level=logging.INFO)
8
- logger = logging.getLogger(__name__)
9
-
10
-
11
- def is_port_available(port):
12
- """
13
- Check if a given port is available (not in use) on the local system.
14
-
15
- Args:
16
- port (int): The port number to check.
17
-
18
- Returns:
19
- bool: True if the port is available, False if it is in use.
20
- """
21
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
22
- try:
23
- s.bind(("", port))
24
- # Port is available
25
- return True
26
- except OSError:
27
- # Port is in use
28
- return False
29
-
30
-
31
- def sweep_port(port):
32
- """
33
- Sweep all processes found listening on a given port.
34
-
35
- Args:
36
- port (int): The port number.
37
-
38
- Returns:
39
- int: Number of processes swept (terminated).
40
- """
41
- try:
42
- # Use lsof to find the processes using the port
43
- result = subprocess.run(
44
- ["lsof", "-i", f":{port}"],
45
- capture_output=True,
46
- text=True,
47
- check=True,
48
- )
49
-
50
- # Parse the output
51
- lines = result.stdout.strip().split("\n")
52
- if len(lines) <= 1:
53
- # No process is using the port
54
- return 0
55
-
56
- # Iterate over each line (excluding the header) and kill each process
57
- killed_count = 0
58
- for line in lines[1:]:
59
- parts = line.split()
60
- if len(parts) > 1:
61
- pid = parts[1]
62
-
63
- # Kill the process using the PID
64
- subprocess.run(["kill", "-9", pid], check=False)
65
- killed_count += 1
66
-
67
- if not is_port_available(port):
68
- logger.warning(
69
- f"Port {port} is still in use after killing processes.",
70
- )
71
-
72
- return True
73
-
74
- except Exception as e:
75
- logger.error(
76
- f"An error occurred while killing processes on port {port}: {e}",
77
- )
78
- return False