kweaver-dolphin 0.1.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.
- DolphinLanguageSDK/__init__.py +58 -0
- dolphin/__init__.py +62 -0
- dolphin/cli/__init__.py +20 -0
- dolphin/cli/args/__init__.py +9 -0
- dolphin/cli/args/parser.py +567 -0
- dolphin/cli/builtin_agents/__init__.py +22 -0
- dolphin/cli/commands/__init__.py +4 -0
- dolphin/cli/interrupt/__init__.py +8 -0
- dolphin/cli/interrupt/handler.py +205 -0
- dolphin/cli/interrupt/keyboard.py +82 -0
- dolphin/cli/main.py +49 -0
- dolphin/cli/multimodal/__init__.py +34 -0
- dolphin/cli/multimodal/clipboard.py +327 -0
- dolphin/cli/multimodal/handler.py +249 -0
- dolphin/cli/multimodal/image_processor.py +214 -0
- dolphin/cli/multimodal/input_parser.py +149 -0
- dolphin/cli/runner/__init__.py +8 -0
- dolphin/cli/runner/runner.py +989 -0
- dolphin/cli/ui/__init__.py +10 -0
- dolphin/cli/ui/console.py +2795 -0
- dolphin/cli/ui/input.py +340 -0
- dolphin/cli/ui/layout.py +425 -0
- dolphin/cli/ui/stream_renderer.py +302 -0
- dolphin/cli/utils/__init__.py +8 -0
- dolphin/cli/utils/helpers.py +135 -0
- dolphin/cli/utils/version.py +49 -0
- dolphin/core/__init__.py +107 -0
- dolphin/core/agent/__init__.py +10 -0
- dolphin/core/agent/agent_state.py +69 -0
- dolphin/core/agent/base_agent.py +970 -0
- dolphin/core/code_block/__init__.py +0 -0
- dolphin/core/code_block/agent_init_block.py +0 -0
- dolphin/core/code_block/assign_block.py +98 -0
- dolphin/core/code_block/basic_code_block.py +1865 -0
- dolphin/core/code_block/explore_block.py +1327 -0
- dolphin/core/code_block/explore_block_v2.py +712 -0
- dolphin/core/code_block/explore_strategy.py +672 -0
- dolphin/core/code_block/judge_block.py +220 -0
- dolphin/core/code_block/prompt_block.py +32 -0
- dolphin/core/code_block/skill_call_deduplicator.py +291 -0
- dolphin/core/code_block/tool_block.py +129 -0
- dolphin/core/common/__init__.py +17 -0
- dolphin/core/common/constants.py +176 -0
- dolphin/core/common/enums.py +1173 -0
- dolphin/core/common/exceptions.py +133 -0
- dolphin/core/common/multimodal.py +539 -0
- dolphin/core/common/object_type.py +165 -0
- dolphin/core/common/output_format.py +432 -0
- dolphin/core/common/types.py +36 -0
- dolphin/core/config/__init__.py +16 -0
- dolphin/core/config/global_config.py +1289 -0
- dolphin/core/config/ontology_config.py +133 -0
- dolphin/core/context/__init__.py +12 -0
- dolphin/core/context/context.py +1580 -0
- dolphin/core/context/context_manager.py +161 -0
- dolphin/core/context/var_output.py +82 -0
- dolphin/core/context/variable_pool.py +356 -0
- dolphin/core/context_engineer/__init__.py +41 -0
- dolphin/core/context_engineer/config/__init__.py +5 -0
- dolphin/core/context_engineer/config/settings.py +402 -0
- dolphin/core/context_engineer/core/__init__.py +7 -0
- dolphin/core/context_engineer/core/budget_manager.py +327 -0
- dolphin/core/context_engineer/core/context_assembler.py +583 -0
- dolphin/core/context_engineer/core/context_manager.py +637 -0
- dolphin/core/context_engineer/core/tokenizer_service.py +260 -0
- dolphin/core/context_engineer/example/incremental_example.py +267 -0
- dolphin/core/context_engineer/example/traditional_example.py +334 -0
- dolphin/core/context_engineer/services/__init__.py +5 -0
- dolphin/core/context_engineer/services/compressor.py +399 -0
- dolphin/core/context_engineer/utils/__init__.py +6 -0
- dolphin/core/context_engineer/utils/context_utils.py +441 -0
- dolphin/core/context_engineer/utils/message_formatter.py +270 -0
- dolphin/core/context_engineer/utils/token_utils.py +139 -0
- dolphin/core/coroutine/__init__.py +15 -0
- dolphin/core/coroutine/context_snapshot.py +154 -0
- dolphin/core/coroutine/context_snapshot_profile.py +922 -0
- dolphin/core/coroutine/context_snapshot_store.py +268 -0
- dolphin/core/coroutine/execution_frame.py +145 -0
- dolphin/core/coroutine/execution_state_registry.py +161 -0
- dolphin/core/coroutine/resume_handle.py +101 -0
- dolphin/core/coroutine/step_result.py +101 -0
- dolphin/core/executor/__init__.py +18 -0
- dolphin/core/executor/debug_controller.py +630 -0
- dolphin/core/executor/dolphin_executor.py +1063 -0
- dolphin/core/executor/executor.py +624 -0
- dolphin/core/flags/__init__.py +27 -0
- dolphin/core/flags/definitions.py +49 -0
- dolphin/core/flags/manager.py +113 -0
- dolphin/core/hook/__init__.py +95 -0
- dolphin/core/hook/expression_evaluator.py +499 -0
- dolphin/core/hook/hook_dispatcher.py +380 -0
- dolphin/core/hook/hook_types.py +248 -0
- dolphin/core/hook/isolated_variable_pool.py +284 -0
- dolphin/core/interfaces.py +53 -0
- dolphin/core/llm/__init__.py +0 -0
- dolphin/core/llm/llm.py +495 -0
- dolphin/core/llm/llm_call.py +100 -0
- dolphin/core/llm/llm_client.py +1285 -0
- dolphin/core/llm/message_sanitizer.py +120 -0
- dolphin/core/logging/__init__.py +20 -0
- dolphin/core/logging/logger.py +526 -0
- dolphin/core/message/__init__.py +8 -0
- dolphin/core/message/compressor.py +749 -0
- dolphin/core/parser/__init__.py +8 -0
- dolphin/core/parser/parser.py +405 -0
- dolphin/core/runtime/__init__.py +10 -0
- dolphin/core/runtime/runtime_graph.py +926 -0
- dolphin/core/runtime/runtime_instance.py +446 -0
- dolphin/core/skill/__init__.py +14 -0
- dolphin/core/skill/context_retention.py +157 -0
- dolphin/core/skill/skill_function.py +686 -0
- dolphin/core/skill/skill_matcher.py +282 -0
- dolphin/core/skill/skillkit.py +700 -0
- dolphin/core/skill/skillset.py +72 -0
- dolphin/core/trajectory/__init__.py +10 -0
- dolphin/core/trajectory/recorder.py +189 -0
- dolphin/core/trajectory/trajectory.py +522 -0
- dolphin/core/utils/__init__.py +9 -0
- dolphin/core/utils/cache_kv.py +212 -0
- dolphin/core/utils/tools.py +340 -0
- dolphin/lib/__init__.py +93 -0
- dolphin/lib/debug/__init__.py +8 -0
- dolphin/lib/debug/visualizer.py +409 -0
- dolphin/lib/memory/__init__.py +28 -0
- dolphin/lib/memory/async_processor.py +220 -0
- dolphin/lib/memory/llm_calls.py +195 -0
- dolphin/lib/memory/manager.py +78 -0
- dolphin/lib/memory/sandbox.py +46 -0
- dolphin/lib/memory/storage.py +245 -0
- dolphin/lib/memory/utils.py +51 -0
- dolphin/lib/ontology/__init__.py +12 -0
- dolphin/lib/ontology/basic/__init__.py +0 -0
- dolphin/lib/ontology/basic/base.py +102 -0
- dolphin/lib/ontology/basic/concept.py +130 -0
- dolphin/lib/ontology/basic/object.py +11 -0
- dolphin/lib/ontology/basic/relation.py +63 -0
- dolphin/lib/ontology/datasource/__init__.py +27 -0
- dolphin/lib/ontology/datasource/datasource.py +66 -0
- dolphin/lib/ontology/datasource/oracle_datasource.py +338 -0
- dolphin/lib/ontology/datasource/sql.py +845 -0
- dolphin/lib/ontology/mapping.py +177 -0
- dolphin/lib/ontology/ontology.py +733 -0
- dolphin/lib/ontology/ontology_context.py +16 -0
- dolphin/lib/ontology/ontology_manager.py +107 -0
- dolphin/lib/skill_results/__init__.py +31 -0
- dolphin/lib/skill_results/cache_backend.py +559 -0
- dolphin/lib/skill_results/result_processor.py +181 -0
- dolphin/lib/skill_results/result_reference.py +179 -0
- dolphin/lib/skill_results/skillkit_hook.py +324 -0
- dolphin/lib/skill_results/strategies.py +328 -0
- dolphin/lib/skill_results/strategy_registry.py +150 -0
- dolphin/lib/skillkits/__init__.py +44 -0
- dolphin/lib/skillkits/agent_skillkit.py +155 -0
- dolphin/lib/skillkits/cognitive_skillkit.py +82 -0
- dolphin/lib/skillkits/env_skillkit.py +250 -0
- dolphin/lib/skillkits/mcp_adapter.py +616 -0
- dolphin/lib/skillkits/mcp_skillkit.py +771 -0
- dolphin/lib/skillkits/memory_skillkit.py +650 -0
- dolphin/lib/skillkits/noop_skillkit.py +31 -0
- dolphin/lib/skillkits/ontology_skillkit.py +89 -0
- dolphin/lib/skillkits/plan_act_skillkit.py +452 -0
- dolphin/lib/skillkits/resource/__init__.py +52 -0
- dolphin/lib/skillkits/resource/models/__init__.py +6 -0
- dolphin/lib/skillkits/resource/models/skill_config.py +109 -0
- dolphin/lib/skillkits/resource/models/skill_meta.py +127 -0
- dolphin/lib/skillkits/resource/resource_skillkit.py +393 -0
- dolphin/lib/skillkits/resource/skill_cache.py +215 -0
- dolphin/lib/skillkits/resource/skill_loader.py +395 -0
- dolphin/lib/skillkits/resource/skill_validator.py +406 -0
- dolphin/lib/skillkits/resource_skillkit.py +11 -0
- dolphin/lib/skillkits/search_skillkit.py +163 -0
- dolphin/lib/skillkits/sql_skillkit.py +274 -0
- dolphin/lib/skillkits/system_skillkit.py +509 -0
- dolphin/lib/skillkits/vm_skillkit.py +65 -0
- dolphin/lib/utils/__init__.py +9 -0
- dolphin/lib/utils/data_process.py +207 -0
- dolphin/lib/utils/handle_progress.py +178 -0
- dolphin/lib/utils/security.py +139 -0
- dolphin/lib/utils/text_retrieval.py +462 -0
- dolphin/lib/vm/__init__.py +11 -0
- dolphin/lib/vm/env_executor.py +895 -0
- dolphin/lib/vm/python_session_manager.py +453 -0
- dolphin/lib/vm/vm.py +610 -0
- dolphin/sdk/__init__.py +60 -0
- dolphin/sdk/agent/__init__.py +12 -0
- dolphin/sdk/agent/agent_factory.py +236 -0
- dolphin/sdk/agent/dolphin_agent.py +1106 -0
- dolphin/sdk/api/__init__.py +4 -0
- dolphin/sdk/runtime/__init__.py +8 -0
- dolphin/sdk/runtime/env.py +363 -0
- dolphin/sdk/skill/__init__.py +10 -0
- dolphin/sdk/skill/global_skills.py +706 -0
- dolphin/sdk/skill/traditional_toolkit.py +260 -0
- kweaver_dolphin-0.1.0.dist-info/METADATA +521 -0
- kweaver_dolphin-0.1.0.dist-info/RECORD +199 -0
- kweaver_dolphin-0.1.0.dist-info/WHEEL +5 -0
- kweaver_dolphin-0.1.0.dist-info/entry_points.txt +27 -0
- kweaver_dolphin-0.1.0.dist-info/licenses/LICENSE.txt +201 -0
- kweaver_dolphin-0.1.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"""Isolated Variable Pool Module
|
|
2
|
+
|
|
3
|
+
This module provides a read-only, isolated variable pool for verification agents.
|
|
4
|
+
|
|
5
|
+
Key Features:
|
|
6
|
+
- Read-only access to parent variable pool
|
|
7
|
+
- Whitelist-based variable exposure
|
|
8
|
+
- Local variable storage for hook-specific data (e.g., $_hook_context)
|
|
9
|
+
- Zero-copy reference to parent pool for performance
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from typing import Any, Set, Optional, TYPE_CHECKING
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from dolphin.core.context.variable_pool import VariablePool
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class VariableAccessError(Exception):
|
|
21
|
+
"""Exception raised when attempting to access an unauthorized variable."""
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class IsolatedVariablePool:
|
|
26
|
+
"""Read-only isolated variable pool for verification agents.
|
|
27
|
+
|
|
28
|
+
Provides:
|
|
29
|
+
- Read-only access to parent variable pool (reference, not copy)
|
|
30
|
+
- Whitelist filtering (only exposes specified variables)
|
|
31
|
+
- Prevents modification of parent variable pool
|
|
32
|
+
- Local storage for hook-specific variables (e.g., $_hook_context)
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
```python
|
|
36
|
+
isolated_pool = IsolatedVariablePool(
|
|
37
|
+
parent=context.variable_pool,
|
|
38
|
+
read_only=True,
|
|
39
|
+
exposed_variables=['$datasources', '$config']
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# Access allowed variable
|
|
43
|
+
datasources = isolated_pool.get('datasources')
|
|
44
|
+
|
|
45
|
+
# Access hook context (always allowed)
|
|
46
|
+
hook_ctx = isolated_pool.get('_hook_context')
|
|
47
|
+
|
|
48
|
+
# Accessing non-exposed variable raises error
|
|
49
|
+
try:
|
|
50
|
+
secret = isolated_pool.get('db_password')
|
|
51
|
+
except VariableAccessError:
|
|
52
|
+
print("Access denied!")
|
|
53
|
+
```
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
def __init__(
|
|
57
|
+
self,
|
|
58
|
+
parent: VariablePool,
|
|
59
|
+
read_only: bool = True,
|
|
60
|
+
exposed_variables: Optional[list] = None,
|
|
61
|
+
):
|
|
62
|
+
"""Initialize isolated variable pool.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
parent: The parent VariablePool to reference
|
|
66
|
+
read_only: If True, prevents writing to parent pool
|
|
67
|
+
exposed_variables: List of variable names allowed to access from parent.
|
|
68
|
+
If None or empty, all variables are accessible.
|
|
69
|
+
Variable names should NOT include the $ prefix.
|
|
70
|
+
"""
|
|
71
|
+
self._parent = parent
|
|
72
|
+
self._read_only = read_only
|
|
73
|
+
|
|
74
|
+
# Normalize exposed variables (remove $ prefix if present)
|
|
75
|
+
if exposed_variables:
|
|
76
|
+
self._exposed_variables: Set[str] = {
|
|
77
|
+
v[1:] if v.startswith('$') else v for v in exposed_variables
|
|
78
|
+
}
|
|
79
|
+
else:
|
|
80
|
+
self._exposed_variables = set()
|
|
81
|
+
|
|
82
|
+
# Local variables storage (for $_hook_context and agent-local variables)
|
|
83
|
+
self._local: dict = {}
|
|
84
|
+
|
|
85
|
+
def get(self, name: str, default: Any = None) -> Any:
|
|
86
|
+
"""Get variable value (local first, then parent with whitelist check).
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
name: Variable name (without $ prefix)
|
|
90
|
+
default: Default value if not found
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
Variable value or default
|
|
94
|
+
|
|
95
|
+
Raises:
|
|
96
|
+
VariableAccessError: If variable is not in whitelist
|
|
97
|
+
"""
|
|
98
|
+
# Remove $ prefix if present
|
|
99
|
+
if name.startswith('$'):
|
|
100
|
+
name = name[1:]
|
|
101
|
+
|
|
102
|
+
# 1. Local variables take priority (e.g., $_hook_context)
|
|
103
|
+
if name in self._local:
|
|
104
|
+
return self._local[name]
|
|
105
|
+
|
|
106
|
+
# 2. Check whitelist if configured
|
|
107
|
+
if self._exposed_variables and name not in self._exposed_variables:
|
|
108
|
+
# Special variables (starting with _) for hook system are always accessible locally
|
|
109
|
+
if name.startswith('_'):
|
|
110
|
+
return default
|
|
111
|
+
raise VariableAccessError(
|
|
112
|
+
f"Variable '{name}' is not exposed to verifier agent. "
|
|
113
|
+
f"Add it to exposed_variables in hook config."
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# 3. Read from parent pool (read-only reference)
|
|
117
|
+
return self._parent.get_var_value(name, default)
|
|
118
|
+
|
|
119
|
+
def set(self, name: str, value: Any, immutable: bool = False) -> None:
|
|
120
|
+
"""Set variable value.
|
|
121
|
+
|
|
122
|
+
In read-only mode, only local variables can be set.
|
|
123
|
+
Special variables (starting with $_) are always stored locally.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
name: Variable name
|
|
127
|
+
value: Value to set
|
|
128
|
+
immutable: Whether the variable should be immutable (ignored)
|
|
129
|
+
|
|
130
|
+
Raises:
|
|
131
|
+
VariableAccessError: If attempting to write to parent in read-only mode
|
|
132
|
+
"""
|
|
133
|
+
# Remove $ prefix if present
|
|
134
|
+
if name.startswith('$'):
|
|
135
|
+
name = name[1:]
|
|
136
|
+
|
|
137
|
+
# Special variables (starting with _) always go to local storage
|
|
138
|
+
if name.startswith('_'):
|
|
139
|
+
self._local[name] = value
|
|
140
|
+
return
|
|
141
|
+
|
|
142
|
+
# In read-only mode, store in local pool
|
|
143
|
+
if self._read_only:
|
|
144
|
+
self._local[name] = value
|
|
145
|
+
else:
|
|
146
|
+
# Non-read-only mode: can write to parent (use with caution)
|
|
147
|
+
self._parent.set_var(name, value)
|
|
148
|
+
|
|
149
|
+
def __contains__(self, name: str) -> bool:
|
|
150
|
+
"""Check if variable exists."""
|
|
151
|
+
# Remove $ prefix if present
|
|
152
|
+
if name.startswith('$'):
|
|
153
|
+
name = name[1:]
|
|
154
|
+
|
|
155
|
+
# Check local first
|
|
156
|
+
if name in self._local:
|
|
157
|
+
return True
|
|
158
|
+
|
|
159
|
+
# Check whitelist
|
|
160
|
+
if self._exposed_variables and name not in self._exposed_variables:
|
|
161
|
+
return False
|
|
162
|
+
|
|
163
|
+
# Check parent
|
|
164
|
+
return self._parent.contain_var(name)
|
|
165
|
+
|
|
166
|
+
def contain_var(self, name: str) -> bool:
|
|
167
|
+
"""Check if variable exists (alias for __contains__)."""
|
|
168
|
+
return name in self
|
|
169
|
+
|
|
170
|
+
def get_var_value(self, name: str, default: Any = None) -> Any:
|
|
171
|
+
"""Get variable value (alias for get, compatible with VariablePool interface)."""
|
|
172
|
+
try:
|
|
173
|
+
return self.get(name, default)
|
|
174
|
+
except VariableAccessError:
|
|
175
|
+
return default
|
|
176
|
+
|
|
177
|
+
def get_var_path_value(self, varpath: str, default: Any = None) -> Any:
|
|
178
|
+
"""Get value from variable pool using dot notation path.
|
|
179
|
+
|
|
180
|
+
Example: get_var_path_value('user.profile.name')
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
varpath: Variable path with dot notation
|
|
184
|
+
default: Default value if not found
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
Value at the specified path or default
|
|
188
|
+
"""
|
|
189
|
+
if not varpath:
|
|
190
|
+
return default
|
|
191
|
+
|
|
192
|
+
# Remove $ prefix if present
|
|
193
|
+
if varpath.startswith('$'):
|
|
194
|
+
varpath = varpath[1:]
|
|
195
|
+
|
|
196
|
+
parts = varpath.split(".")
|
|
197
|
+
base_var = parts[0]
|
|
198
|
+
|
|
199
|
+
# Get base variable
|
|
200
|
+
try:
|
|
201
|
+
value = self.get(base_var, default)
|
|
202
|
+
except VariableAccessError:
|
|
203
|
+
return default
|
|
204
|
+
|
|
205
|
+
if value is default:
|
|
206
|
+
return default
|
|
207
|
+
|
|
208
|
+
# Navigate through the path
|
|
209
|
+
for part in parts[1:]:
|
|
210
|
+
if isinstance(value, dict):
|
|
211
|
+
if part not in value:
|
|
212
|
+
return default
|
|
213
|
+
value = value[part]
|
|
214
|
+
else:
|
|
215
|
+
return default
|
|
216
|
+
|
|
217
|
+
return value
|
|
218
|
+
|
|
219
|
+
def delete_var(self, name: str) -> None:
|
|
220
|
+
"""Delete a local variable.
|
|
221
|
+
|
|
222
|
+
Only local variables can be deleted. Parent pool variables
|
|
223
|
+
are never modified in read-only mode.
|
|
224
|
+
|
|
225
|
+
Args:
|
|
226
|
+
name: Variable name to delete
|
|
227
|
+
"""
|
|
228
|
+
# Remove $ prefix if present
|
|
229
|
+
if name.startswith('$'):
|
|
230
|
+
name = name[1:]
|
|
231
|
+
|
|
232
|
+
if name in self._local:
|
|
233
|
+
del self._local[name]
|
|
234
|
+
|
|
235
|
+
def get_all_variables(self) -> dict:
|
|
236
|
+
"""Get all accessible variables (local + allowed parent variables).
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
Dictionary of all accessible variables and their values
|
|
240
|
+
"""
|
|
241
|
+
result = {}
|
|
242
|
+
|
|
243
|
+
# Add parent variables (respecting whitelist)
|
|
244
|
+
if self._exposed_variables:
|
|
245
|
+
for name in self._exposed_variables:
|
|
246
|
+
if self._parent.contain_var(name):
|
|
247
|
+
var = self._parent.get_var(name)
|
|
248
|
+
if var:
|
|
249
|
+
result[name] = var.to_dict()
|
|
250
|
+
else:
|
|
251
|
+
# No whitelist - expose all parent variables
|
|
252
|
+
result.update(self._parent.get_all_variables())
|
|
253
|
+
|
|
254
|
+
# Add/override with local variables
|
|
255
|
+
for name, value in self._local.items():
|
|
256
|
+
result[name] = {'value': value}
|
|
257
|
+
|
|
258
|
+
return result
|
|
259
|
+
|
|
260
|
+
def keys(self) -> list:
|
|
261
|
+
"""Get all accessible variable names."""
|
|
262
|
+
if self._exposed_variables:
|
|
263
|
+
parent_keys = [k for k in self._exposed_variables if self._parent.contain_var(k)]
|
|
264
|
+
else:
|
|
265
|
+
parent_keys = list(self._parent.keys())
|
|
266
|
+
|
|
267
|
+
local_keys = list(self._local.keys())
|
|
268
|
+
|
|
269
|
+
# Combine and deduplicate
|
|
270
|
+
return list(set(parent_keys + local_keys))
|
|
271
|
+
|
|
272
|
+
def clear(self) -> None:
|
|
273
|
+
"""Clear local variables only. Parent pool is never modified."""
|
|
274
|
+
self._local.clear()
|
|
275
|
+
|
|
276
|
+
@property
|
|
277
|
+
def is_read_only(self) -> bool:
|
|
278
|
+
"""Check if pool is in read-only mode."""
|
|
279
|
+
return self._read_only
|
|
280
|
+
|
|
281
|
+
@property
|
|
282
|
+
def exposed_variable_names(self) -> Set[str]:
|
|
283
|
+
"""Get the set of exposed variable names."""
|
|
284
|
+
return self._exposed_variables.copy()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Protocol 接口定义 - 用于解耦跨层依赖
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import Protocol, List, Any, Optional
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class IMemoryManager(Protocol):
|
|
10
|
+
"""内存管理器接口 - 实现在 dolphin.lib.memory"""
|
|
11
|
+
|
|
12
|
+
def retrieve_relevant_memory(
|
|
13
|
+
self,
|
|
14
|
+
context: Any,
|
|
15
|
+
user_id: str,
|
|
16
|
+
query: str,
|
|
17
|
+
top_k: int = 5,
|
|
18
|
+
) -> List[Any]:
|
|
19
|
+
"""检索相关记忆"""
|
|
20
|
+
...
|
|
21
|
+
|
|
22
|
+
def store_memory(
|
|
23
|
+
self,
|
|
24
|
+
user_id: str,
|
|
25
|
+
content: str,
|
|
26
|
+
metadata: Optional[dict] = None,
|
|
27
|
+
) -> bool:
|
|
28
|
+
"""存储记忆"""
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ISkillkit(Protocol):
|
|
33
|
+
"""Skillkit 接口 - 用于类型提示"""
|
|
34
|
+
|
|
35
|
+
def exec(self, skill_name: str, *args, **kwargs) -> Any:
|
|
36
|
+
"""执行 skill"""
|
|
37
|
+
...
|
|
38
|
+
|
|
39
|
+
def get_skill_list(self) -> List[str]:
|
|
40
|
+
"""获取 skill 列表"""
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ITrajectory(Protocol):
|
|
45
|
+
"""轨迹接口 - 用于类型提示"""
|
|
46
|
+
|
|
47
|
+
def record(self, event_type: str, data: dict) -> None:
|
|
48
|
+
"""记录事件"""
|
|
49
|
+
...
|
|
50
|
+
|
|
51
|
+
def get_records(self) -> List[dict]:
|
|
52
|
+
"""获取所有记录"""
|
|
53
|
+
...
|
|
File without changes
|