@contractspec/example.voice-providers 1.57.0 → 1.59.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 +25 -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,32 +1,36 @@
1
+ // @bun
2
+ // src/handlers/create-provider.ts
1
3
  import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
2
4
  import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
3
-
4
- //#region src/handlers/create-provider.ts
5
5
  function createVoiceProvider(input) {
6
- const { integrationKey, secrets, config } = input;
7
- if (!secrets.apiKey) throw new Error("Voice provider apiKey is required.");
8
- switch (integrationKey) {
9
- case "ai-voice.gradium": return new GradiumVoiceProvider({
10
- apiKey: secrets.apiKey,
11
- defaultVoiceId: config?.defaultVoiceId,
12
- region: config?.region,
13
- baseUrl: config?.baseUrl,
14
- timeoutMs: config?.timeoutMs,
15
- outputFormat: config?.outputFormat
16
- });
17
- case "ai-voice.fal": return new FalVoiceProvider({
18
- apiKey: secrets.apiKey,
19
- modelId: config?.modelId,
20
- defaultVoiceUrl: config?.defaultVoiceUrl,
21
- defaultExaggeration: config?.defaultExaggeration,
22
- defaultTemperature: config?.defaultTemperature,
23
- defaultCfg: config?.defaultCfg,
24
- pollIntervalMs: config?.pollIntervalMs
25
- });
26
- default: throw new Error(`Unsupported voice provider: ${integrationKey}`);
27
- }
6
+ const { integrationKey, secrets, config } = input;
7
+ if (!secrets.apiKey) {
8
+ throw new Error("Voice provider apiKey is required.");
9
+ }
10
+ switch (integrationKey) {
11
+ case "ai-voice.gradium":
12
+ return new GradiumVoiceProvider({
13
+ apiKey: secrets.apiKey,
14
+ defaultVoiceId: config?.defaultVoiceId,
15
+ region: config?.region,
16
+ baseUrl: config?.baseUrl,
17
+ timeoutMs: config?.timeoutMs,
18
+ outputFormat: config?.outputFormat
19
+ });
20
+ case "ai-voice.fal":
21
+ return new FalVoiceProvider({
22
+ apiKey: secrets.apiKey,
23
+ modelId: config?.modelId,
24
+ defaultVoiceUrl: config?.defaultVoiceUrl,
25
+ defaultExaggeration: config?.defaultExaggeration,
26
+ defaultTemperature: config?.defaultTemperature,
27
+ defaultCfg: config?.defaultCfg,
28
+ pollIntervalMs: config?.pollIntervalMs
29
+ });
30
+ default:
31
+ throw new Error(`Unsupported voice provider: ${integrationKey}`);
32
+ }
28
33
  }
29
-
30
- //#endregion
31
- export { createVoiceProvider };
32
- //# sourceMappingURL=create-provider.js.map
34
+ export {
35
+ createVoiceProvider
36
+ };
@@ -1,8 +1,4 @@
1
- import { VoiceProviderFactoryInput } from "./create-provider.js";
2
- import { Voice } from "@contractspec/lib.contracts/integrations/providers/voice";
3
-
4
- //#region src/handlers/list-voices.d.ts
5
- declare function listVoices(input: VoiceProviderFactoryInput): Promise<Voice[]>;
6
- //#endregion
7
- export { listVoices };
1
+ import type { Voice } from '@contractspec/lib.contracts/integrations/providers/voice';
2
+ import { type VoiceProviderFactoryInput } from './create-provider';
3
+ export declare function listVoices(input: VoiceProviderFactoryInput): Promise<Voice[]>;
8
4
  //# sourceMappingURL=list-voices.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list-voices.d.ts","names":[],"sources":["../../src/handlers/list-voices.ts"],"mappings":";;;;iBAOsB,UAAA,CACpB,KAAA,EAAO,yBAAA,GACN,OAAA,CAAQ,KAAA"}
1
+ {"version":3,"file":"list-voices.d.ts","sourceRoot":"","sources":["../../src/handlers/list-voices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0DAA0D,CAAC;AAEtF,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,mBAAmB,CAAC;AAE3B,wBAAsB,UAAU,CAC9B,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,KAAK,EAAE,CAAC,CAGlB"}
@@ -1,10 +1,42 @@
1
- import { createVoiceProvider } from "./create-provider.js";
1
+ // @bun
2
+ // src/handlers/create-provider.ts
3
+ import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
4
+ import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
5
+ function createVoiceProvider(input) {
6
+ const { integrationKey, secrets, config } = input;
7
+ if (!secrets.apiKey) {
8
+ throw new Error("Voice provider apiKey is required.");
9
+ }
10
+ switch (integrationKey) {
11
+ case "ai-voice.gradium":
12
+ return new GradiumVoiceProvider({
13
+ apiKey: secrets.apiKey,
14
+ defaultVoiceId: config?.defaultVoiceId,
15
+ region: config?.region,
16
+ baseUrl: config?.baseUrl,
17
+ timeoutMs: config?.timeoutMs,
18
+ outputFormat: config?.outputFormat
19
+ });
20
+ case "ai-voice.fal":
21
+ return new FalVoiceProvider({
22
+ apiKey: secrets.apiKey,
23
+ modelId: config?.modelId,
24
+ defaultVoiceUrl: config?.defaultVoiceUrl,
25
+ defaultExaggeration: config?.defaultExaggeration,
26
+ defaultTemperature: config?.defaultTemperature,
27
+ defaultCfg: config?.defaultCfg,
28
+ pollIntervalMs: config?.pollIntervalMs
29
+ });
30
+ default:
31
+ throw new Error(`Unsupported voice provider: ${integrationKey}`);
32
+ }
33
+ }
2
34
 
3
- //#region src/handlers/list-voices.ts
35
+ // src/handlers/list-voices.ts
4
36
  async function listVoices(input) {
5
- return createVoiceProvider(input).listVoices();
37
+ const provider = createVoiceProvider(input);
38
+ return provider.listVoices();
6
39
  }
7
-
8
- //#endregion
9
- export { listVoices };
10
- //# sourceMappingURL=list-voices.js.map
40
+ export {
41
+ listVoices
42
+ };
@@ -1,11 +1,7 @@
1
- import { VoiceProviderFactoryInput } from "./create-provider.js";
2
- import { VoiceSynthesisInput, VoiceSynthesisResult } from "@contractspec/lib.contracts/integrations/providers/voice";
3
-
4
- //#region src/handlers/synthesize.d.ts
5
- interface SynthesizeVoiceInput extends VoiceProviderFactoryInput {
6
- synthesis: VoiceSynthesisInput;
1
+ import type { VoiceSynthesisInput, VoiceSynthesisResult } from '@contractspec/lib.contracts/integrations/providers/voice';
2
+ import { type VoiceProviderFactoryInput } from './create-provider';
3
+ export interface SynthesizeVoiceInput extends VoiceProviderFactoryInput {
4
+ synthesis: VoiceSynthesisInput;
7
5
  }
8
- declare function synthesizeVoice(input: SynthesizeVoiceInput): Promise<VoiceSynthesisResult>;
9
- //#endregion
10
- export { SynthesizeVoiceInput, synthesizeVoice };
6
+ export declare function synthesizeVoice(input: SynthesizeVoiceInput): Promise<VoiceSynthesisResult>;
11
7
  //# sourceMappingURL=synthesize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"synthesize.d.ts","names":[],"sources":["../../src/handlers/synthesize.ts"],"mappings":";;;;UAUiB,oBAAA,SAA6B,yBAAA;EAC5C,SAAA,EAAW,mBAAA;AAAA;AAAA,iBAGS,eAAA,CACpB,KAAA,EAAO,oBAAA,GACN,OAAA,CAAQ,oBAAA"}
1
+ {"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../src/handlers/synthesize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,0DAA0D,CAAC;AAElE,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,oBAAqB,SAAQ,yBAAyB;IACrE,SAAS,EAAE,mBAAmB,CAAC;CAChC;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CAG/B"}
@@ -1,10 +1,42 @@
1
- import { createVoiceProvider } from "./create-provider.js";
1
+ // @bun
2
+ // src/handlers/create-provider.ts
3
+ import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
4
+ import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
5
+ function createVoiceProvider(input) {
6
+ const { integrationKey, secrets, config } = input;
7
+ if (!secrets.apiKey) {
8
+ throw new Error("Voice provider apiKey is required.");
9
+ }
10
+ switch (integrationKey) {
11
+ case "ai-voice.gradium":
12
+ return new GradiumVoiceProvider({
13
+ apiKey: secrets.apiKey,
14
+ defaultVoiceId: config?.defaultVoiceId,
15
+ region: config?.region,
16
+ baseUrl: config?.baseUrl,
17
+ timeoutMs: config?.timeoutMs,
18
+ outputFormat: config?.outputFormat
19
+ });
20
+ case "ai-voice.fal":
21
+ return new FalVoiceProvider({
22
+ apiKey: secrets.apiKey,
23
+ modelId: config?.modelId,
24
+ defaultVoiceUrl: config?.defaultVoiceUrl,
25
+ defaultExaggeration: config?.defaultExaggeration,
26
+ defaultTemperature: config?.defaultTemperature,
27
+ defaultCfg: config?.defaultCfg,
28
+ pollIntervalMs: config?.pollIntervalMs
29
+ });
30
+ default:
31
+ throw new Error(`Unsupported voice provider: ${integrationKey}`);
32
+ }
33
+ }
2
34
 
3
- //#region src/handlers/synthesize.ts
35
+ // src/handlers/synthesize.ts
4
36
  async function synthesizeVoice(input) {
5
- return createVoiceProvider(input).synthesize(input.synthesis);
37
+ const provider = createVoiceProvider(input);
38
+ return provider.synthesize(input.synthesis);
6
39
  }
7
-
8
- //#endregion
9
- export { synthesizeVoice };
10
- //# sourceMappingURL=synthesize.js.map
40
+ export {
41
+ synthesizeVoice
42
+ };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { falVoiceConnection, gradiumVoiceConnection, voiceSampleConnections } from "./connection.sample.js";
2
- import example from "./example.js";
3
- import { VoiceIntegrationKey, VoiceProviderConfig, VoiceProviderFactoryInput, VoiceProviderSecrets, createVoiceProvider } from "./handlers/create-provider.js";
4
- import { listVoices } from "./handlers/list-voices.js";
5
- import { SynthesizeVoiceInput, synthesizeVoice } from "./handlers/synthesize.js";
6
- export { SynthesizeVoiceInput, VoiceIntegrationKey, VoiceProviderConfig, VoiceProviderFactoryInput, VoiceProviderSecrets, createVoiceProvider, example, falVoiceConnection, gradiumVoiceConnection, listVoices, synthesizeVoice, voiceSampleConnections };
1
+ export * from './handlers/create-provider';
2
+ export * from './handlers/list-voices';
3
+ export * from './handlers/synthesize';
4
+ export * from './connection.sample';
5
+ export { default as example } from './example';
6
+ import './docs';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,172 @@
1
- import { falVoiceConnection, gradiumVoiceConnection, voiceSampleConnections } from "./connection.sample.js";
2
- import example from "./example.js";
3
- import { createVoiceProvider } from "./handlers/create-provider.js";
4
- import { listVoices } from "./handlers/list-voices.js";
5
- import { synthesizeVoice } from "./handlers/synthesize.js";
6
- import "./docs/index.js";
7
-
8
- export { createVoiceProvider, example, falVoiceConnection, gradiumVoiceConnection, listVoices, synthesizeVoice, voiceSampleConnections };
1
+ // @bun
2
+ // src/connection.sample.ts
3
+ var gradiumVoiceConnection = {
4
+ meta: {
5
+ id: "conn-gradium-voice-demo",
6
+ tenantId: "acme-inc",
7
+ integrationKey: "ai-voice.gradium",
8
+ integrationVersion: "1.0.0",
9
+ label: "Gradium Voice",
10
+ environment: "production",
11
+ createdAt: "2026-01-01T00:00:00.000Z",
12
+ updatedAt: "2026-01-01T00:00:00.000Z"
13
+ },
14
+ ownershipMode: "byok",
15
+ config: {
16
+ defaultVoiceId: "YTpq7expH9539ERJ",
17
+ region: "eu",
18
+ outputFormat: "wav"
19
+ },
20
+ secretProvider: "vault",
21
+ secretRef: "vault://integrations/acme-inc/conn-gradium-voice-demo",
22
+ status: "connected"
23
+ };
24
+ var falVoiceConnection = {
25
+ meta: {
26
+ id: "conn-fal-voice-demo",
27
+ tenantId: "acme-inc",
28
+ integrationKey: "ai-voice.fal",
29
+ integrationVersion: "1.0.0",
30
+ label: "Fal Voice",
31
+ environment: "production",
32
+ createdAt: "2026-01-01T00:00:00.000Z",
33
+ updatedAt: "2026-01-01T00:00:00.000Z"
34
+ },
35
+ ownershipMode: "byok",
36
+ config: {
37
+ modelId: "fal-ai/chatterbox/text-to-speech",
38
+ defaultVoiceUrl: "https://storage.googleapis.com/chatterbox-demo-samples/prompts/male_rickmorty.mp3",
39
+ defaultExaggeration: 0.25,
40
+ defaultTemperature: 0.7,
41
+ defaultCfg: 0.5,
42
+ pollIntervalMs: 1000
43
+ },
44
+ secretProvider: "vault",
45
+ secretRef: "vault://integrations/acme-inc/conn-fal-voice-demo",
46
+ status: "connected"
47
+ };
48
+ var voiceSampleConnections = [
49
+ gradiumVoiceConnection,
50
+ falVoiceConnection
51
+ ];
52
+
53
+ // src/docs/voice-providers.docblock.ts
54
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
55
+ var blocks = [
56
+ {
57
+ id: "docs.examples.voice-providers",
58
+ title: "Voice Providers (example)",
59
+ summary: "Multi-provider voice integration example covering Gradium and Fal text-to-speech flows.",
60
+ kind: "reference",
61
+ visibility: "public",
62
+ route: "/docs/examples/voice-providers",
63
+ tags: ["voice", "tts", "gradium", "fal", "example"],
64
+ body: `## What this example shows
65
+ ` + "- Provider selection for `ai-voice.gradium` and `ai-voice.fal`.\n" + `- Listing voice catalogs and synthesizing text into audio bytes.
66
+ ` + `- Connection metadata patterns for BYOK secret references.
67
+
68
+ ` + `## Secrets and config
69
+ ` + "- `apiKey` for each provider.\n" + "- Gradium config: `defaultVoiceId`, `region`, `outputFormat`.\n" + "- Fal config: `modelId`, `defaultVoiceUrl`, synthesis tuning fields.\n\n" + `## Guardrails
70
+ ` + `- Keep API keys in secret providers only.
71
+ ` + `- Prefer declarative provider config over hardcoded runtime options.
72
+ ` + "- Keep synthesis side effects explicit for deterministic workflows."
73
+ },
74
+ {
75
+ id: "docs.examples.voice-providers.usage",
76
+ title: "Voice Providers - Usage",
77
+ summary: "How to wire provider factory and synthesis helpers in runtime code.",
78
+ kind: "usage",
79
+ visibility: "public",
80
+ route: "/docs/examples/voice-providers/usage",
81
+ tags: ["voice", "usage"],
82
+ body: `## Usage
83
+ ` + "- 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
84
+ ` + `- Fal uses an audio URL output; this example downloads bytes for a canonical result shape.
85
+ ` + "- Gradium maps provider output formats into ContractSpec voice result conventions."
86
+ }
87
+ ];
88
+ registerDocBlocks(blocks);
89
+ // src/example.ts
90
+ import { defineExample } from "@contractspec/lib.contracts";
91
+ var example = defineExample({
92
+ meta: {
93
+ key: "voice-providers",
94
+ version: "1.0.0",
95
+ title: "Voice Providers (Gradium and Fal)",
96
+ description: "Multi-provider voice integration example for Gradium and Fal text-to-speech adapters.",
97
+ kind: "integration",
98
+ visibility: "public",
99
+ stability: "experimental",
100
+ owners: ["@platform.integrations"],
101
+ tags: ["voice", "tts", "gradium", "fal", "integrations"]
102
+ },
103
+ docs: {
104
+ rootDocId: "docs.examples.voice-providers",
105
+ usageDocId: "docs.examples.voice-providers.usage"
106
+ },
107
+ entrypoints: {
108
+ packageName: "@contractspec/example.voice-providers",
109
+ docs: "./docs"
110
+ },
111
+ surfaces: {
112
+ templates: true,
113
+ sandbox: { enabled: true, modes: ["markdown", "specs"] },
114
+ studio: { enabled: true, installable: true },
115
+ mcp: { enabled: true }
116
+ }
117
+ });
118
+ var example_default = example;
119
+
120
+ // src/handlers/create-provider.ts
121
+ import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
122
+ import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
123
+ function createVoiceProvider(input) {
124
+ const { integrationKey, secrets, config } = input;
125
+ if (!secrets.apiKey) {
126
+ throw new Error("Voice provider apiKey is required.");
127
+ }
128
+ switch (integrationKey) {
129
+ case "ai-voice.gradium":
130
+ return new GradiumVoiceProvider({
131
+ apiKey: secrets.apiKey,
132
+ defaultVoiceId: config?.defaultVoiceId,
133
+ region: config?.region,
134
+ baseUrl: config?.baseUrl,
135
+ timeoutMs: config?.timeoutMs,
136
+ outputFormat: config?.outputFormat
137
+ });
138
+ case "ai-voice.fal":
139
+ return new FalVoiceProvider({
140
+ apiKey: secrets.apiKey,
141
+ modelId: config?.modelId,
142
+ defaultVoiceUrl: config?.defaultVoiceUrl,
143
+ defaultExaggeration: config?.defaultExaggeration,
144
+ defaultTemperature: config?.defaultTemperature,
145
+ defaultCfg: config?.defaultCfg,
146
+ pollIntervalMs: config?.pollIntervalMs
147
+ });
148
+ default:
149
+ throw new Error(`Unsupported voice provider: ${integrationKey}`);
150
+ }
151
+ }
152
+
153
+ // src/handlers/list-voices.ts
154
+ async function listVoices(input) {
155
+ const provider = createVoiceProvider(input);
156
+ return provider.listVoices();
157
+ }
158
+
159
+ // src/handlers/synthesize.ts
160
+ async function synthesizeVoice(input) {
161
+ const provider = createVoiceProvider(input);
162
+ return provider.synthesize(input.synthesis);
163
+ }
164
+ export {
165
+ voiceSampleConnections,
166
+ synthesizeVoice,
167
+ listVoices,
168
+ gradiumVoiceConnection,
169
+ falVoiceConnection,
170
+ example_default as example,
171
+ createVoiceProvider
172
+ };
@@ -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
+ };