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.
Files changed (58) hide show
  1. gemcode/__init__.py +3 -0
  2. gemcode/__main__.py +3 -0
  3. gemcode/agent.py +146 -0
  4. gemcode/audit.py +16 -0
  5. gemcode/callbacks.py +473 -0
  6. gemcode/capability_routing.py +137 -0
  7. gemcode/cli.py +658 -0
  8. gemcode/compaction.py +35 -0
  9. gemcode/computer_use/__init__.py +0 -0
  10. gemcode/computer_use/browser_computer.py +275 -0
  11. gemcode/config.py +247 -0
  12. gemcode/interactions.py +15 -0
  13. gemcode/invoke.py +151 -0
  14. gemcode/kairos_daemon.py +221 -0
  15. gemcode/limits.py +83 -0
  16. gemcode/live_audio_engine.py +124 -0
  17. gemcode/mcp_loader.py +57 -0
  18. gemcode/memory/__init__.py +0 -0
  19. gemcode/memory/embedding_memory_service.py +292 -0
  20. gemcode/memory/file_memory_service.py +176 -0
  21. gemcode/modality_tools.py +216 -0
  22. gemcode/model_routing.py +179 -0
  23. gemcode/paths.py +29 -0
  24. gemcode/permissions.py +5 -0
  25. gemcode/plugins/__init__.py +0 -0
  26. gemcode/plugins/terminal_hooks_plugin.py +168 -0
  27. gemcode/plugins/tool_recovery_plugin.py +135 -0
  28. gemcode/prompt_suggestions.py +80 -0
  29. gemcode/query/__init__.py +36 -0
  30. gemcode/query/config.py +35 -0
  31. gemcode/query/deps.py +20 -0
  32. gemcode/query/engine.py +55 -0
  33. gemcode/query/stop_hooks.py +63 -0
  34. gemcode/query/token_budget.py +109 -0
  35. gemcode/query/transitions.py +41 -0
  36. gemcode/session_runtime.py +81 -0
  37. gemcode/thinking.py +136 -0
  38. gemcode/tool_prompt_manifest.py +118 -0
  39. gemcode/tool_registry.py +50 -0
  40. gemcode/tools/__init__.py +25 -0
  41. gemcode/tools/edit.py +53 -0
  42. gemcode/tools/filesystem.py +73 -0
  43. gemcode/tools/search.py +85 -0
  44. gemcode/tools/shell.py +73 -0
  45. gemcode/tools_inspector.py +132 -0
  46. gemcode/trust.py +54 -0
  47. gemcode/tui/app.py +697 -0
  48. gemcode/tui/scrollback.py +312 -0
  49. gemcode/vertex.py +22 -0
  50. gemcode/web/__init__.py +2 -0
  51. gemcode/web/claude_sse_adapter.py +282 -0
  52. gemcode/web/terminal_repl.py +147 -0
  53. gemcode-0.2.2.dist-info/METADATA +440 -0
  54. gemcode-0.2.2.dist-info/RECORD +58 -0
  55. gemcode-0.2.2.dist-info/WHEEL +5 -0
  56. gemcode-0.2.2.dist-info/entry_points.txt +2 -0
  57. gemcode-0.2.2.dist-info/licenses/LICENSE +151 -0
  58. 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
+