-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy path__init__.py
More file actions
460 lines (449 loc) · 10.9 KB
/
Copy path__init__.py
File metadata and controls
460 lines (449 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# -*- coding: utf-8 -*-
"""
Agent Core - Core library for CraftBot.
This package provides core functionality shared between agent implementations,
including action framework, state management, LLM interfaces, and integrations.
"""
__version__ = "0.1.0"
# Re-export key classes for convenient imports
from agent_core.core.state import (
StateProvider,
StateRegistry,
get_state,
get_state_or_none,
AgentProperties,
ReasoningResult,
TaskSummary,
MainState,
DEFAULT_MAX_ACTIONS_PER_TASK,
DEFAULT_MAX_TOKEN_PER_TASK,
)
from agent_core.core.models import (
InterfaceType,
MODEL_REGISTRY,
ProviderConfig,
PROVIDER_CONFIG,
ModelFactory,
test_provider_connection,
)
from agent_core.core.embedding_interface import EmbeddingInterface
from agent_core.core.vlm_interface import VLMInterface
from agent_core.core.image_gen_interface import ImageGenInterface
from agent_core.core.database_interface import DatabaseInterface
from agent_core.core.trigger import Trigger
from agent_core.core.task import Task, TodoItem, TodoStatus
from agent_core.core.action_framework import (
ActionRegistry,
ActionMetadata,
RegisteredAction,
action,
registry_instance,
load_actions_from_directories,
PLATFORM_ALL,
PLATFORM_LINUX,
PLATFORM_WINDOWS,
PLATFORM_DARWIN,
)
from agent_core.core.llm.google_gemini_client import GeminiClient, GeminiAPIError
from agent_core.core.impl.llm.cache import (
CacheConfig,
get_cache_config,
CacheMetrics,
CacheMetricsEntry,
get_cache_metrics,
BytePlusCacheManager,
BytePlusContextOverflowError,
BYTEPLUS_MAX_INPUT_TOKENS,
GeminiCacheManager,
)
from agent_core.core.action import Action, Observe
from agent_core.core.event_stream import Event, EventRecord
from agent_core.decorators import (
profile,
profile_loop,
profiler,
OperationCategory,
ProfileContext,
enable_profiling,
disable_profiling,
log_events,
)
from agent_core.core.credentials import (
get_credential,
get_credentials,
has_embedded_credentials,
run_oauth_flow,
run_oauth_flow_async,
)
from agent_core.core.config import (
ConfigRegistry,
get_workspace_root,
get_config,
get_credential_client,
register_credential_client,
)
from agent_core.core.registry import (
ComponentRegistry,
# Database
DatabaseRegistry,
get_database,
get_database_or_none,
# Action
ActionExecutorRegistry,
ActionManagerRegistry,
get_action_executor,
get_action_executor_or_none,
get_action_manager,
get_action_manager_or_none,
# Memory
MemoryRegistry,
get_memory_manager,
get_memory_manager_or_none,
# LLM
LLMInterfaceRegistry,
get_llm_interface,
get_llm_interface_or_none,
# Event stream
EventStreamRegistry,
EventStreamManagerRegistry,
get_event_stream,
get_event_stream_or_none,
get_event_stream_manager,
get_event_stream_manager_or_none,
# Task manager
TaskManagerRegistry,
get_task_manager,
get_task_manager_or_none,
# State manager
StateManagerRegistry,
get_state_manager,
get_state_manager_or_none,
# Context engine
ContextEngineRegistry,
get_context_engine,
get_context_engine_or_none,
# Trigger queue
TriggerQueueRegistry,
get_trigger_queue,
get_trigger_queue_or_none,
)
from agent_core.core.hooks import (
OnTaskCreatedHook,
OnTaskEndedHook,
OnTodoTransitionHook,
OnActionStartHook,
OnActionEndHook,
OnEventLoggedHook,
GetSkipEventTypesHook,
# Token/State hooks
GetTokenCountHook,
SetTokenCountHook,
# Usage reporting hooks
UsageEventData,
ReportUsageHook,
)
# Implementations
from agent_core.core.impl.action import (
ActionExecutor,
ActionLibrary,
ActionRouter,
ActionManager,
set_gui_execute_hook,
)
from agent_core.core.impl.memory import (
MemoryManager,
MemoryFileWatcher,
MemoryPointer,
MemoryChunk,
create_memory_processing_task,
)
from agent_core.core.impl.llm import LLMCallType
from agent_core.core.impl.trigger import TriggerQueue
from agent_core.core.impl.workflow_lock import WorkflowLockManager
from agent_core.core.impl.event_stream import (
EventStream,
EventStreamManager,
)
# Prompts
from agent_core.core.prompts import (
# Registry
PromptRegistry,
prompt_registry,
get_prompt,
register_prompt,
# Event stream
EVENT_STREAM_SUMMARIZATION_PROMPT,
# Action prompts
SELECT_ACTION_PROMPT,
SELECT_ACTION_IN_TASK_PROMPT,
SELECT_ACTION_IN_GUI_PROMPT,
SELECT_ACTION_IN_SIMPLE_TASK_PROMPT,
GUI_ACTION_SPACE_PROMPT,
# Context prompts
AGENT_ROLE_PROMPT,
AGENT_INFO_PROMPT,
POLICY_PROMPT,
USER_PROFILE_PROMPT,
ENVIRONMENTAL_CONTEXT_PROMPT,
AGENT_FILE_SYSTEM_CONTEXT_PROMPT,
# Routing prompts
ROUTE_TO_SESSION_PROMPT,
# GUI prompts
GUI_REASONING_PROMPT,
GUI_REASONING_PROMPT_OMNIPARSER,
GUI_QUERY_FOCUSED_PROMPT,
GUI_PIXEL_POSITION_PROMPT,
# Skill selection prompts
SKILLS_AND_ACTION_SETS_SELECTION_PROMPT,
SKILL_SELECTION_PROMPT,
ACTION_SET_SELECTION_PROMPT,
)
# MCP
from agent_core.core.impl.mcp import (
MCPServerConfig,
MCPConfig,
MCPTool,
MCPServerConnection,
MCPClient,
mcp_client,
MCPActionAdapter,
set_client_info as set_mcp_client_info,
)
# Skill
from agent_core.core.impl.skill import (
Skill,
SkillMetadata,
SkillsConfig,
SkillLoader,
SkillManager,
skill_manager,
)
# Onboarding
from agent_core.core.impl.onboarding import (
OnboardingState,
OnboardingManager,
onboarding_manager,
HARD_ONBOARDING_STEPS,
DEFAULT_AGENT_NAME,
load_state as load_onboarding_state,
save_state as save_onboarding_state,
)
# Settings
from agent_core.core.impl.settings import (
SettingsManager,
settings_manager,
)
# Config Watcher
from agent_core.core.impl.config import (
ConfigWatcher,
config_watcher,
)
__all__ = [
# Version
"__version__",
# State management
"StateProvider",
"StateRegistry",
"get_state",
"get_state_or_none",
"AgentProperties",
"ReasoningResult",
"TaskSummary",
"MainState",
"DEFAULT_MAX_ACTIONS_PER_TASK",
"DEFAULT_MAX_TOKEN_PER_TASK",
# Model factory and types
"InterfaceType",
"MODEL_REGISTRY",
"ProviderConfig",
"PROVIDER_CONFIG",
"ModelFactory",
"test_provider_connection",
# Interfaces
"EmbeddingInterface",
"VLMInterface",
"ImageGenInterface",
"DatabaseInterface",
"GeminiClient",
"GeminiAPIError",
# Cache
"CacheConfig",
"get_cache_config",
"CacheMetrics",
"CacheMetricsEntry",
"get_cache_metrics",
"BytePlusCacheManager",
"BytePlusContextOverflowError",
"BYTEPLUS_MAX_INPUT_TOKENS",
"GeminiCacheManager",
# Action framework
"Action",
"Observe",
"ActionRegistry",
"ActionMetadata",
"RegisteredAction",
"action",
"registry_instance",
"load_actions_from_directories",
"PLATFORM_ALL",
"PLATFORM_LINUX",
"PLATFORM_WINDOWS",
"PLATFORM_DARWIN",
# Task management
"Task",
"TodoItem",
"TodoStatus",
# Event stream
"Event",
"EventRecord",
# Trigger
"Trigger",
# Profiling
"profile",
"profile_loop",
"profiler",
"OperationCategory",
"ProfileContext",
"enable_profiling",
"disable_profiling",
"log_events",
# Credentials
"get_credential",
"get_credentials",
"has_embedded_credentials",
"run_oauth_flow",
"run_oauth_flow_async",
# Config
"ConfigRegistry",
"get_workspace_root",
"get_config",
"get_credential_client",
"register_credential_client",
# Component registry
"ComponentRegistry",
# Registries
"DatabaseRegistry",
"get_database",
"get_database_or_none",
"ActionExecutorRegistry",
"ActionManagerRegistry",
"get_action_executor",
"get_action_executor_or_none",
"get_action_manager",
"get_action_manager_or_none",
"MemoryRegistry",
"get_memory_manager",
"get_memory_manager_or_none",
"LLMInterfaceRegistry",
"get_llm_interface",
"get_llm_interface_or_none",
"EventStreamRegistry",
"EventStreamManagerRegistry",
"get_event_stream",
"get_event_stream_or_none",
"get_event_stream_manager",
"get_event_stream_manager_or_none",
"TaskManagerRegistry",
"get_task_manager",
"get_task_manager_or_none",
"StateManagerRegistry",
"get_state_manager",
"get_state_manager_or_none",
"ContextEngineRegistry",
"get_context_engine",
"get_context_engine_or_none",
"TriggerQueueRegistry",
"get_trigger_queue",
"get_trigger_queue_or_none",
# Implementations
"ActionExecutor",
"ActionLibrary",
"ActionRouter",
"ActionManager",
"set_gui_execute_hook",
"MemoryManager",
"MemoryFileWatcher",
"MemoryPointer",
"MemoryChunk",
"create_memory_processing_task",
"LLMCallType",
"TriggerQueue",
"WorkflowLockManager",
"EventStream",
"EventStreamManager",
# Prompts - Registry
"PromptRegistry",
"prompt_registry",
"get_prompt",
"register_prompt",
# Prompts - Event stream
"EVENT_STREAM_SUMMARIZATION_PROMPT",
# Prompts - Action
"SELECT_ACTION_PROMPT",
"SELECT_ACTION_IN_TASK_PROMPT",
"SELECT_ACTION_IN_GUI_PROMPT",
"SELECT_ACTION_IN_SIMPLE_TASK_PROMPT",
"GUI_ACTION_SPACE_PROMPT",
# Prompts - Context
"AGENT_ROLE_PROMPT",
"AGENT_INFO_PROMPT",
"POLICY_PROMPT",
"USER_PROFILE_PROMPT",
"ENVIRONMENTAL_CONTEXT_PROMPT",
"AGENT_FILE_SYSTEM_CONTEXT_PROMPT",
# Prompts - Routing
"ROUTE_TO_SESSION_PROMPT",
# Prompts - GUI
"GUI_REASONING_PROMPT",
"GUI_REASONING_PROMPT_OMNIPARSER",
"GUI_QUERY_FOCUSED_PROMPT",
"GUI_PIXEL_POSITION_PROMPT",
# Prompts - Skill selection
"SKILLS_AND_ACTION_SETS_SELECTION_PROMPT",
"SKILL_SELECTION_PROMPT",
"ACTION_SET_SELECTION_PROMPT",
# Hooks
"OnTaskCreatedHook",
"OnTaskEndedHook",
"OnTodoTransitionHook",
"OnActionStartHook",
"OnActionEndHook",
"OnEventLoggedHook",
"GetSkipEventTypesHook",
# Token/State hooks
"GetTokenCountHook",
"SetTokenCountHook",
# Usage reporting hooks
"UsageEventData",
"ReportUsageHook",
# MCP
"MCPServerConfig",
"MCPConfig",
"MCPTool",
"MCPServerConnection",
"MCPClient",
"mcp_client",
"MCPActionAdapter",
"set_mcp_client_info",
# Skill
"Skill",
"SkillMetadata",
"SkillsConfig",
"SkillLoader",
"SkillManager",
"skill_manager",
# Onboarding
"OnboardingState",
"OnboardingManager",
"onboarding_manager",
"HARD_ONBOARDING_STEPS",
"DEFAULT_AGENT_NAME",
"load_onboarding_state",
"save_onboarding_state",
# Settings
"SettingsManager",
"settings_manager",
# Config Watcher
"ConfigWatcher",
"config_watcher",
]