gemcode 0.2.2__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.
- gemcode/__init__.py +3 -0
- gemcode/__main__.py +3 -0
- gemcode/agent.py +146 -0
- gemcode/audit.py +16 -0
- gemcode/callbacks.py +473 -0
- gemcode/capability_routing.py +137 -0
- gemcode/cli.py +658 -0
- gemcode/compaction.py +35 -0
- gemcode/computer_use/__init__.py +0 -0
- gemcode/computer_use/browser_computer.py +275 -0
- gemcode/config.py +247 -0
- gemcode/interactions.py +15 -0
- gemcode/invoke.py +151 -0
- gemcode/kairos_daemon.py +221 -0
- gemcode/limits.py +83 -0
- gemcode/live_audio_engine.py +124 -0
- gemcode/mcp_loader.py +57 -0
- gemcode/memory/__init__.py +0 -0
- gemcode/memory/embedding_memory_service.py +292 -0
- gemcode/memory/file_memory_service.py +176 -0
- gemcode/modality_tools.py +216 -0
- gemcode/model_routing.py +179 -0
- gemcode/paths.py +29 -0
- gemcode/permissions.py +5 -0
- gemcode/plugins/__init__.py +0 -0
- gemcode/plugins/terminal_hooks_plugin.py +168 -0
- gemcode/plugins/tool_recovery_plugin.py +135 -0
- gemcode/prompt_suggestions.py +80 -0
- gemcode/query/__init__.py +36 -0
- gemcode/query/config.py +35 -0
- gemcode/query/deps.py +20 -0
- gemcode/query/engine.py +55 -0
- gemcode/query/stop_hooks.py +63 -0
- gemcode/query/token_budget.py +109 -0
- gemcode/query/transitions.py +41 -0
- gemcode/session_runtime.py +81 -0
- gemcode/thinking.py +136 -0
- gemcode/tool_prompt_manifest.py +118 -0
- gemcode/tool_registry.py +50 -0
- gemcode/tools/__init__.py +25 -0
- gemcode/tools/edit.py +53 -0
- gemcode/tools/filesystem.py +73 -0
- gemcode/tools/search.py +85 -0
- gemcode/tools/shell.py +73 -0
- gemcode/tools_inspector.py +132 -0
- gemcode/trust.py +54 -0
- gemcode/tui/app.py +697 -0
- gemcode/tui/scrollback.py +312 -0
- gemcode/vertex.py +22 -0
- gemcode/web/__init__.py +2 -0
- gemcode/web/claude_sse_adapter.py +282 -0
- gemcode/web/terminal_repl.py +147 -0
- gemcode-0.2.2.dist-info/METADATA +440 -0
- gemcode-0.2.2.dist-info/RECORD +58 -0
- gemcode-0.2.2.dist-info/WHEEL +5 -0
- gemcode-0.2.2.dist-info/entry_points.txt +2 -0
- gemcode-0.2.2.dist-info/licenses/LICENSE +151 -0
- gemcode-0.2.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Capability-based routing (Claude Code style conceptually).
|
|
3
|
+
|
|
4
|
+
This layer decides which *capabilities* to enable (deep research tools,
|
|
5
|
+
embeddings retrieval, computer-use tools) and leaves the existing Claude-like
|
|
6
|
+
outer/inner loops intact.
|
|
7
|
+
|
|
8
|
+
It is intentionally conservative:
|
|
9
|
+
- It only enables capabilities (turns them on), it does not disable
|
|
10
|
+
explicitly requested capabilities.
|
|
11
|
+
- Computer-use model selection is enforced at model-routing precedence, and
|
|
12
|
+
tool execution remains permission-gated via `callbacks.py`.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import re
|
|
18
|
+
|
|
19
|
+
from gemcode.config import GemCodeConfig
|
|
20
|
+
|
|
21
|
+
CapabilityMode = str # "auto|research|embeddings|computer|audio|all"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
_RESEARCH_TRIGGERS = [
|
|
25
|
+
"deep research",
|
|
26
|
+
"deep-dive",
|
|
27
|
+
"research",
|
|
28
|
+
"citations",
|
|
29
|
+
"sources",
|
|
30
|
+
"grounded",
|
|
31
|
+
"investigate",
|
|
32
|
+
"literature",
|
|
33
|
+
"benchmark",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
_EMBEDDINGS_TRIGGERS = [
|
|
37
|
+
"embedding",
|
|
38
|
+
"embeddings",
|
|
39
|
+
"semantic search",
|
|
40
|
+
"similarity",
|
|
41
|
+
"vector",
|
|
42
|
+
"rag",
|
|
43
|
+
"retrieve",
|
|
44
|
+
"relevant docs",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
_COMPUTER_TRIGGERS = [
|
|
48
|
+
"click",
|
|
49
|
+
"button",
|
|
50
|
+
"double click",
|
|
51
|
+
"type into",
|
|
52
|
+
"navigate",
|
|
53
|
+
"browser",
|
|
54
|
+
"open website",
|
|
55
|
+
"scroll",
|
|
56
|
+
"ui automation",
|
|
57
|
+
"open tab",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
_AUDIO_TRIGGERS = [
|
|
61
|
+
"audio",
|
|
62
|
+
"voice",
|
|
63
|
+
"microphone",
|
|
64
|
+
"speak",
|
|
65
|
+
"listen",
|
|
66
|
+
"tts",
|
|
67
|
+
"tts preview",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _contains_any(haystack: str, needles: list[str]) -> bool:
|
|
72
|
+
h = haystack.lower()
|
|
73
|
+
return any(n in h for n in needles)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def apply_capability_routing(
|
|
77
|
+
cfg: GemCodeConfig,
|
|
78
|
+
prompt: str,
|
|
79
|
+
*,
|
|
80
|
+
context: str = "prompt",
|
|
81
|
+
) -> None:
|
|
82
|
+
"""
|
|
83
|
+
Mutates `cfg` in-place:
|
|
84
|
+
- sets `enable_deep_research`, `enable_embeddings`, `enable_computer_use`
|
|
85
|
+
- sets `enable_audio` only when context is `live-audio`
|
|
86
|
+
"""
|
|
87
|
+
mode = (getattr(cfg, "capability_mode", "auto") or "auto").lower()
|
|
88
|
+
p_norm = re.sub(r"\s+", " ", prompt or "").strip().lower()
|
|
89
|
+
|
|
90
|
+
def enable_research() -> None:
|
|
91
|
+
cfg.enable_deep_research = True
|
|
92
|
+
|
|
93
|
+
def enable_embeddings() -> None:
|
|
94
|
+
cfg.enable_embeddings = True
|
|
95
|
+
|
|
96
|
+
def enable_computer() -> None:
|
|
97
|
+
cfg.enable_computer_use = True
|
|
98
|
+
|
|
99
|
+
def enable_audio() -> None:
|
|
100
|
+
if context == "live-audio":
|
|
101
|
+
cfg.enable_audio = True
|
|
102
|
+
|
|
103
|
+
# User-selected mode.
|
|
104
|
+
if mode == "research":
|
|
105
|
+
enable_research()
|
|
106
|
+
return
|
|
107
|
+
if mode == "embeddings":
|
|
108
|
+
enable_embeddings()
|
|
109
|
+
return
|
|
110
|
+
if mode == "computer":
|
|
111
|
+
enable_computer()
|
|
112
|
+
return
|
|
113
|
+
if mode == "audio":
|
|
114
|
+
enable_audio()
|
|
115
|
+
return
|
|
116
|
+
if mode == "all":
|
|
117
|
+
enable_research()
|
|
118
|
+
enable_embeddings()
|
|
119
|
+
enable_computer()
|
|
120
|
+
enable_audio()
|
|
121
|
+
return
|
|
122
|
+
|
|
123
|
+
# Auto mode: prompt heuristics.
|
|
124
|
+
if mode == "auto":
|
|
125
|
+
if _contains_any(p_norm, _RESEARCH_TRIGGERS):
|
|
126
|
+
enable_research()
|
|
127
|
+
if _contains_any(p_norm, _EMBEDDINGS_TRIGGERS):
|
|
128
|
+
enable_embeddings()
|
|
129
|
+
if _contains_any(p_norm, _COMPUTER_TRIGGERS):
|
|
130
|
+
enable_computer()
|
|
131
|
+
if _contains_any(p_norm, _AUDIO_TRIGGERS):
|
|
132
|
+
enable_audio()
|
|
133
|
+
return
|
|
134
|
+
|
|
135
|
+
# Unknown mode: do nothing.
|
|
136
|
+
return
|
|
137
|
+
|