@framers/agentos-ext-voice-synthesis 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -8
- package/dist/index.d.ts +17 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -7
- package/dist/index.js.map +1 -1
- package/dist/tools/speechToText.d.ts +77 -0
- package/dist/tools/speechToText.d.ts.map +1 -0
- package/dist/tools/speechToText.js +479 -0
- package/dist/tools/speechToText.js.map +1 -0
- package/manifest.json +20 -5
- package/package.json +6 -2
- package/src/index.ts +38 -7
- package/src/tools/speechToText.ts +650 -0
- package/test/textToSpeech.spec.ts +211 -2
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Voice Synthesis Extension for AgentOS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Voice input/output tools for AgentOS:
|
|
4
|
+
|
|
5
|
+
- `text_to_speech` via OpenAI, ElevenLabs, or a local Ollama-compatible runtime
|
|
6
|
+
- `speech_to_text` via OpenAI Whisper, Deepgram, or Whisper-local/OpenAI-compatible local STT runtimes
|
|
4
7
|
|
|
5
8
|
## Installation
|
|
6
9
|
|
|
@@ -10,18 +13,73 @@ npm install @framers/agentos-ext-voice-synthesis
|
|
|
10
13
|
|
|
11
14
|
## Configuration
|
|
12
15
|
|
|
13
|
-
Set
|
|
16
|
+
Set one or more of the following environment variables, or pass them via
|
|
17
|
+
extension options:
|
|
18
|
+
|
|
19
|
+
- `OPENAI_API_KEY`
|
|
20
|
+
- `ELEVENLABS_API_KEY`
|
|
21
|
+
- `DEEPGRAM_API_KEY`
|
|
22
|
+
- `OLLAMA_BASE_URL` for a local OpenAI-compatible TTS runtime
|
|
23
|
+
- `WHISPER_LOCAL_BASE_URL` for a local OpenAI-compatible STT runtime
|
|
24
|
+
- `TTS_PROVIDER` to prefer `openai`, `elevenlabs`, `ollama`, or `auto`
|
|
25
|
+
- `STT_PROVIDER` to prefer `openai`, `deepgram`, `whisper-local`, or `auto`
|
|
26
|
+
- `OPENAI_BASE_URL` for OpenAI-compatible speech endpoints
|
|
14
27
|
|
|
15
28
|
## Tool: text_to_speech
|
|
16
29
|
|
|
17
30
|
**Input:**
|
|
18
|
-
- `text` (string, required) — Text to convert
|
|
19
|
-
- `
|
|
20
|
-
- `
|
|
21
|
-
- `
|
|
22
|
-
- `
|
|
31
|
+
- `text` (string, required) — Text to convert, max 5000 chars
|
|
32
|
+
- `provider` (string, optional) — `openai`, `elevenlabs`, `ollama`, or `auto`
|
|
33
|
+
- `voice` (string, optional) — OpenAI: `alloy`, `echo`, `fable`, `onyx`, `nova`, `shimmer`; ElevenLabs: `rachel`, `domi`, `bella`, `antoni`, `josh`, `arnold`, `adam`, `sam`
|
|
34
|
+
- `model` (string, optional) — OpenAI: `tts-1`, `tts-1-hd`; ElevenLabs: `eleven_monolingual_v1`, `eleven_multilingual_v2`
|
|
35
|
+
- `speed` (number, OpenAI only) — 0.25 to 4.0
|
|
36
|
+
- `stability` (number, ElevenLabs only) — 0 to 1
|
|
37
|
+
- `similarity_boost` (number, ElevenLabs only) — 0 to 1
|
|
38
|
+
- `format` (string) — `mp3`, `opus`, `aac`, `flac`, `wav`
|
|
39
|
+
|
|
40
|
+
**Output:** Base64-encoded audio, provider metadata, and a duration estimate.
|
|
41
|
+
|
|
42
|
+
## Provider selection
|
|
43
|
+
|
|
44
|
+
The tool prefers providers in this order when `provider` is omitted:
|
|
45
|
+
|
|
46
|
+
1. OpenAI, if `OPENAI_API_KEY` is set
|
|
47
|
+
2. ElevenLabs, if `ELEVENLABS_API_KEY` is set
|
|
48
|
+
3. Ollama-compatible local runtime as a best-effort fallback
|
|
49
|
+
|
|
50
|
+
Ollama support is experimental and assumes an OpenAI-compatible TTS endpoint at
|
|
51
|
+
`/v1/audio/speech`.
|
|
52
|
+
|
|
53
|
+
## Tool: speech_to_text
|
|
54
|
+
|
|
55
|
+
**Providers:**
|
|
56
|
+
- `openai` — hosted Whisper via `OPENAI_API_KEY`
|
|
57
|
+
- `deepgram` — hosted Deepgram STT via `DEEPGRAM_API_KEY`
|
|
58
|
+
- `whisper-local` — local OpenAI-compatible transcription endpoint via `WHISPER_LOCAL_BASE_URL`
|
|
59
|
+
- `auto` — prefers OpenAI, then Deepgram, then explicitly configured local STT
|
|
60
|
+
|
|
61
|
+
**Input:**
|
|
62
|
+
- `audioBase64` (string) — Base64 audio payload, optionally as a `data:` URL
|
|
63
|
+
- `audioUrl` (string) — Fetchable audio URL
|
|
64
|
+
- `provider` (string, optional) — `auto`, `openai`, `deepgram`, or `whisper-local`
|
|
65
|
+
- `mimeType` (string, optional) — For example `audio/wav`
|
|
66
|
+
- `fileName` (string, optional) — File name sent to the provider
|
|
67
|
+
- `format` (string, optional) — Audio format hint such as `wav`, `mp3`, `m4a`, `webm`
|
|
68
|
+
- `language` (string, optional) — ISO language hint
|
|
69
|
+
- `prompt` (string, optional) — Context prompt to bias transcription
|
|
70
|
+
- `model` (string, optional) — Provider model override such as `whisper-1`, `nova-2`, or `base`
|
|
71
|
+
- `temperature` (number, optional) — Whisper temperature override
|
|
72
|
+
- `responseFormat` (string, optional) — `json`, `text`, `srt`, `verbose_json`, or `vtt`
|
|
73
|
+
- `diarize` (boolean, optional) — Enable speaker diarization where supported
|
|
74
|
+
- `utterances` (boolean, optional) — Request utterance segmentation where supported
|
|
75
|
+
- `smartFormat` (boolean, optional) — Enable provider-side formatting where supported
|
|
76
|
+
- `detectLanguage` (boolean, optional) — Enable provider-side language detection where supported
|
|
77
|
+
|
|
78
|
+
**Output:** Transcribed text, provider/model metadata, language, optional confidence, duration, and optional segments.
|
|
23
79
|
|
|
24
|
-
|
|
80
|
+
`whisper-local` targets OpenAI-compatible local transcription servers. That
|
|
81
|
+
keeps the tool contract stable even when you swap between hosted Whisper,
|
|
82
|
+
Deepgram, and local runtimes behind the same API shape.
|
|
25
83
|
|
|
26
84
|
## License
|
|
27
85
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Voice Synthesis Extension Pack —
|
|
2
|
+
* Voice Synthesis Extension Pack — TTS + STT voice tools for agents.
|
|
3
3
|
*
|
|
4
|
-
* Supports: OpenAI TTS, ElevenLabs, Ollama (local).
|
|
4
|
+
* Supports: OpenAI TTS/STT, ElevenLabs TTS, Ollama (local TTS).
|
|
5
5
|
* Auto-detects available provider from API keys.
|
|
6
6
|
*/
|
|
7
7
|
import { TextToSpeechTool, type TTSProvider } from './tools/textToSpeech.js';
|
|
8
|
+
import { SpeechToTextTool, type STTProvider } from './tools/speechToText.js';
|
|
8
9
|
export interface VoiceSynthesisExtensionOptions {
|
|
9
10
|
elevenLabsApiKey?: string;
|
|
10
11
|
openaiApiKey?: string;
|
|
11
12
|
openaiBaseUrl?: string;
|
|
13
|
+
deepgramApiKey?: string;
|
|
14
|
+
deepgramBaseUrl?: string;
|
|
12
15
|
ollamaBaseUrl?: string;
|
|
16
|
+
whisperLocalBaseUrl?: string;
|
|
13
17
|
defaultProvider?: TTSProvider;
|
|
18
|
+
defaultSttProvider?: STTProvider;
|
|
14
19
|
priority?: number;
|
|
15
20
|
}
|
|
16
21
|
export declare function createExtensionPack(context: any): {
|
|
17
22
|
name: string;
|
|
18
23
|
version: string;
|
|
19
|
-
descriptors: {
|
|
24
|
+
descriptors: ({
|
|
20
25
|
id: string;
|
|
21
26
|
kind: "tool";
|
|
22
27
|
priority: number;
|
|
23
28
|
payload: TextToSpeechTool;
|
|
24
29
|
requiredSecrets: never[];
|
|
25
|
-
}
|
|
30
|
+
} | {
|
|
31
|
+
id: string;
|
|
32
|
+
kind: "tool";
|
|
33
|
+
priority: number;
|
|
34
|
+
payload: SpeechToTextTool;
|
|
35
|
+
requiredSecrets: never[];
|
|
36
|
+
})[];
|
|
26
37
|
onActivate: () => Promise<void>;
|
|
27
38
|
onDeactivate: () => Promise<void>;
|
|
28
39
|
};
|
|
29
40
|
export { TextToSpeechTool };
|
|
41
|
+
export { SpeechToTextTool };
|
|
30
42
|
export type { TTSInput, TTSOutput, TTSConfig, TTSProvider } from './tools/textToSpeech.js';
|
|
43
|
+
export type { STTInput, STTOutput, STTConfig, STTProvider } from './tools/speechToText.js';
|
|
31
44
|
export default createExtensionPack;
|
|
32
45
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAkB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE7F,MAAM,WAAW,8BAA8B;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,GAAG
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAkB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAkB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE7F,MAAM,WAAW,8BAA8B;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,WAAW,CAAC;IAC9B,kBAAkB,CAAC,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,GAAG;;;;;;;;;;;;;;;;;;EA8D/C;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3F,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3F,eAAe,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Voice Synthesis Extension Pack —
|
|
2
|
+
* Voice Synthesis Extension Pack — TTS + STT voice tools for agents.
|
|
3
3
|
*
|
|
4
|
-
* Supports: OpenAI TTS, ElevenLabs, Ollama (local).
|
|
4
|
+
* Supports: OpenAI TTS/STT, ElevenLabs TTS, Ollama (local TTS).
|
|
5
5
|
* Auto-detects available provider from API keys.
|
|
6
6
|
*/
|
|
7
7
|
import { TextToSpeechTool } from './tools/textToSpeech.js';
|
|
8
|
+
import { SpeechToTextTool } from './tools/speechToText.js';
|
|
8
9
|
export function createExtensionPack(context) {
|
|
9
10
|
const options = (context.options || {});
|
|
10
11
|
const config = {
|
|
@@ -14,28 +15,54 @@ export function createExtensionPack(context) {
|
|
|
14
15
|
ollamaBaseUrl: options.ollamaBaseUrl || process.env.OLLAMA_BASE_URL,
|
|
15
16
|
defaultProvider: options.defaultProvider || process.env.TTS_PROVIDER || 'auto',
|
|
16
17
|
};
|
|
17
|
-
const
|
|
18
|
-
|
|
18
|
+
const sttConfig = {
|
|
19
|
+
openaiApiKey: options.openaiApiKey || context.getSecret?.('openai.apiKey') || process.env.OPENAI_API_KEY,
|
|
20
|
+
openaiBaseUrl: options.openaiBaseUrl || process.env.OPENAI_BASE_URL,
|
|
21
|
+
deepgramApiKey: options.deepgramApiKey || context.getSecret?.('deepgram.apiKey') || process.env.DEEPGRAM_API_KEY,
|
|
22
|
+
deepgramBaseUrl: options.deepgramBaseUrl || process.env.DEEPGRAM_BASE_URL,
|
|
23
|
+
whisperLocalBaseUrl: options.whisperLocalBaseUrl || process.env.WHISPER_LOCAL_BASE_URL,
|
|
24
|
+
defaultProvider: options.defaultSttProvider || process.env.STT_PROVIDER || 'auto',
|
|
25
|
+
};
|
|
26
|
+
const ttsTool = new TextToSpeechTool(config);
|
|
27
|
+
const sttTool = new SpeechToTextTool(sttConfig);
|
|
19
28
|
const providers = [];
|
|
20
29
|
if (config.openaiApiKey)
|
|
21
30
|
providers.push('OpenAI');
|
|
22
31
|
if (config.elevenLabsApiKey)
|
|
23
32
|
providers.push('ElevenLabs');
|
|
24
33
|
providers.push('Ollama (local fallback)');
|
|
34
|
+
const sttProviders = [];
|
|
35
|
+
if (sttConfig.openaiApiKey)
|
|
36
|
+
sttProviders.push('OpenAI Whisper');
|
|
37
|
+
if (sttConfig.deepgramApiKey)
|
|
38
|
+
sttProviders.push('Deepgram');
|
|
39
|
+
if (sttConfig.whisperLocalBaseUrl)
|
|
40
|
+
sttProviders.push('Whisper-local');
|
|
41
|
+
const features = [
|
|
42
|
+
`TTS: ${providers.join(', ')}`,
|
|
43
|
+
`STT: ${sttProviders.length > 0 ? sttProviders.join(', ') : 'not configured'}`,
|
|
44
|
+
];
|
|
25
45
|
return {
|
|
26
46
|
name: '@framers/agentos-ext-voice-synthesis',
|
|
27
47
|
version: '2.0.0',
|
|
28
48
|
descriptors: [
|
|
29
49
|
{
|
|
30
|
-
id:
|
|
50
|
+
id: ttsTool.name,
|
|
51
|
+
kind: 'tool',
|
|
52
|
+
priority: options.priority || 50,
|
|
53
|
+
payload: ttsTool,
|
|
54
|
+
requiredSecrets: [],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: sttTool.name,
|
|
31
58
|
kind: 'tool',
|
|
32
59
|
priority: options.priority || 50,
|
|
33
|
-
payload:
|
|
60
|
+
payload: sttTool,
|
|
34
61
|
requiredSecrets: [],
|
|
35
62
|
},
|
|
36
63
|
],
|
|
37
64
|
onActivate: async () => {
|
|
38
|
-
context.logger?.info?.(`Voice Synthesis activated —
|
|
65
|
+
context.logger?.info?.(`Voice Synthesis activated — ${features.join(' | ')}`);
|
|
39
66
|
},
|
|
40
67
|
onDeactivate: async () => {
|
|
41
68
|
context.logger?.info?.('Voice Synthesis deactivated');
|
|
@@ -43,5 +70,6 @@ export function createExtensionPack(context) {
|
|
|
43
70
|
};
|
|
44
71
|
}
|
|
45
72
|
export { TextToSpeechTool };
|
|
73
|
+
export { SpeechToTextTool };
|
|
46
74
|
export default createExtensionPack;
|
|
47
75
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAoC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAoC,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAoC,MAAM,yBAAyB,CAAC;AAe7F,MAAM,UAAU,mBAAmB,CAAC,OAAY;IAC9C,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAmC,CAAC;IAE1E,MAAM,MAAM,GAAc;QACxB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;Q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AAI,EAAE;YACvB,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,6BAA6B,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAG5B,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-provider STT Tool — speech-to-text transcription.
|
|
3
|
+
*
|
|
4
|
+
* Supports: OpenAI Whisper, Deepgram, and Whisper-local/OpenAI-compatible
|
|
5
|
+
* local runtimes behind one stable tool contract.
|
|
6
|
+
*/
|
|
7
|
+
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
8
|
+
export type STTProvider = 'openai' | 'deepgram' | 'whisper-local' | 'auto';
|
|
9
|
+
export type STTResponseFormat = 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
|
|
10
|
+
export interface STTInput {
|
|
11
|
+
audioBase64?: string;
|
|
12
|
+
audioUrl?: string;
|
|
13
|
+
mimeType?: string;
|
|
14
|
+
fileName?: string;
|
|
15
|
+
format?: string;
|
|
16
|
+
language?: string;
|
|
17
|
+
prompt?: string;
|
|
18
|
+
temperature?: number;
|
|
19
|
+
responseFormat?: STTResponseFormat;
|
|
20
|
+
provider?: STTProvider;
|
|
21
|
+
model?: string;
|
|
22
|
+
diarize?: boolean;
|
|
23
|
+
utterances?: boolean;
|
|
24
|
+
smartFormat?: boolean;
|
|
25
|
+
detectLanguage?: boolean;
|
|
26
|
+
providerOptions?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export interface STTWord {
|
|
29
|
+
word: string;
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
32
|
+
confidence?: number;
|
|
33
|
+
speaker?: string | number;
|
|
34
|
+
}
|
|
35
|
+
export interface STTSegment {
|
|
36
|
+
text: string;
|
|
37
|
+
start: number;
|
|
38
|
+
end: number;
|
|
39
|
+
confidence?: number;
|
|
40
|
+
speaker?: string | number;
|
|
41
|
+
words?: STTWord[];
|
|
42
|
+
}
|
|
43
|
+
export interface STTOutput {
|
|
44
|
+
text: string;
|
|
45
|
+
provider: Exclude<STTProvider, 'auto'>;
|
|
46
|
+
model: string;
|
|
47
|
+
language?: string;
|
|
48
|
+
confidence?: number;
|
|
49
|
+
durationSeconds?: number;
|
|
50
|
+
segments?: STTSegment[];
|
|
51
|
+
providerResponse?: unknown;
|
|
52
|
+
}
|
|
53
|
+
export interface STTConfig {
|
|
54
|
+
openaiApiKey?: string;
|
|
55
|
+
openaiBaseUrl?: string;
|
|
56
|
+
deepgramApiKey?: string;
|
|
57
|
+
deepgramBaseUrl?: string;
|
|
58
|
+
whisperLocalBaseUrl?: string;
|
|
59
|
+
defaultProvider?: STTProvider;
|
|
60
|
+
}
|
|
61
|
+
export declare class SpeechToTextTool implements ITool<STTInput, STTOutput> {
|
|
62
|
+
readonly id = "stt-multi-provider-v1";
|
|
63
|
+
readonly name = "speech_to_text";
|
|
64
|
+
readonly displayName = "Speech to Text";
|
|
65
|
+
readonly description: string;
|
|
66
|
+
readonly category = "media";
|
|
67
|
+
readonly version = "2.0.0";
|
|
68
|
+
readonly hasSideEffects = false;
|
|
69
|
+
readonly requiredCapabilities: string[];
|
|
70
|
+
readonly inputSchema: JSONSchemaObject;
|
|
71
|
+
private readonly config;
|
|
72
|
+
constructor(config?: STTConfig);
|
|
73
|
+
private resolveProvider;
|
|
74
|
+
private prepareAudio;
|
|
75
|
+
execute(args: STTInput, _context: ToolExecutionContext): Promise<ToolExecutionResult<STTOutput>>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=speechToText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speechToText.d.ts","sourceRoot":"","sources":["../../src/tools/speechToText.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV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