@nodetool-ai/protocol 0.8.19 → 0.8.20

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 (88) hide show
  1. package/dist/.nodetool-build-stamp +1 -1
  2. package/dist/api-schemas/assets.d.ts +13 -0
  3. package/dist/api-schemas/assets.d.ts.map +1 -1
  4. package/dist/api-schemas/assets.js +13 -1
  5. package/dist/api-schemas/assets.js.map +1 -1
  6. package/dist/api-schemas/index.d.ts +1 -0
  7. package/dist/api-schemas/index.d.ts.map +1 -1
  8. package/dist/api-schemas/index.js +1 -0
  9. package/dist/api-schemas/index.js.map +1 -1
  10. package/dist/api-schemas/mcp-config.d.ts +13 -0
  11. package/dist/api-schemas/mcp-config.d.ts.map +1 -1
  12. package/dist/api-schemas/mcp-config.js +5 -3
  13. package/dist/api-schemas/mcp-config.js.map +1 -1
  14. package/dist/api-schemas/openverse.d.ts +1 -0
  15. package/dist/api-schemas/openverse.d.ts.map +1 -1
  16. package/dist/api-schemas/sdk-execution-v1.d.ts +3 -0
  17. package/dist/api-schemas/sdk-execution-v1.d.ts.map +1 -1
  18. package/dist/api-schemas/storage.d.ts +42 -1
  19. package/dist/api-schemas/storage.d.ts.map +1 -1
  20. package/dist/api-schemas/storage.js +42 -2
  21. package/dist/api-schemas/storage.js.map +1 -1
  22. package/dist/api-schemas/timeline-tool-contracts.d.ts +4307 -157
  23. package/dist/api-schemas/timeline-tool-contracts.d.ts.map +1 -1
  24. package/dist/api-schemas/timeline-tool-contracts.js +342 -20
  25. package/dist/api-schemas/timeline-tool-contracts.js.map +1 -1
  26. package/dist/api-schemas/timeline-tool-params.d.ts +6705 -144
  27. package/dist/api-schemas/timeline-tool-params.d.ts.map +1 -1
  28. package/dist/api-schemas/timeline-tool-params.js +1697 -40
  29. package/dist/api-schemas/timeline-tool-params.js.map +1 -1
  30. package/dist/api-schemas/timeline.d.ts +8749 -51
  31. package/dist/api-schemas/timeline.d.ts.map +1 -1
  32. package/dist/api-schemas/timeline.js +757 -40
  33. package/dist/api-schemas/timeline.js.map +1 -1
  34. package/dist/api-schemas/triggers.d.ts +99 -0
  35. package/dist/api-schemas/triggers.d.ts.map +1 -0
  36. package/dist/api-schemas/triggers.js +48 -0
  37. package/dist/api-schemas/triggers.js.map +1 -0
  38. package/dist/api-schemas/workflows.d.ts +54 -0
  39. package/dist/api-schemas/workflows.d.ts.map +1 -1
  40. package/dist/api-schemas/workflows.js +13 -1
  41. package/dist/api-schemas/workflows.js.map +1 -1
  42. package/dist/api-types.d.ts +1 -0
  43. package/dist/api-types.d.ts.map +1 -1
  44. package/dist/api-types.js +2 -0
  45. package/dist/api-types.js.map +1 -1
  46. package/dist/cloud-profile.d.ts.map +1 -1
  47. package/dist/cloud-profile.js +2 -0
  48. package/dist/cloud-profile.js.map +1 -1
  49. package/dist/game-design.d.ts +6 -4
  50. package/dist/game-design.d.ts.map +1 -1
  51. package/dist/game-design.js +178 -51
  52. package/dist/game-design.js.map +1 -1
  53. package/dist/local-providers.d.ts.map +1 -1
  54. package/dist/local-providers.js +9 -0
  55. package/dist/local-providers.js.map +1 -1
  56. package/dist/markdown-blocks.d.ts.map +1 -1
  57. package/dist/markdown-blocks.js +31 -4
  58. package/dist/markdown-blocks.js.map +1 -1
  59. package/dist/messages.d.ts +30 -0
  60. package/dist/messages.d.ts.map +1 -1
  61. package/dist/messages.js.map +1 -1
  62. package/dist/missing-runtime-package.d.ts +4 -1
  63. package/dist/missing-runtime-package.d.ts.map +1 -1
  64. package/dist/missing-runtime-package.js +17 -0
  65. package/dist/missing-runtime-package.js.map +1 -1
  66. package/dist/native-game-templates.d.ts.map +1 -1
  67. package/dist/native-game-templates.js +18 -4
  68. package/dist/native-game-templates.js.map +1 -1
  69. package/dist/processing-messages.schema.json +3 -0
  70. package/dist/project-directories.d.ts +1 -0
  71. package/dist/project-directories.d.ts.map +1 -1
  72. package/dist/project-directories.js +12 -2
  73. package/dist/project-directories.js.map +1 -1
  74. package/dist/render-record.d.ts +3 -2
  75. package/dist/render-record.d.ts.map +1 -1
  76. package/dist/render-record.js +3 -2
  77. package/dist/render-record.js.map +1 -1
  78. package/dist/sandbox-capability.d.ts +9 -2
  79. package/dist/sandbox-capability.d.ts.map +1 -1
  80. package/dist/sandbox-capability.js +12 -3
  81. package/dist/sandbox-capability.js.map +1 -1
  82. package/dist/ws-commands.d.ts +496 -1
  83. package/dist/ws-commands.d.ts.map +1 -1
  84. package/dist/ws-commands.js +262 -3
  85. package/dist/ws-commands.js.map +1 -1
  86. package/package.json +1 -1
  87. package/schema/sdk-v1.execution.schema.json +6 -0
  88. package/schema/sdk-v1.manifest.json +1 -1
@@ -23,11 +23,28 @@
23
23
  import { z } from "zod";
24
24
  import { isRecord, isString } from "../predicates.js";
25
25
  import { withKeyRemedies } from "../zod-schema.js";
26
- import { captionStyle, secondaryCurvePoints, clipDeflickerAnalysis, effectMask, clipStabilizeAnalysis, clipModel3DAnimation, clipModel3DCamera, clipModel3DStyle, clipShapeStyle, clipTextStyle, midiInstrument, samplerMidiInstrument, samplerZone, KNOWN_CLIP_EFFECT_TYPE_LIST, KNOWN_TRANSITION_TYPE_LIST, MIDI_MAX_NOTES_PER_CLIP } from "./timeline.js";
26
+ import { captionStyle, secondaryCurvePoints, clipDeflickerAnalysis, effectMask, clipStabilizeAnalysis, clipModel3DAnimation, clipModel3DCamera, clipModel3DStyle, clipShapeStyle, clipTextStyle, midiInstrument, midiNoteExpression, automationTarget, midiControllerKind, musicKey, musicRole, trackEffect, MAX_AUTOMATION_LANES_PER_TRACK, MAX_AUTOMATION_POINTS_PER_LANE, MIDI_MAX_POINTS_PER_LANE, MIDI_MAX_CONTROLLER_LANES_PER_CLIP, mediaTrack, timelineChord, timelineClip, timelineMarker, samplerMidiInstrument, samplerZone, KNOWN_CLIP_EFFECT_TYPE_LIST, KNOWN_TRANSITION_TYPE_LIST, MIDI_MAX_NOTES_PER_CLIP, stepAutomationMode, stepCondition, stepDegree, stepEditMode, stepKey, stepPitchSource, stepPlaybackMode, stepRate, stepRowAssignment, stepRowSort, stepScaleId, stepSwingDivision, STEP_PATTERN_MAX_STEPS } from "./timeline.js";
27
27
  /** How every clip-addressing tool names its target. */
28
28
  export const targetParam = z
29
29
  .string()
30
30
  .describe('Clip id, clip name (case-insensitive), or the literal "selected" for the currently-selected clip.');
31
+ /**
32
+ * A time given as a bar position, for the clip ops that take ms (D49). The ms
33
+ * form and this form are mutually exclusive; the op refuses both together.
34
+ */
35
+ export const barTimeShape = {
36
+ atBar: z
37
+ .number()
38
+ .int()
39
+ .min(1)
40
+ .optional()
41
+ .describe("A time as a bar position, counted from 1, resolved through the tempo map. Use it instead of the ms form, never together."),
42
+ beat: z
43
+ .number()
44
+ .min(1)
45
+ .optional()
46
+ .describe("The beat inside `atBar`, counted from 1. Default 1.")
47
+ };
31
48
  /** Explicit target and prompt for the nondestructive video-edit operation. */
32
49
  const requireProviderModelPair = (value, ctx) => {
33
50
  if ((value.provider === undefined) !== (value.model === undefined)) {
@@ -92,17 +109,26 @@ export const clipOpacityParam = z
92
109
  export const clipTransformPatchParam = z
93
110
  .object({
94
111
  position: z
95
- .object({ x: z.number().optional(), y: z.number().optional() })
112
+ .object({
113
+ x: z.number().finite().optional(),
114
+ y: z.number().finite().optional()
115
+ })
96
116
  .optional(),
97
117
  scale: z
98
- .object({ x: z.number().optional(), y: z.number().optional() })
118
+ .object({
119
+ x: z.number().finite().optional(),
120
+ y: z.number().finite().optional()
121
+ })
99
122
  .optional(),
100
- rotation: z.number().optional(),
101
- rotationX: z.number().optional(),
102
- rotationY: z.number().optional(),
103
- perspective: z.number().positive().optional(),
123
+ rotation: z.number().finite().optional(),
124
+ rotationX: z.number().finite().optional(),
125
+ rotationY: z.number().finite().optional(),
126
+ perspective: z.number().finite().positive().optional(),
104
127
  anchor: z
105
- .object({ x: z.number().optional(), y: z.number().optional() })
128
+ .object({
129
+ x: z.number().finite().optional(),
130
+ y: z.number().finite().optional()
131
+ })
106
132
  .optional()
107
133
  })
108
134
  .optional();
@@ -232,22 +258,43 @@ export function withFieldNotes(schema, notes) {
232
258
  * complete description of a centred drop shadow, and demanding `offsetX: 0`
233
259
  * cost a round trip on a call that was already right.
234
260
  */
261
+ const gradientStopParams = z.object({
262
+ offset: z.number().finite().min(0).max(1),
263
+ color: z.string()
264
+ });
265
+ export const styleFillParams = z.discriminatedUnion("type", [
266
+ z.object({ type: z.literal("solid"), color: z.string() }),
267
+ z.object({
268
+ type: z.literal("linear"),
269
+ angle: z.number().finite(),
270
+ stops: z.array(gradientStopParams).min(2)
271
+ }),
272
+ z.object({
273
+ type: z.literal("radial"),
274
+ stops: z.array(gradientStopParams).min(2)
275
+ })
276
+ ]);
235
277
  const textShadowParams = z
236
278
  .object({
237
279
  color: z.string().default("#000000"),
238
- blurPx: z.number().default(0),
239
- offsetX: z.number().default(0).describe("Default 0."),
240
- offsetY: z.number().default(0).describe("Default 0.")
280
+ blurPx: z.number().finite().min(0).default(0),
281
+ offsetX: z.number().finite().default(0).describe("Default 0."),
282
+ offsetY: z.number().finite().default(0).describe("Default 0.")
241
283
  })
242
284
  .strict();
243
285
  const textStrokeParams = z
244
- .object({ color: z.string(), widthPx: z.number() })
286
+ .object({ color: z.string(), widthPx: z.number().finite().min(0) })
245
287
  .strict();
246
288
  const textBackgroundParams = z
247
289
  .object({
248
290
  color: z.string(),
249
- paddingPx: z.number(),
250
- radiusPx: z.number().optional().describe("Corner rounding, in sequence px.")
291
+ paddingPx: z.number().finite().min(0),
292
+ radiusPx: z
293
+ .number()
294
+ .finite()
295
+ .min(0)
296
+ .optional()
297
+ .describe("Corner rounding, in sequence px.")
251
298
  })
252
299
  .strict();
253
300
  /**
@@ -280,18 +327,16 @@ const FONT_WEIGHT_KEYWORDS = {
280
327
  /** A weight written as a word (or a quoted number), as its number. */
281
328
  const writtenFontWeight = z
282
329
  .string()
283
- .transform((raw) => raw
284
- .trim()
285
- .toLowerCase()
286
- .replace(/[\s_-]/g, ""))
287
- .refine((key) => FONT_WEIGHT_KEYWORDS[key] !== undefined || isFiniteWeight(key), {
288
- message: `not a weight — use a number, or one of: ${Object.keys(FONT_WEIGHT_KEYWORDS).join(", ")}`
330
+ .transform((raw) => raw.trim().toLowerCase())
331
+ .refine((raw) => FONT_WEIGHT_KEYWORDS[raw.replace(/[\s_-]/g, "")] !== undefined ||
332
+ isFiniteWeight(raw), {
333
+ message: `not a weight — use a positive number, or one of: ${Object.keys(FONT_WEIGHT_KEYWORDS).join(", ")}`
289
334
  })
290
- .transform((key) => FONT_WEIGHT_KEYWORDS[key] ?? Number(key));
291
- const isFiniteWeight = (key) => key !== "" && Number.isFinite(Number(key));
335
+ .transform((raw) => FONT_WEIGHT_KEYWORDS[raw.replace(/[\s_-]/g, "")] ?? Number(raw));
336
+ const isFiniteWeight = (key) => key !== "" && Number.isFinite(Number(key)) && Number(key) > 0;
292
337
  /** `fontWeight`, accepting the CSS keyword spellings as well as the number. */
293
338
  export const fontWeightParam = z
294
- .union([z.number(), writtenFontWeight])
339
+ .union([z.number().finite().positive(), writtenFontWeight])
295
340
  .describe("Numeric weight (400 regular, 600 semibold, 800 extrabold). The CSS " +
296
341
  'keywords ("bold", "semibold", …) are accepted and stored as their number.');
297
342
  /** A text clip's whole authored look, as `set_clip_params` replaces it. */
@@ -320,7 +365,34 @@ export const textStyleParams = withFieldNotes(clipTextStyle, {
320
365
  * Only the authoring surface is strict. Widening the document schema would
321
366
  * make an already-saved sequence carrying `"center"` fail to save.
322
367
  */
368
+ fontSizePx: z
369
+ .number()
370
+ .finite()
371
+ .positive()
372
+ .describe("Font size in sequence pixels, not CSS pixels."),
323
373
  fontWeight: fontWeightParam.optional(),
374
+ fontStyle: z
375
+ .enum(["normal", "italic"])
376
+ .optional()
377
+ .describe('"normal" (default) or "italic".'),
378
+ letterSpacingPx: z
379
+ .number()
380
+ .finite()
381
+ .optional()
382
+ .describe("Extra advance between glyphs, in sequence px. Default 0."),
383
+ lineHeight: z
384
+ .number()
385
+ .finite()
386
+ .positive()
387
+ .optional()
388
+ .describe("Line advance as a multiple of the font size. Default 1.2."),
389
+ maxWidthFrac: z
390
+ .number()
391
+ .finite()
392
+ .positive()
393
+ .max(1)
394
+ .optional()
395
+ .describe("Wrap width as a fraction of frame width."),
324
396
  verticalAlign: z
325
397
  .enum(["top", "middle", "bottom"])
326
398
  .optional()
@@ -337,7 +409,11 @@ export const textStyleParams = withFieldNotes(clipTextStyle, {
337
409
  .optional()
338
410
  .describe("Scrim drawn behind the wrapped block: {color, paddingPx, radiusPx?}. " +
339
411
  "The rounding field is `radiusPx`, not `cornerRadius`. An 8-digit " +
340
- "hex or rgba() colour keeps the picture visible through it.")
412
+ "hex or rgba() colour keeps the picture visible through it."),
413
+ fill: styleFillParams
414
+ .optional()
415
+ .describe('Gradient or solid fill, {type: "solid"|"linear"|"radial", ...}. ' +
416
+ "Wins over `color` when set.")
341
417
  });
342
418
  /**
343
419
  * Where a text clip is placed, for a caller that reached for x/y.
@@ -379,7 +455,21 @@ export const partialTextStyleParams = textStyleParams
379
455
  * and a clip with no text style yet still needs the three required fields
380
456
  * before it draws anything.
381
457
  */
382
- export const textStylePatchParams = textStyleParams.partial();
458
+ const textStylePatchShape = Object.fromEntries(Object.entries(textStyleParams.shape).map(([key, schema]) => {
459
+ if (key === "text" || key === "fontSizePx" || key === "color") {
460
+ return [key, schema.optional()];
461
+ }
462
+ return [key, schema.nullable().optional()];
463
+ }));
464
+ export const textStylePatchParams = z.object(textStylePatchShape);
465
+ const SHAPE_KIND_VALUES = [
466
+ "rect",
467
+ "ellipse",
468
+ "line",
469
+ "polygon",
470
+ "star",
471
+ "path"
472
+ ];
383
473
  /** A shape clip's geometry and fill. */
384
474
  export const shapeStyleParams = withFieldNotes(clipShapeStyle, {
385
475
  x: "Left edge (or the line's first point), 0..1 of frame width.",
@@ -408,7 +498,105 @@ export const shapeStyleParams = withFieldNotes(clipShapeStyle, {
408
498
  // Strict for the same reason the text bags are: a geometry key spelled
409
499
  // wrong inside `shape` was stripped, and the shape drew at its default
410
500
  // somewhere else on the frame with nothing said about it.
411
- }).strict();
501
+ })
502
+ .extend({
503
+ kind: z.enum(SHAPE_KIND_VALUES),
504
+ fill: z
505
+ .union([z.string(), styleFillParams])
506
+ .optional()
507
+ .describe("Solid colour string or linear/radial gradient object. Alpha belongs " +
508
+ "in the colour or gradient stop colours."),
509
+ fillStyle: styleFillParams
510
+ .optional()
511
+ .describe("Gradient or solid fill, wins over `fill` when set. A soft scrim is " +
512
+ '{type: "linear", angle: 90, stops: [{offset: 0, color: "#05070C00"}, ' +
513
+ '{offset: 1, color: "#05070CDD"}]} — the alpha lives in the stop colours.'),
514
+ strokeWidthPx: z
515
+ .number()
516
+ .finite()
517
+ .min(0)
518
+ .optional()
519
+ .describe("Outline width in sequence pixels. Default 8."),
520
+ x: z
521
+ .number()
522
+ .finite()
523
+ .optional()
524
+ .describe("Left edge (or the line's first point), 0..1 of frame width."),
525
+ y: z
526
+ .number()
527
+ .finite()
528
+ .optional()
529
+ .describe("Top edge (or the line's first point), 0..1 of frame height."),
530
+ width: z
531
+ .number()
532
+ .finite()
533
+ .min(0)
534
+ .optional()
535
+ .describe("Width, as a multiple of frame width (non-negative)."),
536
+ height: z
537
+ .number()
538
+ .finite()
539
+ .min(0)
540
+ .optional()
541
+ .describe("Height, as a multiple of frame height (non-negative)."),
542
+ x2: z
543
+ .number()
544
+ .finite()
545
+ .optional()
546
+ .describe('kind "line" only: the second point, 0..1 of frame width.'),
547
+ y2: z
548
+ .number()
549
+ .finite()
550
+ .optional()
551
+ .describe('kind "line" only: the second point, 0..1 of frame height.'),
552
+ sides: z
553
+ .number()
554
+ .int()
555
+ .min(3)
556
+ .max(Math.floor(2147483647 / 2))
557
+ .optional()
558
+ .describe('Point count for kind "polygon" and "star".'),
559
+ innerRadius: z
560
+ .number()
561
+ .finite()
562
+ .min(0)
563
+ .max(1)
564
+ .optional()
565
+ .describe('kind "star" only: inner radius as a fraction of the outer.'),
566
+ cornerRadius: z
567
+ .number()
568
+ .finite()
569
+ .min(0)
570
+ .optional()
571
+ .describe("Corner rounding, in the same normalized units."),
572
+ dash: z
573
+ .array(z.number().finite().min(0))
574
+ .optional()
575
+ .describe("Dash pattern in normalized units, as ctx.setLineDash takes it."),
576
+ lineCap: z
577
+ .enum(["butt", "round", "square"])
578
+ .optional()
579
+ .describe('"butt", "round" or "square".'),
580
+ lineJoin: z
581
+ .enum(["miter", "round", "bevel"])
582
+ .optional()
583
+ .describe('"miter", "round" or "bevel".'),
584
+ trimStart: z
585
+ .number()
586
+ .finite()
587
+ .min(0)
588
+ .max(1)
589
+ .optional()
590
+ .describe("Stroke only the sub-range [trimStart, trimEnd] of the path, 0..1."),
591
+ trimEnd: z
592
+ .number()
593
+ .finite()
594
+ .min(0)
595
+ .max(1)
596
+ .optional()
597
+ .describe("Stroke only the sub-range [trimStart, trimEnd] of the path, 0..1.")
598
+ })
599
+ .strict();
412
600
  /**
413
601
  * What `add_text_clip` and `add_shape_clip` tell the model, shared so the
414
602
  * browser registry and the headless bridge describe one tool.
@@ -651,7 +839,7 @@ export const RENDER_MODEL3D_REFERENCE_DESCRIPTION = "Render a 3D clip's span as
651
839
  "The longest side is at most 1280 px. A later change to the model, the " +
652
840
  "camera, the span or the sequence settings makes the reference stale. " +
653
841
  "A call on a clip whose stored reference is current renders nothing and " +
654
- "returns it. The result carries `reference` {assetId, dependencyHash, " +
842
+ "returns it, unless `force` is true. The result carries `reference` {assetId, dependencyHash, " +
655
843
  "pass} and `cameraMove`, a one-sentence description of the camera move.";
656
844
  /**
657
845
  * A caption's look. Every field is optional and an absent one keeps the
@@ -665,6 +853,27 @@ export const captionStyleParams = withFieldNotes(captionStyle, {
665
853
  outline: "Outline under the glyphs. widthPx 0 draws none.",
666
854
  bottomMarginFrac: "Gap from the frame bottom, as a fraction of height. Default 0.12.",
667
855
  background: "Scrim behind the whole block."
856
+ }).extend({
857
+ fontSizeFrac: z
858
+ .number()
859
+ .finite()
860
+ .positive()
861
+ .max(1)
862
+ .optional()
863
+ .describe("Font size as a fraction of frame height. Default 0.05."),
864
+ outline: textStrokeParams
865
+ .optional()
866
+ .describe("Outline under the glyphs. widthPx 0 draws none."),
867
+ bottomMarginFrac: z
868
+ .number()
869
+ .finite()
870
+ .min(0)
871
+ .max(1)
872
+ .optional()
873
+ .describe("Gap from the frame bottom, as a fraction of height. Default 0.12."),
874
+ background: textBackgroundParams
875
+ .optional()
876
+ .describe("Scrim behind the whole block.")
668
877
  });
669
878
  // ── Transitions ─────────────────────────────────────────────────────────────
670
879
  /**
@@ -1462,7 +1671,25 @@ export const midiNoteParams = z.object({
1462
1671
  .number()
1463
1672
  .int()
1464
1673
  .positive()
1465
- .describe("How long the note is held, in ticks. 960 = one quarter note.")
1674
+ .describe("How long the note is held, in ticks. 960 = one quarter note."),
1675
+ muted: z.boolean().optional().describe("A muted note is not played."),
1676
+ channel: z
1677
+ .number()
1678
+ .int()
1679
+ .min(0)
1680
+ .max(15)
1681
+ .optional()
1682
+ .describe("MIDI channel 0..15. Default 0."),
1683
+ release_velocity: z
1684
+ .number()
1685
+ .int()
1686
+ .min(0)
1687
+ .max(127)
1688
+ .optional()
1689
+ .describe("Note-off velocity, 0..127."),
1690
+ expression: midiNoteExpression
1691
+ .optional()
1692
+ .describe("Per-note curves (pitch in semitones, volume gain, pan, brightness). Point ticks count from the note's start.")
1466
1693
  });
1467
1694
  const notesParam = z
1468
1695
  .array(midiNoteParams)
@@ -1484,14 +1711,13 @@ export const addMidiClipParams = z.object({
1484
1711
  name: z.string().optional().describe("Label for the clip."),
1485
1712
  notes: notesParam.optional()
1486
1713
  });
1487
- /** `set_notes`. Replaces the whole list — send every note the clip should keep. */
1488
- export const setNotesParams = z.object({
1489
- clip: targetParam,
1490
- notes: notesParam.describe("The clip's complete note list; this replaces what is there. Pass a note's `id` to keep it.")
1491
- });
1492
1714
  /** `set_tempo`. One constant tempo for the document. */
1493
1715
  export const setTempoParams = z.object({
1494
- bpm: z.number().positive().describe("Beats per minute."),
1716
+ bpm: z
1717
+ .number()
1718
+ .positive()
1719
+ .optional()
1720
+ .describe("Beats per minute. Omit to keep the current tempo."),
1495
1721
  offset_ms: z
1496
1722
  .number()
1497
1723
  .min(0)
@@ -1508,14 +1734,25 @@ export const setTempoParams = z.object({
1508
1734
  .int()
1509
1735
  .positive()
1510
1736
  .optional()
1511
- .describe("Time-signature denominator, e.g. 4 in 4/4. Default 4.")
1737
+ .describe("Time-signature denominator, e.g. 4 in 4/4. Default 4."),
1738
+ key: musicKey
1739
+ .nullable()
1740
+ .optional()
1741
+ .describe("The project key, `{ tonic, mode }` with mode major or minor. `null` clears it. Omit to keep the current key."),
1742
+ auto_crossfade_ms: z
1743
+ .number()
1744
+ .min(0)
1745
+ .max(1000)
1746
+ .optional()
1747
+ .describe("Crossfade length in ms for audio clips that touch on one track. 0 turns it off. Default 10.")
1512
1748
  });
1513
1749
  export const SET_TEMPO_DESCRIPTION = "Set the document's constant tempo. Milliseconds are the timeline's master " +
1514
1750
  "clock and a note's ticks are read against the tempo, so changing it " +
1515
1751
  "rescales every midi clip around `offset_ms` — halving the BPM doubles each " +
1516
1752
  "midi clip's start and length, and the notes keep their place inside it. " +
1517
1753
  "Clips that are not midi do not move, so a midi part re-tempoed against " +
1518
- "picture will no longer line up with it.";
1754
+ "picture will no longer line up with it. The project `key` and the audio " +
1755
+ "`auto_crossfade_ms` are set here too, and a tempo change keeps the key.";
1519
1756
  /** A voice named instead of spelled out. The id is one of the engine's
1520
1757
  * `MIDI_INSTRUMENT_PRESETS`; the handler resolves it to the full instrument
1521
1758
  * and stores that, so the track keeps its sound if the table changes. */
@@ -1553,6 +1790,11 @@ export const QUANTIZE_DIVISION_VALUES = [
1553
1790
  "1/16T"
1554
1791
  ];
1555
1792
  /** `transpose_clip`. Moves every note in the clip, ids kept. */
1793
+ /** Narrows a note edit to the notes the piano roll would have selected. */
1794
+ const noteIdsParam = z
1795
+ .array(z.string())
1796
+ .optional()
1797
+ .describe("Edit only these notes, by id. Omit to edit every note in the clip.");
1556
1798
  export const transposeClipParams = z.object({
1557
1799
  clip: targetParam,
1558
1800
  semitones: z
@@ -1560,7 +1802,8 @@ export const transposeClipParams = z.object({
1560
1802
  .int()
1561
1803
  .min(-48)
1562
1804
  .max(48)
1563
- .describe("Whole semitones to move every note by. 12 is an octave up, -12 an octave down.")
1805
+ .describe("Whole semitones to move every note by. 12 is an octave up, -12 an octave down."),
1806
+ note_ids: noteIdsParam
1564
1807
  });
1565
1808
  export const TRANSPOSE_CLIP_DESCRIPTION = "Move every note in a midi clip by whole semitones (12 = one octave). A " +
1566
1809
  "note pushed past the 0..127 MIDI range is held at the end rather than " +
@@ -1581,7 +1824,14 @@ export const quantizeNotesParams = z.object({
1581
1824
  target: z
1582
1825
  .enum(["start", "start_and_length"])
1583
1826
  .optional()
1584
- .describe('"start" moves onsets only; "start_and_length" also rounds each held length to whole grid steps, never below one. Default "start".')
1827
+ .describe('"start" moves onsets only; "start_and_length" also rounds each held length to whole grid steps, never below one. Default "start".'),
1828
+ swing: z
1829
+ .number()
1830
+ .min(0)
1831
+ .max(1)
1832
+ .optional()
1833
+ .describe("Delay of every odd grid step, 0..1 of half a step. Only the onset moves. Default 0."),
1834
+ note_ids: noteIdsParam
1585
1835
  });
1586
1836
  export const QUANTIZE_NOTES_DESCRIPTION = "Snap a midi clip's note onsets to a grid. The grid is a note value — 1/4, " +
1587
1837
  "1/8, 1/16, 1/32, or the triplets 1/8T and 1/16T — read in ticks at PPQ " +
@@ -1595,11 +1845,321 @@ export const scaleVelocityParams = z.object({
1595
1845
  .number()
1596
1846
  .min(0.1)
1597
1847
  .max(4)
1598
- .describe("Multiplier on every velocity. 1.2 plays the phrase harder, 0.8 softer.")
1848
+ .describe("Multiplier on every velocity. 1.2 plays the phrase harder, 0.8 softer."),
1849
+ note_ids: noteIdsParam
1599
1850
  });
1600
1851
  export const SCALE_VELOCITY_DESCRIPTION = "Scale how hard every note in a midi clip is struck. Velocities are clamped " +
1601
1852
  "to 1..127, so a large factor flattens the part's dynamics rather than " +
1602
1853
  "making it louder — set the track's `gainDb` for level.";
1854
+ /** The note functions the piano roll offers beyond quantize, transpose and velocity scaling. */
1855
+ export const EDIT_NOTES_FUNCTIONS = [
1856
+ "scale_quantize",
1857
+ "legato",
1858
+ "remove_overlaps",
1859
+ "delete_duplicates",
1860
+ "glue",
1861
+ "mute",
1862
+ "unmute",
1863
+ "delete",
1864
+ "set_velocity"
1865
+ ];
1866
+ /** Scale ids `scale_quantize` snaps to. Mirrors `SCALES` in `@nodetool-ai/timeline`. */
1867
+ export const EDIT_NOTES_SCALES = [
1868
+ "major", "minor", "dorian", "mixolydian", "phrygian", "lydian", "locrian",
1869
+ "harmMinor", "melMinor", "phrygDom", "lydDom", "locrian2", "altered",
1870
+ "wholeTone", "dimHW", "dimWH", "majPent", "minPent", "blues"
1871
+ ];
1872
+ /** One controller lane write of `set_notes`. */
1873
+ export const controllerLaneParams = z.object({
1874
+ kind: midiControllerKind,
1875
+ cc: z
1876
+ .number()
1877
+ .int()
1878
+ .min(0)
1879
+ .max(127)
1880
+ .optional()
1881
+ .describe("Controller number, 0..127. Required for kind `cc`, refused otherwise."),
1882
+ pitch: z
1883
+ .number()
1884
+ .int()
1885
+ .min(0)
1886
+ .max(127)
1887
+ .optional()
1888
+ .describe("Note pitch the pressure follows. Required for kind `polyPressure`, refused otherwise."),
1889
+ channel: z.number().int().min(0).max(15).optional().describe("MIDI channel 0..15. Default 0."),
1890
+ interpolation: z
1891
+ .enum(["linear", "step"])
1892
+ .optional()
1893
+ .describe("How the lane moves between points. Default linear."),
1894
+ points: z
1895
+ .array(z.object({
1896
+ tick: z
1897
+ .number()
1898
+ .int()
1899
+ .min(0)
1900
+ .describe("Ticks from the clip's content start, like a note's start_tick."),
1901
+ value: z
1902
+ .number()
1903
+ .int()
1904
+ .describe("0..127. Pitch bend runs -8192..8191, 0 at centre.")
1905
+ }))
1906
+ .max(MIDI_MAX_POINTS_PER_LANE)
1907
+ .describe("The lane's complete point list. An empty list removes the lane.")
1908
+ });
1909
+ /**
1910
+ * `set_notes`. Replaces the whole note list, or runs a piano-roll note
1911
+ * function on a selection, or writes controller lanes. One tool because the
1912
+ * three are one surface in the editor: a clip's content.
1913
+ */
1914
+ const completeNotePatch = z.object({
1915
+ id: z.string().min(1),
1916
+ pitch: z.number().int().min(0).max(127),
1917
+ velocity: z.number().int().min(1).max(127),
1918
+ startTick: z.number().int().nonnegative(),
1919
+ durationTick: z.number().int().positive(),
1920
+ muted: z.boolean().optional(),
1921
+ channel: z.number().int().min(0).max(15).optional(),
1922
+ releaseVelocity: z.number().int().min(0).max(127).optional(),
1923
+ expression: midiNoteExpression.optional()
1924
+ }).strict();
1925
+ export const notePatchParams = z.discriminatedUnion("edit", [
1926
+ z.object({
1927
+ edit: z.literal("midi.moveNotes"),
1928
+ notes: z
1929
+ .array(z
1930
+ .object({
1931
+ id: z.string().min(1),
1932
+ startTick: z.number().int().nonnegative().optional(),
1933
+ pitch: z.number().int().min(0).max(127).optional()
1934
+ })
1935
+ .strict())
1936
+ .max(MIDI_MAX_NOTES_PER_CLIP)
1937
+ }),
1938
+ z.object({
1939
+ edit: z.literal("midi.resizeNotes"),
1940
+ notes: z
1941
+ .array(z
1942
+ .object({
1943
+ id: z.string().min(1),
1944
+ durationTick: z.number().int().positive()
1945
+ })
1946
+ .strict())
1947
+ .max(MIDI_MAX_NOTES_PER_CLIP)
1948
+ }),
1949
+ z.object({
1950
+ edit: z.literal("midi.setNoteVelocities"),
1951
+ notes: z
1952
+ .array(z
1953
+ .object({
1954
+ id: z.string().min(1),
1955
+ velocity: z.number().int().min(1).max(127)
1956
+ })
1957
+ .strict())
1958
+ .max(MIDI_MAX_NOTES_PER_CLIP)
1959
+ }),
1960
+ z.object({
1961
+ edit: z.literal("midi.addNotes"),
1962
+ notes: z.array(completeNotePatch).max(MIDI_MAX_NOTES_PER_CLIP)
1963
+ }),
1964
+ z.object({
1965
+ edit: z.literal("midi.patchNotes"),
1966
+ notes: z.array(completeNotePatch).max(MIDI_MAX_NOTES_PER_CLIP),
1967
+ addedNotes: z.array(completeNotePatch).max(MIDI_MAX_NOTES_PER_CLIP).optional(),
1968
+ noteIds: z.array(z.string().min(1)).max(MIDI_MAX_NOTES_PER_CLIP).optional()
1969
+ }),
1970
+ z.object({
1971
+ edit: z.literal("midi.removeNotes"),
1972
+ noteIds: z.array(z.string().min(1)).max(MIDI_MAX_NOTES_PER_CLIP)
1973
+ })
1974
+ ]);
1975
+ export const setNotesParams = z.object({
1976
+ clip: targetParam,
1977
+ patch: notePatchParams.optional().describe("Apply one named MIDI patch with absolute values. Uses native edit payload fields (camelCase). Exclusive with notes, function and controllers."),
1978
+ notes: notesParam
1979
+ .optional()
1980
+ .describe("The clip's complete note list; this replaces what is there. Pass a note's `id` to keep it. Omit it to leave the notes alone."),
1981
+ function: z
1982
+ .enum(EDIT_NOTES_FUNCTIONS)
1983
+ .optional()
1984
+ .describe("Run a note function instead of replacing the list. scale_quantize snaps pitches into `scale` on `root`. legato extends each note to the next onset. remove_overlaps cuts a note at the next note of the same pitch. delete_duplicates drops a note that repeats an earlier one. glue merges the named notes of one pitch and channel (needs `note_ids`). mute and unmute set the muted flag. delete removes notes. set_velocity writes one `velocity`. Never together with `notes`."),
1985
+ note_ids: noteIdsParam,
1986
+ pitches: z
1987
+ .array(z.number().int().min(0).max(127))
1988
+ .optional()
1989
+ .describe("With `function`: act only on the notes on these pitches, the way a step-editor row does. Together with `note_ids` it keeps the notes in both. Omit both to act on every note."),
1990
+ velocity: z
1991
+ .number()
1992
+ .int()
1993
+ .min(1)
1994
+ .max(127)
1995
+ .optional()
1996
+ .describe("set_velocity only: the velocity to write, 1..127."),
1997
+ root: z
1998
+ .number()
1999
+ .int()
2000
+ .min(0)
2001
+ .max(11)
2002
+ .optional()
2003
+ .describe("scale_quantize only: the scale's root as a pitch class, 0 (C) to 11 (B). Default: project key tonic, or 0."),
2004
+ scale: z
2005
+ .enum(EDIT_NOTES_SCALES)
2006
+ .optional()
2007
+ .describe("scale_quantize only: the scale to snap to."),
2008
+ controllers: z
2009
+ .array(controllerLaneParams)
2010
+ .min(1)
2011
+ .max(MIDI_MAX_CONTROLLER_LANES_PER_CLIP)
2012
+ .optional()
2013
+ .describe("Controller lanes to write: CC, pitch bend, channel pressure or poly pressure. Each entry names a lane by `kind` (with `cc` or `pitch`) and `channel` and replaces that lane's whole point list. A lane that does not exist is created. An empty `points` list removes the lane. Lanes you do not name stay.")
2014
+ });
2015
+ export const SET_NOTES_DESCRIPTION = "Write a midi clip's content. Send patch with edit midi.moveNotes, midi.resizeNotes, midi.setNoteVelocities, midi.addNotes or midi.removeNotes to change only named notes. midi.patchNotes combines full changed notes, optional addedNotes and removed noteIds atomically. Unknown note IDs are errors. Use midi.addNotes to insert notes. " +
2016
+ "Send `notes` to replace the whole list, not " +
2017
+ "merge: every note the clip should keep, each with `pitch`, `start_tick` and " +
2018
+ "`duration_tick` (960 ticks = one quarter note, from the clip's content " +
2019
+ "start), and a note's `id` to keep it. Send `function` instead to run a " +
2020
+ "piano-roll note function on a selection: scale_quantize, legato, " +
2021
+ "remove_overlaps, delete_duplicates, glue, mute, unmute, delete or " +
2022
+ "set_velocity. Select with `note_ids`, with `pitches` (a step-editor row) " +
2023
+ "or both, else every note is acted on. Send `controllers` to write CC, pitch " +
2024
+ "bend or pressure lanes. Read the current notes and lanes with " +
2025
+ "ui_timeline_get_state and `clip`.";
2026
+ /** Narrow automation edits. Selection ranges include both endpoints. */
2027
+ /** Bounds sample conversion to safe integer magnitudes even at MHz sample rates. */
2028
+ export const MAX_AUTOMATION_TIME_MS = 1e12;
2029
+ const [mixerAutomationTarget, deviceAutomationTarget, clipAutomationTarget] = automationTarget.options;
2030
+ const strictAutomationTarget = z.discriminatedUnion("kind", [
2031
+ mixerAutomationTarget.strict(),
2032
+ deviceAutomationTarget.strict(),
2033
+ clipAutomationTarget.strict()
2034
+ ]);
2035
+ export const automationEditSchemas = {
2036
+ "automation.addPoints": z
2037
+ .object({
2038
+ edit: z.literal("automation.addPoints"),
2039
+ target: strictAutomationTarget,
2040
+ points: z
2041
+ .array(z
2042
+ .object({
2043
+ timeMs: z
2044
+ .number()
2045
+ .finite()
2046
+ .min(-MAX_AUTOMATION_TIME_MS)
2047
+ .max(MAX_AUTOMATION_TIME_MS),
2048
+ value: z.number().finite(),
2049
+ easing: z.string().min(1).max(256).optional()
2050
+ })
2051
+ .strict())
2052
+ .min(1)
2053
+ .max(MAX_AUTOMATION_POINTS_PER_LANE)
2054
+ })
2055
+ .strict(),
2056
+ "automation.movePoints": z
2057
+ .object({
2058
+ edit: z.literal("automation.movePoints"),
2059
+ target: strictAutomationTarget,
2060
+ fromMs: z.number().finite().min(0).max(MAX_AUTOMATION_TIME_MS),
2061
+ toMs: z.number().finite().min(0).max(MAX_AUTOMATION_TIME_MS),
2062
+ deltaMs: z
2063
+ .number()
2064
+ .finite()
2065
+ .min(-MAX_AUTOMATION_TIME_MS)
2066
+ .max(MAX_AUTOMATION_TIME_MS),
2067
+ deltaValue: z.number().finite()
2068
+ })
2069
+ .strict()
2070
+ .refine((p) => p.toMs >= p.fromMs, {
2071
+ message: "toMs must be at or after fromMs.",
2072
+ path: ["toMs"]
2073
+ }),
2074
+ "automation.deletePoints": z
2075
+ .object({
2076
+ edit: z.literal("automation.deletePoints"),
2077
+ target: strictAutomationTarget,
2078
+ fromMs: z.number().finite().min(0).max(MAX_AUTOMATION_TIME_MS),
2079
+ toMs: z.number().finite().min(0).max(MAX_AUTOMATION_TIME_MS)
2080
+ })
2081
+ .strict()
2082
+ .refine((p) => p.toMs >= p.fromMs, {
2083
+ message: "toMs must be at or after fromMs.",
2084
+ path: ["toMs"]
2085
+ }),
2086
+ "automation.clearLane": z
2087
+ .object({
2088
+ edit: z.literal("automation.clearLane"),
2089
+ target: strictAutomationTarget
2090
+ })
2091
+ .strict(),
2092
+ "automation.setLaneEnabled": z
2093
+ .object({
2094
+ edit: z.literal("automation.setLaneEnabled"),
2095
+ target: strictAutomationTarget,
2096
+ enabled: z.boolean()
2097
+ })
2098
+ .strict(),
2099
+ setTrackAutomationMode: z
2100
+ .object({
2101
+ edit: z.literal("setTrackAutomationMode"),
2102
+ mode: z.enum(["off", "read", "touch", "latch", "write"])
2103
+ })
2104
+ .strict()
2105
+ };
2106
+ export const automationEditParams = z.discriminatedUnion("edit", [
2107
+ automationEditSchemas["automation.addPoints"],
2108
+ automationEditSchemas["automation.movePoints"],
2109
+ automationEditSchemas["automation.deletePoints"],
2110
+ automationEditSchemas["automation.clearLane"],
2111
+ automationEditSchemas["automation.setLaneEnabled"],
2112
+ automationEditSchemas["setTrackAutomationMode"]
2113
+ ]);
2114
+ /** The lanes one `set_track` call writes. */
2115
+ export const automationLaneParams = z.object({
2116
+ target: automationTarget.describe("The control: `{kind:'mixer', param:'volumeDb'|'pan'}`, `{kind:'device', deviceId, param}` (deviceId `instrument` or a track effect id) or `{kind:'clip', property}` on a picture track."),
2117
+ enabled: z
2118
+ .boolean()
2119
+ .optional()
2120
+ .describe("false keeps the lane but plays the parameter's own value. Default true."),
2121
+ points: z
2122
+ .array(z.object({
2123
+ timeMs: z.number().finite().min(0).describe("Document time in ms."),
2124
+ value: z.number().finite().describe("The parameter's value in its own unit."),
2125
+ easing: z
2126
+ .string()
2127
+ .optional()
2128
+ .describe("Easing of the segment that ends at this point. Default linear.")
2129
+ }))
2130
+ .max(MAX_AUTOMATION_POINTS_PER_LANE)
2131
+ .describe("The lane's complete point list. An empty list removes the lane.")
2132
+ });
2133
+ /** The mixer and music fields `set_track` takes beyond the plain channel settings. */
2134
+ export const setTrackMixShape = {
2135
+ automationEdit: automationEditParams
2136
+ .optional()
2137
+ .describe("Narrow automation edit. Use alone with track. Moves/deletes select an inclusive fromMs/toMs range. Read lanes and points with get_state track."),
2138
+ effects: z
2139
+ .array(trackEffect)
2140
+ .max(32)
2141
+ .optional()
2142
+ .describe("The whole insert chain, in order. [] removes it."),
2143
+ folder: z
2144
+ .string()
2145
+ .min(1)
2146
+ .nullable()
2147
+ .optional()
2148
+ .describe("A track folder by name, created when missing. null takes the track out of its folder."),
2149
+ musicRole: musicRole
2150
+ .nullable()
2151
+ .optional()
2152
+ .describe("The stem the track holds in a music project. null clears it."),
2153
+ automationMode: z
2154
+ .enum(["off", "read", "touch", "latch", "write"])
2155
+ .optional()
2156
+ .describe("How the track's lanes play and record. off plays none, read plays them, touch, latch and write also record a pass."),
2157
+ automation: z
2158
+ .array(automationLaneParams)
2159
+ .max(MAX_AUTOMATION_LANES_PER_TRACK)
2160
+ .optional()
2161
+ .describe("Automation lanes to write. Each entry names its `target` and replaces that lane's whole point list, so moving, deleting and easing points are one write. A lane that does not exist is created. An empty `points` list removes the lane. Lanes you do not name stay. Points are sorted by time.")
2162
+ };
1603
2163
  // ── Smart Reframe ───────────────────────────────────────────────────────────
1604
2164
  const safeMarginParam = z
1605
2165
  .number()
@@ -1641,6 +2201,1047 @@ export const addReframeKeyframeParams = z
1641
2201
  export const clearReframeParams = z
1642
2202
  .object({ clip_id: z.string().min(1) })
1643
2203
  .strict();
2204
+ // ── Chords ──────────────────────────────────────────────────────────────────
2205
+ const chordTrackIdParam = z
2206
+ .string()
2207
+ .min(1)
2208
+ .optional()
2209
+ .describe("The chord track, by id or name. Default: the first chord track (set_chords and apply_progression create one when none exists).");
2210
+ const barParam = z.number().int().min(1);
2211
+ const startBarParam = barParam
2212
+ .optional()
2213
+ .describe("First bar, counted from 1. Default 1.");
2214
+ const endBarParam = barParam
2215
+ .optional()
2216
+ .describe("Last bar, counted from 1 and included. Default: the end.");
2217
+ /** `set_chords`. A chart string or a chord list, never both. */
2218
+ export const setChordsParams = z.object({
2219
+ trackId: chordTrackIdParam,
2220
+ startBar: startBarParam,
2221
+ chart: z
2222
+ .string()
2223
+ .optional()
2224
+ .describe('A bar chart: "|" separates bars, the chords in one bar split it evenly, "%" holds the previous chord, "-" is a slot with no chord. Example "| Am | F | C G | % |". Chord symbols: C C# D Eb E F F# G Ab A Bb B plus m, dim, aug, sus2, sus4, 5, 6, m6, 7, maj7, m7, m(maj7), m7b5, dim7, aug7, 7sus4, add9, m(add9), 9, maj9, m9, 7b9, 7#9, m11, 11, maj13, 13, and a slash bass such as C/E. Send `chart` or `chords`, not both.'),
2225
+ chords: z
2226
+ .array(z.object({
2227
+ symbol: z.string().min(1).describe('A chord symbol, such as "Am7" or "C/E".'),
2228
+ bars: z.number().positive().optional().describe("Length in bars."),
2229
+ beats: z
2230
+ .number()
2231
+ .positive()
2232
+ .optional()
2233
+ .describe("Length in beats. Added to `bars`. Default: 1 bar.")
2234
+ }).strict())
2235
+ .optional()
2236
+ .describe("Chords in order from `startBar`, each with a length. Send `chart` or `chords`, not both.")
2237
+ });
2238
+ export const SET_CHORDS_DESCRIPTION = "Write chords on a chord track from a bar chart string or a chord list. The chords replace what the covered range held. The chord track is created when the document has none. Read the result's `chart` to check what was written.";
2239
+ /** `clear_chords`. */
2240
+ export const clearChordsParams = z.object({
2241
+ trackId: chordTrackIdParam,
2242
+ startBar: startBarParam,
2243
+ endBar: endBarParam
2244
+ });
2245
+ export const CLEAR_CHORDS_DESCRIPTION = "Remove the chords from bar `startBar` to bar `endBar` (both included) of a chord track. A chord that crosses the edge is trimmed. Without bars it clears the whole track.";
2246
+ /** `join_clips`. Join clips of one track into one clip (CE5, D52). */
2247
+ export const joinClipsParams = z.object({
2248
+ clips: z
2249
+ .array(targetParam)
2250
+ .optional()
2251
+ .describe("The clips to join, at least two, all on one track. Omit it to join the selected clips.")
2252
+ });
2253
+ export const JOIN_CLIPS_DESCRIPTION = 'Join midi clips of one track into one clip from the first start to the last end. Notes, controllers and expression re-base to the new start, gaps stay silent, and harmony settings come from the first clip. Audio clips join only when they are adjacent pieces of one source with continuous source time (for example the halves of a split). Other audio joins are refused with "needs bounce". A looped clip is written out as plain copies first. Omit `clips` to join the selected clips.';
2254
+ /** `loop_clip`. Region loop on a midi or audio clip (CE3, D47). */
2255
+ export const loopClipParams = z.object({
2256
+ clip: targetParam,
2257
+ times: z
2258
+ .number()
2259
+ .positive()
2260
+ .optional()
2261
+ .describe("Play the loop window this many times. The clip then lasts `times` windows. A fraction ends part way through a window."),
2262
+ untilMs: z
2263
+ .number()
2264
+ .finite()
2265
+ .optional()
2266
+ .describe("Extend the clip to end at this timeline time, in ms."),
2267
+ untilBar: z
2268
+ .number()
2269
+ .int()
2270
+ .min(1)
2271
+ .optional()
2272
+ .describe("Extend the clip to end at the start of this bar, counted from 1, resolved through the tempo map."),
2273
+ loopLengthMs: z
2274
+ .number()
2275
+ .positive()
2276
+ .nullable()
2277
+ .optional()
2278
+ .describe("The length of one loop window in ms, taken from the clip's in-point. Default: the current loop length, or the clip's whole length for a clip that does not loop. `null` removes the loop and keeps the clip's length.")
2279
+ });
2280
+ export const LOOP_CLIP_DESCRIPTION = "Loop a midi or audio clip. The window from the clip's in-point, `loopLengthMs` long (default: the clip as it is), repeats until the clip's end. Send `times`, `untilMs` or `untilBar` to set the end, or only `loopLengthMs` to change the window. Notes and audio that cross a repeat boundary are cut there. `loopLengthMs: null` removes the loop. get_state shows `loopLengthMs` and `loopRepeats`. Splitting, joining or trimming a looped clip first writes it out as plain copies.";
2281
+ /** The tracks a section edit acts on (CE4, D48). */
2282
+ const sectionTrackIdsShape = {
2283
+ trackIds: z
2284
+ .array(z.string().min(1))
2285
+ .min(1)
2286
+ .optional()
2287
+ .describe("Track ids or names. Omit to edit every track, and also the markers. With trackIds only those tracks change.")
2288
+ };
2289
+ const sectionRangeShape = {
2290
+ fromBar: z
2291
+ .number()
2292
+ .int()
2293
+ .min(1)
2294
+ .optional()
2295
+ .describe("The range starts at the start of this bar, counted from 1."),
2296
+ toBar: z
2297
+ .number()
2298
+ .int()
2299
+ .min(1)
2300
+ .optional()
2301
+ .describe("The range ends at the start of this bar (not included), counted from 1. Needs fromBar."),
2302
+ fromMs: z.number().finite().min(0).optional().describe("Range start, in ms."),
2303
+ toMs: z.number().finite().min(0).optional().describe("Range end, in ms. Needs fromMs."),
2304
+ ...sectionTrackIdsShape
2305
+ };
2306
+ /** `insert_time`. Insert silence across tracks (CE4, D48). */
2307
+ export const insertTimeParams = z.object({
2308
+ ...barTimeShape,
2309
+ atMs: z.number().finite().min(0).optional().describe("Insert point, in ms. Send this or atBar."),
2310
+ bars: z
2311
+ .number()
2312
+ .positive()
2313
+ .finite()
2314
+ .optional()
2315
+ .describe("Length of the silence in bars of the current time signature. Send this or ms."),
2316
+ ms: z.number().positive().finite().optional().describe("Length of the silence, in ms."),
2317
+ ...sectionTrackIdsShape
2318
+ });
2319
+ export const INSERT_TIME_DESCRIPTION = "Insert silence. Content at or after the point moves later by the length. A clip that crosses the point splits there. Send `atBar` (with optional `beat`) or `atMs`, and `bars` or `ms`. Without `trackIds` every track changes, and so do the chords, markers and automation points. Locked clips move with the inserted time.";
2320
+ /** `delete_time`. Remove a range across tracks and close it (CE4, D48). */
2321
+ export const deleteTimeParams = z.object(sectionRangeShape);
2322
+ export const DELETE_TIME_DESCRIPTION = "Remove a time range and close it. Send `fromBar` and `toBar` (the range ends at the start of toBar) or `fromMs` and `toMs`. Clips that cross an edge are trimmed, clips inside are removed, and later content moves earlier. Without `trackIds` every track changes, and so do the chords, markers and automation points. It refuses when it would cut or remove a locked clip, and the error names the clips.";
2323
+ /** `duplicate_range`. Copy a section and insert the copy after it (CE4, D48). */
2324
+ export const duplicateRangeParams = z.object(sectionRangeShape);
2325
+ export const DUPLICATE_RANGE_DESCRIPTION = "Copy a section and insert the copy right after it. Send `fromBar` and `toBar` (the range ends at the start of toBar) or `fromMs` and `toMs`. Later content moves later by the section length. Without `trackIds` every track is copied, with the chords, markers and automation points inside the range.";
2326
+ /**
2327
+ * What `paste_range` places: a section's content, as `readSectionContent`
2328
+ * reads it (CE4, D61). Times are relative to the start of the section.
2329
+ */
2330
+ export const sectionContentShape = z.object({
2331
+ lengthMs: z.number().positive().finite().describe("Length of the section, in ms."),
2332
+ clips: z
2333
+ .array(timelineClip)
2334
+ .describe("Copied clips. `startMs` counts from the start of the section."),
2335
+ mediaTracks: z
2336
+ .array(mediaTrack)
2337
+ .optional()
2338
+ .describe("Tracking resources the copied clips own, by `clipId`."),
2339
+ chords: z
2340
+ .array(z.object({ trackId: z.string().min(1), chords: z.array(timelineChord) }))
2341
+ .optional()
2342
+ .describe("Chords by chord track. `startTick` counts from the start of the section."),
2343
+ automation: z
2344
+ .array(z.object({
2345
+ trackId: z.string().min(1),
2346
+ laneId: z.string().min(1).optional(),
2347
+ target: automationTarget,
2348
+ enabled: z.boolean().optional(),
2349
+ points: z.array(z.object({
2350
+ timeMs: z.number().finite().min(0),
2351
+ value: z.number().finite(),
2352
+ easing: z.string().optional()
2353
+ }))
2354
+ }))
2355
+ .optional()
2356
+ .describe("Automation points by track and lane. `timeMs` counts from the start of the section."),
2357
+ markers: z
2358
+ .array(timelineMarker)
2359
+ .optional()
2360
+ .describe("Markers. `timeMs` counts from the start of the section.")
2361
+ });
2362
+ /** `paste_range`. Place copied section content at a time, in one edit (CE4, D61). */
2363
+ export const pasteRangeParams = z.object({
2364
+ ...barTimeShape,
2365
+ atMs: z.number().finite().min(0).optional().describe("Paste point, in ms. Send this or atBar."),
2366
+ mode: z
2367
+ .enum(["insert", "overwrite"])
2368
+ .optional()
2369
+ .describe("`insert` (default) opens a gap of the section length at the point and places the content in it. `overwrite` replaces what the range covers on the tracks that receive content, and moves nothing."),
2370
+ content: sectionContentShape
2371
+ });
2372
+ export const PASTE_RANGE_DESCRIPTION = "Paste copied section content (clips with their tracking resources, chords, automation points, markers) at a time, as one edit and one undo step. Send `atBar` (with optional `beat`) or `atMs`, the `content`, and optionally `mode`. Insert mode shifts later content like insert_time. Overwrite mode replaces the range on the tracks that receive content. It refuses when a destination track is locked.";
2373
+ /** `list_progressions`. */
2374
+ export const LIST_PROGRESSIONS_DESCRIPTION = "List the progression library: id, name, family, numerals and length in bars. Pass an id or a name to ui_timeline_apply_progression.";
2375
+ /** `apply_progression`. */
2376
+ export const applyProgressionParams = z.object({
2377
+ progression: z
2378
+ .string()
2379
+ .min(1)
2380
+ .describe("A progression id or name from ui_timeline_list_progressions."),
2381
+ key: z
2382
+ .string()
2383
+ .optional()
2384
+ .describe('The key: "A minor", "C", "F# major", "Bb". Default: the document key, else C major.'),
2385
+ startBar: startBarParam,
2386
+ barsPerChord: z
2387
+ .number()
2388
+ .positive()
2389
+ .optional()
2390
+ .describe("Stretch each chord to this many bars. Default: the progression's own lengths."),
2391
+ repeat: z
2392
+ .number()
2393
+ .int()
2394
+ .min(1)
2395
+ .optional()
2396
+ .describe("How many times the progression plays in a row. Default 1."),
2397
+ trackId: chordTrackIdParam
2398
+ });
2399
+ export const APPLY_PROGRESSION_DESCRIPTION = "Write a library progression in a key onto a chord track. The chords replace what the covered range held. The chord track is created when the document has none.";
2400
+ /** `transpose_chords`. */
2401
+ export const transposeChordsParams = z.object({
2402
+ semitones: z.number().int().describe("Semitones to move up (positive) or down (negative)."),
2403
+ startBar: startBarParam,
2404
+ endBar: endBarParam,
2405
+ includeNotes: z
2406
+ .boolean()
2407
+ .optional()
2408
+ .describe("True also transposes the written notes of midi clips that do not follow the chord track, inside the range. Default false."),
2409
+ trackId: chordTrackIdParam
2410
+ });
2411
+ export const TRANSPOSE_CHORDS_DESCRIPTION = "Move the chords of a chord track by semitones. With `includeNotes` the written notes of midi clips that do not follow the chord track move with them.";
2412
+ /** `detect_chords`. */
2413
+ export const detectChordsParams = z.object({
2414
+ clipIds: z
2415
+ .array(z.string().min(1))
2416
+ .optional()
2417
+ .describe("Clips to read, by id or name. Send `clipIds` or `trackIds`."),
2418
+ trackIds: z
2419
+ .array(z.string().min(1))
2420
+ .optional()
2421
+ .describe("Tracks to read: every clip on them. Send `clipIds` or `trackIds`."),
2422
+ startBar: startBarParam,
2423
+ endBar: endBarParam,
2424
+ resolution: z
2425
+ .enum(["bar", "half", "beat"])
2426
+ .optional()
2427
+ .describe('One chord per "bar", per "half" bar, or per "beat". Default "bar".'),
2428
+ write: z
2429
+ .boolean()
2430
+ .optional()
2431
+ .describe("True (default) replaces the chords of the range on the chord track. False only returns the chart."),
2432
+ chordTrackId: chordTrackIdParam
2433
+ });
2434
+ export const DETECT_CHORDS_DESCRIPTION = "Find the chords of midi clips (from their notes) or audio clips (from the sound), one per bar, half bar or beat. Writes them to the chord track (created when the document has none) and returns the chart. Without `startBar` it starts at the bar of the first sounding note or clip, so chords before the source stay. Read midi and audio in separate calls. A track list skips drum tracks and muted clips.";
2435
+ /** `set_clip_harmony`. */
2436
+ export const setClipHarmonyParams = z.object({
2437
+ clipId: z.string().min(1).describe("The midi clip, by id or name."),
2438
+ style: z
2439
+ .enum(["off", "arp", "comp"])
2440
+ .optional()
2441
+ .describe('"arp" plays an arpeggio of the chord, "comp" plays a comping pattern, "off" plays the written notes.'),
2442
+ preset: z
2443
+ .string()
2444
+ .optional()
2445
+ .describe("A comp pattern name from ui_timeline_list_harmony_presets. Implies style comp."),
2446
+ order: z
2447
+ .enum(["up", "down", "updown", "played", "random"])
2448
+ .optional()
2449
+ .describe("Arpeggio order. Default up."),
2450
+ scale: z
2451
+ .enum(["off", "key", "chords"])
2452
+ .optional()
2453
+ .describe('Snaps written notes: "key" to the key scale, "chords" to the scale of each chord.'),
2454
+ octave: z.number().int().min(0).max(8).optional().describe("Octave of the chord voicing."),
2455
+ chordTrackId: z
2456
+ .string()
2457
+ .min(1)
2458
+ .optional()
2459
+ .describe("The chord track the clip follows. Default: the first chord track.")
2460
+ });
2461
+ export const SET_CLIP_HARMONY_DESCRIPTION = "Make a midi clip follow the chord track: arpeggiate it, comp it with a pattern, or snap its notes to the chords' scale. The fields you send merge into the clip's harmony. Use style off and scale off to stop following.";
2462
+ /** `list_harmony_presets`. */
2463
+ export const LIST_HARMONY_PRESETS_DESCRIPTION = "List the comp pattern names (with their family) and the arpeggio orders that ui_timeline_set_clip_harmony accepts.";
2464
+ /** `fit_notes_to_chords`. */
2465
+ export const fitNotesToChordsParams = z.object({
2466
+ clipIds: z.array(z.string().min(1)).min(1).describe("The midi clips, by id or name."),
2467
+ mode: z
2468
+ .enum(["chord-tones", "scale"])
2469
+ .optional()
2470
+ .describe('"scale" (default) moves each note to the nearest pitch of the chord\'s scale. "chord-tones" moves it to the nearest chord tone.'),
2471
+ chordTrackId: z
2472
+ .string()
2473
+ .min(1)
2474
+ .optional()
2475
+ .describe("The chord track. Default: the first chord track.")
2476
+ });
2477
+ export const FIT_NOTES_TO_CHORDS_DESCRIPTION = "Rewrite the notes of midi clips so each one sits in the chord that sounds at its start. Ties go down. Notes outside every chord stay. This changes the written notes, so the piano roll shows the result.";
2478
+ // ── Step Sequencer (SQ48–SQ54) ──────────────────────────────────────────────
2479
+ const stepSelectionParam = z
2480
+ .union([
2481
+ z.string().min(1),
2482
+ z.array(z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS)).min(1)
2483
+ ])
2484
+ .describe('1-based step indices: a range/list string like "1,5,9,13" or "1-4", or an integer array like [1, 5, 9].');
2485
+ const stepValuesPatchParam = z
2486
+ .object({
2487
+ on: z.boolean().optional(),
2488
+ velocity: z.number().int().min(1).max(127).optional(),
2489
+ gate: z.number().int().min(1).max(100).optional(),
2490
+ tie: z.boolean().optional(),
2491
+ note: z.number().int().min(-12).max(12).optional(),
2492
+ octave: z.number().int().min(-2).max(8).optional(),
2493
+ repeat: z.number().int().min(1).max(16).optional(),
2494
+ chance: z.number().int().min(0).max(100).optional(),
2495
+ offset: z.number().int().min(-50).max(50).optional(),
2496
+ stepRate: stepRate.nullable().optional(),
2497
+ skip: z.boolean().optional(),
2498
+ value: z.number().finite().optional(),
2499
+ condition: stepCondition.optional(),
2500
+ midiChannel: z.number().int().min(1).max(16).optional(),
2501
+ articulation: z.number().int().min(0).max(255).optional(),
2502
+ velocityRamp: z.number().int().min(-100).max(100).optional(),
2503
+ velocityCurve: z.number().int().min(-100).max(100).optional(),
2504
+ distribution: z.number().int().min(-100).max(100).optional()
2505
+ })
2506
+ .strict();
2507
+ const stepRampField = z.enum([
2508
+ "velocity",
2509
+ "gate",
2510
+ "note",
2511
+ "octave",
2512
+ "repeat",
2513
+ "chance",
2514
+ "offset",
2515
+ "value",
2516
+ "velocityRamp",
2517
+ "velocityCurve",
2518
+ "distribution"
2519
+ ]);
2520
+ const stepRowSortBy = z.enum([
2521
+ "type",
2522
+ "typeAndNote",
2523
+ "typeAndName",
2524
+ "typeAndKitPad"
2525
+ ]);
2526
+ const addPatternRowInputParam = z
2527
+ .object({
2528
+ assignment: stepRowAssignment
2529
+ .optional()
2530
+ .describe("Explicit row assignment (note, kit, melodic, degree, or automation)."),
2531
+ pitch: z
2532
+ .union([z.number().int().min(0).max(127), z.string().min(1)])
2533
+ .optional()
2534
+ .describe("Shorthand fixed note pitch (0..127 or note name like C3)."),
2535
+ pad: z
2536
+ .union([z.number().int().min(0).max(127), z.string().min(1)])
2537
+ .optional()
2538
+ .describe("Shorthand drum kit pad index or pad name."),
2539
+ degree: z
2540
+ .union([stepDegree, z.number().int().min(0).max(6)])
2541
+ .optional()
2542
+ .describe('Shorthand scale degree ("root".."7th" or 0..6).'),
2543
+ octave: z
2544
+ .number()
2545
+ .int()
2546
+ .min(-2)
2547
+ .max(8)
2548
+ .optional()
2549
+ .describe("Octave for a degree row (-2..8). Default 3."),
2550
+ cc: z
2551
+ .number()
2552
+ .int()
2553
+ .min(0)
2554
+ .max(127)
2555
+ .optional()
2556
+ .describe("Shorthand MIDI CC number 0..127 for an automation row."),
2557
+ param: z
2558
+ .string()
2559
+ .min(1)
2560
+ .optional()
2561
+ .describe('Shorthand automation parameter ("pitchBend", "channelPressure", or a device param id).'),
2562
+ deviceId: z
2563
+ .string()
2564
+ .min(1)
2565
+ .optional()
2566
+ .describe('Device id for a device automation row (default "instrument").'),
2567
+ name: z.string().min(1).optional().describe("Row display label."),
2568
+ text: z
2569
+ .string()
2570
+ .optional()
2571
+ .describe('Initial step text for this row, e.g. "x... x... x... x...".'),
2572
+ stepRate: stepRate.optional(),
2573
+ lengthSteps: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).optional(),
2574
+ playback: stepPlaybackMode.optional(),
2575
+ mute: z.boolean().optional(),
2576
+ solo: z.boolean().optional(),
2577
+ loopStart: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).optional(),
2578
+ loopEnd: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).optional(),
2579
+ midiChannel: z.number().int().min(1).max(16).optional(),
2580
+ automationMode: stepAutomationMode.optional(),
2581
+ color: z.string().min(1).optional(),
2582
+ subrows: z.array(stepEditMode).optional(),
2583
+ subrowsExpanded: z.boolean().optional()
2584
+ })
2585
+ .strict();
2586
+ export const getPatternParams = z.object({
2587
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2588
+ modes: z
2589
+ .array(stepEditMode)
2590
+ .optional()
2591
+ .describe("Optional edit modes to return per-step value arrays for each row.")
2592
+ });
2593
+ export const GET_PATTERN_DESCRIPTION = "Read a step sequencer pattern region: settings, rows, pattern text, and optional per-mode step value arrays (1-based steps).";
2594
+ export const createPatternRegionParams = z.object({
2595
+ trackId: z.string().min(1).describe("MIDI track id or name."),
2596
+ ...barTimeShape,
2597
+ atMs: z
2598
+ .number()
2599
+ .finite()
2600
+ .min(0)
2601
+ .optional()
2602
+ .describe("Start time in ms. Use this or atBar, never both."),
2603
+ bars: z
2604
+ .number()
2605
+ .positive()
2606
+ .finite()
2607
+ .optional()
2608
+ .describe("Region length in bars of the current time signature. Default 1."),
2609
+ name: z.string().min(1).optional().describe("Clip label."),
2610
+ template: z
2611
+ .string()
2612
+ .min(1)
2613
+ .optional()
2614
+ .describe('Library pattern/template id or name, or "track default".'),
2615
+ text: z
2616
+ .string()
2617
+ .optional()
2618
+ .describe("Optional step sequencer pattern text lines to populate rows.")
2619
+ });
2620
+ export const CREATE_PATTERN_REGION_DESCRIPTION = "Create a step sequencer pattern region on a MIDI track, defaulting to 1 bar and using the track template, drum kit pads, or pattern text.";
2621
+ export const convertPatternToMidiParams = z.object({
2622
+ clipIds: z
2623
+ .array(z.string().min(1))
2624
+ .min(1)
2625
+ .describe("Pattern region clip ids or names to expand into editable MIDI clips.")
2626
+ });
2627
+ export const CONVERT_PATTERN_TO_MIDI_DESCRIPTION = "Convert step sequencer pattern regions into regular MIDI clips with expanded notes and controller lanes, keeping region params.";
2628
+ export const convertMidiToPatternParams = z.object({
2629
+ clipIds: z
2630
+ .array(z.string().min(1))
2631
+ .min(1)
2632
+ .describe("MIDI clip ids or names to convert into step sequencer pattern regions."),
2633
+ stepRate: stepRate
2634
+ .optional()
2635
+ .describe('Optional step grid rate; defaults to "1/16".')
2636
+ });
2637
+ export const CONVERT_MIDI_TO_PATTERN_DESCRIPTION = "Convert MIDI clips into step sequencer pattern regions (up to 64 steps), reporting any dropped notes or same-step collisions.";
2638
+ export const separatePatternRowsParams = z.object({
2639
+ clipId: z.string().min(1).describe("Pattern region clip id or name to split by row.")
2640
+ });
2641
+ export const SEPARATE_PATTERN_ROWS_DESCRIPTION = "Separate a step sequencer pattern region into one MIDI track per row below the source track and remove the source region.";
2642
+ export const setPatternParams = z.object({
2643
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2644
+ name: z.string().optional().describe("Pattern name."),
2645
+ lengthSteps: z
2646
+ .number()
2647
+ .int()
2648
+ .min(1)
2649
+ .max(STEP_PATTERN_MAX_STEPS)
2650
+ .optional()
2651
+ .describe("Pattern length 1..64; growing repeats existing steps."),
2652
+ stepRate: stepRate
2653
+ .optional()
2654
+ .describe("Pattern step rate; writes through to every row."),
2655
+ playback: stepPlaybackMode
2656
+ .optional()
2657
+ .describe("Pattern playback order; writes through to every row."),
2658
+ swing: z.number().int().min(0).max(100).optional().describe("Swing amount 0..100."),
2659
+ swingDivision: stepSwingDivision.optional().describe("Swing grid division: 1/8 or 1/16."),
2660
+ legato: z.boolean().optional().describe("Extend gate-100 notes by +1 tick so they overlap the next step."),
2661
+ mono: z.boolean().optional().describe("Allow only one active note row per step on edits."),
2662
+ midiChannel: z
2663
+ .number()
2664
+ .int()
2665
+ .min(1)
2666
+ .max(16)
2667
+ .optional()
2668
+ .describe("Default MIDI channel 1..16; writes through to every row."),
2669
+ key: stepKey
2670
+ .nullable()
2671
+ .optional()
2672
+ .describe('Pattern key { tonic (0..11), mode ("major" | "minor") }, or null to clear.'),
2673
+ pitchSource: stepPitchSource
2674
+ .optional()
2675
+ .describe('Pitch source: "off", "key", or "chords".'),
2676
+ scale: stepScaleId
2677
+ .optional()
2678
+ .describe("Scale id for degree rows and scale quantize."),
2679
+ scaleQuantize: z
2680
+ .boolean()
2681
+ .optional()
2682
+ .describe("Snap row pitches to the pattern scale."),
2683
+ noTranspose: z
2684
+ .boolean()
2685
+ .optional()
2686
+ .describe("When changing key, skip transposing existing notes."),
2687
+ automationMode: stepAutomationMode
2688
+ .optional()
2689
+ .describe("Automation row interpolation: latch (step) or slide (linear)."),
2690
+ loopStart: z
2691
+ .number()
2692
+ .int()
2693
+ .min(1)
2694
+ .max(STEP_PATTERN_MAX_STEPS)
2695
+ .optional()
2696
+ .describe("1-based loop start step; writes through to every row."),
2697
+ loopEnd: z
2698
+ .number()
2699
+ .int()
2700
+ .min(1)
2701
+ .max(STEP_PATTERN_MAX_STEPS)
2702
+ .optional()
2703
+ .describe("1-based loop end step; writes through to every row.")
2704
+ });
2705
+ export const SET_PATTERN_DESCRIPTION = "Update step sequencer pattern settings (length, step rate, playback, swing, legato, mono, key, automation mode, loop range).";
2706
+ export const setPatternSeedParams = z.object({
2707
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2708
+ seed: z
2709
+ .number()
2710
+ .int()
2711
+ .min(0)
2712
+ .max(0xffffffff)
2713
+ .optional()
2714
+ .describe("Optional uint32 seed; omit to generate and return a fresh seed.")
2715
+ });
2716
+ export const SET_PATTERN_SEED_DESCRIPTION = "Set or regenerate the deterministic random seed of a step sequencer pattern for chance and random playback modes.";
2717
+ export const addPatternRowsParams = z.object({
2718
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2719
+ rows: z
2720
+ .array(addPatternRowInputParam)
2721
+ .min(1)
2722
+ .describe("Rows to add (max 128 total rows per pattern).")
2723
+ });
2724
+ export const ADD_PATTERN_ROWS_DESCRIPTION = "Add note, kit pad, melodic, degree, or automation rows to a step sequencer pattern region (up to 128 rows total).";
2725
+ export const setPatternRowParams = z.object({
2726
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2727
+ row: z.string().min(1).describe("Row id or unique case-insensitive row name."),
2728
+ name: z.string().min(1).optional(),
2729
+ assignment: stepRowAssignment.optional(),
2730
+ stepRate: stepRate.optional(),
2731
+ lengthSteps: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).optional(),
2732
+ playback: stepPlaybackMode.optional(),
2733
+ mute: z.boolean().optional(),
2734
+ solo: z.boolean().optional(),
2735
+ loopStart: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).optional(),
2736
+ loopEnd: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).optional(),
2737
+ midiChannel: z.number().int().min(1).max(16).optional(),
2738
+ automationMode: stepAutomationMode.optional(),
2739
+ color: z.string().min(1).nullable().optional(),
2740
+ subrows: z.array(stepEditMode).optional(),
2741
+ subrowsExpanded: z.boolean().optional()
2742
+ });
2743
+ export const SET_PATTERN_ROW_DESCRIPTION = "Edit settings, assignment, mute/solo, loop range, length, automation mode, color, or subrows of one row in a step sequencer pattern.";
2744
+ export const removePatternRowsParams = z.object({
2745
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2746
+ rows: z
2747
+ .array(z.string().min(1))
2748
+ .optional()
2749
+ .describe("Row ids or names to remove."),
2750
+ unused: z
2751
+ .boolean()
2752
+ .optional()
2753
+ .describe("True removes every row with no active steps.")
2754
+ });
2755
+ export const REMOVE_PATTERN_ROWS_DESCRIPTION = "Remove named rows or all unused rows from a step sequencer pattern region.";
2756
+ export const movePatternRowParams = z.object({
2757
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2758
+ row: z.string().min(1).describe("Row id or unique case-insensitive row name."),
2759
+ toIndex: z.number().int().min(0).describe("0-based destination index in the pattern row list.")
2760
+ });
2761
+ export const MOVE_PATTERN_ROW_DESCRIPTION = "Move a step sequencer pattern row to a new 0-based index.";
2762
+ export const sortPatternRowsParams = z.object({
2763
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2764
+ by: stepRowSortBy.describe("Sort criterion: type, typeAndNote, typeAndName, or typeAndKitPad."),
2765
+ descending: z.boolean().optional().describe("Reverse sort direction. Default false.")
2766
+ });
2767
+ export const SORT_PATTERN_ROWS_DESCRIPTION = "Sort rows in a step sequencer pattern by type, note, name, or kit pad.";
2768
+ export const setPatternRowSortParams = z.object({
2769
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2770
+ rowSort: stepRowSort.describe('Active row sort mode: "none" (manual order), "typeAsc", "typeDesc", "typeAndNoteAsc", "typeAndNoteDesc", "typeAndNameAsc", "typeAndNameDesc", "typeAndKitPadAsc", or "typeAndKitPadDesc".')
2771
+ });
2772
+ export const SET_PATTERN_ROW_SORT_DESCRIPTION = 'Set or clear the persistent row sort mode of a step sequencer pattern ("none" or a sort mode); sorts existing rows immediately when not "none" and keeps newly added rows in sorted order.';
2773
+ export const copyPatternRowParams = z.object({
2774
+ clipId: z.string().min(1).describe("Source pattern region clip id or name."),
2775
+ row: z.string().min(1).describe("Source row id or name."),
2776
+ toClipId: z
2777
+ .string()
2778
+ .min(1)
2779
+ .optional()
2780
+ .describe("Destination pattern clip id or name. Default: same clip."),
2781
+ toRow: z
2782
+ .string()
2783
+ .min(1)
2784
+ .optional()
2785
+ .describe("Destination row id or name to replace (keeps fixed note/kit pitch)."),
2786
+ asNew: z
2787
+ .boolean()
2788
+ .optional()
2789
+ .describe("Paste as a new row instead of replacing an existing row."),
2790
+ settingsOnly: z
2791
+ .boolean()
2792
+ .optional()
2793
+ .describe("Copy only row settings (rate, length, playback, loop, subrows) without step values."),
2794
+ nextAssignment: z
2795
+ .boolean()
2796
+ .optional()
2797
+ .describe("Duplicate as a new row assigned to the next note, pad, degree, or CC.")
2798
+ });
2799
+ export const COPY_PATTERN_ROW_DESCRIPTION = "Copy or duplicate a step sequencer pattern row to another row, a new row, or another pattern region.";
2800
+ export const setStepsParams = z.object({
2801
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2802
+ row: z.string().min(1).describe("Row id or unique case-insensitive row name."),
2803
+ steps: stepSelectionParam,
2804
+ values: stepValuesPatchParam
2805
+ .optional()
2806
+ .describe("Fields to set on each selected step. Editing a value on an off step turns it on."),
2807
+ ramp: z
2808
+ .object({
2809
+ field: stepRampField,
2810
+ from: z.number(),
2811
+ to: z.number(),
2812
+ leaveOff: z.boolean().optional()
2813
+ })
2814
+ .strict()
2815
+ .optional()
2816
+ .describe("Linear ramp across the selected steps for one numeric field.")
2817
+ });
2818
+ export const SET_STEPS_DESCRIPTION = "Edit step values or write a linear value ramp on selected 1-based steps of a step sequencer pattern row.";
2819
+ export const setPatternTextParams = z.object({
2820
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2821
+ text: z
2822
+ .string()
2823
+ .min(1)
2824
+ .describe("Pattern text lines (`<Row> [| rate] : xX o . - _`)."),
2825
+ mode: z
2826
+ .enum(["merge", "replace"])
2827
+ .optional()
2828
+ .describe('"merge" (default) updates matching rows and adds missing ones; "replace" replaces all rows.')
2829
+ });
2830
+ export const SET_PATTERN_TEXT_DESCRIPTION = "Apply compact pattern text lines (`x`, `X`, `o`, `.`, `-`, `_`) to a step sequencer pattern region by merge or replace.";
2831
+ export const clearPatternParams = z.object({
2832
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2833
+ scope: z
2834
+ .enum(["steps", "row", "pattern"])
2835
+ .describe("Clear selected steps, one row, or the whole pattern."),
2836
+ row: z.string().min(1).optional().describe("Row id or name (required for steps and row scope)."),
2837
+ steps: stepSelectionParam.optional().describe("1-based steps (required for steps scope)."),
2838
+ mode: stepEditMode
2839
+ .optional()
2840
+ .describe("Optional single mode to clear; omit to reset every field and turn steps off."),
2841
+ rowType: z
2842
+ .enum(["note", "automation"])
2843
+ .optional()
2844
+ .describe("When scope is pattern, restrict clearing to note rows or automation rows.")
2845
+ });
2846
+ export const CLEAR_PATTERN_DESCRIPTION = "Clear steps, a row, or a whole step sequencer pattern, either resetting all values or one edit mode.";
2847
+ export const copyStepsParams = z.object({
2848
+ clipId: z.string().min(1).describe("Source pattern region clip id or name."),
2849
+ row: z.string().min(1).describe("Source row id or name."),
2850
+ steps: stepSelectionParam,
2851
+ toRow: z.string().min(1).describe("Destination row id or name (must match note vs automation type)."),
2852
+ toStep: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).describe("1-based destination start step."),
2853
+ toClipId: z.string().min(1).optional().describe("Optional destination pattern clip id or name."),
2854
+ cut: z.boolean().optional().describe("True resets the source steps after copying.")
2855
+ });
2856
+ export const COPY_STEPS_DESCRIPTION = "Copy or cut 1-based steps from one step sequencer row to another row of the same type.";
2857
+ export const repeatStepParams = z.object({
2858
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2859
+ row: z.string().min(1).describe("Row id or name."),
2860
+ step: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).describe("1-based step to repeat into the next step.")
2861
+ });
2862
+ export const REPEAT_STEP_DESCRIPTION = "Copy a step sequencer step with all its settings into the immediately following step.";
2863
+ export const rotatePatternParams = z.object({
2864
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2865
+ by: z.number().int().describe("Steps to shift (+ right, - left)."),
2866
+ row: z.string().min(1).optional().describe("Optional row id or name; omit to rotate every row."),
2867
+ mode: stepEditMode
2868
+ .optional()
2869
+ .describe("Optional mode to rotate only that mode's values while keeping on/off in place.")
2870
+ });
2871
+ export const ROTATE_PATTERN_DESCRIPTION = "Rotate steps or one edit mode's values left or right across a step sequencer pattern or row.";
2872
+ export const transposePatternParams = z.object({
2873
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2874
+ semitones: z.number().int().describe("Semitones to transpose (+ up, - down)."),
2875
+ row: z.string().min(1).optional().describe("Optional row id or name; omit to transpose all note/melodic rows."),
2876
+ steps: stepSelectionParam.optional().describe("Optional 1-based steps to transpose on melodic/kit rows.")
2877
+ });
2878
+ export const TRANSPOSE_PATTERN_DESCRIPTION = "Transpose pitches in a step sequencer pattern, a row, or selected steps by semitones.";
2879
+ export const randomizePatternParams = z.object({
2880
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2881
+ mode: stepEditMode.describe("Edit mode to randomize (e.g. onOff, velocity, gate, note, chance, offset)."),
2882
+ rows: z.array(z.string().min(1)).optional().describe("Optional row ids or names; omit for all rows."),
2883
+ steps: stepSelectionParam.optional().describe("Optional 1-based steps; omit for all steps."),
2884
+ seed: z
2885
+ .number()
2886
+ .int()
2887
+ .min(0)
2888
+ .max(0xffffffff)
2889
+ .optional()
2890
+ .describe("Deterministic uint32 seed; returned in the result so calls are repeatable."),
2891
+ density: z
2892
+ .number()
2893
+ .min(0)
2894
+ .max(100)
2895
+ .optional()
2896
+ .describe("Probability percent 0..100 for on/off randomization. Default 50.")
2897
+ });
2898
+ export const RANDOMIZE_PATTERN_DESCRIPTION = "Randomize one edit mode in a step sequencer pattern with a repeatable seed, respecting mono mode.";
2899
+ export const nudgePatternValuesParams = z.object({
2900
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2901
+ mode: stepEditMode.describe("Edit mode to increment or decrement."),
2902
+ delta: z.number().finite().describe("Step delta (+ increment, - decrement)."),
2903
+ row: z.string().min(1).optional().describe("Optional row id or name; omit for all rows.")
2904
+ });
2905
+ export const NUDGE_PATTERN_VALUES_DESCRIPTION = "Increment or decrement one edit mode's values across a step sequencer pattern or row.";
2906
+ export const tieStepsParams = z.object({
2907
+ clipId: z.string().min(1).describe("Pattern region clip id or name."),
2908
+ row: z.string().min(1).describe("Row id or name."),
2909
+ from: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).describe("1-based start step of the tie range."),
2910
+ to: z.number().int().min(1).max(STEP_PATTERN_MAX_STEPS).describe("1-based end step of the tie range."),
2911
+ tie: z.boolean().describe("True ties steps (from+1..to) into from; false clears ties across the range.")
2912
+ });
2913
+ export const TIE_STEPS_DESCRIPTION = "Tie or untie a 1-based range of steps in a step sequencer pattern row.";
2914
+ export const listStepPatternsParams = z.object({
2915
+ query: z.string().optional().describe("Case-insensitive name/tag substring filter."),
2916
+ kind: z.enum(["pattern", "template"]).optional().describe("Filter by pattern or blank template."),
2917
+ category: z.string().optional().describe("Filter by category (e.g. Drums, Bass, Keys, Arps, Templates)."),
2918
+ folder: z
2919
+ .string()
2920
+ .optional()
2921
+ .describe("Filter user entries by folder path or folder id (full or 12-char prefix).")
2922
+ });
2923
+ export const LIST_STEP_PATTERNS_DESCRIPTION = "List factory and saved user step sequencer patterns, templates, and user library folders.";
2924
+ export const applyStepPatternParams = z.object({
2925
+ clipId: z
2926
+ .string()
2927
+ .min(1)
2928
+ .optional()
2929
+ .describe("Existing pattern (or empty MIDI) clip id or name to load into."),
2930
+ trackId: z
2931
+ .string()
2932
+ .min(1)
2933
+ .optional()
2934
+ .describe("MIDI track id or name to create a new pattern region on (when clipId is omitted). When the track has no clips and still holds its default or unset instrument, it takes the pattern's saved instrument or preset."),
2935
+ ...barTimeShape,
2936
+ atMs: z.number().finite().min(0).optional().describe("Start time in ms when creating on trackId."),
2937
+ bars: z.number().positive().finite().optional().describe("Length in bars when creating on trackId. Default 1."),
2938
+ pattern: z.string().min(1).describe("Pattern or template id or name from ui_timeline_list_step_patterns."),
2939
+ useProjectKey: z
2940
+ .boolean()
2941
+ .optional()
2942
+ .describe("True transposes melodic/degree rows to the project key.")
2943
+ });
2944
+ export const APPLY_STEP_PATTERN_DESCRIPTION = "Load a factory or user step sequencer pattern or template onto a region or create a new pattern region on a track, applying the pattern's saved instrument or preset when the target MIDI track is empty with its default instrument.";
2945
+ export const saveStepPatternParams = z.object({
2946
+ clipId: z.string().min(1).describe("Pattern region clip id or name to save."),
2947
+ name: z.string().trim().min(1).describe("Name for the saved pattern or template."),
2948
+ kind: z.enum(["pattern", "template"]).describe("Save full pattern or step-free template."),
2949
+ folder: z.string().optional().describe("Optional subfolder inside Step Patterns/<Patterns|Templates>.")
2950
+ });
2951
+ export const SAVE_STEP_PATTERN_DESCRIPTION = "Save a step sequencer region (along with its track's instrument and preset, when set) as a reusable user pattern or template in the Step Patterns library.";
2952
+ export const setTrackStepTemplateParams = z.object({
2953
+ trackId: z.string().min(1).describe("MIDI track id or name."),
2954
+ fromClipId: z
2955
+ .string()
2956
+ .min(1)
2957
+ .optional()
2958
+ .describe("Pattern clip id or name whose rows/settings become the track's default step template."),
2959
+ clear: z.boolean().optional().describe("True removes the stored default template on the track.")
2960
+ });
2961
+ export const SET_TRACK_STEP_TEMPLATE_DESCRIPTION = "Store a pattern's template as a MIDI track's default step sequencer template, or clear it.";
2962
+ export const createStepPatternFolderParams = z.object({
2963
+ name: z
2964
+ .string()
2965
+ .trim()
2966
+ .min(1)
2967
+ .describe('Folder name or relative subfolder path (e.g. "Drums" or "Drums/Trap") inside Step Patterns/<Patterns|Templates>.'),
2968
+ kind: z
2969
+ .enum(["pattern", "template"])
2970
+ .optional()
2971
+ .describe('Library section: "pattern" (default) or "template".'),
2972
+ parentFolder: z
2973
+ .string()
2974
+ .optional()
2975
+ .describe("Optional parent subfolder path or folder id (full or 12-char prefix) inside the same section.")
2976
+ });
2977
+ export const CREATE_STEP_PATTERN_FOLDER_DESCRIPTION = "Create a user folder in the step sequencer pattern or template library.";
2978
+ export const renameStepPatternFolderParams = z.object({
2979
+ folder: z
2980
+ .string()
2981
+ .trim()
2982
+ .min(1)
2983
+ .describe('Existing user folder path (e.g. "Drums" or "Step Patterns/Patterns/Drums") or folder id (full or 12-char prefix).'),
2984
+ newName: z
2985
+ .string()
2986
+ .trim()
2987
+ .min(1)
2988
+ .describe("New single-segment name for the folder."),
2989
+ kind: z
2990
+ .enum(["pattern", "template"])
2991
+ .optional()
2992
+ .describe('Library section ("pattern" or "template"), optional when folder is an id, full path, or unique relative path.')
2993
+ });
2994
+ export const RENAME_STEP_PATTERN_FOLDER_DESCRIPTION = "Rename a user folder in the step sequencer pattern library and update patterns inside it.";
2995
+ export const deleteStepPatternFolderParams = z.object({
2996
+ folder: z
2997
+ .string()
2998
+ .trim()
2999
+ .min(1)
3000
+ .describe('Existing user folder path or folder id (full or 12-char prefix) to delete; patterns inside move to its parent folder.'),
3001
+ kind: z
3002
+ .enum(["pattern", "template"])
3003
+ .optional()
3004
+ .describe('Library section ("pattern" or "template"), optional when folder is an id, full path, or unique relative path.')
3005
+ });
3006
+ export const DELETE_STEP_PATTERN_FOLDER_DESCRIPTION = "Delete a user folder in the step sequencer pattern library and move its patterns to the parent folder.";
3007
+ export const moveStepPatternParams = z.object({
3008
+ pattern: z
3009
+ .string()
3010
+ .trim()
3011
+ .min(1)
3012
+ .describe("User step pattern or template id (full or 12-char prefix) or unique name."),
3013
+ folder: z
3014
+ .string()
3015
+ .nullable()
3016
+ .optional()
3017
+ .describe('Destination folder path (e.g. "Drums"), folder id (full or 12-char prefix), or empty/null to move to the section root.')
3018
+ });
3019
+ export const MOVE_STEP_PATTERN_DESCRIPTION = "Move a user step sequencer pattern or template into another library folder or back to the root.";
3020
+ // ── VST/AU plug-in hosting (VST1) ───────────────────────────────────────────
3021
+ const pluginSelectorParam = z
3022
+ .union([
3023
+ z.string().trim().min(1),
3024
+ z
3025
+ .object({
3026
+ uid: z.string().min(1).max(512).optional(),
3027
+ path: z.string().min(1).max(4096).optional(),
3028
+ name: z.string().min(1).max(256).optional(),
3029
+ vendor: z.string().max(256).optional(),
3030
+ format: z.enum(["vst3", "au"]).optional()
3031
+ })
3032
+ .refine((v) => Boolean(v.uid || v.path || v.name), {
3033
+ message: "Provide at least one of uid, path, or name to select a plugin."
3034
+ })
3035
+ ])
3036
+ .describe("Plugin identifier from ui_timeline_list_plugins: uid, bundle path, unique case-insensitive name, or { uid, path, name, vendor, format }.");
3037
+ export const listPluginsParams = z.object({
3038
+ kind: z
3039
+ .enum(["instrument", "effect", "all"])
3040
+ .optional()
3041
+ .describe('Filter by plugin role: "instrument", "effect", or "all" (default "all").'),
3042
+ format: z
3043
+ .enum(["vst3", "au", "all"])
3044
+ .optional()
3045
+ .describe('Filter by plugin format: "vst3", "au", or "all" (default "all").'),
3046
+ query: z
3047
+ .string()
3048
+ .optional()
3049
+ .describe("Optional case-insensitive substring filter on plugin name, vendor, uid, or path."),
3050
+ rescan: z
3051
+ .boolean()
3052
+ .optional()
3053
+ .describe("Force a fresh scan of standard VST3/AU plugin folders instead of reading the cached scan.")
3054
+ });
3055
+ export const LIST_PLUGINS_DESCRIPTION = "List available third-party VST3 and AU instruments and audio effects installed on the host machine.";
3056
+ const MAX_INT32 = 2_147_483_647;
3057
+ export const loadPluginParams = z.object({
3058
+ track: trackTargetParam.describe('Track id or name, or "master" for master bus insert effects.'),
3059
+ plugin: pluginSelectorParam,
3060
+ slot: z
3061
+ .enum(["instrument", "effect"])
3062
+ .optional()
3063
+ .describe('Where to load the plugin: "instrument" (MIDI tracks only) or "effect" (audio, MIDI, or master insert chain). Omit to infer from the plugin role and track type.'),
3064
+ effectId: z
3065
+ .string()
3066
+ .trim()
3067
+ .min(1)
3068
+ .optional()
3069
+ .describe("When loading an insert effect, replace an existing effect by id (or 12-char prefix) instead of appending a new slot."),
3070
+ index: z
3071
+ .number()
3072
+ .int()
3073
+ .min(0)
3074
+ .max(MAX_INT32)
3075
+ .optional()
3076
+ .describe("Optional 0-based insertion index in the track or master insert effect chain."),
3077
+ enabled: z
3078
+ .boolean()
3079
+ .optional()
3080
+ .describe("Whether a newly loaded insert effect starts enabled (default true)."),
3081
+ wet: z
3082
+ .number()
3083
+ .min(0)
3084
+ .max(1)
3085
+ .optional()
3086
+ .describe("Dry/wet mix for an insert effect in 0..1 (default 1)."),
3087
+ gainDb: z
3088
+ .number()
3089
+ .min(-60)
3090
+ .max(12)
3091
+ .optional()
3092
+ .describe("Output gain in dB for a VST/AU instrument (-60..12, default 0)."),
3093
+ state: z
3094
+ .string()
3095
+ .max(8_000_000)
3096
+ .nullable()
3097
+ .optional()
3098
+ .describe("Optional initial base64 plugin state. Omit or pass null for the plugin default sound.")
3099
+ });
3100
+ export const LOAD_PLUGIN_DESCRIPTION = "Load a third-party VST3/AU instrument onto a MIDI track or insert a VST3/AU effect onto an audio, MIDI, or master bus chain.";
3101
+ export const listPluginPresetsParams = z.object({
3102
+ track: trackTargetParam.describe('Track id or name, or "master" for a master bus insert effect.'),
3103
+ effectId: z
3104
+ .string()
3105
+ .trim()
3106
+ .min(1)
3107
+ .optional()
3108
+ .describe("Insert effect id (or 12-char prefix or unique plugin name). Omit to address the track's VST/AU instrument."),
3109
+ query: z
3110
+ .string()
3111
+ .optional()
3112
+ .describe("Optional case-insensitive substring filter on preset names.")
3113
+ });
3114
+ export const LIST_PLUGIN_PRESETS_DESCRIPTION = "List the presets (programs) exposed by a loaded VST3/AU instrument or insert effect, together with its active preset index.";
3115
+ export const selectPluginPresetParams = z.object({
3116
+ track: trackTargetParam.describe('Track id or name, or "master" for a master bus insert effect.'),
3117
+ effectId: z
3118
+ .string()
3119
+ .trim()
3120
+ .min(1)
3121
+ .optional()
3122
+ .describe("Insert effect id (or 12-char prefix or unique plugin name). Omit to address the track's VST/AU instrument."),
3123
+ preset: z
3124
+ .union([z.number().int().min(0).max(MAX_INT32), z.string().trim().min(1).max(256)])
3125
+ .describe("0-based preset index or case-insensitive preset name from ui_timeline_list_plugin_presets.")
3126
+ });
3127
+ export const SELECT_PLUGIN_PRESET_DESCRIPTION = "Select a preset by index or name on a loaded VST3/AU instrument or insert effect and persist the resulting plugin state on the timeline.";
3128
+ export const getPluginParametersParams = z.object({
3129
+ track: trackTargetParam.describe('Track id or name, or "master" for a master bus insert effect.'),
3130
+ effectId: z
3131
+ .string()
3132
+ .trim()
3133
+ .min(1)
3134
+ .optional()
3135
+ .describe("Insert effect id (or 12-char prefix or unique plugin name). Omit to address the track's VST/AU instrument."),
3136
+ parameters: z
3137
+ .array(z.union([z.string().trim().min(1).max(256), z.number().int().min(0).max(MAX_INT32)]))
3138
+ .max(256)
3139
+ .optional()
3140
+ .describe("Optional parameter ids, indices, or names to read. Omit to list every parameter exposed by the plugin."),
3141
+ query: z
3142
+ .string()
3143
+ .optional()
3144
+ .describe("Optional case-insensitive substring filter on parameter id, name, or unit label.")
3145
+ });
3146
+ export const GET_PLUGIN_PARAMETERS_DESCRIPTION = "List or read parameters of a loaded VST3/AU instrument or insert effect, returning each parameter's id, index, name, normalized value (0..1), and formatted displayValue.";
3147
+ const pluginParameterChangeParam = z
3148
+ .object({
3149
+ parameter: z
3150
+ .union([z.string().trim().min(1).max(256), z.number().int().min(0).max(MAX_INT32)])
3151
+ .describe("Parameter id, 0-based index, or case-insensitive name from ui_timeline_get_plugin_parameters."),
3152
+ value: z
3153
+ .number()
3154
+ .min(0)
3155
+ .max(1)
3156
+ .optional()
3157
+ .describe("Normalized parameter value in 0..1. Provide either value or displayValue, not both."),
3158
+ displayValue: z
3159
+ .string()
3160
+ .trim()
3161
+ .min(1)
3162
+ .max(256)
3163
+ .optional()
3164
+ .describe('Formatted display value (e.g. "1200 Hz", "-6 dB", "On"). Provide either value or displayValue, not both.')
3165
+ })
3166
+ .superRefine((entry, ctx) => {
3167
+ const hasValue = entry.value !== undefined;
3168
+ const hasDisplay = entry.displayValue !== undefined;
3169
+ if (hasValue === hasDisplay) {
3170
+ ctx.addIssue({
3171
+ code: "custom",
3172
+ message: "Provide exactly one of value (0..1) or displayValue."
3173
+ });
3174
+ }
3175
+ });
3176
+ export const setPluginParametersShape = {
3177
+ track: trackTargetParam.describe('Track id or name, or "master" for a master bus insert effect.'),
3178
+ effectId: z
3179
+ .string()
3180
+ .trim()
3181
+ .min(1)
3182
+ .optional()
3183
+ .describe("Insert effect id (or 12-char prefix or unique plugin name). Omit to address the track's VST/AU instrument."),
3184
+ parameter: z
3185
+ .union([z.string().trim().min(1).max(256), z.number().int().min(0).max(MAX_INT32)])
3186
+ .optional()
3187
+ .describe("Single parameter id, 0-based index, or name (shorthand for a one-entry `parameters` array)."),
3188
+ value: z
3189
+ .number()
3190
+ .min(0)
3191
+ .max(1)
3192
+ .optional()
3193
+ .describe("Normalized 0..1 value for the single `parameter` shorthand."),
3194
+ displayValue: z
3195
+ .string()
3196
+ .trim()
3197
+ .min(1)
3198
+ .max(256)
3199
+ .optional()
3200
+ .describe("Formatted display value for the single `parameter` shorthand."),
3201
+ parameters: z
3202
+ .array(pluginParameterChangeParam)
3203
+ .min(1)
3204
+ .max(128)
3205
+ .optional()
3206
+ .describe("One or more parameter updates: [{ parameter, value | displayValue }].")
3207
+ };
3208
+ export const setPluginParametersParams = z
3209
+ .object(setPluginParametersShape)
3210
+ .superRefine((input, ctx) => {
3211
+ const hasList = input.parameters !== undefined;
3212
+ const hasSingle = input.parameter !== undefined;
3213
+ if (hasList && hasSingle) {
3214
+ ctx.addIssue({
3215
+ code: "custom",
3216
+ message: "Pass either `parameters` or single-parameter `parameter`, not both."
3217
+ });
3218
+ return;
3219
+ }
3220
+ if (!hasList && !hasSingle) {
3221
+ ctx.addIssue({
3222
+ code: "custom",
3223
+ message: "Pass `parameters` or `parameter` with `value` or `displayValue`."
3224
+ });
3225
+ return;
3226
+ }
3227
+ if (hasSingle) {
3228
+ const hasValue = input.value !== undefined;
3229
+ const hasDisplay = input.displayValue !== undefined;
3230
+ if (hasValue === hasDisplay) {
3231
+ ctx.addIssue({
3232
+ code: "custom",
3233
+ message: "Provide exactly one of value (0..1) or displayValue for `parameter`."
3234
+ });
3235
+ }
3236
+ }
3237
+ else if (input.value !== undefined || input.displayValue !== undefined) {
3238
+ ctx.addIssue({
3239
+ code: "custom",
3240
+ message: "Top-level value/displayValue only applies with single `parameter`, not `parameters`."
3241
+ });
3242
+ }
3243
+ });
3244
+ export const SET_PLUGIN_PARAMETERS_DESCRIPTION = "Set one or more parameters on a loaded VST3/AU instrument or insert effect by id, index, or name using either a normalized 0..1 value or a displayValue string, and persist the updated plugin state.";
1644
3245
  // ── The shared tool surface ─────────────────────────────────────────────────
1645
3246
  /**
1646
3247
  * Every `ui_timeline_*` tool both the headless bridge and the browser registry
@@ -1719,6 +3320,22 @@ export const SHARED_TIMELINE_TOOL_NAMES = [
1719
3320
  "ui_timeline_transpose_clip",
1720
3321
  "ui_timeline_quantize_notes",
1721
3322
  "ui_timeline_scale_velocity",
3323
+ // Chords: the chord track and the clips that follow it.
3324
+ "ui_timeline_set_chords",
3325
+ "ui_timeline_clear_chords",
3326
+ "ui_timeline_loop_clip",
3327
+ "ui_timeline_join_clips",
3328
+ "ui_timeline_insert_time",
3329
+ "ui_timeline_delete_time",
3330
+ "ui_timeline_duplicate_range",
3331
+ "ui_timeline_paste_range",
3332
+ "ui_timeline_list_progressions",
3333
+ "ui_timeline_apply_progression",
3334
+ "ui_timeline_transpose_chords",
3335
+ "ui_timeline_detect_chords",
3336
+ "ui_timeline_set_clip_harmony",
3337
+ "ui_timeline_list_harmony_presets",
3338
+ "ui_timeline_fit_notes_to_chords",
1722
3339
  // The guided video flow (PRD § 8.6). Both surfaces register them; the
1723
3340
  // headless one writes the plan itself where the editor asks the Director.
1724
3341
  "ui_timeline_set_setup",
@@ -1731,6 +3348,46 @@ export const SHARED_TIMELINE_TOOL_NAMES = [
1731
3348
  "ui_timeline_retarget_format",
1732
3349
  "ui_timeline_set_reframe_subject",
1733
3350
  "ui_timeline_add_reframe_keyframe",
1734
- "ui_timeline_clear_reframe"
3351
+ "ui_timeline_clear_reframe",
3352
+ // Step Sequencer (SQ48–SQ54).
3353
+ "ui_timeline_get_pattern",
3354
+ "ui_timeline_create_pattern_region",
3355
+ "ui_timeline_convert_pattern_to_midi",
3356
+ "ui_timeline_convert_midi_to_pattern",
3357
+ "ui_timeline_separate_pattern_rows",
3358
+ "ui_timeline_set_pattern",
3359
+ "ui_timeline_set_pattern_seed",
3360
+ "ui_timeline_add_pattern_rows",
3361
+ "ui_timeline_set_pattern_row",
3362
+ "ui_timeline_remove_pattern_rows",
3363
+ "ui_timeline_move_pattern_row",
3364
+ "ui_timeline_sort_pattern_rows",
3365
+ "ui_timeline_set_pattern_row_sort",
3366
+ "ui_timeline_copy_pattern_row",
3367
+ "ui_timeline_set_steps",
3368
+ "ui_timeline_set_pattern_text",
3369
+ "ui_timeline_clear_pattern",
3370
+ "ui_timeline_copy_steps",
3371
+ "ui_timeline_repeat_step",
3372
+ "ui_timeline_rotate_pattern",
3373
+ "ui_timeline_transpose_pattern",
3374
+ "ui_timeline_randomize_pattern",
3375
+ "ui_timeline_nudge_pattern_values",
3376
+ "ui_timeline_tie_steps",
3377
+ "ui_timeline_list_step_patterns",
3378
+ "ui_timeline_apply_step_pattern",
3379
+ "ui_timeline_save_step_pattern",
3380
+ "ui_timeline_set_track_step_template",
3381
+ "ui_timeline_create_step_pattern_folder",
3382
+ "ui_timeline_rename_step_pattern_folder",
3383
+ "ui_timeline_delete_step_pattern_folder",
3384
+ "ui_timeline_move_step_pattern",
3385
+ // VST/AU plug-in hosting (VST1).
3386
+ "ui_timeline_list_plugins",
3387
+ "ui_timeline_load_plugin",
3388
+ "ui_timeline_list_plugin_presets",
3389
+ "ui_timeline_select_plugin_preset",
3390
+ "ui_timeline_get_plugin_parameters",
3391
+ "ui_timeline_set_plugin_parameters"
1735
3392
  ];
1736
3393
  //# sourceMappingURL=timeline-tool-params.js.map