@assemblyline-agents/audio 3.0.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/LICENSE +21 -0
- package/README.md +23 -0
- package/dist/caf.d.ts +6 -0
- package/dist/caf.d.ts.map +1 -0
- package/dist/caf.js +60 -0
- package/dist/caf.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/openrouter.d.ts +44 -0
- package/dist/openrouter.d.ts.map +1 -0
- package/dist/openrouter.js +232 -0
- package/dist/openrouter.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Assembly Line contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# `@assemblyline-agents/audio`
|
|
2
|
+
|
|
3
|
+
Framework-level pre-model audio processing for Assembly Line agents.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { defineGateway } from "@assemblyline-agents/core";
|
|
7
|
+
import { openRouterAudioTranscription } from "@assemblyline-agents/audio";
|
|
8
|
+
|
|
9
|
+
export default defineGateway({
|
|
10
|
+
media: openRouterAudioTranscription()
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Set `OPENROUTER_API_KEY`. The default model is
|
|
15
|
+
`openai/whisper-large-v3-turbo`; override it with
|
|
16
|
+
`OPENROUTER_AUDIO_TRANSCRIPTION_MODEL` or gateway options. Successful
|
|
17
|
+
transcripts are stored in the configured private blob adapter and reused by
|
|
18
|
+
attachment hash. Transcript text is supplied to the model as untrusted derived
|
|
19
|
+
context and is not copied into run audit events.
|
|
20
|
+
|
|
21
|
+
Apple CAF voice notes are converted to M4A with the package's bounded FFmpeg
|
|
22
|
+
binary before they are sent to OpenRouter. The original private attachment is
|
|
23
|
+
not modified. M4A and the other provider-supported formats are sent unchanged.
|
package/dist/caf.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caf.d.ts","sourceRoot":"","sources":["../src/caf.ts"],"names":[],"mappings":"AAWA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMtE;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC9C,OAAO,CAAC,UAAU,CAAC,CAwCrB"}
|
package/dist/caf.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
const ffmpegPath = createRequire(import.meta.url)("ffmpeg-static");
|
|
8
|
+
const execFileAsync = promisify(execFile);
|
|
9
|
+
const MAX_FFMPEG_LOG_BYTES = 64 * 1024;
|
|
10
|
+
export function isCafAudio(filename, mimeType) {
|
|
11
|
+
const normalized = mimeType.toLowerCase().split(";")[0]?.trim();
|
|
12
|
+
return filename.toLowerCase().endsWith(".caf")
|
|
13
|
+
|| normalized === "audio/x-caf"
|
|
14
|
+
|| normalized === "audio/caf"
|
|
15
|
+
|| normalized === "audio/vnd.apple.caf";
|
|
16
|
+
}
|
|
17
|
+
export async function convertCafToM4a(bytes, limits) {
|
|
18
|
+
if (!ffmpegPath)
|
|
19
|
+
throw new Error("CAF voice-note conversion is unavailable on this platform.");
|
|
20
|
+
if (bytes.byteLength > limits.maxBytes) {
|
|
21
|
+
throw new Error("The attachment exceeded the media processor size limit.");
|
|
22
|
+
}
|
|
23
|
+
const directory = await mkdtemp(join(tmpdir(), "assembly-line-caf-"));
|
|
24
|
+
const inputPath = join(directory, "input.caf");
|
|
25
|
+
const outputPath = join(directory, "output.m4a");
|
|
26
|
+
try {
|
|
27
|
+
await writeFile(inputPath, bytes);
|
|
28
|
+
await execFileAsync(ffmpegPath, [
|
|
29
|
+
"-nostdin",
|
|
30
|
+
"-hide_banner",
|
|
31
|
+
"-loglevel", "error",
|
|
32
|
+
"-y",
|
|
33
|
+
"-f", "caf",
|
|
34
|
+
"-i", inputPath,
|
|
35
|
+
"-map", "0:a:0",
|
|
36
|
+
"-vn",
|
|
37
|
+
"-map_metadata", "-1",
|
|
38
|
+
"-c:a", "aac",
|
|
39
|
+
"-b:a", "96k",
|
|
40
|
+
"-threads", "1",
|
|
41
|
+
"-movflags", "+faststart",
|
|
42
|
+
"-fs", String(limits.maxBytes),
|
|
43
|
+
outputPath
|
|
44
|
+
], {
|
|
45
|
+
timeout: limits.timeoutMs,
|
|
46
|
+
maxBuffer: MAX_FFMPEG_LOG_BYTES,
|
|
47
|
+
windowsHide: true
|
|
48
|
+
});
|
|
49
|
+
const outputSize = (await stat(outputPath)).size;
|
|
50
|
+
if (outputSize === 0)
|
|
51
|
+
throw new Error("CAF voice-note conversion returned empty audio.");
|
|
52
|
+
if (outputSize > limits.maxBytes)
|
|
53
|
+
throw new Error("The converted voice note exceeded the size limit.");
|
|
54
|
+
return new Uint8Array(await readFile(outputPath));
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
await rm(directory, { recursive: true, force: true });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=caf.js.map
|
package/dist/caf.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caf.js","sourceRoot":"","sources":["../src/caf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,eAAe,CAAkB,CAAC;AACpF,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC1C,MAAM,oBAAoB,GAAG,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KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC9B,UAAU;SACX,EAAE;YACD,OAAO,EAAE,MAAM,CAAC,SAAS;YACzB,SAAS,EAAE,oBAAoB;YAC/B,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;QACjD,IAAI,UAAU,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACzF,IAAI,UAAU,GAAG,MAAM,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACvG,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IACpD,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ProviderModule } from "@assemblyline-agents/core";
|
|
2
|
+
import { type OpenRouterAudioTranscriberOptions } from "./openrouter.js";
|
|
3
|
+
export { OpenRouterAudioTranscriber, type OpenRouterAudioTranscriberOptions, type OpenRouterAudioTranscriptionResult } from "./openrouter.js";
|
|
4
|
+
export declare const OPENROUTER_AUDIO_TRANSCRIPTION_PROVIDER_METADATA: {
|
|
5
|
+
kind: string;
|
|
6
|
+
role: "media";
|
|
7
|
+
packageName: string;
|
|
8
|
+
requiredEnv: string[];
|
|
9
|
+
optionalEnv: string[];
|
|
10
|
+
capabilities: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare function openRouterAudioTranscription(options?: OpenRouterAudioTranscriberOptions): import("@assemblyline-agents/core").AdapterDefinition;
|
|
13
|
+
export declare const assemblyLineProvider: ProviderModule;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAA8B,KAAK,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAErG,OAAO,EACL,0BAA0B,EAC1B,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACxC,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,gDAAgD;;;;;;;CAc5D,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,OAAO,GAAE,iCAAsC,yDAM3F;AAED,eAAO,MAAM,oBAAoB,EAAE,cAalC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { adapter } from "@assemblyline-agents/core";
|
|
2
|
+
import { OpenRouterAudioTranscriber } from "./openrouter.js";
|
|
3
|
+
export { OpenRouterAudioTranscriber } from "./openrouter.js";
|
|
4
|
+
export const OPENROUTER_AUDIO_TRANSCRIPTION_PROVIDER_METADATA = {
|
|
5
|
+
kind: "openrouter-audio-transcription",
|
|
6
|
+
role: "media",
|
|
7
|
+
packageName: "@assemblyline-agents/audio",
|
|
8
|
+
requiredEnv: ["OPENROUTER_API_KEY"],
|
|
9
|
+
optionalEnv: [
|
|
10
|
+
"OPENROUTER_AUDIO_TRANSCRIPTION_MODEL",
|
|
11
|
+
"OPENROUTER_AUDIO_TRANSCRIPTION_FALLBACK_MODELS",
|
|
12
|
+
"OPENROUTER_AUDIO_TRANSCRIPTION_LANGUAGE",
|
|
13
|
+
"ASSEMBLY_LINE_AUDIO_TRANSCRIPTION_MAX_BYTES",
|
|
14
|
+
"ASSEMBLY_LINE_AUDIO_TRANSCRIPTION_MAX_ATTACHMENTS",
|
|
15
|
+
"ASSEMBLY_LINE_AUDIO_TRANSCRIPTION_TIMEOUT_MS"
|
|
16
|
+
],
|
|
17
|
+
capabilities: ["audio-transcription", "attachment-context", "durable-transcript-cache"]
|
|
18
|
+
};
|
|
19
|
+
export function openRouterAudioTranscription(options = {}) {
|
|
20
|
+
return adapter("openrouter-audio-transcription", options, { package: "@assemblyline-agents/audio" });
|
|
21
|
+
}
|
|
22
|
+
export const assemblyLineProvider = {
|
|
23
|
+
providers: [
|
|
24
|
+
{
|
|
25
|
+
metadata: OPENROUTER_AUDIO_TRANSCRIPTION_PROVIDER_METADATA,
|
|
26
|
+
create(ctx) {
|
|
27
|
+
return new OpenRouterAudioTranscriber({
|
|
28
|
+
options: ctx.options,
|
|
29
|
+
env: ctx.env,
|
|
30
|
+
fetch: ctx.fetch
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAwC,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,0BAA0B,EAA0C,MAAM,iBAAiB,CAAC;AAErG,OAAO,EACL,0BAA0B,EAG3B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,gDAAgD,GAAG;IAC9D,IAAI,EAAE,gCAAgC;IACtC,IAAI,EAAE,OAAgB;IACtB,WAAW,EAAE,4BAA4B;IACzC,WAAW,EAAE,CAAC,oBAAoB,CAAC;IACnC,WAAW,EAAE;QACX,sCAAsC;QACtC,gDAAgD;QAChD,yCAAyC;QACzC,6CAA6C;QAC7C,mDAAmD;QACnD,8CAA8C;KAC/C;IACD,YAAY,EAAE,CAAC,qBAAqB,EAAE,oBAAoB,EAAE,0BAA0B,CAAC;CACxF,CAAC;AAEF,MAAM,UAAU,4BAA4B,CAAC,UAA6C,EAAE;IAC1F,OAAO,OAAO,CACZ,gCAAgC,EAChC,OAAgC,EAChC,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAmB;IAClD,SAAS,EAAE;QACT;YACE,QAAQ,EAAE,gDAAgD;YAC1D,MAAM,CAAC,GAAG;gBACR,OAAO,IAAI,0BAA0B,CAAC;oBACpC,OAAO,EAAE,GAAG,CAAC,OAA4C;oBACzD,GAAG,EAAE,GAAG,CAAC,GAAG;oBACZ,KAAK,EAAE,GAAG,CAAC,KAAK;iBACjB,CAAC,CAAC;YACL,CAAC;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { JsonObject } from "@assemblyline-agents/core";
|
|
2
|
+
import type { MediaProcessor, MediaProcessorAttachment, MediaProcessorInput, MediaProcessorResult } from "@assemblyline-agents/runtime";
|
|
3
|
+
export interface OpenRouterAudioTranscriberOptions {
|
|
4
|
+
model?: string;
|
|
5
|
+
fallbackModels?: string[];
|
|
6
|
+
language?: string;
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
referer?: string;
|
|
10
|
+
modelMetadataKey?: string;
|
|
11
|
+
maxBytes?: number;
|
|
12
|
+
maxAttachments?: number;
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
maxResponseBytes?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface OpenRouterAudioTranscriptionResult {
|
|
17
|
+
text: string;
|
|
18
|
+
model: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class OpenRouterAudioTranscriber implements MediaProcessor {
|
|
21
|
+
readonly id = "openrouter-audio-transcription";
|
|
22
|
+
readonly maxAttachments: number;
|
|
23
|
+
readonly maxBytes: number;
|
|
24
|
+
private readonly options;
|
|
25
|
+
private readonly env;
|
|
26
|
+
private readonly fetch;
|
|
27
|
+
constructor(input?: {
|
|
28
|
+
options?: OpenRouterAudioTranscriberOptions;
|
|
29
|
+
env?: Record<string, string | undefined>;
|
|
30
|
+
fetch?: typeof fetch;
|
|
31
|
+
});
|
|
32
|
+
matches(input: MediaProcessorAttachment): boolean;
|
|
33
|
+
cacheKey(input: MediaProcessorAttachment): string;
|
|
34
|
+
process(input: MediaProcessorInput): Promise<MediaProcessorResult>;
|
|
35
|
+
failureContext(input: MediaProcessorAttachment, error: string): JsonObject;
|
|
36
|
+
private failed;
|
|
37
|
+
private transcribe;
|
|
38
|
+
private models;
|
|
39
|
+
private language;
|
|
40
|
+
private endpoint;
|
|
41
|
+
private timeoutMs;
|
|
42
|
+
private maxResponseBytes;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=openrouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openrouter.d.ts","sourceRoot":"","sources":["../src/openrouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EACV,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAYtC,MAAM,WAAW,iCAAiC;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,0BAA2B,YAAW,cAAc;IAC/D,QAAQ,CAAC,EAAE,oCAAoC;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqC;IACzD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;gBAEzB,KAAK,GAAE;QACjB,OAAO,CAAC,EAAE,iCAAiC,CAAC;QAC5C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;QACzC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;KACjB;IAoBN,OAAO,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO;IAMjD,QAAQ,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM;IAS3C,OAAO,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA+BxE,cAAc,CAAC,KAAK,EAAE,wBAAwB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI1E,OAAO,CAAC,MAAM;YAQA,UAAU;IA8CxB,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,gBAAgB;CAGzB"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { convertCafToM4a, isCafAudio } from "./caf.js";
|
|
2
|
+
const DEFAULT_ENDPOINT = "https://openrouter.ai/api/v1/audio/transcriptions";
|
|
3
|
+
const DEFAULT_MODEL = "openai/whisper-large-v3-turbo";
|
|
4
|
+
const DEFAULT_FALLBACK_MODELS = ["openai/whisper-large-v3", "openai/whisper-1"];
|
|
5
|
+
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
6
|
+
const DEFAULT_MAX_RESPONSE_BYTES = 512 * 1024;
|
|
7
|
+
const DEFAULT_MAX_AUDIO_BYTES = 25 * 1024 * 1024;
|
|
8
|
+
const DEFAULT_MAX_AUDIO_ATTACHMENTS = 4;
|
|
9
|
+
const CAF_PREPROCESSING_VERSION = "caf-to-m4a-v1";
|
|
10
|
+
export class OpenRouterAudioTranscriber {
|
|
11
|
+
id = "openrouter-audio-transcription";
|
|
12
|
+
maxAttachments;
|
|
13
|
+
maxBytes;
|
|
14
|
+
options;
|
|
15
|
+
env;
|
|
16
|
+
fetch;
|
|
17
|
+
constructor(input = {}) {
|
|
18
|
+
this.options = input.options ?? {};
|
|
19
|
+
this.env = input.env ?? {};
|
|
20
|
+
this.fetch = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
21
|
+
this.maxAttachments = boundedInteger(this.options.maxAttachments, envNumber(this.env, "ASSEMBLY_LINE_AUDIO_TRANSCRIPTION_MAX_ATTACHMENTS", "OPENROUTER_AUDIO_TRANSCRIPTION_MAX_ATTACHMENTS"), DEFAULT_MAX_AUDIO_ATTACHMENTS, 1, 10);
|
|
22
|
+
this.maxBytes = boundedInteger(this.options.maxBytes, envNumber(this.env, "ASSEMBLY_LINE_AUDIO_TRANSCRIPTION_MAX_BYTES", "OPENROUTER_AUDIO_TRANSCRIPTION_MAX_BYTES"), DEFAULT_MAX_AUDIO_BYTES, 1, 50 * 1024 * 1024);
|
|
23
|
+
}
|
|
24
|
+
matches(input) {
|
|
25
|
+
if (input.mimeType.startsWith("audio/"))
|
|
26
|
+
return true;
|
|
27
|
+
if (stringValue(input.attachment.kind).toLowerCase() === "audio")
|
|
28
|
+
return true;
|
|
29
|
+
return /\.(?:aac|caf|flac|m4a|mp3|mp4|ogg|wav|webm)$/iu.test(input.filename);
|
|
30
|
+
}
|
|
31
|
+
cacheKey(input) {
|
|
32
|
+
return JSON.stringify({
|
|
33
|
+
endpoint: this.endpoint(),
|
|
34
|
+
models: this.models(input),
|
|
35
|
+
language: this.language() || null,
|
|
36
|
+
preprocessing: isCafAudio(input.filename, input.mimeType) ? CAF_PREPROCESSING_VERSION : null
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async process(input) {
|
|
40
|
+
if (input.bytes.byteLength === 0)
|
|
41
|
+
return this.failed(input, "The voice note was empty.");
|
|
42
|
+
const apiKey = this.env.OPENROUTER_API_KEY?.trim();
|
|
43
|
+
if (!apiKey)
|
|
44
|
+
return this.failed(input, "Voice transcription is not configured.");
|
|
45
|
+
try {
|
|
46
|
+
const result = await this.transcribe(input, apiKey);
|
|
47
|
+
return {
|
|
48
|
+
status: "processed",
|
|
49
|
+
context: {
|
|
50
|
+
audioTranscriptions: [{
|
|
51
|
+
status: "transcribed",
|
|
52
|
+
source: "untrusted_user_audio",
|
|
53
|
+
attachmentId: stringValue(input.attachment.id) || input.filename,
|
|
54
|
+
filename: input.filename,
|
|
55
|
+
mimeType: input.mimeType,
|
|
56
|
+
model: result.model,
|
|
57
|
+
text: result.text
|
|
58
|
+
}]
|
|
59
|
+
},
|
|
60
|
+
audit: {
|
|
61
|
+
provider: "openrouter",
|
|
62
|
+
model: result.model,
|
|
63
|
+
sourceSize: input.bytes.byteLength
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
return this.failed(input, safeError(error));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
failureContext(input, error) {
|
|
72
|
+
return failedContext(input, safeError(error));
|
|
73
|
+
}
|
|
74
|
+
failed(input, error) {
|
|
75
|
+
return {
|
|
76
|
+
status: "failed",
|
|
77
|
+
context: failedContext(input, error),
|
|
78
|
+
audit: { provider: "openrouter", reason: error }
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async transcribe(input, apiKey) {
|
|
82
|
+
const models = this.models(input);
|
|
83
|
+
const caf = isCafAudio(input.filename, input.mimeType);
|
|
84
|
+
const bytes = caf
|
|
85
|
+
? await convertCafToM4a(input.bytes, { maxBytes: this.maxBytes, timeoutMs: this.timeoutMs() })
|
|
86
|
+
: input.bytes;
|
|
87
|
+
const format = caf ? "m4a" : audioFormat(input.filename, input.mimeType);
|
|
88
|
+
let lastError;
|
|
89
|
+
for (const model of models) {
|
|
90
|
+
try {
|
|
91
|
+
const response = await this.fetch(this.endpoint(), {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: {
|
|
94
|
+
authorization: `Bearer ${apiKey}`,
|
|
95
|
+
"content-type": "application/json",
|
|
96
|
+
"http-referer": this.options.referer ?? this.env.ASSEMBLY_LINE_PUBLIC_URL ?? this.env.APP_PUBLIC_URL ?? "https://assembly-line.local",
|
|
97
|
+
"x-openrouter-title": this.options.title ?? "Assembly Line audio transcription"
|
|
98
|
+
},
|
|
99
|
+
body: JSON.stringify({
|
|
100
|
+
model,
|
|
101
|
+
input_audio: {
|
|
102
|
+
data: Buffer.from(bytes).toString("base64"),
|
|
103
|
+
format
|
|
104
|
+
},
|
|
105
|
+
...(this.language() ? { language: this.language() } : {})
|
|
106
|
+
}),
|
|
107
|
+
signal: AbortSignal.timeout(this.timeoutMs())
|
|
108
|
+
});
|
|
109
|
+
const payload = await readJson(response, this.maxResponseBytes());
|
|
110
|
+
if (!response.ok) {
|
|
111
|
+
const error = new Error(`OpenRouter transcription failed with HTTP ${response.status}.`);
|
|
112
|
+
if (!retryableStatus(response.status))
|
|
113
|
+
throw error;
|
|
114
|
+
lastError = error;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const text = isRecord(payload) && typeof payload.text === "string" ? payload.text.trim() : "";
|
|
118
|
+
if (!text)
|
|
119
|
+
throw new Error("OpenRouter returned an empty transcription.");
|
|
120
|
+
return { text, model };
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
throw lastError ?? new Error("OpenRouter could not transcribe the audio attachment.");
|
|
127
|
+
}
|
|
128
|
+
models(input) {
|
|
129
|
+
const metadataModel = this.options.modelMetadataKey
|
|
130
|
+
? stringValue(input.metadata[this.options.modelMetadataKey])
|
|
131
|
+
: "";
|
|
132
|
+
const primary = metadataModel || this.options.model || this.env.OPENROUTER_AUDIO_TRANSCRIPTION_MODEL || DEFAULT_MODEL;
|
|
133
|
+
const configuredFallbacks = this.options.fallbackModels ?? splitModels(this.env.OPENROUTER_AUDIO_TRANSCRIPTION_FALLBACK_MODELS);
|
|
134
|
+
const fallbacks = configuredFallbacks.length > 0 ? configuredFallbacks : DEFAULT_FALLBACK_MODELS;
|
|
135
|
+
return [...new Set([primary, ...fallbacks].map(stripOpenRouterPrefix).map((value) => value.trim()).filter(Boolean))];
|
|
136
|
+
}
|
|
137
|
+
language() {
|
|
138
|
+
return this.options.language?.trim() || this.env.OPENROUTER_AUDIO_TRANSCRIPTION_LANGUAGE?.trim() || "";
|
|
139
|
+
}
|
|
140
|
+
endpoint() {
|
|
141
|
+
return this.options.endpoint?.trim() || DEFAULT_ENDPOINT;
|
|
142
|
+
}
|
|
143
|
+
timeoutMs() {
|
|
144
|
+
return boundedInteger(this.options.timeoutMs, envNumber(this.env, "ASSEMBLY_LINE_AUDIO_TRANSCRIPTION_TIMEOUT_MS", "OPENROUTER_AUDIO_TRANSCRIPTION_TIMEOUT_MS"), DEFAULT_TIMEOUT_MS, 5_000, 180_000);
|
|
145
|
+
}
|
|
146
|
+
maxResponseBytes() {
|
|
147
|
+
return boundedInteger(this.options.maxResponseBytes, undefined, DEFAULT_MAX_RESPONSE_BYTES, 1_024, 2 * 1024 * 1024);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function failedContext(input, error) {
|
|
151
|
+
return {
|
|
152
|
+
audioTranscriptions: [{
|
|
153
|
+
status: "failed",
|
|
154
|
+
source: "untrusted_user_audio",
|
|
155
|
+
attachmentId: stringValue(input.attachment.id) || input.filename,
|
|
156
|
+
filename: input.filename,
|
|
157
|
+
mimeType: input.mimeType,
|
|
158
|
+
error
|
|
159
|
+
}]
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function audioFormat(filename, mimeType) {
|
|
163
|
+
const extension = filename.toLowerCase().split(".").at(-1) ?? "";
|
|
164
|
+
if (["wav", "mp3", "flac", "m4a", "ogg", "webm", "aac"].includes(extension))
|
|
165
|
+
return extension;
|
|
166
|
+
if (extension === "mp4")
|
|
167
|
+
return "m4a";
|
|
168
|
+
const normalized = mimeType.toLowerCase().split(";")[0]?.trim();
|
|
169
|
+
if (normalized === "audio/wav" || normalized === "audio/x-wav")
|
|
170
|
+
return "wav";
|
|
171
|
+
if (normalized === "audio/mpeg" || normalized === "audio/mp3")
|
|
172
|
+
return "mp3";
|
|
173
|
+
if (normalized === "audio/flac")
|
|
174
|
+
return "flac";
|
|
175
|
+
if (normalized === "audio/mp4" || normalized === "audio/x-m4a")
|
|
176
|
+
return "m4a";
|
|
177
|
+
if (normalized === "audio/ogg")
|
|
178
|
+
return "ogg";
|
|
179
|
+
if (normalized === "audio/webm")
|
|
180
|
+
return "webm";
|
|
181
|
+
if (normalized === "audio/aac")
|
|
182
|
+
return "aac";
|
|
183
|
+
throw new Error(`Unsupported voice-note format: ${mimeType || filename || "unknown"}.`);
|
|
184
|
+
}
|
|
185
|
+
async function readJson(response, maxBytes) {
|
|
186
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
187
|
+
if (bytes.byteLength > maxBytes)
|
|
188
|
+
throw new Error("OpenRouter transcription response was too large.");
|
|
189
|
+
try {
|
|
190
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return {};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function boundedInteger(first, second, fallback, min, max) {
|
|
197
|
+
for (const value of [first, second]) {
|
|
198
|
+
if (Number.isInteger(value) && value !== undefined && value >= min && value <= max)
|
|
199
|
+
return value;
|
|
200
|
+
}
|
|
201
|
+
return fallback;
|
|
202
|
+
}
|
|
203
|
+
function envNumber(env, primary, alias) {
|
|
204
|
+
const raw = env[primary] ?? env[alias];
|
|
205
|
+
if (!raw?.trim())
|
|
206
|
+
return undefined;
|
|
207
|
+
const parsed = Number(raw);
|
|
208
|
+
return Number.isInteger(parsed) ? parsed : undefined;
|
|
209
|
+
}
|
|
210
|
+
function splitModels(value) {
|
|
211
|
+
return value?.split(",").map((model) => model.trim()).filter(Boolean) ?? [];
|
|
212
|
+
}
|
|
213
|
+
function retryableStatus(status) {
|
|
214
|
+
return status === 408 || status === 409 || status === 425 || status === 429 || status >= 500;
|
|
215
|
+
}
|
|
216
|
+
function stripOpenRouterPrefix(model) {
|
|
217
|
+
return model.trim().replace(/^openrouter\//u, "");
|
|
218
|
+
}
|
|
219
|
+
function safeError(error) {
|
|
220
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
221
|
+
if (/not configured|unsupported|empty|unavailable|size limit|exceeded|HTTP \d{3}|too large/iu.test(message)) {
|
|
222
|
+
return message.slice(0, 240);
|
|
223
|
+
}
|
|
224
|
+
return "Voice transcription failed before the agent turn started.";
|
|
225
|
+
}
|
|
226
|
+
function stringValue(value) {
|
|
227
|
+
return typeof value === "string" ? value.trim() : "";
|
|
228
|
+
}
|
|
229
|
+
function isRecord(value) {
|
|
230
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=openrouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openrouter.js","sourceRoot":"","sources":["../src/openrouter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,gBAAgB,GAAG,mDAAmD,CAAC;AAC7E,MAAM,aAAa,GAAG,+BAA+B,CAAC;AACtD,MAAM,uBAAuB,GAAG,CAAC,yBAAyB,EAAE,kBAAkB,CAAC,CAAC;AAChF,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,0BAA0B,GAAG,GAAG,GAAG,IAAI,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CAAC;AAED,SAAS,eAAe,CAAC,MAAc;IACrC,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC;AAC/F,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,IAAI,yFAAyF,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5G,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,2DAA2D,CAAC;AACrE,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@assemblyline-agents/audio",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"default": "./dist/index.js"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22.19.0"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"ffmpeg-static": "^5.3.0",
|
|
16
|
+
"@assemblyline-agents/runtime": "3.0.0",
|
|
17
|
+
"@assemblyline-agents/core": "3.0.0"
|
|
18
|
+
},
|
|
19
|
+
"description": "Pre-model audio processing adapters for Assembly Line agents.",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/jasonbadeaux/assembly-line.git",
|
|
27
|
+
"directory": "packages/audio"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/jasonbadeaux/assembly-line/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/jasonbadeaux/assembly-line#readme",
|
|
33
|
+
"author": "Assembly Line contributors",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"assembly-line",
|
|
36
|
+
"agents",
|
|
37
|
+
"audio",
|
|
38
|
+
"speech-to-text",
|
|
39
|
+
"openrouter"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -p tsconfig.json",
|
|
46
|
+
"check": "tsc -p tsconfig.json --noEmit"
|
|
47
|
+
}
|
|
48
|
+
}
|