ge150-linux 0.3.0__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 (98) hide show
  1. ge150/__init__.py +6 -0
  2. ge150/__main__.py +7 -0
  3. ge150/cli.py +257 -0
  4. ge150/cli_ai.py +71 -0
  5. ge150/cli_edit.py +457 -0
  6. ge150/cli_hw.py +66 -0
  7. ge150/cli_settings.py +120 -0
  8. ge150/cli_t3k.py +104 -0
  9. ge150/data/__init__.py +0 -0
  10. ge150/data/chevron-down.svg +1 -0
  11. ge150/data/effects.json +195 -0
  12. ge150/data/ge150.svg +22 -0
  13. ge150/data/gear.json +147 -0
  14. ge150/formats/__init__.py +1 -0
  15. ge150/formats/amp_nr.py +70 -0
  16. ge150/formats/mbf.py +185 -0
  17. ge150/formats/mo_json.py +157 -0
  18. ge150/formats/wav_ir.py +160 -0
  19. ge150/mcp_server/__init__.py +1 -0
  20. ge150/mcp_server/bridge.py +187 -0
  21. ge150/mcp_server/install.py +40 -0
  22. ge150/mcp_server/server.py +245 -0
  23. ge150/mcp_server/tools.py +494 -0
  24. ge150/model/__init__.py +1 -0
  25. ge150/model/catalog.py +118 -0
  26. ge150/model/device_state.py +214 -0
  27. ge150/model/gear.py +107 -0
  28. ge150/model/preset.py +158 -0
  29. ge150/model/settings.py +145 -0
  30. ge150/protocol/__init__.py +1 -0
  31. ge150/protocol/crc.py +28 -0
  32. ge150/protocol/framing.py +154 -0
  33. ge150/protocol/messages.py +262 -0
  34. ge150/protocol/opcodes.py +121 -0
  35. ge150/protocol/session.py +323 -0
  36. ge150/services/__init__.py +1 -0
  37. ge150/services/ai_permissions.py +76 -0
  38. ge150/services/auto_backup.py +63 -0
  39. ge150/services/backup.py +111 -0
  40. ge150/services/bulk_edit.py +276 -0
  41. ge150/services/chat_history.py +147 -0
  42. ge150/services/editor.py +303 -0
  43. ge150/services/guitars.py +255 -0
  44. ge150/services/hw_check.py +329 -0
  45. ge150/services/reader.py +126 -0
  46. ge150/services/tone3000.py +474 -0
  47. ge150/services/tone_agent.py +246 -0
  48. ge150/services/tone_ai.py +467 -0
  49. ge150/sim/__init__.py +1 -0
  50. ge150/sim/fake_device.py +250 -0
  51. ge150/sim/sim_transport.py +63 -0
  52. ge150/ui/__init__.py +1 -0
  53. ge150/ui/ab_compare.py +105 -0
  54. ge150/ui/about_dialog.py +246 -0
  55. ge150/ui/ai_chat.py +682 -0
  56. ge150/ui/ai_host.py +104 -0
  57. ge150/ui/ai_options.py +136 -0
  58. ge150/ui/ai_panel.py +23 -0
  59. ge150/ui/ai_permissions_dialog.py +161 -0
  60. ge150/ui/amp_art.py +549 -0
  61. ge150/ui/app.py +76 -0
  62. ge150/ui/art_spec.py +298 -0
  63. ge150/ui/assistant_page.py +360 -0
  64. ge150/ui/bridge.py +34 -0
  65. ge150/ui/bulk_form.py +416 -0
  66. ge150/ui/bulk_review.py +352 -0
  67. ge150/ui/chain_view.py +474 -0
  68. ge150/ui/chat_history.py +222 -0
  69. ge150/ui/dialogs.py +221 -0
  70. ge150/ui/gear_art.py +515 -0
  71. ge150/ui/gear_view.py +134 -0
  72. ge150/ui/guitar_dialog.py +397 -0
  73. ge150/ui/icons.py +63 -0
  74. ge150/ui/knob.py +211 -0
  75. ge150/ui/main_window.py +537 -0
  76. ge150/ui/markdown.py +55 -0
  77. ge150/ui/mic_view.py +392 -0
  78. ge150/ui/model_gallery.py +199 -0
  79. ge150/ui/module_editor.py +303 -0
  80. ge150/ui/preset_list.py +133 -0
  81. ge150/ui/settings_dialog.py +149 -0
  82. ge150/ui/theme.py +319 -0
  83. ge150/ui/tone3000_loader.py +102 -0
  84. ge150/ui/tone3000_page.py +325 -0
  85. ge150/ui/tone_detail.py +151 -0
  86. ge150/ui/worker.py +84 -0
  87. ge150/ui/working.py +117 -0
  88. ge150/usb/__init__.py +19 -0
  89. ge150/usb/device_ids.py +28 -0
  90. ge150/usb/hidraw_transport.py +122 -0
  91. ge150/usb/transport.py +33 -0
  92. ge150/usb/usb_transport.py +83 -0
  93. ge150_linux-0.3.0.dist-info/METADATA +252 -0
  94. ge150_linux-0.3.0.dist-info/RECORD +98 -0
  95. ge150_linux-0.3.0.dist-info/WHEEL +5 -0
  96. ge150_linux-0.3.0.dist-info/entry_points.txt +4 -0
  97. ge150_linux-0.3.0.dist-info/licenses/LICENSE +21 -0
  98. ge150_linux-0.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,245 @@
1
+ """``ge150-mcp``: MCP server (stdio) that lets Claude Code, Codex or any MCP client drive
2
+ the pedal through :class:`~ge150.mcp_server.tools.PedalTools`.
3
+
4
+ ge150-mcp # the GE150 editor if it is open, else the pedal on USB
5
+ ge150-mcp --sim # the built-in simulator when the editor is not open
6
+
7
+ Only one program may own the pedal. When the GE150 editor is open this server forwards every
8
+ call to it (``bridge.py``): the GUI shows the AI's changes at once and asks the user before
9
+ anything is stored. Otherwise it opens the pedal itself and storing is refused.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import argparse
15
+ import logging
16
+ import sys
17
+ from collections.abc import Callable
18
+ from typing import Any, TypeVar
19
+
20
+ from mcp.server.mcpserver import MCPServer
21
+ from mcp.server.mcpserver.exceptions import ToolError as MCPToolError
22
+ from mcp.types import ToolAnnotations
23
+ from pydantic import BaseModel, Field
24
+
25
+ from ge150 import __version__
26
+ from ge150.mcp_server.tools import INSTRUCTIONS, GuardedTools, PedalTools, ToolError
27
+
28
+ T = TypeVar("T")
29
+ READ = ToolAnnotations(read_only_hint=True, idempotent_hint=True, open_world_hint=False)
30
+ LIVE = ToolAnnotations(read_only_hint=False, destructive_hint=False, open_world_hint=False)
31
+ STORE = ToolAnnotations(read_only_hint=False, destructive_hint=True, open_world_hint=False)
32
+ WEB = ToolAnnotations(read_only_hint=True, idempotent_hint=True, open_world_hint=True)
33
+ WEB_STORE = ToolAnnotations(read_only_hint=False, destructive_hint=True, open_world_hint=True)
34
+
35
+
36
+ class ParamValue(BaseModel):
37
+ name: str = Field(description="parameter name from get_catalog, e.g. GAIN")
38
+ value: str = Field(description="display value, e.g. 65, -3.5, 380 or an enum option")
39
+
40
+
41
+ class ModuleSetting(BaseModel):
42
+ module: str = Field(description="FX, DS, AMP, CAB, NS, EQ, MOD, DELAY or REVERB")
43
+ on: bool
44
+ model: str = Field("", description="model name from get_catalog; empty keeps the current")
45
+ params: list[ParamValue] = Field(default_factory=list)
46
+
47
+
48
+ class PresetModuleEdit(BaseModel):
49
+ module: str = Field(description="FX, DS, AMP, CAB, NS, EQ, MOD, DELAY or REVERB")
50
+ on: bool | None = Field(None, description="omit to keep the preset's on/off")
51
+ model: str = Field("", description="model name from get_catalog; empty keeps the current")
52
+ params: list[ParamValue] = Field(default_factory=list)
53
+
54
+
55
+ class PresetEditSpec(BaseModel):
56
+ slot: int = Field(description="stored preset number 1..200")
57
+ name: str = Field("", description="new name for the preset (up to 14 chars: letters, "
58
+ "digits, '-' and space); empty keeps it")
59
+ copy_from: int = Field(0, description="start from the stored content of this other "
60
+ "preset (its name comes too unless name is given): moves or "
61
+ "reorders presets, e.g. crossed copy_from swaps two; 0 = its own")
62
+ modules: list[PresetModuleEdit] = Field(default_factory=list)
63
+
64
+
65
+ def _call(fn: Callable[[], T]) -> T:
66
+ try:
67
+ return fn()
68
+ except ToolError as exc:
69
+ raise MCPToolError(str(exc)) from exc
70
+
71
+
72
+ def build_server(tools: PedalTools | Any) -> MCPServer:
73
+ """``tools``: a :class:`PedalTools` or a proxy with the same methods (``bridge.py``)."""
74
+ server: MCPServer = MCPServer("ge150", title="MOOER GE150", version=__version__,
75
+ instructions=INSTRUCTIONS)
76
+
77
+ @server.tool(annotations=READ)
78
+ def get_catalog(module: str = "") -> dict[str, Any]:
79
+ """Modules of the pedal, or the models of one module (with the real gear each one
80
+ is based on and the name, range and options of every parameter)."""
81
+ return _call(lambda: tools.get_catalog(module))
82
+
83
+ @server.tool(annotations=READ)
84
+ def get_current_patch() -> dict[str, Any]:
85
+ """The sound loaded now: every module (on/off, model, parameter values), the preset
86
+ slot and name, and whether it has unsaved changes."""
87
+ return _call(tools.get_current_patch)
88
+
89
+ @server.tool(annotations=READ)
90
+ def list_presets(query: str = "") -> dict[str, Any]:
91
+ """The 200 stored presets (slot and name), optionally filtered by text."""
92
+ return _call(lambda: tools.list_presets(query))
93
+
94
+ @server.tool(annotations=READ)
95
+ def get_preset(slot: int) -> dict[str, Any]:
96
+ """A stored preset decoded (without loading it)."""
97
+ return _call(lambda: tools.get_preset(slot))
98
+
99
+ @server.tool(annotations=READ)
100
+ def list_user_irs() -> dict[str, Any]:
101
+ """Names of the user cabinet IR slots (CAB 27-36)."""
102
+ return _call(tools.list_user_irs)
103
+
104
+ @server.tool(annotations=READ)
105
+ def get_guitar() -> dict[str, Any]:
106
+ """The guitar the user is playing (brand, model, year, woods, pickups, electronics,
107
+ strings, tuning), as registered in the GE150 editor. Its pickups and woods shape how
108
+ much gain, EQ and brightness a patch needs."""
109
+ return _call(tools.get_guitar)
110
+
111
+ @server.tool(annotations=READ)
112
+ def get_settings() -> dict[str, Any]:
113
+ """System settings (input/OTG level, screen, CAB SIM THRU) and the rhythm box."""
114
+ return _call(tools.get_settings)
115
+
116
+ @server.tool(annotations=LIVE)
117
+ def set_module(module: str, on: bool | None = None, model: str = "",
118
+ params: list[ParamValue] | None = None) -> dict[str, Any]:
119
+ """Change one module live: switch it on/off, pick a model and set parameters.
120
+ Not saved; undo reverts it."""
121
+ values = {p.name: p.value for p in params or []}
122
+ return _call(lambda: tools.set_module(module, on, model, values))
123
+
124
+ @server.tool(annotations=LIVE)
125
+ def apply_patch(modules: list[ModuleSetting], name: str = "") -> dict[str, Any]:
126
+ """Set several modules at once (a whole sound). Modules not listed are unchanged.
127
+ Not saved; undo reverts it."""
128
+ data = [m.model_dump() for m in modules]
129
+ return _call(lambda: tools.apply_patch(data, name))
130
+
131
+ @server.tool(annotations=LIVE)
132
+ def undo() -> dict[str, Any]:
133
+ """Go back to the sound before the last set_module/apply_patch of this session."""
134
+ return _call(tools.undo)
135
+
136
+ @server.tool(annotations=LIVE)
137
+ def select_preset(slot: int, discard_changes: bool = False) -> dict[str, Any]:
138
+ """Load a stored preset. If the current one has unsaved changes, ask the user first
139
+ and pass discard_changes=true only if they agree."""
140
+ return _call(lambda: tools.select_preset(slot, discard_changes))
141
+
142
+ @server.tool(annotations=READ)
143
+ def get_presets(query: str) -> dict[str, Any]:
144
+ """Every stored preset whose name contains query (e.g. "av83"), decoded, in one
145
+ call."""
146
+ return _call(lambda: tools.get_presets(query))
147
+
148
+ @server.tool(annotations=LIVE)
149
+ def propose_preset_edits(edits: list[PresetEditSpec], summary: str = "") -> dict[str, Any]:
150
+ """Propose changes to several STORED presets at once (values per preset, so
151
+ relative changes like "-10 %" are computed by you from get_presets): effects,
152
+ names (name) and order (copy_from moves a preset's content to another slot).
153
+ Nothing is written: the GE150 editor shows a review table and the user applies or
154
+ discards. summary: one line for the user."""
155
+ data = [e.model_dump() for e in edits]
156
+ return _call(lambda: tools.propose_preset_edits(data, summary))
157
+
158
+ @server.tool(annotations=STORE)
159
+ def save_preset(slot: int = 0, name: str = "") -> dict[str, Any]:
160
+ """Store the current sound in preset ``slot`` (0 = the current one), optionally
161
+ renamed (up to 14 chars). The GE150 editor asks the user to confirm; only when
162
+ the user asked to save."""
163
+ return _call(lambda: tools.save_preset(slot, name))
164
+
165
+ @server.tool(annotations=WEB)
166
+ def tone3000_search(query: str) -> dict[str, Any]:
167
+ """Search cabinet IRs on TONE3000 (e.g. "Marshall 1960 V30"). Rate-limited: few,
168
+ precise searches."""
169
+ return _call(lambda: tools.tone3000_search(query))
170
+
171
+ @server.tool(annotations=WEB)
172
+ def tone3000_get(tone_id: int) -> dict[str, Any]:
173
+ """A TONE3000 tone: title, author, licence and its IR files."""
174
+ return _call(lambda: tools.tone3000_get(tone_id))
175
+
176
+ @server.tool(annotations=WEB_STORE)
177
+ def load_tone3000_ir(slot: int = 0, tone_id: int = 0, model_id: int = 0,
178
+ name: str = "", use: bool = True) -> dict[str, Any]:
179
+ """Download a TONE3000 IR, store it in a user IR slot (CAB 27..36) and select it
180
+ in the CAB module (live; use=false only stores it). slot 0 = automatic: the slot
181
+ already holding this IR, else a free one, else the editor asks the user which one
182
+ to overwrite. tone_id 0 opens the TONE3000 catalogue so the user picks one. The
183
+ GE150 editor asks the user to confirm."""
184
+ return _call(lambda: tools.load_tone3000_ir(slot, tone_id, model_id, name, use))
185
+
186
+ return server
187
+
188
+
189
+ def _open_editor(args: argparse.Namespace) -> Any:
190
+ from ge150.protocol.session import DeviceSession
191
+ from ge150.services.editor import Editor
192
+
193
+ if args.sim:
194
+ from ge150.sim.sim_transport import SimTransport
195
+
196
+ transport: Any = SimTransport()
197
+ else:
198
+ from ge150.usb import open_transport
199
+
200
+ transport = open_transport(args.backend, args.device)
201
+ session = DeviceSession(transport).start()
202
+ editor = Editor(session)
203
+ editor.sync()
204
+ return session, editor
205
+
206
+
207
+ def main(argv: list[str] | None = None) -> int:
208
+ parser = argparse.ArgumentParser(prog="ge150-mcp", description=__doc__.splitlines()[0])
209
+ parser.add_argument("--sim", action="store_true", help="use the built-in simulator")
210
+ parser.add_argument("--backend", choices=("auto", "hidraw", "usb"), default="auto")
211
+ parser.add_argument("--device", help="hidraw node, e.g. /dev/hidraw4")
212
+ parser.add_argument("--standalone", action="store_true",
213
+ help="open the pedal even if the GE150 editor is running")
214
+ parser.add_argument("--editor-only", action="store_true",
215
+ help="only forward to the GE150 editor; never open the pedal (used by "
216
+ "the editor's own AI panel)")
217
+ parser.add_argument("-v", "--verbose", action="store_true")
218
+ args = parser.parse_args(argv)
219
+ # stdout carries the MCP protocol: every log goes to stderr.
220
+ logging.basicConfig(stream=sys.stderr,
221
+ level=logging.DEBUG if args.verbose else logging.WARNING)
222
+ from ge150.mcp_server.bridge import find_editor
223
+
224
+ remote = None if args.standalone else find_editor()
225
+ if remote is not None:
226
+ logging.info("forwarding to the GE150 editor at %s", remote.url)
227
+ build_server(remote).run("stdio")
228
+ return 0
229
+ if args.editor_only:
230
+ print("ge150-mcp: the GE150 editor is not answering (--editor-only)", file=sys.stderr)
231
+ return 1
232
+ try:
233
+ session, editor = _open_editor(args)
234
+ except Exception as exc:
235
+ print(f"ge150-mcp: cannot open the pedal: {exc}", file=sys.stderr)
236
+ return 1
237
+ try:
238
+ build_server(GuardedTools(PedalTools(editor))).run("stdio")
239
+ finally:
240
+ session.close()
241
+ return 0
242
+
243
+
244
+ if __name__ == "__main__":
245
+ raise SystemExit(main())