@sentdm/sentdm 0.45.0 → 0.47.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 (191) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/client.d.mts +6 -11
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +6 -11
  5. package/client.d.ts.map +1 -1
  6. package/client.js +3 -10
  7. package/client.js.map +1 -1
  8. package/client.mjs +3 -10
  9. package/client.mjs.map +1 -1
  10. package/core/pagination.d.mts +25 -0
  11. package/core/pagination.d.mts.map +1 -1
  12. package/core/pagination.d.ts +25 -0
  13. package/core/pagination.d.ts.map +1 -1
  14. package/core/pagination.js +28 -1
  15. package/core/pagination.js.map +1 -1
  16. package/core/pagination.mjs +26 -0
  17. package/core/pagination.mjs.map +1 -1
  18. package/package.json +1 -1
  19. package/resources/channels/channels.d.mts +2 -2
  20. package/resources/channels/channels.d.mts.map +1 -1
  21. package/resources/channels/channels.d.ts +2 -2
  22. package/resources/channels/channels.d.ts.map +1 -1
  23. package/resources/channels/channels.js.map +1 -1
  24. package/resources/channels/channels.mjs.map +1 -1
  25. package/resources/channels/index.d.mts +1 -1
  26. package/resources/channels/index.d.mts.map +1 -1
  27. package/resources/channels/index.d.ts +1 -1
  28. package/resources/channels/index.d.ts.map +1 -1
  29. package/resources/channels/index.js.map +1 -1
  30. package/resources/channels/index.mjs.map +1 -1
  31. package/resources/channels/voice.d.mts +72 -115
  32. package/resources/channels/voice.d.mts.map +1 -1
  33. package/resources/channels/voice.d.ts +72 -115
  34. package/resources/channels/voice.d.ts.map +1 -1
  35. package/resources/channels/voice.js +35 -45
  36. package/resources/channels/voice.js.map +1 -1
  37. package/resources/channels/voice.mjs +35 -45
  38. package/resources/channels/voice.mjs.map +1 -1
  39. package/resources/index.d.mts +1 -1
  40. package/resources/index.d.mts.map +1 -1
  41. package/resources/index.d.ts +1 -1
  42. package/resources/index.d.ts.map +1 -1
  43. package/resources/index.js +3 -3
  44. package/resources/index.js.map +1 -1
  45. package/resources/index.mjs +1 -1
  46. package/resources/index.mjs.map +1 -1
  47. package/resources/messages.d.mts +8 -1
  48. package/resources/messages.d.mts.map +1 -1
  49. package/resources/messages.d.ts +8 -1
  50. package/resources/messages.d.ts.map +1 -1
  51. package/resources/profiles/campaigns.d.mts +3 -2
  52. package/resources/profiles/campaigns.d.mts.map +1 -1
  53. package/resources/profiles/campaigns.d.ts +3 -2
  54. package/resources/profiles/campaigns.d.ts.map +1 -1
  55. package/resources/profiles/campaigns.js +3 -2
  56. package/resources/profiles/campaigns.js.map +1 -1
  57. package/resources/profiles/campaigns.mjs +3 -2
  58. package/resources/profiles/campaigns.mjs.map +1 -1
  59. package/resources/templates.d.mts +14 -13
  60. package/resources/templates.d.mts.map +1 -1
  61. package/resources/templates.d.ts +14 -13
  62. package/resources/templates.d.ts.map +1 -1
  63. package/resources/voice/agents.d.mts +524 -0
  64. package/resources/voice/agents.d.mts.map +1 -0
  65. package/resources/voice/agents.d.ts +524 -0
  66. package/resources/voice/agents.d.ts.map +1 -0
  67. package/resources/voice/agents.js +193 -0
  68. package/resources/voice/agents.js.map +1 -0
  69. package/resources/voice/agents.mjs +189 -0
  70. package/resources/voice/agents.mjs.map +1 -0
  71. package/resources/{calls → voice/calls}/calls.d.mts +103 -26
  72. package/resources/voice/calls/calls.d.mts.map +1 -0
  73. package/resources/{calls → voice/calls}/calls.d.ts +103 -26
  74. package/resources/voice/calls/calls.d.ts.map +1 -0
  75. package/resources/{calls → voice/calls}/calls.js +35 -28
  76. package/resources/voice/calls/calls.js.map +1 -0
  77. package/resources/{calls → voice/calls}/calls.mjs +34 -27
  78. package/resources/voice/calls/calls.mjs.map +1 -0
  79. package/resources/voice/calls/index.d.mts.map +1 -0
  80. package/resources/voice/calls/index.d.ts.map +1 -0
  81. package/resources/voice/calls/index.js.map +1 -0
  82. package/resources/voice/calls/index.mjs.map +1 -0
  83. package/resources/{calls → voice/calls}/participants.d.mts +16 -14
  84. package/resources/voice/calls/participants.d.mts.map +1 -0
  85. package/resources/{calls → voice/calls}/participants.d.ts +16 -14
  86. package/resources/voice/calls/participants.d.ts.map +1 -0
  87. package/resources/{calls → voice/calls}/participants.js +19 -17
  88. package/resources/voice/calls/participants.js.map +1 -0
  89. package/resources/{calls → voice/calls}/participants.mjs +19 -17
  90. package/resources/voice/calls/participants.mjs.map +1 -0
  91. package/resources/voice/calls.d.mts.map +1 -0
  92. package/resources/voice/calls.d.ts.map +1 -0
  93. package/resources/{calls.js → voice/calls.js} +1 -1
  94. package/resources/voice/calls.js.map +1 -0
  95. package/resources/voice/calls.mjs.map +1 -0
  96. package/resources/voice/catalogue.d.mts +86 -0
  97. package/resources/voice/catalogue.d.mts.map +1 -0
  98. package/resources/voice/catalogue.d.ts +86 -0
  99. package/resources/voice/catalogue.d.ts.map +1 -0
  100. package/resources/voice/catalogue.js +40 -0
  101. package/resources/voice/catalogue.js.map +1 -0
  102. package/resources/voice/catalogue.mjs +36 -0
  103. package/resources/voice/catalogue.mjs.map +1 -0
  104. package/resources/voice/index.d.mts +6 -0
  105. package/resources/voice/index.d.mts.map +1 -0
  106. package/resources/voice/index.d.ts +6 -0
  107. package/resources/voice/index.d.ts.map +1 -0
  108. package/resources/voice/index.js +15 -0
  109. package/resources/voice/index.js.map +1 -0
  110. package/resources/voice/index.mjs +7 -0
  111. package/resources/voice/index.mjs.map +1 -0
  112. package/resources/voice/tokens.d.mts +111 -0
  113. package/resources/voice/tokens.d.mts.map +1 -0
  114. package/resources/voice/tokens.d.ts +111 -0
  115. package/resources/voice/tokens.d.ts.map +1 -0
  116. package/resources/voice/tokens.js +47 -0
  117. package/resources/voice/tokens.js.map +1 -0
  118. package/resources/voice/tokens.mjs +43 -0
  119. package/resources/voice/tokens.mjs.map +1 -0
  120. package/resources/voice/voice.d.mts +22 -0
  121. package/resources/voice/voice.d.mts.map +1 -0
  122. package/resources/voice/voice.d.ts +22 -0
  123. package/resources/voice/voice.d.ts.map +1 -0
  124. package/resources/voice/voice.js +29 -0
  125. package/resources/voice/voice.js.map +1 -0
  126. package/resources/voice/voice.mjs +24 -0
  127. package/resources/voice/voice.mjs.map +1 -0
  128. package/resources/voice.d.mts +2 -0
  129. package/resources/voice.d.mts.map +1 -0
  130. package/resources/voice.d.ts +2 -0
  131. package/resources/voice.d.ts.map +1 -0
  132. package/resources/voice.js +6 -0
  133. package/resources/voice.js.map +1 -0
  134. package/resources/voice.mjs +3 -0
  135. package/resources/voice.mjs.map +1 -0
  136. package/resources/webhooks.d.mts +154 -31
  137. package/resources/webhooks.d.mts.map +1 -1
  138. package/resources/webhooks.d.ts +154 -31
  139. package/resources/webhooks.d.ts.map +1 -1
  140. package/resources/webhooks.js +51 -11
  141. package/resources/webhooks.js.map +1 -1
  142. package/resources/webhooks.mjs +51 -11
  143. package/resources/webhooks.mjs.map +1 -1
  144. package/src/client.ts +12 -45
  145. package/src/core/pagination.ts +64 -0
  146. package/src/resources/channels/channels.ts +0 -6
  147. package/src/resources/channels/index.ts +0 -3
  148. package/src/resources/channels/voice.ts +74 -144
  149. package/src/resources/index.ts +1 -18
  150. package/src/resources/messages.ts +8 -1
  151. package/src/resources/profiles/campaigns.ts +3 -2
  152. package/src/resources/templates.ts +14 -13
  153. package/src/resources/voice/agents.ts +729 -0
  154. package/src/resources/{calls → voice/calls}/calls.ts +122 -33
  155. package/src/resources/{calls → voice/calls}/participants.ts +23 -21
  156. package/src/resources/voice/catalogue.ts +118 -0
  157. package/src/resources/voice/index.ts +55 -0
  158. package/src/resources/voice/tokens.ts +146 -0
  159. package/src/resources/voice/voice.ts +134 -0
  160. package/src/resources/voice.ts +3 -0
  161. package/src/resources/webhooks.ts +162 -31
  162. package/src/version.ts +1 -1
  163. package/version.d.mts +1 -1
  164. package/version.d.ts +1 -1
  165. package/version.js +1 -1
  166. package/version.mjs +1 -1
  167. package/resources/calls/calls.d.mts.map +0 -1
  168. package/resources/calls/calls.d.ts.map +0 -1
  169. package/resources/calls/calls.js.map +0 -1
  170. package/resources/calls/calls.mjs.map +0 -1
  171. package/resources/calls/index.d.mts.map +0 -1
  172. package/resources/calls/index.d.ts.map +0 -1
  173. package/resources/calls/index.js.map +0 -1
  174. package/resources/calls/index.mjs.map +0 -1
  175. package/resources/calls/participants.d.mts.map +0 -1
  176. package/resources/calls/participants.d.ts.map +0 -1
  177. package/resources/calls/participants.js.map +0 -1
  178. package/resources/calls/participants.mjs.map +0 -1
  179. package/resources/calls.d.mts.map +0 -1
  180. package/resources/calls.d.ts.map +0 -1
  181. package/resources/calls.js.map +0 -1
  182. package/resources/calls.mjs.map +0 -1
  183. /package/resources/{calls → voice/calls}/index.d.mts +0 -0
  184. /package/resources/{calls → voice/calls}/index.d.ts +0 -0
  185. /package/resources/{calls → voice/calls}/index.js +0 -0
  186. /package/resources/{calls → voice/calls}/index.mjs +0 -0
  187. /package/resources/{calls.d.mts → voice/calls.d.mts} +0 -0
  188. /package/resources/{calls.d.ts → voice/calls.d.ts} +0 -0
  189. /package/resources/{calls.mjs → voice/calls.mjs} +0 -0
  190. /package/src/resources/{calls → voice/calls}/index.ts +0 -0
  191. /package/src/resources/{calls.ts → voice/calls.ts} +0 -0
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Agents = void 0;
5
+ const resource_1 = require("../../core/resource.js");
6
+ const pagination_1 = require("../../core/pagination.js");
7
+ const headers_1 = require("../../internal/headers.js");
8
+ const path_1 = require("../../internal/utils/path.js");
9
+ /**
10
+ * Phone calls from the numbers you hold, driven by your own callback URL.
11
+ *
12
+ * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
13
+ *
14
+ * Every call is a record under `/v3/voice/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
15
+ *
16
+ * **Voice agents.** `POST /v3/voice/agents` creates an agent that answers calls through the Sent Voice Gateway: `session_type` says whether Sent carries the call as text (speech recognised and spoken for the agent) or as audio, `websocket_url` is where the gateway dials the agent for each call (leave it out and the agent dials in with your API key), and `tools`, `transfer_targets`, `fallback` and `limits` say what it may do on a call. The agent's `signing_secret` is shown on create and on `POST /v3/voice/agents/{id}/rotate-secret` only. Voices and languages for text sessions come from `GET /v3/voice/voices`. A number takes calls to an agent once it is bound to it on `/v3/channels/voice`.
17
+ */
18
+ class Agents extends resource_1.APIResource {
19
+ /**
20
+ * Creates an agent that answers phone calls through the Sent Voice Gateway.
21
+ * `session_type` says whether Sent carries the call as text (the caller's speech
22
+ * recognised for the agent, the agent's text spoken) or as audio. With
23
+ * `websocket_url` the gateway dials your agent for each call and signs the
24
+ * handshake with the `signing_secret` this response returns; without it, your
25
+ * agent dials in with your API key and this agent's `id`.
26
+ *
27
+ * `tools`, `transfer_targets`, `fallback` and `limits` say what the agent may do
28
+ * on a call. Voices and languages for text sessions come from
29
+ * `GET /v3/voice/voices`. Calls reach the agent once a number is bound to it on
30
+ * `/v3/channels/voice`.
31
+ *
32
+ * `signing_secret` is shown here and on `POST /v3/voice/agents/{id}/rotate-secret`
33
+ * only; store it now. With `sandbox: true` the request is validated and the agent
34
+ * reported with `202`; nothing is written.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const apiResponseOfVoiceAgent =
39
+ * await client.voice.agents.create();
40
+ * ```
41
+ */
42
+ create(params, options) {
43
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
44
+ return this._client.post('/v3/voice/agents', {
45
+ body,
46
+ ...options,
47
+ headers: (0, headers_1.buildHeaders)([
48
+ {
49
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
50
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
51
+ },
52
+ options?.headers,
53
+ ]),
54
+ });
55
+ }
56
+ /**
57
+ * The agent as stored, without its signing secret.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const apiResponseOfVoiceAgent =
62
+ * await client.voice.agents.retrieve('id');
63
+ * ```
64
+ */
65
+ retrieve(id, params = {}, options) {
66
+ const { 'x-profile-id': xProfileID } = params ?? {};
67
+ return this._client.get((0, path_1.path) `/v3/voice/agents/${id}`, {
68
+ ...options,
69
+ headers: (0, headers_1.buildHeaders)([
70
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
71
+ options?.headers,
72
+ ]),
73
+ });
74
+ }
75
+ /**
76
+ * Changes the fields you name and answers with the agent as stored, the same shape
77
+ * `GET` returns.
78
+ *
79
+ * A key left out is left alone. A key sent as `null` clears an optional field
80
+ * (`websocket_url` makes the agent dial in, `greeting` and `fallback` go,
81
+ * `speech`, `audio`, `tools`, `limits` and `transcripts` return to their
82
+ * defaults). A key sent with a value replaces that field whole: send the whole
83
+ * `limits` object, not one of its keys. Changing `session_type` drops `speech`,
84
+ * `audio` and `greeting` unless the body sends them, since the other type cannot
85
+ * carry them. The result is checked like a new agent, and a body that changes
86
+ * nothing is `400`.
87
+ *
88
+ * With `sandbox: true` nothing is written: the request is validated against the
89
+ * stored agent and the agent is reported with `200` as it would read after the
90
+ * change.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const apiResponseOfVoiceAgent =
95
+ * await client.voice.agents.update('id');
96
+ * ```
97
+ */
98
+ update(id, params, options) {
99
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
100
+ return this._client.patch((0, path_1.path) `/v3/voice/agents/${id}`, {
101
+ body,
102
+ ...options,
103
+ headers: (0, headers_1.buildHeaders)([
104
+ {
105
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
106
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
107
+ },
108
+ options?.headers,
109
+ ]),
110
+ });
111
+ }
112
+ /**
113
+ * Your voice agents, newest first. `page` and `page_size` (1 to 100, default 20)
114
+ * page the list. Signing secrets are never listed.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * // Automatically fetches more pages as needed.
119
+ * for await (const voiceAgent of client.voice.agents.list()) {
120
+ * // ...
121
+ * }
122
+ * ```
123
+ */
124
+ list(params = {}, options) {
125
+ const { 'x-profile-id': xProfileID, ...query } = params ?? {};
126
+ return this._client.getAPIList('/v3/voice/agents', (pagination_1.VoiceAgentsPage), {
127
+ query,
128
+ ...options,
129
+ headers: (0, headers_1.buildHeaders)([
130
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
131
+ options?.headers,
132
+ ]),
133
+ });
134
+ }
135
+ /**
136
+ * Removes the agent. Calls it already took keep their `agent_id`.
137
+ *
138
+ * An agent that one of your voice numbers routes to, or that another of your
139
+ * agents lists in `transfer_targets`, is not deleted: the answer is `409` with a
140
+ * message naming those numbers and agents. Unbind the numbers
141
+ * (`PATCH /v3/channels/voice/{number}` with `"agent_id": null`), take the agent
142
+ * out of the others' `transfer_targets` or delete them, and try again.
143
+ *
144
+ * With `sandbox: true` nothing is written: the agent is looked up and the answer
145
+ * is the one a real delete would give.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * await client.voice.agents.delete('id');
150
+ * ```
151
+ */
152
+ delete(id, params, options) {
153
+ const { 'x-profile-id': xProfileID, ...body } = params;
154
+ return this._client.delete((0, path_1.path) `/v3/voice/agents/${id}`, {
155
+ body,
156
+ ...options,
157
+ headers: (0, headers_1.buildHeaders)([
158
+ { Accept: '*/*', ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
159
+ options?.headers,
160
+ ]),
161
+ });
162
+ }
163
+ /**
164
+ * Generates a new `signing_secret` for the agent and returns it. The previous
165
+ * secret stops signing immediately, so update your agent before the next call
166
+ * reaches it.
167
+ *
168
+ * With `sandbox: true` a secret is generated and returned with `202`, and nothing
169
+ * is written.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * const apiResponseOfVoiceAgentSecret =
174
+ * await client.voice.agents.rotateSecret('id');
175
+ * ```
176
+ */
177
+ rotateSecret(id, params, options) {
178
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
179
+ return this._client.post((0, path_1.path) `/v3/voice/agents/${id}/rotate-secret`, {
180
+ body,
181
+ ...options,
182
+ headers: (0, headers_1.buildHeaders)([
183
+ {
184
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
185
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
186
+ },
187
+ options?.headers,
188
+ ]),
189
+ });
190
+ }
191
+ }
192
+ exports.Agents = Agents;
193
+ //# sourceMappingURL=agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/resources/voice/agents.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAGlD,yDAAiG;AACjG,uDAAsD;AAEtD,uDAAiD;AAEjD;;;;;;;;GAQG;AACH,MAAa,MAAO,SAAQ,sBAAW;IACrC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,MAAM,CAAC,MAAyB,EAAE,OAAwB;QACxD,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC1F,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC3C,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC;gBACpB;oBACE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE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ACV,MAA+B,EAC/B,OAAwB;QAExB,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC1F,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,oBAAoB,EAAE,gBAAgB,EAAE;YACnE,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC;gBACpB;oBACE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBAC/E,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;iBACrE;gBACD,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF;AAjMD,wBAiMC"}
@@ -0,0 +1,189 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../../core/resource.mjs";
3
+ import { VoiceAgentsPage } from "../../core/pagination.mjs";
4
+ import { buildHeaders } from "../../internal/headers.mjs";
5
+ import { path } from "../../internal/utils/path.mjs";
6
+ /**
7
+ * Phone calls from the numbers you hold, driven by your own callback URL.
8
+ *
9
+ * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
10
+ *
11
+ * Every call is a record under `/v3/voice/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
12
+ *
13
+ * **Voice agents.** `POST /v3/voice/agents` creates an agent that answers calls through the Sent Voice Gateway: `session_type` says whether Sent carries the call as text (speech recognised and spoken for the agent) or as audio, `websocket_url` is where the gateway dials the agent for each call (leave it out and the agent dials in with your API key), and `tools`, `transfer_targets`, `fallback` and `limits` say what it may do on a call. The agent's `signing_secret` is shown on create and on `POST /v3/voice/agents/{id}/rotate-secret` only. Voices and languages for text sessions come from `GET /v3/voice/voices`. A number takes calls to an agent once it is bound to it on `/v3/channels/voice`.
14
+ */
15
+ export class Agents extends APIResource {
16
+ /**
17
+ * Creates an agent that answers phone calls through the Sent Voice Gateway.
18
+ * `session_type` says whether Sent carries the call as text (the caller's speech
19
+ * recognised for the agent, the agent's text spoken) or as audio. With
20
+ * `websocket_url` the gateway dials your agent for each call and signs the
21
+ * handshake with the `signing_secret` this response returns; without it, your
22
+ * agent dials in with your API key and this agent's `id`.
23
+ *
24
+ * `tools`, `transfer_targets`, `fallback` and `limits` say what the agent may do
25
+ * on a call. Voices and languages for text sessions come from
26
+ * `GET /v3/voice/voices`. Calls reach the agent once a number is bound to it on
27
+ * `/v3/channels/voice`.
28
+ *
29
+ * `signing_secret` is shown here and on `POST /v3/voice/agents/{id}/rotate-secret`
30
+ * only; store it now. With `sandbox: true` the request is validated and the agent
31
+ * reported with `202`; nothing is written.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const apiResponseOfVoiceAgent =
36
+ * await client.voice.agents.create();
37
+ * ```
38
+ */
39
+ create(params, options) {
40
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
41
+ return this._client.post('/v3/voice/agents', {
42
+ body,
43
+ ...options,
44
+ headers: buildHeaders([
45
+ {
46
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
47
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
48
+ },
49
+ options?.headers,
50
+ ]),
51
+ });
52
+ }
53
+ /**
54
+ * The agent as stored, without its signing secret.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const apiResponseOfVoiceAgent =
59
+ * await client.voice.agents.retrieve('id');
60
+ * ```
61
+ */
62
+ retrieve(id, params = {}, options) {
63
+ const { 'x-profile-id': xProfileID } = params ?? {};
64
+ return this._client.get(path `/v3/voice/agents/${id}`, {
65
+ ...options,
66
+ headers: buildHeaders([
67
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
68
+ options?.headers,
69
+ ]),
70
+ });
71
+ }
72
+ /**
73
+ * Changes the fields you name and answers with the agent as stored, the same shape
74
+ * `GET` returns.
75
+ *
76
+ * A key left out is left alone. A key sent as `null` clears an optional field
77
+ * (`websocket_url` makes the agent dial in, `greeting` and `fallback` go,
78
+ * `speech`, `audio`, `tools`, `limits` and `transcripts` return to their
79
+ * defaults). A key sent with a value replaces that field whole: send the whole
80
+ * `limits` object, not one of its keys. Changing `session_type` drops `speech`,
81
+ * `audio` and `greeting` unless the body sends them, since the other type cannot
82
+ * carry them. The result is checked like a new agent, and a body that changes
83
+ * nothing is `400`.
84
+ *
85
+ * With `sandbox: true` nothing is written: the request is validated against the
86
+ * stored agent and the agent is reported with `200` as it would read after the
87
+ * change.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const apiResponseOfVoiceAgent =
92
+ * await client.voice.agents.update('id');
93
+ * ```
94
+ */
95
+ update(id, params, options) {
96
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
97
+ return this._client.patch(path `/v3/voice/agents/${id}`, {
98
+ body,
99
+ ...options,
100
+ headers: buildHeaders([
101
+ {
102
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
103
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
104
+ },
105
+ options?.headers,
106
+ ]),
107
+ });
108
+ }
109
+ /**
110
+ * Your voice agents, newest first. `page` and `page_size` (1 to 100, default 20)
111
+ * page the list. Signing secrets are never listed.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * // Automatically fetches more pages as needed.
116
+ * for await (const voiceAgent of client.voice.agents.list()) {
117
+ * // ...
118
+ * }
119
+ * ```
120
+ */
121
+ list(params = {}, options) {
122
+ const { 'x-profile-id': xProfileID, ...query } = params ?? {};
123
+ return this._client.getAPIList('/v3/voice/agents', (VoiceAgentsPage), {
124
+ query,
125
+ ...options,
126
+ headers: buildHeaders([
127
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
128
+ options?.headers,
129
+ ]),
130
+ });
131
+ }
132
+ /**
133
+ * Removes the agent. Calls it already took keep their `agent_id`.
134
+ *
135
+ * An agent that one of your voice numbers routes to, or that another of your
136
+ * agents lists in `transfer_targets`, is not deleted: the answer is `409` with a
137
+ * message naming those numbers and agents. Unbind the numbers
138
+ * (`PATCH /v3/channels/voice/{number}` with `"agent_id": null`), take the agent
139
+ * out of the others' `transfer_targets` or delete them, and try again.
140
+ *
141
+ * With `sandbox: true` nothing is written: the agent is looked up and the answer
142
+ * is the one a real delete would give.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * await client.voice.agents.delete('id');
147
+ * ```
148
+ */
149
+ delete(id, params, options) {
150
+ const { 'x-profile-id': xProfileID, ...body } = params;
151
+ return this._client.delete(path `/v3/voice/agents/${id}`, {
152
+ body,
153
+ ...options,
154
+ headers: buildHeaders([
155
+ { Accept: '*/*', ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
156
+ options?.headers,
157
+ ]),
158
+ });
159
+ }
160
+ /**
161
+ * Generates a new `signing_secret` for the agent and returns it. The previous
162
+ * secret stops signing immediately, so update your agent before the next call
163
+ * reaches it.
164
+ *
165
+ * With `sandbox: true` a secret is generated and returned with `202`, and nothing
166
+ * is written.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * const apiResponseOfVoiceAgentSecret =
171
+ * await client.voice.agents.rotateSecret('id');
172
+ * ```
173
+ */
174
+ rotateSecret(id, params, options) {
175
+ const { 'Idempotency-Key': idempotencyKey, 'x-profile-id': xProfileID, ...body } = params;
176
+ return this._client.post(path `/v3/voice/agents/${id}/rotate-secret`, {
177
+ body,
178
+ ...options,
179
+ headers: buildHeaders([
180
+ {
181
+ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
182
+ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined),
183
+ },
184
+ options?.headers,
185
+ ]),
186
+ });
187
+ }
188
+ }
189
+ //# sourceMappingURL=agents.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.mjs","sourceRoot":"","sources":["../../src/resources/voice/agents.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAGlD,OAAO,EAAe,eAAe,EAA8B,kCAA8B;AACjG,OAAO,EAAE,YAAY,EAAE,mCAA+B;AAEtD,OAAO,EAAE,IAAI,EAAE,sCAAkC;AAEjD;;;;;;;;GAQG;AACH,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,MAAM,CAAC,MAAyB,EAAE,OAAwB;QACxD,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC1F,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC3C,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC;gBACpB;oBACE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBAC/E,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;iBACrE;gBACD,OAAO,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AAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC;gBACpB;oBACE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBAC/E,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;iBACrE;gBACD,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,27 +1,31 @@
1
- import { APIResource } from "../../core/resource.mjs";
2
- import * as WebhooksAPI from "../webhooks.mjs";
1
+ import { APIResource } from "../../../core/resource.mjs";
2
+ import * as WebhooksAPI from "../../webhooks.mjs";
3
3
  import * as ParticipantsAPI from "./participants.mjs";
4
4
  import { APIResponseOfListOfCallParticipant, CallParticipant, CallParticipantTarget, ParticipantAddParams, ParticipantListParams, ParticipantRemoveAllParams, ParticipantRemoveParams, ParticipantUpdateParams, Participants } from "./participants.mjs";
5
- import { APIPromise } from "../../core/api-promise.mjs";
6
- import { CallsPage, type CallsPageParams, PagePromise } from "../../core/pagination.mjs";
7
- import { RequestOptions } from "../../internal/request-options.mjs";
5
+ import { APIPromise } from "../../../core/api-promise.mjs";
6
+ import { CallsPage, type CallsPageParams, PagePromise } from "../../../core/pagination.mjs";
7
+ import { RequestOptions } from "../../../internal/request-options.mjs";
8
8
  /**
9
9
  * Phone calls from the numbers you hold, driven by your own callback URL.
10
10
  *
11
- * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/channels/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
11
+ * `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent asks what to do with each call on it, and `POST /v3/voice/tokens` mints a short-lived token that lets a user of your app place and receive calls as that number. When a call arrives or a caller presses a key, a signed question is POSTed to the callback URL and the answer decides the call; `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need before a real call reaches it, and `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret. The call events themselves (`call.completed` and the rest) arrive through your webhooks.
12
12
  *
13
- * Every call is a record under `/v3/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
13
+ * Every call is a record under `/v3/voice/calls`: read it, list its recordings once one is ready, hang it up, start or stop recording, and add, mute or remove conference participants while it is live. A leg to a phone number runs for at most what your balance affords at the destination's rate.
14
+ *
15
+ * **Voice agents.** `POST /v3/voice/agents` creates an agent that answers calls through the Sent Voice Gateway: `session_type` says whether Sent carries the call as text (speech recognised and spoken for the agent) or as audio, `websocket_url` is where the gateway dials the agent for each call (leave it out and the agent dials in with your API key), and `tools`, `transfer_targets`, `fallback` and `limits` say what it may do on a call. The agent's `signing_secret` is shown on create and on `POST /v3/voice/agents/{id}/rotate-secret` only. Voices and languages for text sessions come from `GET /v3/voice/voices`. A number takes calls to an agent once it is bound to it on `/v3/channels/voice`.
14
16
  */
15
17
  export declare class Calls extends APIResource {
16
18
  participants: ParticipantsAPI.Participants;
17
19
  /**
18
- * Retrieves one of your calls by id: the parties, the owning number, the current
19
- * status with its failure reason, duration, price, recording availability, and a
20
- * timeline of when the call entered each status.
20
+ * Retrieves one of your calls by id: the parties, the owning number, the phone
21
+ * number the call was connected to and the caller id it showed, the current status
22
+ * with its failure reason, duration, price with the billed legs and what each
23
+ * cost, recording availability, and a timeline of when the call entered each
24
+ * status.
21
25
  *
22
26
  * @example
23
27
  * ```ts
24
- * const apiResponseOfCall = await client.calls.retrieve(
28
+ * const apiResponseOfCall = await client.voice.calls.retrieve(
25
29
  * 'call_9f2ab000-0000-4000-8000-000000000001',
26
30
  * );
27
31
  * ```
@@ -29,14 +33,17 @@ export declare class Calls extends APIResource {
29
33
  retrieve(id: string, params?: CallRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<APIResponseOfCall>;
30
34
  /**
31
35
  * Retrieves a paginated list of your calls, most recent first. Filter by
32
- * direction, status, the owning number, and the time the call started (from and to
33
- * are inclusive). Use the call webhooks for real-time updates; this list is for
34
- * looking calls up afterwards.
36
+ * direction, status, the owning number, the mode (inapp, or agent for calls your
37
+ * voice agents answered), the agent that answered, and the time the call started
38
+ * (from and to are inclusive). Each call carries the phone number it was connected
39
+ * to, the caller id it showed, and the billed legs with what each cost. Use the
40
+ * call webhooks for real-time updates; this list is for looking calls up
41
+ * afterwards.
35
42
  *
36
43
  * @example
37
44
  * ```ts
38
45
  * // Automatically fetches more pages as needed.
39
- * for await (const call of client.calls.list()) {
46
+ * for await (const call of client.voice.calls.list()) {
40
47
  * // ...
41
48
  * }
42
49
  * ```
@@ -46,12 +53,12 @@ export declare class Calls extends APIResource {
46
53
  * Ends one of your live calls. The call then ends the way any other call does once
47
54
  * the disconnect is reported: an answered call as COMPLETED with call.completed, a
48
55
  * call still ringing as NO_ANSWER, REJECTED or FAILED with call.failed. A call
49
- * that has already ended answers 409, and so does a call with no phone leg, such
50
- * as one between two app users.
56
+ * that has already ended answers 409, as do a call with no phone leg, such as one
57
+ * between two app users, and a call one of your voice agents answers.
51
58
  *
52
59
  * @example
53
60
  * ```ts
54
- * await client.calls.hangup(
61
+ * await client.voice.calls.hangup(
55
62
  * 'call_9f2ab000-0000-4000-8000-000000000001',
56
63
  * );
57
64
  * ```
@@ -69,7 +76,7 @@ export declare class Calls extends APIResource {
69
76
  * @example
70
77
  * ```ts
71
78
  * const apiResponseOfCallRecordings =
72
- * await client.calls.listRecordings(
79
+ * await client.voice.calls.listRecordings(
73
80
  * 'call_9f2ab000-0000-4000-8000-000000000001',
74
81
  * );
75
82
  * ```
@@ -78,13 +85,13 @@ export declare class Calls extends APIResource {
78
85
  /**
79
86
  * Starts or stops recording one of your live calls. Use start to begin recording
80
87
  * mid-call, or stop to end a recording, whether it was started here or by a
81
- * connect answer with record set. A call that has already ended answers 409, and
82
- * so does a call with no phone leg, such as one between two app users, which can't
83
- * be recorded.
88
+ * connect answer with record set. A call that has already ended answers 409, as do
89
+ * a call with no phone leg, such as one between two app users, and a call one of
90
+ * your voice agents answers, neither of which can be recorded this way.
84
91
  *
85
92
  * @example
86
93
  * ```ts
87
- * await client.calls.record(
94
+ * await client.voice.calls.record(
88
95
  * 'call_9f2ab000-0000-4000-8000-000000000001',
89
96
  * );
90
97
  * ```
@@ -164,11 +171,28 @@ export interface Call {
164
171
  * webhook
165
172
  */
166
173
  id?: string;
174
+ /**
175
+ * The voice agent that answered the call, such as
176
+ * agent_9f2ab000-0000-4000-8000-000000000001. Null for an inapp call
177
+ */
178
+ agent_id?: string | null;
167
179
  /**
168
180
  * When the call was answered (UTC). Null until then, and always null for a call
169
181
  * between two of your app users
170
182
  */
171
183
  answered_at?: string | null;
184
+ /**
185
+ * The caller id shown on the phone leg, in E.164 format: the one your answer
186
+ * chose, or the owning number when it chose none. Null for a call with no phone
187
+ * leg
188
+ */
189
+ caller_id_used?: string | null;
190
+ /**
191
+ * The phone number the call was connected to, in E.164 format: the number your
192
+ * answer dialed, or the fallback number a call to one of your voice agents
193
+ * reached. Null when the call was not connected to a phone number
194
+ */
195
+ connected_number?: string | null;
172
196
  /**
173
197
  * outbound for a call placed from your app, inbound for a call to one of your
174
198
  * numbers
@@ -184,15 +208,28 @@ export interface Call {
184
208
  ended_at?: string | null;
185
209
  /**
186
210
  * Why the call did not complete: callback_timeout, invalid_answer,
187
- * insufficient_balance, destination_blocked, callback_not_configured, rejected or
188
- * no_answer. Null while the call is live, when it completed, and when it failed
189
- * without a recorded reason
211
+ * insufficient_balance, destination_blocked, callback_not_configured, rejected,
212
+ * no_answer, or for an agent call agent_busy or agent_unreachable. Null while the
213
+ * call is live, when it completed, and when it failed without a recorded reason
190
214
  */
191
215
  failure_reason?: string | null;
192
216
  /**
193
217
  * One end of a call
194
218
  */
195
219
  from?: CallParty;
220
+ /**
221
+ * The legs the price covers, one entry per billed leg, each with its own cost: a
222
+ * call your answer connected to a phone number ran the caller's leg to your number
223
+ * and the leg to the connected number at once, and both are billed. Null until the
224
+ * call has been priced
225
+ */
226
+ legs?: Array<Call.Leg> | null;
227
+ /**
228
+ * The calling mode: inapp for a call between people in your app and phone numbers,
229
+ * routed by your number's callback URL; agent for a call one of your voice agents
230
+ * answered
231
+ */
232
+ mode?: string;
196
233
  /**
197
234
  * Your number that owns the call, in E.164 format: the dialed number for an
198
235
  * inbound call, the caller's bound number for a call placed from your app
@@ -224,6 +261,36 @@ export interface Call {
224
261
  */
225
262
  to?: CallParty;
226
263
  }
264
+ export declare namespace Call {
265
+ /**
266
+ * One leg of a call the price covers
267
+ */
268
+ interface Leg {
269
+ /**
270
+ * The whole minutes the leg was billed for
271
+ */
272
+ billed_minutes?: number;
273
+ /**
274
+ * What the leg cost, in the same unit as the call's price
275
+ */
276
+ cost?: number;
277
+ /**
278
+ * The currency of the cost: USD
279
+ */
280
+ currency?: string;
281
+ /**
282
+ * inbound for the caller's leg to your number, outbound for a leg placed on your
283
+ * behalf
284
+ */
285
+ direction?: string;
286
+ /**
287
+ * The phone number the leg reached, in E.164 format: your number for the inbound
288
+ * leg, the number dialed for an outbound one. Null for a leg to one of your app
289
+ * users or a room
290
+ */
291
+ number?: string | null;
292
+ }
293
+ }
227
294
  /**
228
295
  * One end of a call
229
296
  */
@@ -302,6 +369,11 @@ export interface CallRetrieveParams {
302
369
  'x-profile-id'?: string;
303
370
  }
304
371
  export interface CallListParams extends CallsPageParams {
372
+ /**
373
+ * Query param: Optional filter on the voice agent that answered the call, such as
374
+ * agent_9f2ab000-0000-4000-8000-000000000001
375
+ */
376
+ agent_id?: string | null;
305
377
  /**
306
378
  * Query param: Optional direction filter: outbound for calls placed from your app,
307
379
  * inbound for calls to one of your numbers
@@ -311,6 +383,11 @@ export interface CallListParams extends CallsPageParams {
311
383
  * Query param: Only calls started at or after this time (ISO 8601)
312
384
  */
313
385
  from?: string | null;
386
+ /**
387
+ * Query param: Optional mode filter: inapp for calls routed by your number's
388
+ * callback URL, agent for calls one of your voice agents answered
389
+ */
390
+ mode?: string | null;
314
391
  /**
315
392
  * Query param: Optional filter on the number that owns the call, one of your
316
393
  * voice-enabled numbers in E.164 format
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.d.mts","sourceRoot":"","sources":["../../../src/resources/voice/calls/calls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,mCAA+B;AACrD,OAAO,KAAK,WAAW,2BAAuB;AAC9C,OAAO,KAAK,eAAe,2BAAuB;AAClD,OAAO,EACL,kCAAkC,EAClC,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACb,2BAAuB;AACxB,OAAO,EAAE,UAAU,EAAE,sCAAkC;AACvD,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,WAAW,EAAE,qCAAiC;AAExF,OAAO,EAAE,cAAc,EAAE,8CAA0C;AAGnE;;;;;;;;GAQG;AACH,qBAAa,KAAM,SAAQ,WAAW;IACpC,YAAY,EAAE,eAAe,CAAC,YAAY,CAAkD;IAE5F;;;;;;;;;;;;;OAaG;IACH,QAAQ,CACN,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,kBAAkB,GAAG,IAAI,GAAG,SAAc,EAClD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,iBAAiB,CAAC;IAWhC;;;;;;;;;;;;;;;;OAgBG;IACH,IAAI,CACF,MAAM,GAAE,cAAc,GAAG,IAAI,GAAG,SAAc,EAC9C,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,cAAc,EAAE,I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