@lokascript/domain-voice 2.1.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.
@@ -0,0 +1,515 @@
1
+ import { defineCommand, defineRole } from '@lokascript/framework';
2
+ import type { CommandSchema } from '@lokascript/framework';
3
+
4
+ // =============================================================================
5
+ // navigate — Go to URL, page section, or ARIA landmark
6
+ // EN: navigate to home / go to /settings
7
+ // ES: navegar a inicio
8
+ // JA: ホーム に 移動
9
+ // AR: انتقل إلى الرئيسية
10
+ // KO: 홈 으로 이동
11
+ // ZH: 导航 到 首页
12
+ // TR: ana-sayfa ya git
13
+ // FR: naviguer vers accueil
14
+ // =============================================================================
15
+
16
+ export const navigateSchema = defineCommand({
17
+ action: 'navigate',
18
+ description: 'Navigate to a URL, page section, or ARIA landmark',
19
+ category: 'navigation',
20
+ primaryRole: 'destination',
21
+ roles: [
22
+ defineRole({
23
+ role: 'destination',
24
+ description: 'URL, page section, or ARIA landmark to navigate to',
25
+ required: true,
26
+ expectedTypes: ['expression'],
27
+ svoPosition: 1,
28
+ sovPosition: 1,
29
+ markerOverride: {
30
+ en: 'to',
31
+ es: 'a',
32
+ ja: 'に',
33
+ ar: 'إلى',
34
+ ko: '로',
35
+ zh: '到',
36
+ tr: 'ya',
37
+ fr: 'vers',
38
+ },
39
+ }),
40
+ ],
41
+ });
42
+
43
+ // =============================================================================
44
+ // click — Click an element by selector, text content, or ARIA label
45
+ // EN: click the submit button / click #submit
46
+ // ES: clic en enviar
47
+ // JA: 送信ボタン を クリック
48
+ // AR: انقر على إرسال
49
+ // KO: 제출 을 클릭
50
+ // ZH: 点击 提交
51
+ // TR: gönder i tıkla
52
+ // FR: cliquer sur envoyer
53
+ // =============================================================================
54
+
55
+ export const clickSchema = defineCommand({
56
+ action: 'click',
57
+ description: 'Click an element identified by selector, text content, or ARIA label',
58
+ category: 'interaction',
59
+ primaryRole: 'patient',
60
+ roles: [
61
+ defineRole({
62
+ role: 'patient',
63
+ description: 'The element to click',
64
+ required: true,
65
+ expectedTypes: ['expression', 'selector'],
66
+ svoPosition: 1,
67
+ sovPosition: 1,
68
+ markerOverride: {
69
+ ja: 'を',
70
+ ko: '을',
71
+ ar: 'على',
72
+ fr: 'sur',
73
+ },
74
+ }),
75
+ ],
76
+ });
77
+
78
+ // =============================================================================
79
+ // type — Type text into an input field
80
+ // EN: type hello into search / type hello world
81
+ // ES: escribir hola en búsqueda
82
+ // JA: 検索 に こんにちは を 入力
83
+ // AR: اكتب مرحبا في البحث
84
+ // KO: 검색 에 안녕 을 입력
85
+ // ZH: 输入 你好 到 搜索
86
+ // TR: arama ya merhaba yaz
87
+ // FR: taper bonjour dans recherche
88
+ // =============================================================================
89
+
90
+ export const typeSchema = defineCommand({
91
+ action: 'type',
92
+ description: 'Type text into an input field',
93
+ category: 'interaction',
94
+ primaryRole: 'patient',
95
+ roles: [
96
+ defineRole({
97
+ role: 'patient',
98
+ description: 'The text to type',
99
+ required: true,
100
+ expectedTypes: ['expression'],
101
+ svoPosition: 2,
102
+ sovPosition: 2,
103
+ markerOverride: { ja: 'を', ko: '을' },
104
+ }),
105
+ defineRole({
106
+ role: 'destination',
107
+ description: 'The input field to type into',
108
+ required: false,
109
+ expectedTypes: ['expression', 'selector'],
110
+ svoPosition: 1,
111
+ sovPosition: 3,
112
+ markerOverride: {
113
+ en: 'into',
114
+ es: 'en',
115
+ ja: 'に',
116
+ ar: 'في',
117
+ ko: '에',
118
+ zh: '到',
119
+ tr: 'ya',
120
+ fr: 'dans',
121
+ },
122
+ }),
123
+ ],
124
+ });
125
+
126
+ // =============================================================================
127
+ // scroll — Scroll the page or element
128
+ // EN: scroll down / scroll up by 500
129
+ // ES: desplazar abajo
130
+ // JA: 下 に スクロール
131
+ // AR: تمرير لأسفل
132
+ // KO: 아래 로 스크롤
133
+ // ZH: 滚动 下
134
+ // TR: aşağı kaydır
135
+ // FR: défiler bas
136
+ // =============================================================================
137
+
138
+ export const scrollSchema = defineCommand({
139
+ action: 'scroll',
140
+ description: 'Scroll the page or a specific element',
141
+ category: 'navigation',
142
+ primaryRole: 'manner',
143
+ roles: [
144
+ defineRole({
145
+ role: 'manner',
146
+ description: 'Direction to scroll (up, down, left, right, top, bottom)',
147
+ required: true,
148
+ expectedTypes: ['expression'],
149
+ svoPosition: 2,
150
+ sovPosition: 2,
151
+ }),
152
+ defineRole({
153
+ role: 'quantity',
154
+ description: 'Amount to scroll (pixels or "page")',
155
+ required: false,
156
+ expectedTypes: ['expression'],
157
+ svoPosition: 1,
158
+ sovPosition: 1,
159
+ markerOverride: {
160
+ en: 'by',
161
+ es: 'por',
162
+ ja: 'だけ',
163
+ ar: 'ب',
164
+ ko: '만큼',
165
+ zh: '幅',
166
+ tr: 'kadar',
167
+ fr: 'de',
168
+ },
169
+ }),
170
+ ],
171
+ });
172
+
173
+ // =============================================================================
174
+ // read — Read element content aloud via TTS
175
+ // EN: read the heading / read #article
176
+ // ES: leer el título
177
+ // JA: 見出し を 読む
178
+ // AR: اقرأ العنوان
179
+ // KO: 제목 을 읽기
180
+ // ZH: 朗读 标题
181
+ // TR: başlık oku
182
+ // FR: lire le titre
183
+ // =============================================================================
184
+
185
+ export const readSchema = defineCommand({
186
+ action: 'read',
187
+ description: 'Read element content aloud using text-to-speech',
188
+ category: 'accessibility',
189
+ primaryRole: 'patient',
190
+ roles: [
191
+ defineRole({
192
+ role: 'patient',
193
+ description: 'The element whose content to read aloud',
194
+ required: true,
195
+ expectedTypes: ['expression', 'selector'],
196
+ svoPosition: 1,
197
+ sovPosition: 1,
198
+ markerOverride: { ja: 'を', ko: '을' },
199
+ }),
200
+ ],
201
+ });
202
+
203
+ // =============================================================================
204
+ // zoom — Zoom the page in or out
205
+ // EN: zoom in / zoom out / zoom reset
206
+ // ES: zoom más / zoom menos
207
+ // JA: ズーム イン / ズーム アウト
208
+ // AR: تكبير / تصغير
209
+ // KO: 확대 / 축소
210
+ // ZH: 缩放 放大 / 缩放 缩小
211
+ // TR: yakınlaş / uzaklaş
212
+ // FR: zoomer / dézoomer
213
+ // =============================================================================
214
+
215
+ export const zoomSchema = defineCommand({
216
+ action: 'zoom',
217
+ description: 'Zoom the page in or out',
218
+ category: 'accessibility',
219
+ primaryRole: 'manner',
220
+ roles: [
221
+ defineRole({
222
+ role: 'manner',
223
+ description: 'Zoom direction (in, out, reset)',
224
+ required: true,
225
+ expectedTypes: ['expression'],
226
+ svoPosition: 1,
227
+ sovPosition: 1,
228
+ }),
229
+ ],
230
+ });
231
+
232
+ // =============================================================================
233
+ // select — Select text or an element
234
+ // EN: select all / select the paragraph
235
+ // ES: seleccionar todo
236
+ // JA: 全て を 選択
237
+ // AR: اختر الكل
238
+ // KO: 전체 를 선택
239
+ // ZH: 选择 全部
240
+ // TR: hepsi seç
241
+ // FR: sélectionner tout
242
+ // =============================================================================
243
+
244
+ export const selectSchema = defineCommand({
245
+ action: 'select',
246
+ description: 'Select text content or an element',
247
+ category: 'interaction',
248
+ primaryRole: 'patient',
249
+ roles: [
250
+ defineRole({
251
+ role: 'patient',
252
+ description: 'The element or text to select',
253
+ required: true,
254
+ expectedTypes: ['expression', 'selector'],
255
+ svoPosition: 1,
256
+ sovPosition: 1,
257
+ markerOverride: { ja: 'を', ko: '를' },
258
+ }),
259
+ ],
260
+ });
261
+
262
+ // =============================================================================
263
+ // back — Navigate back in history
264
+ // EN: back / go back
265
+ // ES: atrás
266
+ // JA: 戻る
267
+ // AR: رجوع
268
+ // KO: 뒤로
269
+ // ZH: 返回
270
+ // TR: geri
271
+ // FR: retour
272
+ // =============================================================================
273
+
274
+ export const backSchema = defineCommand({
275
+ action: 'back',
276
+ description: 'Navigate to the previous page in history',
277
+ category: 'navigation',
278
+ primaryRole: 'quantity',
279
+ roles: [
280
+ defineRole({
281
+ role: 'quantity',
282
+ description: 'Number of pages to go back (default: 1)',
283
+ required: false,
284
+ expectedTypes: ['expression'],
285
+ svoPosition: 1,
286
+ sovPosition: 1,
287
+ }),
288
+ ],
289
+ });
290
+
291
+ // =============================================================================
292
+ // forward — Navigate forward in history
293
+ // EN: forward
294
+ // ES: adelante
295
+ // JA: 進む
296
+ // AR: تقدم
297
+ // KO: 앞으로
298
+ // ZH: 前进
299
+ // TR: ileri
300
+ // FR: avancer
301
+ // =============================================================================
302
+
303
+ export const forwardSchema = defineCommand({
304
+ action: 'forward',
305
+ description: 'Navigate to the next page in history',
306
+ category: 'navigation',
307
+ primaryRole: 'quantity',
308
+ roles: [
309
+ defineRole({
310
+ role: 'quantity',
311
+ description: 'Number of pages to go forward (default: 1)',
312
+ required: false,
313
+ expectedTypes: ['expression'],
314
+ svoPosition: 1,
315
+ sovPosition: 1,
316
+ }),
317
+ ],
318
+ });
319
+
320
+ // =============================================================================
321
+ // focus — Move keyboard focus to an element
322
+ // EN: focus search / focus #email
323
+ // ES: enfocar búsqueda
324
+ // JA: 検索 に フォーカス
325
+ // AR: ركّز على البحث
326
+ // KO: 검색 에 포커스
327
+ // ZH: 聚焦 搜索
328
+ // TR: arama ya odakla
329
+ // FR: focaliser recherche
330
+ // =============================================================================
331
+
332
+ export const focusSchema = defineCommand({
333
+ action: 'focus',
334
+ description: 'Move keyboard focus to an element',
335
+ category: 'accessibility',
336
+ primaryRole: 'patient',
337
+ roles: [
338
+ defineRole({
339
+ role: 'patient',
340
+ description: 'The element to focus',
341
+ required: true,
342
+ expectedTypes: ['expression', 'selector'],
343
+ svoPosition: 1,
344
+ sovPosition: 1,
345
+ markerOverride: {
346
+ ja: 'に',
347
+ ko: '에',
348
+ ar: 'على',
349
+ tr: 'ya',
350
+ },
351
+ }),
352
+ ],
353
+ });
354
+
355
+ // =============================================================================
356
+ // close — Close tab, dialog, or modal
357
+ // EN: close / close dialog / close tab
358
+ // ES: cerrar / cerrar diálogo
359
+ // JA: 閉じる / ダイアログ を 閉じる
360
+ // AR: أغلق / أغلق الحوار
361
+ // KO: 닫기 / 대화상자 를 닫기
362
+ // ZH: 关闭 / 关闭 对话框
363
+ // TR: kapat / diyalog kapat
364
+ // FR: fermer / fermer dialogue
365
+ // =============================================================================
366
+
367
+ export const closeSchema = defineCommand({
368
+ action: 'close',
369
+ description: 'Close the current tab, dialog, or modal',
370
+ category: 'interaction',
371
+ primaryRole: 'patient',
372
+ roles: [
373
+ defineRole({
374
+ role: 'patient',
375
+ description: 'What to close (tab, dialog, modal, menu)',
376
+ required: false,
377
+ expectedTypes: ['expression'],
378
+ svoPosition: 1,
379
+ sovPosition: 1,
380
+ markerOverride: { ja: 'を', ko: '를' },
381
+ }),
382
+ ],
383
+ });
384
+
385
+ // =============================================================================
386
+ // open — Open a link, tab, or menu
387
+ // EN: open settings / open #menu
388
+ // ES: abrir configuración
389
+ // JA: 設定 を 開く
390
+ // AR: افتح الإعدادات
391
+ // KO: 설정 을 열기
392
+ // ZH: 打开 设置
393
+ // TR: ayarlar aç
394
+ // FR: ouvrir paramètres
395
+ // =============================================================================
396
+
397
+ export const openSchema = defineCommand({
398
+ action: 'open',
399
+ description: 'Open a link in a new tab, or open a menu/dropdown',
400
+ category: 'interaction',
401
+ primaryRole: 'patient',
402
+ roles: [
403
+ defineRole({
404
+ role: 'patient',
405
+ description: 'What to open (link, tab, menu, URL)',
406
+ required: true,
407
+ expectedTypes: ['expression'],
408
+ svoPosition: 1,
409
+ sovPosition: 1,
410
+ markerOverride: { ja: 'を', ko: '을' },
411
+ }),
412
+ ],
413
+ });
414
+
415
+ // =============================================================================
416
+ // search — Search on page or via search form
417
+ // EN: search hello / search hello in page
418
+ // ES: buscar hola en página
419
+ // JA: ページ で こんにちは を 検索
420
+ // AR: ابحث عن مرحبا في الصفحة
421
+ // KO: 페이지 에서 안녕 을 검색
422
+ // ZH: 搜索 你好
423
+ // TR: sayfa da merhaba ara
424
+ // FR: chercher bonjour dans page
425
+ // =============================================================================
426
+
427
+ export const searchSchema = defineCommand({
428
+ action: 'search',
429
+ description: 'Search for text on the page or via a search form',
430
+ category: 'interaction',
431
+ primaryRole: 'patient',
432
+ roles: [
433
+ defineRole({
434
+ role: 'patient',
435
+ description: 'The search query text',
436
+ required: true,
437
+ expectedTypes: ['expression'],
438
+ svoPosition: 2,
439
+ sovPosition: 2,
440
+ markerOverride: {
441
+ ar: 'عن',
442
+ ja: 'を',
443
+ ko: '을',
444
+ },
445
+ }),
446
+ defineRole({
447
+ role: 'destination',
448
+ description: 'Where to search (page, site, or search field)',
449
+ required: false,
450
+ expectedTypes: ['expression'],
451
+ svoPosition: 1,
452
+ sovPosition: 3,
453
+ markerOverride: {
454
+ en: 'in',
455
+ es: 'en',
456
+ ja: 'で',
457
+ ar: 'في',
458
+ ko: '에서',
459
+ zh: '在',
460
+ tr: 'da',
461
+ fr: 'dans',
462
+ },
463
+ }),
464
+ ],
465
+ });
466
+
467
+ // =============================================================================
468
+ // help — List available commands or get help
469
+ // EN: help / help navigate
470
+ // ES: ayuda / ayuda navegar
471
+ // JA: ヘルプ / 移動 の ヘルプ
472
+ // AR: مساعدة / مساعدة انتقل
473
+ // KO: 도움말 / 이동 도움말
474
+ // ZH: 帮助 / 导航 帮助
475
+ // TR: yardım / git yardım
476
+ // FR: aide / aide naviguer
477
+ // =============================================================================
478
+
479
+ export const helpSchema = defineCommand({
480
+ action: 'help',
481
+ description: 'List available voice commands or get help for a specific command',
482
+ category: 'meta',
483
+ primaryRole: 'patient',
484
+ roles: [
485
+ defineRole({
486
+ role: 'patient',
487
+ description: 'Specific command to get help for (optional)',
488
+ required: false,
489
+ expectedTypes: ['expression'],
490
+ svoPosition: 1,
491
+ sovPosition: 1,
492
+ }),
493
+ ],
494
+ });
495
+
496
+ // =============================================================================
497
+ // All Schemas
498
+ // =============================================================================
499
+
500
+ export const allSchemas: CommandSchema[] = [
501
+ navigateSchema,
502
+ clickSchema,
503
+ typeSchema,
504
+ scrollSchema,
505
+ readSchema,
506
+ zoomSchema,
507
+ selectSchema,
508
+ backSchema,
509
+ forwardSchema,
510
+ focusSchema,
511
+ closeSchema,
512
+ openSchema,
513
+ searchSchema,
514
+ helpSchema,
515
+ ];