@vellumai/assistant 0.11.6-dev.202608261801.b683b42 → 0.11.6-dev.202608261918.60eeea2
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/ARCHITECTURE.md +26 -14
- package/Dockerfile +1 -0
- package/docs/stt-provider-onboarding.md +8 -4
- package/knip.json +1 -0
- package/node_modules/@vellumai/avatar-manifest/package.json +18 -0
- package/node_modules/@vellumai/avatar-manifest/src/__tests__/manifest.test.ts +173 -0
- package/node_modules/@vellumai/avatar-manifest/src/__tests__/read.test.ts +114 -0
- package/node_modules/@vellumai/avatar-manifest/src/index.ts +29 -0
- package/node_modules/@vellumai/avatar-manifest/src/layout.ts +18 -0
- package/node_modules/@vellumai/avatar-manifest/src/manifest.ts +156 -0
- package/node_modules/@vellumai/avatar-manifest/src/read.ts +109 -0
- package/node_modules/@vellumai/avatar-manifest/tsconfig.json +20 -0
- package/package.json +3 -1
- package/src/__tests__/avatar-identity-sync.test.ts +5 -1
- package/src/__tests__/llm-resolver.test.ts +54 -0
- package/src/__tests__/managed-speech-defaults.test.ts +64 -0
- package/src/__tests__/media-stream-stt-session.test.ts +2 -0
- package/src/__tests__/schedule-retry.test.ts +177 -4
- package/src/__tests__/scheduler-reuse-conversation.test.ts +6 -6
- package/src/__tests__/secret-routes-platform-proxy.test.ts +55 -0
- package/src/avatar/__tests__/ensure-raster.test.ts +291 -0
- package/src/avatar/avatar-manifest.ts +48 -100
- package/src/avatar/avatar-store.ts +7 -7
- package/src/avatar/ensure-raster.ts +146 -0
- package/src/avatar/resvg-lazy.test.ts +0 -1
- package/src/avatar/traits-png-sync.ts +9 -10
- package/src/background-wake/wake-intent-hooks.test.ts +0 -1
- package/src/calls/__tests__/telephony-synthesis-language.test.ts +81 -0
- package/src/calls/__tests__/voice-session-bridge.test.ts +20 -0
- package/src/calls/media-stream-stt-session.ts +2 -1
- package/src/calls/telephony-synthesis-language.ts +13 -5
- package/src/calls/voice-session-bridge.ts +6 -4
- package/src/config/bundled-skills/media-processing/services/audio-transcribe.ts +3 -1
- package/src/config/bundled-skills/media-processing/services/preprocess.ts +1 -1
- package/src/config/bundled-skills/phone-calls/SKILL.md +1 -1
- package/src/config/bundled-skills/phone-calls/references/CONFIG.md +16 -15
- package/src/config/bundled-skills/phone-calls/references/TROUBLESHOOTING.md +2 -1
- package/src/config/bundled-skills/transcribe/tools/transcribe-media.ts +1 -1
- package/src/config/llm-resolver.ts +24 -0
- package/src/config/managed-speech-defaults.ts +75 -18
- package/src/config/schemas/__tests__/stt.test.ts +94 -0
- package/src/config/schemas/stt.ts +99 -0
- package/src/daemon/config-watcher.ts +2 -1
- package/src/daemon/lifecycle.ts +3 -1
- package/src/heartbeat/__tests__/heartbeat-service.test.ts +0 -1
- package/src/live-voice/__tests__/live-voice-flux-turn-end.test.ts +42 -0
- package/src/live-voice/live-voice-credential-preflight.ts +5 -1
- package/src/live-voice/live-voice-session.ts +13 -3
- package/src/notifications/__tests__/activity-failed-dedupe.test.ts +161 -0
- package/src/notifications/activity-failed-dedupe.ts +95 -0
- package/src/platform/platform-patch-queue.test.ts +368 -0
- package/src/platform/platform-patch-queue.ts +190 -0
- package/src/platform/sync-avatar.test.ts +527 -0
- package/src/platform/sync-avatar.ts +209 -0
- package/src/platform/sync-identity.test.ts +75 -0
- package/src/platform/sync-identity.ts +17 -110
- package/src/plugin-api/transcription-session.ts +1 -1
- package/src/providers/speech-to-text/__tests__/resolve.test.ts +197 -0
- package/src/providers/speech-to-text/provider-catalog.ts +15 -1
- package/src/providers/speech-to-text/resolve.ts +55 -12
- package/src/runtime/__tests__/background-job-runner.test.ts +61 -3
- package/src/runtime/background-job-runner.ts +37 -9
- package/src/runtime/http-server.ts +12 -4
- package/src/runtime/routes/__tests__/avatar-state-routes.test.ts +18 -18
- package/src/runtime/routes/avatar-routes.ts +17 -30
- package/src/runtime/routes/inbound-stages/transcribe-audio.ts +1 -1
- package/src/runtime/routes/secret-routes.ts +7 -0
- package/src/runtime/routes/stt-routes.ts +7 -4
- package/src/runtime/routes/watch-routes.ts +9 -5
- package/src/runtime/sync/resource-sync-events.ts +2 -0
- package/src/schedule/retry-policy.ts +8 -8
- package/src/schedule/schedule-recovery.ts +0 -1
- package/src/schedule/scheduler.ts +83 -15
- package/src/stt/__tests__/roles.test.ts +152 -0
- package/src/stt/roles.ts +180 -0
- package/src/stt/stt-stream-session.ts +3 -2
- package/src/util/platform.ts +6 -7
package/ARCHITECTURE.md
CHANGED
|
@@ -577,17 +577,29 @@ All guardian decisions for voice access requests flow through:
|
|
|
577
577
|
|
|
578
578
|
Audio-to-text conversion occurs in six distinct runtime boundaries, each with its own provider model and adapter layer. The `services.stt` config block is the single source of truth for STT provider selection across assistant, client, live voice, and telephony boundaries.
|
|
579
579
|
|
|
580
|
+
**Per-consumer roles:** `services.stt.provider` (plus that provider's `services.stt.providers.<id>.model` family) is the global selection. `services.stt.roles.<role>` overrides it for one consumer, naming a `{provider, model?}` pair; an unset role falls back to the global. Roles exist because capability is per boundary while the global is not: the Flux family streams but has no batch endpoint, so a global set to it breaks file transcription and telephony at the same moment it improves live voice. A role names the consumer rather than the boundary, because one telephony call resolves a streaming transcriber and a batch fallback within the same session.
|
|
581
|
+
|
|
582
|
+
| Role | Consumers | Boundaries required |
|
|
583
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
|
|
584
|
+
| `liveVoice` | `src/live-voice/live-voice-session.ts`, `src/live-voice/live-voice-credential-preflight.ts` | streaming |
|
|
585
|
+
| `telephony` | `src/calls/media-stream-stt-session.ts` (streaming dial and batch fallback) | streaming + batch + telephony |
|
|
586
|
+
| `dictation` | `/v1/stt/stream` (`src/runtime/http-server.ts`), `POST /v1/stt/transcribe`, `src/plugin-api/transcription-session.ts` | streaming + batch |
|
|
587
|
+
| `watch` | `/v1/watch/stream` (`src/runtime/routes/watch-routes.ts`) | streaming |
|
|
588
|
+
| `batch` | inbound audio (`routes/inbound-stages/transcribe-audio.ts`), `POST /v1/stt/transcribe-file`, media-processing/transcribe skills | batch |
|
|
589
|
+
|
|
590
|
+
Roles are defined in `src/stt/roles.ts`: `STT_ROLE_REQUIREMENTS` declares each role's boundaries, `sttSelectionForRole()`/`sttCatalogKeyForRole()` perform the lookup, and `sttRoleCapabilityGap()` states why a pair cannot serve a role. Selection is resolved inside `resolveBatchTranscriber()`/`resolveStreamingTranscriber()`, so a caller passes `role` and nothing else. Capability is checked against the **resolved catalog row** (`sttCatalogKeyFor(provider, model)`), not the bare provider id, since `deepgram` batches and `deepgram` running `flux` does not. Validation is fail-closed: `services.stt.roles` rejects an incapable pair at config parse time rather than substituting a working provider at dial time. Telephony and live-voice preflight, the dictation session label, and the telephony language pin all read their own role, so what preflight judges is what the session dials.
|
|
591
|
+
|
|
580
592
|
**Provider catalog model:** The daemon's canonical provider catalog (`src/providers/speech-to-text/provider-catalog.ts`) is the single source of truth for all STT provider metadata — credential mappings, supported boundaries, telephony mode, conversation streaming mode, and client-facing display metadata (names, hints, setup mode, credentials guide). Native clients fetch provider metadata at launch via `GET /v1/stt/providers`. To add a new provider, follow the checklist in `docs/stt-provider-onboarding.md`.
|
|
581
593
|
|
|
582
594
|
**Boundary overview:**
|
|
583
595
|
|
|
584
|
-
| Boundary | Runtime | Provider (current)
|
|
585
|
-
| ---------------------------- | --------------------------------------------------- |
|
|
586
|
-
| **Telephony (media-stream)** | Daemon process (Twilio Media Streams WebSocket) |
|
|
587
|
-
| **Daemon batch** | Daemon process (REST API to provider) |
|
|
588
|
-
| **Conversation streaming** | Daemon process (WebSocket-based) |
|
|
589
|
-
| **Live voice channel** | Assistant process (gateway-authenticated WebSocket) |
|
|
590
|
-
| **Client service-first** | Web/Electron via gateway → daemon |
|
|
596
|
+
| Boundary | Runtime | Provider (current) | Adapter module | Caller |
|
|
597
|
+
| ---------------------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
598
|
+
| **Telephony (media-stream)** | Daemon process (Twilio Media Streams WebSocket) | `telephony` role, else `services.stt.provider` | `src/calls/media-stream-stt-session.ts`, `src/providers/speech-to-text/resolve.ts`, streaming provider adapters | `src/calls/media-stream-server.ts` |
|
|
599
|
+
| **Daemon batch** | Daemon process (REST API to provider) | `batch` role, else `services.stt.provider` | `src/stt/daemon-batch-transcriber.ts` | `src/runtime/routes/inbound-stages/transcribe-audio.ts` |
|
|
600
|
+
| **Conversation streaming** | Daemon process (WebSocket-based) | `dictation` role, else `services.stt.provider` | `src/stt/stt-stream-session.ts`, `src/providers/speech-to-text/deepgram-realtime.ts`, `src/providers/speech-to-text/google-gemini-live-stream.ts`, `src/providers/speech-to-text/openai-whisper-stream.ts`, `src/providers/speech-to-text/xai-realtime.ts` | Web/Electron dictation client via gateway WS proxy |
|
|
601
|
+
| **Live voice channel** | Assistant process (gateway-authenticated WebSocket) | `liveVoice` role, else `services.stt.provider` | `src/runtime/http-server.ts`, `src/live-voice/live-voice-session-manager.ts`, `src/live-voice/live-voice-session.ts`, `src/providers/speech-to-text/resolve.ts`, streaming provider adapters | Web/Electron live voice client via `/v1/live-voice` |
|
|
602
|
+
| **Client service-first** | Web/Electron via gateway → daemon | `dictation` (transcribe) / `batch` (transcribe-file) role, else `services.stt.provider` | `src/runtime/routes/stt-routes.ts` | Web/Electron dictation and voice clients |
|
|
591
603
|
|
|
592
604
|
**Telephony boundary (media-stream):**
|
|
593
605
|
|
|
@@ -595,8 +607,8 @@ Every phone call connects over Twilio Media Streams: the voice webhook emits `<C
|
|
|
595
607
|
|
|
596
608
|
Transcription mode is selected once per session in `media-stream-stt-session.ts`:
|
|
597
609
|
|
|
598
|
-
- **Streaming** (default)
|
|
599
|
-
- **Batch fallback
|
|
610
|
+
- **Streaming** (default): when `calls.voice.telephonyStreaming` is enabled and the `telephony` role resolves a streaming transcriber (`resolveStreamingTranscriber({ role: "telephony" })`), inbound audio is decoded (mu-law → PCM16, resampled 8 kHz → 16 kHz) and fed to the provider's realtime adapter. Replies trigger only on utterance-boundary finals (for Deepgram, `speech_final`/`UtteranceEnd`, never mid-sentence `is_final` segments), and barge-in fires from local energy VAD, never from transcriber partials.
|
|
611
|
+
- **Batch fallback**: otherwise the session segments turns with the energy-based `MediaTurnDetector` and transcribes each completed turn via the same role's batch API. Both halves of a call read the `telephony` role, which is why a role names its consumer rather than a boundary.
|
|
600
612
|
|
|
601
613
|
A credential preflight (`resolveTelephonyCredentialReadiness()` in `src/calls/telephony-credential-preflight.ts`) gates every call: it requires a credentialed, telephony-capable STT provider **and** a media-stream-playable TTS provider (the configured one or a credentialed playable fallback). Inbound calls that fail the preflight receive `<Say>` setup-required copy plus `<Hangup/>` instead of a doomed stream; outbound placement fails before dialing via `preflightVoiceIngress()` with the same user-facing message.
|
|
602
614
|
|
|
@@ -632,7 +644,7 @@ To add a new daemon batch STT provider, follow the full checklist in `docs/stt-p
|
|
|
632
644
|
|
|
633
645
|
**Conversation streaming boundary:**
|
|
634
646
|
|
|
635
|
-
Real-time conversation chat message capture on macOS uses a WebSocket-based streaming STT path. When the
|
|
647
|
+
Real-time conversation chat message capture on macOS uses a WebSocket-based streaming STT path. When the provider the `dictation` role resolves to supports conversation streaming (determined by the `conversationStreamingMode` field in the provider catalog), native clients open a WebSocket session through the gateway to the daemon's `/v1/stt/stream` endpoint. The daemon resolves a `StreamingTranscriber` for that provider and streams partial/final transcript events back to the client in real time.
|
|
636
648
|
|
|
637
649
|
Each provider that advertises a conversation streaming mode in the catalog ships an adapter implementing the `StreamingTranscriber` interface from `src/stt/types.ts`. The catalog (`src/providers/speech-to-text/provider-catalog.ts`) is the source of truth for which providers are streaming-capable; `resolveStreamingTranscriber()` maps each to its adapter:
|
|
638
650
|
|
|
@@ -653,8 +665,8 @@ Each provider that advertises a conversation streaming mode in the catalog ships
|
|
|
653
665
|
|
|
654
666
|
**Session lifecycle (daemon side):**
|
|
655
667
|
|
|
656
|
-
1. Client opens a WebSocket to `/v1/stt/stream` with required query parameter `mimeType` and optional `provider` and `sampleRate`. The `provider` parameter is optional compatibility metadata
|
|
657
|
-
2. `SttStreamSession` (in `src/stt/stt-stream-session.ts`) resolves a `StreamingTranscriber` via `resolveStreamingTranscriber()` from `src/providers/speech-to-text/resolve.ts`, using the
|
|
668
|
+
1. Client opens a WebSocket to `/v1/stt/stream` with required query parameter `mimeType` and optional `provider` and `sampleRate`. The `provider` parameter is optional compatibility metadata: the runtime is config-authoritative and always resolves the streaming transcriber from the `dictation` role (`services.stt.roles.dictation`, else `services.stt.provider`). When a requested provider disagrees with the one that role resolves to, the runtime logs a mismatch warning.
|
|
669
|
+
2. `SttStreamSession` (in `src/stt/stt-stream-session.ts`) resolves a `StreamingTranscriber` via `resolveStreamingTranscriber()` from `src/providers/speech-to-text/resolve.ts`, using the dictation role's provider (not the requested one).
|
|
658
670
|
3. The transcriber's `start()` method opens the provider session.
|
|
659
671
|
4. A `ready` event (with `provider` field) is sent to the client, signaling that audio frames are accepted.
|
|
660
672
|
5. Client sends `audio` frames (binary WebSocket frames or base64-encoded JSON) and a `stop` event when recording ends.
|
|
@@ -725,7 +737,7 @@ V1 is local/gateway-scoped. Managed/cloud WebSocket proxy support, cross-region
|
|
|
725
737
|
|
|
726
738
|
**Client service-first boundary:**
|
|
727
739
|
|
|
728
|
-
All product-facing dictation and voice-streaming paths use a service-first STT strategy. Clients record audio, encode it to WAV, and POST it through the gateway to the daemon's `POST /v1/stt/transcribe` endpoint. The daemon resolves the
|
|
740
|
+
All product-facing dictation and voice-streaming paths use a service-first STT strategy. Clients record audio, encode it to WAV, and POST it through the gateway to the daemon's `POST /v1/stt/transcribe` endpoint. The daemon resolves the `dictation` role's provider through `resolveBatchTranscriber()` and returns the transcribed text. `POST /v1/stt/transcribe-file` resolves the `batch` role the same way.
|
|
729
741
|
|
|
730
742
|
- The client receives a typed result distinguishing success from `notConfigured`, `serviceUnavailable`, and `error`, so callers can deterministically trigger their fallback path.
|
|
731
743
|
- The gateway proxies the request via assistant-scoped path rewriting: `/v1/assistants/:id/stt/transcribe` is rewritten to `/v1/stt/transcribe` on the daemon.
|
|
@@ -735,7 +747,7 @@ The web client implements these flows in `clients/web/src/domains/chat/voice/`:
|
|
|
735
747
|
|
|
736
748
|
**Cross-boundary notes:**
|
|
737
749
|
|
|
738
|
-
- The `services.stt` config block is the single source of truth for STT provider selection across the daemon batch boundary, the conversation streaming boundary, the client service-first boundary, and the telephony boundary. The batch and streaming resolvers (`resolveBatchTranscriber()`, `resolveStreamingTranscriber()`) both read
|
|
750
|
+
- The `services.stt` config block is the single source of truth for STT provider selection across the daemon batch boundary, the conversation streaming boundary, the client service-first boundary, and the telephony boundary. The batch and streaming resolvers (`resolveBatchTranscriber()`, `resolveStreamingTranscriber()`) both read it, taking the caller's `role` override (`services.stt.roles.<role>`) when one is set and the global `services.stt.provider` otherwise, and resolve credentials through the same catalog; the telephony boundary's media-stream STT session uses these same resolvers, selecting streaming vs batch transcription via `resolveStreamingTranscriber()`/`resolveBatchTranscriber()` under the `calls.voice.telephonyStreaming` flag, gated by `resolveTelephonySttCapability()`, while call placement/TwiML is gated by `resolveTelephonyCredentialReadiness()`. The daemon provider catalog (`src/providers/speech-to-text/provider-catalog.ts`) is the authoritative registry of supported providers. Native clients fetch display metadata via `GET /v1/stt/providers`.
|
|
739
751
|
- **Spoken language** is a second axis on the same block: `services.stt.language` is read by `resolveStreamingTranscriber()` and `resolveBatchTranscriber()` and forwarded to the adapters that accept one (Deepgram, xAI, and the managed relay, which passes it to Deepgram server-side). Callers may override it per streaming session, but none need to: reading it in the resolvers means every boundary inherits the setting. Gemini and Whisper take no language option and auto-detect natively, so they ignore it. Leaving it unset is **not** auto-detection on Deepgram or the managed relay: Deepgram's default is English, so non-English speech transcribes as English-sounding nonsense. `"multi"` selects nova-3 code-switching across English, Spanish, French, German, Hindi, Russian, Portuguese, Japanese, Italian, and Dutch, the mode to use when a speaker mixes languages inside one utterance. BYOK Deepgram pins `model=nova-3` for **any** explicitly configured language, not just `"multi"`: the curated roster is verified against nova-3 (the default nova-2 supports only a subset, and rejects `"multi"` outright), and `deepgramLanguageOptions()` owns the model+language pairing so every call site inherits the rule; leaving the language unset keeps the adapter default model with no language param. `"multi"` is never forwarded to xAI (it is not a BCP-47 code; xAI auto-handles multilingual audio). The managed relay pins nova-3 and allowlists `language`, so streaming needs no platform-side change; managed **batch** goes through the platform speech proxy, which accepts no language parameter, so forwarding it there is deferred pending a platform-side change.
|
|
740
752
|
- Conversation streaming does not replace the client service-first batch path. When streaming is available, it runs concurrently during recording and provides real-time partials and finals. The batch path remains the fallback for providers that do not support streaming, when streaming fails mid-session, or when streaming produces no final transcript.
|
|
741
753
|
- Credential mapping is catalog-driven: `provider-secret-catalog.ts` derives STT API-key provider names from the daemon catalog via `listCredentialProviderNames()`, deduplicating against the LLM/search provider list. Adding a provider to the catalog automatically includes its credential name in `API_KEY_PROVIDERS`.
|
package/Dockerfile
CHANGED
|
@@ -117,6 +117,7 @@ RUN ln -sf /usr/local/bin/bun /usr/local/bin/bunx
|
|
|
117
117
|
COPY --from=builder /app /app
|
|
118
118
|
|
|
119
119
|
# Copy source after installing dependencies for better layer caching.
|
|
120
|
+
COPY packages/avatar-manifest /app/packages/avatar-manifest
|
|
120
121
|
COPY packages/ces-client /app/packages/ces-client
|
|
121
122
|
COPY packages/service-contracts /app/packages/service-contracts
|
|
122
123
|
COPY packages/credential-storage /app/packages/credential-storage
|
|
@@ -29,7 +29,7 @@ This ensures the exhaustive switch in `daemon-batch-transcriber.ts` produces a c
|
|
|
29
29
|
|
|
30
30
|
- Append the new provider ID string to the `VALID_STT_PROVIDERS` tuple.
|
|
31
31
|
|
|
32
|
-
The `services.stt.providers` map uses a sparse `z.record(z.string(), ...)` schema, so adding a new provider does **not** require a workspace migration to seed a `services.stt.providers.<id>` entry. Users only need to set `services.stt.provider` to the new ID and supply credentials.
|
|
32
|
+
The `services.stt.providers` map uses a sparse `z.record(z.string(), ...)` schema, so adding a new provider does **not** require a workspace migration to seed a `services.stt.providers.<id>` entry. Users only need to set `services.stt.provider` (or a single consumer's `services.stt.roles.<role>`, see step 7) to the new ID and supply credentials.
|
|
33
33
|
|
|
34
34
|
**Language handling.** `services.stt.language` is resolved centrally in `resolveStreamingTranscriber()` (and in `resolveBatchTranscriber()` for the daemon-batch boundary), so a new adapter inherits it for free: accept a `language` option in the adapter's constructor and forward it to the provider. If the provider auto-detects natively and has no language parameter (as Gemini and Whisper do), accept nothing and let the resolver's value be ignored; document that choice in the adapter, because "no language param" means auto-detect for some providers and _English_ for others (Deepgram), and that difference is an easy source of silent wrong-language transcription. A provider that supports both batch and streaming must forward the language on **both** paths, not just the streaming one.
|
|
35
35
|
|
|
@@ -84,12 +84,16 @@ Clients derive shared-vs-exclusive key behavior from the catalog automatically:
|
|
|
84
84
|
|
|
85
85
|
## 7. Verify unified STT architecture
|
|
86
86
|
|
|
87
|
-
`services.stt
|
|
87
|
+
The `services.stt` block is the single source of truth for all STT routing, including telephony. There is no separate telephony STT config path.
|
|
88
|
+
|
|
89
|
+
Routing has two levels. `services.stt.provider`, plus that provider's `services.stt.providers.<id>.model` family, is the global selection every consumer falls back to. `services.stt.roles.<role>` overrides it for one consumer, naming a `{provider, model?}` pair. The roles are `liveVoice`, `telephony`, `dictation`, `watch` and `batch`; `src/stt/roles.ts` maps each to the boundaries its call sites resolve on, and `ARCHITECTURE.md` lists the consumers per role. A new provider needs no per-role registration: a role may name any provider in the catalog whose row covers the boundaries that role requires.
|
|
88
90
|
|
|
89
91
|
Before submitting the PR, verify that:
|
|
90
92
|
|
|
91
|
-
1. **No stale config references
|
|
93
|
+
1. **No stale config references**: grep for any references to a separate telephony transcription config. Telephony transcription runs daemon-side over the Twilio media-stream transport (`src/calls/media-stream-stt-session.ts`), which resolves through `resolveStreamingTranscriber()`/`resolveBatchTranscriber()` under the `telephony` role like every other boundary resolves under its own.
|
|
92
94
|
|
|
93
95
|
2. **Provider catalog telephony metadata** — the new provider's catalog entry (step 1) declares `telephonyMode` and `supportedBoundaries`; these are the single source of truth for the telephony capability check (`resolveTelephonySttCapability()`) and for streaming-vs-batch mode selection in the media-stream STT session. No per-provider routing maps exist.
|
|
94
96
|
|
|
95
|
-
3. **
|
|
97
|
+
3. **Role capability follows the catalog row**: `sttRoleCapabilityGap()` reads `supportedBoundaries` and `telephonyMode` from the row the pair resolves to (`sttCatalogKeyFor(provider, model)`), so a model family that drops a boundary must be its own catalog row. Get the row right and config validation rejects incapable role pairs on its own; nothing per-role needs writing.
|
|
98
|
+
|
|
99
|
+
4. **No duplicate wiring**: a provider should appear only once in `services.stt`. The telephony layer consumes the same catalog, and a role selects from it; there is no second registration step for telephony or for any role.
|
package/knip.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vellumai/avatar-manifest",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.ts"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"typecheck": "bunx tsc --noEmit",
|
|
12
|
+
"test": "bun test src/"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/bun": "1.3.11",
|
|
16
|
+
"typescript": "5.9.3"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AVATAR_FIELD_MAX_LENGTH,
|
|
5
|
+
deriveAvatarFromLegacyFiles,
|
|
6
|
+
parseAvatarManifest,
|
|
7
|
+
resolveAvatarFromFiles,
|
|
8
|
+
} from "../manifest.js";
|
|
9
|
+
|
|
10
|
+
const overlong = "x".repeat(AVATAR_FIELD_MAX_LENGTH + 1);
|
|
11
|
+
|
|
12
|
+
const traits = { bodyShape: "round", eyeStyle: "dot", color: "#abc" };
|
|
13
|
+
const image = { updatedAt: "2026-01-01T00:00:00.000Z", etag: "abc" };
|
|
14
|
+
|
|
15
|
+
describe("parseAvatarManifest", () => {
|
|
16
|
+
test("accepts a character manifest", () => {
|
|
17
|
+
expect(
|
|
18
|
+
parseAvatarManifest({ kind: "character", traits, source: "builder" }),
|
|
19
|
+
).toEqual({ kind: "character", traits, source: "builder", image: null });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("accepts an image manifest", () => {
|
|
23
|
+
expect(parseAvatarManifest({ kind: "image", image })).toEqual({
|
|
24
|
+
kind: "image",
|
|
25
|
+
traits: null,
|
|
26
|
+
source: null,
|
|
27
|
+
image,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("accepts kind none without a payload", () => {
|
|
32
|
+
expect(parseAvatarManifest({ kind: "none" })).toEqual({
|
|
33
|
+
kind: "none",
|
|
34
|
+
traits: null,
|
|
35
|
+
source: null,
|
|
36
|
+
image: null,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("rejects an overlong trait or image field", () => {
|
|
41
|
+
expect(
|
|
42
|
+
parseAvatarManifest({
|
|
43
|
+
kind: "character",
|
|
44
|
+
traits: { ...traits, color: overlong },
|
|
45
|
+
}),
|
|
46
|
+
).toBeNull();
|
|
47
|
+
expect(
|
|
48
|
+
parseAvatarManifest({
|
|
49
|
+
kind: "image",
|
|
50
|
+
image: { ...image, etag: overlong },
|
|
51
|
+
}),
|
|
52
|
+
).toBeNull();
|
|
53
|
+
expect(
|
|
54
|
+
parseAvatarManifest({
|
|
55
|
+
kind: "character",
|
|
56
|
+
traits: { ...traits, color: "x".repeat(AVATAR_FIELD_MAX_LENGTH) },
|
|
57
|
+
}),
|
|
58
|
+
).not.toBeNull();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("normalizes an unknown source to null", () => {
|
|
62
|
+
expect(
|
|
63
|
+
parseAvatarManifest({ kind: "image", image, source: "unknown" }),
|
|
64
|
+
).toEqual({ kind: "image", traits: null, source: null, image });
|
|
65
|
+
expect(parseAvatarManifest({ kind: "none", source: 7 })).toEqual({
|
|
66
|
+
kind: "none",
|
|
67
|
+
traits: null,
|
|
68
|
+
source: null,
|
|
69
|
+
image: null,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("drops payload irrelevant to the kind", () => {
|
|
74
|
+
expect(
|
|
75
|
+
parseAvatarManifest({ kind: "image", image, traits: { bodyShape: 1 } }),
|
|
76
|
+
).toEqual({ kind: "image", traits: null, source: null, image });
|
|
77
|
+
expect(
|
|
78
|
+
parseAvatarManifest({ kind: "character", traits, image: "stale" }),
|
|
79
|
+
).toEqual({ kind: "character", traits, source: null, image: null });
|
|
80
|
+
expect(parseAvatarManifest({ kind: "none", traits, image })).toEqual({
|
|
81
|
+
kind: "none",
|
|
82
|
+
traits: null,
|
|
83
|
+
source: null,
|
|
84
|
+
image: null,
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test.each([
|
|
89
|
+
["non-object", "nope"],
|
|
90
|
+
["missing kind", {}],
|
|
91
|
+
["invalid kind", { kind: "sprite", traits }],
|
|
92
|
+
["character without traits", { kind: "character" }],
|
|
93
|
+
[
|
|
94
|
+
"character with incomplete traits",
|
|
95
|
+
{ kind: "character", traits: { bodyShape: "round" } },
|
|
96
|
+
],
|
|
97
|
+
["image without meta", { kind: "image" }],
|
|
98
|
+
["image with empty etag", { kind: "image", image: { ...image, etag: "" } }],
|
|
99
|
+
])("rejects %s", (_label, value) => {
|
|
100
|
+
expect(parseAvatarManifest(value)).toBeNull();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe("deriveAvatarFromLegacyFiles", () => {
|
|
105
|
+
test("overlong traits are invalid", () => {
|
|
106
|
+
expect(
|
|
107
|
+
deriveAvatarFromLegacyFiles({
|
|
108
|
+
traitsJson: { ...traits, bodyShape: overlong },
|
|
109
|
+
hasImage: true,
|
|
110
|
+
}),
|
|
111
|
+
).toEqual({ kind: "image" });
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("valid traits win over a present image", () => {
|
|
115
|
+
expect(
|
|
116
|
+
deriveAvatarFromLegacyFiles({ traitsJson: traits, hasImage: true }),
|
|
117
|
+
).toEqual({ kind: "character", traits });
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test("invalid traits fall back to the image", () => {
|
|
121
|
+
expect(
|
|
122
|
+
deriveAvatarFromLegacyFiles({
|
|
123
|
+
traitsJson: { bodyShape: 1 },
|
|
124
|
+
hasImage: true,
|
|
125
|
+
}),
|
|
126
|
+
).toEqual({ kind: "image" });
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("nothing usable yields none", () => {
|
|
130
|
+
expect(
|
|
131
|
+
deriveAvatarFromLegacyFiles({ traitsJson: undefined, hasImage: false }),
|
|
132
|
+
).toEqual({ kind: "none" });
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe("resolveAvatarFromFiles", () => {
|
|
137
|
+
test("a valid manifest decides regardless of sidecars", () => {
|
|
138
|
+
expect(
|
|
139
|
+
resolveAvatarFromFiles({
|
|
140
|
+
manifestJson: { kind: "none" },
|
|
141
|
+
traitsJson: traits,
|
|
142
|
+
hasImage: true,
|
|
143
|
+
}),
|
|
144
|
+
).toEqual({ kind: "none" });
|
|
145
|
+
expect(
|
|
146
|
+
resolveAvatarFromFiles({
|
|
147
|
+
manifestJson: { kind: "image", image },
|
|
148
|
+
traitsJson: traits,
|
|
149
|
+
hasImage: true,
|
|
150
|
+
}),
|
|
151
|
+
).toEqual({ kind: "image", image });
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("a partial image manifest falls back to traits-first derivation", () => {
|
|
155
|
+
expect(
|
|
156
|
+
resolveAvatarFromFiles({
|
|
157
|
+
manifestJson: { kind: "image" },
|
|
158
|
+
traitsJson: traits,
|
|
159
|
+
hasImage: true,
|
|
160
|
+
}),
|
|
161
|
+
).toEqual({ kind: "character", traits });
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test("a legacy image carries no manifest metadata", () => {
|
|
165
|
+
expect(
|
|
166
|
+
resolveAvatarFromFiles({
|
|
167
|
+
manifestJson: undefined,
|
|
168
|
+
traitsJson: undefined,
|
|
169
|
+
hasImage: true,
|
|
170
|
+
}),
|
|
171
|
+
).toEqual({ kind: "image", image: null });
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
mkdirSync,
|
|
4
|
+
mkdtempSync,
|
|
5
|
+
rmSync,
|
|
6
|
+
symlinkSync,
|
|
7
|
+
writeFileSync,
|
|
8
|
+
} from "node:fs";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
|
|
12
|
+
import { AVATAR_SIDECAR_MAX_BYTES, readWorkspaceAvatar } from "../read.js";
|
|
13
|
+
|
|
14
|
+
const traits = { bodyShape: "round", eyeStyle: "dot", color: "#abc" };
|
|
15
|
+
|
|
16
|
+
describe("readWorkspaceAvatar", () => {
|
|
17
|
+
let workspaceDir: string;
|
|
18
|
+
let avatarDir: string;
|
|
19
|
+
|
|
20
|
+
const write = (name: string, contents: string): void => {
|
|
21
|
+
mkdirSync(avatarDir, { recursive: true });
|
|
22
|
+
writeFileSync(join(avatarDir, name), contents);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
workspaceDir = mkdtempSync(join(tmpdir(), "avatar-manifest-"));
|
|
27
|
+
avatarDir = join(workspaceDir, "data", "avatar");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
rmSync(workspaceDir, { recursive: true, force: true });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("missing avatar dir yields none", () => {
|
|
35
|
+
expect(readWorkspaceAvatar(workspaceDir)).toEqual({ kind: "none" });
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("manifest character returns its traits", () => {
|
|
39
|
+
write("avatar.json", JSON.stringify({ kind: "character", traits }));
|
|
40
|
+
write("avatar-image.png", "png");
|
|
41
|
+
expect(readWorkspaceAvatar(workspaceDir)).toEqual({
|
|
42
|
+
kind: "character",
|
|
43
|
+
traits,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("image resolves to the PNG path", () => {
|
|
48
|
+
write("avatar-image.png", "png");
|
|
49
|
+
expect(readWorkspaceAvatar(workspaceDir)).toEqual({
|
|
50
|
+
kind: "image",
|
|
51
|
+
imagePath: join(avatarDir, "avatar-image.png"),
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("corrupt manifest falls back to the traits sidecar", () => {
|
|
56
|
+
write("avatar.json", "{ not json");
|
|
57
|
+
write("character-traits.json", JSON.stringify(traits));
|
|
58
|
+
expect(readWorkspaceAvatar(workspaceDir)).toEqual({
|
|
59
|
+
kind: "character",
|
|
60
|
+
traits,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("oversized sidecars are treated as absent", () => {
|
|
65
|
+
const padded = JSON.stringify({
|
|
66
|
+
kind: "character",
|
|
67
|
+
traits,
|
|
68
|
+
pad: "x".repeat(AVATAR_SIDECAR_MAX_BYTES),
|
|
69
|
+
});
|
|
70
|
+
write("avatar.json", padded);
|
|
71
|
+
write("character-traits.json", JSON.stringify({ ...traits, pad: padded }));
|
|
72
|
+
expect(readWorkspaceAvatar(workspaceDir)).toEqual({ kind: "none" });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("a sidecar at the cap still reads", () => {
|
|
76
|
+
const body = JSON.stringify({ kind: "character", traits, pad: "" });
|
|
77
|
+
write(
|
|
78
|
+
"avatar.json",
|
|
79
|
+
body.replace(
|
|
80
|
+
'"pad":""',
|
|
81
|
+
`"pad":"${"x".repeat(AVATAR_SIDECAR_MAX_BYTES - body.length)}"`,
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
expect(readWorkspaceAvatar(workspaceDir)).toEqual({
|
|
85
|
+
kind: "character",
|
|
86
|
+
traits,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("a symlinked avatar dir is treated as absent", () => {
|
|
91
|
+
const foreign = mkdtempSync(join(tmpdir(), "foreign-avatar-"));
|
|
92
|
+
writeFileSync(
|
|
93
|
+
join(foreign, "character-traits.json"),
|
|
94
|
+
JSON.stringify({
|
|
95
|
+
bodyShape: "blob",
|
|
96
|
+
eyeStyle: "curious",
|
|
97
|
+
color: "green",
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
mkdirSync(join(workspaceDir, "data"), { recursive: true });
|
|
101
|
+
symlinkSync(foreign, avatarDir);
|
|
102
|
+
expect(readWorkspaceAvatar(workspaceDir)).toEqual({ kind: "none" });
|
|
103
|
+
rmSync(foreign, { recursive: true, force: true });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("symlinked sidecars are treated as absent", () => {
|
|
107
|
+
const outside = join(workspaceDir, "outside.json");
|
|
108
|
+
writeFileSync(outside, JSON.stringify({ kind: "character", traits }));
|
|
109
|
+
mkdirSync(avatarDir, { recursive: true });
|
|
110
|
+
symlinkSync(outside, join(avatarDir, "avatar.json"));
|
|
111
|
+
symlinkSync(outside, join(avatarDir, "character-traits.json"));
|
|
112
|
+
expect(readWorkspaceAvatar(workspaceDir)).toEqual({ kind: "none" });
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vellumai/avatar-manifest: the single source of truth for the on-disk
|
|
3
|
+
* avatar layout of an assistant workspace (`<workspace>/data/avatar`) and
|
|
4
|
+
* how its files resolve to an avatar.
|
|
5
|
+
*
|
|
6
|
+
* The daemon owns the files (it writes the manifest and sidecars); hosts
|
|
7
|
+
* such as the desktop app read them directly so a sleeping assistant still
|
|
8
|
+
* has an avatar in the chooser. Both go through the parsing and legacy
|
|
9
|
+
* derivation here so they cannot disagree. Leaf package: node builtins only.
|
|
10
|
+
*/
|
|
11
|
+
export {
|
|
12
|
+
AVATAR_IMAGE_FILENAME,
|
|
13
|
+
AVATAR_MANIFEST_FILENAME,
|
|
14
|
+
AVATAR_TRAITS_FILENAME,
|
|
15
|
+
resolveAvatarDir,
|
|
16
|
+
} from "./layout.js";
|
|
17
|
+
export {
|
|
18
|
+
deriveAvatarFromLegacyFiles,
|
|
19
|
+
parseAvatarManifest,
|
|
20
|
+
} from "./manifest.js";
|
|
21
|
+
export type {
|
|
22
|
+
AvatarImageMeta,
|
|
23
|
+
AvatarKind,
|
|
24
|
+
AvatarSource,
|
|
25
|
+
AvatarState,
|
|
26
|
+
CharacterTraits,
|
|
27
|
+
} from "./manifest.js";
|
|
28
|
+
export { readWorkspaceAvatar } from "./read.js";
|
|
29
|
+
export type { WorkspaceAvatar } from "./read.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
|
|
3
|
+
/** Path segments of the avatar directory below the workspace directory. */
|
|
4
|
+
const AVATAR_DIR_SEGMENTS: readonly string[] = ["data", "avatar"];
|
|
5
|
+
|
|
6
|
+
/** Avatar state manifest. */
|
|
7
|
+
export const AVATAR_MANIFEST_FILENAME = "avatar.json";
|
|
8
|
+
|
|
9
|
+
/** Legacy sidecar holding the persisted character traits. */
|
|
10
|
+
export const AVATAR_TRAITS_FILENAME = "character-traits.json";
|
|
11
|
+
|
|
12
|
+
/** The avatar PNG (uploaded, or rendered from the character traits). */
|
|
13
|
+
export const AVATAR_IMAGE_FILENAME = "avatar-image.png";
|
|
14
|
+
|
|
15
|
+
/** The avatar directory for a workspace (`<workspace>/data/avatar`). */
|
|
16
|
+
export function resolveAvatarDir(workspaceDir: string): string {
|
|
17
|
+
return join(workspaceDir, ...AVATAR_DIR_SEGMENTS);
|
|
18
|
+
}
|