@fonoster/sdk 0.27.0 → 0.31.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/README.md +12 -9
- package/dist/node/Agents.js +5 -20
- package/dist/node/Applications.d.ts +21 -85
- package/dist/node/Applications.js +64 -74
- package/dist/node/Billing.d.ts +50 -0
- package/dist/node/Billing.js +84 -0
- package/dist/node/CallRecords.d.ts +92 -0
- package/dist/node/CallRecords.js +127 -0
- package/dist/node/Calls.d.ts +3 -1
- package/dist/node/Calls.js +3 -1
- package/dist/node/Domains.js +4 -2
- package/dist/node/Numbers.js +2 -7
- package/dist/node/Providers.d.ts +49 -0
- package/dist/node/Providers.js +109 -0
- package/dist/node/Regions.d.ts +91 -0
- package/dist/node/Regions.js +127 -0
- package/dist/node/Usage.d.ts +44 -0
- package/dist/node/Usage.js +41 -0
- package/dist/node/Users.d.ts +4 -2
- package/dist/node/Users.js +4 -2
- package/dist/node/Webhooks.d.ts +56 -0
- package/dist/node/Webhooks.js +139 -0
- package/dist/node/Workspaces.d.ts +22 -3
- package/dist/node/Workspaces.js +29 -2
- package/dist/node/client/AbstractClient.d.ts +94 -3
- package/dist/node/client/AbstractClient.js +101 -1
- package/dist/node/client/Client.d.ts +9 -0
- package/dist/node/client/Client.js +34 -1
- package/dist/node/client/jsonToObject.js +17 -0
- package/dist/node/client/objectToJson.js +35 -0
- package/dist/node/client/types/ApplicationsClient.d.ts +2 -1
- package/dist/node/client/types/BillingClient.d.ts +28 -0
- package/dist/node/client/types/BillingClient.js +2 -0
- package/dist/node/client/types/CapabilitiesClient.d.ts +24 -0
- package/dist/node/client/types/CapabilitiesClient.js +2 -0
- package/dist/node/client/types/FonosterClient.d.ts +12 -0
- package/dist/node/client/types/IdentityClient.d.ts +3 -1
- package/dist/node/client/types/ProvidersClient.d.ts +28 -0
- package/dist/node/client/types/ProvidersClient.js +2 -0
- package/dist/node/client/types/UsageClient.d.ts +24 -0
- package/dist/node/client/types/UsageClient.js +2 -0
- package/dist/node/client/types/WebhooksClient.d.ts +31 -0
- package/dist/node/client/types/WebhooksClient.js +2 -0
- package/dist/node/client/types/index.d.ts +5 -0
- package/dist/node/client/types/index.js +5 -0
- package/dist/node/generated/node/applications_grpc_pb.js +34 -0
- package/dist/node/generated/node/applications_pb.js +2991 -178
- package/dist/node/generated/node/billing_grpc_pb.js +169 -0
- package/dist/node/generated/node/billing_pb.js +1720 -0
- package/dist/node/generated/node/calls_pb.js +62 -2
- package/dist/node/generated/node/capabilities_grpc_pb.js +66 -0
- package/dist/node/generated/node/capabilities_pb.js +2288 -0
- package/dist/node/generated/node/identity_grpc_pb.js +34 -0
- package/dist/node/generated/node/identity_pb.js +609 -5
- package/dist/node/generated/node/providers_grpc_pb.js +200 -0
- package/dist/node/generated/node/providers_pb.js +3094 -0
- package/dist/node/generated/node/usage_grpc_pb.js +64 -0
- package/dist/node/generated/node/usage_pb.js +866 -0
- package/dist/node/generated/node/webhooks_grpc_pb.js +302 -0
- package/dist/node/generated/node/webhooks_pb.js +3314 -0
- package/dist/node/generated/web/ApplicationsServiceClientPb.ts +43 -0
- package/dist/node/generated/web/BillingServiceClientPb.ts +258 -0
- package/dist/node/generated/web/CapabilitiesServiceClientPb.ts +87 -0
- package/dist/node/generated/web/IdentityServiceClientPb.ts +43 -0
- package/dist/node/generated/web/ProvidersServiceClientPb.ts +258 -0
- package/dist/node/generated/web/UsageServiceClientPb.ts +86 -0
- package/dist/node/generated/web/WebhooksServiceClientPb.ts +387 -0
- package/dist/node/generated/web/applications_pb.d.ts +343 -1
- package/dist/node/generated/web/applications_pb.js +2991 -178
- package/dist/node/generated/web/billing_pb.d.ts +210 -0
- package/dist/node/generated/web/billing_pb.js +1720 -0
- package/dist/node/generated/web/calls_pb.d.ts +8 -0
- package/dist/node/generated/web/calls_pb.js +62 -2
- package/dist/node/generated/web/capabilities_pb.d.ts +273 -0
- package/dist/node/generated/web/capabilities_pb.js +2288 -0
- package/dist/node/generated/web/identity_pb.d.ts +76 -0
- package/dist/node/generated/web/identity_pb.js +609 -5
- package/dist/node/generated/web/providers_pb.d.ts +372 -0
- package/dist/node/generated/web/providers_pb.js +3094 -0
- package/dist/node/generated/web/usage_pb.d.ts +106 -0
- package/dist/node/generated/web/usage_pb.js +866 -0
- package/dist/node/generated/web/webhooks_pb.d.ts +398 -0
- package/dist/node/generated/web/webhooks_pb.js +3314 -0
- package/dist/node/node.d.ts +7 -0
- package/dist/node/node.js +6 -0
- package/dist/node/tsconfig.tsbuildinfo +1 -1
- package/dist/node/utils.d.ts +7 -12
- package/dist/node/utils.js +18 -39
- package/dist/web/fonoster.min.js +1 -1
- package/dist/web/index.esm.js +1 -1
- package/package.json +8 -13
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ In Node.js:
|
|
|
64
64
|
```typescript
|
|
65
65
|
const SDK = require("@fonoster/sdk");
|
|
66
66
|
const ACCESS_KEY_ID = "WO00000000000000000000000000000000";
|
|
67
|
-
const ENDPOINT = "api.fonoster.
|
|
67
|
+
const ENDPOINT = "api.fonoster.ai";
|
|
68
68
|
const client = new SDK.Client({ accessKeyId: ACCESS_KEY_ID, endpoint: ENDPOINT });
|
|
69
69
|
```
|
|
70
70
|
|
|
@@ -75,7 +75,7 @@ In the browser:
|
|
|
75
75
|
```typescript
|
|
76
76
|
const SDK = require("@fonoster/sdk");
|
|
77
77
|
const ACCESS_KEY_ID = "WO00000000000000000000000000000000";
|
|
78
|
-
const URL = "https://api.fonoster.
|
|
78
|
+
const URL = "https://api.fonoster.ai/v1beta2";
|
|
79
79
|
const client = new SDK.WebClient({ accessKeyId: ACCESS_KEY_ID, url: URL });
|
|
80
80
|
```
|
|
81
81
|
|
|
@@ -92,7 +92,7 @@ async function main() {
|
|
|
92
92
|
const applications = new SDK.Applications(client);
|
|
93
93
|
await applications.createApplication({
|
|
94
94
|
name: "MyApp",
|
|
95
|
-
type: "
|
|
95
|
+
type: "STREAM",
|
|
96
96
|
endpoint: "localhost:50061" // Your app's endpoint
|
|
97
97
|
});
|
|
98
98
|
}
|
|
@@ -694,7 +694,8 @@ apiKeys
|
|
|
694
694
|
|
|
695
695
|
## Applications
|
|
696
696
|
Fonoster Applications, part of the Fonoster Voice Subsystem,
|
|
697
|
-
allow you to create, update, retrieve, and delete
|
|
697
|
+
allow you to create, update, retrieve, and delete Applications: streams (your own WebSocket
|
|
698
|
+
server) and Autopilot agents.
|
|
698
699
|
Note that an active Fonoster deployment is required.
|
|
699
700
|
|
|
700
701
|
**Kind**: global class
|
|
@@ -747,7 +748,7 @@ async function main(request) {
|
|
|
747
748
|
|
|
748
749
|
const request = {
|
|
749
750
|
name: "My application",
|
|
750
|
-
type: "
|
|
751
|
+
type: "STREAM",
|
|
751
752
|
endpoint: "welcome.demo.fonoster.local", // Built-in demo application
|
|
752
753
|
speechToText: {
|
|
753
754
|
productRef: "stt.deepgram",
|
|
@@ -778,7 +779,7 @@ Creates a new Application in Fonoster. The only required fields are the name and
|
|
|
778
779
|
| --- | --- | --- |
|
|
779
780
|
| request | <code>CreateApplicationRequest</code> | The request object that contains the necessary information to create a new application |
|
|
780
781
|
| request.name | <code>string</code> | The name of the application |
|
|
781
|
-
| request.type | <code>ApplicationType</code> | The type of application
|
|
782
|
+
| request.type | <code>ApplicationType</code> | The type of application: STREAM or AUTOPILOT |
|
|
782
783
|
| request.endpoint | <code>string</code> | The endpoint where the application is hosted |
|
|
783
784
|
| request.speechToText | <code>SpeechToText</code> | The speech-to-text configuration |
|
|
784
785
|
| request.speechToText.productRef | <code>string</code> | The product reference of the speech-to-text engine (e.g., stt.deepgram) |
|
|
@@ -796,7 +797,7 @@ const apps = new SDK.Applications(client); // Existing client object
|
|
|
796
797
|
|
|
797
798
|
const request = {
|
|
798
799
|
name: "My application",
|
|
799
|
-
type: "
|
|
800
|
+
type: "STREAM",
|
|
800
801
|
endpoint: "welcome.demo.fonoster.local", // Built-in demo application
|
|
801
802
|
speechToText: {
|
|
802
803
|
productRef: "stt.deepgram",
|
|
@@ -955,7 +956,7 @@ const request = {
|
|
|
955
956
|
config: {
|
|
956
957
|
conversationSettings: {
|
|
957
958
|
firstMessage: "Hello, how can I help you today?",
|
|
958
|
-
systemPrompt: "You are a helpful
|
|
959
|
+
systemPrompt: "You are a helpful agent.",
|
|
959
960
|
systemErrorMessage: "I'm sorry, I didn't catch that. Can you say that again?",
|
|
960
961
|
goodbyeMessage: "Thank you for calling. Have a great day!",
|
|
961
962
|
languageModel: {
|
|
@@ -1139,6 +1140,7 @@ Retrieves a list of Calls from a Workspace.
|
|
|
1139
1140
|
| request | <code>ListCallsRequest</code> | The request object that contains the necessary information to retrieve a list of Calls |
|
|
1140
1141
|
| request.pageSize | <code>number</code> | The number of Calls to retrieve |
|
|
1141
1142
|
| request.pageToken | <code>string</code> | The token to retrieve the next page of Calls |
|
|
1143
|
+
| request.appRef | <code>string</code> | Optional. Lists only the Calls the App with this reference handled |
|
|
1142
1144
|
|
|
1143
1145
|
**Example**
|
|
1144
1146
|
```js
|
|
@@ -1146,7 +1148,8 @@ const calls = new SDK.Calls(client); // Existing client object
|
|
|
1146
1148
|
|
|
1147
1149
|
const request = {
|
|
1148
1150
|
pageSize: 10,
|
|
1149
|
-
pageToken: "00000000-0000-0000-0000-000000000000"
|
|
1151
|
+
pageToken: "00000000-0000-0000-0000-000000000000",
|
|
1152
|
+
appRef: "00000000-0000-0000-0000-000000000000" // Optional: only this App's Calls
|
|
1150
1153
|
};
|
|
1151
1154
|
|
|
1152
1155
|
calls
|
package/dist/node/Agents.js
CHANGED
|
@@ -114,15 +114,8 @@ class Agents {
|
|
|
114
114
|
request: { ref },
|
|
115
115
|
enumMapping: [["privacy", agents_pb_1.Privacy]]
|
|
116
116
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return response
|
|
120
|
-
? {
|
|
121
|
-
...response,
|
|
122
|
-
credentials,
|
|
123
|
-
domain
|
|
124
|
-
}
|
|
125
|
-
: null;
|
|
117
|
+
// The domain and credentials come back as plain objects (objectToJson).
|
|
118
|
+
return response ?? null;
|
|
126
119
|
}
|
|
127
120
|
/**
|
|
128
121
|
* Updates an existing Agent in the Workspace.
|
|
@@ -192,19 +185,11 @@ class Agents {
|
|
|
192
185
|
enumMapping: [["privacy", agents_pb_1.Privacy]],
|
|
193
186
|
repeatableObjectMapping: [["itemsList", agents_pb_1.Agent]]
|
|
194
187
|
});
|
|
195
|
-
//
|
|
196
|
-
|
|
197
|
-
const credentials = agent?.credentials?.toObject();
|
|
198
|
-
const domain = agent?.domain?.toObject();
|
|
199
|
-
return {
|
|
200
|
-
...agent,
|
|
201
|
-
credentials,
|
|
202
|
-
domain
|
|
203
|
-
};
|
|
204
|
-
});
|
|
188
|
+
// Each agent's domain and credentials come back as plain objects
|
|
189
|
+
// (objectToJson); calling toObject() on them threw "toObject is not a function".
|
|
205
190
|
return {
|
|
206
191
|
...response,
|
|
207
|
-
items:
|
|
192
|
+
items: response.items ?? []
|
|
208
193
|
};
|
|
209
194
|
}
|
|
210
195
|
/**
|
|
@@ -16,57 +16,9 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { Application, BaseApiObject, CreateApplicationRequest, EvaluateIntelligenceEvent, EvaluateIntelligenceRequest, ListApplicationsRequest, ListApplicationsResponse, UpdateApplicationRequest } from "@fonoster/types";
|
|
19
|
+
import { Application, BaseApiObject, CreateApplicationRequest, CreateApplicationResponse, EvaluateIntelligenceEvent, EvaluateIntelligenceRequest, ListApplicationsRequest, ListApplicationsResponse, RotateSigningSecretResponse, UpdateApplicationRequest, UpdateApplicationResponse } from "@fonoster/types";
|
|
20
20
|
import { FonosterClient } from "./client/types";
|
|
21
21
|
import { TestTokenResponse } from "./generated/node/applications_pb";
|
|
22
|
-
/**
|
|
23
|
-
* @classdesc Fonoster Applications, part of the Fonoster Voice Subsystem,
|
|
24
|
-
* allow you to create, update, retrieve, and delete Voice Applications.
|
|
25
|
-
* Note that an active Fonoster deployment is required.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
*
|
|
29
|
-
* const SDK = require("@fonoster/sdk");
|
|
30
|
-
*
|
|
31
|
-
* async function main(request) {
|
|
32
|
-
* const apiKey = "your-api-key";
|
|
33
|
-
* const apiSecret = "your-api-secret"
|
|
34
|
-
* const accessKeyId = "WO00000000000000000000000000000000";
|
|
35
|
-
*
|
|
36
|
-
* try {
|
|
37
|
-
* const client = SDK.Client({ accessKeyId });
|
|
38
|
-
* await client.loginWithApiKey(apiKey, apiSecret);
|
|
39
|
-
*
|
|
40
|
-
* const apps = new SDK.Applications(client);
|
|
41
|
-
* const response = await apps.createApplication(request);
|
|
42
|
-
*
|
|
43
|
-
* console.log(response); // successful response
|
|
44
|
-
* } catch (e) {
|
|
45
|
-
* console.error(e); // an error occurred
|
|
46
|
-
* }
|
|
47
|
-
* }
|
|
48
|
-
*
|
|
49
|
-
* const request = {
|
|
50
|
-
* name: "My application",
|
|
51
|
-
* type: "EXTERNAL",
|
|
52
|
-
* endpoint: "welcome.demo.fonoster.local", // Built-in demo application
|
|
53
|
-
* speechToText: {
|
|
54
|
-
* productRef: "stt.deepgram",
|
|
55
|
-
* config: {
|
|
56
|
-
* model: "nova-2",
|
|
57
|
-
* languageCode: "en-US"
|
|
58
|
-
* }
|
|
59
|
-
* },
|
|
60
|
-
* textToSpeech: {
|
|
61
|
-
* productRef: "tts.elevenlabs",
|
|
62
|
-
* config: {
|
|
63
|
-
* voice: "lrTWbMInQjSJ9q5ywFKP"
|
|
64
|
-
* }
|
|
65
|
-
* }
|
|
66
|
-
* };
|
|
67
|
-
*
|
|
68
|
-
* main(request);
|
|
69
|
-
*/
|
|
70
22
|
declare class Applications {
|
|
71
23
|
private readonly client;
|
|
72
24
|
/**
|
|
@@ -82,37 +34,19 @@ declare class Applications {
|
|
|
82
34
|
*
|
|
83
35
|
* @param {CreateApplicationRequest} request - The request object that contains the necessary information to create a new application
|
|
84
36
|
* @param {string} request.name - The name of the application
|
|
85
|
-
* @param {ApplicationType} request.type - The type of application
|
|
37
|
+
* @param {ApplicationType} request.type - The type of application: STREAM or AUTOPILOT
|
|
86
38
|
* @param {string} request.endpoint - The endpoint where the application is hosted
|
|
87
|
-
* @param {SpeechToText} request.speechToText - The speech-to-text configuration
|
|
88
|
-
* @param {string} request.speechToText.productRef - The product reference of the speech-to-text engine (e.g., stt.deepgram)
|
|
89
|
-
* @param {object} request.speechToText.config - The configuration object for the speech-to-text engine (e.g., { model: "nova-2", languageCode: "en-US" })
|
|
90
|
-
* @param {TextToSpeech} request.textToSpeech - The text-to-speech configuration
|
|
91
|
-
* @param {string} request.textToSpeech.productRef - The product reference of the text-to-speech engine (e.g., tts.elevenlabs)
|
|
92
|
-
* @param {object} request.textToSpeech.config - The configuration object for the text-to-speech engine (e.g., { voice: "lrTWbMInQjSJ9q5ywFKP" })
|
|
93
39
|
* @param {Intelligence} request.intelligence - The intelligence configuration
|
|
94
|
-
* @param {
|
|
95
|
-
* @param {object} request.intelligence.config - The configuration object for the intelligence engine
|
|
40
|
+
* @param {object} request.intelligence.config - Autopilot agents: the agent (its model is a catalog id such as openai/gpt-4o-mini)
|
|
96
41
|
* @return {Promise<CreateAppResponse>} - The response object that contains the reference to the newly created application
|
|
97
42
|
* @example
|
|
98
43
|
* const apps = new SDK.Applications(client); // Existing client object
|
|
99
44
|
*
|
|
100
45
|
* const request = {
|
|
101
46
|
* name: "My application",
|
|
102
|
-
* type: "
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* productRef: "stt.deepgram",
|
|
106
|
-
* config: {
|
|
107
|
-
* languageCode: "en-US"
|
|
108
|
-
* }
|
|
109
|
-
* },
|
|
110
|
-
* textToSpeech: {
|
|
111
|
-
* productRef: "tts.elevenlabs",
|
|
112
|
-
* config: {
|
|
113
|
-
* voice: "lrTWbMInQjSJ9q5ywFKP"
|
|
114
|
-
* }
|
|
115
|
-
* }
|
|
47
|
+
* type: "STREAM",
|
|
48
|
+
* url: "wss://bot.example.com/session",
|
|
49
|
+
* speech: { voice: "elevenlabs/21m00Tcm4TlvDq8ikWAM", language: "en-US" }
|
|
116
50
|
* };
|
|
117
51
|
*
|
|
118
52
|
* apps
|
|
@@ -120,7 +54,7 @@ declare class Applications {
|
|
|
120
54
|
* .then(console.log) // successful response
|
|
121
55
|
* .catch(console.error); // an error occurred
|
|
122
56
|
*/
|
|
123
|
-
createApplication(request: CreateApplicationRequest): Promise<
|
|
57
|
+
createApplication(request: CreateApplicationRequest): Promise<CreateApplicationResponse>;
|
|
124
58
|
/**
|
|
125
59
|
* Retrieves an existing Application in the Workspace.
|
|
126
60
|
*
|
|
@@ -144,15 +78,8 @@ declare class Applications {
|
|
|
144
78
|
* @param {string} request.ref - The reference of the application to update
|
|
145
79
|
* @param {string} request.name - The name of the application
|
|
146
80
|
* @param {string} request.endpoint - The endpoint where the application is hosted
|
|
147
|
-
* @param {SpeechToText} request.speechToText - The speech-to-text configuration
|
|
148
|
-
* @param {string} request.speechToText.productRef - The product reference of the speech-to-text engine (e.g., stt.deepgram)
|
|
149
|
-
* @param {object} request.speechToText.config - The configuration object for the speech-to-text engine (e.g., { model: "nova-2", languageCode: "en-US" })
|
|
150
|
-
* @param {TextToSpeech} request.textToSpeech - The text-to-speech configuration
|
|
151
|
-
* @param {string} request.textToSpeech.productRef - The product reference of the text-to-speech engine (e.g., tts.elevenlabs)
|
|
152
|
-
* @param {object} request.textToSpeech.config - The configuration object for the text-to-speech engine (e.g., { voice: "lrTWbMInQjSJ9q5ywFKP" })
|
|
153
81
|
* @param {Intelligence} request.intelligence - The intelligence configuration
|
|
154
|
-
* @param {
|
|
155
|
-
* @param {object} request.intelligence.config - The configuration object for the intelligence engine
|
|
82
|
+
* @param {object} request.intelligence.config - Autopilot agents: the agent (its model is a catalog id such as openai/gpt-4o-mini)
|
|
156
83
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated application
|
|
157
84
|
* @example
|
|
158
85
|
* const apps = new SDK.Applications(client); // Existing client object
|
|
@@ -160,7 +87,7 @@ declare class Applications {
|
|
|
160
87
|
* const request = {
|
|
161
88
|
* ref: "00000000-0000-0000-0000-000000000000",
|
|
162
89
|
* name: "My application",
|
|
163
|
-
*
|
|
90
|
+
* url: "wss://bot.example.com/session"
|
|
164
91
|
* };
|
|
165
92
|
*
|
|
166
93
|
* apps
|
|
@@ -168,7 +95,7 @@ declare class Applications {
|
|
|
168
95
|
* .then(console.log) // successful response
|
|
169
96
|
* .catch(console.error); // an error occurred
|
|
170
97
|
*/
|
|
171
|
-
updateApplication(request: UpdateApplicationRequest): Promise<
|
|
98
|
+
updateApplication(request: UpdateApplicationRequest): Promise<UpdateApplicationResponse>;
|
|
172
99
|
/**
|
|
173
100
|
* Retrieves a list of Applications from Fonoster.
|
|
174
101
|
*
|
|
@@ -206,13 +133,22 @@ declare class Applications {
|
|
|
206
133
|
* .then(console.log) // successful response
|
|
207
134
|
* .catch(console.error); // an error occurred
|
|
208
135
|
*/
|
|
136
|
+
/**
|
|
137
|
+
* Replaces the app's signing secret. The old secret stops working at once (no overlap window),
|
|
138
|
+
* so redeploy the app with the new one. The secret is returned only here.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} ref - The application's reference
|
|
141
|
+
* @return {Promise<RotateSigningSecretResponse>} - The new secret and its hint
|
|
142
|
+
* @example
|
|
143
|
+
* const { signingSecret } = await applications.rotateSigningSecret("00000000-...");
|
|
144
|
+
*/
|
|
145
|
+
rotateSigningSecret(ref: string): Promise<RotateSigningSecretResponse>;
|
|
209
146
|
deleteApplication(ref: string): Promise<BaseApiObject>;
|
|
210
147
|
/**
|
|
211
148
|
* Evaluates the intelligence of an application.
|
|
212
149
|
*
|
|
213
150
|
* @param {EvaluateIntelligenceRequest} request - The request object that contains the necessary information to evaluate the intelligence of an application
|
|
214
|
-
* @param {
|
|
215
|
-
* @param {object} request.intelligence.config - The configuration object for the intelligence engine
|
|
151
|
+
* @param {object} request.intelligence.config - Autopilot agents: the agent (its model is a catalog id such as openai/gpt-4o-mini)
|
|
216
152
|
* @return {AsyncGenerator<EvaluateIntelligenceEvent>} - Stream of evaluation events (step results, scenario summaries, or errors)
|
|
217
153
|
* @example
|
|
218
154
|
* const apps = new SDK.Applications(client);
|
|
@@ -27,7 +27,8 @@ const applications_pb_1 = require("./generated/node/applications_pb");
|
|
|
27
27
|
const utils_1 = require("./utils");
|
|
28
28
|
/**
|
|
29
29
|
* @classdesc Fonoster Applications, part of the Fonoster Voice Subsystem,
|
|
30
|
-
* allow you to create, update, retrieve, and delete
|
|
30
|
+
* allow you to create, update, retrieve, and delete Applications: streams (your own WebSocket
|
|
31
|
+
* server) and Autopilot agents.
|
|
31
32
|
* Note that an active Fonoster deployment is required.
|
|
32
33
|
*
|
|
33
34
|
* @example
|
|
@@ -54,25 +55,34 @@ const utils_1 = require("./utils");
|
|
|
54
55
|
*
|
|
55
56
|
* const request = {
|
|
56
57
|
* name: "My application",
|
|
57
|
-
* type: "
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* config: {
|
|
62
|
-
* model: "nova-2",
|
|
63
|
-
* languageCode: "en-US"
|
|
64
|
-
* }
|
|
65
|
-
* },
|
|
66
|
-
* textToSpeech: {
|
|
67
|
-
* productRef: "tts.elevenlabs",
|
|
68
|
-
* config: {
|
|
69
|
-
* voice: "lrTWbMInQjSJ9q5ywFKP"
|
|
70
|
-
* }
|
|
71
|
-
* }
|
|
58
|
+
* type: "STREAM",
|
|
59
|
+
* url: "wss://bot.example.com/session", // Serves the session protocol (@fonoster/voice)
|
|
60
|
+
* protocol: "fonoster", // or "twilio" for a Twilio Media Streams server
|
|
61
|
+
* speech: { voice: "elevenlabs/21m00Tcm4TlvDq8ikWAM", language: "en-US" }
|
|
72
62
|
* };
|
|
73
63
|
*
|
|
74
64
|
* main(request);
|
|
75
65
|
*/
|
|
66
|
+
/** Nested messages of create and update requests (the application model). */
|
|
67
|
+
const REQUEST_OBJECTS = [
|
|
68
|
+
["intelligence", applications_pb_1.ProductContainer],
|
|
69
|
+
["speech", applications_pb_1.SpeechDefaults],
|
|
70
|
+
["audio", applications_pb_1.AudioFormat],
|
|
71
|
+
["listeners", applications_pb_1.Listener],
|
|
72
|
+
["amd", applications_pb_1.AmdSettings],
|
|
73
|
+
["filters", applications_pb_1.AudioFilter]
|
|
74
|
+
];
|
|
75
|
+
/** Repeated messages of an Application in responses (their options Structs are converted after). */
|
|
76
|
+
const RESPONSE_REPEATED = [["filtersList", applications_pb_1.AudioFilter]];
|
|
77
|
+
/** Repeated fields come back as `listenersList` when empty; always return `listeners`. */
|
|
78
|
+
function withSessionFields(app) {
|
|
79
|
+
const { listenersList, filtersList, ...rest } = app;
|
|
80
|
+
return {
|
|
81
|
+
...rest,
|
|
82
|
+
listeners: (rest.listeners ?? listenersList ?? []),
|
|
83
|
+
filters: (rest.filters ?? filtersList ?? [])
|
|
84
|
+
};
|
|
85
|
+
}
|
|
76
86
|
class Applications {
|
|
77
87
|
client;
|
|
78
88
|
/**
|
|
@@ -90,37 +100,19 @@ class Applications {
|
|
|
90
100
|
*
|
|
91
101
|
* @param {CreateApplicationRequest} request - The request object that contains the necessary information to create a new application
|
|
92
102
|
* @param {string} request.name - The name of the application
|
|
93
|
-
* @param {ApplicationType} request.type - The type of application
|
|
103
|
+
* @param {ApplicationType} request.type - The type of application: STREAM or AUTOPILOT
|
|
94
104
|
* @param {string} request.endpoint - The endpoint where the application is hosted
|
|
95
|
-
* @param {SpeechToText} request.speechToText - The speech-to-text configuration
|
|
96
|
-
* @param {string} request.speechToText.productRef - The product reference of the speech-to-text engine (e.g., stt.deepgram)
|
|
97
|
-
* @param {object} request.speechToText.config - The configuration object for the speech-to-text engine (e.g., { model: "nova-2", languageCode: "en-US" })
|
|
98
|
-
* @param {TextToSpeech} request.textToSpeech - The text-to-speech configuration
|
|
99
|
-
* @param {string} request.textToSpeech.productRef - The product reference of the text-to-speech engine (e.g., tts.elevenlabs)
|
|
100
|
-
* @param {object} request.textToSpeech.config - The configuration object for the text-to-speech engine (e.g., { voice: "lrTWbMInQjSJ9q5ywFKP" })
|
|
101
105
|
* @param {Intelligence} request.intelligence - The intelligence configuration
|
|
102
|
-
* @param {
|
|
103
|
-
* @param {object} request.intelligence.config - The configuration object for the intelligence engine
|
|
106
|
+
* @param {object} request.intelligence.config - Autopilot agents: the agent (its model is a catalog id such as openai/gpt-4o-mini)
|
|
104
107
|
* @return {Promise<CreateAppResponse>} - The response object that contains the reference to the newly created application
|
|
105
108
|
* @example
|
|
106
109
|
* const apps = new SDK.Applications(client); // Existing client object
|
|
107
110
|
*
|
|
108
111
|
* const request = {
|
|
109
112
|
* name: "My application",
|
|
110
|
-
* type: "
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* productRef: "stt.deepgram",
|
|
114
|
-
* config: {
|
|
115
|
-
* languageCode: "en-US"
|
|
116
|
-
* }
|
|
117
|
-
* },
|
|
118
|
-
* textToSpeech: {
|
|
119
|
-
* productRef: "tts.elevenlabs",
|
|
120
|
-
* config: {
|
|
121
|
-
* voice: "lrTWbMInQjSJ9q5ywFKP"
|
|
122
|
-
* }
|
|
123
|
-
* }
|
|
113
|
+
* type: "STREAM",
|
|
114
|
+
* url: "wss://bot.example.com/session",
|
|
115
|
+
* speech: { voice: "elevenlabs/21m00Tcm4TlvDq8ikWAM", language: "en-US" }
|
|
124
116
|
* };
|
|
125
117
|
*
|
|
126
118
|
* apps
|
|
@@ -137,11 +129,7 @@ class Applications {
|
|
|
137
129
|
metadata: this.client.getMetadata(),
|
|
138
130
|
request: reqWithStructOverride,
|
|
139
131
|
enumMapping: [["type", applications_pb_1.ApplicationType]],
|
|
140
|
-
objectMapping:
|
|
141
|
-
["textToSpeech", applications_pb_1.ProductContainer],
|
|
142
|
-
["speechToText", applications_pb_1.ProductContainer],
|
|
143
|
-
["intelligence", applications_pb_1.ProductContainer]
|
|
144
|
-
]
|
|
132
|
+
objectMapping: REQUEST_OBJECTS
|
|
145
133
|
});
|
|
146
134
|
}
|
|
147
135
|
/**
|
|
@@ -167,13 +155,10 @@ class Applications {
|
|
|
167
155
|
metadata: this.client.getMetadata(),
|
|
168
156
|
request: { ref },
|
|
169
157
|
enumMapping: [["type", applications_pb_1.ApplicationType]],
|
|
170
|
-
objectMapping: [
|
|
171
|
-
|
|
172
|
-
["speechToText", applications_pb_1.ProductContainer],
|
|
173
|
-
["intelligence", applications_pb_1.ProductContainer]
|
|
174
|
-
]
|
|
158
|
+
objectMapping: [["intelligence", applications_pb_1.ProductContainer]],
|
|
159
|
+
repeatableObjectMapping: RESPONSE_REPEATED
|
|
175
160
|
});
|
|
176
|
-
return (0, utils_1.buildStructOverrideReverse)(response);
|
|
161
|
+
return withSessionFields((0, utils_1.buildStructOverrideReverse)(response));
|
|
177
162
|
}
|
|
178
163
|
/**
|
|
179
164
|
* Updates an existing application in Fonoster.
|
|
@@ -182,15 +167,8 @@ class Applications {
|
|
|
182
167
|
* @param {string} request.ref - The reference of the application to update
|
|
183
168
|
* @param {string} request.name - The name of the application
|
|
184
169
|
* @param {string} request.endpoint - The endpoint where the application is hosted
|
|
185
|
-
* @param {SpeechToText} request.speechToText - The speech-to-text configuration
|
|
186
|
-
* @param {string} request.speechToText.productRef - The product reference of the speech-to-text engine (e.g., stt.deepgram)
|
|
187
|
-
* @param {object} request.speechToText.config - The configuration object for the speech-to-text engine (e.g., { model: "nova-2", languageCode: "en-US" })
|
|
188
|
-
* @param {TextToSpeech} request.textToSpeech - The text-to-speech configuration
|
|
189
|
-
* @param {string} request.textToSpeech.productRef - The product reference of the text-to-speech engine (e.g., tts.elevenlabs)
|
|
190
|
-
* @param {object} request.textToSpeech.config - The configuration object for the text-to-speech engine (e.g., { voice: "lrTWbMInQjSJ9q5ywFKP" })
|
|
191
170
|
* @param {Intelligence} request.intelligence - The intelligence configuration
|
|
192
|
-
* @param {
|
|
193
|
-
* @param {object} request.intelligence.config - The configuration object for the intelligence engine
|
|
171
|
+
* @param {object} request.intelligence.config - Autopilot agents: the agent (its model is a catalog id such as openai/gpt-4o-mini)
|
|
194
172
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated application
|
|
195
173
|
* @example
|
|
196
174
|
* const apps = new SDK.Applications(client); // Existing client object
|
|
@@ -198,7 +176,7 @@ class Applications {
|
|
|
198
176
|
* const request = {
|
|
199
177
|
* ref: "00000000-0000-0000-0000-000000000000",
|
|
200
178
|
* name: "My application",
|
|
201
|
-
*
|
|
179
|
+
* url: "wss://bot.example.com/session"
|
|
202
180
|
* };
|
|
203
181
|
*
|
|
204
182
|
* apps
|
|
@@ -215,11 +193,7 @@ class Applications {
|
|
|
215
193
|
metadata: this.client.getMetadata(),
|
|
216
194
|
request: reqWithStructOverride,
|
|
217
195
|
enumMapping: [["type", applications_pb_1.ApplicationType]],
|
|
218
|
-
objectMapping:
|
|
219
|
-
["textToSpeech", applications_pb_1.ProductContainer],
|
|
220
|
-
["speechToText", applications_pb_1.ProductContainer],
|
|
221
|
-
["intelligence", applications_pb_1.ProductContainer]
|
|
222
|
-
]
|
|
196
|
+
objectMapping: REQUEST_OBJECTS
|
|
223
197
|
});
|
|
224
198
|
}
|
|
225
199
|
/**
|
|
@@ -250,15 +224,14 @@ class Applications {
|
|
|
250
224
|
metadata: this.client.getMetadata(),
|
|
251
225
|
request,
|
|
252
226
|
enumMapping: [["type", applications_pb_1.ApplicationType]],
|
|
253
|
-
objectMapping: [
|
|
254
|
-
|
|
255
|
-
["
|
|
256
|
-
|
|
257
|
-
]
|
|
258
|
-
repeatableObjectMapping: [["itemsList", applications_pb_1.Application]]
|
|
227
|
+
objectMapping: [["intelligence", applications_pb_1.ProductContainer]],
|
|
228
|
+
repeatableObjectMapping: [
|
|
229
|
+
["itemsList", applications_pb_1.Application],
|
|
230
|
+
...RESPONSE_REPEATED
|
|
231
|
+
]
|
|
259
232
|
});
|
|
260
233
|
return {
|
|
261
|
-
items: response.items.map(utils_1.buildStructOverrideReverse),
|
|
234
|
+
items: response.items.map((item) => withSessionFields((0, utils_1.buildStructOverrideReverse)(item))),
|
|
262
235
|
nextPageToken: response.nextPageToken
|
|
263
236
|
};
|
|
264
237
|
}
|
|
@@ -278,6 +251,24 @@ class Applications {
|
|
|
278
251
|
* .then(console.log) // successful response
|
|
279
252
|
* .catch(console.error); // an error occurred
|
|
280
253
|
*/
|
|
254
|
+
/**
|
|
255
|
+
* Replaces the app's signing secret. The old secret stops working at once (no overlap window),
|
|
256
|
+
* so redeploy the app with the new one. The secret is returned only here.
|
|
257
|
+
*
|
|
258
|
+
* @param {string} ref - The application's reference
|
|
259
|
+
* @return {Promise<RotateSigningSecretResponse>} - The new secret and its hint
|
|
260
|
+
* @example
|
|
261
|
+
* const { signingSecret } = await applications.rotateSigningSecret("00000000-...");
|
|
262
|
+
*/
|
|
263
|
+
async rotateSigningSecret(ref) {
|
|
264
|
+
const applicationsClient = this.client.getApplicationsClient();
|
|
265
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
266
|
+
method: applicationsClient.rotateSigningSecret.bind(applicationsClient),
|
|
267
|
+
requestPBObjectConstructor: applications_pb_1.RotateSigningSecretRequest,
|
|
268
|
+
metadata: this.client.getMetadata(),
|
|
269
|
+
request: { ref }
|
|
270
|
+
});
|
|
271
|
+
}
|
|
281
272
|
async deleteApplication(ref) {
|
|
282
273
|
const applicationsClient = this.client.getApplicationsClient();
|
|
283
274
|
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
@@ -291,8 +282,7 @@ class Applications {
|
|
|
291
282
|
* Evaluates the intelligence of an application.
|
|
292
283
|
*
|
|
293
284
|
* @param {EvaluateIntelligenceRequest} request - The request object that contains the necessary information to evaluate the intelligence of an application
|
|
294
|
-
* @param {
|
|
295
|
-
* @param {object} request.intelligence.config - The configuration object for the intelligence engine
|
|
285
|
+
* @param {object} request.intelligence.config - Autopilot agents: the agent (its model is a catalog id such as openai/gpt-4o-mini)
|
|
296
286
|
* @return {AsyncGenerator<EvaluateIntelligenceEvent>} - Stream of evaluation events (step results, scenario summaries, or errors)
|
|
297
287
|
* @example
|
|
298
288
|
* const apps = new SDK.Applications(client);
|
|
@@ -329,7 +319,7 @@ class Applications {
|
|
|
329
319
|
streamError = err instanceof Error ? err : new Error(String(err));
|
|
330
320
|
done = true;
|
|
331
321
|
});
|
|
332
|
-
while (!done || queue.length > 0) {
|
|
322
|
+
while (!done || queue.length > 0 || streamError) {
|
|
333
323
|
if (streamError)
|
|
334
324
|
throw streamError;
|
|
335
325
|
if (queue.length > 0) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { BillingSummary, CreatePortalSessionRequest, CreatePortalSessionResponse, CreateTopUpRequest, UpdateAutoRechargeRequest } from "@fonoster/types";
|
|
20
|
+
import { FonosterClient } from "./client/types";
|
|
21
|
+
/**
|
|
22
|
+
* @classdesc Fonoster Cloud's billing for the owner signed in: the balance in credits
|
|
23
|
+
* (1 credit = $0.01) by source, the plan, top-ups, auto-recharge and the Stripe Customer Portal.
|
|
24
|
+
* Only workspace owners may call it, and only on Fonoster Cloud (the capabilities say
|
|
25
|
+
* `billing.enabled`). The account is always the caller's: it covers every workspace they own.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const billing = new SDK.Billing(client);
|
|
29
|
+
* const { balance, sources } = await billing.getBilling();
|
|
30
|
+
* await billing.createTopUp({ credits: 1000 });
|
|
31
|
+
*/
|
|
32
|
+
declare class Billing {
|
|
33
|
+
private readonly client;
|
|
34
|
+
constructor(client: FonosterClient);
|
|
35
|
+
/** The balance by source, the plan and auto-recharge. */
|
|
36
|
+
getBilling(): Promise<BillingSummary>;
|
|
37
|
+
/** Turns auto-recharge on or off, with its threshold and amount in credits. */
|
|
38
|
+
updateAutoRecharge(request: UpdateAutoRechargeRequest): Promise<BillingSummary>;
|
|
39
|
+
/**
|
|
40
|
+
* Buys top-up credits, charged to the payment method added in the Customer Portal, with tax on
|
|
41
|
+
* top. The credits appear once the payment succeeds.
|
|
42
|
+
*/
|
|
43
|
+
createTopUp(request: CreateTopUpRequest): Promise<BillingSummary>;
|
|
44
|
+
/** Moves the owner from the Trial to Pay-as-you-go. Needs a payment method first. */
|
|
45
|
+
subscribe(): Promise<BillingSummary>;
|
|
46
|
+
/** A Stripe Customer Portal link for payment methods and invoices. */
|
|
47
|
+
createPortalSession(request: CreatePortalSessionRequest): Promise<CreatePortalSessionResponse>;
|
|
48
|
+
private summary;
|
|
49
|
+
}
|
|
50
|
+
export { Billing };
|