xstudio-linux 0.0.0-stage → 0.2.3

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 (222) hide show
  1. package/CHANGELOG.md +443 -0
  2. package/LICENSE +31 -0
  3. package/README.md +527 -2
  4. package/dist/adapter-cli/cli.d.ts +28 -0
  5. package/dist/adapter-cli/cli.js +235 -0
  6. package/dist/adapter-cli/cli.js.map +1 -0
  7. package/dist/adapter-mcp/server.d.ts +81 -0
  8. package/dist/adapter-mcp/server.js +477 -0
  9. package/dist/adapter-mcp/server.js.map +1 -0
  10. package/dist/config.d.ts +45 -0
  11. package/dist/config.js +78 -0
  12. package/dist/config.js.map +1 -0
  13. package/dist/core/catalog/pronunciation.d.ts +47 -0
  14. package/dist/core/catalog/pronunciation.js +402 -0
  15. package/dist/core/catalog/pronunciation.js.map +1 -0
  16. package/dist/core/catalog/singers.d.ts +46 -0
  17. package/dist/core/catalog/singers.js +122 -0
  18. package/dist/core/catalog/singers.js.map +1 -0
  19. package/dist/core/contracts.d.ts +348 -0
  20. package/dist/core/contracts.js +17 -0
  21. package/dist/core/contracts.js.map +1 -0
  22. package/dist/core/degrade/chain.d.ts +80 -0
  23. package/dist/core/degrade/chain.js +137 -0
  24. package/dist/core/degrade/chain.js.map +1 -0
  25. package/dist/core/diagnose/error-resolver.d.ts +51 -0
  26. package/dist/core/diagnose/error-resolver.js +202 -0
  27. package/dist/core/diagnose/error-resolver.js.map +1 -0
  28. package/dist/core/guard/skill-gate.d.ts +89 -0
  29. package/dist/core/guard/skill-gate.js +121 -0
  30. package/dist/core/guard/skill-gate.js.map +1 -0
  31. package/dist/core/midi/convert.d.ts +31 -0
  32. package/dist/core/midi/convert.js +125 -0
  33. package/dist/core/midi/convert.js.map +1 -0
  34. package/dist/core/midi/smf.d.ts +37 -0
  35. package/dist/core/midi/smf.js +422 -0
  36. package/dist/core/midi/smf.js.map +1 -0
  37. package/dist/core/render/artifacts.d.ts +37 -0
  38. package/dist/core/render/artifacts.js +417 -0
  39. package/dist/core/render/artifacts.js.map +1 -0
  40. package/dist/core/render/orchestrator.d.ts +110 -0
  41. package/dist/core/render/orchestrator.js +974 -0
  42. package/dist/core/render/orchestrator.js.map +1 -0
  43. package/dist/core/svip/codec.d.ts +30 -0
  44. package/dist/core/svip/codec.js +664 -0
  45. package/dist/core/svip/codec.js.map +1 -0
  46. package/dist/core/svip/document.d.ts +31 -0
  47. package/dist/core/svip/document.js +158 -0
  48. package/dist/core/svip/document.js.map +1 -0
  49. package/dist/core/svip/editor.d.ts +71 -0
  50. package/dist/core/svip/editor.js +245 -0
  51. package/dist/core/svip/editor.js.map +1 -0
  52. package/dist/core/svip/model.d.ts +74 -0
  53. package/dist/core/svip/model.js +158 -0
  54. package/dist/core/svip/model.js.map +1 -0
  55. package/dist/core/svip/tick.d.ts +21 -0
  56. package/dist/core/svip/tick.js +59 -0
  57. package/dist/core/svip/tick.js.map +1 -0
  58. package/dist/core/svip/validator.d.ts +39 -0
  59. package/dist/core/svip/validator.js +267 -0
  60. package/dist/core/svip/validator.js.map +1 -0
  61. package/dist/host/linux.d.ts +15 -0
  62. package/dist/host/linux.js +42 -0
  63. package/dist/host/linux.js.map +1 -0
  64. package/dist/host/sidecar.d.ts +61 -0
  65. package/dist/host/sidecar.js +365 -0
  66. package/dist/host/sidecar.js.map +1 -0
  67. package/dist/host/wine-launch.d.ts +60 -0
  68. package/dist/host/wine-launch.js +77 -0
  69. package/dist/host/wine-launch.js.map +1 -0
  70. package/dist/host/wine-paths.d.ts +30 -0
  71. package/dist/host/wine-paths.js +103 -0
  72. package/dist/host/wine-paths.js.map +1 -0
  73. package/dist/index.d.ts +20 -0
  74. package/dist/index.js +17 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/services.d.ts +55 -0
  77. package/dist/services.js +78 -0
  78. package/dist/services.js.map +1 -0
  79. package/dist/shared/errors.d.ts +61 -0
  80. package/dist/shared/errors.js +125 -0
  81. package/dist/shared/errors.js.map +1 -0
  82. package/dist/shared/paths.d.ts +8 -0
  83. package/dist/shared/paths.js +30 -0
  84. package/dist/shared/paths.js.map +1 -0
  85. package/dist/shared/schema.d.ts +26 -0
  86. package/dist/shared/schema.js +68 -0
  87. package/dist/shared/schema.js.map +1 -0
  88. package/dist/shared/types.d.ts +43 -0
  89. package/dist/shared/types.js +19 -0
  90. package/dist/shared/types.js.map +1 -0
  91. package/dist/tests/unit/artifacts.test.d.ts +1 -0
  92. package/dist/tests/unit/artifacts.test.js +243 -0
  93. package/dist/tests/unit/artifacts.test.js.map +1 -0
  94. package/dist/tests/unit/data-plane.test.d.ts +1 -0
  95. package/dist/tests/unit/data-plane.test.js +153 -0
  96. package/dist/tests/unit/data-plane.test.js.map +1 -0
  97. package/dist/tests/unit/degrade.test.d.ts +1 -0
  98. package/dist/tests/unit/degrade.test.js +133 -0
  99. package/dist/tests/unit/degrade.test.js.map +1 -0
  100. package/dist/tests/unit/diagnosis.test.d.ts +1 -0
  101. package/dist/tests/unit/diagnosis.test.js +66 -0
  102. package/dist/tests/unit/diagnosis.test.js.map +1 -0
  103. package/dist/tests/unit/errors.test.d.ts +1 -0
  104. package/dist/tests/unit/errors.test.js +83 -0
  105. package/dist/tests/unit/errors.test.js.map +1 -0
  106. package/dist/tests/unit/mcp-server.test.d.ts +1 -0
  107. package/dist/tests/unit/mcp-server.test.js +267 -0
  108. package/dist/tests/unit/mcp-server.test.js.map +1 -0
  109. package/dist/tests/unit/mcp-smoke.d.ts +6 -0
  110. package/dist/tests/unit/mcp-smoke.js +7 -0
  111. package/dist/tests/unit/mcp-smoke.js.map +1 -0
  112. package/dist/tests/unit/mcp-smoke.test.d.ts +1 -0
  113. package/dist/tests/unit/mcp-smoke.test.js +196 -0
  114. package/dist/tests/unit/mcp-smoke.test.js.map +1 -0
  115. package/dist/tests/unit/midi.test.d.ts +1 -0
  116. package/dist/tests/unit/midi.test.js +255 -0
  117. package/dist/tests/unit/midi.test.js.map +1 -0
  118. package/dist/tests/unit/pronunciation.test.d.ts +1 -0
  119. package/dist/tests/unit/pronunciation.test.js +83 -0
  120. package/dist/tests/unit/pronunciation.test.js.map +1 -0
  121. package/dist/tests/unit/registry-contract.test.d.ts +1 -0
  122. package/dist/tests/unit/registry-contract.test.js +114 -0
  123. package/dist/tests/unit/registry-contract.test.js.map +1 -0
  124. package/dist/tests/unit/render-orchestrator.test.d.ts +1 -0
  125. package/dist/tests/unit/render-orchestrator.test.js +548 -0
  126. package/dist/tests/unit/render-orchestrator.test.js.map +1 -0
  127. package/dist/tests/unit/sidecar.test.d.ts +1 -0
  128. package/dist/tests/unit/sidecar.test.js +299 -0
  129. package/dist/tests/unit/sidecar.test.js.map +1 -0
  130. package/dist/tests/unit/singers.test.d.ts +1 -0
  131. package/dist/tests/unit/singers.test.js +73 -0
  132. package/dist/tests/unit/singers.test.js.map +1 -0
  133. package/dist/tests/unit/skill-gate.test.d.ts +1 -0
  134. package/dist/tests/unit/skill-gate.test.js +182 -0
  135. package/dist/tests/unit/skill-gate.test.js.map +1 -0
  136. package/dist/tests/unit/svip-codec.test.d.ts +1 -0
  137. package/dist/tests/unit/svip-codec.test.js +182 -0
  138. package/dist/tests/unit/svip-codec.test.js.map +1 -0
  139. package/dist/tests/unit/svip-document.test.d.ts +1 -0
  140. package/dist/tests/unit/svip-document.test.js +137 -0
  141. package/dist/tests/unit/svip-document.test.js.map +1 -0
  142. package/dist/tests/unit/svip-editor.test.d.ts +1 -0
  143. package/dist/tests/unit/svip-editor.test.js +275 -0
  144. package/dist/tests/unit/svip-editor.test.js.map +1 -0
  145. package/dist/tests/unit/svip-tick.test.d.ts +1 -0
  146. package/dist/tests/unit/svip-tick.test.js +66 -0
  147. package/dist/tests/unit/svip-tick.test.js.map +1 -0
  148. package/dist/tools/common.d.ts +80 -0
  149. package/dist/tools/common.js +167 -0
  150. package/dist/tools/common.js.map +1 -0
  151. package/dist/tools/control.d.ts +21 -0
  152. package/dist/tools/control.js +376 -0
  153. package/dist/tools/control.js.map +1 -0
  154. package/dist/tools/data.d.ts +37 -0
  155. package/dist/tools/data.js +680 -0
  156. package/dist/tools/data.js.map +1 -0
  157. package/dist/tools/definition.d.ts +60 -0
  158. package/dist/tools/definition.js +44 -0
  159. package/dist/tools/definition.js.map +1 -0
  160. package/dist/tools/degrade.d.ts +3 -0
  161. package/dist/tools/degrade.js +30 -0
  162. package/dist/tools/degrade.js.map +1 -0
  163. package/dist/tools/guide.d.ts +10 -0
  164. package/dist/tools/guide.js +66 -0
  165. package/dist/tools/guide.js.map +1 -0
  166. package/dist/tools/open.d.ts +3 -0
  167. package/dist/tools/open.js +74 -0
  168. package/dist/tools/open.js.map +1 -0
  169. package/dist/tools/probe.d.ts +8 -0
  170. package/dist/tools/probe.js +132 -0
  171. package/dist/tools/probe.js.map +1 -0
  172. package/dist/tools/registry.d.ts +10 -0
  173. package/dist/tools/registry.js +16 -0
  174. package/dist/tools/registry.js.map +1 -0
  175. package/dist/version.d.ts +4 -0
  176. package/dist/version.js +19 -0
  177. package/dist/version.js.map +1 -0
  178. package/docs/DESIGN.md +553 -0
  179. package/docs/RECON-GUI.md +271 -0
  180. package/docs/RECON.md +339 -0
  181. package/docs/SPEC.md +786 -0
  182. package/docs/WINE.md +192 -0
  183. package/examples/.scratch/01-midi-to-wudi/wudi-demo.svip3 +0 -0
  184. package/examples/.scratch/01-midi-to-wudi/wudi-melody.mid +0 -0
  185. package/examples/.scratch/01-midi-to-wudi/wudi-roundtrip.mid +0 -0
  186. package/examples/.scratch/02-three-singers/melody.chenziyu.svip3 +0 -0
  187. package/examples/.scratch/02-three-singers/melody.hechang.svip3 +0 -0
  188. package/examples/.scratch/02-three-singers/melody.svip3 +0 -0
  189. package/examples/.scratch/02-three-singers/melody.wudi.svip3 +0 -0
  190. package/examples/.scratch/03-velocity-diction/phrase.svip3 +0 -0
  191. package/examples/.scratch/03-velocity-diction/phrase.svip3.bak.20261206-163755-200 +0 -0
  192. package/examples/.scratch/03-velocity-diction/phrase.svip3.bak.20261206-163755-203 +0 -0
  193. package/examples/.scratch/03-velocity-diction/phrase.svip3.bak.20261206-163755-204 +0 -0
  194. package/examples/.scratch/04-unknown-dialog-abort/dialog-demo.svip3 +0 -0
  195. package/examples/01-midi-to-wudi.mjs +144 -0
  196. package/examples/02-three-singers-compare.mjs +140 -0
  197. package/examples/03-velocity-diction-rerender.mjs +160 -0
  198. package/examples/04-unknown-dialog-abort.mjs +126 -0
  199. package/examples/README.md +101 -0
  200. package/examples/lib/harness.mjs +274 -0
  201. package/fixtures/midi/melody-480.mid +0 -0
  202. package/fixtures/midi/melody-96.mid +0 -0
  203. package/fixtures/svip/1.svip3 +0 -0
  204. package/fixtures/svip/3.svip3 +0 -0
  205. package/fixtures/uia/README.md +37 -0
  206. package/fixtures/uia/export-dialog.snapshot.json +446 -0
  207. package/fixtures/uia/main-window.snapshot.json +2997 -0
  208. package/fixtures/uia/open-dialog.snapshot.json +103 -0
  209. package/icon.svg +10 -0
  210. package/package.json +84 -4
  211. package/proto/xstudio.proto +128 -0
  212. package/scripts/check-contract.mjs +184 -0
  213. package/scripts/entry-smoke.mjs +26 -0
  214. package/scripts/inspect-svip.mjs +161 -0
  215. package/scripts/setup-venv.sh +93 -0
  216. package/scripts/wine-gui-probe.py +302 -0
  217. package/sidecar/xstudio_uia.py +1478 -0
  218. package/skills/xstudio-gui/SKILL.md +194 -0
  219. package/skills/xstudio-gui/assertions.md +103 -0
  220. package/skills/xstudio-gui/dialogs.md +90 -0
  221. package/skills/xstudio-gui/gestures.md +158 -0
  222. package/skills/xstudio-gui/ui-map.json +242 -0
@@ -0,0 +1,348 @@
1
+ /**
2
+ * The integration contracts between the data plane (core/), the F layer
3
+ * (sidecar + render/) and the adapters.
4
+ *
5
+ * Owners:
6
+ * - core-svip teammate: model.ts, codec.ts, document.ts, editor.ts,
7
+ * validator.ts, tick.ts, midi/smf.ts, midi/convert.ts.
8
+ * - tavily teammate: tavily/*, catalog/singers.ts, catalog/pronunciation.ts,
9
+ * diagnose/error-resolver.ts.
10
+ * - gui teammate: host/sidecar.ts, sidecar/uia.ps1, core/render/*, skills/xstudio-gui/*.
11
+ *
12
+ * Do not change these signatures without telling the Lead: the adapter tools are
13
+ * written against them.
14
+ * @module xstudio-linux/core/contracts
15
+ */
16
+ /** One unknown protobuf field preserved verbatim across a round trip. */
17
+ export interface UnknownField {
18
+ /** Field number. */
19
+ no: number;
20
+ /** Wire type (0 varint, 1 fixed64, 2 length-delimited, 5 fixed32). */
21
+ wireType: number;
22
+ /** Hex of the complete field encoding including tag and length prefix. */
23
+ raw: string;
24
+ }
25
+ /** One note as stored in a .svip3 project. */
26
+ export interface NoteModel {
27
+ /** Absolute tick on the project timeline (PPQ = 480). */
28
+ positionTick: number;
29
+ /** Duration in ticks: 240 = eighth, 480 = quarter, 720 = dotted quarter. */
30
+ lengthTick: number;
31
+ /** MIDI pitch: 60 = C4. */
32
+ midiPitch: number;
33
+ /** Lyric text, UTF-8. */
34
+ lyricText: string;
35
+ /** Romanized phoneme, e.g. "la". */
36
+ phonemeRoman: string;
37
+ /** Constant 1 in every observed file; read-only pass-through. */
38
+ noteFlag: number;
39
+ /** -1 means "unset" (sentinel); never reinterpret it. */
40
+ exprParam1: number;
41
+ /** -1 means "unset" (sentinel); never reinterpret it. */
42
+ exprParam2: number;
43
+ /** Unknown fields preserved for forward compatibility. */
44
+ $unknowns?: UnknownField[];
45
+ }
46
+ /** The track payload (label / range / note list). */
47
+ export interface TrackPayloadModel {
48
+ label: string;
49
+ subType: number;
50
+ startTick: number;
51
+ endTick: number;
52
+ notes: NoteModel[];
53
+ /** uint64 all-ones in observed files (wire type 0 — verified; the spec's fixed64 was an inference). Preserved as a decimal string. */
54
+ visibilityMask: string;
55
+ shortId: string;
56
+ $unknowns?: UnknownField[];
57
+ }
58
+ /** A singing track. */
59
+ export interface SingingTrackModel {
60
+ /** Global velocity offset as a linear float. */
61
+ velocityOffset: number;
62
+ /** Singer display name stored by X Studio, e.g. "伍笛". */
63
+ singerName: string;
64
+ /** UI color, e.g. "#7F97AE". */
65
+ uiColorHex: string;
66
+ /** 2 = singing. */
67
+ trackType: number;
68
+ payload: TrackPayloadModel;
69
+ /** Stable track UUID. */
70
+ uuid: string;
71
+ /** Pan in dB (observed -18). */
72
+ panDb: number;
73
+ $unknowns?: UnknownField[];
74
+ }
75
+ /** The google.protobuf.Any wrapper around the track. */
76
+ export interface TrackDataModel {
77
+ /** e.g. "type.googleapis.com/xstudio.proto.SingingTrack". */
78
+ typeUrl: string;
79
+ /** Decoded singing track, or null for an unsupported track type. */
80
+ singing: SingingTrackModel | null;
81
+ /** Raw Any.value bytes kept when `singing` is null (pass-through). */
82
+ rawValue?: Uint8Array;
83
+ $unknowns?: UnknownField[];
84
+ }
85
+ /** The complete project model (one singing track, matching the observed format). */
86
+ export interface ProjectModel {
87
+ sourcePath: string;
88
+ appVersion: string;
89
+ /** 115200 in observed files; read-only pass-through. */
90
+ internalClockBase: number;
91
+ tempo: {
92
+ bpmX100: number;
93
+ $unknowns?: UnknownField[];
94
+ };
95
+ timeSig: {
96
+ numerator: number;
97
+ denominator: number;
98
+ $unknowns?: UnknownField[];
99
+ };
100
+ trackData: TrackDataModel;
101
+ gain: {
102
+ linearGain: number;
103
+ $unknowns?: UnknownField[];
104
+ };
105
+ /** Constant 8; read-only pass-through. */
106
+ unknownField9: number;
107
+ /** 7680 in observed files; read-only pass-through. */
108
+ totalTicks: number;
109
+ /** Constant 1; read-only pass-through. */
110
+ flags: number;
111
+ display: {
112
+ placeholder: string;
113
+ $unknowns?: UnknownField[];
114
+ };
115
+ $unknowns?: UnknownField[];
116
+ }
117
+ /** A decoded project plus the bytes/model it came from (round-trip guarantee). */
118
+ export interface ProjectDocument {
119
+ path: string;
120
+ model: ProjectModel;
121
+ originalBytes: Uint8Array;
122
+ originalModel: ProjectModel;
123
+ }
124
+ /** Options for writing a project back to disk. */
125
+ export interface WriteProjectOptions {
126
+ /** Create a timestamped backup before replacing the file. */
127
+ backup: boolean;
128
+ /** Normalize `source_path` to forward slashes (recommended). */
129
+ normalizeSourcePath: boolean;
130
+ }
131
+ /** Result of one write. */
132
+ export interface WriteProjectResult {
133
+ path: string;
134
+ backupPath?: string;
135
+ bytesWritten: number;
136
+ /** False when the model was unchanged and the original bytes were reused. */
137
+ changed: boolean;
138
+ }
139
+ /** Reference to one note: 0-based index in `payload.notes`. */
140
+ export type NoteRef = {
141
+ index: number;
142
+ } | {
143
+ positionTick: number;
144
+ midiPitch?: number;
145
+ };
146
+ /** Fields accepted by note_add. */
147
+ export interface NoteInput {
148
+ positionTick: number;
149
+ lengthTick: number;
150
+ midiPitch: number;
151
+ lyricText: string;
152
+ phonemeRoman: string;
153
+ }
154
+ /** Fields accepted by note_edit. */
155
+ export type NotePatch = Partial<NoteInput>;
156
+ /** A compact project summary for project_read (default view). */
157
+ export interface ProjectSummary {
158
+ path: string;
159
+ appVersion: string;
160
+ tempoBpm: number;
161
+ timeSignature: {
162
+ numerator: number;
163
+ denominator: number;
164
+ };
165
+ track: {
166
+ index: number;
167
+ singerName: string;
168
+ uuid: string;
169
+ velocityOffset: number;
170
+ noteCount: number;
171
+ label: string;
172
+ startTick: number;
173
+ endTick: number;
174
+ uiColorHex: string;
175
+ };
176
+ gainLinear: number;
177
+ ppq: 480;
178
+ }
179
+ /** One singer's metadata. */
180
+ export interface SingerMeta {
181
+ /** Product-line-prefixed id, e.g. "beta-netease:wudi". */
182
+ id: string;
183
+ /** Display name, e.g. "伍笛". */
184
+ name: string;
185
+ style: string[];
186
+ language: string;
187
+ requiresDownload: boolean;
188
+ isPaid: boolean;
189
+ source: 'local';
190
+ fetchedAt: number;
191
+ }
192
+ /** Result of a singer catalog query. */
193
+ export interface SingerQueryResult {
194
+ singers: SingerMeta[];
195
+ via: 'pb' | 'local-fallback';
196
+ cached: boolean;
197
+ warnings: string[];
198
+ }
199
+ /** Result of a pronunciation lookup. */
200
+ export interface PronunciationResult {
201
+ pinyin: string;
202
+ confidence: number;
203
+ via: 'pb' | 'local-fallback';
204
+ source: 'local-rule' | 'fallback';
205
+ }
206
+ /** A dialog fingerprint from skills/xstudio-gui/dialogs.md. */
207
+ export interface DialogFingerprint {
208
+ id: string;
209
+ match: string[];
210
+ action: 'dismiss' | 'cancel' | 'confirm' | 'retry' | 'login' | 'manual';
211
+ instruction: string;
212
+ }
213
+ /** Diagnosis for an unknown dialog. */
214
+ export interface DialogDiagnosis {
215
+ cause: string;
216
+ suggestedAction: 'retry' | 'dismiss' | 'login_required' | 'update_available' | 'manual';
217
+ manualInstruction?: string;
218
+ confidence: number;
219
+ via: 'pb' | 'local-fallback';
220
+ }
221
+ /** One UIA element in a snapshot. */
222
+ export interface UiElement {
223
+ /** Snapshot-local reference, e.g. "e12". */
224
+ ref: string;
225
+ name: string;
226
+ automationId: string;
227
+ className: string;
228
+ controlType: string;
229
+ patterns: string[];
230
+ enabled: boolean;
231
+ offscreen: boolean;
232
+ depth: number;
233
+ bounds?: {
234
+ x: number;
235
+ y: number;
236
+ width: number;
237
+ height: number;
238
+ };
239
+ value?: string;
240
+ }
241
+ /** A UIA snapshot of the X Studio main window. */
242
+ export interface UiSnapshot {
243
+ window: {
244
+ title: string;
245
+ pid: number;
246
+ className: string;
247
+ bounds?: {
248
+ x: number;
249
+ y: number;
250
+ width: number;
251
+ height: number;
252
+ };
253
+ };
254
+ elements: UiElement[];
255
+ truncated: boolean;
256
+ screenshotPath?: string;
257
+ capturedAt: number;
258
+ /** False when the accessibility tree is unreachable (Wine default); window-level data is still valid. */
259
+ treeAvailable?: boolean;
260
+ /** Snapshot-scoped token all element refs are prefixed with (Linux sidecar). */
261
+ snapshotToken?: string;
262
+ }
263
+ /** One primitive GUI action. */
264
+ export interface UiAction {
265
+ ref: string;
266
+ op: 'click' | 'set_text' | 'select' | 'invoke_pattern' | 'send_keys' | 'expand' | 'collapse';
267
+ value?: string;
268
+ }
269
+ /** Assertion request. */
270
+ export interface UiAssertion {
271
+ ref?: string;
272
+ text?: string;
273
+ state?: 'exists' | 'enabled' | 'visible' | 'focused' | 'value';
274
+ expect?: string;
275
+ }
276
+ /** Dialog state read from the app. */
277
+ export interface DialogInfo {
278
+ title: string;
279
+ text: string;
280
+ buttons: string[];
281
+ windowClass: string;
282
+ }
283
+ /** The GUI sidecar as consumed by the adapter and the render orchestrator. */
284
+ export interface GuiSidecarProbeResult {
285
+ running: boolean;
286
+ foreground: boolean;
287
+ windowTitle: string | null;
288
+ pid?: number;
289
+ /** False when the window is iconic/minimized (Linux sidecar). */
290
+ mapped?: boolean;
291
+ /** "atspi" only when the accessibility tree is actually exposed. */
292
+ backend?: string;
293
+ /** Whether the AT-SPI library itself is importable (diagnostics). */
294
+ atspiLib?: boolean;
295
+ }
296
+ export interface GuiSidecar {
297
+ probe(options?: {
298
+ activate?: boolean;
299
+ }): Promise<GuiSidecarProbeResult>;
300
+ snapshot(options?: {
301
+ includeScreenshot?: boolean;
302
+ maxElements?: number;
303
+ }): Promise<UiSnapshot>;
304
+ act(action: UiAction): Promise<{
305
+ ok: boolean;
306
+ detail?: string;
307
+ }>;
308
+ assert(assertion: UiAssertion): Promise<{
309
+ ok: boolean;
310
+ actual?: string;
311
+ detail?: string;
312
+ }>;
313
+ readDialog(): Promise<DialogInfo | null>;
314
+ respondDialog(choice: string): Promise<{
315
+ ok: boolean;
316
+ detail?: string;
317
+ }>;
318
+ abort(): Promise<{
319
+ ok: boolean;
320
+ }>;
321
+ dispose(): Promise<void>;
322
+ }
323
+ /** Trigger result for a cloud render. */
324
+ export interface RenderTriggerResult {
325
+ opened: boolean;
326
+ started: boolean;
327
+ steps: string[];
328
+ }
329
+ /** Wait result for a cloud render. */
330
+ export interface RenderWaitResult {
331
+ completed: boolean;
332
+ elapsedMs: number;
333
+ evidence: string[];
334
+ }
335
+ /** Export request. */
336
+ export interface ExportRequest {
337
+ projectPath: string;
338
+ format: 'wav' | 'mp3' | 'flac';
339
+ sampleRate?: number;
340
+ bitrate?: string;
341
+ outDir: string;
342
+ }
343
+ /** Export result. */
344
+ export interface ExportResult {
345
+ path: string;
346
+ bytes: number;
347
+ format: string;
348
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The integration contracts between the data plane (core/), the F layer
3
+ * (sidecar + render/) and the adapters.
4
+ *
5
+ * Owners:
6
+ * - core-svip teammate: model.ts, codec.ts, document.ts, editor.ts,
7
+ * validator.ts, tick.ts, midi/smf.ts, midi/convert.ts.
8
+ * - tavily teammate: tavily/*, catalog/singers.ts, catalog/pronunciation.ts,
9
+ * diagnose/error-resolver.ts.
10
+ * - gui teammate: host/sidecar.ts, sidecar/uia.ps1, core/render/*, skills/xstudio-gui/*.
11
+ *
12
+ * Do not change these signatures without telling the Lead: the adapter tools are
13
+ * written against them.
14
+ * @module xstudio-linux/core/contracts
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/core/contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Execution-path degradation state machine: pb-editable → gui-assisted → guide-only.
3
+ *
4
+ * The plugin prefers the strongest available path from `config.paths
5
+ * .preferredChain` (default `["pb", "gui", "guide"]`). Availability is a fact
6
+ * reported by the caller (probe results, capability checks); this module is pure
7
+ * and deterministic, so the whole decision can be unit-tested without touching
8
+ * the app, the GUI sidecar or the network.
9
+ *
10
+ * ```ts
11
+ * const chain = new DegradeChain(config)
12
+ * const selection = chain.select({ pb: false, gui: { available: true }, guide: true })
13
+ * // -> { path: "gui", stage: "gui-assisted", degraded: true, ... }
14
+ * ```
15
+ * @module xstudio-linux/core/degrade/chain
16
+ */
17
+ /** One execution path the plugin can use, strongest first by default. */
18
+ export type ControlPath = 'pb' | 'gui' | 'guide';
19
+ /** The default preferred chain (matches `src/config.ts`). */
20
+ export declare const DEFAULT_PATH_CHAIN: readonly ControlPath[];
21
+ /** The stage a selected path represents. */
22
+ export type DegradeStage = 'pb-editable' | 'gui-assisted' | 'guide-only' | 'unavailable';
23
+ /** Availability of one path: a boolean, or a boolean plus the reason it is false. */
24
+ export type PathAvailability = boolean | {
25
+ available: boolean;
26
+ reason?: string;
27
+ };
28
+ /** Availability facts keyed by path. An absent fact means "not reported" → unavailable. */
29
+ export type AvailabilityFacts = Partial<Record<ControlPath, PathAvailability>>;
30
+ /** One preferred path that was skipped, with the reason. */
31
+ export interface SkippedLink {
32
+ link: ControlPath;
33
+ reason: string;
34
+ }
35
+ /** The outcome of one selection. */
36
+ export interface PathSelection {
37
+ /** The selected path, or null when no preferred path is available. */
38
+ path: ControlPath | null;
39
+ /** The degradation stage of the selection (`unavailable` when path is null). */
40
+ stage: DegradeStage;
41
+ /** True when at least one preferred path was skipped. */
42
+ degraded: boolean;
43
+ /** Skipped paths in preference order, each with its reason. */
44
+ skipped: SkippedLink[];
45
+ /** Human-readable explanation of the decision. */
46
+ reason: string;
47
+ }
48
+ /** True when a value is a known control path. */
49
+ export declare function isControlPath(value: unknown): value is ControlPath;
50
+ /**
51
+ * Normalize an untrusted chain: keep known paths, drop duplicates, preserve
52
+ * order, and fall back to {@link DEFAULT_PATH_CHAIN} when nothing valid remains.
53
+ */
54
+ export declare function normalizePathChain(chain: unknown): ControlPath[];
55
+ /**
56
+ * Extract the preferred chain from a resolved config (`{paths: {preferredChain}}`),
57
+ * a bare `{preferredChain}` object or an array. Falls back to the default chain.
58
+ */
59
+ export declare function preferredChainFromConfig(config: unknown): ControlPath[];
60
+ /** The stage for a selected path; `null` means no path is available. */
61
+ export declare function stageForPath(path: ControlPath | null): DegradeStage;
62
+ /**
63
+ * Select the first available path from `chain` for the given availability facts.
64
+ *
65
+ * Pure: never throws, never mutates its inputs, and reports every skipped path
66
+ * with a reason.
67
+ */
68
+ export declare function selectPath(chain: readonly ControlPath[], facts?: AvailabilityFacts): PathSelection;
69
+ /** The degradation state machine bound to one config's preferred chain. */
70
+ export declare class DegradeChain {
71
+ /** Normalized preferred chain (never empty). */
72
+ readonly chain: ControlPath[];
73
+ constructor(config: unknown);
74
+ /** The first available path and the reasons for every skip. */
75
+ select(facts?: AvailabilityFacts): PathSelection;
76
+ /** True when only the manual guide path remains (or nothing is available). */
77
+ isGuideOnly(facts?: AvailabilityFacts): boolean;
78
+ /** The still-available fallbacks after the selected path, in preference order. */
79
+ fallbacks(facts?: AvailabilityFacts): ControlPath[];
80
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Execution-path degradation state machine: pb-editable → gui-assisted → guide-only.
3
+ *
4
+ * The plugin prefers the strongest available path from `config.paths
5
+ * .preferredChain` (default `["pb", "gui", "guide"]`). Availability is a fact
6
+ * reported by the caller (probe results, capability checks); this module is pure
7
+ * and deterministic, so the whole decision can be unit-tested without touching
8
+ * the app, the GUI sidecar or the network.
9
+ *
10
+ * ```ts
11
+ * const chain = new DegradeChain(config)
12
+ * const selection = chain.select({ pb: false, gui: { available: true }, guide: true })
13
+ * // -> { path: "gui", stage: "gui-assisted", degraded: true, ... }
14
+ * ```
15
+ * @module xstudio-linux/core/degrade/chain
16
+ */
17
+ /** The default preferred chain (matches `src/config.ts`). */
18
+ export const DEFAULT_PATH_CHAIN = Object.freeze(['pb', 'gui', 'guide']);
19
+ /** True when a value is a known control path. */
20
+ export function isControlPath(value) {
21
+ return value === 'pb' || value === 'gui' || value === 'guide';
22
+ }
23
+ /**
24
+ * Normalize an untrusted chain: keep known paths, drop duplicates, preserve
25
+ * order, and fall back to {@link DEFAULT_PATH_CHAIN} when nothing valid remains.
26
+ */
27
+ export function normalizePathChain(chain) {
28
+ const normalized = [];
29
+ if (Array.isArray(chain)) {
30
+ for (const item of chain) {
31
+ if (isControlPath(item) && !normalized.includes(item))
32
+ normalized.push(item);
33
+ }
34
+ }
35
+ return normalized.length > 0 ? normalized : [...DEFAULT_PATH_CHAIN];
36
+ }
37
+ /**
38
+ * Extract the preferred chain from a resolved config (`{paths: {preferredChain}}`),
39
+ * a bare `{preferredChain}` object or an array. Falls back to the default chain.
40
+ */
41
+ export function preferredChainFromConfig(config) {
42
+ if (Array.isArray(config))
43
+ return normalizePathChain(config);
44
+ if (typeof config !== 'object' || config === null)
45
+ return [...DEFAULT_PATH_CHAIN];
46
+ const record = config;
47
+ const paths = record.paths;
48
+ if (typeof paths === 'object' && paths !== null && !Array.isArray(paths)) {
49
+ const chain = paths.preferredChain;
50
+ if (chain !== undefined)
51
+ return normalizePathChain(chain);
52
+ }
53
+ if (record.preferredChain !== undefined)
54
+ return normalizePathChain(record.preferredChain);
55
+ return [...DEFAULT_PATH_CHAIN];
56
+ }
57
+ /** The stage for a selected path; `null` means no path is available. */
58
+ export function stageForPath(path) {
59
+ if (path === 'pb')
60
+ return 'pb-editable';
61
+ if (path === 'gui')
62
+ return 'gui-assisted';
63
+ if (path === 'guide')
64
+ return 'guide-only';
65
+ return 'unavailable';
66
+ }
67
+ /** Normalize one availability fact into `{available, reason}`. */
68
+ function readAvailability(facts, link) {
69
+ const raw = facts[link];
70
+ if (raw === undefined || raw === null)
71
+ return { available: false, reason: '未上报可用性(按不可用处理)' };
72
+ if (typeof raw === 'boolean') {
73
+ return raw ? { available: true, reason: `${link} 可用` } : { available: false, reason: `${link} 上报为不可用` };
74
+ }
75
+ if (typeof raw === 'object') {
76
+ if (raw.available === true) {
77
+ return { available: true, reason: typeof raw.reason === 'string' && raw.reason !== '' ? raw.reason : `${link} 可用` };
78
+ }
79
+ const reason = typeof raw.reason === 'string' && raw.reason !== '' ? raw.reason : `${link} 上报为不可用`;
80
+ return { available: false, reason };
81
+ }
82
+ return { available: false, reason: '可用性数据格式非法(按不可用处理)' };
83
+ }
84
+ /**
85
+ * Select the first available path from `chain` for the given availability facts.
86
+ *
87
+ * Pure: never throws, never mutates its inputs, and reports every skipped path
88
+ * with a reason.
89
+ */
90
+ export function selectPath(chain, facts = {}) {
91
+ const normalized = normalizePathChain([...chain]);
92
+ const skipped = [];
93
+ for (const link of normalized) {
94
+ const availability = readAvailability(facts, link);
95
+ if (availability.available) {
96
+ const degraded = skipped.length > 0;
97
+ const reason = degraded
98
+ ? `已降级到 ${link}:${skipped.map((skippedLink) => `${skippedLink.link}(${skippedLink.reason})`).join('、')} 不可用`
99
+ : `首选路径 ${link} 可用`;
100
+ return { path: link, stage: stageForPath(link), degraded, skipped, reason };
101
+ }
102
+ skipped.push({ link, reason: availability.reason });
103
+ }
104
+ return {
105
+ path: null,
106
+ stage: 'unavailable',
107
+ degraded: true,
108
+ skipped,
109
+ reason: `所有首选路径都不可用:${skipped.map((skippedLink) => `${skippedLink.link}(${skippedLink.reason})`).join('、')}`,
110
+ };
111
+ }
112
+ /** The degradation state machine bound to one config's preferred chain. */
113
+ export class DegradeChain {
114
+ /** Normalized preferred chain (never empty). */
115
+ chain;
116
+ constructor(config) {
117
+ this.chain = preferredChainFromConfig(config);
118
+ }
119
+ /** The first available path and the reasons for every skip. */
120
+ select(facts = {}) {
121
+ return selectPath(this.chain, facts);
122
+ }
123
+ /** True when only the manual guide path remains (or nothing is available). */
124
+ isGuideOnly(facts = {}) {
125
+ const stage = this.select(facts).stage;
126
+ return stage === 'guide-only' || stage === 'unavailable';
127
+ }
128
+ /** The still-available fallbacks after the selected path, in preference order. */
129
+ fallbacks(facts = {}) {
130
+ const selection = this.select(facts);
131
+ if (selection.path === null)
132
+ return [];
133
+ const index = this.chain.indexOf(selection.path);
134
+ return index < 0 ? [] : this.chain.slice(index + 1);
135
+ }
136
+ }
137
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/core/degrade/chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAA2B,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAU,CAAC,CAAA;AA+BxG,iDAAiD;AACjD,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,KAAK,IAAI,IA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s are matched against a local fingerprint table (the
5
+ * same ids the GUI skill documents). Unmatched dialogs return the always-safe
6
+ * `manual` action with confidence 0; Tavily enrichment was removed, so no
7
+ * search is ever performed and no search-derived text can enter the result.
8
+ * @module xstudio-linux/core/diagnose/error-resolver
9
+ */
10
+ import type { DialogDiagnosis, DialogFingerprint } from '../contracts.js';
11
+ /** The only suggested actions a diagnosis may return. */
12
+ export declare const DIAGNOSIS_ACTIONS: readonly DialogDiagnosis['suggestedAction'][];
13
+ /** Longest dialog snippet quoted into a manual instruction. */
14
+ export declare const MAX_DIALOG_INSTRUCTION_CHARS = 120;
15
+ /**
16
+ * Local dialog fingerprint table.
17
+ *
18
+ * `action` uses the {@link DialogFingerprint} vocabulary (dismiss/cancel/
19
+ * confirm/retry/login/manual); `match` entries are alternative substrings,
20
+ * any one of which identifies the dialog. More specific fingerprints come
21
+ * first so "无法连接网络" matches cloud-unreachable rather than a generic one.
22
+ */
23
+ export declare const KNOWN_DIALOGS: readonly DialogFingerprint[];
24
+ /** Map a fingerprint action onto the diagnosis enum (never auto-confirm). */
25
+ export declare function suggestionForFingerprint(action: DialogFingerprint['action']): DialogDiagnosis['suggestedAction'];
26
+ /** The diagnosis action for one known fingerprint. */
27
+ export declare function diagnosisActionForFingerprint(fingerprint: DialogFingerprint): DialogDiagnosis['suggestedAction'];
28
+ /** NFKC-normalize, collapse all whitespace and trim (defensive on unknown input). */
29
+ export declare function normalizeDialogText(text: unknown): string;
30
+ /**
31
+ * Match a dialog against the local fingerprint table.
32
+ *
33
+ * Returns the most specific fingerprint (table order) whose any-of match
34
+ * needles appears in the normalized dialog text, or null for unknown dialogs.
35
+ */
36
+ export declare function matchKnownDialog(text: string): DialogFingerprint | null;
37
+ /** The always-safe unknown-dialog result. */
38
+ export declare function fallbackDiagnosis(dialogText: string, reason: string): DialogDiagnosis;
39
+ /** Construction dependencies (kept for signature compatibility; ignored). */
40
+ export interface DiagnoseDeps {
41
+ config?: unknown;
42
+ fetchImpl?: unknown;
43
+ now?: () => number;
44
+ }
45
+ /**
46
+ * Diagnose one X Studio dialog (local fingerprints only; never throws).
47
+ *
48
+ * Known fingerprints resolve with `via: "pb"` and confidence 1. Unknown
49
+ * dialogs return the always-safe `manual` action with `via: "local-fallback"`.
50
+ */
51
+ export declare function diagnoseDialog(errorText: string, _deps?: DiagnoseDeps): Promise<DialogDiagnosis>;