@fonoster/sdk 0.26.0 → 0.30.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 (66) hide show
  1. package/README.md +6 -5
  2. package/dist/node/Applications.d.ts +21 -85
  3. package/dist/node/Applications.js +55 -73
  4. package/dist/node/CallRecords.d.ts +92 -0
  5. package/dist/node/CallRecords.js +124 -0
  6. package/dist/node/Domains.js +4 -2
  7. package/dist/node/Providers.d.ts +49 -0
  8. package/dist/node/Providers.js +107 -0
  9. package/dist/node/Regions.d.ts +91 -0
  10. package/dist/node/Regions.js +124 -0
  11. package/dist/node/Users.d.ts +4 -2
  12. package/dist/node/Users.js +4 -2
  13. package/dist/node/Webhooks.d.ts +56 -0
  14. package/dist/node/Webhooks.js +139 -0
  15. package/dist/node/Workspaces.d.ts +22 -3
  16. package/dist/node/Workspaces.js +29 -2
  17. package/dist/node/client/AbstractClient.d.ts +83 -3
  18. package/dist/node/client/AbstractClient.js +97 -1
  19. package/dist/node/client/Client.d.ts +7 -0
  20. package/dist/node/client/Client.js +21 -0
  21. package/dist/node/client/jsonToObject.js +17 -0
  22. package/dist/node/client/objectToJson.js +35 -0
  23. package/dist/node/client/types/ApplicationsClient.d.ts +2 -1
  24. package/dist/node/client/types/CapabilitiesClient.d.ts +24 -0
  25. package/dist/node/client/types/CapabilitiesClient.js +2 -0
  26. package/dist/node/client/types/FonosterClient.d.ts +8 -0
  27. package/dist/node/client/types/IdentityClient.d.ts +3 -1
  28. package/dist/node/client/types/ProvidersClient.d.ts +28 -0
  29. package/dist/node/client/types/ProvidersClient.js +2 -0
  30. package/dist/node/client/types/WebhooksClient.d.ts +31 -0
  31. package/dist/node/client/types/WebhooksClient.js +2 -0
  32. package/dist/node/client/types/index.d.ts +3 -0
  33. package/dist/node/client/types/index.js +3 -0
  34. package/dist/node/generated/node/applications_grpc_pb.js +34 -0
  35. package/dist/node/generated/node/applications_pb.js +2657 -206
  36. package/dist/node/generated/node/capabilities_grpc_pb.js +66 -0
  37. package/dist/node/generated/node/capabilities_pb.js +2085 -0
  38. package/dist/node/generated/node/identity_grpc_pb.js +34 -0
  39. package/dist/node/generated/node/identity_pb.js +609 -5
  40. package/dist/node/generated/node/providers_grpc_pb.js +200 -0
  41. package/dist/node/generated/node/providers_pb.js +3034 -0
  42. package/dist/node/generated/node/webhooks_grpc_pb.js +302 -0
  43. package/dist/node/generated/node/webhooks_pb.js +3314 -0
  44. package/dist/node/generated/web/ApplicationsServiceClientPb.ts +43 -0
  45. package/dist/node/generated/web/CapabilitiesServiceClientPb.ts +87 -0
  46. package/dist/node/generated/web/IdentityServiceClientPb.ts +43 -0
  47. package/dist/node/generated/web/ProvidersServiceClientPb.ts +258 -0
  48. package/dist/node/generated/web/WebhooksServiceClientPb.ts +387 -0
  49. package/dist/node/generated/web/applications_pb.d.ts +301 -1
  50. package/dist/node/generated/web/applications_pb.js +2657 -206
  51. package/dist/node/generated/web/capabilities_pb.d.ts +249 -0
  52. package/dist/node/generated/web/capabilities_pb.js +2085 -0
  53. package/dist/node/generated/web/identity_pb.d.ts +76 -0
  54. package/dist/node/generated/web/identity_pb.js +609 -5
  55. package/dist/node/generated/web/providers_pb.d.ts +364 -0
  56. package/dist/node/generated/web/providers_pb.js +3034 -0
  57. package/dist/node/generated/web/webhooks_pb.d.ts +398 -0
  58. package/dist/node/generated/web/webhooks_pb.js +3314 -0
  59. package/dist/node/node.d.ts +5 -0
  60. package/dist/node/node.js +4 -0
  61. package/dist/node/tsconfig.tsbuildinfo +1 -1
  62. package/dist/node/utils.d.ts +1 -13
  63. package/dist/node/utils.js +1 -38
  64. package/dist/web/fonoster.min.js +1 -1
  65. package/dist/web/index.esm.js +1 -1
  66. package/package.json +5 -5
package/README.md CHANGED
@@ -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: "EXTERNAL",
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 Voice Applications.
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: "EXTERNAL",
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 (e.g., EXTERNAL) |
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: "EXTERNAL",
800
+ type: "STREAM",
800
801
  endpoint: "welcome.demo.fonoster.local", // Built-in demo application
801
802
  speechToText: {
802
803
  productRef: "stt.deepgram",
@@ -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 (e.g., EXTERNAL)
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 {string} request.intelligence.productRef - The product reference of the intelligence engine (e.g., llm.groq)
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: "EXTERNAL",
103
- * endpoint: "welcome.demo.fonoster.local", // Built-in demo application
104
- * speechToText: {
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<BaseApiObject>;
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 {string} request.intelligence.productRef - The product reference of the intelligence engine (e.g., llm.groq)
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
- * endpoint: "welcome.demo.fonoster.local", // Built-in demo application
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<BaseApiObject>;
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 {string} request.intelligence.productRef - The product reference of the intelligence engine (e.g., llm.groq)
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 Voice Applications.
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,30 @@ const utils_1 = require("./utils");
54
55
  *
55
56
  * const request = {
56
57
  * name: "My application",
57
- * type: "EXTERNAL",
58
- * endpoint: "welcome.demo.fonoster.local", // Built-in demo application
59
- * speechToText: {
60
- * productRef: "stt.deepgram",
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
+ ];
74
+ /** Repeated fields come back as `listenersList` when empty; always return `listeners`. */
75
+ function withSessionFields(app) {
76
+ const { listenersList, ...rest } = app;
77
+ return {
78
+ ...rest,
79
+ listeners: (rest.listeners ?? listenersList ?? [])
80
+ };
81
+ }
76
82
  class Applications {
77
83
  client;
78
84
  /**
@@ -90,37 +96,19 @@ class Applications {
90
96
  *
91
97
  * @param {CreateApplicationRequest} request - The request object that contains the necessary information to create a new application
92
98
  * @param {string} request.name - The name of the application
93
- * @param {ApplicationType} request.type - The type of application (e.g., EXTERNAL)
99
+ * @param {ApplicationType} request.type - The type of application: STREAM or AUTOPILOT
94
100
  * @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
101
  * @param {Intelligence} request.intelligence - The intelligence configuration
102
- * @param {string} request.intelligence.productRef - The product reference of the intelligence engine (e.g., llm.groq)
103
- * @param {object} request.intelligence.config - The configuration object for the intelligence engine
102
+ * @param {object} request.intelligence.config - Autopilot agents: the agent (its model is a catalog id such as openai/gpt-4o-mini)
104
103
  * @return {Promise<CreateAppResponse>} - The response object that contains the reference to the newly created application
105
104
  * @example
106
105
  * const apps = new SDK.Applications(client); // Existing client object
107
106
  *
108
107
  * const request = {
109
108
  * name: "My application",
110
- * type: "EXTERNAL",
111
- * endpoint: "welcome.demo.fonoster.local", // Built-in demo application
112
- * speechToText: {
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
- * }
109
+ * type: "STREAM",
110
+ * url: "wss://bot.example.com/session",
111
+ * speech: { voice: "elevenlabs/21m00Tcm4TlvDq8ikWAM", language: "en-US" }
124
112
  * };
125
113
  *
126
114
  * apps
@@ -137,11 +125,7 @@ class Applications {
137
125
  metadata: this.client.getMetadata(),
138
126
  request: reqWithStructOverride,
139
127
  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
- ]
128
+ objectMapping: REQUEST_OBJECTS
145
129
  });
146
130
  }
147
131
  /**
@@ -167,13 +151,9 @@ class Applications {
167
151
  metadata: this.client.getMetadata(),
168
152
  request: { ref },
169
153
  enumMapping: [["type", applications_pb_1.ApplicationType]],
170
- objectMapping: [
171
- ["textToSpeech", applications_pb_1.ProductContainer],
172
- ["speechToText", applications_pb_1.ProductContainer],
173
- ["intelligence", applications_pb_1.ProductContainer]
174
- ]
154
+ objectMapping: [["intelligence", applications_pb_1.ProductContainer]]
175
155
  });
176
- return (0, utils_1.buildStructOverrideReverse)(response);
156
+ return withSessionFields((0, utils_1.buildStructOverrideReverse)(response));
177
157
  }
178
158
  /**
179
159
  * Updates an existing application in Fonoster.
@@ -182,15 +162,8 @@ class Applications {
182
162
  * @param {string} request.ref - The reference of the application to update
183
163
  * @param {string} request.name - The name of the application
184
164
  * @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
165
  * @param {Intelligence} request.intelligence - The intelligence configuration
192
- * @param {string} request.intelligence.productRef - The product reference of the intelligence engine (e.g., llm.groq)
193
- * @param {object} request.intelligence.config - The configuration object for the intelligence engine
166
+ * @param {object} request.intelligence.config - Autopilot agents: the agent (its model is a catalog id such as openai/gpt-4o-mini)
194
167
  * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated application
195
168
  * @example
196
169
  * const apps = new SDK.Applications(client); // Existing client object
@@ -198,7 +171,7 @@ class Applications {
198
171
  * const request = {
199
172
  * ref: "00000000-0000-0000-0000-000000000000",
200
173
  * name: "My application",
201
- * endpoint: "welcome.demo.fonoster.local", // Built-in demo application
174
+ * url: "wss://bot.example.com/session"
202
175
  * };
203
176
  *
204
177
  * apps
@@ -215,11 +188,7 @@ class Applications {
215
188
  metadata: this.client.getMetadata(),
216
189
  request: reqWithStructOverride,
217
190
  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
- ]
191
+ objectMapping: REQUEST_OBJECTS
223
192
  });
224
193
  }
225
194
  /**
@@ -250,15 +219,11 @@ class Applications {
250
219
  metadata: this.client.getMetadata(),
251
220
  request,
252
221
  enumMapping: [["type", applications_pb_1.ApplicationType]],
253
- objectMapping: [
254
- ["speechToText", applications_pb_1.ProductContainer],
255
- ["textToSpeech", applications_pb_1.ProductContainer],
256
- ["intelligence", applications_pb_1.ProductContainer]
257
- ],
222
+ objectMapping: [["intelligence", applications_pb_1.ProductContainer]],
258
223
  repeatableObjectMapping: [["itemsList", applications_pb_1.Application]]
259
224
  });
260
225
  return {
261
- items: response.items.map(utils_1.buildStructOverrideReverse),
226
+ items: response.items.map((item) => withSessionFields((0, utils_1.buildStructOverrideReverse)(item))),
262
227
  nextPageToken: response.nextPageToken
263
228
  };
264
229
  }
@@ -278,6 +243,24 @@ class Applications {
278
243
  * .then(console.log) // successful response
279
244
  * .catch(console.error); // an error occurred
280
245
  */
246
+ /**
247
+ * Replaces the app's signing secret. The old secret stops working at once (no overlap window),
248
+ * so redeploy the app with the new one. The secret is returned only here.
249
+ *
250
+ * @param {string} ref - The application's reference
251
+ * @return {Promise<RotateSigningSecretResponse>} - The new secret and its hint
252
+ * @example
253
+ * const { signingSecret } = await applications.rotateSigningSecret("00000000-...");
254
+ */
255
+ async rotateSigningSecret(ref) {
256
+ const applicationsClient = this.client.getApplicationsClient();
257
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
258
+ method: applicationsClient.rotateSigningSecret.bind(applicationsClient),
259
+ requestPBObjectConstructor: applications_pb_1.RotateSigningSecretRequest,
260
+ metadata: this.client.getMetadata(),
261
+ request: { ref }
262
+ });
263
+ }
281
264
  async deleteApplication(ref) {
282
265
  const applicationsClient = this.client.getApplicationsClient();
283
266
  return await (0, makeRpcRequest_1.makeRpcRequest)({
@@ -291,8 +274,7 @@ class Applications {
291
274
  * Evaluates the intelligence of an application.
292
275
  *
293
276
  * @param {EvaluateIntelligenceRequest} request - The request object that contains the necessary information to evaluate the intelligence of an application
294
- * @param {string} request.intelligence.productRef - The product reference of the intelligence engine (e.g., llm.groq)
295
- * @param {object} request.intelligence.config - The configuration object for the intelligence engine
277
+ * @param {object} request.intelligence.config - Autopilot agents: the agent (its model is a catalog id such as openai/gpt-4o-mini)
296
278
  * @return {AsyncGenerator<EvaluateIntelligenceEvent>} - Stream of evaluation events (step results, scenario summaries, or errors)
297
279
  * @example
298
280
  * const apps = new SDK.Applications(client);
@@ -329,7 +311,7 @@ class Applications {
329
311
  streamError = err instanceof Error ? err : new Error(String(err));
330
312
  done = true;
331
313
  });
332
- while (!done || queue.length > 0) {
314
+ while (!done || queue.length > 0 || streamError) {
333
315
  if (streamError)
334
316
  throw streamError;
335
317
  if (queue.length > 0) {
@@ -0,0 +1,92 @@
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 { CallRecordAuditEntry, CallRecordDetail, ListCallRecordsRequest, ListCallRecordsResponse, RetentionPolicy } from "@fonoster/types";
20
+ import { FonosterClient } from "./client/types";
21
+ type FetchLike = (url: string, init?: {
22
+ method?: string;
23
+ headers?: Record<string, string>;
24
+ body?: string;
25
+ }) => Promise<{
26
+ ok: boolean;
27
+ status: number;
28
+ headers: {
29
+ get(name: string): string | null;
30
+ };
31
+ json(): Promise<unknown>;
32
+ arrayBuffer(): Promise<ArrayBuffer>;
33
+ }>;
34
+ /** An error answer from the records API (status and its `error` code). */
35
+ declare class CallRecordsError extends Error {
36
+ readonly status: number;
37
+ readonly code: string;
38
+ constructor(status: number, code: string, message?: string);
39
+ }
40
+ /**
41
+ * @classdesc Call records (vCon) through the HTTP records API (`/api/records`): search, one
42
+ * record (redacted unless you ask for the original and have the owner or admin role), the
43
+ * recording, the audit log, erasure and retention.
44
+ *
45
+ * @example
46
+ * const records = new SDK.CallRecords(client);
47
+ * const { items } = await records.listRecords({ after: "2026-10-01T00:00:00Z" });
48
+ * const record = await records.getRecord(items[0].callRef);
49
+ */
50
+ declare class CallRecords {
51
+ private readonly client;
52
+ private readonly baseUrl?;
53
+ private readonly fetchFn;
54
+ /**
55
+ * @param {FonosterClient} client - A logged-in client
56
+ * @param {object} options - `baseUrl` of the HTTP API (default: the client's), `fetch`
57
+ */
58
+ constructor(client: FonosterClient, options?: {
59
+ baseUrl?: string;
60
+ fetch?: FetchLike;
61
+ });
62
+ private url;
63
+ /** Sends a request, refreshing the access token once on 401. */
64
+ private send;
65
+ private json;
66
+ /** Searches the workspace's records, newest first. */
67
+ listRecords(request?: ListCallRecordsRequest): Promise<ListCallRecordsResponse>;
68
+ /** One record; the latest version unless `version` is given. */
69
+ getRecord(callRef: string, options?: {
70
+ version?: number;
71
+ original?: boolean;
72
+ }): Promise<CallRecordDetail>;
73
+ /** The recording (WAV) with its content hash. */
74
+ getRecording(callRef: string, options?: {
75
+ version?: number;
76
+ original?: boolean;
77
+ }): Promise<{
78
+ data: ArrayBuffer;
79
+ contentType: string;
80
+ contentHash: string;
81
+ }>;
82
+ /** Deletions and erasures of a record (owner or admin). */
83
+ getAudit(callRef: string): Promise<CallRecordAuditEntry[]>;
84
+ /** Erases the call: every object is deleted and a signed tombstone remains (owner or admin). */
85
+ eraseRecord(callRef: string, reason?: string): Promise<unknown>;
86
+ /** Deletes one part (recording, transcript, messages) of a record (owner or admin). */
87
+ deletePart(callRef: string, part: string, reason?: string): Promise<unknown>;
88
+ getRetention(): Promise<RetentionPolicy[]>;
89
+ /** Sets how many days a part is kept; `null` removes the policy (owner or admin). */
90
+ setRetention(part: string, days: number | null): Promise<RetentionPolicy>;
91
+ }
92
+ export { CallRecords, CallRecordsError };
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CallRecordsError = exports.CallRecords = void 0;
4
+ /** An error answer from the records API (status and its `error` code). */
5
+ class CallRecordsError extends Error {
6
+ status;
7
+ code;
8
+ constructor(status, code, message) {
9
+ super(message ?? `records API: ${status} ${code}`);
10
+ this.status = status;
11
+ this.code = code;
12
+ }
13
+ }
14
+ exports.CallRecordsError = CallRecordsError;
15
+ /**
16
+ * @classdesc Call records (vCon) through the HTTP records API (`/api/records`): search, one
17
+ * record (redacted unless you ask for the original and have the owner or admin role), the
18
+ * recording, the audit log, erasure and retention.
19
+ *
20
+ * @example
21
+ * const records = new SDK.CallRecords(client);
22
+ * const { items } = await records.listRecords({ after: "2026-10-01T00:00:00Z" });
23
+ * const record = await records.getRecord(items[0].callRef);
24
+ */
25
+ class CallRecords {
26
+ client;
27
+ baseUrl;
28
+ fetchFn;
29
+ /**
30
+ * @param {FonosterClient} client - A logged-in client
31
+ * @param {object} options - `baseUrl` of the HTTP API (default: the client's), `fetch`
32
+ */
33
+ constructor(client, options = {}) {
34
+ this.client = client;
35
+ this.baseUrl = options.baseUrl?.replace(/\/+$/, "");
36
+ this.fetchFn =
37
+ options.fetch ?? globalThis.fetch;
38
+ }
39
+ url(path, query = {}) {
40
+ const base = this.baseUrl ?? this.client.getHttpUrl?.() ?? "https://api.fonoster.com";
41
+ const qs = Object.entries(query)
42
+ .filter(([, v]) => v !== undefined && v !== null && v !== "")
43
+ .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
44
+ .join("&");
45
+ return `${base}/api/records${path}${qs ? `?${qs}` : ""}`;
46
+ }
47
+ /** Sends a request, refreshing the access token once on 401. */
48
+ async send(path, init = {}) {
49
+ const attempt = () => this.fetchFn(this.url(path, init.query), {
50
+ method: init.method ?? "GET",
51
+ headers: {
52
+ authorization: `Bearer ${this.client.getAccessToken()}`,
53
+ "x-accesskey-id": this.client.getAccessKeyId(),
54
+ ...(init.body ? { "content-type": "application/json" } : {})
55
+ },
56
+ body: init.body ? JSON.stringify(init.body) : undefined
57
+ });
58
+ let res = await attempt();
59
+ if (res.status === 401) {
60
+ await this.client.refreshToken();
61
+ res = await attempt();
62
+ }
63
+ if (!res.ok) {
64
+ const body = (await res.json().catch(() => ({})));
65
+ throw new CallRecordsError(res.status, body.error ?? "error", body.message);
66
+ }
67
+ return res;
68
+ }
69
+ async json(path, init) {
70
+ return (await (await this.send(path, init)).json());
71
+ }
72
+ /** Searches the workspace's records, newest first. */
73
+ async listRecords(request = {}) {
74
+ return this.json("", { query: request });
75
+ }
76
+ /** One record; the latest version unless `version` is given. */
77
+ async getRecord(callRef, options = {}) {
78
+ return this.json(`/${encodeURIComponent(callRef)}`, {
79
+ query: {
80
+ version: options.version,
81
+ original: options.original ? "true" : undefined
82
+ }
83
+ });
84
+ }
85
+ /** The recording (WAV) with its content hash. */
86
+ async getRecording(callRef, options = {}) {
87
+ const res = await this.send(`/${encodeURIComponent(callRef)}/recording`, {
88
+ query: {
89
+ version: options.version,
90
+ original: options.original ? "true" : undefined
91
+ }
92
+ });
93
+ return {
94
+ data: await res.arrayBuffer(),
95
+ contentType: res.headers.get("content-type") ?? "audio/x-wav",
96
+ contentHash: res.headers.get("x-content-hash") ?? ""
97
+ };
98
+ }
99
+ /** Deletions and erasures of a record (owner or admin). */
100
+ async getAudit(callRef) {
101
+ const { items } = await this.json(`/${encodeURIComponent(callRef)}/audit`);
102
+ return items;
103
+ }
104
+ /** Erases the call: every object is deleted and a signed tombstone remains (owner or admin). */
105
+ async eraseRecord(callRef, reason) {
106
+ return this.json(`/${encodeURIComponent(callRef)}`, {
107
+ method: "DELETE",
108
+ body: reason ? { reason } : undefined
109
+ });
110
+ }
111
+ /** Deletes one part (recording, transcript, messages) of a record (owner or admin). */
112
+ async deletePart(callRef, part, reason) {
113
+ return this.json(`/${encodeURIComponent(callRef)}/parts/${encodeURIComponent(part)}`, { method: "DELETE", body: reason ? { reason } : undefined });
114
+ }
115
+ async getRetention() {
116
+ const { items } = await this.json("/retention");
117
+ return items;
118
+ }
119
+ /** Sets how many days a part is kept; `null` removes the policy (owner or admin). */
120
+ async setRetention(part, days) {
121
+ return this.json("/retention", { method: "PUT", body: { part, days } });
122
+ }
123
+ }
124
+ exports.CallRecords = CallRecords;