agentscope-runtime 0.2.0b1__py3-none-any.whl → 1.0.0__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 (185) hide show
  1. agentscope_runtime/adapters/__init__.py +0 -0
  2. agentscope_runtime/adapters/agentscope/__init__.py +0 -0
  3. agentscope_runtime/adapters/agentscope/long_term_memory/__init__.py +6 -0
  4. agentscope_runtime/adapters/agentscope/long_term_memory/_long_term_memory_adapter.py +258 -0
  5. agentscope_runtime/adapters/agentscope/memory/__init__.py +6 -0
  6. agentscope_runtime/adapters/agentscope/memory/_memory_adapter.py +152 -0
  7. agentscope_runtime/adapters/agentscope/message.py +535 -0
  8. agentscope_runtime/adapters/agentscope/stream.py +506 -0
  9. agentscope_runtime/adapters/agentscope/tool/__init__.py +9 -0
  10. agentscope_runtime/adapters/agentscope/tool/sandbox_tool.py +69 -0
  11. agentscope_runtime/adapters/agentscope/tool/tool.py +233 -0
  12. agentscope_runtime/adapters/autogen/__init__.py +0 -0
  13. agentscope_runtime/adapters/autogen/tool/__init__.py +7 -0
  14. agentscope_runtime/adapters/autogen/tool/tool.py +211 -0
  15. agentscope_runtime/adapters/text/__init__.py +0 -0
  16. agentscope_runtime/adapters/text/stream.py +29 -0
  17. agentscope_runtime/common/collections/redis_mapping.py +4 -1
  18. agentscope_runtime/common/container_clients/fc_client.py +855 -0
  19. agentscope_runtime/common/container_clients/kubernetes_client.py +6 -13
  20. agentscope_runtime/common/utils/__init__.py +0 -0
  21. agentscope_runtime/common/utils/lazy_loader.py +57 -0
  22. agentscope_runtime/engine/__init__.py +25 -18
  23. agentscope_runtime/engine/app/agent_app.py +161 -91
  24. agentscope_runtime/engine/app/base_app.py +4 -118
  25. agentscope_runtime/engine/constant.py +8 -0
  26. agentscope_runtime/engine/deployers/__init__.py +8 -0
  27. agentscope_runtime/engine/deployers/adapter/__init__.py +2 -0
  28. agentscope_runtime/engine/deployers/adapter/a2a/a2a_adapter_utils.py +0 -21
  29. agentscope_runtime/engine/deployers/adapter/a2a/a2a_protocol_adapter.py +28 -9
  30. agentscope_runtime/engine/deployers/adapter/responses/__init__.py +2 -0
  31. agentscope_runtime/engine/deployers/adapter/responses/response_api_adapter_utils.py +5 -2
  32. agentscope_runtime/engine/deployers/adapter/responses/response_api_protocol_adapter.py +1 -1
  33. agentscope_runtime/engine/deployers/agentrun_deployer.py +2541 -0
  34. agentscope_runtime/engine/deployers/cli_fc_deploy.py +1 -1
  35. agentscope_runtime/engine/deployers/kubernetes_deployer.py +9 -21
  36. agentscope_runtime/engine/deployers/local_deployer.py +47 -74
  37. agentscope_runtime/engine/deployers/modelstudio_deployer.py +216 -50
  38. agentscope_runtime/engine/deployers/utils/app_runner_utils.py +29 -0
  39. agentscope_runtime/engine/deployers/utils/detached_app.py +510 -0
  40. agentscope_runtime/engine/deployers/utils/docker_image_utils/__init__.py +1 -1
  41. agentscope_runtime/engine/deployers/utils/docker_image_utils/dockerfile_generator.py +1 -1
  42. agentscope_runtime/engine/deployers/utils/docker_image_utils/{runner_image_factory.py → image_factory.py} +121 -61
  43. agentscope_runtime/engine/deployers/utils/package.py +693 -0
  44. agentscope_runtime/engine/deployers/utils/service_utils/__init__.py +0 -5
  45. agentscope_runtime/engine/deployers/utils/service_utils/fastapi_factory.py +301 -282
  46. agentscope_runtime/engine/deployers/utils/service_utils/fastapi_templates.py +2 -4
  47. agentscope_runtime/engine/deployers/utils/service_utils/process_manager.py +23 -1
  48. agentscope_runtime/engine/deployers/utils/templates/app_main.py.j2 +84 -0
  49. agentscope_runtime/engine/deployers/utils/templates/runner_main.py.j2 +95 -0
  50. agentscope_runtime/engine/deployers/utils/{service_utils → templates}/standalone_main.py.j2 +0 -45
  51. agentscope_runtime/engine/deployers/utils/wheel_packager.py +119 -18
  52. agentscope_runtime/engine/helpers/runner.py +40 -0
  53. agentscope_runtime/engine/runner.py +171 -130
  54. agentscope_runtime/engine/schemas/agent_schemas.py +114 -3
  55. agentscope_runtime/engine/schemas/modelstudio_llm.py +4 -2
  56. agentscope_runtime/engine/schemas/oai_llm.py +23 -23
  57. agentscope_runtime/engine/schemas/response_api.py +65 -0
  58. agentscope_runtime/engine/schemas/session.py +24 -0
  59. agentscope_runtime/engine/services/__init__.py +0 -9
  60. agentscope_runtime/engine/services/agent_state/__init__.py +16 -0
  61. agentscope_runtime/engine/services/agent_state/redis_state_service.py +113 -0
  62. agentscope_runtime/engine/services/agent_state/state_service.py +179 -0
  63. agentscope_runtime/engine/services/memory/__init__.py +24 -0
  64. agentscope_runtime/engine/services/{mem0_memory_service.py → memory/mem0_memory_service.py} +17 -13
  65. agentscope_runtime/engine/services/{memory_service.py → memory/memory_service.py} +28 -7
  66. agentscope_runtime/engine/services/{redis_memory_service.py → memory/redis_memory_service.py} +1 -1
  67. agentscope_runtime/engine/services/{reme_personal_memory_service.py → memory/reme_personal_memory_service.py} +9 -6
  68. agentscope_runtime/engine/services/{reme_task_memory_service.py → memory/reme_task_memory_service.py} +2 -2
  69. agentscope_runtime/engine/services/{tablestore_memory_service.py → memory/tablestore_memory_service.py} +16 -19
  70. agentscope_runtime/engine/services/sandbox/__init__.py +13 -0
  71. agentscope_runtime/engine/services/{sandbox_service.py → sandbox/sandbox_service.py} +86 -71
  72. agentscope_runtime/engine/services/session_history/__init__.py +23 -0
  73. agentscope_runtime/engine/services/{redis_session_history_service.py → session_history/redis_session_history_service.py} +3 -2
  74. agentscope_runtime/engine/services/{session_history_service.py → session_history/session_history_service.py} +44 -34
  75. agentscope_runtime/engine/services/{tablestore_session_history_service.py → session_history/tablestore_session_history_service.py} +14 -19
  76. agentscope_runtime/engine/services/utils/tablestore_service_utils.py +2 -2
  77. agentscope_runtime/engine/tracing/base.py +10 -9
  78. agentscope_runtime/engine/tracing/message_util.py +1 -1
  79. agentscope_runtime/engine/tracing/tracing_util.py +7 -2
  80. agentscope_runtime/engine/tracing/wrapper.py +49 -31
  81. agentscope_runtime/sandbox/__init__.py +10 -2
  82. agentscope_runtime/sandbox/box/agentbay/__init__.py +4 -0
  83. agentscope_runtime/sandbox/box/agentbay/agentbay_sandbox.py +559 -0
  84. agentscope_runtime/sandbox/box/base/base_sandbox.py +12 -0
  85. agentscope_runtime/sandbox/box/browser/browser_sandbox.py +115 -11
  86. agentscope_runtime/sandbox/box/cloud/__init__.py +4 -0
  87. agentscope_runtime/sandbox/box/cloud/cloud_sandbox.py +254 -0
  88. agentscope_runtime/sandbox/box/filesystem/filesystem_sandbox.py +66 -0
  89. agentscope_runtime/sandbox/box/gui/gui_sandbox.py +42 -0
  90. agentscope_runtime/sandbox/box/mobile/__init__.py +4 -0
  91. agentscope_runtime/sandbox/box/mobile/box/__init__.py +0 -0
  92. agentscope_runtime/sandbox/box/mobile/mobile_sandbox.py +216 -0
  93. agentscope_runtime/sandbox/box/training_box/training_box.py +2 -44
  94. agentscope_runtime/sandbox/client/http_client.py +1 -0
  95. agentscope_runtime/sandbox/enums.py +2 -1
  96. agentscope_runtime/sandbox/manager/sandbox_manager.py +15 -2
  97. agentscope_runtime/sandbox/manager/server/app.py +12 -0
  98. agentscope_runtime/sandbox/manager/server/config.py +19 -0
  99. agentscope_runtime/sandbox/model/manager_config.py +79 -2
  100. agentscope_runtime/sandbox/utils.py +0 -18
  101. agentscope_runtime/tools/RAGs/__init__.py +0 -0
  102. agentscope_runtime/tools/RAGs/modelstudio_rag.py +377 -0
  103. agentscope_runtime/tools/RAGs/modelstudio_rag_lite.py +219 -0
  104. agentscope_runtime/tools/__init__.py +119 -0
  105. agentscope_runtime/tools/_constants.py +18 -0
  106. agentscope_runtime/tools/alipay/__init__.py +4 -0
  107. agentscope_runtime/tools/alipay/base.py +334 -0
  108. agentscope_runtime/tools/alipay/payment.py +835 -0
  109. agentscope_runtime/tools/alipay/subscribe.py +551 -0
  110. agentscope_runtime/tools/base.py +264 -0
  111. agentscope_runtime/tools/cli/__init__.py +0 -0
  112. agentscope_runtime/tools/cli/modelstudio_mcp_server.py +78 -0
  113. agentscope_runtime/tools/generations/__init__.py +75 -0
  114. agentscope_runtime/tools/generations/async_image_to_video.py +350 -0
  115. agentscope_runtime/tools/generations/async_image_to_video_wan25.py +366 -0
  116. agentscope_runtime/tools/generations/async_speech_to_video.py +422 -0
  117. agentscope_runtime/tools/generations/async_text_to_video.py +320 -0
  118. agentscope_runtime/tools/generations/async_text_to_video_wan25.py +334 -0
  119. agentscope_runtime/tools/generations/image_edit.py +208 -0
  120. agentscope_runtime/tools/generations/image_edit_wan25.py +193 -0
  121. agentscope_runtime/tools/generations/image_generation.py +202 -0
  122. agentscope_runtime/tools/generations/image_generation_wan25.py +201 -0
  123. agentscope_runtime/tools/generations/image_style_repaint.py +208 -0
  124. agentscope_runtime/tools/generations/image_to_video.py +233 -0
  125. agentscope_runtime/tools/generations/qwen_image_edit.py +205 -0
  126. agentscope_runtime/tools/generations/qwen_image_generation.py +214 -0
  127. agentscope_runtime/tools/generations/qwen_text_to_speech.py +154 -0
  128. agentscope_runtime/tools/generations/speech_to_text.py +260 -0
  129. agentscope_runtime/tools/generations/speech_to_video.py +314 -0
  130. agentscope_runtime/tools/generations/text_to_video.py +221 -0
  131. agentscope_runtime/tools/mcp_wrapper.py +215 -0
  132. agentscope_runtime/tools/realtime_clients/__init__.py +13 -0
  133. agentscope_runtime/tools/realtime_clients/asr_client.py +27 -0
  134. agentscope_runtime/tools/realtime_clients/azure_asr_client.py +195 -0
  135. agentscope_runtime/tools/realtime_clients/azure_tts_client.py +383 -0
  136. agentscope_runtime/tools/realtime_clients/modelstudio_asr_client.py +151 -0
  137. agentscope_runtime/tools/realtime_clients/modelstudio_tts_client.py +199 -0
  138. agentscope_runtime/tools/realtime_clients/realtime_tool.py +55 -0
  139. agentscope_runtime/tools/realtime_clients/tts_client.py +33 -0
  140. agentscope_runtime/tools/searches/__init__.py +3 -0
  141. agentscope_runtime/tools/searches/modelstudio_search.py +877 -0
  142. agentscope_runtime/tools/searches/modelstudio_search_lite.py +310 -0
  143. agentscope_runtime/tools/utils/__init__.py +0 -0
  144. agentscope_runtime/tools/utils/api_key_util.py +45 -0
  145. agentscope_runtime/tools/utils/crypto_utils.py +99 -0
  146. agentscope_runtime/tools/utils/mcp_util.py +35 -0
  147. agentscope_runtime/version.py +1 -1
  148. {agentscope_runtime-0.2.0b1.dist-info → agentscope_runtime-1.0.0.dist-info}/METADATA +244 -168
  149. agentscope_runtime-1.0.0.dist-info/RECORD +240 -0
  150. {agentscope_runtime-0.2.0b1.dist-info → agentscope_runtime-1.0.0.dist-info}/entry_points.txt +1 -0
  151. agentscope_runtime/engine/agents/__init__.py +0 -2
  152. agentscope_runtime/engine/agents/agentscope_agent.py +0 -488
  153. agentscope_runtime/engine/agents/agno_agent.py +0 -222
  154. agentscope_runtime/engine/agents/autogen_agent.py +0 -250
  155. agentscope_runtime/engine/agents/base_agent.py +0 -29
  156. agentscope_runtime/engine/agents/langgraph_agent.py +0 -59
  157. agentscope_runtime/engine/agents/utils.py +0 -53
  158. agentscope_runtime/engine/deployers/utils/package_project_utils.py +0 -1163
  159. agentscope_runtime/engine/deployers/utils/service_utils/service_config.py +0 -75
  160. agentscope_runtime/engine/deployers/utils/service_utils/service_factory.py +0 -220
  161. agentscope_runtime/engine/helpers/helper.py +0 -179
  162. agentscope_runtime/engine/schemas/context.py +0 -54
  163. agentscope_runtime/engine/services/context_manager.py +0 -164
  164. agentscope_runtime/engine/services/environment_manager.py +0 -50
  165. agentscope_runtime/engine/services/manager.py +0 -174
  166. agentscope_runtime/engine/services/rag_service.py +0 -195
  167. agentscope_runtime/engine/services/tablestore_rag_service.py +0 -143
  168. agentscope_runtime/sandbox/tools/__init__.py +0 -12
  169. agentscope_runtime/sandbox/tools/base/__init__.py +0 -8
  170. agentscope_runtime/sandbox/tools/base/tool.py +0 -52
  171. agentscope_runtime/sandbox/tools/browser/__init__.py +0 -57
  172. agentscope_runtime/sandbox/tools/browser/tool.py +0 -597
  173. agentscope_runtime/sandbox/tools/filesystem/__init__.py +0 -32
  174. agentscope_runtime/sandbox/tools/filesystem/tool.py +0 -319
  175. agentscope_runtime/sandbox/tools/function_tool.py +0 -321
  176. agentscope_runtime/sandbox/tools/gui/__init__.py +0 -7
  177. agentscope_runtime/sandbox/tools/gui/tool.py +0 -77
  178. agentscope_runtime/sandbox/tools/mcp_tool.py +0 -195
  179. agentscope_runtime/sandbox/tools/sandbox_tool.py +0 -104
  180. agentscope_runtime/sandbox/tools/tool.py +0 -238
  181. agentscope_runtime/sandbox/tools/utils.py +0 -68
  182. agentscope_runtime-0.2.0b1.dist-info/RECORD +0 -183
  183. {agentscope_runtime-0.2.0b1.dist-info → agentscope_runtime-1.0.0.dist-info}/WHEEL +0 -0
  184. {agentscope_runtime-0.2.0b1.dist-info → agentscope_runtime-1.0.0.dist-info}/licenses/LICENSE +0 -0
  185. {agentscope_runtime-0.2.0b1.dist-info → agentscope_runtime-1.0.0.dist-info}/top_level.txt +0 -0
@@ -2,34 +2,27 @@
2
2
  # pylint:disable=protected-access
3
3
 
4
4
  import hashlib
5
+ import json
5
6
  import logging
6
7
  import os
7
8
  from typing import Optional, List, Dict, Union
8
9
 
9
10
  from pydantic import BaseModel, Field
10
11
 
11
- from agentscope_runtime.engine.runner import Runner
12
-
13
- # from .package_project import PackageConfig, package_project, create_tar_gz
14
- from ..package_project_utils import (
15
- PackageConfig,
16
- package_project,
17
- )
18
- from ..service_utils import (
19
- ServicesConfig,
20
- )
21
- from .dockerfile_generator import DockerfileGenerator, DockerfileConfig
22
12
  from .docker_image_builder import (
23
13
  DockerImageBuilder,
24
14
  BuildConfig,
25
15
  RegistryConfig,
26
16
  )
27
-
17
+ from .dockerfile_generator import DockerfileGenerator, DockerfileConfig
18
+ from ..detached_app import build_detached_app
19
+ from ..package import DEFAULT_ENTRYPOINT_FILE
20
+ from .....engine.runner import Runner
28
21
 
29
22
  logger = logging.getLogger(__name__)
30
23
 
31
24
 
32
- class RunnerImageConfig(BaseModel):
25
+ class ImageConfig(BaseModel):
33
26
  """Complete configuration for building a Runner image"""
34
27
 
35
28
  # Package configuration
@@ -38,7 +31,6 @@ class RunnerImageConfig(BaseModel):
38
31
  build_context_dir: str = "/tmp/k8s_build"
39
32
  endpoint_path: str = "/process"
40
33
  protocol_adapters: Optional[List] = None # New: protocol adapters
41
- services_config: Optional[ServicesConfig] = None
42
34
  custom_endpoints: Optional[
43
35
  List[Dict]
44
36
  ] = None # New: custom endpoints configuration
@@ -49,6 +41,13 @@ class RunnerImageConfig(BaseModel):
49
41
  env_vars: Dict[str, str] = Field(default_factory=lambda: {})
50
42
  startup_command: Optional[str] = None
51
43
 
44
+ # Runtime configuration
45
+ host: str = "0.0.0.0" # Container-friendly default
46
+ embed_task_processor: bool = False
47
+ extra_startup_args: Dict[str, Union[str, int, bool]] = Field(
48
+ default_factory=dict,
49
+ )
50
+
52
51
  # Build configuration
53
52
  no_cache: bool = False
54
53
  quiet: bool = False
@@ -64,7 +63,7 @@ class RunnerImageConfig(BaseModel):
64
63
  push_to_registry: bool = False
65
64
 
66
65
 
67
- class RunnerImageFactory:
66
+ class ImageFactory:
68
67
  """
69
68
  Factory class for building Runner Docker images.
70
69
  Coordinates ProjectPackager, DockerfileGenerator, and DockerImageBuilder.
@@ -79,15 +78,13 @@ class RunnerImageFactory:
79
78
 
80
79
  @staticmethod
81
80
  def _generate_image_name(
82
- runner: Runner,
83
- config: RunnerImageConfig,
81
+ config: ImageConfig,
84
82
  ) -> str:
85
83
  """Generate a unique image tag based on runner content and config"""
86
84
  # Create hash based on runner and configuration
87
85
  if config.image_name:
88
86
  return config.image_name
89
87
  hash_content = (
90
- f"{str(runner._agent.name)}"
91
88
  f"{str(config.requirements)}"
92
89
  f"{str(config.extra_files)}"
93
90
  f"{config.base_image}"
@@ -95,19 +92,7 @@ class RunnerImageFactory:
95
92
  )
96
93
  content_hash = hashlib.md5(hash_content.encode()).hexdigest()[:8]
97
94
 
98
- return f"agent-{content_hash}"
99
-
100
- @staticmethod
101
- def _validate_runner(runner: Runner):
102
- """Validate runner object"""
103
- if not hasattr(runner, "_agent") or runner._agent is None:
104
- raise ValueError("Runner must have a valid agent")
105
-
106
- # Log warnings for missing components
107
- if not hasattr(runner, "_environment_manager"):
108
- logger.warning("Runner missing _environment_manager")
109
- if not hasattr(runner, "_context_manager"):
110
- logger.warning("Runner missing _context_manager")
95
+ return f"agentscope-runtime-{content_hash}"
111
96
 
112
97
  @staticmethod
113
98
  def _validate_requirements(
@@ -131,10 +116,61 @@ class RunnerImageFactory:
131
116
  f"Invalid requirements type: {type(requirements)}",
132
117
  )
133
118
 
134
- def _build_runner_image(
119
+ @staticmethod
120
+ def _generate_startup_command(
121
+ entrypoint_file: str,
122
+ config: ImageConfig,
123
+ ) -> str:
124
+ """
125
+ Generate a comprehensive startup command for the containerized
126
+ application.
127
+
128
+ This method creates a startup command that includes all necessary
129
+ parameters for running the AgentScope application in a container
130
+ environment, similar to what's used in the app_main.py.j2 template.
131
+
132
+ Args:
133
+ entrypoint_file: Project entrypoint details
134
+ config: ImageConfig with runtime settings
135
+
136
+ Returns:
137
+ str: Complete startup command with all parameters
138
+ """
139
+ # If a custom startup command is provided, use it directly
140
+ if config.startup_command:
141
+ return config.startup_command
142
+
143
+ # Start with basic python command
144
+ cmd_parts = ["python", entrypoint_file]
145
+
146
+ # Add host configuration
147
+ cmd_parts.extend(["--host", config.host])
148
+
149
+ # Add port configuration
150
+ cmd_parts.extend(["--port", str(config.port)])
151
+
152
+ # Add embed-task-processor flag if enabled
153
+ if config.embed_task_processor:
154
+ cmd_parts.append("--embed-task-processor")
155
+
156
+ # Add any extra startup arguments
157
+ for arg_name, arg_value in config.extra_startup_args.items():
158
+ # Convert underscore to dash for CLI compatibility
159
+ cli_arg = f"--{arg_name.replace('_', '-')}"
160
+
161
+ if isinstance(arg_value, bool):
162
+ if arg_value: # Only add flag if True
163
+ cmd_parts.append(cli_arg)
164
+ else:
165
+ cmd_parts.extend([cli_arg, str(arg_value)])
166
+
167
+ return json.dumps(cmd_parts)
168
+
169
+ def _build_image(
135
170
  self,
136
- runner: Runner,
137
- config: RunnerImageConfig,
171
+ app,
172
+ runner: Optional[Runner],
173
+ config: ImageConfig,
138
174
  ) -> str:
139
175
  """
140
176
  Build a complete Docker image for the Runner.
@@ -157,18 +193,22 @@ class RunnerImageFactory:
157
193
  RuntimeError: If any step of the build process fails
158
194
  """
159
195
  try:
160
- # Validation
161
- self._validate_runner(runner)
162
-
163
196
  logger.info(f"Building Runner image: {config.image_tag}")
164
197
 
165
198
  # Generate Dockerfile
166
199
  logger.info("Generating Dockerfile...")
200
+
201
+ # Generate comprehensive startup command
202
+ startup_command = self._generate_startup_command(
203
+ entrypoint_file=DEFAULT_ENTRYPOINT_FILE,
204
+ config=config,
205
+ )
206
+
167
207
  dockerfile_config = DockerfileConfig(
168
208
  base_image=config.base_image,
169
209
  port=config.port,
170
210
  env_vars=config.env_vars,
171
- startup_command=config.startup_command,
211
+ startup_command=startup_command,
172
212
  )
173
213
 
174
214
  dockerfile_path = self.dockerfile_generator.create_dockerfile(
@@ -176,23 +216,18 @@ class RunnerImageFactory:
176
216
  )
177
217
  logger.info(f"Dockerfile created: {dockerfile_path}")
178
218
 
179
- # Package the project
219
+ # Package the project using detached bundle logic
180
220
  logger.info("Packaging Runner project...")
181
- project_dir, is_updated = package_project(
182
- agent=runner._agent,
183
- config=PackageConfig(
184
- requirements=config.requirements,
185
- extra_packages=config.extra_packages,
186
- output_dir=config.build_context_dir,
187
- endpoint_path=config.endpoint_path,
188
- protocol_adapters=config.protocol_adapters,
189
- services_config=config.services_config,
190
- custom_endpoints=config.custom_endpoints,
191
- ),
221
+
222
+ project_dir, _ = build_detached_app(
223
+ app=app,
224
+ runner=runner,
225
+ requirements=config.requirements,
226
+ extra_packages=config.extra_packages,
227
+ output_dir=config.build_context_dir,
192
228
  dockerfile_path=dockerfile_path,
193
- # caller_depth is no longer needed due to automatic
194
- # stack search
195
229
  )
230
+ is_updated = True
196
231
  logger.info(f"Project packaged: {project_dir}")
197
232
 
198
233
  # Build Docker image
@@ -209,7 +244,7 @@ class RunnerImageFactory:
209
244
  # Build and push to registry
210
245
  full_image_name = self.image_builder.build_and_push(
211
246
  build_context=project_dir,
212
- image_name=self._generate_image_name(runner, config),
247
+ image_name=self._generate_image_name(config),
213
248
  image_tag=config.image_tag,
214
249
  build_config=build_config,
215
250
  registry_config=config.registry_config,
@@ -220,7 +255,7 @@ class RunnerImageFactory:
220
255
  # Just build locally
221
256
  full_image_name = self.image_builder.build_image(
222
257
  build_context=project_dir,
223
- image_name=self._generate_image_name(runner, config),
258
+ image_name=self._generate_image_name(config),
224
259
  image_tag=config.image_tag,
225
260
  config=build_config,
226
261
  source_updated=is_updated,
@@ -237,9 +272,10 @@ class RunnerImageFactory:
237
272
  # Cleanup temporary resources
238
273
  self.cleanup()
239
274
 
240
- def build_runner_image(
275
+ def build_image(
241
276
  self,
242
- runner: Runner,
277
+ app=None,
278
+ runner: Optional[Runner] = None,
243
279
  requirements: Optional[Union[str, List[str]]] = None,
244
280
  extra_packages: Optional[List[str]] = None,
245
281
  base_image: str = "python:3.10-slim-bookworm",
@@ -247,17 +283,21 @@ class RunnerImageFactory:
247
283
  image_tag: Optional[str] = None,
248
284
  registry_config: Optional[RegistryConfig] = None,
249
285
  push_to_registry: bool = False,
250
- services_config: Optional[ServicesConfig] = None,
251
286
  protocol_adapters: Optional[List] = None, # New: protocol adapters
252
287
  custom_endpoints: Optional[
253
288
  List[Dict]
254
289
  ] = None, # New parameter for custom endpoints
290
+ # New runtime configuration parameters
291
+ host: str = "0.0.0.0",
292
+ embed_task_processor: bool = True,
293
+ extra_startup_args: Optional[Dict[str, Union[str, int, bool]]] = None,
255
294
  **kwargs,
256
295
  ) -> str:
257
296
  """
258
297
  Simplified interface for building Runner images.
259
298
 
260
299
  Args:
300
+ app: agent app object
261
301
  runner: Runner object
262
302
  requirements: Python requirements
263
303
  extra_packages: Additional files to include
@@ -266,15 +306,33 @@ class RunnerImageFactory:
266
306
  image_tag: Optional image tag
267
307
  registry_config: Optional registry config
268
308
  push_to_registry: Whether to push to registry
269
- services_config: Optional services config
270
309
  protocol_adapters: Protocol adapters
271
310
  custom_endpoints: Custom endpoints from agent app
311
+ host: Host to bind to (default: 0.0.0.0 for containers)
312
+ embed_task_processor: Whether to embed task processor
313
+ extra_startup_args: Additional startup arguments
272
314
  **kwargs: Additional configuration options
273
315
 
274
316
  Returns:
275
317
  str: Built image name
276
318
  """
277
- config = RunnerImageConfig(
319
+ if app is not None:
320
+ custom_endpoints = custom_endpoints or getattr(
321
+ app,
322
+ "custom_endpoints",
323
+ None,
324
+ )
325
+ protocol_adapters = protocol_adapters or getattr(
326
+ app,
327
+ "protocol_adapters",
328
+ None,
329
+ )
330
+ kwargs.setdefault(
331
+ "endpoint_path",
332
+ getattr(app, "endpoint_path", "/process"),
333
+ )
334
+
335
+ config = ImageConfig(
278
336
  requirements=self._validate_requirements(requirements),
279
337
  extra_packages=extra_packages or [],
280
338
  base_image=base_image,
@@ -283,12 +341,14 @@ class RunnerImageFactory:
283
341
  registry_config=registry_config,
284
342
  push_to_registry=push_to_registry,
285
343
  protocol_adapters=protocol_adapters,
286
- services_config=services_config,
287
344
  custom_endpoints=custom_endpoints,
345
+ host=host,
346
+ embed_task_processor=embed_task_processor,
347
+ extra_startup_args=extra_startup_args or {},
288
348
  **kwargs,
289
349
  )
290
350
 
291
- return self._build_runner_image(runner, config)
351
+ return self._build_image(app, runner, config)
292
352
 
293
353
  def cleanup(self):
294
354
  """Clean up all temporary resources"""