sycommon-python-lib 0.2.7a14__py3-none-any.whl → 0.2.7a15__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.
- sycommon/agent/deep_agent.py +15 -11
- sycommon/agent/middleware/sensitive_guard.py +9 -9
- {sycommon_python_lib-0.2.7a14.dist-info → sycommon_python_lib-0.2.7a15.dist-info}/METADATA +1 -1
- {sycommon_python_lib-0.2.7a14.dist-info → sycommon_python_lib-0.2.7a15.dist-info}/RECORD +7 -7
- {sycommon_python_lib-0.2.7a14.dist-info → sycommon_python_lib-0.2.7a15.dist-info}/WHEEL +0 -0
- {sycommon_python_lib-0.2.7a14.dist-info → sycommon_python_lib-0.2.7a15.dist-info}/entry_points.txt +0 -0
- {sycommon_python_lib-0.2.7a14.dist-info → sycommon_python_lib-0.2.7a15.dist-info}/top_level.txt +0 -0
sycommon/agent/deep_agent.py
CHANGED
|
@@ -1421,17 +1421,21 @@ async def _sync_skills_to_sandbox(
|
|
|
1421
1421
|
if remote_content and remote_content.file_data:
|
|
1422
1422
|
# FileData 是 TypedDict(dict), 用键访问而非属性
|
|
1423
1423
|
content = remote_content.file_data.get("content", "") or ""
|
|
1424
|
-
#
|
|
1425
|
-
#
|
|
1426
|
-
#
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1424
|
+
# 优先直接解 version(明文小文件最快);
|
|
1425
|
+
# 解不出再兜底解码 base64——沙箱 /read 对大文件(如 skill-creator 的
|
|
1426
|
+
# 34KB SKILL.md)返回 base64, 但 encoding 标志位可能漏标/误标,
|
|
1427
|
+
# 若依赖该标志位,漏标时会因找不到 "version:" 行误判为"无版本"
|
|
1428
|
+
# → 每次新建 Agent 都全量重传。改为「先解 → 解不出再 b64 兜底」,
|
|
1429
|
+
# 不依赖 encoding 字段, 对明文/base64 两种返回都正确。
|
|
1430
|
+
version = _parse_skill_version(content)
|
|
1431
|
+
if version:
|
|
1432
|
+
return version
|
|
1433
|
+
try:
|
|
1434
|
+
import base64 as _b64
|
|
1435
|
+
decoded = _b64.b64decode(content).decode("utf-8", errors="replace")
|
|
1436
|
+
return _parse_skill_version(decoded)
|
|
1437
|
+
except Exception:
|
|
1438
|
+
return ""
|
|
1435
1439
|
except Exception:
|
|
1436
1440
|
pass
|
|
1437
1441
|
return ""
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
共享同一实例,避免敏感数据通过委派链继续流向外部模型。
|
|
11
11
|
|
|
12
12
|
agent 本就是内部模型(model_tier="internal")时短路放行,不检测。
|
|
13
|
-
检测失败 fail-
|
|
13
|
+
检测失败 fail-open(视为不敏感,放行)。
|
|
14
14
|
"""
|
|
15
15
|
import asyncio
|
|
16
16
|
from typing import Any, Awaitable, Callable, List, Optional
|
|
@@ -301,16 +301,14 @@ class SensitiveGuardMiddleware(AgentMiddleware):
|
|
|
301
301
|
return self._internal_raw
|
|
302
302
|
|
|
303
303
|
async def _detect(self, messages: List[BaseMessage]) -> SensitiveCheck:
|
|
304
|
-
"""一次检测:命中即返回 SensitiveCheck。fail-
|
|
304
|
+
"""一次检测:命中即返回 SensitiveCheck。fail-open(识别不出来→视为不敏感放行)。
|
|
305
305
|
|
|
306
306
|
稳定性策略:
|
|
307
307
|
- 检测提示词只描述「判什么敏感」,不要求模型自己格式化输出;
|
|
308
308
|
- 直接用 detector.ainvoke 拿原始文本,本方法用正则提 {…} 再 Pydantic 解析;
|
|
309
309
|
- 单轮、零修正重试,避免 with_structured_output 的解析重试烧 token。
|
|
310
|
-
|
|
310
|
+
识别失败时 fail-open 视为不敏感(默认放行),避免误伤正常请求。
|
|
311
311
|
"""
|
|
312
|
-
import json
|
|
313
|
-
import re
|
|
314
312
|
content = _messages_to_text(messages)
|
|
315
313
|
try:
|
|
316
314
|
detector = await self._get_detector()
|
|
@@ -336,13 +334,15 @@ class SensitiveGuardMiddleware(AgentMiddleware):
|
|
|
336
334
|
text = raw.content if isinstance(raw, BaseMessage) else str(raw)
|
|
337
335
|
check = _parse_detect_json(text)
|
|
338
336
|
if check is None:
|
|
337
|
+
# fail-open:识别不出来默认放行(不阻断/不降级),仅告警便于排查。
|
|
339
338
|
SYLogger.warning(
|
|
340
|
-
f"[SensitiveGuard] 检测无有效JSON(fail-
|
|
341
|
-
return SensitiveCheck(is_sensitive=
|
|
339
|
+
f"[SensitiveGuard] 检测无有效JSON(fail-open→放行): {text[:300]!r}")
|
|
340
|
+
return SensitiveCheck(is_sensitive=False, reason="no_json_in_detect_output")
|
|
342
341
|
return check
|
|
343
342
|
except Exception as e:
|
|
344
|
-
|
|
345
|
-
|
|
343
|
+
# fail-open:检测异常默认放行,避免检测器自身故障拖垮正常对话。
|
|
344
|
+
SYLogger.warning(f"[SensitiveGuard] 检测异常(fail-open→放行): {e}")
|
|
345
|
+
return SensitiveCheck(is_sensitive=False, reason=f"detect_error:{e}")
|
|
346
346
|
|
|
347
347
|
async def awrap_model_call(
|
|
348
348
|
self,
|
|
@@ -136,7 +136,7 @@ sycommon/services.py,sha256=CwC_gESafo05Qn41KLQgtulx6PfX7s2FkxlBI-hXve4,24861
|
|
|
136
136
|
sycommon/agent/__init__.py,sha256=mxceAeUifQ-DKvWp7ZEJIFlmOCb5wpYHPGQw3rwEN8I,4378
|
|
137
137
|
sycommon/agent/agent_manager.py,sha256=UhhaekEumT7g4v_Z1UB4jTp13X0n8M8erYaQdkGGWkA,13620
|
|
138
138
|
sycommon/agent/chat_events.py,sha256=t7qWa6OrIWLfqtd1AnqaVP67QWkn1JxpCBTZYQpoLuM,14226
|
|
139
|
-
sycommon/agent/deep_agent.py,sha256=
|
|
139
|
+
sycommon/agent/deep_agent.py,sha256=NX5CO9SciGArB35KZKzhVbApsZjlwq_RyuJtSAYr9nE,74520
|
|
140
140
|
sycommon/agent/multi_agent_team.py,sha256=HFdTmMvJns07rrEsq70GCmILWKDzGxgSh6ZeyhX9Lc4,30260
|
|
141
141
|
sycommon/agent/summarization_utils.py,sha256=bqZRFqSekNGlv2mYQPaT_s2QNA5VDTKddi2Va_SkHWc,18376
|
|
142
142
|
sycommon/agent/acp/__init__.py,sha256=vQGMQYAA5-ZaejYmDZ4r4Fklqs17qH3cDXQ5pZlwj-0,1844
|
|
@@ -147,7 +147,7 @@ sycommon/agent/acp/tool.py,sha256=yt6ohKL2y7wIZMNiLv-m5oCg5u1p5GAbqgjzQVt285Y,10
|
|
|
147
147
|
sycommon/agent/mcp/__init__.py,sha256=iKrdDhIrFsNIkqG_kgcwNe-nOiM6uVfolKv44LfQ-FQ,636
|
|
148
148
|
sycommon/agent/mcp/models.py,sha256=zda4ho-UTYOJ5oPAZPZ-vxhfDRLghUCsMroHnA2A2QQ,1490
|
|
149
149
|
sycommon/agent/mcp/tool_loader.py,sha256=OQa-lE7RL2s3Lqh-kNOKaUrb130hvorB_HjyFBqZBZs,10960
|
|
150
|
-
sycommon/agent/middleware/sensitive_guard.py,sha256=
|
|
150
|
+
sycommon/agent/middleware/sensitive_guard.py,sha256=uUYIl1rMP92XNe_uP0nry-NLkcFuIuO8luBP9C58C1g,21916
|
|
151
151
|
sycommon/agent/middleware/sitecustomize.py,sha256=Bt7XFnWV_LJo89l858AGp5VUkXwefpLGmjkCtLe-CMw,4800
|
|
152
152
|
sycommon/agent/middleware/skill_api_whitelist.py,sha256=e15aJekXegPp64owSCEdUE5y0SmwCQVQCF4jnhReZNU,10958
|
|
153
153
|
sycommon/agent/middleware/skill_wl_check.py,sha256=rCJ9F6aWPh8tVQBIPmcq2lKDsfwiJQduwSUku_8kXfs,3952
|
|
@@ -307,8 +307,8 @@ sycommon/tools/syemail.py,sha256=BDFhgf7WDOQeTcjxJEQdu0dQhnHFPO_p3eI0-Ni3LhQ,561
|
|
|
307
307
|
sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
|
|
308
308
|
sycommon/xxljob/__init__.py,sha256=7eoBlQxv-B39IfRSCY2bkqdGYs1QRe1umAWd88VMEEM,86
|
|
309
309
|
sycommon/xxljob/xxljob_service.py,sha256=1yifwIBNGsCIxLnQjHKiBlbsigc_zvPH-dMTZcNxe-Q,7649
|
|
310
|
-
sycommon_python_lib-0.2.
|
|
311
|
-
sycommon_python_lib-0.2.
|
|
312
|
-
sycommon_python_lib-0.2.
|
|
313
|
-
sycommon_python_lib-0.2.
|
|
314
|
-
sycommon_python_lib-0.2.
|
|
310
|
+
sycommon_python_lib-0.2.7a15.dist-info/METADATA,sha256=SD8YD_nOVRB1yGn0aEp0niThMJOphAymWoFHrcmqR6c,7962
|
|
311
|
+
sycommon_python_lib-0.2.7a15.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
312
|
+
sycommon_python_lib-0.2.7a15.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
|
|
313
|
+
sycommon_python_lib-0.2.7a15.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
|
|
314
|
+
sycommon_python_lib-0.2.7a15.dist-info/RECORD,,
|
|
File without changes
|
{sycommon_python_lib-0.2.7a14.dist-info → sycommon_python_lib-0.2.7a15.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.7a14.dist-info → sycommon_python_lib-0.2.7a15.dist-info}/top_level.txt
RENAMED
|
File without changes
|