kweaver-dolphin 0.2.2__py3-none-any.whl → 0.2.3__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.
- dolphin/core/code_block/basic_code_block.py +16 -14
- dolphin/sdk/agent/dolphin_agent.py +54 -0
- {kweaver_dolphin-0.2.2.dist-info → kweaver_dolphin-0.2.3.dist-info}/METADATA +1 -1
- {kweaver_dolphin-0.2.2.dist-info → kweaver_dolphin-0.2.3.dist-info}/RECORD +8 -8
- {kweaver_dolphin-0.2.2.dist-info → kweaver_dolphin-0.2.3.dist-info}/WHEEL +0 -0
- {kweaver_dolphin-0.2.2.dist-info → kweaver_dolphin-0.2.3.dist-info}/entry_points.txt +0 -0
- {kweaver_dolphin-0.2.2.dist-info → kweaver_dolphin-0.2.3.dist-info}/licenses/LICENSE.txt +0 -0
- {kweaver_dolphin-0.2.2.dist-info → kweaver_dolphin-0.2.3.dist-info}/top_level.txt +0 -0
|
@@ -1944,20 +1944,22 @@ class BasicCodeBlock:
|
|
|
1944
1944
|
)
|
|
1945
1945
|
continue
|
|
1946
1946
|
|
|
1947
|
-
#
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
self.context
|
|
1959
|
-
|
|
1960
|
-
|
|
1947
|
+
# Standard approach: Apply interrupt_config if provided in tool_def
|
|
1948
|
+
if "interrupt_config" in tool_def:
|
|
1949
|
+
interrupt_config = tool_def.get("interrupt_config")
|
|
1950
|
+
if interrupt_config and isinstance(interrupt_config, dict):
|
|
1951
|
+
tool_instance.interrupt_config = interrupt_config
|
|
1952
|
+
self.context.debug(
|
|
1953
|
+
f"[_load_dynamic_tools] Applied interrupt_config to {tool_name}"
|
|
1954
|
+
)
|
|
1955
|
+
|
|
1956
|
+
# Hook: Allow upper layer (SDK) to post-process tool instance
|
|
1957
|
+
# This allows SDK to apply temporary policies (e.g., auto-add interrupt_config)
|
|
1958
|
+
if hasattr(self.context, 'on_dynamic_tool_loaded'):
|
|
1959
|
+
try:
|
|
1960
|
+
self.context.on_dynamic_tool_loaded(tool_instance, tool_def)
|
|
1961
|
+
except Exception as e:
|
|
1962
|
+
self.context.error(f"Error in on_dynamic_tool_loaded hook: {e}")
|
|
1961
1963
|
|
|
1962
1964
|
# Add tool instance to skillkit
|
|
1963
1965
|
current_skillkit.addSkill(tool_instance)
|
|
@@ -98,6 +98,10 @@ class DolphinAgent(BaseAgent):
|
|
|
98
98
|
self.skillkit = skillkit
|
|
99
99
|
self.variables = variables
|
|
100
100
|
self.file_path = file_path
|
|
101
|
+
|
|
102
|
+
# Enable auto-interrupt for dynamically loaded tools
|
|
103
|
+
# This is a temporary hack/policy at SDK layer, not in core
|
|
104
|
+
self._enable_dynamic_tool_auto_interrupt = True
|
|
101
105
|
self.global_config = global_config
|
|
102
106
|
self.global_config_path = global_config_path
|
|
103
107
|
self.global_skills = global_skills
|
|
@@ -363,6 +367,11 @@ class DolphinAgent(BaseAgent):
|
|
|
363
367
|
}
|
|
364
368
|
)
|
|
365
369
|
|
|
370
|
+
# Register hook for dynamic tool loading (SDK-layer policy)
|
|
371
|
+
# This is a temporary hack: auto-add interrupt_config to dynamic tools
|
|
372
|
+
if self._enable_dynamic_tool_auto_interrupt:
|
|
373
|
+
self._register_dynamic_tool_hooks()
|
|
374
|
+
|
|
366
375
|
# Validate DPH syntax
|
|
367
376
|
self._validate_syntax()
|
|
368
377
|
|
|
@@ -373,6 +382,51 @@ class DolphinAgent(BaseAgent):
|
|
|
373
382
|
"INIT_FAILED", f"Failed to initialize agent: {str(e)}"
|
|
374
383
|
)
|
|
375
384
|
|
|
385
|
+
def _register_dynamic_tool_hooks(self):
|
|
386
|
+
"""Register hooks for dynamically loaded tools (SDK-layer temporary policy)
|
|
387
|
+
|
|
388
|
+
This is a TEMPORARY HACK to auto-add interrupt_config to all dynamic tools.
|
|
389
|
+
|
|
390
|
+
Architecture decision:
|
|
391
|
+
- Placed at SDK layer (DolphinAgent) instead of core layer (BasicCodeBlock)
|
|
392
|
+
- Reduces invasiveness and keeps core clean
|
|
393
|
+
- Future: Remove this method when upper business layer provides interrupt_config
|
|
394
|
+
|
|
395
|
+
Working mechanism:
|
|
396
|
+
- Core layer: Standard approach - applies interrupt_config if present in tool_def
|
|
397
|
+
- SDK layer: Temporary policy - auto-adds interrupt_config to tool_instance
|
|
398
|
+
"""
|
|
399
|
+
def on_dynamic_tool_loaded(tool_instance, tool_def):
|
|
400
|
+
"""Hook called after each dynamic tool is loaded and interrupt_config applied
|
|
401
|
+
|
|
402
|
+
Args:
|
|
403
|
+
tool_instance: The created tool instance (already has interrupt_config if tool_def had it)
|
|
404
|
+
tool_def: The tool definition dict from _dynamic_tools
|
|
405
|
+
"""
|
|
406
|
+
# Only add if tool doesn't already have interrupt_config
|
|
407
|
+
# (i.e., not provided in tool_def)
|
|
408
|
+
if not hasattr(tool_instance, 'interrupt_config'):
|
|
409
|
+
tool_name = tool_def.get("name", "unknown")
|
|
410
|
+
|
|
411
|
+
# TEMPORARY HACK: Auto-add interrupt_config
|
|
412
|
+
# TODO: Remove this when upper layer provides interrupt_config in tool_def
|
|
413
|
+
auto_interrupt_config = {
|
|
414
|
+
"requires_confirmation": True,
|
|
415
|
+
"confirmation_message": (
|
|
416
|
+
f"即将调用「{tool_name}」工具,是否确认执行?"
|
|
417
|
+
)
|
|
418
|
+
}
|
|
419
|
+
tool_instance.interrupt_config = auto_interrupt_config
|
|
420
|
+
|
|
421
|
+
self._logger.debug(
|
|
422
|
+
f"[DolphinAgent] Auto-added interrupt protection to dynamic tool: {tool_name}"
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
# Register the hook on executor's context
|
|
426
|
+
if self.executor and self.executor.context:
|
|
427
|
+
self.executor.context.on_dynamic_tool_loaded = on_dynamic_tool_loaded
|
|
428
|
+
self._logger.debug("[DolphinAgent] Registered dynamic tool hook (temporary policy)")
|
|
429
|
+
|
|
376
430
|
def _parse_header_info(self):
|
|
377
431
|
"""Parse the header information block of DPH files, supporting the general @XX ... @XX format.
|
|
378
432
|
同时从content中移除这些header块,避免干扰后续解析
|
|
@@ -33,7 +33,7 @@ dolphin/core/agent/base_agent.py,sha256=MC4cY_oE9hPYtUjZMKOLxDimxVMwyPWIpnjvXRdS
|
|
|
33
33
|
dolphin/core/code_block/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
34
|
dolphin/core/code_block/agent_init_block.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
dolphin/core/code_block/assign_block.py,sha256=xbPiQOkFAbrcRDnwkcNN2tfxy7OG8IXPPbjlCM1KJ9I,4124
|
|
36
|
-
dolphin/core/code_block/basic_code_block.py,sha256=
|
|
36
|
+
dolphin/core/code_block/basic_code_block.py,sha256=tgHGPiWO7n3VJyLJ49k6j60pkMRtPrG6-f7jlE6vES4,82309
|
|
37
37
|
dolphin/core/code_block/explore_block.py,sha256=dlYJ4VQMNG6-iFbwzE4CCCcNE_fVQJatB9kVJNUHNp8,71609
|
|
38
38
|
dolphin/core/code_block/explore_block_v2.py,sha256=gKNxQRkTHnZb-HiJ467YOO-Ftoq4lBVtfobEPn1m03o,32614
|
|
39
39
|
dolphin/core/code_block/explore_strategy.py,sha256=m_HWs9dtTiLuyC37JrPUR4Hpcl4jseEoFIQtpPFTaZU,22882
|
|
@@ -186,16 +186,16 @@ dolphin/lib/vm/vm.py,sha256=lLNzbNrb1Z0BIG9QR4VssropSXuM0wuSYJTPN4GLPnc,22528
|
|
|
186
186
|
dolphin/sdk/__init__.py,sha256=I4YBDhkWozXEMD-KVkfJBhz_y8r_Q7OgaiwgrawpI3I,1181
|
|
187
187
|
dolphin/sdk/agent/__init__.py,sha256=zoHZhRrEWwlnkvqEBvSDHLjtB4zeEL7ULRujT1n8_-Y,304
|
|
188
188
|
dolphin/sdk/agent/agent_factory.py,sha256=auoCYDd7yspGZhzKAmKmTBMUrSmJ2vHHLtKK24KM_a4,7387
|
|
189
|
-
dolphin/sdk/agent/dolphin_agent.py,sha256=
|
|
189
|
+
dolphin/sdk/agent/dolphin_agent.py,sha256=coUSnI1xCJIiZQdCUbeftrcN_Him-ZvIDoK9dcCr2aU,49772
|
|
190
190
|
dolphin/sdk/api/__init__.py,sha256=Unr4EQIm0hHeMAJzYzA9TsuyJ0TbL8CEzRSEGNFrn-w,75
|
|
191
191
|
dolphin/sdk/runtime/__init__.py,sha256=W90bnFZ_l6ukuZ3l1iBRWN0oPetdNisjj6dxBMk1NEM,130
|
|
192
192
|
dolphin/sdk/runtime/env.py,sha256=OU0CEZuVXgdQPeNsYq6BhFETcc-Q2vcAp6jLvOrEsbU,12337
|
|
193
193
|
dolphin/sdk/skill/__init__.py,sha256=zzfHgrxIWxUEFH1HMiwb08U1M1ukHcdNtFqKi3Sg1ug,246
|
|
194
194
|
dolphin/sdk/skill/global_skills.py,sha256=uYgzwSLKsdlb5Y5dhOxr00JSeuOx4fHF1aDgrHh7UGs,29466
|
|
195
195
|
dolphin/sdk/skill/traditional_toolkit.py,sha256=Yyejm1LCUDVfXb1MCiaiT2tyFsrW0bj0uvKa5VjA8FM,9355
|
|
196
|
-
kweaver_dolphin-0.2.
|
|
197
|
-
kweaver_dolphin-0.2.
|
|
198
|
-
kweaver_dolphin-0.2.
|
|
199
|
-
kweaver_dolphin-0.2.
|
|
200
|
-
kweaver_dolphin-0.2.
|
|
201
|
-
kweaver_dolphin-0.2.
|
|
196
|
+
kweaver_dolphin-0.2.3.dist-info/licenses/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
197
|
+
kweaver_dolphin-0.2.3.dist-info/METADATA,sha256=-aM8AO5_1mTQ_o8Zn8vcEj7h-0jW9lLMVM9zzPG-rXU,15420
|
|
198
|
+
kweaver_dolphin-0.2.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
199
|
+
kweaver_dolphin-0.2.3.dist-info/entry_points.txt,sha256=iiLRmsPjhVBJvL4XZmoSdbr0-4cIjRQ1cFkJqSdEWE0,718
|
|
200
|
+
kweaver_dolphin-0.2.3.dist-info/top_level.txt,sha256=vwNhnr4e0NgKRTfM56xcCfo9t2ZebTbbPF38xpBYiq0,27
|
|
201
|
+
kweaver_dolphin-0.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|