@steve31415/baselib 3.70.0 → 3.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deploy/config.js +3 -0
- package/dist/deploy/deploy.d.ts +20 -1
- package/dist/deploy/deploy.js +69 -11
- package/dist/deploy/types.d.ts +3 -0
- package/dist/llm/complete.js +16 -4
- package/dist/llm/index.d.ts +1 -1
- package/dist/llm/models.d.ts +8 -0
- package/dist/llm/models.js +5 -0
- package/dist/llm/providers/gemini.js +3 -1
- package/dist/llm/types.d.ts +21 -0
- package/package.json +1 -1
package/dist/deploy/config.js
CHANGED
|
@@ -22,6 +22,9 @@ function validateService(raw, index) {
|
|
|
22
22
|
fail(`services[${index}].health.audience`);
|
|
23
23
|
if (s.health.kind === 'public-canonical' && !s.canonicalUrl)
|
|
24
24
|
fail(`services[${index}].canonicalUrl`);
|
|
25
|
+
// The path also goes into gcloud's comma-separated --startup-probe value.
|
|
26
|
+
if (s.health.path !== undefined && !/^\/[A-Za-z0-9/_.-]*$/.test(s.health.path))
|
|
27
|
+
fail(`services[${index}].health.path (want /[A-Za-z0-9/_.-]*)`);
|
|
25
28
|
return s;
|
|
26
29
|
}
|
|
27
30
|
export function validateConfig(raw) {
|
package/dist/deploy/deploy.d.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import type { Runner } from './types.js';
|
|
1
|
+
import type { Runner, ServiceHealth } from './types.js';
|
|
2
2
|
/** A gate's output shows its test browser process crashed (e.g. a segfault). */
|
|
3
3
|
export declare function testBrowserCrashed(output: string): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The `--startup-probe` value every `services update` asserts: Cloud Run
|
|
6
|
+
* sends `GET <health path>` to each new instance and lets it take traffic
|
|
7
|
+
* only on a success, instead of its default check that the port merely
|
|
8
|
+
* accepts connections. null for `health.kind: 'none'` (the probe is left as
|
|
9
|
+
* configured). Omitting httpGet.port probes the container port.
|
|
10
|
+
*
|
|
11
|
+
* Timing: one attempt a second, each allowed one second, 240 attempts — the
|
|
12
|
+
* same four-minute window as Cloud Run's default TCP probe. 2026-11-21: the
|
|
13
|
+
* slowest serving revision fleet-wide became healthy in 5.2 s (corpus), about
|
|
14
|
+
* 2% of the window; the window is deliberately generous because a slow start
|
|
15
|
+
* that times out fails the deploy (safely: traffic stays put). A one-second
|
|
16
|
+
* period costs at most a second over the TCP probe — the first attempt usually
|
|
17
|
+
* lands before the server listens (measured on a throwaway service: healthy
|
|
18
|
+
* 1.3 s after start). The /health it hits is baselib's addHealth, a static
|
|
19
|
+
* reply in every app, so the probe proves the HTTP app answers, not that its
|
|
20
|
+
* dependencies are up.
|
|
21
|
+
*/
|
|
22
|
+
export declare function startupProbeArg(health: ServiceHealth): string | null;
|
|
4
23
|
export interface DeployOptions {
|
|
5
24
|
repoRoot: string;
|
|
6
25
|
runner: Runner;
|
package/dist/deploy/deploy.js
CHANGED
|
@@ -13,7 +13,7 @@ import { DEFAULT_ACCOUNT, loadConfig, loadHooks } from './config.js';
|
|
|
13
13
|
import { CommandFailure, must, mustJson } from './exec.js';
|
|
14
14
|
import { openEvidence, PhaseTimer } from './evidence.js';
|
|
15
15
|
import { acquireLock, clearHold, publishRetainedAssets, readHold, readReleaseRecord, releaseLock, verifyLock, writeReleaseRecord, } from './gcs.js';
|
|
16
|
-
import { consistentBaseSha, readServingState, SHA40, strayTrafficPin } from './plan.js';
|
|
16
|
+
import { consistentBaseSha, readServingState, servingRevisionName, SHA40, strayTrafficPin } from './plan.js';
|
|
17
17
|
import { writeDeployMarker } from './deploy-marker.js';
|
|
18
18
|
const RELEASE_DEADLINE_MS = 25 * 60_000;
|
|
19
19
|
const IMAGE_DIGEST = /@sha256:[0-9a-f]{64}$/;
|
|
@@ -23,6 +23,30 @@ const BROWSER_CRASH = /^\s*\[pid=\d+\]\[err\] Received signal \d+ /m;
|
|
|
23
23
|
export function testBrowserCrashed(output) {
|
|
24
24
|
return BROWSER_CRASH.test(output);
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The `--startup-probe` value every `services update` asserts: Cloud Run
|
|
28
|
+
* sends `GET <health path>` to each new instance and lets it take traffic
|
|
29
|
+
* only on a success, instead of its default check that the port merely
|
|
30
|
+
* accepts connections. null for `health.kind: 'none'` (the probe is left as
|
|
31
|
+
* configured). Omitting httpGet.port probes the container port.
|
|
32
|
+
*
|
|
33
|
+
* Timing: one attempt a second, each allowed one second, 240 attempts — the
|
|
34
|
+
* same four-minute window as Cloud Run's default TCP probe. 2026-11-21: the
|
|
35
|
+
* slowest serving revision fleet-wide became healthy in 5.2 s (corpus), about
|
|
36
|
+
* 2% of the window; the window is deliberately generous because a slow start
|
|
37
|
+
* that times out fails the deploy (safely: traffic stays put). A one-second
|
|
38
|
+
* period costs at most a second over the TCP probe — the first attempt usually
|
|
39
|
+
* lands before the server listens (measured on a throwaway service: healthy
|
|
40
|
+
* 1.3 s after start). The /health it hits is baselib's addHealth, a static
|
|
41
|
+
* reply in every app, so the probe proves the HTTP app answers, not that its
|
|
42
|
+
* dependencies are up.
|
|
43
|
+
*/
|
|
44
|
+
export function startupProbeArg(health) {
|
|
45
|
+
if (health.kind === 'none')
|
|
46
|
+
return null;
|
|
47
|
+
const path = health.path ?? '/health';
|
|
48
|
+
return `httpGet.path=${path},periodSeconds=1,timeoutSeconds=1,failureThreshold=240`;
|
|
49
|
+
}
|
|
26
50
|
const MAX_DIRTY_PATHS = 20;
|
|
27
51
|
/** The clean-worktree refusal, naming what made the tree dirty (`git status
|
|
28
52
|
* --porcelain` lines) so the reader need not go and look (2026-10-11: games'
|
|
@@ -278,6 +302,34 @@ export async function runDeploy(options) {
|
|
|
278
302
|
...gcloudBase, '--region', config.region, '--quiet', '--format=json',
|
|
279
303
|
'--to-revisions', `${revision}=100`,
|
|
280
304
|
]);
|
|
305
|
+
// Pin, then read the pin back: the read-back is the verdict, not gcloud's
|
|
306
|
+
// exit status. `update-traffic` waits for the whole service to become
|
|
307
|
+
// ready, which it does not while its newest revision is the one that
|
|
308
|
+
// failed, so a pin back to the serving revision exits nonzero (120)
|
|
309
|
+
// although it took effect (throwaway service pw-probe-test, 2026-11-21).
|
|
310
|
+
const pinAndConfirm = async (name, revision) => {
|
|
311
|
+
const result = await pinTraffic(name, revision);
|
|
312
|
+
const read = await runner('gcloud', [
|
|
313
|
+
'run', 'services', 'describe', name,
|
|
314
|
+
...gcloudBase, '--region', config.region, '--format=json',
|
|
315
|
+
]);
|
|
316
|
+
let confirmed = false;
|
|
317
|
+
if (read.code === 0) {
|
|
318
|
+
try {
|
|
319
|
+
const described = JSON.parse(read.stdout);
|
|
320
|
+
confirmed =
|
|
321
|
+
strayTrafficPin(described, revision) === null && servingRevisionName(name, described) === revision;
|
|
322
|
+
}
|
|
323
|
+
catch {
|
|
324
|
+
confirmed = false;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const note = confirmed && result.code !== 0
|
|
328
|
+
? ` (gcloud exited ${result.code} because the service stays not ready while its newest ` +
|
|
329
|
+
'revision is the failed one; the pin was read back and is correct)'
|
|
330
|
+
: '';
|
|
331
|
+
return { result, confirmed, note };
|
|
332
|
+
};
|
|
281
333
|
const repinCommand = (name, revision) => `gcloud run services update-traffic ${name} --project ${config.project} ` +
|
|
282
334
|
`--region ${config.region} --to-revisions ${revision}=100`;
|
|
283
335
|
// A failed `update-traffic` leaves the service's desired traffic pinned
|
|
@@ -292,11 +344,11 @@ export async function runDeploy(options) {
|
|
|
292
344
|
'because the deploy lock was lost (another deploy or rollback owns the service now)');
|
|
293
345
|
return;
|
|
294
346
|
}
|
|
295
|
-
const restored = await
|
|
347
|
+
const { result: restored, confirmed, note } = await pinAndConfirm(name, revision);
|
|
296
348
|
await evidence.save(`${name}-traffic-restore.json`, restored.stdout + restored.stderr);
|
|
297
|
-
if (
|
|
349
|
+
if (confirmed) {
|
|
298
350
|
log(`${name}: traffic switch to ${failedRevision} failed; restored the traffic pin to ` +
|
|
299
|
-
`${revision}, which still serves`);
|
|
351
|
+
`${revision}, which still serves${note}`);
|
|
300
352
|
}
|
|
301
353
|
else {
|
|
302
354
|
const tail = (restored.stderr.trim() || restored.stdout.trim()).slice(-500);
|
|
@@ -319,14 +371,14 @@ export async function runDeploy(options) {
|
|
|
319
371
|
// An earlier release's failed traffic switch whose pin was not put
|
|
320
372
|
// back (that run was killed, or its restore failed): `services
|
|
321
373
|
// update` would fail on it, so re-pin to what serves first.
|
|
322
|
-
const repinned = await
|
|
323
|
-
if (
|
|
374
|
+
const { result: repinned, confirmed, note } = await pinAndConfirm(service.name, current.revision);
|
|
375
|
+
if (!confirmed) {
|
|
324
376
|
const tail = (repinned.stderr.trim() || repinned.stdout.trim()).slice(-1500);
|
|
325
377
|
throw new CommandFailure(`${service.name}: traffic is pinned to ${stray} while ${current.revision} serves, and ` +
|
|
326
378
|
`re-pinning failed; every deploy fails until: ${repinCommand(service.name, current.revision)}\n${tail}`, repinned);
|
|
327
379
|
}
|
|
328
380
|
log(`${service.name}: traffic was pinned to ${stray} while ${current.revision} served ` +
|
|
329
|
-
`(left by an earlier failed release); re-pinned to ${current.revision}`);
|
|
381
|
+
`(left by an earlier failed release); re-pinned to ${current.revision}${note}`);
|
|
330
382
|
}
|
|
331
383
|
// One --update-env-vars with gcloud's alternate-delimiter form (^|^ …)
|
|
332
384
|
// so declared values may contain commas; '|' is rejected by validateConfig.
|
|
@@ -344,6 +396,9 @@ export async function runDeploy(options) {
|
|
|
344
396
|
.join(',');
|
|
345
397
|
updateArgs.push('--update-secrets', pairs);
|
|
346
398
|
}
|
|
399
|
+
const probe = startupProbeArg(service.health);
|
|
400
|
+
if (probe)
|
|
401
|
+
updateArgs.push('--startup-probe', probe);
|
|
347
402
|
const updated = await must(runner, 'gcloud', updateArgs, { timeoutMs: 10 * 60_000 });
|
|
348
403
|
await evidence.save(`${service.name}-update.json`, updated.stdout);
|
|
349
404
|
const after = await mustJson(runner, 'gcloud', [
|
|
@@ -359,10 +414,13 @@ export async function runDeploy(options) {
|
|
|
359
414
|
// here proves only the configuration and image import: Cloud Run starts
|
|
360
415
|
// no instance of a revision without traffic (notes-00156-dkv reported
|
|
361
416
|
// Ready 5 s before its first instance existed, and that instance exited
|
|
362
|
-
// at startup)
|
|
363
|
-
//
|
|
364
|
-
//
|
|
365
|
-
//
|
|
417
|
+
// at startup); gcloud's --deploy-health-check, documented as starting
|
|
418
|
+
// one instance, changed nothing at 0% traffic (2026-11-21, throwaway
|
|
419
|
+
// service). The boot check is `update-traffic` below: Cloud Run starts
|
|
420
|
+
// the revision and moves no traffic unless its startup probe (the HTTP
|
|
421
|
+
// /health probe asserted above) passes, for min-instance and
|
|
422
|
+
// scale-to-zero services alike (2026-11-20 investigation; a
|
|
423
|
+
// revision-tag URL is no alternative while ingress is
|
|
366
424
|
// internal-and-cloud-load-balancing, as for all but one service).
|
|
367
425
|
let ready = false;
|
|
368
426
|
let lastCondition = '';
|
package/dist/deploy/types.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export interface ServiceHealth {
|
|
|
6
6
|
* - none: no shared health check (app hook covers it) */
|
|
7
7
|
kind: 'public-canonical' | 'oidc-run-url' | 'oidc-audience' | 'none';
|
|
8
8
|
audience?: string;
|
|
9
|
+
/** Health path (default /health): the smoke's target, and since 3.71.0 the
|
|
10
|
+
* path of the HTTP startup probe every deploy asserts (kind 'none' leaves
|
|
11
|
+
* the probe alone). */
|
|
9
12
|
path?: string;
|
|
10
13
|
}
|
|
11
14
|
export interface ServiceConfig {
|
package/dist/llm/complete.js
CHANGED
|
@@ -5,6 +5,12 @@ const DEFAULT_MAX_TOKENS = 2048;
|
|
|
5
5
|
const DEFAULT_TEMPERATURE = 0.3;
|
|
6
6
|
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
7
7
|
const DEFAULT_THINKING_LEVELS = ['low', 'medium', 'high'];
|
|
8
|
+
/** Input media a model must accept to be tried: the requested model not
|
|
9
|
+
* taking one is rejected up front; a fallback not taking it is skipped. */
|
|
10
|
+
const MEDIA_GATES = [
|
|
11
|
+
{ kind: 'image', label: 'Image', accepts: (entry) => entry.supportsImages === true },
|
|
12
|
+
{ kind: 'audio', label: 'Audio', accepts: (entry) => entry.supportsAudio === true },
|
|
13
|
+
];
|
|
8
14
|
/**
|
|
9
15
|
* The effort level to send a model: none when the model has no effort
|
|
10
16
|
* control, otherwise the requested level clamped to the nearest one the
|
|
@@ -43,10 +49,14 @@ export async function llmComplete(request) {
|
|
|
43
49
|
// requested model not taking them is the caller's bug, so say so rather
|
|
44
50
|
// than silently answering from a fallback; fallbacks without image input
|
|
45
51
|
// are skipped in the loop below.
|
|
52
|
+
// Audio is gated the same way (only Gemini takes it).
|
|
46
53
|
const hasImages = (request.images?.length ?? 0) > 0;
|
|
47
|
-
|
|
54
|
+
const hasAudio = (request.audio?.length ?? 0) > 0;
|
|
55
|
+
for (const gate of MEDIA_GATES) {
|
|
56
|
+
if (!(gate.kind === 'image' ? hasImages : hasAudio) || gate.accepts(entry))
|
|
57
|
+
continue;
|
|
48
58
|
throw new LLMError({
|
|
49
|
-
message: `Model ${request.model} does not accept
|
|
59
|
+
message: `Model ${request.model} does not accept ${gate.kind} input. ${gate.label}-capable models: ${Object.keys(MODEL_REGISTRY).filter((m) => gate.accepts(MODEL_REGISTRY[m])).join(', ')}`,
|
|
50
60
|
provider: entry.provider,
|
|
51
61
|
model: entry.apiModelId,
|
|
52
62
|
isRetryable: false,
|
|
@@ -88,9 +98,10 @@ export async function llmComplete(request) {
|
|
|
88
98
|
const modelEntry = MODEL_REGISTRY[modelName];
|
|
89
99
|
if (!modelEntry)
|
|
90
100
|
continue;
|
|
91
|
-
|
|
101
|
+
const missing = MEDIA_GATES.find((gate) => (gate.kind === 'image' ? hasImages : hasAudio) && !gate.accepts(modelEntry));
|
|
102
|
+
if (missing) {
|
|
92
103
|
request.logger?.debug('llm.skip_provider', {
|
|
93
|
-
model: modelName, provider: modelEntry.provider, reason:
|
|
104
|
+
model: modelName, provider: modelEntry.provider, reason: `no ${missing.kind} input`,
|
|
94
105
|
});
|
|
95
106
|
continue;
|
|
96
107
|
}
|
|
@@ -108,6 +119,7 @@ export async function llmComplete(request) {
|
|
|
108
119
|
apiModelId: modelEntry.apiModelId,
|
|
109
120
|
prompt: request.prompt,
|
|
110
121
|
images: hasImages ? request.images : undefined,
|
|
122
|
+
audio: hasAudio ? request.audio : undefined,
|
|
111
123
|
systemPrompt: request.systemPrompt,
|
|
112
124
|
maxTokens,
|
|
113
125
|
temperature,
|
package/dist/llm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { llmComplete } from './complete.js';
|
|
2
2
|
export { MODEL_REGISTRY } from './models.js';
|
|
3
3
|
export type { ModelEntry } from './models.js';
|
|
4
|
-
export { LLMError, EFFORT_LEVELS, type Effort, type LLMRequest, type LLMResponse, type FailedAttempt, type FinishCategory, type ProviderName, type ApiKeys, type JsonSchema, type LLMImage, type LLMImageMediaType, } from './types.js';
|
|
4
|
+
export { LLMError, EFFORT_LEVELS, type Effort, type LLMRequest, type LLMResponse, type FailedAttempt, type FinishCategory, type ProviderName, type ApiKeys, type JsonSchema, type LLMImage, type LLMImageMediaType, type LLMAudio, type LLMAudioMediaType, } from './types.js';
|
package/dist/llm/models.d.ts
CHANGED
|
@@ -66,6 +66,14 @@ export interface ModelEntry {
|
|
|
66
66
|
* was verified live (test/helpers/llm.ts records the probe).
|
|
67
67
|
*/
|
|
68
68
|
supportsImages?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Whether this model accepts audio input (`LLMRequest.audio`). Defaults to
|
|
71
|
+
* `false`, gated exactly like `supportsImages`. Set only on models whose
|
|
72
|
+
* audio handling was verified live (test/helpers/llm.ts records the probe):
|
|
73
|
+
* the Gemini 3.x entries. No Anthropic or OpenAI model in the registry
|
|
74
|
+
* takes audio.
|
|
75
|
+
*/
|
|
76
|
+
supportsAudio?: boolean;
|
|
69
77
|
}
|
|
70
78
|
/**
|
|
71
79
|
* Output budget below which a `thinksByDefault` model is considered at risk of
|
package/dist/llm/models.js
CHANGED
|
@@ -35,6 +35,7 @@ export const MODEL_REGISTRY = {
|
|
|
35
35
|
provider: 'gemini',
|
|
36
36
|
apiModelId: 'gemini-3.5-flash-lite',
|
|
37
37
|
supportsImages: true,
|
|
38
|
+
supportsAudio: true,
|
|
38
39
|
fallbacks: ['gpt-5.6-luna', 'claude-haiku-4-5'],
|
|
39
40
|
// Default thinking_level is `minimal` — reasoning overhead is negligible,
|
|
40
41
|
// so no `thinksByDefault` headroom warning.
|
|
@@ -47,6 +48,7 @@ export const MODEL_REGISTRY = {
|
|
|
47
48
|
provider: 'gemini',
|
|
48
49
|
apiModelId: 'gemini-3.6-flash',
|
|
49
50
|
supportsImages: true,
|
|
51
|
+
supportsAudio: true,
|
|
50
52
|
fallbacks: ['gpt-5.6-luna', 'claude-haiku-4-5'],
|
|
51
53
|
// Thinks by default (thinking_level defaults to `medium`); reasoning
|
|
52
54
|
// tokens are billed as output and count against maxOutputTokens.
|
|
@@ -83,6 +85,7 @@ export const MODEL_REGISTRY = {
|
|
|
83
85
|
provider: 'gemini',
|
|
84
86
|
apiModelId: 'gemini-3.1-flash-lite',
|
|
85
87
|
supportsImages: true,
|
|
88
|
+
supportsAudio: true,
|
|
86
89
|
fallbacks: ['claude-sonnet-4-6'],
|
|
87
90
|
supportsEffort: true,
|
|
88
91
|
},
|
|
@@ -90,6 +93,7 @@ export const MODEL_REGISTRY = {
|
|
|
90
93
|
provider: 'gemini',
|
|
91
94
|
apiModelId: 'gemini-3-flash-preview',
|
|
92
95
|
supportsImages: true,
|
|
96
|
+
supportsAudio: true,
|
|
93
97
|
fallbacks: ['claude-haiku-4-5', 'gpt-5.6-luna'],
|
|
94
98
|
supportsEffort: true,
|
|
95
99
|
thinkingLevels: ['minimal', 'low', 'medium', 'high'],
|
|
@@ -214,6 +218,7 @@ export const MODEL_REGISTRY = {
|
|
|
214
218
|
provider: 'gemini',
|
|
215
219
|
apiModelId: 'gemini-3.1-pro-preview',
|
|
216
220
|
supportsImages: true,
|
|
221
|
+
supportsAudio: true,
|
|
217
222
|
fallbacks: ['claude-opus-5-5', 'gpt-5.6-sol'],
|
|
218
223
|
// Thinks by default (thinking_level defaults to `high`).
|
|
219
224
|
thinksByDefault: true,
|
|
@@ -65,6 +65,7 @@ export const geminiProvider = {
|
|
|
65
65
|
provider: 'gemini', model: request.apiModelId, endpoint,
|
|
66
66
|
...(request.callSite ? { callSite: request.callSite } : {}),
|
|
67
67
|
...(request.images ? { images: request.images.length } : {}),
|
|
68
|
+
...(request.audio ? { audio: request.audio.length } : {}),
|
|
68
69
|
});
|
|
69
70
|
const startTime = Date.now();
|
|
70
71
|
const generationConfig = {
|
|
@@ -96,10 +97,11 @@ export const geminiProvider = {
|
|
|
96
97
|
generationConfig.thinkingConfig = { thinkingBudget: request.thinkingBudget };
|
|
97
98
|
}
|
|
98
99
|
const body = {
|
|
99
|
-
// Images go as inline-data parts ahead of the prompt's text part.
|
|
100
|
+
// Images, then audio, go as inline-data parts ahead of the prompt's text part.
|
|
100
101
|
contents: [{
|
|
101
102
|
parts: [
|
|
102
103
|
...(request.images ?? []).map((image) => ({ inlineData: { mimeType: image.mediaType, data: image.data } })),
|
|
104
|
+
...(request.audio ?? []).map((clip) => ({ inlineData: { mimeType: clip.mediaType, data: clip.data } })),
|
|
103
105
|
{ text: request.prompt },
|
|
104
106
|
],
|
|
105
107
|
}],
|
package/dist/llm/types.d.ts
CHANGED
|
@@ -21,6 +21,17 @@ export interface LLMImage {
|
|
|
21
21
|
mediaType: LLMImageMediaType;
|
|
22
22
|
data: string;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Audio media types Gemini accepted in the live probe of 2026-11-21 (Ogg with
|
|
26
|
+
* or without a `codecs=opus` parameter, MP3, MP4/AAC, WAV): see
|
|
27
|
+
* test/helpers/llm.ts. Pass the bare type; parameters are not needed.
|
|
28
|
+
*/
|
|
29
|
+
export type LLMAudioMediaType = 'audio/ogg' | 'audio/mpeg' | 'audio/mp4' | 'audio/wav';
|
|
30
|
+
/** A sound recording sent beside the prompt: raw base64, no `data:` URL prefix. */
|
|
31
|
+
export interface LLMAudio {
|
|
32
|
+
mediaType: LLMAudioMediaType;
|
|
33
|
+
data: string;
|
|
34
|
+
}
|
|
24
35
|
/** Request to llmComplete(). */
|
|
25
36
|
export interface LLMRequest {
|
|
26
37
|
/** Model name from the registry (e.g. 'claude-sonnet-4-6', 'gemini-2.5-flash'). */
|
|
@@ -34,6 +45,14 @@ export interface LLMRequest {
|
|
|
34
45
|
* call is rejected up front), and failover skips fallbacks that are not.
|
|
35
46
|
*/
|
|
36
47
|
images?: LLMImage[];
|
|
48
|
+
/**
|
|
49
|
+
* Audio for the model to listen to beside the prompt (a voice message to
|
|
50
|
+
* transcribe), placed before the prompt text like `images`. Gated the same
|
|
51
|
+
* way, by the registry's `supportsAudio`: only Gemini models take it, so a
|
|
52
|
+
* request with audio has no cross-provider failover — a Gemini outage
|
|
53
|
+
* fails the call, and the caller retries later.
|
|
54
|
+
*/
|
|
55
|
+
audio?: LLMAudio[];
|
|
37
56
|
/** Optional system prompt. */
|
|
38
57
|
systemPrompt?: string;
|
|
39
58
|
/** Max output tokens. Default: 2048. */
|
|
@@ -211,6 +230,8 @@ export interface ProviderCallRequest {
|
|
|
211
230
|
prompt: string;
|
|
212
231
|
/** Present and non-empty only for a `supportsImages` model (gated in complete.ts). */
|
|
213
232
|
images?: LLMImage[];
|
|
233
|
+
/** Present and non-empty only for a `supportsAudio` model (gated in complete.ts). */
|
|
234
|
+
audio?: LLMAudio[];
|
|
214
235
|
systemPrompt?: string;
|
|
215
236
|
maxTokens: number;
|
|
216
237
|
temperature: number;
|
package/package.json
CHANGED