livepilot 1.27.0 → 1.27.2

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 (66) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +26 -7
  3. package/bin/livepilot.js +86 -23
  4. package/installer/install.js +21 -12
  5. package/livepilot/.Codex-plugin/plugin.json +1 -1
  6. package/livepilot/.claude-plugin/plugin.json +1 -1
  7. package/livepilot/skills/livepilot-core/SKILL.md +8 -8
  8. package/livepilot/skills/livepilot-core/references/overview.md +2 -2
  9. package/livepilot/skills/livepilot-evaluation/references/capability-modes.md +1 -1
  10. package/m4l_device/LivePilot_Analyzer.amxd +0 -0
  11. package/m4l_device/livepilot_bridge.js +48 -11
  12. package/mcp_server/__init__.py +1 -1
  13. package/mcp_server/atlas/__init__.py +20 -1
  14. package/mcp_server/atlas/tools.py +83 -22
  15. package/mcp_server/composer/fast/brief_builder.py +6 -2
  16. package/mcp_server/composer/full/apply.py +9 -0
  17. package/mcp_server/composer/full/layer_planner.py +16 -6
  18. package/mcp_server/composer/tools.py +12 -6
  19. package/mcp_server/connection.py +2 -1
  20. package/mcp_server/creative_constraints/engine.py +46 -0
  21. package/mcp_server/experiment/engine.py +10 -3
  22. package/mcp_server/grader/client.py +30 -2
  23. package/mcp_server/grader/tools.py +8 -2
  24. package/mcp_server/hook_hunter/analyzer.py +15 -2
  25. package/mcp_server/m4l_bridge.py +145 -54
  26. package/mcp_server/memory/taste_graph.py +16 -0
  27. package/mcp_server/memory/technique_store.py +23 -3
  28. package/mcp_server/mix_engine/state_builder.py +4 -2
  29. package/mcp_server/musical_intelligence/detectors.py +11 -2
  30. package/mcp_server/musical_intelligence/tools.py +15 -2
  31. package/mcp_server/preview_studio/engine.py +30 -1
  32. package/mcp_server/project_brain/tools.py +56 -52
  33. package/mcp_server/reference_engine/tools.py +22 -2
  34. package/mcp_server/runtime/execution_router.py +6 -0
  35. package/mcp_server/runtime/live_version.py +27 -8
  36. package/mcp_server/runtime/mcp_dispatch.py +22 -0
  37. package/mcp_server/runtime/remote_commands.py +9 -4
  38. package/mcp_server/runtime/safety_kernel.py +11 -0
  39. package/mcp_server/sample_engine/critics.py +7 -3
  40. package/mcp_server/sample_engine/slice_workflow.py +3 -2
  41. package/mcp_server/sample_engine/tools.py +53 -21
  42. package/mcp_server/server.py +1 -1
  43. package/mcp_server/song_brain/builder.py +17 -1
  44. package/mcp_server/sound_design/tools.py +1 -1
  45. package/mcp_server/splice_client/http_bridge.py +43 -1
  46. package/mcp_server/splice_client/models.py +7 -3
  47. package/mcp_server/synthesis_brain/adapters/analog.py +13 -1
  48. package/mcp_server/synthesis_brain/adapters/operator.py +5 -2
  49. package/mcp_server/synthesis_brain/adapters/wavetable.py +4 -4
  50. package/mcp_server/tools/_composition_engine/models.py +6 -0
  51. package/mcp_server/tools/_composition_engine/sections.py +4 -0
  52. package/mcp_server/tools/clips.py +5 -4
  53. package/mcp_server/tools/composition.py +5 -1
  54. package/mcp_server/tools/midi_io.py +40 -1
  55. package/mcp_server/tools/transport.py +1 -1
  56. package/mcp_server/user_corpus/plugin_engine/detector.py +66 -11
  57. package/mcp_server/user_corpus/runner.py +7 -1
  58. package/mcp_server/user_corpus/scanners/amxd.py +24 -13
  59. package/mcp_server/user_corpus/tools.py +45 -9
  60. package/mcp_server/wonder_mode/tools.py +66 -27
  61. package/package.json +1 -1
  62. package/remote_script/LivePilot/__init__.py +21 -8
  63. package/remote_script/LivePilot/server.py +23 -3
  64. package/remote_script/LivePilot/tracks.py +11 -5
  65. package/requirements.txt +1 -1
  66. package/server.json +2 -2
@@ -185,10 +185,14 @@ class SpliceSample:
185
185
  def is_free(self) -> bool:
186
186
  """True iff this sample costs no credits under any plan.
187
187
 
188
- Splice marks samples as free via `IsPremium == False` or `Price == 0`.
189
- This is orthogonal to plan: even a free-tier user can license these.
188
+ `IsPremium` is Splice's authoritative free flag and is always
189
+ populated in the proto. `Price` is NOT reliable: proto3 ints
190
+ default to 0 when the server omits the field, so OR-ing in
191
+ `price == 0` would misclassify premium samples (whose Price is
192
+ unset/zero) as free and bypass ALL credit/quota gating. Trust
193
+ only `IsPremium`.
190
194
  """
191
- return (not self.is_premium) or self.price == 0
195
+ return not self.is_premium
192
196
 
193
197
  def to_dict(self) -> dict:
194
198
  return {
@@ -9,9 +9,12 @@ detune/unison variants and dual-filter variants.
9
9
  from __future__ import annotations
10
10
 
11
11
  import hashlib
12
+ import logging
12
13
  from typing import Optional
13
14
 
14
15
  from ...branches import BranchSeed, freeform_seed
16
+
17
+ logger = logging.getLogger(__name__)
15
18
  from ..models import (
16
19
  SynthProfile,
17
20
  TimbralFingerprint,
@@ -115,7 +118,16 @@ class AnalogAdapter:
115
118
  try:
116
119
  maybe = strategy_fn(profile, target, kernel, adapter=self)
117
120
  except Exception:
118
- # Never let one strategy's crash kill the rest.
121
+ # Never let one strategy's crash kill the rest, but make the
122
+ # swallowed failure observable instead of silently degrading
123
+ # the branch set.
124
+ logger.warning(
125
+ "Analog strategy %s crashed on track %s device %s; skipping",
126
+ getattr(strategy_fn, "__name__", strategy_fn),
127
+ profile.track_index,
128
+ profile.device_index,
129
+ exc_info=True,
130
+ )
119
131
  continue
120
132
  if maybe is not None:
121
133
  results.append(maybe)
@@ -103,8 +103,11 @@ def _pick_target_modulator(
103
103
  return None
104
104
  candidates.sort(reverse=True) # highest level first
105
105
  top_level, top_op = candidates[0]
106
- # If every modulator is silent, still return the first one the shift
107
- # primes the patch for a future Level bump. Better than no branch.
106
+ # If every modulator is silent (Level <= 0), shifting its Coarse produces
107
+ # no audible change. Return None so the caller falls through to
108
+ # _fallback_carrier_target and targets an audible carrier instead.
109
+ if top_level <= 0.0:
110
+ return None
108
111
  return top_op
109
112
 
110
113
 
@@ -48,8 +48,8 @@ from .base import register_adapter
48
48
  # corpus (see skills/livepilot-core/references/device-knowledge/
49
49
  # instruments-synths.md). PR9 uses a small subset; later PRs extend.
50
50
  _KNOWN_PARAMS = {
51
- "Osc 1 Position",
52
- "Osc 2 Position",
51
+ "Osc 1 Pos",
52
+ "Osc 2 Pos",
53
53
  "Osc 1 Transpose",
54
54
  "Osc 2 Transpose",
55
55
  "Voices",
@@ -220,7 +220,7 @@ class WavetableAdapter:
220
220
  # shift to that region's center. The actual shift magnitude
221
221
  # (how close to the center) scales with freshness — low
222
222
  # freshness stops partway, high freshness commits fully.
223
- current_pos = float(profile.parameter_state.get("Osc 1 Position", 0.0) or 0.0)
223
+ current_pos = float(profile.parameter_state.get("Osc 1 Pos", 0.0) or 0.0)
224
224
  current_region = _classify_position(current_pos)
225
225
  target_region = _choose_target_region(current_region, target)
226
226
  region_target_pos = _region_center(target_region)
@@ -281,7 +281,7 @@ class WavetableAdapter:
281
281
  "params": {
282
282
  "track_index": track,
283
283
  "device_index": device,
284
- "parameter_name": "Osc 1 Position",
284
+ "parameter_name": "Osc 1 Pos",
285
285
  "value": new_pos,
286
286
  },
287
287
  },
@@ -62,6 +62,12 @@ class SectionNode:
62
62
  density: float # 0.0-1.0 (how many tracks are active)
63
63
  tracks_active: list[int] = field(default_factory=list)
64
64
  name: str = ""
65
+ # Real session scene/row index this section maps to (the clip slot to
66
+ # read notes from). -1 means "not scene-backed" (e.g. built from the
67
+ # arrangement view), in which case callers should fall back to the
68
+ # section's position in the graph. Kept last so existing positional
69
+ # SectionNode(...) constructions stay valid.
70
+ scene_index: int = -1
65
71
 
66
72
  def length_bars(self) -> int:
67
73
  return self.end_bar - self.start_bar
@@ -112,6 +112,10 @@ def build_section_graph_from_scenes(
112
112
  density=density,
113
113
  tracks_active=active_tracks,
114
114
  name=scene_name,
115
+ # Real session scene row — used as the get_notes clip_index.
116
+ # Differs from the section's position in this list whenever
117
+ # earlier unnamed/empty scenes were skipped above.
118
+ scene_index=i,
115
119
  ))
116
120
  current_bar = end_bar
117
121
 
@@ -380,9 +380,10 @@ async def check_clip_key_consistency(
380
380
  # 1) Resolve the clip's file path. Relies on the M4L bridge.
381
381
  try:
382
382
  from .analyzer import get_clip_file_path as _get_path
383
- # get_clip_file_path is an @mcp.tool, but FastMCP decorators preserve
384
- # the underlying function we can call it directly for composition.
385
- path_resp = await _get_path.fn(ctx, track_index, clip_index)
383
+ # Under FastMCP 3.3.1 @mcp.tool() returns the plain async function
384
+ # (no .fn accessor), so we call it directly for composition — the
385
+ # same pattern analyzer.verify_all_devices_health uses.
386
+ path_resp = await _get_path(ctx, track_index, clip_index)
386
387
  except Exception as exc:
387
388
  return {
388
389
  "track_index": track_index,
@@ -414,7 +415,7 @@ async def check_clip_key_consistency(
414
415
  # 3) Query the session-detected key (needs the analyzer).
415
416
  try:
416
417
  from .analyzer import get_detected_key as _get_key
417
- key_resp = await _get_key.fn(ctx)
418
+ key_resp = await _get_key(ctx)
418
419
  except Exception as exc:
419
420
  return {
420
421
  "track_index": track_index,
@@ -408,12 +408,16 @@ def get_harmony_field(
408
408
  for i, t in enumerate(tracks)}
409
409
 
410
410
  # Per-track scan: fetch notes + score, then sort by score desc.
411
+ # Use the section's real scene row (scene_index) for the clip slot,
412
+ # not section_index (its position in the section graph) — these
413
+ # diverge whenever earlier unnamed/empty scenes were skipped.
414
+ scene_idx = section.scene_index if getattr(section, "scene_index", -1) >= 0 else section_index
411
415
  HARMONIC_THRESHOLD = 0.3
412
416
  candidates: list[tuple[float, int, list[dict]]] = []
413
417
  for t_idx in section.tracks_active:
414
418
  try:
415
419
  result = ableton.send_command("get_notes", {
416
- "track_index": t_idx, "clip_index": section_index,
420
+ "track_index": t_idx, "clip_index": scene_idx,
417
421
  })
418
422
  except Exception as exc:
419
423
  logger.debug("harmony scan track %d: %s", t_idx, exc)
@@ -34,6 +34,12 @@ def _require_midiutil():
34
34
  )
35
35
 
36
36
 
37
+ # Hard cap on extract_piano_roll's emitted matrix (pitch_range * time_steps).
38
+ # ~16k cells keeps the JSON response well inside a single context window even
39
+ # for a full 88-key range; coarsen 'resolution' to fit larger material.
40
+ _PIANO_ROLL_CELL_BUDGET = 16000
41
+
42
+
37
43
  def _require_pretty_midi():
38
44
  try:
39
45
  import pretty_midi
@@ -348,7 +354,20 @@ def extract_piano_roll(
348
354
 
349
355
  Returns a velocity matrix [pitch_index][time_step] trimmed to
350
356
  the actual pitch range. Resolution is in beats (0.125 = 32nd note).
357
+
358
+ To keep the response bounded, the emitted matrix is capped at
359
+ ``_PIANO_ROLL_CELL_BUDGET`` cells (pitch_range * time_steps). When the
360
+ full roll exceeds the budget the tool returns a structured error with the
361
+ offending dimensions instead of a multi-MB matrix; coarsen ``resolution``
362
+ (larger value = fewer time steps) to fit.
351
363
  """
364
+ if not resolution or resolution <= 0:
365
+ return {
366
+ "error": "resolution must be a positive number of beats per step "
367
+ f"(got {resolution!r}); e.g. 0.125 for 32nd notes.",
368
+ "code": "INVALID_PARAM",
369
+ }
370
+
352
371
  pretty_midi = _require_pretty_midi()
353
372
  path = _validate_midi_path(file_path)
354
373
  pm = pretty_midi.PrettyMIDI(str(path))
@@ -373,10 +392,30 @@ def extract_piano_roll(
373
392
  pitch_max = int(active_pitches[-1])
374
393
  trimmed = roll[pitch_min:pitch_max + 1, :]
375
394
 
395
+ pitch_range = int(trimmed.shape[0])
396
+ time_steps = int(trimmed.shape[1])
397
+ cell_count = pitch_range * time_steps
398
+ if cell_count > _PIANO_ROLL_CELL_BUDGET:
399
+ return {
400
+ "error": (
401
+ f"piano roll too large: {pitch_range} pitches x {time_steps} "
402
+ f"steps = {cell_count} cells exceeds the {_PIANO_ROLL_CELL_BUDGET}"
403
+ "-cell budget. Increase 'resolution' (e.g. 0.25 or 0.5 beats) "
404
+ "to coarsen the time axis."
405
+ ),
406
+ "code": "INVALID_PARAM",
407
+ "pitch_min": pitch_min,
408
+ "pitch_max": pitch_max,
409
+ "pitch_range": pitch_range,
410
+ "time_steps": time_steps,
411
+ "cell_budget": _PIANO_ROLL_CELL_BUDGET,
412
+ "resolution": resolution,
413
+ }
414
+
376
415
  return {
377
416
  "piano_roll": trimmed.astype(int).tolist(),
378
417
  "pitch_min": pitch_min,
379
418
  "pitch_max": pitch_max,
380
- "time_steps": int(trimmed.shape[1]),
419
+ "time_steps": time_steps,
381
420
  "resolution": resolution,
382
421
  }
@@ -167,7 +167,7 @@ async def get_session_diagnostics(ctx: Context, check_clip_keys: bool = False) -
167
167
  # reasonable upper bound for typical production sessions.
168
168
  for clip_idx in range(min(32, len(session_info.get("scenes", []) or []) or 8)):
169
169
  try:
170
- check = await check_clip_key_consistency.fn(ctx, t_idx, clip_idx)
170
+ check = await check_clip_key_consistency(ctx, t_idx, clip_idx)
171
171
  except Exception: # noqa: BLE001 — any failure means "skip this clip"
172
172
  continue
173
173
  if not isinstance(check, dict):
@@ -105,6 +105,62 @@ class DetectedPlugin:
105
105
  # ─── Top-level entry ────────────────────────────────────────────────────────
106
106
 
107
107
 
108
+ # Bundle file/dir extensions per plugin format. VST3/AU/AAX/LV2 bundles are
109
+ # themselves directories (Foo.vst3/Contents/...), so the recursive scan treats
110
+ # a matching entry as a leaf — it records it but never descends inside.
111
+ _BUNDLE_EXTS: dict[str, tuple[str, ...]] = {
112
+ "VST3": (".vst3",),
113
+ "AU": (".component",),
114
+ "VST2": (".vst", ".dylib"),
115
+ "AAX": (".aaxplugin",),
116
+ "LV2": (".lv2",),
117
+ }
118
+
119
+
120
+ def _is_plugin_bundle(path: Path, fmt: str) -> bool:
121
+ """True when *path* is itself a plugin bundle/file for *fmt* (a leaf to
122
+ record) rather than a vendor/organisational subfolder to recurse into."""
123
+ return path.suffix in _BUNDLE_EXTS.get(fmt, ())
124
+
125
+
126
+ def _walk_plugin_bundles(root: Path, fmt: str, max_depth: int = 8):
127
+ """Yield every *fmt* plugin bundle/file under *root*, recursing into plain
128
+ (vendor) subdirectories but NOT descending into bundle directories.
129
+
130
+ Fixes the flat scan that only saw top-level bundles: plugins nested in
131
+ vendor subfolders (e.g. VST3/Arturia/Analog Lab.vst3) were invisible, and
132
+ the vendor folders themselves were mis-emitted as junk 'unknown-*' records.
133
+ Symlink cycles are guarded via resolved-path dedup; recursion depth is
134
+ capped; unreadable directories are skipped with a warning.
135
+ """
136
+ seen_dirs: set[Path] = set()
137
+ stack: list[tuple[Path, int]] = [(root, 0)]
138
+ while stack:
139
+ current, depth = stack.pop()
140
+ try:
141
+ real = current.resolve()
142
+ except OSError:
143
+ continue
144
+ if real in seen_dirs:
145
+ continue
146
+ seen_dirs.add(real)
147
+ try:
148
+ entries = sorted(current.iterdir())
149
+ except (PermissionError, OSError) as e:
150
+ logger.warning("Cannot read %s: %s", current, e)
151
+ continue
152
+ for entry in entries:
153
+ if _is_plugin_bundle(entry, fmt):
154
+ yield entry # leaf — never descend into a bundle
155
+ elif depth < max_depth:
156
+ try:
157
+ descend = entry.is_dir()
158
+ except OSError:
159
+ descend = False
160
+ if descend:
161
+ stack.append((entry, depth + 1))
162
+
163
+
108
164
  def detect_installed_plugins(
109
165
  paths: list[tuple[Path, str]] | None = None,
110
166
  formats: list[str] | None = None,
@@ -138,20 +194,19 @@ def detect_installed_plugins(
138
194
  results: list[DetectedPlugin] = []
139
195
  seen_keys: set[tuple[str, str, str]] = set() # (vendor_lc, name_lc, format)
140
196
 
141
- # 1. Path-based scan — covers VST3 / VST2 / AAX / LV2 + co-located AU v2
197
+ # 1. Path-based scan — covers VST3 / VST2 / AAX / LV2 + co-located AU v2.
198
+ # Recurses into vendor subfolders (e.g. VST3/Arturia/Foo.vst3) but never
199
+ # descends into bundle directories themselves. See _walk_plugin_bundles.
142
200
  for root, fmt in paths:
143
201
  if not root.exists():
144
202
  continue
145
- try:
146
- for entry in sorted(root.iterdir()):
147
- plugin = _identify_plugin(entry, fmt)
148
- if plugin:
149
- key = ((plugin.vendor or "").lower(), plugin.name.lower(), plugin.format)
150
- if key not in seen_keys:
151
- seen_keys.add(key)
152
- results.append(plugin)
153
- except (PermissionError, OSError) as e:
154
- logger.warning("Cannot read %s: %s", root, e)
203
+ for entry in _walk_plugin_bundles(root, fmt):
204
+ plugin = _identify_plugin(entry, fmt)
205
+ if plugin:
206
+ key = ((plugin.vendor or "").lower(), plugin.name.lower(), plugin.format)
207
+ if key not in seen_keys:
208
+ seen_keys.add(key)
209
+ results.append(plugin)
155
210
 
156
211
  # 2. auval-based AU enumeration — captures AUv3 + arbitrary-location AUs
157
212
  want_au = formats is None or "AU" in (formats or [])
@@ -11,6 +11,7 @@ mtime-based incremental skipping is on by default.
11
11
 
12
12
  from __future__ import annotations
13
13
 
14
+ import fnmatch
14
15
  import hashlib
15
16
  import json
16
17
  import logging
@@ -181,7 +182,12 @@ def _iter_files(
181
182
  continue
182
183
  if not scanner.is_applicable(p):
183
184
  continue
184
- if any(p.match(g) for g in excludes):
185
+ # Honor excludes against BOTH the filename (Path.match, right-anchored
186
+ # keeps filename-glob patterns like "*.tmp" working) and the full path
187
+ # string (fnmatch — lets directory patterns like "*Backup*" exclude
188
+ # files *inside* a Backup/ folder, which Path.match alone cannot do).
189
+ path_str = p.as_posix()
190
+ if any(p.match(g) or fnmatch.fnmatch(path_str, g) for g in excludes):
185
191
  continue
186
192
  yield p
187
193
 
@@ -143,17 +143,26 @@ class AmxdScanner(Scanner):
143
143
  # ─── Parsing ─────────────────────────────────────────────────────────────────
144
144
 
145
145
 
146
- # The ampf header carries device type as an ASCII letter at offset 8:
147
- # 'a' (97) = audio effect
148
- # 'i' (105) = instrument
149
- # 'm' (109) = MIDI effect
146
+ # The ampf header carries device type as a 4-byte ASCII tag at offset 8:
147
+ # 'aaaa' = audio effect
148
+ # 'iiii' = instrument
149
+ # 'mmmm' = MIDI effect
150
+ # 'nagg' = MIDI Tool generator (Live 12.1+)
151
+ # 'natt' = MIDI Tool transformation (Live 12.1+)
150
152
  # Earlier guess of 0/1/2 was wrong — verified against the user's 393-file
151
153
  # real-world .amxd corpus where 388/393 devices reported as unknown-{97,109,105}.
154
+ # The single-letter map predates the MIDI Tool surface: both MIDI Tool kinds
155
+ # share first byte 'n' (110), so a single-byte read mis-tagged them as
156
+ # unknown-110 and could not tell generator from transformation. Keying off the
157
+ # full 4-byte tag (raw[8:12]) fixes both. The first-byte fallback preserves the
158
+ # legacy unknown-{byte} shape for any tag we don't recognise.
152
159
  _AMPF_DEVICE_TYPE_BYTE = 8
153
- _DEVICE_TYPE_MAP = {
154
- ord("a"): "audio",
155
- ord("i"): "instrument",
156
- ord("m"): "midi",
160
+ _DEVICE_TYPE_TAG_MAP = {
161
+ b"aaaa": "audio",
162
+ b"iiii": "instrument",
163
+ b"mmmm": "midi",
164
+ b"nagg": "midi_tool_generator",
165
+ b"natt": "midi_tool_transformation",
157
166
  }
158
167
 
159
168
 
@@ -174,11 +183,13 @@ def _parse_amxd(raw: bytes, filename: str) -> dict:
174
183
 
175
184
  # 1. Device type from the ampf header
176
185
  if len(raw) > 24 and raw[:4] == b"ampf":
177
- try:
178
- tb = raw[_AMPF_DEVICE_TYPE_BYTE]
179
- out["device_type"] = _DEVICE_TYPE_MAP.get(tb, f"unknown-{tb}")
180
- except IndexError:
181
- pass
186
+ tag = raw[_AMPF_DEVICE_TYPE_BYTE:_AMPF_DEVICE_TYPE_BYTE + 4]
187
+ known = _DEVICE_TYPE_TAG_MAP.get(tag)
188
+ if known is not None:
189
+ out["device_type"] = known
190
+ else:
191
+ # Fall back to the legacy single-byte unknown-{byte} shape.
192
+ out["device_type"] = f"unknown-{tag[0]}" if tag else None
182
193
 
183
194
  # 2. Locate + parse the JSON patcher block
184
195
  json_blob = _extract_patcher_json(raw)
@@ -50,6 +50,20 @@ from .plugin_engine.research import (
50
50
  )
51
51
 
52
52
 
53
+ # ─── Inline plugin serialization helper ────────────────────────────────────────
54
+ # corpus_detect_plugins persists the FULL plugin dict (incl. raw sdk_metadata =
55
+ # entire moduleinfo.json / Info.plist) to _inventory.json. The inline MCP
56
+ # response, however, only needs lightweight identity fields — returning the full
57
+ # sdk_metadata for every plugin bloats the payload and duplicates the file.
58
+ # Callers that need the raw metadata read it back from _inventory.json.
59
+
60
+
61
+ def _slim_plugin(plugin_dict: dict) -> dict:
62
+ """Return a copy of a serialized DetectedPlugin without the heavy
63
+ ``sdk_metadata`` blob, for inline (non-persisted) MCP responses."""
64
+ return {k: v for k, v in plugin_dict.items() if k != "sdk_metadata"}
65
+
66
+
53
67
  # ─── Vendor canonicalization helpers (used by corpus_canonicalize_plugins) ───
54
68
  # Strips common vendor-suffix words ("DSP", "LLC", "GmbH", etc.) so different
55
69
  # spellings of the same vendor ("Valhalla DSP, LLC" + "Valhalladsp") collapse
@@ -390,7 +404,7 @@ def corpus_detect_plugins(
390
404
  )
391
405
 
392
406
  return {
393
- "plugins": plugins_serialized,
407
+ "plugins": [_slim_plugin(p) for p in plugins_serialized],
394
408
  "totals": {"all": len(detected), "by_format": by_format},
395
409
  "inventory_path": str(inventory_path) if inventory_path else None,
396
410
  "search_paths": [str(p) for p, _ in default_plugin_dir()],
@@ -821,6 +835,7 @@ def corpus_research_targets(
821
835
  def corpus_emit_synthesis_briefs(
822
836
  ctx: Context,
823
837
  plugin_ids: list = None,
838
+ inline_limit: int = 5,
824
839
  ) -> dict:
825
840
  """Phase 4 — emit sonnet-subagent briefs for plugin identity synthesis.
826
841
 
@@ -832,10 +847,18 @@ def corpus_emit_synthesis_briefs(
832
847
  ----------
833
848
  plugin_ids : list of plugin_ids to emit briefs for. If empty, emits for
834
849
  every plugin in the inventory.
850
+ inline_limit : maximum number of FULL briefs returned inline (default 5,
851
+ matching the 'Cap parallel subagents at ~5' instruction).
852
+ Any plugins beyond this cap are returned as lightweight stubs
853
+ ({plugin_id, output_path}) in `deferred` so a single call can
854
+ never return a multi-MB response over a large inventory. Pass
855
+ explicit `plugin_ids` (or a larger inline_limit) to get the
856
+ full brief for a specific batch.
835
857
 
836
858
  Returns
837
859
  -------
838
- {briefs: [{plugin_id, brief, output_path}, ...], total}
860
+ {briefs: [{plugin_id, brief, output_path}, ...], deferred: [{plugin_id,
861
+ output_path}, ...], total, inline_count, inline_limit}
839
862
  """
840
863
  inventory_path = DEFAULT_OUTPUT_ROOT / "plugins" / "_inventory.json"
841
864
  if not inventory_path.exists():
@@ -844,7 +867,9 @@ def corpus_emit_synthesis_briefs(
844
867
  all_plugins = inventory.get("plugins", [])
845
868
 
846
869
  target_ids = set(plugin_ids) if plugin_ids else None
870
+ cap = inline_limit if inline_limit and inline_limit > 0 else 5
847
871
  briefs = []
872
+ deferred = []
848
873
  for plugin_dict in all_plugins:
849
874
  pid = plugin_dict.get("plugin_id")
850
875
  if target_ids is not None and pid not in target_ids:
@@ -866,21 +891,32 @@ def corpus_emit_synthesis_briefs(
866
891
  research_root = DEFAULT_OUTPUT_ROOT / "plugins" / pid / "research"
867
892
 
868
893
  brief = build_synthesis_brief(plugin, local_manual, research_root if research_root.exists() else None)
869
- briefs.append({
870
- "plugin_id": pid,
871
- "brief": brief,
872
- "output_path": brief["output_path"],
873
- })
894
+ if len(briefs) < cap:
895
+ briefs.append({
896
+ "plugin_id": pid,
897
+ "brief": brief,
898
+ "output_path": brief["output_path"],
899
+ })
900
+ else:
901
+ deferred.append({
902
+ "plugin_id": pid,
903
+ "output_path": brief["output_path"],
904
+ })
874
905
 
875
906
  return {
876
907
  "briefs": briefs,
877
- "total": len(briefs),
908
+ "deferred": deferred,
909
+ "total": len(briefs) + len(deferred),
910
+ "inline_count": len(briefs),
911
+ "inline_limit": cap,
878
912
  "instruction": (
879
913
  "For each brief: dispatch one sonnet subagent (Agent tool with "
880
914
  "subagent_type='general-purpose', model='sonnet') passing the brief "
881
915
  "as context. The subagent reads brief['synthesis_inputs'] and writes "
882
916
  "the YAML at brief['output_path']. Cap parallel subagents at ~5 to "
883
- "avoid main-context bloat."
917
+ "avoid main-context bloat. Plugins beyond inline_limit are listed in "
918
+ "'deferred' as stubs — re-call corpus_emit_synthesis_briefs with their "
919
+ "plugin_ids to get the full briefs for the next batch."
884
920
  ),
885
921
  }
886
922