seed-kernel 1.0.11__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.
Files changed (60) hide show
  1. seed/__init__.py +125 -0
  2. seed/cli.py +102 -0
  3. seed/core/__init__.py +8 -0
  4. seed/core/_session_cache.py +41 -0
  5. seed/core/agent_context.py +163 -0
  6. seed/core/agent_registry.py +180 -0
  7. seed/core/agent_runtime.py +2384 -0
  8. seed/core/chat_events.py +70 -0
  9. seed/core/commands.py +149 -0
  10. seed/core/config_plane.py +537 -0
  11. seed/core/engine.py +150 -0
  12. seed/core/env_access.py +168 -0
  13. seed/core/execution.py +148 -0
  14. seed/core/llm_exec.py +1652 -0
  15. seed/core/llm_presets.py +305 -0
  16. seed/core/llm_sess.py +1094 -0
  17. seed/core/media_store.py +84 -0
  18. seed/core/mem_bridge.py +294 -0
  19. seed/core/mem_sys.py +409 -0
  20. seed/core/model_providers.py +88 -0
  21. seed/core/models.py +211 -0
  22. seed/core/paths.py +109 -0
  23. seed/core/persistence.py +133 -0
  24. seed/core/proj_reg.py +609 -0
  25. seed/core/proj_todos.py +141 -0
  26. seed/core/projection_audit.py +317 -0
  27. seed/core/routing.py +192 -0
  28. seed/core/sess_store.py +44 -0
  29. seed/core/tool_output_cap.py +122 -0
  30. seed/core/tool_runtime.py +330 -0
  31. seed/core/trace_audit.py +123 -0
  32. seed/core/turn_loop.py +750 -0
  33. seed/core/usage_accumulator.py +72 -0
  34. seed/integrations/__init__.py +33 -0
  35. seed/integrations/agent_tools.py +160 -0
  36. seed/integrations/cron_sched.py +773 -0
  37. seed/integrations/env_config.py +77 -0
  38. seed/integrations/exec_backend.py +432 -0
  39. seed/integrations/hooks.py +61 -0
  40. seed/integrations/hooks_config.py +109 -0
  41. seed/integrations/instruction_release.py +256 -0
  42. seed/integrations/lsp_client.py +219 -0
  43. seed/integrations/lsp_config.py +99 -0
  44. seed/integrations/mcp_client.py +1283 -0
  45. seed/integrations/mcp_config.py +208 -0
  46. seed/integrations/mcp_registry.py +154 -0
  47. seed/integrations/message_api.py +16 -0
  48. seed/integrations/prompt_task.py +39 -0
  49. seed/integrations/safety.py +331 -0
  50. seed/integrations/session_title.py +211 -0
  51. seed/integrations/symbol_index.py +311 -0
  52. seed/integrations/task_runner.py +275 -0
  53. seed/integrations/webhook_auth.py +33 -0
  54. seed/integrations/webhook_dedup.py +132 -0
  55. seed/models.py +31 -0
  56. seed_kernel-1.0.11.dist-info/METADATA +17 -0
  57. seed_kernel-1.0.11.dist-info/RECORD +60 -0
  58. seed_kernel-1.0.11.dist-info/WHEEL +5 -0
  59. seed_kernel-1.0.11.dist-info/entry_points.txt +2 -0
  60. seed_kernel-1.0.11.dist-info/top_level.txt +1 -0
@@ -0,0 +1,70 @@
1
+ from __future__ import annotations
2
+
3
+ from contextvars import ContextVar, Token
4
+ from typing import Any, Callable, Dict, Optional
5
+
6
+ _EMITTER: ContextVar[Optional[Callable[[Dict[str, Any]], None]]] = ContextVar(
7
+ "seed_chat_event_emitter",
8
+ default=None,
9
+ )
10
+ _CURRENT_TOOL: ContextVar[Optional[Dict[str, Any]]] = ContextVar(
11
+ "seed_current_tool_context",
12
+ default=None,
13
+ )
14
+ _CANCEL_CHECKER: ContextVar[Optional[Callable[[], bool]]] = ContextVar(
15
+ "seed_chat_cancel_checker",
16
+ default=None,
17
+ )
18
+
19
+
20
+ def set_chat_event_emitter(
21
+ emitter: Optional[Callable[[Dict[str, Any]], None]]
22
+ ) -> Token[Optional[Callable[[Dict[str, Any]], None]]]:
23
+ return _EMITTER.set(emitter)
24
+
25
+
26
+ def reset_chat_event_emitter(token: Token[Optional[Callable[[Dict[str, Any]], None]]]) -> None:
27
+ _EMITTER.reset(token)
28
+
29
+
30
+ def emit_chat_event(event: Dict[str, Any]) -> None:
31
+ emitter = _EMITTER.get()
32
+ if not emitter:
33
+ return
34
+ try:
35
+ emitter(dict(event))
36
+ except Exception:
37
+ return
38
+
39
+
40
+ def set_current_tool_context(ctx: Optional[Dict[str, Any]]) -> Token[Optional[Dict[str, Any]]]:
41
+ return _CURRENT_TOOL.set(ctx)
42
+
43
+
44
+ def reset_current_tool_context(token: Token[Optional[Dict[str, Any]]]) -> None:
45
+ _CURRENT_TOOL.reset(token)
46
+
47
+
48
+ def get_current_tool_context() -> Optional[Dict[str, Any]]:
49
+ ctx = _CURRENT_TOOL.get()
50
+ return dict(ctx) if isinstance(ctx, dict) else None
51
+
52
+
53
+ def set_chat_cancel_checker(
54
+ checker: Optional[Callable[[], bool]]
55
+ ) -> Token[Optional[Callable[[], bool]]]:
56
+ return _CANCEL_CHECKER.set(checker)
57
+
58
+
59
+ def reset_chat_cancel_checker(token: Token[Optional[Callable[[], bool]]]) -> None:
60
+ _CANCEL_CHECKER.reset(token)
61
+
62
+
63
+ def is_chat_cancelled() -> bool:
64
+ checker = _CANCEL_CHECKER.get()
65
+ if checker is None:
66
+ return False
67
+ try:
68
+ return bool(checker())
69
+ except Exception:
70
+ return False
seed/core/commands.py ADDED
@@ -0,0 +1,149 @@
1
+ """Command routing engine."""
2
+ from __future__ import annotations
3
+
4
+ import logging
5
+ from typing import List, Optional, Tuple
6
+
7
+ from seed.core.models import Command, CommandRoutingResult
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+
12
+ def tokenize_input(input_string: str) -> Tuple[str, List[str]]:
13
+ tokens = input_string.strip().split()
14
+ if not tokens:
15
+ return "", []
16
+ command_name = tokens[0]
17
+ arguments = tokens[1:] if len(tokens) > 1 else []
18
+ return command_name, arguments
19
+
20
+
21
+ def edit_distance(s1: str, s2: str) -> int:
22
+ if len(s1) < len(s2):
23
+ return edit_distance(s2, s1)
24
+ if len(s2) == 0:
25
+ return len(s1)
26
+ previous_row = range(len(s2) + 1)
27
+ for i, c1 in enumerate(s1):
28
+ current_row = [i + 1]
29
+ for j, c2 in enumerate(s2):
30
+ insertions = previous_row[j + 1] + 1
31
+ deletions = current_row[j] + 1
32
+ substitutions = previous_row[j] + (c1 != c2)
33
+ current_row.append(min(insertions, deletions, substitutions))
34
+ previous_row = current_row
35
+ return previous_row[-1]
36
+
37
+
38
+ def fuzzy_match(input_cmd: str, commands: List[Command], threshold: int = 3) -> List[str]:
39
+ suggestions: List[Tuple[int, str]] = []
40
+ input_lower = input_cmd.lower()
41
+ for cmd in commands:
42
+ if cmd.name.lower() == input_lower or any(
43
+ alias.lower() == input_lower for alias in cmd.aliases
44
+ ):
45
+ return [cmd.name]
46
+ distance = edit_distance(input_lower, cmd.name.lower())
47
+ if distance <= threshold:
48
+ suggestions.append((distance, cmd.name))
49
+ suggestions.sort(key=lambda x: x[0])
50
+ return [name for _, name in suggestions[:3]] if suggestions else []
51
+
52
+
53
+ def find_command(input_cmd: str, commands: List[Command], fuzzy_threshold: int = 3) -> CommandRoutingResult:
54
+ input_lower = input_cmd.lower().strip()
55
+ for cmd in commands:
56
+ if cmd.name.lower() == input_lower:
57
+ return CommandRoutingResult(matched=True, command=cmd, command_args=[])
58
+ for alias in cmd.aliases:
59
+ if alias.lower() == input_lower:
60
+ return CommandRoutingResult(
61
+ matched=True,
62
+ command=cmd,
63
+ command_args=[],
64
+ suggestions=[cmd.name],
65
+ )
66
+ prefix_matches = [
67
+ cmd
68
+ for cmd in commands
69
+ if cmd.name.lower().startswith(input_lower)
70
+ or any(alias.lower().startswith(input_lower) for alias in cmd.aliases)
71
+ ]
72
+ if len(prefix_matches) == 1:
73
+ return CommandRoutingResult(matched=True, command=prefix_matches[0], command_args=[])
74
+
75
+ suggestions = fuzzy_match(input_cmd, commands, fuzzy_threshold)
76
+
77
+ if prefix_matches:
78
+ names = [cmd.name for cmd in prefix_matches[:3]]
79
+ return CommandRoutingResult(
80
+ matched=False,
81
+ command=None,
82
+ command_args=[],
83
+ suggestions=names,
84
+ error=f"Ambiguous prefix match. Did you mean one of: {', '.join(names)}?",
85
+ )
86
+ if suggestions:
87
+ return CommandRoutingResult(
88
+ matched=False,
89
+ command=None,
90
+ command_args=[],
91
+ suggestions=suggestions,
92
+ error=f"Command not found. Did you mean: {', '.join(suggestions)}?",
93
+ )
94
+ return CommandRoutingResult(
95
+ matched=False,
96
+ command=None,
97
+ command_args=[],
98
+ suggestions=[],
99
+ error=f"Command '{input_cmd}' not found. Use 'commands' to see available commands.",
100
+ )
101
+
102
+
103
+ class CommandRouter:
104
+ """Register commands and route raw input strings."""
105
+
106
+ def __init__(self) -> None:
107
+ self.commands: List[Command] = []
108
+
109
+ def add_command(self, command: Command) -> None:
110
+ self.commands.append(command)
111
+
112
+ def add_commands(self, commands: List[Command]) -> None:
113
+ self.commands.extend(commands)
114
+
115
+ def remove_command(self, name: str) -> bool:
116
+ for i, cmd in enumerate(self.commands):
117
+ if cmd.name.lower() == name.lower() or any(
118
+ alias.lower() == name.lower() for alias in cmd.aliases
119
+ ):
120
+ self.commands.pop(i)
121
+ return True
122
+ return False
123
+
124
+ def get_command(self, name: str) -> Optional[Command]:
125
+ for cmd in self.commands:
126
+ if cmd.name.lower() == name.lower() or any(
127
+ alias.lower() == name.lower() for alias in cmd.aliases
128
+ ):
129
+ return cmd
130
+ return None
131
+
132
+ def list_commands(self) -> List[Command]:
133
+ return self.commands.copy()
134
+
135
+ def count_commands(self) -> int:
136
+ return len(self.commands)
137
+
138
+ def route(self, input_string: str, fuzzy_threshold: int = 3) -> CommandRoutingResult:
139
+ command_name, arguments = tokenize_input(input_string)
140
+ if not command_name:
141
+ return CommandRoutingResult(
142
+ matched=False,
143
+ command=None,
144
+ command_args=[],
145
+ error="Empty input",
146
+ )
147
+ result = find_command(command_name, self.commands, fuzzy_threshold)
148
+ result.command_args = arguments
149
+ return result