fractal-midi 0.1.0-alpha.0

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 (123) hide show
  1. package/LICENSE +200 -0
  2. package/NOTICE +28 -0
  3. package/README.md +147 -0
  4. package/dist/am4/applicability.d.ts +61 -0
  5. package/dist/am4/applicability.d.ts.map +1 -0
  6. package/dist/am4/applicability.js +285 -0
  7. package/dist/am4/blockTypes.d.ts +43 -0
  8. package/dist/am4/blockTypes.d.ts.map +1 -0
  9. package/dist/am4/blockTypes.js +48 -0
  10. package/dist/am4/cacheEnums.d.ts +46 -0
  11. package/dist/am4/cacheEnums.d.ts.map +1 -0
  12. package/dist/am4/cacheEnums.js +734 -0
  13. package/dist/am4/cacheParams.d.ts +3533 -0
  14. package/dist/am4/cacheParams.d.ts.map +1 -0
  15. package/dist/am4/cacheParams.js +1996 -0
  16. package/dist/am4/editorControlLabels.d.ts +45 -0
  17. package/dist/am4/editorControlLabels.d.ts.map +1 -0
  18. package/dist/am4/editorControlLabels.js +15894 -0
  19. package/dist/am4/index.d.ts +28 -0
  20. package/dist/am4/index.d.ts.map +1 -0
  21. package/dist/am4/index.js +31 -0
  22. package/dist/am4/ir/preset.d.ts +24 -0
  23. package/dist/am4/ir/preset.d.ts.map +1 -0
  24. package/dist/am4/ir/preset.js +12 -0
  25. package/dist/am4/ir/transpile.d.ts +9 -0
  26. package/dist/am4/ir/transpile.d.ts.map +1 -0
  27. package/dist/am4/ir/transpile.js +19 -0
  28. package/dist/am4/locations.d.ts +32 -0
  29. package/dist/am4/locations.d.ts.map +1 -0
  30. package/dist/am4/locations.js +58 -0
  31. package/dist/am4/paramNames.d.ts +55 -0
  32. package/dist/am4/paramNames.d.ts.map +1 -0
  33. package/dist/am4/paramNames.js +863 -0
  34. package/dist/am4/paramNamesGenerated.d.ts +41 -0
  35. package/dist/am4/paramNamesGenerated.d.ts.map +1 -0
  36. package/dist/am4/paramNamesGenerated.js +183 -0
  37. package/dist/am4/parameterBridge.d.ts +46 -0
  38. package/dist/am4/parameterBridge.d.ts.map +1 -0
  39. package/dist/am4/parameterBridge.js +300 -0
  40. package/dist/am4/params.d.ts +9577 -0
  41. package/dist/am4/params.d.ts.map +1 -0
  42. package/dist/am4/params.js +4537 -0
  43. package/dist/am4/setParam.d.ts +414 -0
  44. package/dist/am4/setParam.d.ts.map +1 -0
  45. package/dist/am4/setParam.js +819 -0
  46. package/dist/am4/shared/paramHelpers.d.ts +55 -0
  47. package/dist/am4/shared/paramHelpers.d.ts.map +1 -0
  48. package/dist/am4/shared/paramHelpers.js +146 -0
  49. package/dist/am4/symbolicIds.d.ts +11 -0
  50. package/dist/am4/symbolicIds.d.ts.map +1 -0
  51. package/dist/am4/symbolicIds.js +587 -0
  52. package/dist/am4/typeApplicability.d.ts +39 -0
  53. package/dist/am4/typeApplicability.d.ts.map +1 -0
  54. package/dist/am4/typeApplicability.js +466 -0
  55. package/dist/am4/variantResolverTables.d.ts +51 -0
  56. package/dist/am4/variantResolverTables.d.ts.map +1 -0
  57. package/dist/am4/variantResolverTables.js +3128 -0
  58. package/dist/axe-fx-ii/blockTypes.d.ts +45 -0
  59. package/dist/axe-fx-ii/blockTypes.d.ts.map +1 -0
  60. package/dist/axe-fx-ii/blockTypes.js +116 -0
  61. package/dist/axe-fx-ii/index.d.ts +5 -0
  62. package/dist/axe-fx-ii/index.d.ts.map +1 -0
  63. package/dist/axe-fx-ii/index.js +18 -0
  64. package/dist/axe-fx-ii/paramAliases.d.ts +54 -0
  65. package/dist/axe-fx-ii/paramAliases.d.ts.map +1 -0
  66. package/dist/axe-fx-ii/paramAliases.js +146 -0
  67. package/dist/axe-fx-ii/params.d.ts +11502 -0
  68. package/dist/axe-fx-ii/params.d.ts.map +1 -0
  69. package/dist/axe-fx-ii/params.js +2847 -0
  70. package/dist/axe-fx-ii/setParam.d.ts +560 -0
  71. package/dist/axe-fx-ii/setParam.d.ts.map +1 -0
  72. package/dist/axe-fx-ii/setParam.js +888 -0
  73. package/dist/axe-fx-iii/blockTypes.d.ts +87 -0
  74. package/dist/axe-fx-iii/blockTypes.d.ts.map +1 -0
  75. package/dist/axe-fx-iii/blockTypes.js +156 -0
  76. package/dist/axe-fx-iii/enumOverlay.d.ts +73 -0
  77. package/dist/axe-fx-iii/enumOverlay.d.ts.map +1 -0
  78. package/dist/axe-fx-iii/enumOverlay.js +236 -0
  79. package/dist/axe-fx-iii/index.d.ts +9 -0
  80. package/dist/axe-fx-iii/index.d.ts.map +1 -0
  81. package/dist/axe-fx-iii/index.js +20 -0
  82. package/dist/axe-fx-iii/params.d.ts +179 -0
  83. package/dist/axe-fx-iii/params.d.ts.map +1 -0
  84. package/dist/axe-fx-iii/params.js +6913 -0
  85. package/dist/axe-fx-iii/setParam.d.ts +460 -0
  86. package/dist/axe-fx-iii/setParam.d.ts.map +1 -0
  87. package/dist/axe-fx-iii/setParam.js +910 -0
  88. package/dist/index.d.ts +2 -0
  89. package/dist/index.d.ts.map +1 -0
  90. package/dist/index.js +12 -0
  91. package/dist/shared/checksum.d.ts +10 -0
  92. package/dist/shared/checksum.d.ts.map +1 -0
  93. package/dist/shared/checksum.js +14 -0
  94. package/dist/shared/device.d.ts +195 -0
  95. package/dist/shared/device.d.ts.map +1 -0
  96. package/dist/shared/device.js +27 -0
  97. package/dist/shared/index.d.ts +8 -0
  98. package/dist/shared/index.d.ts.map +1 -0
  99. package/dist/shared/index.js +11 -0
  100. package/dist/shared/lineage/amp-lineage.json +8313 -0
  101. package/dist/shared/lineage/axefx2-amp-lineage.json +5871 -0
  102. package/dist/shared/lineage/axefx2-delay-lineage.json +226 -0
  103. package/dist/shared/lineage/axefx2-drive-lineage.json +575 -0
  104. package/dist/shared/lineage/axefx2-reverb-lineage.json +467 -0
  105. package/dist/shared/lineage/cab-lineage.json +10777 -0
  106. package/dist/shared/lineage/chorus-lineage.json +173 -0
  107. package/dist/shared/lineage/compressor-lineage.json +338 -0
  108. package/dist/shared/lineage/delay-lineage.json +313 -0
  109. package/dist/shared/lineage/drive-lineage.json +1844 -0
  110. package/dist/shared/lineage/flanger-lineage.json +313 -0
  111. package/dist/shared/lineage/phaser-lineage.json +208 -0
  112. package/dist/shared/lineage/reverb-lineage.json +793 -0
  113. package/dist/shared/lineage/wah-lineage.json +117 -0
  114. package/dist/shared/lineageLookup.d.ts +69 -0
  115. package/dist/shared/lineageLookup.d.ts.map +1 -0
  116. package/dist/shared/lineageLookup.js +196 -0
  117. package/dist/shared/packValue.d.ts +40 -0
  118. package/dist/shared/packValue.d.ts.map +1 -0
  119. package/dist/shared/packValue.js +105 -0
  120. package/dist/shared/types.d.ts +23 -0
  121. package/dist/shared/types.d.ts.map +1 -0
  122. package/dist/shared/types.js +9 -0
  123. package/package.json +75 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Param-name resolution and display-value coercion shared by every tool
3
+ * that takes (block, name) and a value at the input boundary.
4
+ *
5
+ * Display-first contract per CLAUDE.md "Tool API conventions": tool inputs
6
+ * accept the user-facing display value (knob 0–10, dB, ms, %, enum dropdown
7
+ * name); the wire conversion happens at the encoder layer below this file.
8
+ * The helpers here translate display → wire-ready numeric and surface
9
+ * helpful errors for typos.
10
+ */
11
+ import { type Param, type ParamKey } from '../params.js';
12
+ /**
13
+ * Default scratch preset location used for in-place test workflows
14
+ * (apply_preset's `dance:both` analogue, founder spot-checks, HW-064
15
+ * style multi-turn sessions). The historical hard-gate on this location
16
+ * was lifted Session 49 once HW-064 confirmed save-to-inactive-location
17
+ * is a real workflow (device on Z03, save to Z04 succeeded — the user
18
+ * uses it to build multiple presets in one session). Agents should
19
+ * still treat saves as destructive: confirm intent before overwriting
20
+ * a non-empty user-content slot, and never auto-save without an
21
+ * explicit save phrase from the user.
22
+ */
23
+ export declare const DEFAULT_SCRATCH_LOCATION = "Z04";
24
+ /**
25
+ * Typed error for ambiguous-enum resolution. Carries the structured
26
+ * candidate list so the dispatcher / apply executor can populate
27
+ * `DispatchError.details.valid_options` instead of forcing the agent
28
+ * to regex the candidates out of the prose message.
29
+ *
30
+ * H2 Plexi-100W trace (2026-05-15) — agent sent `"Plexi 100W"`, hit
31
+ * the ambiguous-enum branch with 4 candidates, parsed them from the
32
+ * error prose, and retried with `"Plexi 100W High"`. Round-trip cost
33
+ * ~2 s + tokens; structured valid_options closes that gap.
34
+ */
35
+ export declare class EnumAmbiguityError extends Error {
36
+ readonly candidates: readonly string[];
37
+ readonly value: string;
38
+ constructor(value: string, candidates: readonly string[], prefix?: string);
39
+ }
40
+ /**
41
+ * Suggest the closest known param key for an unknown name. Returns the
42
+ * single best match within Levenshtein distance ≤ 2, scoped to the same
43
+ * block so we don't suggest cross-block names. Returns undefined when no
44
+ * close match exists — caller falls back to listing the full set.
45
+ *
46
+ * HW-064 motivation: agent reached for `reverb.pre_delay` (canonical is
47
+ * `predelay`, no underscore) and the error dumped the entire 50+-name
48
+ * reverb param list. A `did you mean "predelay"?` hint is more useful.
49
+ * Aliases (PARAM_ALIASES) handle the common synonyms; this helper
50
+ * catches the rest.
51
+ */
52
+ export declare function suggestParamName(block: string, name: string): string | undefined;
53
+ export declare function paramKey(block: string, name: string): ParamKey;
54
+ export declare function resolveValue(param: Param, value: number | string): number;
55
+ //# sourceMappingURL=paramHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paramHelpers.d.ts","sourceRoot":"","sources":["../../../src/am4/shared/paramHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAKH,KAAK,KAAK,EACV,KAAK,QAAQ,EAChB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IACzC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBACX,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,SAAK;CAOxE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgChF;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAsB9D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CA4BzE"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Param-name resolution and display-value coercion shared by every tool
3
+ * that takes (block, name) and a value at the input boundary.
4
+ *
5
+ * Display-first contract per CLAUDE.md "Tool API conventions": tool inputs
6
+ * accept the user-facing display value (knob 0–10, dB, ms, %, enum dropdown
7
+ * name); the wire conversion happens at the encoder layer below this file.
8
+ * The helpers here translate display → wire-ready numeric and surface
9
+ * helpful errors for typos.
10
+ */
11
+ import { KNOWN_PARAMS, PARAM_ALIASES, findEnumCandidates, resolveEnumValue, } from '../params.js';
12
+ /**
13
+ * Default scratch preset location used for in-place test workflows
14
+ * (apply_preset's `dance:both` analogue, founder spot-checks, HW-064
15
+ * style multi-turn sessions). The historical hard-gate on this location
16
+ * was lifted Session 49 once HW-064 confirmed save-to-inactive-location
17
+ * is a real workflow (device on Z03, save to Z04 succeeded — the user
18
+ * uses it to build multiple presets in one session). Agents should
19
+ * still treat saves as destructive: confirm intent before overwriting
20
+ * a non-empty user-content slot, and never auto-save without an
21
+ * explicit save phrase from the user.
22
+ */
23
+ export const DEFAULT_SCRATCH_LOCATION = 'Z04';
24
+ /**
25
+ * Typed error for ambiguous-enum resolution. Carries the structured
26
+ * candidate list so the dispatcher / apply executor can populate
27
+ * `DispatchError.details.valid_options` instead of forcing the agent
28
+ * to regex the candidates out of the prose message.
29
+ *
30
+ * H2 Plexi-100W trace (2026-05-15) — agent sent `"Plexi 100W"`, hit
31
+ * the ambiguous-enum branch with 4 candidates, parsed them from the
32
+ * error prose, and retried with `"Plexi 100W High"`. Round-trip cost
33
+ * ~2 s + tokens; structured valid_options closes that gap.
34
+ */
35
+ export class EnumAmbiguityError extends Error {
36
+ candidates;
37
+ value;
38
+ constructor(value, candidates, prefix = '') {
39
+ const list = candidates.map((c) => `"${c}"`).join(' / ');
40
+ super(`${prefix}"${value}" is ambiguous — matched ${candidates.length} entries: ${list}. Pick one verbatim.`);
41
+ this.name = 'EnumAmbiguityError';
42
+ this.candidates = candidates;
43
+ this.value = value;
44
+ }
45
+ }
46
+ /**
47
+ * Suggest the closest known param key for an unknown name. Returns the
48
+ * single best match within Levenshtein distance ≤ 2, scoped to the same
49
+ * block so we don't suggest cross-block names. Returns undefined when no
50
+ * close match exists — caller falls back to listing the full set.
51
+ *
52
+ * HW-064 motivation: agent reached for `reverb.pre_delay` (canonical is
53
+ * `predelay`, no underscore) and the error dumped the entire 50+-name
54
+ * reverb param list. A `did you mean "predelay"?` hint is more useful.
55
+ * Aliases (PARAM_ALIASES) handle the common synonyms; this helper
56
+ * catches the rest.
57
+ */
58
+ export function suggestParamName(block, name) {
59
+ const sameBlock = Object.keys(KNOWN_PARAMS)
60
+ .filter((k) => k.startsWith(`${block}.`))
61
+ .map((k) => k.slice(block.length + 1));
62
+ if (sameBlock.length === 0)
63
+ return undefined;
64
+ const distance = (a, b) => {
65
+ if (a === b)
66
+ return 0;
67
+ const al = a.length;
68
+ const bl = b.length;
69
+ if (Math.abs(al - bl) > 2)
70
+ return 3;
71
+ const dp = Array.from({ length: bl + 1 }, (_, j) => j);
72
+ for (let i = 1; i <= al; i++) {
73
+ let prev = i - 1;
74
+ let curr = i;
75
+ for (let j = 1; j <= bl; j++) {
76
+ const tmp = dp[j];
77
+ curr = a[i - 1] === b[j - 1]
78
+ ? prev
79
+ : Math.min(prev, dp[j], dp[j - 1]) + 1;
80
+ dp[j - 1] = prev;
81
+ prev = tmp;
82
+ dp[j] = curr;
83
+ }
84
+ }
85
+ return dp[bl];
86
+ };
87
+ let best;
88
+ for (const candidate of sameBlock) {
89
+ const d = distance(name.toLowerCase(), candidate.toLowerCase());
90
+ if (d <= 2 && (!best || d < best.d))
91
+ best = { name: candidate, d };
92
+ }
93
+ return best?.name;
94
+ }
95
+ export function paramKey(block, name) {
96
+ const literal = `${block}.${name}`;
97
+ if (literal in KNOWN_PARAMS)
98
+ return literal;
99
+ // Common-synonym alias check — `reverb.decay` → `reverb.time`,
100
+ // `delay.repeats` → `delay.feedback`, etc. Resolves silently so the
101
+ // agent's first call lands instead of round-tripping through an
102
+ // unknown-param error. See PARAM_ALIASES in params.ts for the list
103
+ // and Session 44 Lamb-of-God test for the motivating case.
104
+ const aliasTarget = PARAM_ALIASES[literal];
105
+ if (aliasTarget !== undefined && aliasTarget in KNOWN_PARAMS) {
106
+ return aliasTarget;
107
+ }
108
+ const suggestion = suggestParamName(block, name);
109
+ if (suggestion !== undefined) {
110
+ throw new Error(`Unknown parameter "${literal}" — did you mean "${block}.${suggestion}"?`);
111
+ }
112
+ const sameBlock = Object.keys(KNOWN_PARAMS).filter((k) => k.startsWith(`${block}.`));
113
+ throw new Error(sameBlock.length
114
+ ? `Unknown parameter "${literal}". Known params for ${block}: ${sameBlock.join(', ')}.`
115
+ : `Unknown parameter "${literal}". No params registered for ${block} yet.`);
116
+ }
117
+ export function resolveValue(param, value) {
118
+ if (param.unit === 'enum') {
119
+ const resolved = resolveEnumValue(param, value);
120
+ if (resolved === undefined) {
121
+ // If the input substring-matched multiple entries, list THOSE
122
+ // candidates explicitly — they're far more useful than the first
123
+ // 8 names from offset 0 of the enum table. Founder-driven Session
124
+ // 44: agent passed reverb.type = "Room" (matched Room, Small /
125
+ // Room, Medium / Room, Large + a few others) and the previous
126
+ // hint mixed in Hall / Chamber names that weren't candidates.
127
+ const candidates = typeof value === 'string'
128
+ ? findEnumCandidates(param, value)
129
+ : [];
130
+ if (candidates.length >= 2) {
131
+ throw new EnumAmbiguityError(String(value), candidates.map((c) => c.name));
132
+ }
133
+ const samples = Object.values(param.enumValues ?? {}).slice(0, 8).join(', ');
134
+ throw new Error(`"${value}" is not a valid ${param.block}.${param.name} value. First few valid names: ${samples}… (call list_enum_values for the full list).`);
135
+ }
136
+ return resolved;
137
+ }
138
+ // Non-enum params take a numeric display value (e.g. 0–10 knob, dB, ms).
139
+ const num = typeof value === 'number' ? value : Number(value);
140
+ if (!Number.isFinite(num))
141
+ throw new Error(`Expected a number for ${param.block}.${param.name}, got "${value}"`);
142
+ if (num < param.displayMin || num > param.displayMax) {
143
+ throw new Error(`${param.block}.${param.name} out of range [${param.displayMin}..${param.displayMax}]: ${num}`);
144
+ }
145
+ return num;
146
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Per-block symbolic IDs harvested from AM4-Edit.exe at offset
3
+ * ~0x611018+ (Session 46 cont, 2026-05-03). These are AM4-Edit's
4
+ * own internal parameter identifiers (e.g. DISTORT_BRIGHTCAP for
5
+ * the amp block's Bright Cap knob). Provided as agent context for
6
+ * params not yet covered by paramNames.ts hand-curated entries.
7
+ *
8
+ * AUTO-GENERATED by scripts/extract-symbolic-ids.ts — do not hand-edit.
9
+ */
10
+ export declare const SYMBOLIC_IDS_BY_BLOCK: Readonly<Record<string, readonly string[]>>;
11
+ //# sourceMappingURL=symbolicIds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbolicIds.d.ts","sourceRoot":"","sources":["../../src/am4/symbolicIds.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAikB7E,CAAC"}