@aui.io/aui-client 3.1.2 → 3.2.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 (197) hide show
  1. package/README.md +196 -69
  2. package/dist/cjs/ApolloClientWrapper.d.ts +52 -24
  3. package/dist/cjs/ApolloClientWrapper.js +86 -58
  4. package/dist/cjs/BaseClient.d.ts +5 -0
  5. package/dist/cjs/Client.d.ts +4 -1
  6. package/dist/cjs/Client.js +24 -9
  7. package/dist/cjs/api/resources/agentVersions/client/Client.d.ts +26 -2
  8. package/dist/cjs/api/resources/agentVersions/client/Client.js +96 -43
  9. package/dist/cjs/api/resources/agentVersions/client/requests/AgentVersionPushRequest.d.ts +1 -1
  10. package/dist/cjs/api/resources/agents/client/Client.d.ts +22 -7
  11. package/dist/cjs/api/resources/agents/client/Client.js +80 -39
  12. package/dist/cjs/api/resources/agents/client/requests/{ExternalAgentCreateRequest.d.ts → AgentCreateRequest.d.ts} +1 -1
  13. package/dist/{esm/api/resources/agents/client/requests/ExternalAgentUpdateRequest.d.mts → cjs/api/resources/agents/client/requests/AgentUpdateRequest.d.ts} +1 -1
  14. package/dist/cjs/api/resources/agents/client/requests/ListAgentsRequest.d.ts +1 -1
  15. package/dist/cjs/api/resources/agents/client/requests/index.d.ts +2 -2
  16. package/dist/cjs/api/resources/auth/client/Client.d.ts +3 -2
  17. package/dist/cjs/api/resources/auth/client/Client.js +20 -8
  18. package/dist/cjs/api/resources/channels/client/Client.d.ts +7 -6
  19. package/dist/cjs/api/resources/channels/client/Client.js +24 -12
  20. package/dist/cjs/api/resources/channels/client/requests/InitiateThreadRequest.d.ts +3 -10
  21. package/dist/cjs/api/resources/messaging/client/Client.d.ts +51 -14
  22. package/dist/cjs/api/resources/messaging/client/Client.js +249 -50
  23. package/dist/cjs/api/resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.d.ts +9 -0
  24. package/dist/cjs/api/resources/messaging/client/requests/RerunMessageRequest.d.ts +2 -2
  25. package/dist/cjs/api/resources/messaging/client/requests/StreamMessageRequest.d.ts +0 -1
  26. package/dist/cjs/api/resources/messaging/client/requests/index.d.ts +1 -0
  27. package/dist/cjs/api/resources/projects/client/Client.d.ts +14 -2
  28. package/dist/cjs/api/resources/projects/client/Client.js +66 -31
  29. package/dist/cjs/api/resources/session/client/Client.d.ts +2 -1
  30. package/dist/cjs/api/resources/session/client/Client.js +12 -2
  31. package/dist/cjs/api/resources/threads/client/Client.d.ts +37 -2
  32. package/dist/cjs/api/resources/threads/client/Client.js +155 -31
  33. package/dist/cjs/api/resources/threads/client/requests/UpdateThreadRequest.d.ts +8 -0
  34. package/dist/cjs/api/resources/threads/client/requests/index.d.ts +1 -0
  35. package/dist/cjs/api/types/{ExternalAgent.d.ts → Agent.d.ts} +1 -1
  36. package/dist/cjs/api/types/{ExternalAgentCreateResponse.d.ts → AgentCreateResponse.d.ts} +1 -1
  37. package/dist/cjs/api/types/{ExternalAgentListFilters.d.ts → AgentListFilters.d.ts} +1 -1
  38. package/dist/{esm/api/types/ExternalAgentUpdateResponse.d.mts → cjs/api/types/AgentUpdateResponse.d.ts} +1 -1
  39. package/dist/cjs/api/types/AgentVariables.d.ts +12 -0
  40. package/dist/cjs/api/types/AgentVersionPullResponse.d.ts +2 -3
  41. package/dist/cjs/api/types/AgentVersionPushResponse.d.ts +1 -1
  42. package/dist/cjs/api/types/AgentVersionWelcomeMessageResponse.d.ts +6 -0
  43. package/dist/cjs/api/types/GenerateFollowupSuggestionsResponse.d.ts +4 -0
  44. package/dist/cjs/api/types/PageAgent.d.ts +6 -0
  45. package/dist/cjs/api/types/PageAgentVersion.d.ts +6 -0
  46. package/dist/cjs/api/types/PageAgentVersion.js +3 -0
  47. package/dist/cjs/api/types/{ExternalPageLinks.d.ts → PageLinks.d.ts} +1 -1
  48. package/dist/cjs/api/types/PageLinks.js +3 -0
  49. package/dist/cjs/api/types/{ExternalPageMeta.d.ts → PageMeta.d.ts} +1 -1
  50. package/dist/cjs/api/types/PageMeta.js +3 -0
  51. package/dist/cjs/api/types/PageProject.d.ts +6 -0
  52. package/dist/cjs/api/types/PageProject.js +3 -0
  53. package/dist/cjs/api/types/PageThreadListItem.d.ts +6 -0
  54. package/dist/cjs/api/types/PageThreadListItem.js +3 -0
  55. package/dist/cjs/api/types/Project.d.ts +1 -1
  56. package/dist/cjs/api/types/SendMessageRequest.d.ts +7 -5
  57. package/dist/cjs/api/types/ThreadListFilters.d.ts +2 -5
  58. package/dist/cjs/api/types/TokenResponse.d.ts +4 -8
  59. package/dist/cjs/api/types/TraceDecision.d.ts +1 -2
  60. package/dist/cjs/api/types/VersionStats.d.ts +1 -2
  61. package/dist/cjs/api/types/index.d.ts +13 -10
  62. package/dist/cjs/api/types/index.js +13 -10
  63. package/dist/cjs/core/auth/AuthProvider.d.ts +4 -0
  64. package/dist/cjs/core/auth/AuthProvider.js +2 -0
  65. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  66. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  67. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  68. package/dist/cjs/core/auth/BasicAuth.js +27 -0
  69. package/dist/cjs/core/auth/BearerToken.d.ts +5 -0
  70. package/dist/cjs/core/auth/BearerToken.js +15 -0
  71. package/dist/cjs/core/auth/index.d.ts +4 -0
  72. package/dist/cjs/core/auth/index.js +7 -0
  73. package/dist/cjs/core/base64.d.ts +2 -0
  74. package/dist/cjs/core/base64.js +26 -0
  75. package/dist/cjs/core/index.d.ts +2 -0
  76. package/dist/cjs/core/index.js +2 -0
  77. package/dist/cjs/environments.d.ts +2 -2
  78. package/dist/cjs/environments.js +2 -2
  79. package/dist/cjs/index.d.ts +1 -1
  80. package/dist/cjs/index.js +3 -2
  81. package/dist/cjs/version.d.ts +1 -1
  82. package/dist/cjs/version.js +1 -1
  83. package/dist/esm/ApolloClientWrapper.d.mts +52 -24
  84. package/dist/esm/ApolloClientWrapper.mjs +83 -56
  85. package/dist/esm/BaseClient.d.mts +5 -0
  86. package/dist/esm/Client.d.mts +4 -1
  87. package/dist/esm/Client.mjs +25 -10
  88. package/dist/esm/api/resources/agentVersions/client/Client.d.mts +26 -2
  89. package/dist/esm/api/resources/agentVersions/client/Client.mjs +97 -44
  90. package/dist/esm/api/resources/agentVersions/client/requests/AgentVersionPushRequest.d.mts +1 -1
  91. package/dist/esm/api/resources/agents/client/Client.d.mts +22 -7
  92. package/dist/esm/api/resources/agents/client/Client.mjs +81 -40
  93. package/dist/esm/api/resources/agents/client/requests/{ExternalAgentCreateRequest.d.mts → AgentCreateRequest.d.mts} +1 -1
  94. package/dist/{cjs/api/resources/agents/client/requests/ExternalAgentUpdateRequest.d.ts → esm/api/resources/agents/client/requests/AgentUpdateRequest.d.mts} +1 -1
  95. package/dist/esm/api/resources/agents/client/requests/ListAgentsRequest.d.mts +1 -1
  96. package/dist/esm/api/resources/agents/client/requests/index.d.mts +2 -2
  97. package/dist/esm/api/resources/auth/client/Client.d.mts +3 -2
  98. package/dist/esm/api/resources/auth/client/Client.mjs +21 -9
  99. package/dist/esm/api/resources/channels/client/Client.d.mts +7 -6
  100. package/dist/esm/api/resources/channels/client/Client.mjs +25 -13
  101. package/dist/esm/api/resources/channels/client/requests/InitiateThreadRequest.d.mts +3 -10
  102. package/dist/esm/api/resources/messaging/client/Client.d.mts +51 -14
  103. package/dist/esm/api/resources/messaging/client/Client.mjs +249 -50
  104. package/dist/esm/api/resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.d.mts +9 -0
  105. package/dist/esm/api/resources/messaging/client/requests/RerunMessageRequest.d.mts +2 -2
  106. package/dist/esm/api/resources/messaging/client/requests/StreamMessageRequest.d.mts +0 -1
  107. package/dist/esm/api/resources/messaging/client/requests/index.d.mts +1 -0
  108. package/dist/esm/api/resources/projects/client/Client.d.mts +14 -2
  109. package/dist/esm/api/resources/projects/client/Client.mjs +67 -32
  110. package/dist/esm/api/resources/session/client/Client.d.mts +2 -1
  111. package/dist/esm/api/resources/session/client/Client.mjs +12 -2
  112. package/dist/esm/api/resources/threads/client/Client.d.mts +37 -2
  113. package/dist/esm/api/resources/threads/client/Client.mjs +156 -32
  114. package/dist/esm/api/resources/threads/client/requests/UpdateThreadRequest.d.mts +8 -0
  115. package/dist/esm/api/resources/threads/client/requests/index.d.mts +1 -0
  116. package/dist/esm/api/types/{ExternalAgent.d.mts → Agent.d.mts} +1 -1
  117. package/dist/esm/api/types/{ExternalAgentCreateResponse.d.mts → AgentCreateResponse.d.mts} +1 -1
  118. package/dist/esm/api/types/{ExternalAgentListFilters.d.mts → AgentListFilters.d.mts} +1 -1
  119. package/dist/{cjs/api/types/ExternalAgentUpdateResponse.d.ts → esm/api/types/AgentUpdateResponse.d.mts} +1 -1
  120. package/dist/esm/api/types/AgentVariables.d.mts +12 -0
  121. package/dist/esm/api/types/AgentVersionPullResponse.d.mts +2 -3
  122. package/dist/esm/api/types/AgentVersionPushResponse.d.mts +1 -1
  123. package/dist/esm/api/types/AgentVersionWelcomeMessageResponse.d.mts +6 -0
  124. package/dist/esm/api/types/GenerateFollowupSuggestionsResponse.d.mts +4 -0
  125. package/dist/esm/api/types/PageAgent.d.mts +6 -0
  126. package/dist/esm/api/types/PageAgentVersion.d.mts +6 -0
  127. package/dist/esm/api/types/PageAgentVersion.mjs +2 -0
  128. package/dist/esm/api/types/{ExternalPageLinks.d.mts → PageLinks.d.mts} +1 -1
  129. package/dist/esm/api/types/PageLinks.mjs +2 -0
  130. package/dist/esm/api/types/{ExternalPageMeta.d.mts → PageMeta.d.mts} +1 -1
  131. package/dist/esm/api/types/PageMeta.mjs +2 -0
  132. package/dist/esm/api/types/PageProject.d.mts +6 -0
  133. package/dist/esm/api/types/PageProject.mjs +2 -0
  134. package/dist/esm/api/types/PageThreadListItem.d.mts +6 -0
  135. package/dist/esm/api/types/PageThreadListItem.mjs +2 -0
  136. package/dist/esm/api/types/Project.d.mts +1 -1
  137. package/dist/esm/api/types/SendMessageRequest.d.mts +7 -5
  138. package/dist/esm/api/types/ThreadListFilters.d.mts +2 -5
  139. package/dist/esm/api/types/TokenResponse.d.mts +4 -8
  140. package/dist/esm/api/types/TraceDecision.d.mts +1 -2
  141. package/dist/esm/api/types/VersionStats.d.mts +1 -2
  142. package/dist/esm/api/types/index.d.mts +13 -10
  143. package/dist/esm/api/types/index.mjs +13 -10
  144. package/dist/esm/core/auth/AuthProvider.d.mts +4 -0
  145. package/dist/esm/core/auth/AuthProvider.mjs +1 -0
  146. package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
  147. package/dist/esm/core/auth/AuthRequest.mjs +1 -0
  148. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  149. package/dist/esm/core/auth/BasicAuth.mjs +24 -0
  150. package/dist/esm/core/auth/BearerToken.d.mts +5 -0
  151. package/dist/esm/core/auth/BearerToken.mjs +12 -0
  152. package/dist/esm/core/auth/index.d.mts +4 -0
  153. package/dist/esm/core/auth/index.mjs +2 -0
  154. package/dist/esm/core/base64.d.mts +2 -0
  155. package/dist/esm/core/base64.mjs +22 -0
  156. package/dist/esm/core/index.d.mts +2 -0
  157. package/dist/esm/core/index.mjs +2 -0
  158. package/dist/esm/environments.d.mts +2 -2
  159. package/dist/esm/environments.mjs +2 -2
  160. package/dist/esm/index.d.mts +1 -1
  161. package/dist/esm/index.mjs +1 -1
  162. package/dist/esm/version.d.mts +1 -1
  163. package/dist/esm/version.mjs +1 -1
  164. package/package.json +1 -1
  165. package/reference.md +568 -29
  166. package/dist/cjs/api/types/ExternalPageAgentVersion.d.ts +0 -6
  167. package/dist/cjs/api/types/ExternalPageExternalAgent.d.ts +0 -6
  168. package/dist/cjs/api/types/ExternalPageProject.d.ts +0 -6
  169. package/dist/cjs/api/types/ExternalPageThreadListItem.d.ts +0 -6
  170. package/dist/esm/api/types/ExternalPageAgentVersion.d.mts +0 -6
  171. package/dist/esm/api/types/ExternalPageExternalAgent.d.mts +0 -6
  172. package/dist/esm/api/types/ExternalPageProject.d.mts +0 -6
  173. package/dist/esm/api/types/ExternalPageThreadListItem.d.mts +0 -6
  174. /package/dist/cjs/api/resources/agents/client/requests/{ExternalAgentCreateRequest.js → AgentCreateRequest.js} +0 -0
  175. /package/dist/cjs/api/resources/agents/client/requests/{ExternalAgentUpdateRequest.js → AgentUpdateRequest.js} +0 -0
  176. /package/dist/cjs/api/{types/ExternalAgent.js → resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.js} +0 -0
  177. /package/dist/cjs/api/{types/ExternalAgentCreateResponse.js → resources/threads/client/requests/UpdateThreadRequest.js} +0 -0
  178. /package/dist/cjs/api/types/{ExternalAgentListFilters.js → Agent.js} +0 -0
  179. /package/dist/cjs/api/types/{ExternalAgentUpdateResponse.js → AgentCreateResponse.js} +0 -0
  180. /package/dist/cjs/api/types/{ExternalPageAgentVersion.js → AgentListFilters.js} +0 -0
  181. /package/dist/cjs/api/types/{ExternalPageExternalAgent.js → AgentUpdateResponse.js} +0 -0
  182. /package/dist/cjs/api/types/{ExternalPageLinks.js → AgentVariables.js} +0 -0
  183. /package/dist/cjs/api/types/{ExternalPageMeta.js → AgentVersionWelcomeMessageResponse.js} +0 -0
  184. /package/dist/cjs/api/types/{ExternalPageProject.js → GenerateFollowupSuggestionsResponse.js} +0 -0
  185. /package/dist/cjs/api/types/{ExternalPageThreadListItem.js → PageAgent.js} +0 -0
  186. /package/dist/esm/api/resources/agents/client/requests/{ExternalAgentCreateRequest.mjs → AgentCreateRequest.mjs} +0 -0
  187. /package/dist/esm/api/resources/agents/client/requests/{ExternalAgentUpdateRequest.mjs → AgentUpdateRequest.mjs} +0 -0
  188. /package/dist/esm/api/{types/ExternalAgent.mjs → resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.mjs} +0 -0
  189. /package/dist/esm/api/{types/ExternalAgentCreateResponse.mjs → resources/threads/client/requests/UpdateThreadRequest.mjs} +0 -0
  190. /package/dist/esm/api/types/{ExternalAgentListFilters.mjs → Agent.mjs} +0 -0
  191. /package/dist/esm/api/types/{ExternalAgentUpdateResponse.mjs → AgentCreateResponse.mjs} +0 -0
  192. /package/dist/esm/api/types/{ExternalPageAgentVersion.mjs → AgentListFilters.mjs} +0 -0
  193. /package/dist/esm/api/types/{ExternalPageExternalAgent.mjs → AgentUpdateResponse.mjs} +0 -0
  194. /package/dist/esm/api/types/{ExternalPageLinks.mjs → AgentVariables.mjs} +0 -0
  195. /package/dist/esm/api/types/{ExternalPageMeta.mjs → AgentVersionWelcomeMessageResponse.mjs} +0 -0
  196. /package/dist/esm/api/types/{ExternalPageProject.mjs → GenerateFollowupSuggestionsResponse.mjs} +0 -0
  197. /package/dist/esm/api/types/{ExternalPageThreadListItem.mjs → PageAgent.mjs} +0 -0
@@ -9,7 +9,7 @@ export declare namespace Messaging {
9
9
  }
10
10
  export declare class Messaging {
11
11
  protected readonly _options: Messaging.Options;
12
- constructor(_options?: Messaging.Options);
12
+ constructor(_options: Messaging.Options);
13
13
  /**
14
14
  * Send a message; auto-create the thread when ``thread_id`` is omitted. For a live
15
15
  * token stream use ``POST /messages/stream`` (SSE). The resolved thread id is
@@ -28,7 +28,6 @@ export declare class Messaging {
28
28
  *
29
29
  * @example
30
30
  * await client.messaging.sendMessage({
31
- * agent_id: "agent_id",
32
31
  * text: "text",
33
32
  * user_id: "user_id"
34
33
  * })
@@ -36,19 +35,18 @@ export declare class Messaging {
36
35
  sendMessage(request: Apollo.SendMessageRequest, requestOptions?: Messaging.RequestOptions): core.HttpResponsePromise<Apollo.SendMessageResponse>;
37
36
  private __sendMessage;
38
37
  /**
39
- * Send a message and stream tokens over Server-Sent Events. Auto-creates the
40
- * thread when ``thread_id`` is omitted — the resolved id arrives as the first
41
- * ``thread`` event (an SSE client can't read response headers). Resume a dropped
42
- * stream with the standard ``Last-Event-ID`` header: buffered frames replay, no
43
- * fresh turn. FastAPI owns the wire format, keep-alive pings, and OpenAPI docs.
38
+ * Send a message and stream the reply token-by-token over Server-Sent
39
+ * Events. The thread is created automatically when ``thread_id`` is omitted —
40
+ * the resolved id arrives as the first ``thread`` event. Resume a dropped
41
+ * stream with the standard ``Last-Event-ID`` header: missed events replay
42
+ * without running the turn again.
44
43
  */
45
44
  streamMessage(request: Apollo.StreamMessageRequest, requestOptions?: Messaging.RequestOptions): core.HttpResponsePromise<core.Stream<Apollo.StreamMessageResponse>>;
46
45
  private __streamMessage;
47
46
  /**
48
- * Regenerate ``interaction_id`` on the thread against the live version, then
49
- * replay ``text`` onto the clone. The acting user is optional — absent for the
50
- * agent-scoped publishable-key flow, where IA attributes the thread's own user.
51
- * ``thread_id`` in the response is the clone's id, not the original.
47
+ * Regenerate ``interaction_id`` on the thread against the agent's live
48
+ * version, then replay ``text`` onto the resulting new thread. The response's
49
+ * ``thread_id`` is the new thread's id, not the original.
52
50
  *
53
51
  * @param {string} threadId
54
52
  * @param {Apollo.RerunMessageRequest} request
@@ -64,7 +62,6 @@ export declare class Messaging {
64
62
  *
65
63
  * @example
66
64
  * await client.messaging.rerun("threadId", {
67
- * agent_id: "agent_id",
68
65
  * interaction_id: "interaction_id",
69
66
  * text: "text"
70
67
  * })
@@ -72,7 +69,7 @@ export declare class Messaging {
72
69
  rerun(threadId: string, request: Apollo.RerunMessageRequest, requestOptions?: Messaging.RequestOptions): core.HttpResponsePromise<Apollo.SendMessageResponse>;
73
70
  private __rerun;
74
71
  /**
75
- * The thread transcript, scoped to the key's agent.
72
+ * The thread's full transcript, in chronological order.
76
73
  *
77
74
  * @param {string} threadId
78
75
  * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
@@ -110,7 +107,7 @@ export declare class Messaging {
110
107
  threadTrace(threadId: string, requestOptions?: Messaging.RequestOptions): core.HttpResponsePromise<Apollo.Trace[]>;
111
108
  private __threadTrace;
112
109
  /**
113
- * One interaction's trace, resolved directly by interaction id.
110
+ * The reasoning trace of a single interaction, resolved by its id.
114
111
  *
115
112
  * @param {string} interactionId
116
113
  * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
@@ -128,4 +125,44 @@ export declare class Messaging {
128
125
  */
129
126
  interactionTrace(interactionId: string, requestOptions?: Messaging.RequestOptions): core.HttpResponsePromise<Apollo.Trace>;
130
127
  private __interactionTrace;
128
+ /**
129
+ * Generate suggested follow-up prompts from a context you provide —
130
+ * useful for offering the end user quick next questions.
131
+ *
132
+ * @param {Apollo.GenerateFollowupSuggestionsRequest} request
133
+ * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
134
+ *
135
+ * @throws {@link Apollo.BadRequestError}
136
+ * @throws {@link Apollo.UnauthorizedError}
137
+ * @throws {@link Apollo.ForbiddenError}
138
+ * @throws {@link Apollo.NotFoundError}
139
+ * @throws {@link Apollo.ConflictError}
140
+ * @throws {@link Apollo.UnprocessableEntityError}
141
+ * @throws {@link Apollo.InternalServerError}
142
+ *
143
+ * @example
144
+ * await client.messaging.generateFollowupSuggestions()
145
+ */
146
+ generateFollowupSuggestions(request?: Apollo.GenerateFollowupSuggestionsRequest, requestOptions?: Messaging.RequestOptions): core.HttpResponsePromise<Apollo.GenerateFollowupSuggestionsResponse>;
147
+ private __generateFollowupSuggestions;
148
+ /**
149
+ * The welcome message of the agent's live version — what to show before
150
+ * the first user message.
151
+ *
152
+ * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
153
+ *
154
+ * @throws {@link Apollo.BadRequestError}
155
+ * @throws {@link Apollo.UnauthorizedError}
156
+ * @throws {@link Apollo.ForbiddenError}
157
+ * @throws {@link Apollo.NotFoundError}
158
+ * @throws {@link Apollo.ConflictError}
159
+ * @throws {@link Apollo.UnprocessableEntityError}
160
+ * @throws {@link Apollo.InternalServerError}
161
+ *
162
+ * @example
163
+ * await client.messaging.getWelcomeMessage()
164
+ */
165
+ getWelcomeMessage(requestOptions?: Messaging.RequestOptions): core.HttpResponsePromise<Apollo.AgentVersionWelcomeMessageResponse>;
166
+ private __getWelcomeMessage;
167
+ protected _getAuthorizationHeader(): Promise<string | undefined>;
131
168
  }
@@ -50,7 +50,7 @@ const environments = __importStar(require("../../../../environments.js"));
50
50
  const errors = __importStar(require("../../../../errors/index.js"));
51
51
  const Apollo = __importStar(require("../../../index.js"));
52
52
  class Messaging {
53
- constructor(_options = {}) {
53
+ constructor(_options) {
54
54
  this._options = _options;
55
55
  }
56
56
  /**
@@ -71,7 +71,6 @@ class Messaging {
71
71
  *
72
72
  * @example
73
73
  * await client.messaging.sendMessage({
74
- * agent_id: "agent_id",
75
74
  * text: "text",
76
75
  * user_id: "user_id"
77
76
  * })
@@ -81,20 +80,23 @@ class Messaging {
81
80
  }
82
81
  __sendMessage(request, requestOptions) {
83
82
  return __awaiter(this, void 0, void 0, function* () {
84
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
85
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
83
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
84
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
85
+ Authorization: yield this._getAuthorizationHeader(),
86
+ "x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
87
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
86
88
  const _response = yield core.fetcher({
87
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, "messaging/v1/messages"),
89
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "messaging/v1/messages"),
88
90
  method: "POST",
89
91
  headers: _headers,
90
92
  contentType: "application/json",
91
93
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
92
94
  requestType: "json",
93
95
  body: request,
94
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
95
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
96
+ timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
97
+ maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
96
98
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
97
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
99
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
98
100
  logging: this._options.logging,
99
101
  });
100
102
  if (_response.ok) {
@@ -142,22 +144,26 @@ class Messaging {
142
144
  });
143
145
  }
144
146
  /**
145
- * Send a message and stream tokens over Server-Sent Events. Auto-creates the
146
- * thread when ``thread_id`` is omitted — the resolved id arrives as the first
147
- * ``thread`` event (an SSE client can't read response headers). Resume a dropped
148
- * stream with the standard ``Last-Event-ID`` header: buffered frames replay, no
149
- * fresh turn. FastAPI owns the wire format, keep-alive pings, and OpenAPI docs.
147
+ * Send a message and stream the reply token-by-token over Server-Sent
148
+ * Events. The thread is created automatically when ``thread_id`` is omitted —
149
+ * the resolved id arrives as the first ``thread`` event. Resume a dropped
150
+ * stream with the standard ``Last-Event-ID`` header: missed events replay
151
+ * without running the turn again.
150
152
  */
151
153
  streamMessage(request, requestOptions) {
152
154
  return core.HttpResponsePromise.fromPromise(this.__streamMessage(request, requestOptions));
153
155
  }
154
156
  __streamMessage(request, requestOptions) {
155
157
  return __awaiter(this, void 0, void 0, function* () {
156
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
158
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
157
159
  const { "Last-Event-ID": lastEventId, body: _body } = request;
158
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Last-Event-ID": lastEventId != null ? lastEventId : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
160
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
161
+ Authorization: yield this._getAuthorizationHeader(),
162
+ "Last-Event-ID": lastEventId != null ? lastEventId : undefined,
163
+ "x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
164
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
159
165
  const _response = yield core.fetcher({
160
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, "messaging/v1/messages/stream"),
166
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "messaging/v1/messages/stream"),
161
167
  method: "POST",
162
168
  headers: _headers,
163
169
  contentType: "application/json",
@@ -165,10 +171,10 @@ class Messaging {
165
171
  requestType: "json",
166
172
  body: _body,
167
173
  responseType: "sse",
168
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
169
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
174
+ timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
175
+ maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
170
176
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
171
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
177
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
172
178
  logging: this._options.logging,
173
179
  });
174
180
  if (_response.ok) {
@@ -227,10 +233,9 @@ class Messaging {
227
233
  });
228
234
  }
229
235
  /**
230
- * Regenerate ``interaction_id`` on the thread against the live version, then
231
- * replay ``text`` onto the clone. The acting user is optional — absent for the
232
- * agent-scoped publishable-key flow, where IA attributes the thread's own user.
233
- * ``thread_id`` in the response is the clone's id, not the original.
236
+ * Regenerate ``interaction_id`` on the thread against the agent's live
237
+ * version, then replay ``text`` onto the resulting new thread. The response's
238
+ * ``thread_id`` is the new thread's id, not the original.
234
239
  *
235
240
  * @param {string} threadId
236
241
  * @param {Apollo.RerunMessageRequest} request
@@ -246,7 +251,6 @@ class Messaging {
246
251
  *
247
252
  * @example
248
253
  * await client.messaging.rerun("threadId", {
249
- * agent_id: "agent_id",
250
254
  * interaction_id: "interaction_id",
251
255
  * text: "text"
252
256
  * })
@@ -256,20 +260,23 @@ class Messaging {
256
260
  }
257
261
  __rerun(threadId, request, requestOptions) {
258
262
  return __awaiter(this, void 0, void 0, function* () {
259
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
260
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
263
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
264
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
265
+ Authorization: yield this._getAuthorizationHeader(),
266
+ "x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
267
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
261
268
  const _response = yield core.fetcher({
262
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `messaging/v1/threads/${core.url.encodePathParam(threadId)}/rerun`),
269
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `messaging/v1/threads/${core.url.encodePathParam(threadId)}/rerun`),
263
270
  method: "POST",
264
271
  headers: _headers,
265
272
  contentType: "application/json",
266
273
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
267
274
  requestType: "json",
268
275
  body: request,
269
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
270
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
276
+ timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
277
+ maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
271
278
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
272
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
279
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
273
280
  logging: this._options.logging,
274
281
  });
275
282
  if (_response.ok) {
@@ -317,7 +324,7 @@ class Messaging {
317
324
  });
318
325
  }
319
326
  /**
320
- * The thread transcript, scoped to the key's agent.
327
+ * The thread's full transcript, in chronological order.
321
328
  *
322
329
  * @param {string} threadId
323
330
  * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
@@ -338,17 +345,20 @@ class Messaging {
338
345
  }
339
346
  __listMessages(threadId, requestOptions) {
340
347
  return __awaiter(this, void 0, void 0, function* () {
341
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
342
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
348
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
349
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
350
+ Authorization: yield this._getAuthorizationHeader(),
351
+ "x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
352
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
343
353
  const _response = yield core.fetcher({
344
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `messaging/v1/threads/${core.url.encodePathParam(threadId)}/messages`),
354
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `messaging/v1/threads/${core.url.encodePathParam(threadId)}/messages`),
345
355
  method: "GET",
346
356
  headers: _headers,
347
357
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
348
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
349
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
358
+ timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
359
+ maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
350
360
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
351
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
361
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
352
362
  logging: this._options.logging,
353
363
  });
354
364
  if (_response.ok) {
@@ -417,17 +427,20 @@ class Messaging {
417
427
  }
418
428
  __threadTrace(threadId, requestOptions) {
419
429
  return __awaiter(this, void 0, void 0, function* () {
420
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
421
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
430
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
431
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
432
+ Authorization: yield this._getAuthorizationHeader(),
433
+ "x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
434
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
422
435
  const _response = yield core.fetcher({
423
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `messaging/v1/threads/${core.url.encodePathParam(threadId)}/trace`),
436
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `messaging/v1/threads/${core.url.encodePathParam(threadId)}/trace`),
424
437
  method: "GET",
425
438
  headers: _headers,
426
439
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
427
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
428
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
440
+ timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
441
+ maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
429
442
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
430
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
443
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
431
444
  logging: this._options.logging,
432
445
  });
433
446
  if (_response.ok) {
@@ -475,7 +488,7 @@ class Messaging {
475
488
  });
476
489
  }
477
490
  /**
478
- * One interaction's trace, resolved directly by interaction id.
491
+ * The reasoning trace of a single interaction, resolved by its id.
479
492
  *
480
493
  * @param {string} interactionId
481
494
  * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
@@ -496,17 +509,20 @@ class Messaging {
496
509
  }
497
510
  __interactionTrace(interactionId, requestOptions) {
498
511
  return __awaiter(this, void 0, void 0, function* () {
499
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
500
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
512
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
513
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
514
+ Authorization: yield this._getAuthorizationHeader(),
515
+ "x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
516
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
501
517
  const _response = yield core.fetcher({
502
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `messaging/v1/interactions/${core.url.encodePathParam(interactionId)}/trace`),
518
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `messaging/v1/interactions/${core.url.encodePathParam(interactionId)}/trace`),
503
519
  method: "GET",
504
520
  headers: _headers,
505
521
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
506
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
507
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
522
+ timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
523
+ maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
508
524
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
509
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
525
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
510
526
  logging: this._options.logging,
511
527
  });
512
528
  if (_response.ok) {
@@ -553,5 +569,188 @@ class Messaging {
553
569
  }
554
570
  });
555
571
  }
572
+ /**
573
+ * Generate suggested follow-up prompts from a context you provide —
574
+ * useful for offering the end user quick next questions.
575
+ *
576
+ * @param {Apollo.GenerateFollowupSuggestionsRequest} request
577
+ * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
578
+ *
579
+ * @throws {@link Apollo.BadRequestError}
580
+ * @throws {@link Apollo.UnauthorizedError}
581
+ * @throws {@link Apollo.ForbiddenError}
582
+ * @throws {@link Apollo.NotFoundError}
583
+ * @throws {@link Apollo.ConflictError}
584
+ * @throws {@link Apollo.UnprocessableEntityError}
585
+ * @throws {@link Apollo.InternalServerError}
586
+ *
587
+ * @example
588
+ * await client.messaging.generateFollowupSuggestions()
589
+ */
590
+ generateFollowupSuggestions(request = {}, requestOptions) {
591
+ return core.HttpResponsePromise.fromPromise(this.__generateFollowupSuggestions(request, requestOptions));
592
+ }
593
+ __generateFollowupSuggestions() {
594
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
595
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
596
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
597
+ Authorization: yield this._getAuthorizationHeader(),
598
+ "x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
599
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
600
+ const _response = yield core.fetcher({
601
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "messaging/v1/followup-suggestions"),
602
+ method: "POST",
603
+ headers: _headers,
604
+ contentType: "application/json",
605
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
606
+ requestType: "json",
607
+ body: request,
608
+ timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
609
+ maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
610
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
611
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
612
+ logging: this._options.logging,
613
+ });
614
+ if (_response.ok) {
615
+ return {
616
+ data: _response.body,
617
+ rawResponse: _response.rawResponse,
618
+ };
619
+ }
620
+ if (_response.error.reason === "status-code") {
621
+ switch (_response.error.statusCode) {
622
+ case 400:
623
+ throw new Apollo.BadRequestError(_response.error.body, _response.rawResponse);
624
+ case 401:
625
+ throw new Apollo.UnauthorizedError(_response.error.body, _response.rawResponse);
626
+ case 403:
627
+ throw new Apollo.ForbiddenError(_response.error.body, _response.rawResponse);
628
+ case 404:
629
+ throw new Apollo.NotFoundError(_response.error.body, _response.rawResponse);
630
+ case 409:
631
+ throw new Apollo.ConflictError(_response.error.body, _response.rawResponse);
632
+ case 422:
633
+ throw new Apollo.UnprocessableEntityError(_response.error.body, _response.rawResponse);
634
+ case 500:
635
+ throw new Apollo.InternalServerError(_response.error.body, _response.rawResponse);
636
+ default:
637
+ throw new errors.ApolloError({
638
+ statusCode: _response.error.statusCode,
639
+ body: _response.error.body,
640
+ rawResponse: _response.rawResponse,
641
+ });
642
+ }
643
+ }
644
+ switch (_response.error.reason) {
645
+ case "non-json":
646
+ throw new errors.ApolloError({
647
+ statusCode: _response.error.statusCode,
648
+ body: _response.error.rawBody,
649
+ rawResponse: _response.rawResponse,
650
+ });
651
+ case "timeout":
652
+ throw new errors.ApolloTimeoutError("Timeout exceeded when calling POST /messaging/v1/followup-suggestions.");
653
+ case "unknown":
654
+ throw new errors.ApolloError({
655
+ message: _response.error.errorMessage,
656
+ rawResponse: _response.rawResponse,
657
+ });
658
+ }
659
+ });
660
+ }
661
+ /**
662
+ * The welcome message of the agent's live version — what to show before
663
+ * the first user message.
664
+ *
665
+ * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
666
+ *
667
+ * @throws {@link Apollo.BadRequestError}
668
+ * @throws {@link Apollo.UnauthorizedError}
669
+ * @throws {@link Apollo.ForbiddenError}
670
+ * @throws {@link Apollo.NotFoundError}
671
+ * @throws {@link Apollo.ConflictError}
672
+ * @throws {@link Apollo.UnprocessableEntityError}
673
+ * @throws {@link Apollo.InternalServerError}
674
+ *
675
+ * @example
676
+ * await client.messaging.getWelcomeMessage()
677
+ */
678
+ getWelcomeMessage(requestOptions) {
679
+ return core.HttpResponsePromise.fromPromise(this.__getWelcomeMessage(requestOptions));
680
+ }
681
+ __getWelcomeMessage(requestOptions) {
682
+ return __awaiter(this, void 0, void 0, function* () {
683
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
684
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
685
+ Authorization: yield this._getAuthorizationHeader(),
686
+ "x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
687
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
688
+ const _response = yield core.fetcher({
689
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "messaging/v1/welcome-message"),
690
+ method: "GET",
691
+ headers: _headers,
692
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
693
+ timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
694
+ maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
695
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
696
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
697
+ logging: this._options.logging,
698
+ });
699
+ if (_response.ok) {
700
+ return {
701
+ data: _response.body,
702
+ rawResponse: _response.rawResponse,
703
+ };
704
+ }
705
+ if (_response.error.reason === "status-code") {
706
+ switch (_response.error.statusCode) {
707
+ case 400:
708
+ throw new Apollo.BadRequestError(_response.error.body, _response.rawResponse);
709
+ case 401:
710
+ throw new Apollo.UnauthorizedError(_response.error.body, _response.rawResponse);
711
+ case 403:
712
+ throw new Apollo.ForbiddenError(_response.error.body, _response.rawResponse);
713
+ case 404:
714
+ throw new Apollo.NotFoundError(_response.error.body, _response.rawResponse);
715
+ case 409:
716
+ throw new Apollo.ConflictError(_response.error.body, _response.rawResponse);
717
+ case 422:
718
+ throw new Apollo.UnprocessableEntityError(_response.error.body, _response.rawResponse);
719
+ case 500:
720
+ throw new Apollo.InternalServerError(_response.error.body, _response.rawResponse);
721
+ default:
722
+ throw new errors.ApolloError({
723
+ statusCode: _response.error.statusCode,
724
+ body: _response.error.body,
725
+ rawResponse: _response.rawResponse,
726
+ });
727
+ }
728
+ }
729
+ switch (_response.error.reason) {
730
+ case "non-json":
731
+ throw new errors.ApolloError({
732
+ statusCode: _response.error.statusCode,
733
+ body: _response.error.rawBody,
734
+ rawResponse: _response.rawResponse,
735
+ });
736
+ case "timeout":
737
+ throw new errors.ApolloTimeoutError("Timeout exceeded when calling GET /messaging/v1/welcome-message.");
738
+ case "unknown":
739
+ throw new errors.ApolloError({
740
+ message: _response.error.errorMessage,
741
+ rawResponse: _response.rawResponse,
742
+ });
743
+ }
744
+ });
745
+ }
746
+ _getAuthorizationHeader() {
747
+ return __awaiter(this, void 0, void 0, function* () {
748
+ const bearer = yield core.Supplier.get(this._options.token);
749
+ if (bearer != null) {
750
+ return `Bearer ${bearer}`;
751
+ }
752
+ return undefined;
753
+ });
754
+ }
556
755
  }
557
756
  exports.Messaging = Messaging;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @example
3
+ * {}
4
+ */
5
+ export interface GenerateFollowupSuggestionsRequest {
6
+ /** Context the suggestions are generated from. */
7
+ context?: Record<string, unknown>;
8
+ created_by?: string;
9
+ }
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * @example
3
3
  * {
4
- * agent_id: "agent_id",
5
4
  * interaction_id: "interaction_id",
6
5
  * text: "text"
7
6
  * }
8
7
  */
9
8
  export interface RerunMessageRequest {
10
- agent_id: string;
11
9
  interaction_id: string;
12
10
  text: string;
11
+ /** End user to attribute the rerun to; omitted, the thread's original user is kept. */
12
+ user_id?: string;
13
13
  /** Signed image URL on the replayed message. */
14
14
  image_url?: string;
15
15
  version_id?: string;
@@ -4,7 +4,6 @@ import type * as Apollo from "../../../../index.js";
4
4
  * {
5
5
  * "Last-Event-ID": "Last-Event-ID",
6
6
  * body: {
7
- * agent_id: "agent_id",
8
7
  * text: "text",
9
8
  * user_id: "user_id"
10
9
  * }
@@ -1,2 +1,3 @@
1
+ export type { GenerateFollowupSuggestionsRequest } from "./GenerateFollowupSuggestionsRequest.js";
1
2
  export type { RerunMessageRequest } from "./RerunMessageRequest.js";
2
3
  export type { StreamMessageRequest } from "./StreamMessageRequest.js";