@jskit-ai/assistant-voice 0.2.23 → 0.2.25

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/README.md CHANGED
@@ -77,6 +77,8 @@ modal's push-to-talk gesture uses `reviewBeforeSend`. `avatar` and `onVisual`/`o
77
77
  allow presentation in the surrounding app without adding another audio owner.
78
78
  The host's `avatar` slot receives state, mouthLevel, mouthPose, avatar and binding.
79
79
  `useVoiceAvatar` supplies shared animation cues; applications may supply artwork.
80
+ A `still` avatar (`VoiceAvatar`'s `still` prop, or `still: true` given to `useVoiceAvatar`), such as a
81
+ thumbnail, never blinks, gestures, cycles expressions or moves its mouth.
80
82
 
81
83
  ## Lifecycle
82
84
 
@@ -5,7 +5,6 @@ import { createRouter, createWebHistory } from "vue-router";
5
5
  import { createVuetify } from "vuetify";
6
6
  import * as components from "vuetify/components";
7
7
  import * as directives from "vuetify/directives";
8
- import { aliases, mdi } from "vuetify/iconsets/mdi-svg";
9
8
  import { bootClientModules } from "@jskit-ai/kernel/client/moduleBootstrap";
10
9
  import { defineProvider } from "@jskit-ai/kernel/shared/capabilities";
11
10
  import { createSurfaceRuntime } from "@jskit-ai/kernel/shared/surface/runtime";
@@ -14,6 +13,8 @@ import { RealtimeClientProvider } from "@jskit-ai/realtime/client";
14
13
  import { configureAssistantConversations } from "@jskit-ai/assistant-runtime/client";
15
14
  import { createHttpClient } from "@jskit-ai/http-runtime/client";
16
15
  import "vuetify/styles";
16
+ import "@jskit-ai/material-web/client/material.css";
17
+ import { createMaterialVuetifyOptions } from "@jskit-ai/material-web/client";
17
18
  import App from "./App.vue";
18
19
  import { appConfig } from "./config.js";
19
20
 
@@ -40,7 +41,7 @@ const pinia = createPinia();
40
41
  const queryClient = new QueryClient();
41
42
  const router = createRouter({ history: createWebHistory(), routes: [{ path: "/:pathMatch(.*)*", component: App }] });
42
43
  app.use(pinia).use(VueQueryPlugin, { queryClient }).use(router)
43
- .use(createVuetify({ components, directives, icons: { defaultSet: "mdi", aliases, sets: { mdi } } }));
44
+ .use(createVuetify({ components, directives, ...createMaterialVuetifyOptions() }));
44
45
  const modules = await bootClientModules({
45
46
  app, pinia, queryClient, router, env: import.meta.env, surfaceMode: "home", logger: console,
46
47
  surfaceRuntime: createSurfaceRuntime({ defaultSurfaceId: "home", surfaces: appConfig.surfaceDefinitions }),
@@ -9,15 +9,15 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@fastify/websocket": "^11.2.0",
12
- "@jskit-ai/assistant-core": "0.2.21",
13
- "@jskit-ai/assistant-runtime": "0.2.23",
14
- "@jskit-ai/assistant-voice": "0.2.23",
15
- "@jskit-ai/connectors-catalog": "0.2.10",
16
- "@jskit-ai/http-runtime": "0.2.9",
17
- "@jskit-ai/kernel": "0.2.9",
18
- "@jskit-ai/realtime": "0.2.13",
19
- "@jskit-ai/shell-web": "0.2.10",
20
- "@mdi/js": "^7.4.47",
12
+ "@jskit-ai/assistant-core": "0.2.23",
13
+ "@jskit-ai/assistant-runtime": "0.2.25",
14
+ "@jskit-ai/assistant-voice": "0.2.25",
15
+ "@jskit-ai/connectors-catalog": "0.2.11",
16
+ "@jskit-ai/http-runtime": "0.2.10",
17
+ "@jskit-ai/kernel": "0.2.10",
18
+ "@jskit-ai/material-web": "0.1.1",
19
+ "@jskit-ai/realtime": "0.2.15",
20
+ "@jskit-ai/shell-web": "0.2.12",
21
21
  "@tanstack/vue-query": "^5.90.5",
22
22
  "fastify": "^5.12.7",
23
23
  "pinia": "^4.0.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/assistant-voice",
3
- "version": "0.2.23",
3
+ "version": "0.2.25",
4
4
  "type": "module",
5
5
  "description": "Duplex voice conversations with application-owned targets, authorization and speech services.",
6
6
  "scripts": {
@@ -20,8 +20,7 @@
20
20
  "examples"
21
21
  ],
22
22
  "dependencies": {
23
- "@jskit-ai/assistant-core": "0.2.21",
24
- "@mdi/js": "^7.4.47",
23
+ "@jskit-ai/assistant-core": "0.2.23",
25
24
  "ws": "^8.20.1"
26
25
  },
27
26
  "jskit": {
@@ -63,9 +62,9 @@
63
62
  }
64
63
  },
65
64
  "peerDependencies": {
66
- "@jskit-ai/kernel": "0.2.9",
65
+ "@jskit-ai/kernel": "0.2.10",
67
66
  "vue": "^3.5.13",
68
- "vuetify": "^4.0.0"
67
+ "vuetify": "^4.3.0"
69
68
  },
70
69
  "devDependencies": {
71
70
  "@fastify/websocket": "^11.3.2"
@@ -1,5 +1,4 @@
1
1
  <script setup>
2
- import { mdiClose, mdiMessageTextOutline, mdiMicrophone, mdiMinus } from "@mdi/js";
3
2
  import { useDisplay } from "vuetify";
4
3
  import { VCard, VDialog } from "vuetify/components";
5
4
  import { computed } from "vue";
@@ -55,17 +54,17 @@ function updateOpen(value) {
55
54
  <span :title="displayTitle">{{ displayTitle }}</span>
56
55
  <slot name="header-actions" />
57
56
  <v-btn
58
- v-if="minimizable" :icon="mdiMinus" variant="text" :aria-label="t('jskit.assistant.voice.dialog.minimize')"
57
+ v-if="minimizable" icon="$minus" variant="text" :aria-label="t('jskit.assistant.voice.dialog.minimize')"
59
58
  :title="t('jskit.assistant.voice.dialog.minimize')" @click="$emit('minimize', $event)"
60
59
  />
61
- <v-btn :icon="mdiClose" variant="text" :aria-label="displayCloseLabel" :title="displayCloseLabel" @click="$emit('update:modelValue', false)" />
60
+ <v-btn icon="$close" variant="text" :aria-label="displayCloseLabel" :title="displayCloseLabel" @click="$emit('update:modelValue', false)" />
62
61
  </v-card-title>
63
62
  <v-tabs
64
63
  v-if="showModes" :model-value="mode" class="conversation-dialog__tabs" grow :aria-label="t('jskit.assistant.voice.dialog.modes')"
65
64
  @update:model-value="$emit('update:mode', $event)"
66
65
  >
67
- <v-tab value="talk" :prepend-icon="mdiMicrophone">{{ t("jskit.assistant.voice.dialog.talk") }}</v-tab>
68
- <v-tab value="text" :prepend-icon="mdiMessageTextOutline">{{ t("jskit.assistant.voice.dialog.text") }}</v-tab>
66
+ <v-tab value="talk" prepend-icon="$mic">{{ t("jskit.assistant.voice.dialog.talk") }}</v-tab>
67
+ <v-tab value="text" prepend-icon="$chat">{{ t("jskit.assistant.voice.dialog.text") }}</v-tab>
69
68
  </v-tabs>
70
69
  <div class="conversation-dialog__body"><slot /></div>
71
70
  </component>
@@ -2,7 +2,7 @@
2
2
  import { computed } from "vue";
3
3
  import { useVoiceAvatar } from "./voiceAvatar.js";
4
4
  import { useJskitText } from "./i18n.js";
5
- const props = defineProps({ state: { type: String, default: "idle" }, mouthPose: { type: String, default: "closed" }, mouthLevel: { type: Number, default: 0 } });
5
+ const props = defineProps({ state: { type: String, default: "idle" }, mouthPose: { type: String, default: "closed" }, mouthLevel: { type: Number, default: 0 }, still: { type: Boolean, default: false } });
6
6
  const { blinking, visibleMouthPose, reducedMotion } = useVoiceAvatar(props);
7
7
  const { t } = useJskitText();
8
8
  const mouthHeight = computed(() => reducedMotion.value || visibleMouthPose.value === "closed" ? 3 : Math.max(4, Math.min(18, props.mouthLevel * 28)));
@@ -3,7 +3,6 @@ import { computed, ref, watch } from "vue";
3
3
  import { AssistantConversationElement } from "@jskit-ai/assistant-core/client/conversation";
4
4
  import VoiceAvatar from "./VoiceAvatar.vue";
5
5
  import VoiceConversationControls from "./VoiceConversationControls.vue";
6
- import { mdiMicrophone, mdiVolumeHigh } from "@mdi/js";
7
6
  import { useJskitText } from "./i18n.js";
8
7
 
9
8
  const props = defineProps({
@@ -59,13 +58,13 @@ watch(voiceAnswer, () => followCaption(voiceAnswerTarget, followAnswer), { flush
59
58
  v-if="scope.size === 'hidden' && voice.listening.value && !microphoneMuted" role="img"
60
59
  :aria-label="t('jskit.assistant.voice.conversation.listening')" :title="t('jskit.assistant.voice.conversation.listening')"
61
60
  >
62
- <v-icon :icon="mdiMicrophone" size="20" aria-hidden="true" />
61
+ <v-icon icon="$mic" size="20" aria-hidden="true" />
63
62
  </span>
64
63
  <span
65
64
  v-if="scope.size === 'hidden' && voice.speaking.value" role="img"
66
65
  :aria-label="t('jskit.assistant.voice.conversation.speaking')" :title="t('jskit.assistant.voice.conversation.speaking')"
67
66
  >
68
- <v-icon :icon="mdiVolumeHigh" size="20" aria-hidden="true" />
67
+ <v-icon icon="$volumeHigh" size="20" aria-hidden="true" />
69
68
  </span>
70
69
  </slot>
71
70
  </template>
@@ -1,6 +1,5 @@
1
1
  <script setup>
2
2
  import { computed, useId } from "vue";
3
- import { mdiMicrophone, mdiMicrophoneOff, mdiStop, mdiVolumeHigh, mdiVolumeOff } from "@mdi/js";
4
3
  import { useVoiceLauncher } from "./voiceLauncher.js";
5
4
  import { useJskitText, voiceErrorText } from "./i18n.js";
6
5
 
@@ -84,7 +83,7 @@ const gesture = useVoiceLauncher({
84
83
  <fieldset class="assistant-voice-controls__tools" :class="{ 'assistant-voice-controls__tools--compact': compact, 'assistant-voice-controls__tools--icons': iconOnly }" :disabled="disabled" :aria-label="t('jskit.assistant.voice.controls.label', { target: targetLabel })">
85
84
  <div v-if="compact || iconOnly || speechActive" class="assistant-voice-controls__stop">
86
85
  <v-btn
87
- v-if="speechActive" :icon="mdiStop" variant="text" min-width="48" min-height="48"
86
+ v-if="speechActive" icon="$stop" variant="text" min-width="48" min-height="48"
88
87
  :aria-label="t('jskit.assistant.voice.controls.stopTargetSpeaking', { target: targetLabel })"
89
88
  :title="t('jskit.assistant.voice.controls.stopSpeaking')" @click="stopSpeech"
90
89
  />
@@ -93,8 +92,8 @@ const gesture = useVoiceLauncher({
93
92
  <div class="assistant-voice__talk-action">
94
93
  <v-btn
95
94
  class="assistant-voice__talk" color="primary" :variant="iconOnly ? 'text' : handsFreeListening ? 'tonal' : 'flat'" :min-height="iconOnly ? 44 : compact ? 48 : 64" rounded="xl"
96
- :icon="iconOnly ? (voice.listening.value && !microphoneMuted ? mdiMicrophone : mdiMicrophoneOff) : undefined"
97
- :prepend-icon="iconOnly ? undefined : (voice.listening.value && !microphoneMuted ? mdiMicrophone : mdiMicrophoneOff)"
95
+ :icon="iconOnly ? (voice.listening.value && !microphoneMuted ? '$mic' : '$micOff') : undefined"
96
+ :prepend-icon="iconOnly ? undefined : (voice.listening.value && !microphoneMuted ? '$mic' : '$micOff')"
98
97
  :aria-label="iconOnly ? talkLabel : undefined" :title="t('jskit.assistant.voice.controls.talkHint')"
99
98
  :aria-pressed="handsFreeListening || pushHolding" :aria-describedby="gestureHint"
100
99
  :disabled="!canTalk" :slim="compact || iconOnly"
@@ -103,11 +102,11 @@ const gesture = useVoiceLauncher({
103
102
  @keydown.space.prevent="gesture.keyDown" @keyup.space.prevent="gesture.keyUp"
104
103
  @keydown.enter.prevent="gesture.keyDown" @keyup.enter.prevent="gesture.keyUp" @blur="gesture.cancel" @contextmenu.prevent @click="gesture.click"
105
104
  >
106
- <span v-if="iconOnly" class="assistant-voice-controls__icon-disc"><v-icon size="20" :icon="voice.listening.value && !microphoneMuted ? mdiMicrophone : mdiMicrophoneOff" /></span>
105
+ <span v-if="iconOnly" class="assistant-voice-controls__icon-disc"><v-icon size="20" :icon="voice.listening.value && !microphoneMuted ? '$mic' : '$micOff'" /></span>
107
106
  <template v-else>{{ talkLabel }}</template>
108
107
  </v-btn>
109
108
  <v-btn
110
- :icon="readAloud ? mdiVolumeHigh : mdiVolumeOff" :aria-pressed="readAloud" :variant="iconOnly ? 'text' : 'tonal'" :color="iconOnly ? 'primary' : undefined" :min-height="iconOnly ? 44 : compact ? 48 : 64" :width="iconOnly ? 40 : undefined" :min-width="iconOnly ? 40 : compact ? 48 : 64" rounded="xl"
109
+ :icon="readAloud ? '$volumeHigh' : '$volumeOff'" :aria-pressed="readAloud" :variant="iconOnly ? 'text' : 'tonal'" :color="iconOnly ? 'primary' : undefined" :min-height="iconOnly ? 44 : compact ? 48 : 64" :width="iconOnly ? 40 : undefined" :min-width="iconOnly ? 40 : compact ? 48 : 64" rounded="xl"
111
110
  :aria-label="readAloud
112
111
  ? t('jskit.assistant.voice.controls.readAloudOff', { target: targetLabel })
113
112
  : t('jskit.assistant.voice.controls.readAloudOn', { target: targetLabel })"
@@ -115,11 +114,11 @@ const gesture = useVoiceLauncher({
115
114
  :disabled="speakerDisabled || session.readAloudChangePending.value" @click="toggleReadAloud"
116
115
  >
117
116
  <template v-if="iconOnly" #default>
118
- <span class="assistant-voice-controls__icon-disc"><v-icon size="20" :icon="readAloud ? mdiVolumeHigh : mdiVolumeOff" /></span>
117
+ <span class="assistant-voice-controls__icon-disc"><v-icon size="20" :icon="readAloud ? '$volumeHigh' : '$volumeOff'" /></span>
119
118
  </template>
120
119
  </v-btn>
121
120
  <slot name="settings-control" />
122
- <p :id="gestureHint" class="text-body-small text-medium-emphasis">
121
+ <p :id="gestureHint" class="text-body-small on-surface-variant">
123
122
  {{ handsFreeListening ? t("jskit.assistant.voice.controls.tapToPause") : t("jskit.assistant.voice.controls.tapForHandsFree") }}
124
123
  </p>
125
124
  </div>
@@ -1,5 +1,4 @@
1
1
  <script setup>
2
- import { mdiHeadset, mdiStop } from "@mdi/js";
3
2
  import ConversationDialog from "./ConversationDialog.vue";
4
3
  import VoiceConversation from "./VoiceConversation.vue";
5
4
  import VoiceConversationSettings from "./VoiceConversationSettings.vue";
@@ -71,7 +70,7 @@ async function openText() {
71
70
  </template>
72
71
  <template #work-control>
73
72
  <v-btn
74
- v-if="state.binding.cancelWork && state.binding.state.status === 'working'" :disabled="state.busy" :icon="mdiStop" variant="text"
73
+ v-if="state.binding.cancelWork && state.binding.state.status === 'working'" :disabled="state.busy" icon="$stop" variant="text"
75
74
  :aria-label="t('jskit.assistant.voice.host.stopWork')" :title="t('jskit.assistant.voice.host.stopWork')" @click="invoke(state.binding.cancelWork)"
76
75
  />
77
76
  </template>
@@ -81,7 +80,7 @@ async function openText() {
81
80
  </ConversationDialog>
82
81
  <template v-if="presentation === 'dialog' && state.session && !state.visible">
83
82
  <slot v-if="$slots.reopen" name="reopen" :controller="controller" />
84
- <v-btn v-else class="voice-host__reopen" color="primary" :prepend-icon="mdiHeadset" min-height="56" @click="controller.reveal()">
83
+ <v-btn v-else class="voice-host__reopen" color="primary" prepend-icon="$headsetMic" min-height="56" @click="controller.reveal()">
85
84
  {{ t("jskit.assistant.voice.host.reopen", { label: state.binding.label || t("jskit.assistant.voice.assistant") }) }}
86
85
  </v-btn>
87
86
  </template>
@@ -1,5 +1,4 @@
1
1
  <script setup>
2
- import { mdiCog } from "@mdi/js";
3
2
  import { useSlots } from "vue";
4
3
  import VoiceSpeakingVoiceSelect from "./VoiceSpeakingVoiceSelect.vue";
5
4
  import { useJskitText } from "./i18n.js";
@@ -23,11 +22,11 @@ async function openSettings(open) {
23
22
  <v-menu :close-on-content-click="false" location="bottom end" @update:model-value="openSettings">
24
23
  <template #activator="{ props: settingsButton }">
25
24
  <v-btn
26
- v-bind="settingsButton" :icon="mdiCog" variant="text" :color="compact ? 'primary' : undefined"
25
+ v-bind="settingsButton" icon="$settings" variant="text" :color="compact ? 'primary' : undefined"
27
26
  :width="compact ? 40 : undefined" :min-width="compact ? 40 : 48" :min-height="compact ? 44 : 48" :disabled="!voice && !$slots.default"
28
27
  :aria-label="t('jskit.assistant.voice.settings.title')" :title="t('jskit.assistant.voice.settings.title')"
29
28
  >
30
- <template v-if="compact" #default><span class="voice-settings__disc"><v-icon size="20" :icon="mdiCog" /></span></template>
29
+ <template v-if="compact" #default><span class="voice-settings__disc"><v-icon size="20" icon="$settings" /></span></template>
31
30
  </v-btn>
32
31
  </template>
33
32
  <v-card class="voice-settings__menu" role="region" :aria-label="t('jskit.assistant.voice.settings.title')">
@@ -73,13 +73,16 @@ function notFollowing() {}
73
73
 
74
74
  /**
75
75
  * The avatar's blinking, idle gestures and expressions for a voice state, and the mouth pose to draw.
76
- * @param {{ state?: string, mouthPose?: string, mouthLevel: number }} props
76
+ * A `still` avatar, such as a thumbnail, holds its state's expression: it never blinks, gestures, cycles
77
+ * expressions or moves its mouth, and `reducedMotion` is true for it as when the person prefers reduced motion.
78
+ * @param {{ state?: string, mouthPose?: string, mouthLevel: number, still?: boolean }} props
77
79
  */
78
80
  export function useVoiceAvatar(props) {
79
81
  const blinking = ref(false);
80
82
  const activeExpression = ref("");
81
83
  const idleGesture = ref("");
82
- const reducedMotion = ref(false);
84
+ const prefersReducedMotion = ref(false);
85
+ const reducedMotion = computed(() => props.still === true || prefersReducedMotion.value);
83
86
  let blinkTimer = 0;
84
87
  let activeExpressionTimer = 0;
85
88
  const activeExpressionIndexes = {
@@ -110,7 +113,7 @@ export function useVoiceAvatar(props) {
110
113
  return "closed";
111
114
  }
112
115
  const pose = String(props.mouthPose || "closed");
113
- if (props.mouthLevel < 0.045 || !["open", "round", "small", "wide"].includes(pose)) {
116
+ if (props.still === true || props.mouthLevel < 0.045 || !["open", "round", "small", "wide"].includes(pose)) {
114
117
  return "closed";
115
118
  }
116
119
  return pose;
@@ -193,8 +196,7 @@ export function useVoiceAvatar(props) {
193
196
  }
194
197
  }
195
198
 
196
- function updateReducedMotion(event) {
197
- reducedMotion.value = Boolean(event.matches);
199
+ function restartMotion() {
198
200
  clearBlinkTimers();
199
201
  clearActiveExpression();
200
202
  clearIdleGesture();
@@ -208,6 +210,13 @@ export function useVoiceAvatar(props) {
208
210
  }
209
211
  }
210
212
 
213
+ function updateReducedMotion(event) {
214
+ prefersReducedMotion.value = Boolean(event.matches);
215
+ restartMotion();
216
+ }
217
+
218
+ watch(() => props.still === true, restartMotion);
219
+
211
220
  watch(expression, () => {
212
221
  clearActiveExpression();
213
222
  clearIdleGesture();
@@ -220,7 +229,7 @@ export function useVoiceAvatar(props) {
220
229
 
221
230
  onMounted(() => {
222
231
  const reducedMotionQuery = followMediaQuery("(prefers-reduced-motion: reduce)", updateReducedMotion);
223
- reducedMotion.value = reducedMotionQuery.matches;
232
+ prefersReducedMotion.value = reducedMotionQuery.matches;
224
233
  stopFollowingReducedMotion = reducedMotionQuery.stop;
225
234
  if (!reducedMotion.value) {
226
235
  scheduleBlink(1_800 + (Math.random() * 1_800));