@olares/lares-mobile 0.15.35 → 0.15.37
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.
- package/package.json +2 -2
- package/src/App.vue +1 -0
- package/src/chat/ChatBar.vue +1 -1
- package/src/chat/Composer.vue +1 -1
- package/src/chat/Transcript.vue +2 -2
- package/src/host.js +2 -0
- package/src/mobile/MobileDirectorySheet.vue +1 -1
- package/src/mobile/MobileNewSession.vue +1 -1
- package/src/mobile/MobileShell.vue +110 -3
- package/src/settings/AgentSettings.vue +227 -242
- package/src/settings/PluginsSettings.vue +115 -0
- package/src/settings/SettingRow.vue +20 -2
- package/src/settings/TtsSettings.vue +49 -6
- package/src/settings/VoiceKeys.vue +129 -53
- package/src/settings/VoicePreferences.vue +64 -39
- package/src/settings/VoiceSettings.vue +431 -0
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
<span class="lares-agent__spinner" aria-hidden="true" />
|
|
5
5
|
<p>{{ t("agent.loading") }}</p>
|
|
6
6
|
</div>
|
|
7
|
-
<div class="lares-agent__body" :inert="loading || undefined">
|
|
7
|
+
<div v-if="page === 'voice'" class="lares-agent__body" :inert="loading || undefined">
|
|
8
|
+
<VoiceSettings ref="voicePage" v-bind="voiceBind" :heading="false" />
|
|
9
|
+
</div>
|
|
10
|
+
<div v-else class="lares-agent__body" :inert="loading || undefined">
|
|
8
11
|
<section class="lares-agent__group">
|
|
9
12
|
<h2>{{ tModel("settings.title") }}</h2>
|
|
10
13
|
<LaresSelect
|
|
@@ -41,111 +44,6 @@
|
|
|
41
44
|
<p class="lares-agent__hint">{{ t("settings.input.busyEnter.hint") }}</p>
|
|
42
45
|
<p v-if="conversationError" class="lares-agent__hint" data-status="error">{{ conversationError }}</p>
|
|
43
46
|
</section>
|
|
44
|
-
<section class="lares-agent__group">
|
|
45
|
-
<h2>{{ tVoice("settings.title") }}</h2>
|
|
46
|
-
<div class="lares-agent__list">
|
|
47
|
-
<template v-if="isDesktop">
|
|
48
|
-
<label class="lares-agent__field">
|
|
49
|
-
<span>{{ tVoice('settings.stt.model') }}</span>
|
|
50
|
-
<LaresSelect
|
|
51
|
-
:value="voiceModelId"
|
|
52
|
-
:sections="voiceModelSections"
|
|
53
|
-
:disabled="busy || !voice"
|
|
54
|
-
@select="chooseVoiceModel"
|
|
55
|
-
/>
|
|
56
|
-
</label>
|
|
57
|
-
<label class="lares-agent__field">
|
|
58
|
-
<span>{{ tVoice('settings.language.title') }}</span>
|
|
59
|
-
<LaresSelect
|
|
60
|
-
:value="voiceLangId"
|
|
61
|
-
:sections="voiceLanguageSections"
|
|
62
|
-
:disabled="busy || !voice"
|
|
63
|
-
@select="chooseVoiceLanguage"
|
|
64
|
-
/>
|
|
65
|
-
</label>
|
|
66
|
-
</template>
|
|
67
|
-
<template v-else>
|
|
68
|
-
<LaresSettingRow
|
|
69
|
-
:label="tVoice('settings.stt.model')"
|
|
70
|
-
:value="voiceModelLabel"
|
|
71
|
-
chevron
|
|
72
|
-
boxed
|
|
73
|
-
:disabled="Boolean(pending)"
|
|
74
|
-
@click="openSheet('voiceModel')"
|
|
75
|
-
/>
|
|
76
|
-
<LaresSettingRow
|
|
77
|
-
:label="tVoice('settings.language.title')"
|
|
78
|
-
:value="voiceLangLabel"
|
|
79
|
-
chevron
|
|
80
|
-
boxed
|
|
81
|
-
:disabled="Boolean(pending)"
|
|
82
|
-
@click="openSheet('voiceLang')"
|
|
83
|
-
/>
|
|
84
|
-
</template>
|
|
85
|
-
</div>
|
|
86
|
-
<VoicePreferences :key="hostKey" ref="voicePreferences" :settings="settings" :tts-fetch="ttsFetch" :snapshot="voice" :device="device" :t="tVoice" :bind-before-leave="bindBeforeLeave" @change="voice = $event" />
|
|
87
|
-
<h3>{{ tVoice("settings.conversation") }}</h3>
|
|
88
|
-
<div class="lares-agent__list">
|
|
89
|
-
<template v-if="isDesktop">
|
|
90
|
-
<label class="lares-agent__field">
|
|
91
|
-
<span>{{ tVoice('settings.mobileMode') }}</span>
|
|
92
|
-
<LaresSelect
|
|
93
|
-
:value="voice?.config?.mobileMode || 'continuous'"
|
|
94
|
-
:sections="mobileModeSections"
|
|
95
|
-
:disabled="busy || !voice"
|
|
96
|
-
@select="(item) => patchVoice('mobileMode', item.id)"
|
|
97
|
-
/>
|
|
98
|
-
</label>
|
|
99
|
-
<label class="lares-agent__field">
|
|
100
|
-
<span>{{ tVoice('settings.device') }}</span>
|
|
101
|
-
<LaresSelect
|
|
102
|
-
:value="voice?.config?.device || 'auto'"
|
|
103
|
-
:sections="deviceSections"
|
|
104
|
-
:disabled="busy || !voice"
|
|
105
|
-
@select="(item) => patchVoice('device', item.id)"
|
|
106
|
-
/>
|
|
107
|
-
</label>
|
|
108
|
-
<label class="lares-agent__field">
|
|
109
|
-
<span>{{ tVoice('settings.mode.title') }}</span>
|
|
110
|
-
<LaresSelect
|
|
111
|
-
:value="voice?.config?.streaming ? 'streaming' : 'turns'"
|
|
112
|
-
:sections="readingSections"
|
|
113
|
-
:disabled="busy || !voice || !reading"
|
|
114
|
-
@select="(item) => chooseReading(item.id)"
|
|
115
|
-
/>
|
|
116
|
-
</label>
|
|
117
|
-
</template>
|
|
118
|
-
<template v-else>
|
|
119
|
-
<LaresSettingRow
|
|
120
|
-
:label="tVoice('settings.mobileMode')"
|
|
121
|
-
:value="voiceChoiceLabel('mobileMode')"
|
|
122
|
-
chevron
|
|
123
|
-
boxed
|
|
124
|
-
:disabled="Boolean(pending) || !voice"
|
|
125
|
-
@click="openSheet('voiceMobileMode')"
|
|
126
|
-
/>
|
|
127
|
-
<LaresSettingRow
|
|
128
|
-
:label="tVoice('settings.device')"
|
|
129
|
-
:value="voiceChoiceLabel('device')"
|
|
130
|
-
chevron
|
|
131
|
-
boxed
|
|
132
|
-
:disabled="Boolean(pending) || !voice"
|
|
133
|
-
@click="openSheet('voiceDevice')"
|
|
134
|
-
/>
|
|
135
|
-
<LaresSettingRow
|
|
136
|
-
:label="tVoice('settings.mode.title')"
|
|
137
|
-
:value="voiceChoiceLabel('reading')"
|
|
138
|
-
chevron
|
|
139
|
-
boxed
|
|
140
|
-
:disabled="Boolean(pending) || !voice || !reading"
|
|
141
|
-
@click="openSheet('voiceReading')"
|
|
142
|
-
/>
|
|
143
|
-
</template>
|
|
144
|
-
</div>
|
|
145
|
-
<p class="lares-agent__hint">{{ readingHint }}</p>
|
|
146
|
-
<p v-if="voiceError" class="lares-agent__hint" data-status="error">{{ voiceError }}</p>
|
|
147
|
-
<VoiceKeys :key="`keys-${hostKey}`" :client="voiceKeys" :t="tVoice" />
|
|
148
|
-
</section>
|
|
149
47
|
<section class="lares-agent__group">
|
|
150
48
|
<h2>{{ tSearch("settings.title") }}</h2>
|
|
151
49
|
<LaresSelect
|
|
@@ -167,7 +65,44 @@
|
|
|
167
65
|
</div>
|
|
168
66
|
<p v-if="searchError" class="lares-agent__hint" data-status="error">{{ searchError }}</p>
|
|
169
67
|
</section>
|
|
170
|
-
<
|
|
68
|
+
<section v-if="permission?.options?.length || permissionError" class="lares-agent__group">
|
|
69
|
+
<h2>{{ t("permission.default") }}</h2>
|
|
70
|
+
<LaresSelect
|
|
71
|
+
v-if="isDesktop && permission?.options?.length"
|
|
72
|
+
:value="permission.current"
|
|
73
|
+
:sections="permissionSections"
|
|
74
|
+
:disabled="busy || !permission?.writable"
|
|
75
|
+
@select="choosePermission"
|
|
76
|
+
/>
|
|
77
|
+
<div v-else-if="permission?.options?.length" class="lares-agent__list">
|
|
78
|
+
<LaresSettingRow
|
|
79
|
+
:label="permissionLabel"
|
|
80
|
+
:hint="permissionHint"
|
|
81
|
+
chevron
|
|
82
|
+
boxed
|
|
83
|
+
:disabled="Boolean(pending) || !permission.writable"
|
|
84
|
+
@click="openSheet('permission')"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
<div v-if="isDesktop && accessConfirm" class="lares-agent__access">
|
|
88
|
+
<p>{{ t("access.confirm.description") }}</p>
|
|
89
|
+
<label>
|
|
90
|
+
<input v-model="accessAcknowledged" type="checkbox" />
|
|
91
|
+
<span>{{ t("access.confirm.acknowledge") }}</span>
|
|
92
|
+
</label>
|
|
93
|
+
<div class="lares-agent__access-actions">
|
|
94
|
+
<button type="button" @click="cancelAccess">{{ t("access.confirm.cancel") }}</button>
|
|
95
|
+
<button type="button" :disabled="!accessAcknowledged || busy" @click="confirmAccess">{{ t("access.confirm.enable") }}</button>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
<p v-if="permissionError" class="lares-agent__hint" data-status="error">{{ permissionError }}</p>
|
|
99
|
+
</section>
|
|
100
|
+
<section class="lares-agent__group">
|
|
101
|
+
<h2>{{ tVoice("settings.title") }}</h2>
|
|
102
|
+
<VoiceSettings ref="voicePage" v-bind="voiceBind" :heading="false" />
|
|
103
|
+
</section>
|
|
104
|
+
<PluginsSettings :key="`plugins-${hostKey}`" :client="plugins" :locale="locale" :device="layoutDevice" />
|
|
105
|
+
<LaresSheet v-if="!isDesktop" :open="Boolean(panel)" :title="sheetTitle" @close="closeSheet">
|
|
171
106
|
<p v-if="sheetEmpty" class="lares-agent__hint lares-agent__hint--sheet">{{ sheetEmpty }}</p>
|
|
172
107
|
<template v-for="section in sheetSections" :key="section.heading || 'main'">
|
|
173
108
|
<p v-if="section.heading" class="lares-agent__heading">{{ section.heading }}</p>
|
|
@@ -175,11 +110,23 @@
|
|
|
175
110
|
v-for="item in section.items"
|
|
176
111
|
:key="item.id"
|
|
177
112
|
:label="item.label"
|
|
113
|
+
:hint="item.hint"
|
|
178
114
|
:checked="item.id === sheetCurrent"
|
|
179
115
|
:disabled="busy || item.disabled"
|
|
180
116
|
@click="pick(item)"
|
|
181
117
|
/>
|
|
182
118
|
</template>
|
|
119
|
+
<div v-if="panel === 'permission' && accessConfirm" class="lares-agent__access">
|
|
120
|
+
<p>{{ t("access.confirm.description") }}</p>
|
|
121
|
+
<label>
|
|
122
|
+
<input v-model="accessAcknowledged" type="checkbox" />
|
|
123
|
+
<span>{{ t("access.confirm.acknowledge") }}</span>
|
|
124
|
+
</label>
|
|
125
|
+
<div class="lares-agent__access-actions">
|
|
126
|
+
<button type="button" @click="cancelAccess">{{ t("access.confirm.cancel") }}</button>
|
|
127
|
+
<button type="button" :disabled="!accessAcknowledged || busy" @click="confirmAccess">{{ t("access.confirm.enable") }}</button>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
183
130
|
</LaresSheet>
|
|
184
131
|
</div>
|
|
185
132
|
</div>
|
|
@@ -191,25 +138,20 @@ import { EN as MODEL_EN, ZH as MODEL_ZH } from "@olares/lares-core/i18n/chat-mod
|
|
|
191
138
|
import { EN as VOICE_EN, ZH as VOICE_ZH } from "@olares/lares-core/i18n/voice";
|
|
192
139
|
import { EN as SEARCH_EN, ZH as SEARCH_ZH } from "@olares/lares-core/i18n/search";
|
|
193
140
|
import { groupModelsByProvider, selectionKey } from "@olares/lares-core/router/session-model";
|
|
194
|
-
import {
|
|
195
|
-
voiceLanguageItems,
|
|
196
|
-
voiceMenuValue,
|
|
197
|
-
voiceModelItems,
|
|
198
|
-
voiceValueFromMenu,
|
|
199
|
-
} from "@olares/lares-core/voice/languages";
|
|
200
141
|
import {
|
|
201
142
|
searchMenuValue,
|
|
202
143
|
searchSelectorItems,
|
|
203
144
|
searchValueFromMenu,
|
|
204
145
|
} from "@olares/lares-core/search/menu";
|
|
146
|
+
import { presetDescription, presetLabel } from "@olares/lares-core/larepass/permissions";
|
|
205
147
|
import { rememberedSettings } from "@olares/lares-core/larepass/settings";
|
|
206
148
|
import { hostKey as hostSessionKey } from "@olares/lares-core/larepass/host";
|
|
207
149
|
import { createHostClient } from "../host.js";
|
|
208
150
|
import { adoptHost } from "../runtime.js";
|
|
209
151
|
import { createT } from "../i18n.js";
|
|
210
152
|
import { chatDevice, DEVICE_DESKTOP } from "../layout.js";
|
|
211
|
-
import
|
|
212
|
-
import
|
|
153
|
+
import PluginsSettings from "./PluginsSettings.vue";
|
|
154
|
+
import VoiceSettings from "./VoiceSettings.vue";
|
|
213
155
|
import LaresSettingRow from "./SettingRow.vue";
|
|
214
156
|
import LaresSheet from "./Sheet.vue";
|
|
215
157
|
import LaresSelect from "./Select.vue";
|
|
@@ -226,8 +168,9 @@ function itemLabel(items, id) {
|
|
|
226
168
|
|
|
227
169
|
export default {
|
|
228
170
|
name: "LaresAgentSettings",
|
|
229
|
-
components: {
|
|
230
|
-
expose: ["reload", "beforeLeave"],
|
|
171
|
+
components: { PluginsSettings, VoiceSettings, LaresSettingRow, LaresSheet, LaresSelect },
|
|
172
|
+
expose: ["reload", "beforeLeave", "closePage"],
|
|
173
|
+
emits: ["page"],
|
|
231
174
|
props: {
|
|
232
175
|
locale: { type: String, default: "en" },
|
|
233
176
|
device: { type: String, default: "mobile" },
|
|
@@ -241,18 +184,20 @@ export default {
|
|
|
241
184
|
data() {
|
|
242
185
|
const remembered = rememberedSettings();
|
|
243
186
|
return {
|
|
244
|
-
loading: !(remembered.models && remembered.
|
|
187
|
+
loading: !(remembered.models && remembered.search && remembered.conversation),
|
|
245
188
|
pending: "",
|
|
246
189
|
panel: "",
|
|
190
|
+
page: "",
|
|
247
191
|
models: remembered.models,
|
|
248
|
-
voice: remembered.voice,
|
|
249
192
|
search: remembered.search,
|
|
250
193
|
conversation: remembered.conversation,
|
|
194
|
+
permission: remembered.permission,
|
|
251
195
|
modelError: "",
|
|
252
|
-
voiceError: "",
|
|
253
196
|
searchError: "",
|
|
254
197
|
conversationError: "",
|
|
255
|
-
|
|
198
|
+
permissionError: "",
|
|
199
|
+
accessConfirm: false,
|
|
200
|
+
accessAcknowledged: false,
|
|
256
201
|
};
|
|
257
202
|
},
|
|
258
203
|
computed: {
|
|
@@ -277,8 +222,19 @@ export default {
|
|
|
277
222
|
hostKey() {
|
|
278
223
|
return hostSessionKey(this.ports);
|
|
279
224
|
},
|
|
280
|
-
|
|
281
|
-
|
|
225
|
+
plugins() { return createHostClient(this.ports).plugins; },
|
|
226
|
+
voiceBind() {
|
|
227
|
+
return {
|
|
228
|
+
locale: this.locale,
|
|
229
|
+
device: this.device,
|
|
230
|
+
baseUrl: this.baseUrl,
|
|
231
|
+
proxyPrefix: this.proxyPrefix,
|
|
232
|
+
request: this.request,
|
|
233
|
+
env: this.env,
|
|
234
|
+
missing: this.missing,
|
|
235
|
+
bindBeforeLeave: this.bindBeforeLeave,
|
|
236
|
+
};
|
|
237
|
+
},
|
|
282
238
|
settings() {
|
|
283
239
|
return createHostClient(this.ports).settings;
|
|
284
240
|
},
|
|
@@ -294,12 +250,6 @@ export default {
|
|
|
294
250
|
modelFailures() {
|
|
295
251
|
return this.models?.failures ?? [];
|
|
296
252
|
},
|
|
297
|
-
voiceModels() {
|
|
298
|
-
return voiceModelItems(this.voice?.sttModels ?? [], this.tVoice("settings.model.auto"));
|
|
299
|
-
},
|
|
300
|
-
voiceLanguages() {
|
|
301
|
-
return voiceLanguageItems(this.tVoice("lang.auto"));
|
|
302
|
-
},
|
|
303
253
|
searchModels() {
|
|
304
254
|
return Array.isArray(this.search?.searchModels) ? this.search.searchModels : [];
|
|
305
255
|
},
|
|
@@ -318,31 +268,23 @@ export default {
|
|
|
318
268
|
}
|
|
319
269
|
return this.models.default?.model || "—";
|
|
320
270
|
},
|
|
321
|
-
|
|
322
|
-
return
|
|
323
|
-
},
|
|
324
|
-
voiceLangId() {
|
|
325
|
-
return voiceMenuValue(this.voice?.config?.language);
|
|
326
|
-
},
|
|
327
|
-
voiceModelSections() {
|
|
328
|
-
return [{ items: this.voiceModels }];
|
|
271
|
+
permissionOption() {
|
|
272
|
+
return this.permission?.options?.find((option) => option.value === this.permission.current) || null;
|
|
329
273
|
},
|
|
330
|
-
|
|
331
|
-
return
|
|
274
|
+
permissionLabel() {
|
|
275
|
+
return presetLabel(this.t, this.permissionOption) || "—";
|
|
332
276
|
},
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return itemLabel(this.voiceModels, this.voiceModelId);
|
|
277
|
+
permissionHint() {
|
|
278
|
+
return presetDescription(this.t, this.permissionOption) || this.t("permission.default.hint");
|
|
336
279
|
},
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
return this.tVoice("settings.mode.hint");
|
|
280
|
+
permissionSections() {
|
|
281
|
+
return [{
|
|
282
|
+
items: (this.permission?.options || []).map((option) => ({
|
|
283
|
+
id: option.value,
|
|
284
|
+
label: presetLabel(this.t, option),
|
|
285
|
+
hint: presetDescription(this.t, option),
|
|
286
|
+
})),
|
|
287
|
+
}];
|
|
346
288
|
},
|
|
347
289
|
searchMenuId() {
|
|
348
290
|
return searchMenuValue(this.search);
|
|
@@ -372,28 +314,10 @@ export default {
|
|
|
372
314
|
],
|
|
373
315
|
}];
|
|
374
316
|
},
|
|
375
|
-
mobileModeSections() {
|
|
376
|
-
return [{ items: ["single", "continuous"].map((id) => ({ id, label: this.tVoice(`settings.mode.${id}`) })) }];
|
|
377
|
-
},
|
|
378
|
-
deviceSections() {
|
|
379
|
-
return [{ items: ["auto", "device", "headset"].map((id) => ({ id, label: this.tVoice(`settings.device.${id}`) })) }];
|
|
380
|
-
},
|
|
381
|
-
readingSections() {
|
|
382
|
-
return [{
|
|
383
|
-
items: [
|
|
384
|
-
{ id: "turns", label: this.tVoice("settings.mode.turns") },
|
|
385
|
-
{ id: "streaming", label: this.tVoice("settings.mode.streaming"), disabled: !this.reading?.allowed },
|
|
386
|
-
],
|
|
387
|
-
}];
|
|
388
|
-
},
|
|
389
317
|
sheetTitle() {
|
|
390
318
|
if (this.panel === "model") return this.tModel("settings.title");
|
|
391
|
-
if (this.panel === "voiceModel") return this.tVoice("settings.stt.model");
|
|
392
|
-
if (this.panel === "voiceLang") return this.tVoice("settings.language.title");
|
|
393
|
-
if (this.panel === "voiceMobileMode") return this.tVoice("settings.mobileMode");
|
|
394
|
-
if (this.panel === "voiceDevice") return this.tVoice("settings.device");
|
|
395
|
-
if (this.panel === "voiceReading") return this.tVoice("settings.mode.title");
|
|
396
319
|
if (this.panel === "search") return this.tSearch("settings.default");
|
|
320
|
+
if (this.panel === "permission") return this.t("permission.default");
|
|
397
321
|
return "";
|
|
398
322
|
},
|
|
399
323
|
sheetCurrent() {
|
|
@@ -401,16 +325,8 @@ export default {
|
|
|
401
325
|
},
|
|
402
326
|
sheetSections() {
|
|
403
327
|
if (this.panel === "model") return this.modelSelectSections;
|
|
404
|
-
if (this.panel === "voiceModel") {
|
|
405
|
-
return [{ items: this.voiceModels.map((item) => ({ id: item.id, label: item.label })) }];
|
|
406
|
-
}
|
|
407
|
-
if (this.panel === "voiceLang") {
|
|
408
|
-
return [{ items: this.voiceLanguages.map((item) => ({ id: item.id, label: item.label })) }];
|
|
409
|
-
}
|
|
410
|
-
if (this.panel === "voiceMobileMode") return this.mobileModeSections;
|
|
411
|
-
if (this.panel === "voiceDevice") return this.deviceSections;
|
|
412
|
-
if (this.panel === "voiceReading") return this.readingSections;
|
|
413
328
|
if (this.panel === "search") return this.searchSelectSections;
|
|
329
|
+
if (this.panel === "permission") return this.permissionSections;
|
|
414
330
|
return [];
|
|
415
331
|
},
|
|
416
332
|
sheetEmpty() {
|
|
@@ -424,14 +340,16 @@ export default {
|
|
|
424
340
|
hostKey() {
|
|
425
341
|
adoptHost(this.ports);
|
|
426
342
|
this.panel = "";
|
|
343
|
+
this.page = "";
|
|
344
|
+
this.$emit("page", "");
|
|
427
345
|
this.models = null;
|
|
428
|
-
this.voice = null;
|
|
429
346
|
this.search = null;
|
|
430
347
|
this.conversation = null;
|
|
348
|
+
this.permission = null;
|
|
431
349
|
this.modelError = "";
|
|
432
|
-
this.voiceError = "";
|
|
433
350
|
this.searchError = "";
|
|
434
351
|
this.conversationError = "";
|
|
352
|
+
this.permissionError = "";
|
|
435
353
|
this.load(true);
|
|
436
354
|
},
|
|
437
355
|
},
|
|
@@ -440,7 +358,7 @@ export default {
|
|
|
440
358
|
// LarePass has no catalog-revision stream, so returning to the panel is
|
|
441
359
|
// the only moment a Router change can still be picked up.
|
|
442
360
|
this.onVisible = () => {
|
|
443
|
-
if (document.visibilityState === "visible" && !this.busy) this.
|
|
361
|
+
if (document.visibilityState === "visible" && !this.busy) this.reload();
|
|
444
362
|
};
|
|
445
363
|
document.addEventListener("visibilitychange", this.onVisible);
|
|
446
364
|
},
|
|
@@ -465,96 +383,108 @@ export default {
|
|
|
465
383
|
},
|
|
466
384
|
openSheet(panel) {
|
|
467
385
|
if (this.loading) return;
|
|
468
|
-
const ready = panel === "model" ? this.models : panel === "search" ? this.search : this.
|
|
386
|
+
const ready = panel === "model" ? this.models : panel === "search" ? this.search : this.permission?.options?.length;
|
|
469
387
|
if (!ready) return;
|
|
388
|
+
this.accessConfirm = false;
|
|
389
|
+
this.accessAcknowledged = false;
|
|
470
390
|
this.panel = panel;
|
|
471
391
|
},
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
392
|
+
openVoice() {
|
|
393
|
+
this.panel = "";
|
|
394
|
+
this.page = "voice";
|
|
395
|
+
this.$emit("page", "voice");
|
|
396
|
+
},
|
|
397
|
+
closePage() {
|
|
398
|
+
if (this.page !== "voice") return false;
|
|
399
|
+
this.page = "";
|
|
400
|
+
this.$emit("page", "");
|
|
401
|
+
return true;
|
|
402
|
+
},
|
|
403
|
+
closeSheet() {
|
|
404
|
+
this.panel = "";
|
|
405
|
+
this.cancelAccess();
|
|
406
|
+
},
|
|
407
|
+
cancelAccess() {
|
|
408
|
+
this.accessConfirm = false;
|
|
409
|
+
this.accessAcknowledged = false;
|
|
410
|
+
},
|
|
411
|
+
confirmAccess() {
|
|
412
|
+
if (!this.accessAcknowledged) return;
|
|
413
|
+
this.panel = "";
|
|
414
|
+
this.accessConfirm = false;
|
|
415
|
+
return this.savePermission("danger-full-access");
|
|
416
|
+
},
|
|
417
|
+
choosePermission(item) {
|
|
418
|
+
const id = item?.id;
|
|
419
|
+
if (!id || id === this.permission?.current || this.busy) return;
|
|
420
|
+
if (id === "danger-full-access") {
|
|
421
|
+
this.accessConfirm = true;
|
|
422
|
+
this.accessAcknowledged = false;
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
this.cancelAccess();
|
|
426
|
+
return this.savePermission(id);
|
|
479
427
|
},
|
|
480
428
|
async pick(item, panel = this.panel) {
|
|
481
429
|
if (item.disabled) return;
|
|
430
|
+
if (panel === "permission") {
|
|
431
|
+
if (item.id === this.permission?.current) {
|
|
432
|
+
this.closeSheet();
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
this.choosePermission(item);
|
|
436
|
+
if (item.id !== "danger-full-access") this.panel = "";
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
482
439
|
if (item.id === this.sheetCurrentFor(panel)) {
|
|
483
440
|
this.panel = "";
|
|
484
441
|
return;
|
|
485
442
|
}
|
|
486
443
|
this.panel = "";
|
|
487
444
|
if (panel === "model") await this.chooseModel(item.model);
|
|
488
|
-
if (panel === "voiceModel") await this.patchVoice("model", voiceValueFromMenu(item.id));
|
|
489
|
-
if (panel === "voiceLang") await this.patchVoice("language", voiceValueFromMenu(item.id));
|
|
490
|
-
if (panel === "voiceMobileMode") await this.patchVoice("mobileMode", item.id);
|
|
491
|
-
if (panel === "voiceDevice") await this.patchVoice("device", item.id);
|
|
492
|
-
if (panel === "voiceReading") this.chooseReading(item.id);
|
|
493
445
|
if (panel === "search") await this.chooseSearch(item.id);
|
|
494
446
|
},
|
|
495
447
|
sheetCurrentFor(panel) {
|
|
496
448
|
if (panel === "model") return this.modelCurrent;
|
|
497
|
-
if (panel === "voiceModel") return voiceMenuValue(this.voice?.config?.model);
|
|
498
|
-
if (panel === "voiceLang") return voiceMenuValue(this.voice?.config?.language);
|
|
499
|
-
if (panel === "voiceMobileMode") return this.voice?.config?.mobileMode || "continuous";
|
|
500
|
-
if (panel === "voiceDevice") return this.voice?.config?.device || "auto";
|
|
501
|
-
if (panel === "voiceReading") return this.voice?.config?.streaming ? "streaming" : "turns";
|
|
502
449
|
if (panel === "search") return searchMenuValue(this.search);
|
|
450
|
+
if (panel === "permission") return this.permission?.current || "";
|
|
503
451
|
return "";
|
|
504
452
|
},
|
|
505
|
-
beforeLeave() { return this.$refs.
|
|
453
|
+
beforeLeave() { return this.$refs.voicePage?.beforeLeave() ?? Promise.resolve(true); },
|
|
506
454
|
reload() {
|
|
507
|
-
void this.$refs.
|
|
455
|
+
void this.$refs.voicePage?.reload()?.catch(() => {});
|
|
508
456
|
return this.load(true);
|
|
509
457
|
},
|
|
510
458
|
async load(force) {
|
|
511
459
|
const remembered = rememberedSettings();
|
|
512
460
|
if (!force) {
|
|
513
461
|
this.models = remembered.models ?? this.models;
|
|
514
|
-
this.voice = remembered.voice ?? this.voice;
|
|
515
462
|
this.search = remembered.search ?? this.search;
|
|
516
463
|
this.conversation = remembered.conversation ?? this.conversation;
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
464
|
+
this.permission = remembered.permission ?? this.permission;
|
|
465
|
+
if (this.models && this.search && this.conversation && this.permission) return;
|
|
521
466
|
}
|
|
522
467
|
this.panel = "";
|
|
523
468
|
this.loading = true;
|
|
524
469
|
this.modelError = "";
|
|
525
|
-
this.voiceError = "";
|
|
526
470
|
this.searchError = "";
|
|
527
471
|
this.conversationError = "";
|
|
528
|
-
|
|
472
|
+
this.permissionError = "";
|
|
473
|
+
const [models, search, conversation, permission] = await Promise.allSettled([
|
|
529
474
|
this.settings.models({ force }),
|
|
530
|
-
this.settings.voice(force, { diagnostics: false }),
|
|
531
475
|
this.settings.search({ force }),
|
|
532
476
|
this.settings.conversation({ force }),
|
|
477
|
+
this.settings.permission({ force }),
|
|
533
478
|
]);
|
|
534
479
|
if (models.status === "fulfilled") this.models = models.value;
|
|
535
480
|
else this.modelError = this.failText(this.tModel, "settings.loadFailed", models.reason);
|
|
536
|
-
if (voice.status === "fulfilled") this.voice = voice.value;
|
|
537
|
-
else this.voiceError = this.tVoice("settings.loadFailed");
|
|
538
481
|
if (search.status === "fulfilled") this.search = search.value;
|
|
539
482
|
else this.searchError = this.failText(this.tSearch, "settings.loadFailed", search.reason);
|
|
540
483
|
if (conversation.status === "fulfilled") this.conversation = conversation.value;
|
|
541
484
|
else this.conversationError = conversation.reason instanceof Error ? conversation.reason.message : String(conversation.reason);
|
|
485
|
+
if (permission.status === "fulfilled") this.permission = permission.value;
|
|
486
|
+
else this.permissionError = permission.reason instanceof Error ? permission.reason.message : String(permission.reason);
|
|
542
487
|
this.loading = false;
|
|
543
|
-
void this.loadReading();
|
|
544
|
-
},
|
|
545
|
-
async loadReading() {
|
|
546
|
-
try {
|
|
547
|
-
this.reading = await this.settings.readingMode();
|
|
548
|
-
} catch {
|
|
549
|
-
this.reading = { streaming: false, allowed: false, gpu: null };
|
|
550
|
-
}
|
|
551
|
-
},
|
|
552
|
-
chooseReading(value) {
|
|
553
|
-
if (value === "streaming" && !this.reading?.allowed) {
|
|
554
|
-
this.voiceError = this.tVoice("error.voice_streaming_time_slice");
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
void this.patchVoice("streaming", value === "streaming");
|
|
558
488
|
},
|
|
559
489
|
async chooseModel(model) {
|
|
560
490
|
const selection = { provider: model.provider, model: model.id };
|
|
@@ -570,18 +500,18 @@ export default {
|
|
|
570
500
|
this.pending = "";
|
|
571
501
|
}
|
|
572
502
|
},
|
|
573
|
-
async
|
|
574
|
-
if (!this.
|
|
575
|
-
this.
|
|
576
|
-
this.
|
|
503
|
+
async savePermission(preset) {
|
|
504
|
+
if (!this.permission?.writable || this.busy) return;
|
|
505
|
+
if (preset === this.permission.current) return;
|
|
506
|
+
this.pending = "permission";
|
|
507
|
+
this.permissionError = "";
|
|
577
508
|
try {
|
|
578
|
-
this.
|
|
509
|
+
this.permission = await this.settings.setDefaultPermission(preset);
|
|
579
510
|
} catch (err) {
|
|
580
|
-
|
|
581
|
-
const text = code ? this.tVoice(`error.${code}`) : "";
|
|
582
|
-
this.voiceError = text && text !== `error.${code}` ? text : this.tVoice("settings.saveFailed");
|
|
511
|
+
this.permissionError = err instanceof Error ? err.message : String(err);
|
|
583
512
|
} finally {
|
|
584
513
|
this.pending = "";
|
|
514
|
+
this.accessAcknowledged = false;
|
|
585
515
|
}
|
|
586
516
|
},
|
|
587
517
|
async chooseSearch(rawId) {
|
|
@@ -643,15 +573,14 @@ export default {
|
|
|
643
573
|
}
|
|
644
574
|
|
|
645
575
|
.lares-agent__loading {
|
|
646
|
-
position:
|
|
576
|
+
position: fixed;
|
|
647
577
|
inset: 0;
|
|
648
|
-
z-index:
|
|
578
|
+
z-index: 20;
|
|
649
579
|
display: flex;
|
|
650
580
|
flex-direction: column;
|
|
651
581
|
align-items: center;
|
|
652
582
|
justify-content: center;
|
|
653
583
|
gap: 12px;
|
|
654
|
-
min-height: 280px;
|
|
655
584
|
background: color-mix(in srgb, var(--q-background-1) 88%, transparent);
|
|
656
585
|
color: var(--q-ink-2);
|
|
657
586
|
}
|
|
@@ -662,10 +591,6 @@ export default {
|
|
|
662
591
|
line-height: 22px;
|
|
663
592
|
}
|
|
664
593
|
|
|
665
|
-
.lares-agent[data-device="desktop"] .lares-agent__loading {
|
|
666
|
-
min-height: 96px;
|
|
667
|
-
}
|
|
668
|
-
|
|
669
594
|
.lares-agent__spinner {
|
|
670
595
|
width: 22px;
|
|
671
596
|
height: 22px;
|
|
@@ -749,4 +674,64 @@ export default {
|
|
|
749
674
|
font-weight: 500;
|
|
750
675
|
line-height: 18px;
|
|
751
676
|
}
|
|
677
|
+
|
|
678
|
+
.lares-agent__access {
|
|
679
|
+
display: flex;
|
|
680
|
+
flex-direction: column;
|
|
681
|
+
gap: 12px;
|
|
682
|
+
margin: 8px 16px 16px;
|
|
683
|
+
padding: 12px;
|
|
684
|
+
border-radius: 12px;
|
|
685
|
+
background: var(--q-background-3);
|
|
686
|
+
color: var(--q-ink-2);
|
|
687
|
+
font-size: 14px;
|
|
688
|
+
line-height: 20px;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
.lares-agent[data-device="desktop"] .lares-agent__access {
|
|
692
|
+
margin: 0;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
.lares-agent__access p {
|
|
696
|
+
margin: 0;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
.lares-agent__access label {
|
|
700
|
+
display: flex;
|
|
701
|
+
align-items: flex-start;
|
|
702
|
+
gap: 8px;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
.lares-agent__access input {
|
|
706
|
+
width: 18px;
|
|
707
|
+
height: 18px;
|
|
708
|
+
flex: none;
|
|
709
|
+
margin: 1px 0 0;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
.lares-agent__access-actions {
|
|
713
|
+
display: flex;
|
|
714
|
+
justify-content: flex-end;
|
|
715
|
+
gap: 8px;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.lares-agent__access-actions button {
|
|
719
|
+
border: 0;
|
|
720
|
+
border-radius: 8px;
|
|
721
|
+
padding: 8px 12px;
|
|
722
|
+
background: transparent;
|
|
723
|
+
color: var(--q-ink-2);
|
|
724
|
+
font: inherit;
|
|
725
|
+
font-size: 14px;
|
|
726
|
+
font-weight: 600;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.lares-agent__access-actions button:last-child {
|
|
730
|
+
background: var(--q-blue-alpha);
|
|
731
|
+
color: var(--q-blue-default);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
.lares-agent__access-actions button:disabled {
|
|
735
|
+
opacity: 0.45;
|
|
736
|
+
}
|
|
752
737
|
</style>
|