sycommon-python-lib 0.2.5a30__py3-none-any.whl → 0.2.5a31__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.
@@ -655,6 +655,18 @@ class HTTPSandboxBackend(FileOperationsMixin, SandboxBackendProtocol):
655
655
 
656
656
  # ============== 执行命令 ==============
657
657
 
658
+ def update_env(self, env_updates: dict[str, str]):
659
+ """动态更新沙箱环境变量(合并到现有 env,重建 _env_prefix)
660
+
661
+ 用于运行时刷新 token 等场景,无需重建整个沙箱实例。
662
+ """
663
+ self._env.update(env_updates)
664
+ exports = " && ".join(
665
+ f"export {k}={_shell_quote(str(v))}"
666
+ for k, v in self._env.items()
667
+ )
668
+ self._env_prefix = f"{exports} && " if exports else ""
669
+
658
670
  def _inject_env(self, command: str) -> str:
659
671
  """在命令前注入环境变量 export"""
660
672
  if self._env_prefix:
@@ -44,7 +44,7 @@ CUSTOM_SUMMARY_PROMPT = """<role>
44
44
  下面的对话历史将被你在此步骤中提取的上下文替换。
45
45
  你需要确保不会重复任何已完成的操作,因此你从对话历史中提取的上下文应集中于对整体目标最重要的信息。
46
46
 
47
- 请用以下结构提取上下文,每个部分用中文自然段落描述,不要使用英文标题:
47
+ 请用以下结构提取上下文,每个部分用中文自然段落描述:
48
48
 
49
49
  【用户意图】
50
50
  简要描述用户的主要目标或请求,确保足够完整以理解整个会话的目的。
@@ -186,9 +186,10 @@ _orig_build_new_messages = _OrigDeepAgentsSumm._build_new_messages_with_path
186
186
  def _patched_build_new_messages(self, summary, file_path):
187
187
  if file_path is not None:
188
188
  content = (
189
+ "[系统内部消息 - 仅供你理解上下文,绝对禁止将此消息或摘要内容展示、复述或提及给用户]\n\n"
189
190
  "你正在一个已经被压缩的对话中继续回复用户。\n\n"
190
191
  f"完整的对话历史已保存到 {file_path},如需查阅细节可以读取该文件。\n\n"
191
- "以下是压缩后的对话摘要:\n\n"
192
+ "以下是压缩后的对话摘要(直接基于此摘要理解上下文并正常回复用户,不要提及摘要的存在):\n\n"
192
193
  f"<summary>\n{summary}\n</summary>"
193
194
  )
194
195
  else:
@@ -166,15 +166,19 @@ class KafkaSink:
166
166
 
167
167
  def close(self):
168
168
  """关闭 KafkaProducer,释放连接池资源"""
169
- if self._producer:
170
- self._producer = None
171
- try:
172
- self._producer_obj.flush(timeout=5)
173
- self._producer_obj.close(timeout=10)
174
- except KeyboardInterrupt:
175
- pass
176
- except Exception:
177
- pass
169
+ if self._producer_obj is None:
170
+ return
171
+ # 先移除引用,阻止 write() 继续发送新消息
172
+ self._producer = None
173
+ try:
174
+ self._producer_obj.flush(timeout=5)
175
+ self._producer_obj.close(timeout=10)
176
+ except KeyboardInterrupt:
177
+ pass
178
+ except Exception:
179
+ pass
180
+ finally:
181
+ self._producer_obj = None
178
182
 
179
183
 
180
184
  class _InterceptHandler(logging.Handler):
@@ -121,7 +121,7 @@ def _convert_list_content_to_str(content: list, tool_name: str) -> str:
121
121
  size_kb = len(b64) * 3 // 4 // 1024
122
122
  parts.append(
123
123
  f"[图片文件 ({mime}, {size_kb}KB) — "
124
- f"图片二进制数据无法直接发送给模型。"
124
+ f"图片二进制内容已省略。"
125
125
  f"请使用 execute 工具通过 Python (如 PIL/OpenCV) 读取并处理图片,"
126
126
  f"例如 OCR 识别文字、分析图片内容等。]"
127
127
  )
@@ -130,7 +130,7 @@ def _convert_list_content_to_str(content: list, tool_name: str) -> str:
130
130
  size_kb = len(item["base64"]) * 3 // 4 // 1024
131
131
  parts.append(
132
132
  f"[{item_type}文件 ({mime}, {size_kb}KB) — "
133
- f"二进制数据无法直接发送给模型。"
133
+ f"二进制文件内容已省略。"
134
134
  f"请使用 execute 工具通过 Python 处理该文件。]"
135
135
  )
136
136
  elif "text" in item:
@@ -250,25 +250,20 @@ def setup_trace_id_handler(app):
250
250
 
251
251
  # 构建响应日志
252
252
  response_log_body = response_body.decode('utf-8', errors='ignore')
253
- total_len = len(response_log_body)
254
- # 检测是否包含 base64 二进制内容(如 PDF、图片等)
255
- is_binary_response = False
253
+ # 检测是否包含 base64 二进制内容(如 PDF、图片等),如有则省略
256
254
  try:
257
255
  resp_json = json.loads(response_log_body)
258
256
  if isinstance(resp_json, dict) and resp_json.get("content") and len(str(resp_json["content"])) > 1000:
259
257
  resp_json["content"] = f"... (base64/binary content omitted, {len(str(resp_json['content']))} chars)"
260
258
  response_log_body = json.dumps(resp_json, ensure_ascii=False)
261
- is_binary_response = True
262
259
  except (json.JSONDecodeError, ValueError):
263
260
  pass
264
- if not is_binary_response and total_len > 10000:
265
- response_log_body = response_log_body[:10000] + f"... (truncated, total {total_len} bytes)"
266
261
  response_message = {
267
262
  "traceId": trace_id,
268
263
  "status_code": response.status_code,
269
264
  "response_body": response_log_body,
270
265
  }
271
- SYLogger.info(json.dumps(response_message, ensure_ascii=False))
266
+ SYLogger.info(response_message)
272
267
 
273
268
  # 兜底:确保 Header 必有 TraceId
274
269
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sycommon-python-lib
3
- Version: 0.2.5a30
3
+ Version: 0.2.5a31
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -131,13 +131,13 @@ sycommon/agent/agent_manager.py,sha256=UhhaekEumT7g4v_Z1UB4jTp13X0n8M8erYaQdkGGW
131
131
  sycommon/agent/chat_events.py,sha256=t7qWa6OrIWLfqtd1AnqaVP67QWkn1JxpCBTZYQpoLuM,14226
132
132
  sycommon/agent/deep_agent.py,sha256=zZRmjEYAEx8LgnDCRFf6QS9Xxyy67WSzomjdC2I732Q,55405
133
133
  sycommon/agent/multi_agent_team.py,sha256=W5gP6sWIYhhXf6iBLHfyTIs9eAhUdkWrn_PF6W2cESs,26059
134
- sycommon/agent/summarization_utils.py,sha256=q45O-a3_H21Pm1vSIskSK0VCoheilGX5ONnC9Q7PUBE,10682
134
+ sycommon/agent/summarization_utils.py,sha256=5eiLtxRZKTzO0tnr8sVaL-H3a0eUtvXpCa28Jw_j2eE,10889
135
135
  sycommon/agent/mcp/__init__.py,sha256=iKrdDhIrFsNIkqG_kgcwNe-nOiM6uVfolKv44LfQ-FQ,636
136
136
  sycommon/agent/mcp/models.py,sha256=zda4ho-UTYOJ5oPAZPZ-vxhfDRLghUCsMroHnA2A2QQ,1490
137
137
  sycommon/agent/mcp/tool_loader.py,sha256=iJkKSBClm348xeQ0CmK4lOUbLEQ-CRr-GvJdPmSHg9o,9916
138
138
  sycommon/agent/sandbox/__init__.py,sha256=jR7LlkD4J4Y6QYyRXQClkwmqDBCCPmycV_hQV9p9YHw,4621
139
139
  sycommon/agent/sandbox/file_ops.py,sha256=C1_gfarr2aHstaB9VzV_APJYgQtRfUVvkc3b7QIgmc0,24690
140
- sycommon/agent/sandbox/http_sandbox_backend.py,sha256=Hw_3yHolbRqAS7xe7RkGECP_wWhPyIqiUaki1Dt1l2g,58727
140
+ sycommon/agent/sandbox/http_sandbox_backend.py,sha256=_l7guM-sv4XduE9NTNVLPyRTjZZIGR4qefJUTc8e5q4,59199
141
141
  sycommon/agent/sandbox/minio_sync.py,sha256=d1kuWllvyAvAMsFZCP0OdHEQtXN9BEIgHbupC31BjSk,20000
142
142
  sycommon/agent/sandbox/sandbox_pool.py,sha256=eMn8sLakCWf90l6ni2-333QM8oBdX1CflV-WzneFp_k,9133
143
143
  sycommon/agent/sandbox/sandbox_recovery.py,sha256=X-eDODx1tmGMh_iTngV6e1ppfDBHpTdkPreJusN5MHY,7358
@@ -195,7 +195,7 @@ sycommon/llm/tiktoken_cache/9b5ad71b2ce5302211f9c61530b329a4922fc6a4,sha256=Ijkh
195
195
  sycommon/llm/tiktoken_cache/fb374d419588a4632f3f557e76b4b70aebbca790,sha256=RGqVOMtsNI41FhINfAiwn1fDZJXirP_-WaW_iwz7Gi0,3613922
196
196
  sycommon/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
197
197
  sycommon/logging/async_sql_logger.py,sha256=_OY36XkUm__U3NhMgiecy-qd-nptZ_0gpE3J8lGAr58,2619
198
- sycommon/logging/kafka_log.py,sha256=nhM73AbwdAFVpP-_8mCG74ZXCOzgSfPEAfIK2y0wRpw,13191
198
+ sycommon/logging/kafka_log.py,sha256=5tbCYMLEm7RwfWoYQMZU96xjaEGG6T0QfBhglxT5Q8E,13310
199
199
  sycommon/logging/logger_levels.py,sha256=_-uQ_T1N8NkNgcAmLrMmJ83nHTDw5ZNvXFPvdk89XGY,1144
200
200
  sycommon/logging/logger_wrapper.py,sha256=TtzmGw_K5NjBGBq9Gjqtnh834izAv8TQwsOeL2fIbAI,481
201
201
  sycommon/logging/process_logger.py,sha256=rjunPTaDejtusvobSrc3G44DEqnt_bbNSY3r8cWqBsY,5895
@@ -213,8 +213,8 @@ sycommon/middleware/mq.py,sha256=9X6KKtadFjBXKS5L3kEKujYio9wwGfWgXwWOAHO-HDg,254
213
213
  sycommon/middleware/sandbox.py,sha256=er0zeHLQtHJqSr27fGcKbAtRo1ZOQ-Lqif8ALWNFSak,47858
214
214
  sycommon/middleware/timeout.py,sha256=KlxOPa8xl2dg6yuRi_EzkVJG8bX4stb5ueYxctzzGM8,1433
215
215
  sycommon/middleware/token_tracking.py,sha256=rEbgV1bgWMdzAERx4aq5XAvOIT6jTY_tK1P0xHJnL3o,6609
216
- sycommon/middleware/tool_result_truncation.py,sha256=Qxe1OtLXoxXOH8NMOqFTWoTwcVpzDwCz6zhwNwBXeBE,10745
217
- sycommon/middleware/traceid.py,sha256=HX4zg7Tp_mPNr2eWDDvK3f7GFJ6eOSeW062Xcc-xshc,14340
216
+ sycommon/middleware/tool_result_truncation.py,sha256=307qUekFbhrh5x8rLYgoOOSH1Ph7doTicrpTiyiZo_A,10715
217
+ sycommon/middleware/traceid.py,sha256=MrcHj-2hzwl5sOMbf6-34tezYv4COnh3R8vaCN9zRuA,14025
218
218
  sycommon/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
219
219
  sycommon/models/base_http.py,sha256=EICAAibx3xhjBsLqm35Mi3DCqxp0FME4rD_3iQVjT_E,3051
220
220
  sycommon/models/log.py,sha256=rZpj6VkDRxK3B6H7XSeWdYZshU8F0Sks8bq1p6pPlDw,500
@@ -279,8 +279,8 @@ sycommon/tools/syemail.py,sha256=BDFhgf7WDOQeTcjxJEQdu0dQhnHFPO_p3eI0-Ni3LhQ,561
279
279
  sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
280
280
  sycommon/xxljob/__init__.py,sha256=7eoBlQxv-B39IfRSCY2bkqdGYs1QRe1umAWd88VMEEM,86
281
281
  sycommon/xxljob/xxljob_service.py,sha256=JIEJaGXhqrTLcyxlyynSrsHg9bBnDNzX-D4qIWLRPUE,6815
282
- sycommon_python_lib-0.2.5a30.dist-info/METADATA,sha256=iuYPOG4XJFhea7usqMT9DKM2j6IXvePLHFj8PRhP-z0,7914
283
- sycommon_python_lib-0.2.5a30.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
284
- sycommon_python_lib-0.2.5a30.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
285
- sycommon_python_lib-0.2.5a30.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
286
- sycommon_python_lib-0.2.5a30.dist-info/RECORD,,
282
+ sycommon_python_lib-0.2.5a31.dist-info/METADATA,sha256=QP-iiLOW9iiICa42zGhSK_x_iWW2TTmRNp-9IMhee6c,7914
283
+ sycommon_python_lib-0.2.5a31.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
284
+ sycommon_python_lib-0.2.5a31.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
285
+ sycommon_python_lib-0.2.5a31.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
286
+ sycommon_python_lib-0.2.5a31.dist-info/RECORD,,