@contractspec/example.voice-providers 1.57.0 → 1.58.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.
Files changed (59) hide show
  1. package/.turbo/turbo-build.log +43 -46
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +13 -0
  4. package/dist/browser/connection.sample.js +55 -0
  5. package/dist/browser/docs/index.js +36 -0
  6. package/dist/browser/docs/voice-providers.docblock.js +36 -0
  7. package/dist/browser/example.js +33 -0
  8. package/dist/browser/handlers/create-provider.js +35 -0
  9. package/dist/browser/handlers/list-voices.js +41 -0
  10. package/dist/browser/handlers/synthesize.js +41 -0
  11. package/dist/browser/index.js +171 -0
  12. package/dist/browser/run.js +179 -0
  13. package/dist/connection.sample.d.ts +4 -8
  14. package/dist/connection.sample.d.ts.map +1 -1
  15. package/dist/connection.sample.js +54 -49
  16. package/dist/docs/index.d.ts +2 -1
  17. package/dist/docs/index.d.ts.map +1 -0
  18. package/dist/docs/index.js +37 -1
  19. package/dist/docs/voice-providers.docblock.d.ts +2 -1
  20. package/dist/docs/voice-providers.docblock.d.ts.map +1 -0
  21. package/dist/docs/voice-providers.docblock.js +35 -29
  22. package/dist/example.d.ts +2 -6
  23. package/dist/example.d.ts.map +1 -1
  24. package/dist/example.js +32 -44
  25. package/dist/handlers/create-provider.d.ts +21 -25
  26. package/dist/handlers/create-provider.d.ts.map +1 -1
  27. package/dist/handlers/create-provider.js +32 -28
  28. package/dist/handlers/list-voices.d.ts +3 -7
  29. package/dist/handlers/list-voices.d.ts.map +1 -1
  30. package/dist/handlers/list-voices.js +39 -7
  31. package/dist/handlers/synthesize.d.ts +5 -9
  32. package/dist/handlers/synthesize.d.ts.map +1 -1
  33. package/dist/handlers/synthesize.js +39 -7
  34. package/dist/index.d.ts +7 -6
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +172 -8
  37. package/dist/node/connection.sample.js +55 -0
  38. package/dist/node/docs/index.js +36 -0
  39. package/dist/node/docs/voice-providers.docblock.js +36 -0
  40. package/dist/node/example.js +33 -0
  41. package/dist/node/handlers/create-provider.js +35 -0
  42. package/dist/node/handlers/list-voices.js +41 -0
  43. package/dist/node/handlers/synthesize.js +41 -0
  44. package/dist/node/index.js +171 -0
  45. package/dist/node/run.js +179 -0
  46. package/dist/run.d.ts +1 -4
  47. package/dist/run.d.ts.map +1 -1
  48. package/dist/run.js +160 -98
  49. package/package.json +93 -32
  50. package/tsdown.config.js +1 -2
  51. package/.turbo/turbo-build$colon$bundle.log +0 -46
  52. package/dist/connection.sample.js.map +0 -1
  53. package/dist/docs/voice-providers.docblock.js.map +0 -1
  54. package/dist/example.js.map +0 -1
  55. package/dist/handlers/create-provider.js.map +0 -1
  56. package/dist/handlers/list-voices.js.map +0 -1
  57. package/dist/handlers/synthesize.js.map +0 -1
  58. package/dist/run.js.map +0 -1
  59. package/tsconfig.tsbuildinfo +0 -1
@@ -1,47 +1,44 @@
1
- $ bun build:types && bun build:bundle
2
- $ tsc --noEmit
3
- $ tsdown
4
- ℹ tsdown v0.20.3 powered by rolldown v1.0.0-rc.3
5
- ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/voice-providers/tsdown.config.js
6
- ℹ entry: src/connection.sample.ts, src/example.ts, src/index.ts, src/run.ts, src/handlers/create-provider.ts, src/handlers/list-voices.ts, src/handlers/synthesize.ts, src/docs/index.ts, src/docs/voice-providers.docblock.ts
7
- ℹ target: esnext
8
- ℹ tsconfig: tsconfig.json
9
- ℹ Build start
10
- ℹ dist/run.js 3.90 kB │ gzip: 1.33 kB
11
- ℹ dist/docs/voice-providers.docblock.js 1.85 kB │ gzip: 0.87 kB
12
- ℹ dist/connection.sample.js 1.48 kB │ gzip: 0.58 kB
13
- ℹ dist/handlers/create-provider.js 1.21 kB │ gzip: 0.49 kB
14
- ℹ dist/example.js 0.99 kB │ gzip: 0.51 kB
15
- ℹ dist/index.js 0.49 kB │ gzip: 0.20 kB
16
- ℹ dist/handlers/synthesize.js 0.28 kB │ gzip: 0.19 kB
17
- ℹ dist/handlers/list-voices.js 0.26 kB │ gzip: 0.18 kB
18
- ℹ dist/docs/index.js 0.04 kB │ gzip: 0.06 kB
19
- ℹ dist/run.js.map 7.18 kB │ gzip: 2.33 kB
20
- ℹ dist/handlers/create-provider.js.map 2.73 kB │ gzip: 0.96 kB
21
- ℹ dist/docs/voice-providers.docblock.js.map 2.57 kB │ gzip: 1.08 kB
22
- ℹ dist/connection.sample.js.map 2.28 kB │ gzip: 0.83 kB
23
- ℹ dist/example.js.map 1.46 kB │ gzip: 0.70 kB
24
- ℹ dist/handlers/synthesize.js.map 0.76 kB │ gzip: 0.40 kB
25
- ℹ dist/handlers/list-voices.js.map 0.56 kB │ gzip: 0.34 kB
26
- ℹ dist/handlers/create-provider.d.ts.map 0.43 kB │ gzip: 0.24 kB
27
- ℹ dist/handlers/synthesize.d.ts.map 0.22 kB │ gzip: 0.18 kB
28
- ℹ dist/connection.sample.d.ts.map 0.20 kB │ gzip: 0.14 kB
29
- ℹ dist/handlers/list-voices.d.ts.map 0.17 kB │ gzip: 0.15 kB
30
- ℹ dist/example.d.ts.map 0.13 kB │ gzip: 0.13 kB
31
- ℹ dist/run.d.ts.map 0.12 kB │ gzip: 0.13 kB
32
- ℹ dist/handlers/create-provider.d.ts 1.05 kB │ gzip: 0.45 kB
33
- ℹ dist/index.d.ts 0.69 kB │ gzip: 0.24 kB
34
- ℹ dist/handlers/synthesize.d.ts 0.52 kB │ gzip: 0.27 kB
35
- ℹ dist/connection.sample.d.ts 0.45 kB │ gzip: 0.21 kB
36
- ℹ dist/handlers/list-voices.d.ts 0.35 kB │ gzip: 0.23 kB
37
- ℹ dist/example.d.ts 0.25 kB │ gzip: 0.17 kB
38
- ℹ dist/run.d.ts 0.20 kB │ gzip: 0.16 kB
39
- ℹ dist/docs/index.d.ts 0.01 kB │ gzip: 0.03 kB
40
- ℹ dist/docs/voice-providers.docblock.d.ts 0.01 kB │ gzip: 0.03 kB
41
- ℹ 31 files, total: 32.86 kB
42
- [PLUGIN_TIMINGS] Warning: Your build spent significant time in plugins. Here is a breakdown:
43
- - tsdown:external (56%)
44
- - rolldown-plugin-dts:generate (42%)
45
- See https://rolldown.rs/options/checks#plugintimings for more details.
1
+ $ contractspec-bun-build prebuild
2
+ $ bun run prebuild && bun run build:bundle && bun run build:types
3
+ $ contractspec-bun-build prebuild
4
+ $ contractspec-bun-build transpile
5
+ [contractspec-bun-build] transpile target=bun root=src entries=9
6
+ Bundled 9 modules in 40ms
46
7
 
47
- ✔ Build complete in 21592ms
8
+ ./connection.sample.js 1.50 KB (entry point)
9
+ ./run.js 5.59 KB (entry point)
10
+ ./index.js 5.98 KB (entry point)
11
+ docs/index.js 1.92 KB (entry point)
12
+ docs/voice-providers.docblock.js 1.92 KB (entry point)
13
+ ./example.js 0.99 KB (entry point)
14
+ handlers/list-voices.js 1.40 KB (entry point)
15
+ handlers/synthesize.js 1.43 KB (entry point)
16
+ handlers/create-provider.js 1.27 KB (entry point)
17
+
18
+ [contractspec-bun-build] transpile target=node root=src entries=9
19
+ Bundled 9 modules in 31ms
20
+
21
+ ./connection.sample.js 1.49 KB (entry point)
22
+ ./run.js 5.58 KB (entry point)
23
+ ./index.js 5.97 KB (entry point)
24
+ docs/index.js 1.91 KB (entry point)
25
+ docs/voice-providers.docblock.js 1.91 KB (entry point)
26
+ ./example.js 0.98 KB (entry point)
27
+ handlers/list-voices.js 1.40 KB (entry point)
28
+ handlers/synthesize.js 1.42 KB (entry point)
29
+ handlers/create-provider.js 1.26 KB (entry point)
30
+
31
+ [contractspec-bun-build] transpile target=browser root=src entries=9
32
+ Bundled 9 modules in 26ms
33
+
34
+ ./connection.sample.js 1.49 KB (entry point)
35
+ ./run.js 5.58 KB (entry point)
36
+ ./index.js 5.97 KB (entry point)
37
+ docs/index.js 1.91 KB (entry point)
38
+ docs/voice-providers.docblock.js 1.91 KB (entry point)
39
+ ./example.js 0.98 KB (entry point)
40
+ handlers/list-voices.js 1.40 KB (entry point)
41
+ handlers/synthesize.js 1.42 KB (entry point)
42
+ handlers/create-provider.js 1.26 KB (entry point)
43
+
44
+ $ contractspec-bun-build types
@@ -0,0 +1 @@
1
+ $ contractspec-bun-build prebuild
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @contractspec/example.voice-providers
2
2
 
3
+ ## 1.58.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d1f0fd0: chore: Migrate non-app package builds from tsdown to shared Bun tooling, add `@contractspec/tool.bun`, and standardize `prebuild`/`build`/`typecheck` with platform-aware exports and `tsc` declaration emission into `dist`.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [d1f0fd0]
12
+ - Updated dependencies [4355a9e]
13
+ - @contractspec/integration.providers-impls@1.58.0
14
+ - @contractspec/lib.contracts@1.58.0
15
+
3
16
  ## 1.57.0
4
17
 
5
18
  ### Minor Changes
@@ -0,0 +1,55 @@
1
+ // src/connection.sample.ts
2
+ var gradiumVoiceConnection = {
3
+ meta: {
4
+ id: "conn-gradium-voice-demo",
5
+ tenantId: "acme-inc",
6
+ integrationKey: "ai-voice.gradium",
7
+ integrationVersion: "1.0.0",
8
+ label: "Gradium Voice",
9
+ environment: "production",
10
+ createdAt: "2026-01-01T00:00:00.000Z",
11
+ updatedAt: "2026-01-01T00:00:00.000Z"
12
+ },
13
+ ownershipMode: "byok",
14
+ config: {
15
+ defaultVoiceId: "YTpq7expH9539ERJ",
16
+ region: "eu",
17
+ outputFormat: "wav"
18
+ },
19
+ secretProvider: "vault",
20
+ secretRef: "vault://integrations/acme-inc/conn-gradium-voice-demo",
21
+ status: "connected"
22
+ };
23
+ var falVoiceConnection = {
24
+ meta: {
25
+ id: "conn-fal-voice-demo",
26
+ tenantId: "acme-inc",
27
+ integrationKey: "ai-voice.fal",
28
+ integrationVersion: "1.0.0",
29
+ label: "Fal Voice",
30
+ environment: "production",
31
+ createdAt: "2026-01-01T00:00:00.000Z",
32
+ updatedAt: "2026-01-01T00:00:00.000Z"
33
+ },
34
+ ownershipMode: "byok",
35
+ config: {
36
+ modelId: "fal-ai/chatterbox/text-to-speech",
37
+ defaultVoiceUrl: "https://storage.googleapis.com/chatterbox-demo-samples/prompts/male_rickmorty.mp3",
38
+ defaultExaggeration: 0.25,
39
+ defaultTemperature: 0.7,
40
+ defaultCfg: 0.5,
41
+ pollIntervalMs: 1000
42
+ },
43
+ secretProvider: "vault",
44
+ secretRef: "vault://integrations/acme-inc/conn-fal-voice-demo",
45
+ status: "connected"
46
+ };
47
+ var voiceSampleConnections = [
48
+ gradiumVoiceConnection,
49
+ falVoiceConnection
50
+ ];
51
+ export {
52
+ voiceSampleConnections,
53
+ gradiumVoiceConnection,
54
+ falVoiceConnection
55
+ };
@@ -0,0 +1,36 @@
1
+ // src/docs/voice-providers.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var blocks = [
4
+ {
5
+ id: "docs.examples.voice-providers",
6
+ title: "Voice Providers (example)",
7
+ summary: "Multi-provider voice integration example covering Gradium and Fal text-to-speech flows.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/voice-providers",
11
+ tags: ["voice", "tts", "gradium", "fal", "example"],
12
+ body: `## What this example shows
13
+ ` + "- Provider selection for `ai-voice.gradium` and `ai-voice.fal`.\n" + `- Listing voice catalogs and synthesizing text into audio bytes.
14
+ ` + `- Connection metadata patterns for BYOK secret references.
15
+
16
+ ` + `## Secrets and config
17
+ ` + "- `apiKey` for each provider.\n" + "- Gradium config: `defaultVoiceId`, `region`, `outputFormat`.\n" + "- Fal config: `modelId`, `defaultVoiceUrl`, synthesis tuning fields.\n\n" + `## Guardrails
18
+ ` + `- Keep API keys in secret providers only.
19
+ ` + `- Prefer declarative provider config over hardcoded runtime options.
20
+ ` + "- Keep synthesis side effects explicit for deterministic workflows."
21
+ },
22
+ {
23
+ id: "docs.examples.voice-providers.usage",
24
+ title: "Voice Providers - Usage",
25
+ summary: "How to wire provider factory and synthesis helpers in runtime code.",
26
+ kind: "usage",
27
+ visibility: "public",
28
+ route: "/docs/examples/voice-providers/usage",
29
+ tags: ["voice", "usage"],
30
+ body: `## Usage
31
+ ` + "- Call `createVoiceProvider` with integration key, secrets, and config.\n" + "- Use `listVoices` to expose voice choices in admin/config screens.\n" + "- Use `synthesizeVoice` for message generation or workflow steps.\n\n" + `## Notes
32
+ ` + `- Fal uses an audio URL output; this example downloads bytes for a canonical result shape.
33
+ ` + "- Gradium maps provider output formats into ContractSpec voice result conventions."
34
+ }
35
+ ];
36
+ registerDocBlocks(blocks);
@@ -0,0 +1,36 @@
1
+ // src/docs/voice-providers.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var blocks = [
4
+ {
5
+ id: "docs.examples.voice-providers",
6
+ title: "Voice Providers (example)",
7
+ summary: "Multi-provider voice integration example covering Gradium and Fal text-to-speech flows.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/voice-providers",
11
+ tags: ["voice", "tts", "gradium", "fal", "example"],
12
+ body: `## What this example shows
13
+ ` + "- Provider selection for `ai-voice.gradium` and `ai-voice.fal`.\n" + `- Listing voice catalogs and synthesizing text into audio bytes.
14
+ ` + `- Connection metadata patterns for BYOK secret references.
15
+
16
+ ` + `## Secrets and config
17
+ ` + "- `apiKey` for each provider.\n" + "- Gradium config: `defaultVoiceId`, `region`, `outputFormat`.\n" + "- Fal config: `modelId`, `defaultVoiceUrl`, synthesis tuning fields.\n\n" + `## Guardrails
18
+ ` + `- Keep API keys in secret providers only.
19
+ ` + `- Prefer declarative provider config over hardcoded runtime options.
20
+ ` + "- Keep synthesis side effects explicit for deterministic workflows."
21
+ },
22
+ {
23
+ id: "docs.examples.voice-providers.usage",
24
+ title: "Voice Providers - Usage",
25
+ summary: "How to wire provider factory and synthesis helpers in runtime code.",
26
+ kind: "usage",
27
+ visibility: "public",
28
+ route: "/docs/examples/voice-providers/usage",
29
+ tags: ["voice", "usage"],
30
+ body: `## Usage
31
+ ` + "- Call `createVoiceProvider` with integration key, secrets, and config.\n" + "- Use `listVoices` to expose voice choices in admin/config screens.\n" + "- Use `synthesizeVoice` for message generation or workflow steps.\n\n" + `## Notes
32
+ ` + `- Fal uses an audio URL output; this example downloads bytes for a canonical result shape.
33
+ ` + "- Gradium maps provider output formats into ContractSpec voice result conventions."
34
+ }
35
+ ];
36
+ registerDocBlocks(blocks);
@@ -0,0 +1,33 @@
1
+ // src/example.ts
2
+ import { defineExample } from "@contractspec/lib.contracts";
3
+ var example = defineExample({
4
+ meta: {
5
+ key: "voice-providers",
6
+ version: "1.0.0",
7
+ title: "Voice Providers (Gradium and Fal)",
8
+ description: "Multi-provider voice integration example for Gradium and Fal text-to-speech adapters.",
9
+ kind: "integration",
10
+ visibility: "public",
11
+ stability: "experimental",
12
+ owners: ["@platform.integrations"],
13
+ tags: ["voice", "tts", "gradium", "fal", "integrations"]
14
+ },
15
+ docs: {
16
+ rootDocId: "docs.examples.voice-providers",
17
+ usageDocId: "docs.examples.voice-providers.usage"
18
+ },
19
+ entrypoints: {
20
+ packageName: "@contractspec/example.voice-providers",
21
+ docs: "./docs"
22
+ },
23
+ surfaces: {
24
+ templates: true,
25
+ sandbox: { enabled: true, modes: ["markdown", "specs"] },
26
+ studio: { enabled: true, installable: true },
27
+ mcp: { enabled: true }
28
+ }
29
+ });
30
+ var example_default = example;
31
+ export {
32
+ example_default as default
33
+ };
@@ -0,0 +1,35 @@
1
+ // src/handlers/create-provider.ts
2
+ import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
3
+ import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
4
+ function createVoiceProvider(input) {
5
+ const { integrationKey, secrets, config } = input;
6
+ if (!secrets.apiKey) {
7
+ throw new Error("Voice provider apiKey is required.");
8
+ }
9
+ switch (integrationKey) {
10
+ case "ai-voice.gradium":
11
+ return new GradiumVoiceProvider({
12
+ apiKey: secrets.apiKey,
13
+ defaultVoiceId: config?.defaultVoiceId,
14
+ region: config?.region,
15
+ baseUrl: config?.baseUrl,
16
+ timeoutMs: config?.timeoutMs,
17
+ outputFormat: config?.outputFormat
18
+ });
19
+ case "ai-voice.fal":
20
+ return new FalVoiceProvider({
21
+ apiKey: secrets.apiKey,
22
+ modelId: config?.modelId,
23
+ defaultVoiceUrl: config?.defaultVoiceUrl,
24
+ defaultExaggeration: config?.defaultExaggeration,
25
+ defaultTemperature: config?.defaultTemperature,
26
+ defaultCfg: config?.defaultCfg,
27
+ pollIntervalMs: config?.pollIntervalMs
28
+ });
29
+ default:
30
+ throw new Error(`Unsupported voice provider: ${integrationKey}`);
31
+ }
32
+ }
33
+ export {
34
+ createVoiceProvider
35
+ };
@@ -0,0 +1,41 @@
1
+ // src/handlers/create-provider.ts
2
+ import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
3
+ import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
4
+ function createVoiceProvider(input) {
5
+ const { integrationKey, secrets, config } = input;
6
+ if (!secrets.apiKey) {
7
+ throw new Error("Voice provider apiKey is required.");
8
+ }
9
+ switch (integrationKey) {
10
+ case "ai-voice.gradium":
11
+ return new GradiumVoiceProvider({
12
+ apiKey: secrets.apiKey,
13
+ defaultVoiceId: config?.defaultVoiceId,
14
+ region: config?.region,
15
+ baseUrl: config?.baseUrl,
16
+ timeoutMs: config?.timeoutMs,
17
+ outputFormat: config?.outputFormat
18
+ });
19
+ case "ai-voice.fal":
20
+ return new FalVoiceProvider({
21
+ apiKey: secrets.apiKey,
22
+ modelId: config?.modelId,
23
+ defaultVoiceUrl: config?.defaultVoiceUrl,
24
+ defaultExaggeration: config?.defaultExaggeration,
25
+ defaultTemperature: config?.defaultTemperature,
26
+ defaultCfg: config?.defaultCfg,
27
+ pollIntervalMs: config?.pollIntervalMs
28
+ });
29
+ default:
30
+ throw new Error(`Unsupported voice provider: ${integrationKey}`);
31
+ }
32
+ }
33
+
34
+ // src/handlers/list-voices.ts
35
+ async function listVoices(input) {
36
+ const provider = createVoiceProvider(input);
37
+ return provider.listVoices();
38
+ }
39
+ export {
40
+ listVoices
41
+ };
@@ -0,0 +1,41 @@
1
+ // src/handlers/create-provider.ts
2
+ import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
3
+ import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
4
+ function createVoiceProvider(input) {
5
+ const { integrationKey, secrets, config } = input;
6
+ if (!secrets.apiKey) {
7
+ throw new Error("Voice provider apiKey is required.");
8
+ }
9
+ switch (integrationKey) {
10
+ case "ai-voice.gradium":
11
+ return new GradiumVoiceProvider({
12
+ apiKey: secrets.apiKey,
13
+ defaultVoiceId: config?.defaultVoiceId,
14
+ region: config?.region,
15
+ baseUrl: config?.baseUrl,
16
+ timeoutMs: config?.timeoutMs,
17
+ outputFormat: config?.outputFormat
18
+ });
19
+ case "ai-voice.fal":
20
+ return new FalVoiceProvider({
21
+ apiKey: secrets.apiKey,
22
+ modelId: config?.modelId,
23
+ defaultVoiceUrl: config?.defaultVoiceUrl,
24
+ defaultExaggeration: config?.defaultExaggeration,
25
+ defaultTemperature: config?.defaultTemperature,
26
+ defaultCfg: config?.defaultCfg,
27
+ pollIntervalMs: config?.pollIntervalMs
28
+ });
29
+ default:
30
+ throw new Error(`Unsupported voice provider: ${integrationKey}`);
31
+ }
32
+ }
33
+
34
+ // src/handlers/synthesize.ts
35
+ async function synthesizeVoice(input) {
36
+ const provider = createVoiceProvider(input);
37
+ return provider.synthesize(input.synthesis);
38
+ }
39
+ export {
40
+ synthesizeVoice
41
+ };
@@ -0,0 +1,171 @@
1
+ // src/connection.sample.ts
2
+ var gradiumVoiceConnection = {
3
+ meta: {
4
+ id: "conn-gradium-voice-demo",
5
+ tenantId: "acme-inc",
6
+ integrationKey: "ai-voice.gradium",
7
+ integrationVersion: "1.0.0",
8
+ label: "Gradium Voice",
9
+ environment: "production",
10
+ createdAt: "2026-01-01T00:00:00.000Z",
11
+ updatedAt: "2026-01-01T00:00:00.000Z"
12
+ },
13
+ ownershipMode: "byok",
14
+ config: {
15
+ defaultVoiceId: "YTpq7expH9539ERJ",
16
+ region: "eu",
17
+ outputFormat: "wav"
18
+ },
19
+ secretProvider: "vault",
20
+ secretRef: "vault://integrations/acme-inc/conn-gradium-voice-demo",
21
+ status: "connected"
22
+ };
23
+ var falVoiceConnection = {
24
+ meta: {
25
+ id: "conn-fal-voice-demo",
26
+ tenantId: "acme-inc",
27
+ integrationKey: "ai-voice.fal",
28
+ integrationVersion: "1.0.0",
29
+ label: "Fal Voice",
30
+ environment: "production",
31
+ createdAt: "2026-01-01T00:00:00.000Z",
32
+ updatedAt: "2026-01-01T00:00:00.000Z"
33
+ },
34
+ ownershipMode: "byok",
35
+ config: {
36
+ modelId: "fal-ai/chatterbox/text-to-speech",
37
+ defaultVoiceUrl: "https://storage.googleapis.com/chatterbox-demo-samples/prompts/male_rickmorty.mp3",
38
+ defaultExaggeration: 0.25,
39
+ defaultTemperature: 0.7,
40
+ defaultCfg: 0.5,
41
+ pollIntervalMs: 1000
42
+ },
43
+ secretProvider: "vault",
44
+ secretRef: "vault://integrations/acme-inc/conn-fal-voice-demo",
45
+ status: "connected"
46
+ };
47
+ var voiceSampleConnections = [
48
+ gradiumVoiceConnection,
49
+ falVoiceConnection
50
+ ];
51
+
52
+ // src/docs/voice-providers.docblock.ts
53
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
54
+ var blocks = [
55
+ {
56
+ id: "docs.examples.voice-providers",
57
+ title: "Voice Providers (example)",
58
+ summary: "Multi-provider voice integration example covering Gradium and Fal text-to-speech flows.",
59
+ kind: "reference",
60
+ visibility: "public",
61
+ route: "/docs/examples/voice-providers",
62
+ tags: ["voice", "tts", "gradium", "fal", "example"],
63
+ body: `## What this example shows
64
+ ` + "- Provider selection for `ai-voice.gradium` and `ai-voice.fal`.\n" + `- Listing voice catalogs and synthesizing text into audio bytes.
65
+ ` + `- Connection metadata patterns for BYOK secret references.
66
+
67
+ ` + `## Secrets and config
68
+ ` + "- `apiKey` for each provider.\n" + "- Gradium config: `defaultVoiceId`, `region`, `outputFormat`.\n" + "- Fal config: `modelId`, `defaultVoiceUrl`, synthesis tuning fields.\n\n" + `## Guardrails
69
+ ` + `- Keep API keys in secret providers only.
70
+ ` + `- Prefer declarative provider config over hardcoded runtime options.
71
+ ` + "- Keep synthesis side effects explicit for deterministic workflows."
72
+ },
73
+ {
74
+ id: "docs.examples.voice-providers.usage",
75
+ title: "Voice Providers - Usage",
76
+ summary: "How to wire provider factory and synthesis helpers in runtime code.",
77
+ kind: "usage",
78
+ visibility: "public",
79
+ route: "/docs/examples/voice-providers/usage",
80
+ tags: ["voice", "usage"],
81
+ body: `## Usage
82
+ ` + "- Call `createVoiceProvider` with integration key, secrets, and config.\n" + "- Use `listVoices` to expose voice choices in admin/config screens.\n" + "- Use `synthesizeVoice` for message generation or workflow steps.\n\n" + `## Notes
83
+ ` + `- Fal uses an audio URL output; this example downloads bytes for a canonical result shape.
84
+ ` + "- Gradium maps provider output formats into ContractSpec voice result conventions."
85
+ }
86
+ ];
87
+ registerDocBlocks(blocks);
88
+ // src/example.ts
89
+ import { defineExample } from "@contractspec/lib.contracts";
90
+ var example = defineExample({
91
+ meta: {
92
+ key: "voice-providers",
93
+ version: "1.0.0",
94
+ title: "Voice Providers (Gradium and Fal)",
95
+ description: "Multi-provider voice integration example for Gradium and Fal text-to-speech adapters.",
96
+ kind: "integration",
97
+ visibility: "public",
98
+ stability: "experimental",
99
+ owners: ["@platform.integrations"],
100
+ tags: ["voice", "tts", "gradium", "fal", "integrations"]
101
+ },
102
+ docs: {
103
+ rootDocId: "docs.examples.voice-providers",
104
+ usageDocId: "docs.examples.voice-providers.usage"
105
+ },
106
+ entrypoints: {
107
+ packageName: "@contractspec/example.voice-providers",
108
+ docs: "./docs"
109
+ },
110
+ surfaces: {
111
+ templates: true,
112
+ sandbox: { enabled: true, modes: ["markdown", "specs"] },
113
+ studio: { enabled: true, installable: true },
114
+ mcp: { enabled: true }
115
+ }
116
+ });
117
+ var example_default = example;
118
+
119
+ // src/handlers/create-provider.ts
120
+ import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
121
+ import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
122
+ function createVoiceProvider(input) {
123
+ const { integrationKey, secrets, config } = input;
124
+ if (!secrets.apiKey) {
125
+ throw new Error("Voice provider apiKey is required.");
126
+ }
127
+ switch (integrationKey) {
128
+ case "ai-voice.gradium":
129
+ return new GradiumVoiceProvider({
130
+ apiKey: secrets.apiKey,
131
+ defaultVoiceId: config?.defaultVoiceId,
132
+ region: config?.region,
133
+ baseUrl: config?.baseUrl,
134
+ timeoutMs: config?.timeoutMs,
135
+ outputFormat: config?.outputFormat
136
+ });
137
+ case "ai-voice.fal":
138
+ return new FalVoiceProvider({
139
+ apiKey: secrets.apiKey,
140
+ modelId: config?.modelId,
141
+ defaultVoiceUrl: config?.defaultVoiceUrl,
142
+ defaultExaggeration: config?.defaultExaggeration,
143
+ defaultTemperature: config?.defaultTemperature,
144
+ defaultCfg: config?.defaultCfg,
145
+ pollIntervalMs: config?.pollIntervalMs
146
+ });
147
+ default:
148
+ throw new Error(`Unsupported voice provider: ${integrationKey}`);
149
+ }
150
+ }
151
+
152
+ // src/handlers/list-voices.ts
153
+ async function listVoices(input) {
154
+ const provider = createVoiceProvider(input);
155
+ return provider.listVoices();
156
+ }
157
+
158
+ // src/handlers/synthesize.ts
159
+ async function synthesizeVoice(input) {
160
+ const provider = createVoiceProvider(input);
161
+ return provider.synthesize(input.synthesis);
162
+ }
163
+ export {
164
+ voiceSampleConnections,
165
+ synthesizeVoice,
166
+ listVoices,
167
+ gradiumVoiceConnection,
168
+ falVoiceConnection,
169
+ example_default as example,
170
+ createVoiceProvider
171
+ };