alita-sdk 0.3.465__py3-none-any.whl → 0.3.497__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.

Potentially problematic release.


This version of alita-sdk might be problematic. Click here for more details.

Files changed (103) hide show
  1. alita_sdk/cli/agent/__init__.py +5 -0
  2. alita_sdk/cli/agent/default.py +83 -1
  3. alita_sdk/cli/agent_loader.py +22 -4
  4. alita_sdk/cli/agent_ui.py +13 -3
  5. alita_sdk/cli/agents.py +1876 -186
  6. alita_sdk/cli/callbacks.py +96 -25
  7. alita_sdk/cli/cli.py +10 -1
  8. alita_sdk/cli/config.py +151 -9
  9. alita_sdk/cli/context/__init__.py +30 -0
  10. alita_sdk/cli/context/cleanup.py +198 -0
  11. alita_sdk/cli/context/manager.py +731 -0
  12. alita_sdk/cli/context/message.py +285 -0
  13. alita_sdk/cli/context/strategies.py +289 -0
  14. alita_sdk/cli/context/token_estimation.py +127 -0
  15. alita_sdk/cli/input_handler.py +167 -4
  16. alita_sdk/cli/inventory.py +1256 -0
  17. alita_sdk/cli/toolkit.py +14 -17
  18. alita_sdk/cli/toolkit_loader.py +35 -5
  19. alita_sdk/cli/tools/__init__.py +8 -1
  20. alita_sdk/cli/tools/filesystem.py +910 -64
  21. alita_sdk/cli/tools/planning.py +143 -157
  22. alita_sdk/cli/tools/terminal.py +154 -20
  23. alita_sdk/community/__init__.py +64 -8
  24. alita_sdk/community/inventory/__init__.py +224 -0
  25. alita_sdk/community/inventory/config.py +257 -0
  26. alita_sdk/community/inventory/enrichment.py +2137 -0
  27. alita_sdk/community/inventory/extractors.py +1469 -0
  28. alita_sdk/community/inventory/ingestion.py +3172 -0
  29. alita_sdk/community/inventory/knowledge_graph.py +1457 -0
  30. alita_sdk/community/inventory/parsers/__init__.py +218 -0
  31. alita_sdk/community/inventory/parsers/base.py +295 -0
  32. alita_sdk/community/inventory/parsers/csharp_parser.py +907 -0
  33. alita_sdk/community/inventory/parsers/go_parser.py +851 -0
  34. alita_sdk/community/inventory/parsers/html_parser.py +389 -0
  35. alita_sdk/community/inventory/parsers/java_parser.py +593 -0
  36. alita_sdk/community/inventory/parsers/javascript_parser.py +629 -0
  37. alita_sdk/community/inventory/parsers/kotlin_parser.py +768 -0
  38. alita_sdk/community/inventory/parsers/markdown_parser.py +362 -0
  39. alita_sdk/community/inventory/parsers/python_parser.py +604 -0
  40. alita_sdk/community/inventory/parsers/rust_parser.py +858 -0
  41. alita_sdk/community/inventory/parsers/swift_parser.py +832 -0
  42. alita_sdk/community/inventory/parsers/text_parser.py +322 -0
  43. alita_sdk/community/inventory/parsers/yaml_parser.py +370 -0
  44. alita_sdk/community/inventory/patterns/__init__.py +61 -0
  45. alita_sdk/community/inventory/patterns/ast_adapter.py +380 -0
  46. alita_sdk/community/inventory/patterns/loader.py +348 -0
  47. alita_sdk/community/inventory/patterns/registry.py +198 -0
  48. alita_sdk/community/inventory/presets.py +535 -0
  49. alita_sdk/community/inventory/retrieval.py +1403 -0
  50. alita_sdk/community/inventory/toolkit.py +169 -0
  51. alita_sdk/community/inventory/visualize.py +1370 -0
  52. alita_sdk/configurations/bitbucket.py +0 -3
  53. alita_sdk/runtime/clients/client.py +108 -31
  54. alita_sdk/runtime/langchain/assistant.py +4 -2
  55. alita_sdk/runtime/langchain/constants.py +3 -1
  56. alita_sdk/runtime/langchain/document_loaders/AlitaExcelLoader.py +103 -60
  57. alita_sdk/runtime/langchain/document_loaders/constants.py +10 -6
  58. alita_sdk/runtime/langchain/langraph_agent.py +123 -31
  59. alita_sdk/runtime/llms/preloaded.py +2 -6
  60. alita_sdk/runtime/toolkits/__init__.py +2 -0
  61. alita_sdk/runtime/toolkits/application.py +1 -1
  62. alita_sdk/runtime/toolkits/mcp.py +107 -91
  63. alita_sdk/runtime/toolkits/planning.py +173 -0
  64. alita_sdk/runtime/toolkits/tools.py +59 -7
  65. alita_sdk/runtime/tools/artifact.py +46 -17
  66. alita_sdk/runtime/tools/function.py +2 -1
  67. alita_sdk/runtime/tools/llm.py +320 -32
  68. alita_sdk/runtime/tools/mcp_remote_tool.py +23 -7
  69. alita_sdk/runtime/tools/planning/__init__.py +36 -0
  70. alita_sdk/runtime/tools/planning/models.py +246 -0
  71. alita_sdk/runtime/tools/planning/wrapper.py +607 -0
  72. alita_sdk/runtime/tools/vectorstore_base.py +44 -9
  73. alita_sdk/runtime/utils/AlitaCallback.py +106 -20
  74. alita_sdk/runtime/utils/mcp_client.py +465 -0
  75. alita_sdk/runtime/utils/mcp_oauth.py +80 -0
  76. alita_sdk/runtime/utils/mcp_tools_discovery.py +124 -0
  77. alita_sdk/runtime/utils/streamlit.py +6 -10
  78. alita_sdk/runtime/utils/toolkit_utils.py +14 -5
  79. alita_sdk/tools/__init__.py +54 -27
  80. alita_sdk/tools/ado/repos/repos_wrapper.py +1 -2
  81. alita_sdk/tools/base_indexer_toolkit.py +99 -20
  82. alita_sdk/tools/bitbucket/__init__.py +2 -2
  83. alita_sdk/tools/chunkers/__init__.py +3 -1
  84. alita_sdk/tools/chunkers/sematic/json_chunker.py +1 -0
  85. alita_sdk/tools/chunkers/sematic/markdown_chunker.py +97 -6
  86. alita_sdk/tools/chunkers/universal_chunker.py +270 -0
  87. alita_sdk/tools/code/loaders/codesearcher.py +3 -2
  88. alita_sdk/tools/code_indexer_toolkit.py +55 -22
  89. alita_sdk/tools/confluence/api_wrapper.py +63 -14
  90. alita_sdk/tools/elitea_base.py +86 -21
  91. alita_sdk/tools/jira/__init__.py +1 -1
  92. alita_sdk/tools/jira/api_wrapper.py +91 -40
  93. alita_sdk/tools/non_code_indexer_toolkit.py +1 -0
  94. alita_sdk/tools/qtest/__init__.py +1 -1
  95. alita_sdk/tools/sharepoint/api_wrapper.py +2 -2
  96. alita_sdk/tools/vector_adapters/VectorStoreAdapter.py +17 -13
  97. alita_sdk/tools/zephyr_essential/api_wrapper.py +12 -13
  98. {alita_sdk-0.3.465.dist-info → alita_sdk-0.3.497.dist-info}/METADATA +2 -1
  99. {alita_sdk-0.3.465.dist-info → alita_sdk-0.3.497.dist-info}/RECORD +103 -61
  100. {alita_sdk-0.3.465.dist-info → alita_sdk-0.3.497.dist-info}/WHEEL +0 -0
  101. {alita_sdk-0.3.465.dist-info → alita_sdk-0.3.497.dist-info}/entry_points.txt +0 -0
  102. {alita_sdk-0.3.465.dist-info → alita_sdk-0.3.497.dist-info}/licenses/LICENSE +0 -0
  103. {alita_sdk-0.3.465.dist-info → alita_sdk-0.3.497.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,169 @@
1
+ """
2
+ Inventory Retrieval Toolkit.
3
+
4
+ Provides LangChain-compatible toolkit for querying pre-built knowledge graphs.
5
+ This is a pure retrieval toolkit - for ingestion, use the IngestionPipeline.
6
+
7
+ The toolkit can be added to any agent to provide knowledge graph context.
8
+ """
9
+
10
+ from typing import Any, Optional, List, Dict, Literal, ClassVar
11
+
12
+ from langchain_core.tools import BaseTool
13
+ from langchain_core.tools import BaseToolkit
14
+ from pydantic import BaseModel, Field, ConfigDict, create_model
15
+
16
+ from .retrieval import InventoryRetrievalApiWrapper
17
+ from ...tools.base.tool import BaseAction
18
+ from ...tools.utils import clean_string, TOOLKIT_SPLITTER, get_max_toolkit_length
19
+
20
+
21
+ class InventoryRetrievalToolkit(BaseToolkit):
22
+ """
23
+ Toolkit for querying pre-built Knowledge Graphs.
24
+
25
+ This toolkit provides retrieval-only access to a knowledge graph
26
+ that was built using the IngestionPipeline. It can be added to
27
+ any agent to provide codebase context.
28
+
29
+ Available tools:
30
+ - search_graph: Search entities by name, type, or layer
31
+ - get_entity: Get detailed entity info with relations
32
+ - get_entity_content: Retrieve source code via citation
33
+ - impact_analysis: Analyze upstream/downstream dependencies
34
+ - get_related_entities: Get related entities
35
+ - get_stats: Graph statistics
36
+ - get_citations: Citation summaries
37
+ - list_entities_by_type: List entities of a type
38
+ - list_entities_by_layer: List entities in a layer
39
+ """
40
+
41
+ tools: List[BaseTool] = []
42
+ toolkit_max_length: ClassVar[int] = 0
43
+
44
+ # All available tools in this toolkit
45
+ AVAILABLE_TOOLS: ClassVar[List[str]] = [
46
+ "search_graph",
47
+ "get_entity",
48
+ "get_entity_content",
49
+ "impact_analysis",
50
+ "get_related_entities",
51
+ "get_stats",
52
+ "get_citations",
53
+ "list_entities_by_type",
54
+ "list_entities_by_layer",
55
+ ]
56
+
57
+ @staticmethod
58
+ def toolkit_config_schema() -> BaseModel:
59
+ """Return the configuration schema for this toolkit."""
60
+ selected_tools = {
61
+ x['name']: x['args_schema'].model_json_schema()
62
+ for x in InventoryRetrievalApiWrapper.model_construct().get_available_tools()
63
+ }
64
+ InventoryRetrievalToolkit.toolkit_max_length = get_max_toolkit_length(selected_tools)
65
+
66
+ model = create_model(
67
+ 'inventory',
68
+ graph_path=(str, Field(
69
+ description="Path to the knowledge graph JSON file (required). "
70
+ "The graph should be built using IngestionPipeline."
71
+ )),
72
+ base_directory=(Optional[str], Field(
73
+ default=None,
74
+ description="Base directory for local content retrieval. "
75
+ "If set, get_entity_content will read from local files."
76
+ )),
77
+ selected_tools=(List[Literal[tuple(selected_tools)]], Field(
78
+ default=[],
79
+ json_schema_extra={'args_schemas': selected_tools}
80
+ )),
81
+ __config__=ConfigDict(json_schema_extra={
82
+ 'metadata': {
83
+ "label": "Knowledge Graph Retrieval",
84
+ "icon_url": "inventory-icon.svg",
85
+ "max_length": InventoryRetrievalToolkit.toolkit_max_length,
86
+ "categories": ["knowledge management"],
87
+ "extra_categories": [
88
+ "knowledge graph",
89
+ "code context",
90
+ "impact analysis",
91
+ "code search"
92
+ ],
93
+ "description": (
94
+ "Query a pre-built knowledge graph for codebase context. "
95
+ "Use IngestionPipeline to build the graph first."
96
+ ),
97
+ }
98
+ })
99
+ )
100
+ return model
101
+
102
+ @classmethod
103
+ def get_toolkit(
104
+ cls,
105
+ selected_tools: Optional[List[str]] = None,
106
+ toolkit_name: str = "inventory",
107
+ graph_path: Optional[str] = None,
108
+ base_directory: Optional[str] = None,
109
+ source_toolkits: Optional[Dict[str, Any]] = None,
110
+ **kwargs
111
+ ) -> "InventoryRetrievalToolkit":
112
+ """
113
+ Create and return an InventoryRetrievalToolkit instance.
114
+
115
+ Args:
116
+ selected_tools: List of tool names to include (None = all tools)
117
+ toolkit_name: Name for this toolkit instance
118
+ graph_path: Path to the knowledge graph JSON file
119
+ base_directory: Base directory for local content retrieval
120
+ source_toolkits: Dict of source toolkits for remote content retrieval
121
+ **kwargs: Additional configuration
122
+
123
+ Returns:
124
+ Configured InventoryRetrievalToolkit instance
125
+ """
126
+ # Validate selected tools
127
+ if selected_tools is None:
128
+ selected_tools = cls.AVAILABLE_TOOLS
129
+ else:
130
+ selected_tools = [t for t in selected_tools if t in cls.AVAILABLE_TOOLS]
131
+ if not selected_tools:
132
+ selected_tools = cls.AVAILABLE_TOOLS
133
+
134
+ # Create API wrapper
135
+ api_wrapper = InventoryRetrievalApiWrapper(
136
+ graph_path=graph_path or kwargs.get('graph_path', ''),
137
+ base_directory=base_directory or kwargs.get('base_directory'),
138
+ source_toolkits=source_toolkits or kwargs.get('source_toolkits', {}),
139
+ )
140
+
141
+ # Get available tools from wrapper
142
+ available_tools = api_wrapper.get_available_tools()
143
+
144
+ # Build tool mapping
145
+ tool_map = {t['name']: t for t in available_tools}
146
+
147
+ # Create tools with toolkit prefix
148
+ prefix = clean_string(toolkit_name, cls.toolkit_max_length) + TOOLKIT_SPLITTER if toolkit_name else ''
149
+
150
+ tools = []
151
+ for tool_name in selected_tools:
152
+ if tool_name in tool_map:
153
+ tool_info = tool_map[tool_name]
154
+ tools.append(BaseAction(
155
+ api_wrapper=api_wrapper,
156
+ name=f"{prefix}{tool_name}",
157
+ description=tool_info['description'],
158
+ args_schema=tool_info['args_schema']
159
+ ))
160
+
161
+ return cls(tools=tools)
162
+
163
+ def get_tools(self) -> List[BaseTool]:
164
+ """Return list of tools in this toolkit."""
165
+ return self.tools
166
+
167
+
168
+ # Keep backward compatibility alias
169
+ InventoryToolkit = InventoryRetrievalToolkit