@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
  }
@@ -14,7 +14,7 @@ import * as environments from "../../../../environments.mjs";
14
14
  import * as errors from "../../../../errors/index.mjs";
15
15
  import * as Apollo from "../../../index.mjs";
16
16
  export class Messaging {
17
- constructor(_options = {}) {
17
+ constructor(_options) {
18
18
  this._options = _options;
19
19
  }
20
20
  /**
@@ -35,7 +35,6 @@ export class Messaging {
35
35
  *
36
36
  * @example
37
37
  * await client.messaging.sendMessage({
38
- * agent_id: "agent_id",
39
38
  * text: "text",
40
39
  * user_id: "user_id"
41
40
  * })
@@ -45,20 +44,23 @@ export class Messaging {
45
44
  }
46
45
  __sendMessage(request, requestOptions) {
47
46
  return __awaiter(this, void 0, void 0, function* () {
48
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
49
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
47
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
48
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
49
+ Authorization: yield this._getAuthorizationHeader(),
50
+ "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,
51
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
50
52
  const _response = yield core.fetcher({
51
- 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"),
53
+ 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"),
52
54
  method: "POST",
53
55
  headers: _headers,
54
56
  contentType: "application/json",
55
57
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
56
58
  requestType: "json",
57
59
  body: request,
58
- 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,
59
- 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,
60
+ 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,
61
+ 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,
60
62
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
61
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
63
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
62
64
  logging: this._options.logging,
63
65
  });
64
66
  if (_response.ok) {
@@ -106,22 +108,26 @@ export class Messaging {
106
108
  });
107
109
  }
108
110
  /**
109
- * Send a message and stream tokens over Server-Sent Events. Auto-creates the
110
- * thread when ``thread_id`` is omitted — the resolved id arrives as the first
111
- * ``thread`` event (an SSE client can't read response headers). Resume a dropped
112
- * stream with the standard ``Last-Event-ID`` header: buffered frames replay, no
113
- * fresh turn. FastAPI owns the wire format, keep-alive pings, and OpenAPI docs.
111
+ * Send a message and stream the reply token-by-token over Server-Sent
112
+ * Events. The thread is created automatically when ``thread_id`` is omitted —
113
+ * the resolved id arrives as the first ``thread`` event. Resume a dropped
114
+ * stream with the standard ``Last-Event-ID`` header: missed events replay
115
+ * without running the turn again.
114
116
  */
115
117
  streamMessage(request, requestOptions) {
116
118
  return core.HttpResponsePromise.fromPromise(this.__streamMessage(request, requestOptions));
117
119
  }
118
120
  __streamMessage(request, requestOptions) {
119
121
  return __awaiter(this, void 0, void 0, function* () {
120
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
122
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
121
123
  const { "Last-Event-ID": lastEventId, body: _body } = request;
122
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ "Last-Event-ID": lastEventId != null ? lastEventId : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
124
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
125
+ Authorization: yield this._getAuthorizationHeader(),
126
+ "Last-Event-ID": lastEventId != null ? lastEventId : undefined,
127
+ "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,
128
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
123
129
  const _response = yield core.fetcher({
124
- 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"),
130
+ 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"),
125
131
  method: "POST",
126
132
  headers: _headers,
127
133
  contentType: "application/json",
@@ -129,10 +135,10 @@ export class Messaging {
129
135
  requestType: "json",
130
136
  body: _body,
131
137
  responseType: "sse",
132
- 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,
133
- 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,
138
+ 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,
139
+ 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,
134
140
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
135
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
141
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
136
142
  logging: this._options.logging,
137
143
  });
138
144
  if (_response.ok) {
@@ -191,10 +197,9 @@ export class Messaging {
191
197
  });
192
198
  }
193
199
  /**
194
- * Regenerate ``interaction_id`` on the thread against the live version, then
195
- * replay ``text`` onto the clone. The acting user is optional — absent for the
196
- * agent-scoped publishable-key flow, where IA attributes the thread's own user.
197
- * ``thread_id`` in the response is the clone's id, not the original.
200
+ * Regenerate ``interaction_id`` on the thread against the agent's live
201
+ * version, then replay ``text`` onto the resulting new thread. The response's
202
+ * ``thread_id`` is the new thread's id, not the original.
198
203
  *
199
204
  * @param {string} threadId
200
205
  * @param {Apollo.RerunMessageRequest} request
@@ -210,7 +215,6 @@ export class Messaging {
210
215
  *
211
216
  * @example
212
217
  * await client.messaging.rerun("threadId", {
213
- * agent_id: "agent_id",
214
218
  * interaction_id: "interaction_id",
215
219
  * text: "text"
216
220
  * })
@@ -220,20 +224,23 @@ export class Messaging {
220
224
  }
221
225
  __rerun(threadId, request, requestOptions) {
222
226
  return __awaiter(this, void 0, void 0, function* () {
223
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
224
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
227
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
228
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
229
+ Authorization: yield this._getAuthorizationHeader(),
230
+ "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,
231
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
225
232
  const _response = yield core.fetcher({
226
- 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`),
233
+ 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`),
227
234
  method: "POST",
228
235
  headers: _headers,
229
236
  contentType: "application/json",
230
237
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
231
238
  requestType: "json",
232
239
  body: request,
233
- 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,
234
- 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,
240
+ 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,
241
+ 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,
235
242
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
236
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
243
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
237
244
  logging: this._options.logging,
238
245
  });
239
246
  if (_response.ok) {
@@ -281,7 +288,7 @@ export class Messaging {
281
288
  });
282
289
  }
283
290
  /**
284
- * The thread transcript, scoped to the key's agent.
291
+ * The thread's full transcript, in chronological order.
285
292
  *
286
293
  * @param {string} threadId
287
294
  * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
@@ -302,17 +309,20 @@ export class Messaging {
302
309
  }
303
310
  __listMessages(threadId, requestOptions) {
304
311
  return __awaiter(this, void 0, void 0, function* () {
305
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
306
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
312
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
313
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
314
+ Authorization: yield this._getAuthorizationHeader(),
315
+ "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,
316
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
307
317
  const _response = yield core.fetcher({
308
- 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`),
318
+ 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`),
309
319
  method: "GET",
310
320
  headers: _headers,
311
321
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
312
- 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,
313
- 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,
322
+ 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,
323
+ 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,
314
324
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
315
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
325
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
316
326
  logging: this._options.logging,
317
327
  });
318
328
  if (_response.ok) {
@@ -381,17 +391,20 @@ export class Messaging {
381
391
  }
382
392
  __threadTrace(threadId, requestOptions) {
383
393
  return __awaiter(this, void 0, void 0, function* () {
384
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
385
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
394
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
395
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
396
+ Authorization: yield this._getAuthorizationHeader(),
397
+ "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,
398
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
386
399
  const _response = yield core.fetcher({
387
- 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`),
400
+ 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`),
388
401
  method: "GET",
389
402
  headers: _headers,
390
403
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
391
- 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,
392
- 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,
404
+ 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,
405
+ 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,
393
406
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
394
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
407
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
395
408
  logging: this._options.logging,
396
409
  });
397
410
  if (_response.ok) {
@@ -439,7 +452,7 @@ export class Messaging {
439
452
  });
440
453
  }
441
454
  /**
442
- * One interaction's trace, resolved directly by interaction id.
455
+ * The reasoning trace of a single interaction, resolved by its id.
443
456
  *
444
457
  * @param {string} interactionId
445
458
  * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
@@ -460,17 +473,20 @@ export class Messaging {
460
473
  }
461
474
  __interactionTrace(interactionId, requestOptions) {
462
475
  return __awaiter(this, void 0, void 0, function* () {
463
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
464
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
476
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
477
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
478
+ Authorization: yield this._getAuthorizationHeader(),
479
+ "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,
480
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
465
481
  const _response = yield core.fetcher({
466
- 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`),
482
+ 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`),
467
483
  method: "GET",
468
484
  headers: _headers,
469
485
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
470
- 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,
471
- 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,
486
+ 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,
487
+ 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,
472
488
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
473
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
489
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
474
490
  logging: this._options.logging,
475
491
  });
476
492
  if (_response.ok) {
@@ -517,4 +533,187 @@ export class Messaging {
517
533
  }
518
534
  });
519
535
  }
536
+ /**
537
+ * Generate suggested follow-up prompts from a context you provide —
538
+ * useful for offering the end user quick next questions.
539
+ *
540
+ * @param {Apollo.GenerateFollowupSuggestionsRequest} request
541
+ * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
542
+ *
543
+ * @throws {@link Apollo.BadRequestError}
544
+ * @throws {@link Apollo.UnauthorizedError}
545
+ * @throws {@link Apollo.ForbiddenError}
546
+ * @throws {@link Apollo.NotFoundError}
547
+ * @throws {@link Apollo.ConflictError}
548
+ * @throws {@link Apollo.UnprocessableEntityError}
549
+ * @throws {@link Apollo.InternalServerError}
550
+ *
551
+ * @example
552
+ * await client.messaging.generateFollowupSuggestions()
553
+ */
554
+ generateFollowupSuggestions(request = {}, requestOptions) {
555
+ return core.HttpResponsePromise.fromPromise(this.__generateFollowupSuggestions(request, requestOptions));
556
+ }
557
+ __generateFollowupSuggestions() {
558
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
559
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
560
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
561
+ Authorization: yield this._getAuthorizationHeader(),
562
+ "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,
563
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
564
+ const _response = yield core.fetcher({
565
+ 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"),
566
+ method: "POST",
567
+ headers: _headers,
568
+ contentType: "application/json",
569
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
570
+ requestType: "json",
571
+ body: request,
572
+ 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,
573
+ 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,
574
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
575
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
576
+ logging: this._options.logging,
577
+ });
578
+ if (_response.ok) {
579
+ return {
580
+ data: _response.body,
581
+ rawResponse: _response.rawResponse,
582
+ };
583
+ }
584
+ if (_response.error.reason === "status-code") {
585
+ switch (_response.error.statusCode) {
586
+ case 400:
587
+ throw new Apollo.BadRequestError(_response.error.body, _response.rawResponse);
588
+ case 401:
589
+ throw new Apollo.UnauthorizedError(_response.error.body, _response.rawResponse);
590
+ case 403:
591
+ throw new Apollo.ForbiddenError(_response.error.body, _response.rawResponse);
592
+ case 404:
593
+ throw new Apollo.NotFoundError(_response.error.body, _response.rawResponse);
594
+ case 409:
595
+ throw new Apollo.ConflictError(_response.error.body, _response.rawResponse);
596
+ case 422:
597
+ throw new Apollo.UnprocessableEntityError(_response.error.body, _response.rawResponse);
598
+ case 500:
599
+ throw new Apollo.InternalServerError(_response.error.body, _response.rawResponse);
600
+ default:
601
+ throw new errors.ApolloError({
602
+ statusCode: _response.error.statusCode,
603
+ body: _response.error.body,
604
+ rawResponse: _response.rawResponse,
605
+ });
606
+ }
607
+ }
608
+ switch (_response.error.reason) {
609
+ case "non-json":
610
+ throw new errors.ApolloError({
611
+ statusCode: _response.error.statusCode,
612
+ body: _response.error.rawBody,
613
+ rawResponse: _response.rawResponse,
614
+ });
615
+ case "timeout":
616
+ throw new errors.ApolloTimeoutError("Timeout exceeded when calling POST /messaging/v1/followup-suggestions.");
617
+ case "unknown":
618
+ throw new errors.ApolloError({
619
+ message: _response.error.errorMessage,
620
+ rawResponse: _response.rawResponse,
621
+ });
622
+ }
623
+ });
624
+ }
625
+ /**
626
+ * The welcome message of the agent's live version — what to show before
627
+ * the first user message.
628
+ *
629
+ * @param {Messaging.RequestOptions} requestOptions - Request-specific configuration.
630
+ *
631
+ * @throws {@link Apollo.BadRequestError}
632
+ * @throws {@link Apollo.UnauthorizedError}
633
+ * @throws {@link Apollo.ForbiddenError}
634
+ * @throws {@link Apollo.NotFoundError}
635
+ * @throws {@link Apollo.ConflictError}
636
+ * @throws {@link Apollo.UnprocessableEntityError}
637
+ * @throws {@link Apollo.InternalServerError}
638
+ *
639
+ * @example
640
+ * await client.messaging.getWelcomeMessage()
641
+ */
642
+ getWelcomeMessage(requestOptions) {
643
+ return core.HttpResponsePromise.fromPromise(this.__getWelcomeMessage(requestOptions));
644
+ }
645
+ __getWelcomeMessage(requestOptions) {
646
+ return __awaiter(this, void 0, void 0, function* () {
647
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
648
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
649
+ Authorization: yield this._getAuthorizationHeader(),
650
+ "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,
651
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
652
+ const _response = yield core.fetcher({
653
+ 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"),
654
+ method: "GET",
655
+ headers: _headers,
656
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
657
+ 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,
658
+ 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,
659
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
660
+ fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
661
+ logging: this._options.logging,
662
+ });
663
+ if (_response.ok) {
664
+ return {
665
+ data: _response.body,
666
+ rawResponse: _response.rawResponse,
667
+ };
668
+ }
669
+ if (_response.error.reason === "status-code") {
670
+ switch (_response.error.statusCode) {
671
+ case 400:
672
+ throw new Apollo.BadRequestError(_response.error.body, _response.rawResponse);
673
+ case 401:
674
+ throw new Apollo.UnauthorizedError(_response.error.body, _response.rawResponse);
675
+ case 403:
676
+ throw new Apollo.ForbiddenError(_response.error.body, _response.rawResponse);
677
+ case 404:
678
+ throw new Apollo.NotFoundError(_response.error.body, _response.rawResponse);
679
+ case 409:
680
+ throw new Apollo.ConflictError(_response.error.body, _response.rawResponse);
681
+ case 422:
682
+ throw new Apollo.UnprocessableEntityError(_response.error.body, _response.rawResponse);
683
+ case 500:
684
+ throw new Apollo.InternalServerError(_response.error.body, _response.rawResponse);
685
+ default:
686
+ throw new errors.ApolloError({
687
+ statusCode: _response.error.statusCode,
688
+ body: _response.error.body,
689
+ rawResponse: _response.rawResponse,
690
+ });
691
+ }
692
+ }
693
+ switch (_response.error.reason) {
694
+ case "non-json":
695
+ throw new errors.ApolloError({
696
+ statusCode: _response.error.statusCode,
697
+ body: _response.error.rawBody,
698
+ rawResponse: _response.rawResponse,
699
+ });
700
+ case "timeout":
701
+ throw new errors.ApolloTimeoutError("Timeout exceeded when calling GET /messaging/v1/welcome-message.");
702
+ case "unknown":
703
+ throw new errors.ApolloError({
704
+ message: _response.error.errorMessage,
705
+ rawResponse: _response.rawResponse,
706
+ });
707
+ }
708
+ });
709
+ }
710
+ _getAuthorizationHeader() {
711
+ return __awaiter(this, void 0, void 0, function* () {
712
+ const bearer = yield core.Supplier.get(this._options.token);
713
+ if (bearer != null) {
714
+ return `Bearer ${bearer}`;
715
+ }
716
+ return undefined;
717
+ });
718
+ }
520
719
  }
@@ -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.mjs";
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.mjs";
1
2
  export type { RerunMessageRequest } from "./RerunMessageRequest.mjs";
2
3
  export type { StreamMessageRequest } from "./StreamMessageRequest.mjs";