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
@@ -6,7 +6,8 @@ Provides tab completion for commands, cursor movement, and input history.
6
6
 
7
7
  import readline
8
8
  import os
9
- from typing import List, Optional
9
+ from pathlib import Path
10
+ from typing import Dict, List, Optional, Any, Callable
10
11
 
11
12
  from rich.console import Console
12
13
  from rich.text import Text
@@ -26,16 +27,74 @@ CHAT_COMMANDS = [
26
27
  '/mode auto',
27
28
  '/mode yolo',
28
29
  '/dir',
30
+ '/dir add',
31
+ '/dir rm',
32
+ '/dir remove',
33
+ '/inventory',
29
34
  '/session',
30
35
  '/session list',
31
36
  '/session resume',
32
37
  '/add_mcp',
33
38
  '/add_toolkit',
39
+ '/rm_mcp',
40
+ '/rm_toolkit',
41
+ '/reload',
34
42
  'exit',
35
43
  'quit',
36
44
  ]
37
45
 
38
46
 
47
+ # Callback to get dynamic toolkit names for completion
48
+ _toolkit_names_callback: Optional[Callable[[], List[str]]] = None
49
+
50
+ # Callback to get inventory .json files for completion
51
+ _inventory_files_callback: Optional[Callable[[], List[str]]] = None
52
+
53
+
54
+ def set_toolkit_names_callback(callback: Callable[[], List[str]]):
55
+ """
56
+ Set a callback function that returns available toolkit names.
57
+
58
+ This allows the input handler to provide dynamic completions
59
+ for /add_toolkit without having a direct dependency on config.
60
+ """
61
+ global _toolkit_names_callback
62
+ _toolkit_names_callback = callback
63
+
64
+
65
+ def set_inventory_files_callback(callback: Callable[[], List[str]]):
66
+ """
67
+ Set a callback function that returns available inventory .json files.
68
+
69
+ This allows the input handler to provide dynamic completions
70
+ for /inventory without having a direct dependency on agents.py.
71
+ """
72
+ global _inventory_files_callback
73
+ _inventory_files_callback = callback
74
+
75
+
76
+ def get_toolkit_names_for_completion() -> List[str]:
77
+ """Get toolkit names for tab completion."""
78
+ global _toolkit_names_callback
79
+ if _toolkit_names_callback:
80
+ try:
81
+ return _toolkit_names_callback()
82
+ except Exception:
83
+ return []
84
+ return []
85
+
86
+
87
+ def get_inventory_files_for_completion() -> List[str]:
88
+ """Get inventory .json files for tab completion."""
89
+ global _inventory_files_callback
90
+ if _inventory_files_callback:
91
+ try:
92
+ return _inventory_files_callback()
93
+ except Exception:
94
+ return []
95
+ return []
96
+
97
+
39
98
  class ChatInputHandler:
40
99
  """
41
100
  Enhanced input handler with readline support for chat sessions.
@@ -104,8 +163,30 @@ class ChatInputHandler:
104
163
  if line and not line.startswith('/') and text != line:
105
164
  return None
106
165
 
166
+ matches = []
167
+
168
+ # Handle /add_toolkit <name> completion
169
+ if line.startswith('/add_toolkit '):
170
+ # Get partial toolkit name being typed
171
+ toolkit_prefix = text.lower()
172
+ toolkit_names = get_toolkit_names_for_completion()
173
+ matches = [f'/add_toolkit {name}' for name in toolkit_names
174
+ if name.lower().startswith(toolkit_prefix) or toolkit_prefix == '']
175
+ # Also match just the toolkit name if text doesn't start with /
176
+ if not text.startswith('/'):
177
+ matches = [name for name in toolkit_names if name.lower().startswith(toolkit_prefix)]
178
+ # Handle /inventory <path> completion
179
+ elif line.startswith('/inventory '):
180
+ # Get partial path being typed
181
+ path_prefix = text.lower()
182
+ inventory_files = get_inventory_files_for_completion()
183
+ matches = [f'/inventory {path}' for path in inventory_files
184
+ if path.lower().startswith(path_prefix) or path_prefix == '']
185
+ # Also match just the path if text doesn't start with /
186
+ if not text.startswith('/'):
187
+ matches = [path for path in inventory_files if path.lower().startswith(path_prefix)]
107
188
  # Find matching commands
108
- if text.startswith('/'):
189
+ elif text.startswith('/'):
109
190
  matches = [cmd for cmd in CHAT_COMMANDS if cmd.startswith(text)]
110
191
  elif text == '' and line == '':
111
192
  # Show all commands on empty tab
@@ -177,13 +258,20 @@ def chat_input(prompt: str = "") -> str:
177
258
  return get_input_handler().get_input(prompt)
178
259
 
179
260
 
180
- def styled_input() -> str:
261
+ def styled_input(context_info: Optional[Dict[str, Any]] = None) -> str:
181
262
  """
182
263
  Get user input with a styled bordered prompt that works correctly with readline.
183
264
 
184
265
  The prompt is passed directly to input() so readline can properly
185
266
  handle cursor positioning and history navigation.
186
267
 
268
+ Args:
269
+ context_info: Optional context info dict with keys:
270
+ - used_tokens: Current tokens in context
271
+ - max_tokens: Maximum allowed tokens
272
+ - fill_ratio: Context fill ratio (0.0-1.0)
273
+ - pruned_count: Number of pruned messages
274
+
187
275
  Returns:
188
276
  The user's input string
189
277
  """
@@ -193,11 +281,28 @@ def styled_input() -> str:
193
281
  except Exception:
194
282
  width = 78
195
283
 
284
+ # Build context indicator if provided
285
+ context_indicator = ""
286
+ if context_info and context_info.get('max_tokens', 0) > 0:
287
+ context_indicator = _format_context_indicator(
288
+ context_info.get('used_tokens', 0),
289
+ context_info.get('max_tokens', 8000),
290
+ context_info.get('fill_ratio', 0.0),
291
+ context_info.get('pruned_count', 0),
292
+ )
293
+
196
294
  # Print the complete box frame first, then move cursor up to input line
197
295
  console.print()
198
296
  console.print(f"[dim]╭{'─' * width}╮[/dim]")
199
297
  console.print(f"[dim]│[/dim]{' ' * width}[dim]│[/dim]")
200
- console.print(f"[dim]╰{'─' * width}╯[/dim]")
298
+
299
+ # Bottom border with context indicator on the right
300
+ if context_indicator:
301
+ indicator_len = len(_strip_ansi(context_indicator))
302
+ padding = width - indicator_len - 1
303
+ console.print(f"[dim]╰{'─' * padding}[/dim]{context_indicator}[dim]─╯[/dim]")
304
+ else:
305
+ console.print(f"[dim]╰{'─' * width}╯[/dim]")
201
306
 
202
307
  # Move cursor up 2 lines and to position after "│ > "
203
308
  # \033[2A = move up 2 lines, \033[4C = move right 4 columns
@@ -211,6 +316,64 @@ def styled_input() -> str:
211
316
  return user_input
212
317
 
213
318
 
319
+ def _format_context_indicator(
320
+ used_tokens: int,
321
+ max_tokens: int,
322
+ fill_ratio: float,
323
+ pruned_count: int = 0
324
+ ) -> str:
325
+ """
326
+ Format context usage indicator for display.
327
+
328
+ Shows: [1234/8000 ██████░░░░ 15%]
329
+ Color coded: green <70%, yellow 70-90%, red >90%
330
+
331
+ Args:
332
+ used_tokens: Current tokens in context
333
+ max_tokens: Maximum allowed tokens
334
+ fill_ratio: Context fill ratio (0.0-1.0)
335
+ pruned_count: Number of pruned messages
336
+
337
+ Returns:
338
+ Formatted indicator string with ANSI colors
339
+ """
340
+ # Determine color based on fill ratio
341
+ if fill_ratio < 0.7:
342
+ color = "green"
343
+ elif fill_ratio < 0.9:
344
+ color = "yellow"
345
+ else:
346
+ color = "red"
347
+
348
+ # Build progress bar (10 chars)
349
+ bar_width = 10
350
+ filled = int(fill_ratio * bar_width)
351
+ empty = bar_width - filled
352
+ bar = "█" * filled + "░" * empty
353
+
354
+ # Format percentage
355
+ percent = int(fill_ratio * 100)
356
+
357
+ # Build indicator
358
+ indicator = f"[{color}]{used_tokens}/{max_tokens} {bar} {percent}%[/{color}]"
359
+
360
+ # Add pruned count if any
361
+ if pruned_count > 0:
362
+ indicator += f" [dim]({pruned_count} pruned)[/dim]"
363
+
364
+ return indicator
365
+
366
+
367
+ def _strip_ansi(text: str) -> str:
368
+ """Strip ANSI escape codes and Rich markup from text for length calculation."""
369
+ import re
370
+ # Remove Rich markup tags like [green], [/green], [dim], etc.
371
+ text = re.sub(r'\[/?[^\]]+\]', '', text)
372
+ # Remove ANSI escape codes
373
+ text = re.sub(r'\x1b\[[0-9;]*m', '', text)
374
+ return text
375
+
376
+
214
377
  def styled_selection_input(prompt_text: str = "Select") -> str:
215
378
  """
216
379
  Get user selection input with a styled bordered prompt.