@vellumai/assistant 0.11.2-dev.202608051734.355dff7 → 0.11.2-dev.202608051933.deffc0f
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 +4 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/ingress.ts +10 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/ingress.ts +10 -0
- package/node_modules/@vellumai/service-contracts/src/ingress.ts +10 -0
- package/openapi.yaml +22 -0
- package/package.json +1 -1
- package/src/__tests__/agent-loop-override-profile.test.ts +38 -48
- package/src/__tests__/assistant-feature-flags-integration.test.ts +0 -10
- package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +1 -0
- package/src/__tests__/conversation-tool-setup-attribution.test.ts +61 -0
- package/src/__tests__/cu-unified-flow.test.ts +2 -6
- package/src/__tests__/file-ops-service.test.ts +75 -4
- package/src/__tests__/host-bash-proxy.test.ts +10 -5
- package/src/__tests__/host-browser-proxy.test.ts +2 -2
- package/src/__tests__/host-cu-proxy.test.ts +3 -7
- package/src/__tests__/host-file-proxy.test.ts +3 -7
- package/src/__tests__/host-file-read-tool.test.ts +5 -1
- package/src/__tests__/host-transfer-proxy-targeted.test.ts +6 -4
- package/src/__tests__/llm-resolver-override-or-default.test.ts +141 -0
- package/src/__tests__/media-stream-server-integration.test.ts +36 -0
- package/src/__tests__/stt-language-catalog-parity.test.ts +38 -0
- package/src/__tests__/subagent-tool-gate-mode.test.ts +1 -0
- package/src/__tests__/subagent-tools.test.ts +48 -92
- package/src/__tests__/tool-result-spool.test.ts +74 -18
- package/src/agent/loop.ts +6 -3
- package/src/calls/media-stream-server.ts +9 -1
- package/src/config/bundled-skills/settings/TOOLS.json +2 -2
- package/src/config/bundled-skills/settings/tools/voice-config-update.ts +1 -0
- package/src/config/bundled-skills/subagent/SKILL.md +3 -3
- package/src/config/bundled-skills/subagent/TOOLS.json +1 -1
- package/src/config/feature-flag-registry.json +0 -16
- package/src/config/llm-resolver.ts +41 -12
- package/src/config/schemas/stt.ts +10 -4
- package/src/context/post-turn-tool-result-truncation.ts +32 -16
- package/src/context/tool-result-spool.ts +32 -18
- package/src/daemon/conversation-tool-setup.ts +1 -1
- package/src/persistence/conversation-attention-store.ts +30 -10
- package/src/persistence/conversation-queries.ts +74 -1
- package/src/platform/managed-speech.test.ts +20 -0
- package/src/platform/managed-speech.ts +9 -0
- package/src/providers/speech-to-text/__tests__/resolve.test.ts +164 -6
- package/src/providers/speech-to-text/deepgram.ts +1 -0
- package/src/providers/speech-to-text/resolve.ts +80 -10
- package/src/providers/speech-to-text/vellum-managed.ts +7 -1
- package/src/providers/speech-to-text/vellum-speech-relay-connection.ts +3 -1
- package/src/runtime/auth/__tests__/guard-tests.test.ts +2 -0
- package/src/runtime/auth/__tests__/scopes.test.ts +20 -0
- package/src/runtime/auth/same-actor.ts +38 -7
- package/src/runtime/auth/scopes.ts +12 -0
- package/src/runtime/auth/types.ts +2 -0
- package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +279 -1
- package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +14 -10
- package/src/runtime/routes/conversation-list-routes.ts +25 -0
- package/src/runtime/routes/conversation-query-routes.ts +0 -50
- package/src/stt/daemon-batch-transcriber.ts +8 -6
- package/src/tools/filesystem/read.ts +2 -2
- package/src/tools/host-filesystem/read.ts +14 -6
- package/src/tools/shared/filesystem/file-ops-service.ts +36 -3
- package/src/tools/subagent/spawn.ts +26 -78
- package/src/tools/types.ts +5 -3
|
@@ -58,9 +58,27 @@ mock.module("../../../security/credential-key.js", () => ({
|
|
|
58
58
|
|
|
59
59
|
let mockVellumAvailable = false;
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Arguments the managed batch adapter was called with. The managed path has
|
|
63
|
+
* no constructor to spy on (the platform connection is the credential), so
|
|
64
|
+
* the language it forwards is observable only at the transcribe call.
|
|
65
|
+
*/
|
|
66
|
+
const vellumManagedTranscribeCalls: Array<{
|
|
67
|
+
mimeType: string;
|
|
68
|
+
language: string | undefined;
|
|
69
|
+
}> = [];
|
|
70
|
+
|
|
61
71
|
mock.module("../vellum-managed.js", () => ({
|
|
62
72
|
vellumManagedSpeechAvailable: async () => mockVellumAvailable,
|
|
63
|
-
vellumManagedTranscribe: async (
|
|
73
|
+
vellumManagedTranscribe: async (
|
|
74
|
+
_audio: Buffer,
|
|
75
|
+
mimeType: string,
|
|
76
|
+
_signal?: AbortSignal,
|
|
77
|
+
language?: string,
|
|
78
|
+
) => {
|
|
79
|
+
vellumManagedTranscribeCalls.push({ mimeType, language });
|
|
80
|
+
return { text: "" };
|
|
81
|
+
},
|
|
64
82
|
sttErrorFromManagedSpeech: (failure: unknown) => new Error(String(failure)),
|
|
65
83
|
}));
|
|
66
84
|
|
|
@@ -172,6 +190,7 @@ mock.module("../xai-realtime.js", () => ({
|
|
|
172
190
|
// ---------------------------------------------------------------------------
|
|
173
191
|
|
|
174
192
|
const {
|
|
193
|
+
effectiveSttLanguage,
|
|
175
194
|
resolveBatchTranscriber,
|
|
176
195
|
sttCredentialGapReason,
|
|
177
196
|
resolveConversationStreamingSttCapability,
|
|
@@ -1044,7 +1063,9 @@ describe("vellum managed resolution", () => {
|
|
|
1044
1063
|
expect(vellumStreamCtorCalls).toEqual([
|
|
1045
1064
|
{
|
|
1046
1065
|
connection: mockVelayConnection,
|
|
1047
|
-
|
|
1066
|
+
// No language is configured here, so the managed default rides along
|
|
1067
|
+
// with the connection plumbing this test is about.
|
|
1068
|
+
options: { sampleRate: 24000, language: "multi" },
|
|
1048
1069
|
},
|
|
1049
1070
|
]);
|
|
1050
1071
|
});
|
|
@@ -1178,16 +1199,76 @@ describe("resolveStreamingTranscriber language plumbing", () => {
|
|
|
1178
1199
|
expect(deepgramCtorCalls[0]?.options).toMatchObject({ language: "hi" });
|
|
1179
1200
|
});
|
|
1180
1201
|
|
|
1181
|
-
test("no configured language
|
|
1182
|
-
//
|
|
1183
|
-
//
|
|
1202
|
+
test("no configured language falls to multilingual on BYOK Deepgram", async () => {
|
|
1203
|
+
// Unset is not a neutral state on Deepgram: sending no language decodes
|
|
1204
|
+
// as English, so an unconfigured Hindi speaker gets English-sounding
|
|
1205
|
+
// nonsense. The default fills that gap with code-switching, which also
|
|
1206
|
+
// pins nova-3 the way any explicit language does.
|
|
1184
1207
|
mockProviderKeys = { deepgram: "dg-key" };
|
|
1185
1208
|
applyConfig({ provider: "deepgram" });
|
|
1186
1209
|
|
|
1187
1210
|
await resolveStreamingTranscriber({ sampleRate: 16000 });
|
|
1188
1211
|
|
|
1189
1212
|
expect(deepgramCtorCalls).toHaveLength(1);
|
|
1190
|
-
expect(deepgramCtorCalls[0]?.options).
|
|
1213
|
+
expect(deepgramCtorCalls[0]?.options).toMatchObject({
|
|
1214
|
+
language: "multi",
|
|
1215
|
+
model: "nova-3",
|
|
1216
|
+
});
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
test("no configured language falls to multilingual on the managed relay", async () => {
|
|
1220
|
+
// The relay dials Deepgram server-side, so it inherits the same English
|
|
1221
|
+
// default and needs the same fill-in.
|
|
1222
|
+
mockVellumAvailable = true;
|
|
1223
|
+
mockVelayConnection = {
|
|
1224
|
+
wsBaseUrl: "ws://gateway.test",
|
|
1225
|
+
httpBaseUrl: "http://gateway.test",
|
|
1226
|
+
mintServiceToken: () => "vk-test",
|
|
1227
|
+
};
|
|
1228
|
+
applyConfig({ provider: "vellum" });
|
|
1229
|
+
|
|
1230
|
+
await resolveStreamingTranscriber({ sampleRate: 24000 });
|
|
1231
|
+
|
|
1232
|
+
expect(vellumStreamCtorCalls).toEqual([
|
|
1233
|
+
{
|
|
1234
|
+
connection: mockVelayConnection,
|
|
1235
|
+
options: { sampleRate: 24000, language: "multi" },
|
|
1236
|
+
},
|
|
1237
|
+
]);
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
test("an explicitly configured language still wins over the default", async () => {
|
|
1241
|
+
// The default only fills the unset case: someone who picked Tamil (off
|
|
1242
|
+
// the code-switching roster entirely) must keep it.
|
|
1243
|
+
mockProviderKeys = { deepgram: "dg-key" };
|
|
1244
|
+
applyConfig({ provider: "deepgram", language: "ta" });
|
|
1245
|
+
|
|
1246
|
+
await resolveStreamingTranscriber({ sampleRate: 16000 });
|
|
1247
|
+
|
|
1248
|
+
expect(deepgramCtorCalls[0]?.options).toMatchObject({ language: "ta" });
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
test("an explicit English pin is honored rather than treated as unset", async () => {
|
|
1252
|
+
// "en" is what the settings picker writes for a deliberate English pin,
|
|
1253
|
+
// so it must not collapse back into the multilingual default.
|
|
1254
|
+
mockProviderKeys = { deepgram: "dg-key" };
|
|
1255
|
+
applyConfig({ provider: "deepgram", language: "en" });
|
|
1256
|
+
|
|
1257
|
+
await resolveStreamingTranscriber({ sampleRate: 16000 });
|
|
1258
|
+
|
|
1259
|
+
expect(deepgramCtorCalls[0]?.options).toMatchObject({ language: "en" });
|
|
1260
|
+
});
|
|
1261
|
+
|
|
1262
|
+
test("providers that detect natively keep receiving no language when unset", async () => {
|
|
1263
|
+
// xAI reads unset as native auto-detection, so the multilingual default
|
|
1264
|
+
// would replace a broader capability with a ten-language one.
|
|
1265
|
+
mockProviderKeys = { xai: "xai-key" };
|
|
1266
|
+
applyConfig({ provider: "xai" });
|
|
1267
|
+
|
|
1268
|
+
await resolveStreamingTranscriber({ sampleRate: 16000 });
|
|
1269
|
+
|
|
1270
|
+
expect(xaiCtorCalls).toHaveLength(1);
|
|
1271
|
+
expect(xaiCtorCalls[0]?.options).not.toHaveProperty("language");
|
|
1191
1272
|
});
|
|
1192
1273
|
|
|
1193
1274
|
test("providers that auto-detect natively never receive a language", async () => {
|
|
@@ -1245,6 +1326,61 @@ describe("resolveStreamingTranscriber language plumbing", () => {
|
|
|
1245
1326
|
model: "nova-3",
|
|
1246
1327
|
});
|
|
1247
1328
|
});
|
|
1329
|
+
|
|
1330
|
+
test("managed batch forwards the configured language to the platform", async () => {
|
|
1331
|
+
// The platform proxy passes it to Deepgram server-side, so a managed
|
|
1332
|
+
// voice note decodes in the same language the live session does.
|
|
1333
|
+
vellumManagedTranscribeCalls.length = 0;
|
|
1334
|
+
mockVellumAvailable = true;
|
|
1335
|
+
applyConfig({ provider: "vellum", language: "ta" });
|
|
1336
|
+
|
|
1337
|
+
const transcriber = await resolveBatchTranscriber();
|
|
1338
|
+
await transcriber!.transcribe({
|
|
1339
|
+
audio: Buffer.from("fake-audio"),
|
|
1340
|
+
mimeType: "audio/ogg",
|
|
1341
|
+
});
|
|
1342
|
+
|
|
1343
|
+
expect(vellumManagedTranscribeCalls).toHaveLength(1);
|
|
1344
|
+
expect(vellumManagedTranscribeCalls[0]?.language).toBe("ta");
|
|
1345
|
+
});
|
|
1346
|
+
|
|
1347
|
+
test("managed batch falls to multilingual when no language is configured", async () => {
|
|
1348
|
+
// The gap this closes: managed voice notes used to decode as English no
|
|
1349
|
+
// matter what the user had chosen, because nothing was forwarded.
|
|
1350
|
+
vellumManagedTranscribeCalls.length = 0;
|
|
1351
|
+
mockVellumAvailable = true;
|
|
1352
|
+
applyConfig({ provider: "vellum" });
|
|
1353
|
+
|
|
1354
|
+
const transcriber = await resolveBatchTranscriber();
|
|
1355
|
+
await transcriber!.transcribe({
|
|
1356
|
+
audio: Buffer.from("fake-audio"),
|
|
1357
|
+
mimeType: "audio/ogg",
|
|
1358
|
+
});
|
|
1359
|
+
|
|
1360
|
+
expect(vellumManagedTranscribeCalls).toHaveLength(1);
|
|
1361
|
+
expect(vellumManagedTranscribeCalls[0]?.language).toBe("multi");
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
test("batch resolution falls to multilingual when no language is configured", async () => {
|
|
1365
|
+
// Dictation and voice notes ride the batch path, and they read the same
|
|
1366
|
+
// config the live session does. A user whose spoken language works in
|
|
1367
|
+
// voice mode must not find it broken in a voice note.
|
|
1368
|
+
deepgramBatchCtorCalls.length = 0;
|
|
1369
|
+
mockProviderKeys = { deepgram: "dg-key" };
|
|
1370
|
+
applyConfig({ provider: "deepgram" });
|
|
1371
|
+
|
|
1372
|
+
const transcriber = await resolveBatchTranscriber();
|
|
1373
|
+
await transcriber!.transcribe({
|
|
1374
|
+
audio: Buffer.from("fake-audio"),
|
|
1375
|
+
mimeType: "audio/ogg",
|
|
1376
|
+
});
|
|
1377
|
+
|
|
1378
|
+
expect(deepgramBatchCtorCalls).toHaveLength(1);
|
|
1379
|
+
expect(deepgramBatchCtorCalls[0]?.options).toMatchObject({
|
|
1380
|
+
language: "multi",
|
|
1381
|
+
model: "nova-3",
|
|
1382
|
+
});
|
|
1383
|
+
});
|
|
1248
1384
|
});
|
|
1249
1385
|
|
|
1250
1386
|
describe("sttCredentialGapReason", () => {
|
|
@@ -1254,3 +1390,25 @@ describe("sttCredentialGapReason", () => {
|
|
|
1254
1390
|
expect(sttCredentialGapReason("deepgram")).toContain("API key");
|
|
1255
1391
|
});
|
|
1256
1392
|
});
|
|
1393
|
+
|
|
1394
|
+
describe("effectiveSttLanguage", () => {
|
|
1395
|
+
test("fills the unset case only where unset would mean English", () => {
|
|
1396
|
+
// Deepgram and the managed relay decode language-less audio as English,
|
|
1397
|
+
// so leaving them unset is a silent pin rather than a neutral state.
|
|
1398
|
+
expect(effectiveSttLanguage("deepgram", undefined)).toBe("multi");
|
|
1399
|
+
expect(effectiveSttLanguage("vellum", undefined)).toBe("multi");
|
|
1400
|
+
// Everyone else detects natively from the audio; filling in a ten-language
|
|
1401
|
+
// roster would narrow what they can already do.
|
|
1402
|
+
expect(effectiveSttLanguage("xai", undefined)).toBeUndefined();
|
|
1403
|
+
expect(effectiveSttLanguage("google-gemini", undefined)).toBeUndefined();
|
|
1404
|
+
expect(effectiveSttLanguage("openai-whisper", undefined)).toBeUndefined();
|
|
1405
|
+
});
|
|
1406
|
+
|
|
1407
|
+
test("a configured language always wins, including English", () => {
|
|
1408
|
+
// The default decides what happens when nobody has chosen, nothing more.
|
|
1409
|
+
expect(effectiveSttLanguage("deepgram", "ta")).toBe("ta");
|
|
1410
|
+
expect(effectiveSttLanguage("deepgram", "en")).toBe("en");
|
|
1411
|
+
expect(effectiveSttLanguage("vellum", "multi")).toBe("multi");
|
|
1412
|
+
expect(effectiveSttLanguage("xai", "hi")).toBe("hi");
|
|
1413
|
+
});
|
|
1414
|
+
});
|
|
@@ -16,6 +16,64 @@ import {
|
|
|
16
16
|
|
|
17
17
|
const log = getLogger("stt-resolver");
|
|
18
18
|
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Default spoken language
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Providers that decode language-less audio as English rather than detecting
|
|
25
|
+
* the spoken language: Deepgram directly, and the managed relay, which dials
|
|
26
|
+
* Deepgram server-side. For these, an unset `services.stt.language` is not a
|
|
27
|
+
* neutral state: it is a silent English pin that returns non-English speech
|
|
28
|
+
* as English-sounding nonsense.
|
|
29
|
+
*
|
|
30
|
+
* Providers absent from this set need no default: xAI, Gemini and Whisper all
|
|
31
|
+
* detect natively from the audio when no language is sent.
|
|
32
|
+
*/
|
|
33
|
+
const MULTILINGUAL_DEFAULT_PROVIDERS: ReadonlySet<SttProviderId> = new Set([
|
|
34
|
+
"deepgram",
|
|
35
|
+
"vellum",
|
|
36
|
+
] as SttProviderId[]);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The language an unset config resolves to on the providers above: nova-3's
|
|
40
|
+
* code-switching mode, which follows a speaker between the ten languages of
|
|
41
|
+
* Deepgram's multi roster (`DEEPGRAM_MULTI_LANGUAGE_CODES` in `deepgram.ts`)
|
|
42
|
+
* without being told which one they are speaking. Chosen over an English pin
|
|
43
|
+
* because the failure it replaces is
|
|
44
|
+
* silent: a Hindi speaker under the English default gets fluent-looking
|
|
45
|
+
* garbage rather than an error, and has no way to tell recognition is
|
|
46
|
+
* misconfigured from the transcript alone.
|
|
47
|
+
*
|
|
48
|
+
* It is a default, not a ceiling. Speakers of the other 39 languages on the
|
|
49
|
+
* monolingual roster still pick theirs explicitly, and that pick continues to
|
|
50
|
+
* win here. This only decides what happens when nobody has chosen.
|
|
51
|
+
*/
|
|
52
|
+
const DEFAULT_MULTILINGUAL_CODE = "multi";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The spoken language to transcribe with, given what config holds and which
|
|
56
|
+
* provider will receive it. Configured values always win; the default only
|
|
57
|
+
* fills the unset case, and only where unset would otherwise mean English.
|
|
58
|
+
*
|
|
59
|
+
* Applied inside the resolvers rather than at the config layer so config keeps
|
|
60
|
+
* recording what the user chose (or that they chose nothing). The settings
|
|
61
|
+
* surfaces read that distinction to show which rows are defaults, and the live
|
|
62
|
+
* session compares raw config values to decide whether a language change needs
|
|
63
|
+
* a re-dial.
|
|
64
|
+
*/
|
|
65
|
+
export function effectiveSttLanguage(
|
|
66
|
+
providerId: SttProviderId,
|
|
67
|
+
configured: string | undefined,
|
|
68
|
+
): string | undefined {
|
|
69
|
+
if (configured) {
|
|
70
|
+
return configured;
|
|
71
|
+
}
|
|
72
|
+
return MULTILINGUAL_DEFAULT_PROVIDERS.has(providerId)
|
|
73
|
+
? DEFAULT_MULTILINGUAL_CODE
|
|
74
|
+
: undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
19
77
|
// ---------------------------------------------------------------------------
|
|
20
78
|
// Batch transcriber resolver (existing public API — unchanged contract)
|
|
21
79
|
// ---------------------------------------------------------------------------
|
|
@@ -38,7 +96,10 @@ export async function resolveBatchTranscriber(): Promise<BatchTranscriber | null
|
|
|
38
96
|
// change cannot pair one setting's old value with another's new value.
|
|
39
97
|
const stt = getConfig().services.stt;
|
|
40
98
|
const provider = stt.provider;
|
|
41
|
-
const language =
|
|
99
|
+
const language = effectiveSttLanguage(
|
|
100
|
+
provider as SttProviderId,
|
|
101
|
+
stt.language,
|
|
102
|
+
);
|
|
42
103
|
|
|
43
104
|
// Look up credential provider via the catalog.
|
|
44
105
|
const credentialProviderName = getCredentialProvider(
|
|
@@ -54,11 +115,12 @@ export async function resolveBatchTranscriber(): Promise<BatchTranscriber | null
|
|
|
54
115
|
}
|
|
55
116
|
|
|
56
117
|
if (provider === "vellum") {
|
|
57
|
-
// Managed batch
|
|
58
|
-
//
|
|
59
|
-
//
|
|
118
|
+
// Managed batch rides the platform's speech proxy, which forwards the
|
|
119
|
+
// language to Deepgram server-side. A platform build predating that
|
|
120
|
+
// field ignores it rather than failing, so the daemon can send one
|
|
121
|
+
// before the platform side deploys.
|
|
60
122
|
return (await sttProviderKeyResolves("vellum"))
|
|
61
|
-
? createDaemonBatchTranscriber(null, "vellum")
|
|
123
|
+
? createDaemonBatchTranscriber(null, "vellum", language)
|
|
62
124
|
: null;
|
|
63
125
|
}
|
|
64
126
|
|
|
@@ -304,9 +366,11 @@ export interface ResolveStreamingTranscriberOptions {
|
|
|
304
366
|
* Defaults to `services.stt.language`; pass explicitly to override the
|
|
305
367
|
* config for a single session.
|
|
306
368
|
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
369
|
+
* Leaving both unset does not reach the adapters as "no language": on
|
|
370
|
+
* Deepgram and the managed relay, where that would mean English rather
|
|
371
|
+
* than detection, {@link effectiveSttLanguage} fills in code-switching
|
|
372
|
+
* first. See {@link CreateStreamingTranscriberOptions.language} for how
|
|
373
|
+
* each adapter treats what it finally receives.
|
|
310
374
|
*/
|
|
311
375
|
language?: string;
|
|
312
376
|
}
|
|
@@ -339,8 +403,14 @@ export async function resolveStreamingTranscriber(
|
|
|
339
403
|
const provider = options.providerId ?? (stt.provider as SttProviderId);
|
|
340
404
|
// Config-level language applies to every streaming caller (live voice,
|
|
341
405
|
// dictation, telephony) unless one overrides it for a single session, so
|
|
342
|
-
// the setting lands in one place rather than at each call site.
|
|
343
|
-
|
|
406
|
+
// the setting lands in one place rather than at each call site. An unset
|
|
407
|
+
// config falls to the provider's default (see `effectiveSttLanguage`),
|
|
408
|
+
// which is where a caller passing no language gets multilingual rather
|
|
409
|
+
// than a silent English pin.
|
|
410
|
+
const language = effectiveSttLanguage(
|
|
411
|
+
provider,
|
|
412
|
+
options.language ?? stt.language,
|
|
413
|
+
);
|
|
344
414
|
const diarizePreference: DiarizePreference = options.diarize ?? "off";
|
|
345
415
|
|
|
346
416
|
// Look up credential provider via the catalog.
|
|
@@ -95,8 +95,14 @@ export async function vellumManagedTranscribe(
|
|
|
95
95
|
audio: Buffer,
|
|
96
96
|
mimeType: string,
|
|
97
97
|
signal?: AbortSignal,
|
|
98
|
+
language?: string,
|
|
98
99
|
): Promise<SttTranscribeResult> {
|
|
99
|
-
const result = await managedSpeechTranscribe({
|
|
100
|
+
const result = await managedSpeechTranscribe({
|
|
101
|
+
audio,
|
|
102
|
+
mimeType,
|
|
103
|
+
signal,
|
|
104
|
+
language,
|
|
105
|
+
});
|
|
100
106
|
if (!result.ok) {
|
|
101
107
|
throw sttErrorFromManagedSpeech(result);
|
|
102
108
|
}
|
|
@@ -59,7 +59,9 @@ export async function resolveSpeechRelayConnection(): Promise<SpeechRelayConnect
|
|
|
59
59
|
mintToken({
|
|
60
60
|
aud: "vellum-gateway",
|
|
61
61
|
sub: DAEMON_SERVICE_SUB,
|
|
62
|
-
|
|
62
|
+
// Least-privilege (ATL-1033): this token rides in the dial URL, so it
|
|
63
|
+
// must open nothing but the speech relay.
|
|
64
|
+
scope_profile: "speech_relay_v1",
|
|
63
65
|
policy_epoch: CURRENT_POLICY_EPOCH,
|
|
64
66
|
ttlSeconds: RELAY_TOKEN_TTL_SECONDS,
|
|
65
67
|
});
|
|
@@ -276,6 +276,7 @@ describe("scope profile contract", () => {
|
|
|
276
276
|
"internal.write",
|
|
277
277
|
],
|
|
278
278
|
local_v1: ["local.all"],
|
|
279
|
+
speech_relay_v1: ["speech.relay"],
|
|
279
280
|
ui_page_v1: ["settings.read"],
|
|
280
281
|
};
|
|
281
282
|
|
|
@@ -299,6 +300,7 @@ describe("scope profile contract", () => {
|
|
|
299
300
|
"gateway_ingress_v1",
|
|
300
301
|
"gateway_service_v1",
|
|
301
302
|
"local_v1",
|
|
303
|
+
"speech_relay_v1",
|
|
302
304
|
"ui_page_v1",
|
|
303
305
|
];
|
|
304
306
|
|
|
@@ -64,6 +64,26 @@ describe("resolveScopeProfile", () => {
|
|
|
64
64
|
expect(scopes.size).toBe(7);
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
+
test("speech_relay_v1 includes only speech.relay (ATL-1033 least-privilege)", () => {
|
|
68
|
+
const scopes = resolveScopeProfile("speech_relay_v1");
|
|
69
|
+
expect(scopes.has("speech.relay")).toBe(true);
|
|
70
|
+
expect(scopes.size).toBe(1);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("unknown profiles resolve to no scopes, including prototype keys", () => {
|
|
74
|
+
// Claims come from JSON, so the ScopeProfile type does not protect at
|
|
75
|
+
// runtime. Unknown names and Object.prototype keys must both fail closed.
|
|
76
|
+
for (const profile of [
|
|
77
|
+
"bogus_v1",
|
|
78
|
+
"toString",
|
|
79
|
+
"constructor",
|
|
80
|
+
"__proto__",
|
|
81
|
+
]) {
|
|
82
|
+
const scopes = resolveScopeProfile(profile as never);
|
|
83
|
+
expect(scopes.size).toBe(0);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
67
87
|
test("local_v1 includes only local.all", () => {
|
|
68
88
|
const scopes = resolveScopeProfile("local_v1");
|
|
69
89
|
expect(scopes.has("local.all")).toBe(true);
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
* Both paths log a single structured warn line on rejection with the
|
|
19
19
|
* shape `{ sourceActorPrincipalId, targetClientId, targetActorPrincipalId,
|
|
20
20
|
* op, reason }` so that bash, file, and CU rejections render identically
|
|
21
|
-
* in the audit log.
|
|
21
|
+
* in the audit log. The user-facing wording differs by path: the proxy
|
|
22
|
+
* result names the failing comparison, while the HTTP 403 stays generic
|
|
23
|
+
* because it can reach a caller who does not own the target client.
|
|
22
24
|
*/
|
|
23
25
|
import type { HostProxyCapability } from "../../channels/types.js";
|
|
24
26
|
import { isHttpAuthDisabled } from "../../config/env.js";
|
|
@@ -29,14 +31,39 @@ import { ForbiddenError } from "../routes/errors.js";
|
|
|
29
31
|
const log = getLogger("same-actor");
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
|
-
* Canonical user-facing rejection message
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* 403.
|
|
34
|
+
* Canonical user-facing rejection message for the HTTP/IPC route path,
|
|
35
|
+
* where the caller may be any principal and the reason must not describe
|
|
36
|
+
* the target client's internal state.
|
|
36
37
|
*/
|
|
37
38
|
const REJECTION_MESSAGE =
|
|
38
39
|
"Submitting actor does not match the target client's actor for this request. The targeted client's authenticated user must submit the result.";
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Per-reason rejection messages for the proxy path.
|
|
43
|
+
*
|
|
44
|
+
* The proxy's rejection is read by the agent (and, through the transcript,
|
|
45
|
+
* by the user) on their own turn, so it can and should name which of the
|
|
46
|
+
* three comparisons failed. Collapsing them into one sentence made a
|
|
47
|
+
* single-user desktop report that "the submitting actor does not match the
|
|
48
|
+
* target client's actor" in two cases where the two actors were never
|
|
49
|
+
* compared at all: the turn carried no actor principal, or the target
|
|
50
|
+
* client registered its SSE stream without one. Those have different fixes
|
|
51
|
+
* — re-establish the caller's identity versus reconnect the client — and
|
|
52
|
+
* neither is "sign in as the other user".
|
|
53
|
+
*
|
|
54
|
+
* The route path keeps {@link REJECTION_MESSAGE}: an HTTP 403 can reach a
|
|
55
|
+
* caller who is not the owner, and `missing_target` versus `mismatch` would
|
|
56
|
+
* describe a client that is not theirs.
|
|
57
|
+
*/
|
|
58
|
+
const PROXY_REJECTION_MESSAGES: Record<RejectionReason, string> = {
|
|
59
|
+
missing_source:
|
|
60
|
+
"This turn has no authenticated actor, so it cannot target a connected client. Host-proxy execution binds each request to the user who sent the message; retry from a signed-in client, or check that the assistant's guardian binding resolved.",
|
|
61
|
+
missing_target:
|
|
62
|
+
"The target client is connected but registered without an authenticated user, so it cannot be targeted. Quit and reopen the desktop app to re-register it, then retry.",
|
|
63
|
+
mismatch:
|
|
64
|
+
"Submitting actor does not match the target client's actor for this request. The target client is signed in as a different user — run `assistant clients list` to see which connected clients you own.",
|
|
65
|
+
};
|
|
66
|
+
|
|
40
67
|
/** OpenAPI 403 description for `*-result` endpoints, kept identical. */
|
|
41
68
|
export const SAME_ACTOR_FORBIDDEN_DESCRIPTION =
|
|
42
69
|
"Submitting client does not match the targeted client, or the submitting actor's principal does not match the target client's actor.";
|
|
@@ -164,14 +191,18 @@ export function enforceSameActorOrThrow(
|
|
|
164
191
|
* on rejection (so the proxy can pass it directly back to the agent),
|
|
165
192
|
* or `null` on success. Always uses the live hub lookup — proxy
|
|
166
193
|
* registration runs while the target SSE subscription is active.
|
|
194
|
+
*
|
|
195
|
+
* The returned message names the failing comparison — see
|
|
196
|
+
* {@link PROXY_REJECTION_MESSAGES}.
|
|
167
197
|
*/
|
|
168
198
|
export function enforceSameActorOrErrorResult(
|
|
169
199
|
args: SameActorLiveArgs,
|
|
170
200
|
): { content: string; isError: true } | null {
|
|
171
|
-
|
|
201
|
+
const reason = detectRejection(args);
|
|
202
|
+
if (reason == null) {
|
|
172
203
|
return null;
|
|
173
204
|
}
|
|
174
|
-
return { content:
|
|
205
|
+
return { content: PROXY_REJECTION_MESSAGES[reason], isError: true };
|
|
175
206
|
}
|
|
176
207
|
|
|
177
208
|
/**
|
|
@@ -38,15 +38,27 @@ const PROFILE_SCOPES: Record<ScopeProfile, ReadonlySet<Scope>> = {
|
|
|
38
38
|
"internal.write",
|
|
39
39
|
]),
|
|
40
40
|
local_v1: new Set<Scope>(["local.all"]),
|
|
41
|
+
// Managed speech relay only (ATL-1033): the daemon's relay-dial token must
|
|
42
|
+
// not open any other edge-scoped route.
|
|
43
|
+
speech_relay_v1: new Set<Scope>(["speech.relay"]),
|
|
41
44
|
ui_page_v1: new Set<Scope>(["settings.read"]),
|
|
42
45
|
};
|
|
43
46
|
|
|
47
|
+
const EMPTY_SCOPES: ReadonlySet<Scope> = new Set();
|
|
48
|
+
|
|
44
49
|
// ---------------------------------------------------------------------------
|
|
45
50
|
// Public API
|
|
46
51
|
// ---------------------------------------------------------------------------
|
|
47
52
|
|
|
48
53
|
/** Resolve a scope profile name to its set of granted scopes. */
|
|
49
54
|
export function resolveScopeProfile(profile: ScopeProfile): ReadonlySet<Scope> {
|
|
55
|
+
// Claims come from JSON, so an unrecognized profile (e.g. minted by a newer
|
|
56
|
+
// peer) can reach this despite the type. Resolve it to no scopes, not a
|
|
57
|
+
// TypeError in the caller. The own-property check keeps inherited keys
|
|
58
|
+
// ("toString", "constructor") failing closed too.
|
|
59
|
+
if (!Object.prototype.hasOwnProperty.call(PROFILE_SCOPES, profile)) {
|
|
60
|
+
return EMPTY_SCOPES;
|
|
61
|
+
}
|
|
50
62
|
return PROFILE_SCOPES[profile];
|
|
51
63
|
}
|
|
52
64
|
|
|
@@ -14,6 +14,7 @@ export type ScopeProfile =
|
|
|
14
14
|
| "gateway_ingress_v1"
|
|
15
15
|
| "gateway_service_v1"
|
|
16
16
|
| "local_v1"
|
|
17
|
+
| "speech_relay_v1"
|
|
17
18
|
| "ui_page_v1";
|
|
18
19
|
|
|
19
20
|
// ---------------------------------------------------------------------------
|
|
@@ -35,6 +36,7 @@ export type Scope =
|
|
|
35
36
|
| "internal.write"
|
|
36
37
|
| "feature_flags.read"
|
|
37
38
|
| "feature_flags.write"
|
|
39
|
+
| "speech.relay"
|
|
38
40
|
| "local.all";
|
|
39
41
|
|
|
40
42
|
// ---------------------------------------------------------------------------
|