@stack-spot/portal-network 1.0.0-betaadp.3 → 1.0.0-dev.1768423147036

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 (220) hide show
  1. package/CHANGELOG.md +633 -0
  2. package/dist/api/account.d.ts +413 -277
  3. package/dist/api/account.d.ts.map +1 -1
  4. package/dist/api/account.js +261 -176
  5. package/dist/api/account.js.map +1 -1
  6. package/dist/api/accountAssetManager.d.ts +309 -0
  7. package/dist/api/accountAssetManager.d.ts.map +1 -0
  8. package/dist/api/accountAssetManager.js +169 -0
  9. package/dist/api/accountAssetManager.js.map +1 -0
  10. package/dist/api/agent-tools.d.ts +818 -261
  11. package/dist/api/agent-tools.d.ts.map +1 -1
  12. package/dist/api/agent-tools.js +245 -50
  13. package/dist/api/agent-tools.js.map +1 -1
  14. package/dist/api/agent.d.ts +55 -55
  15. package/dist/api/agent.d.ts.map +1 -1
  16. package/dist/api/ai.d.ts +488 -98
  17. package/dist/api/ai.d.ts.map +1 -1
  18. package/dist/api/ai.js +426 -146
  19. package/dist/api/ai.js.map +1 -1
  20. package/dist/api/cloudPlatform.d.ts +374 -221
  21. package/dist/api/cloudPlatform.d.ts.map +1 -1
  22. package/dist/api/cloudPlatform.js +299 -93
  23. package/dist/api/cloudPlatform.js.map +1 -1
  24. package/dist/api/cloudPlatformHorizon.d.ts +178 -9
  25. package/dist/api/cloudPlatformHorizon.d.ts.map +1 -1
  26. package/dist/api/cloudPlatformHorizon.js +69 -1
  27. package/dist/api/cloudPlatformHorizon.js.map +1 -1
  28. package/dist/api/codeShift.d.ts +1125 -83
  29. package/dist/api/codeShift.d.ts.map +1 -1
  30. package/dist/api/codeShift.js +538 -16
  31. package/dist/api/codeShift.js.map +1 -1
  32. package/dist/api/dataIntegration.d.ts +291 -1
  33. package/dist/api/dataIntegration.d.ts.map +1 -1
  34. package/dist/api/dataIntegration.js +254 -0
  35. package/dist/api/dataIntegration.js.map +1 -1
  36. package/dist/api/discover.d.ts +98 -12
  37. package/dist/api/discover.d.ts.map +1 -1
  38. package/dist/api/discover.js +78 -2
  39. package/dist/api/discover.js.map +1 -1
  40. package/dist/api/edpBfa.d.ts +215 -0
  41. package/dist/api/edpBfa.d.ts.map +1 -0
  42. package/dist/api/edpBfa.js +87 -0
  43. package/dist/api/edpBfa.js.map +1 -0
  44. package/dist/api/genAiInference.d.ts +22 -2
  45. package/dist/api/genAiInference.d.ts.map +1 -1
  46. package/dist/api/genAiInference.js +22 -3
  47. package/dist/api/genAiInference.js.map +1 -1
  48. package/dist/api/workflows.d.ts +68 -5
  49. package/dist/api/workflows.d.ts.map +1 -1
  50. package/dist/api/workflows.js +16 -0
  51. package/dist/api/workflows.js.map +1 -1
  52. package/dist/api/workspace-ai.d.ts +41 -0
  53. package/dist/api/workspace-ai.d.ts.map +1 -1
  54. package/dist/api/workspace-ai.js +34 -0
  55. package/dist/api/workspace-ai.js.map +1 -1
  56. package/dist/api/workspaceManager.d.ts +16 -10
  57. package/dist/api/workspaceManager.d.ts.map +1 -1
  58. package/dist/api/workspaceManager.js +10 -0
  59. package/dist/api/workspaceManager.js.map +1 -1
  60. package/dist/api-addresses.d.ts +20 -18
  61. package/dist/api-addresses.d.ts.map +1 -1
  62. package/dist/api-addresses.js +81 -21
  63. package/dist/api-addresses.js.map +1 -1
  64. package/dist/apis-itau.json +241 -0
  65. package/dist/apis.json +17 -1
  66. package/dist/client/account-asset-manager.d.ts +112 -0
  67. package/dist/client/account-asset-manager.d.ts.map +1 -0
  68. package/dist/client/account-asset-manager.js +160 -0
  69. package/dist/client/account-asset-manager.js.map +1 -0
  70. package/dist/client/account.d.ts +265 -242
  71. package/dist/client/account.d.ts.map +1 -1
  72. package/dist/client/account.js +80 -34
  73. package/dist/client/account.js.map +1 -1
  74. package/dist/client/agent-tools.d.ts +295 -121
  75. package/dist/client/agent-tools.d.ts.map +1 -1
  76. package/dist/client/agent-tools.js +166 -12
  77. package/dist/client/agent-tools.js.map +1 -1
  78. package/dist/client/agent.d.ts +46 -46
  79. package/dist/client/agent.d.ts.map +1 -1
  80. package/dist/client/ai.d.ts +265 -79
  81. package/dist/client/ai.d.ts.map +1 -1
  82. package/dist/client/ai.js +268 -24
  83. package/dist/client/ai.js.map +1 -1
  84. package/dist/client/api-management.d.ts +10 -1
  85. package/dist/client/api-management.d.ts.map +1 -1
  86. package/dist/client/api-management.js +11 -2
  87. package/dist/client/api-management.js.map +1 -1
  88. package/dist/client/cloud-account.d.ts +13 -13
  89. package/dist/client/cloud-platform-horizon.d.ts +38 -19
  90. package/dist/client/cloud-platform-horizon.d.ts.map +1 -1
  91. package/dist/client/cloud-platform-horizon.js +19 -1
  92. package/dist/client/cloud-platform-horizon.js.map +1 -1
  93. package/dist/client/cloud-platform.d.ts +213 -46
  94. package/dist/client/cloud-platform.d.ts.map +1 -1
  95. package/dist/client/cloud-platform.js +168 -33
  96. package/dist/client/cloud-platform.js.map +1 -1
  97. package/dist/client/cloud-runtimes.d.ts +4 -4
  98. package/dist/client/cloud-services.d.ts +17 -17
  99. package/dist/client/cloud-services.d.ts.map +1 -1
  100. package/dist/client/code-shift.d.ts +535 -162
  101. package/dist/client/code-shift.d.ts.map +1 -1
  102. package/dist/client/code-shift.js +296 -7
  103. package/dist/client/code-shift.js.map +1 -1
  104. package/dist/client/content.d.ts +127 -132
  105. package/dist/client/content.d.ts.map +1 -1
  106. package/dist/client/data-integration.d.ts +92 -53
  107. package/dist/client/data-integration.d.ts.map +1 -1
  108. package/dist/client/data-integration.js +38 -2
  109. package/dist/client/data-integration.js.map +1 -1
  110. package/dist/client/discover.d.ts +31 -10
  111. package/dist/client/discover.d.ts.map +1 -1
  112. package/dist/client/discover.js +239 -3
  113. package/dist/client/discover.js.map +1 -1
  114. package/dist/client/edp-bfa.d.ts +16 -0
  115. package/dist/client/edp-bfa.d.ts.map +1 -0
  116. package/dist/client/edp-bfa.js +24 -0
  117. package/dist/client/edp-bfa.js.map +1 -0
  118. package/dist/client/event-bus.d.ts.map +1 -1
  119. package/dist/client/gen-ai-inference.d.ts +20 -20
  120. package/dist/client/insights.d.ts +7 -7
  121. package/dist/client/notification.d.ts +17 -10
  122. package/dist/client/notification.d.ts.map +1 -1
  123. package/dist/client/notification.js +10 -1
  124. package/dist/client/notification.js.map +1 -1
  125. package/dist/client/runtime-manager.d.ts +8 -8
  126. package/dist/client/secrets.d.ts.map +1 -1
  127. package/dist/client/secrets.js +1 -1
  128. package/dist/client/secrets.js.map +1 -1
  129. package/dist/client/types.d.ts +50 -7
  130. package/dist/client/types.d.ts.map +1 -1
  131. package/dist/client/workflow.d.ts +10 -10
  132. package/dist/client/workspace-ai.d.ts +65 -55
  133. package/dist/client/workspace-ai.d.ts.map +1 -1
  134. package/dist/client/workspace-ai.js +19 -9
  135. package/dist/client/workspace-ai.js.map +1 -1
  136. package/dist/client/workspace-manager.d.ts +115 -76
  137. package/dist/client/workspace-manager.d.ts.map +1 -1
  138. package/dist/client/workspace-manager.js +47 -2
  139. package/dist/client/workspace-manager.js.map +1 -1
  140. package/dist/client/workspace-search.d.ts +2 -2
  141. package/dist/client/workspace.d.ts +58 -105
  142. package/dist/client/workspace.d.ts.map +1 -1
  143. package/dist/error/DefaultAPIError.d.ts.map +1 -1
  144. package/dist/error/DefaultAPIError.js.map +1 -1
  145. package/dist/error/StackspotAPIError.d.ts +3 -4
  146. package/dist/error/StackspotAPIError.d.ts.map +1 -1
  147. package/dist/error/StackspotAPIError.js +3 -3
  148. package/dist/error/StackspotAPIError.js.map +1 -1
  149. package/dist/error/dictionary/accountAssetManager.d.ts +11 -0
  150. package/dist/error/dictionary/accountAssetManager.d.ts.map +1 -0
  151. package/dist/error/dictionary/accountAssetManager.js +11 -0
  152. package/dist/error/dictionary/accountAssetManager.js.map +1 -0
  153. package/dist/error/dictionary/cloud-platform.d.ts +76 -8
  154. package/dist/error/dictionary/cloud-platform.d.ts.map +1 -1
  155. package/dist/error/dictionary/cloud-platform.js +80 -12
  156. package/dist/error/dictionary/cloud-platform.js.map +1 -1
  157. package/dist/error/dictionary/workspace-ai.d.ts +9 -0
  158. package/dist/error/dictionary/workspace-ai.d.ts.map +1 -0
  159. package/dist/error/dictionary/workspace-ai.js +9 -0
  160. package/dist/error/dictionary/workspace-ai.js.map +1 -0
  161. package/dist/index.d.ts +5 -3
  162. package/dist/index.d.ts.map +1 -1
  163. package/dist/index.js +4 -2
  164. package/dist/index.js.map +1 -1
  165. package/dist/network/NetworkClient.d.ts +4 -2
  166. package/dist/network/NetworkClient.d.ts.map +1 -1
  167. package/dist/network/NetworkClient.js +16 -4
  168. package/dist/network/NetworkClient.js.map +1 -1
  169. package/dist/network/types.d.ts +2 -0
  170. package/dist/network/types.d.ts.map +1 -1
  171. package/dist/utils/StreamedJson.d.ts +3 -1
  172. package/dist/utils/StreamedJson.d.ts.map +1 -1
  173. package/dist/utils/StreamedJson.js +23 -3
  174. package/dist/utils/StreamedJson.js.map +1 -1
  175. package/package.dev.json +3 -0
  176. package/package.json +10 -9
  177. package/package.stg.json +3 -0
  178. package/readme.md +40 -1
  179. package/src/api/account.ts +701 -540
  180. package/src/api/accountAssetManager.ts +771 -0
  181. package/src/api/agent-tools.ts +1354 -556
  182. package/src/api/ai.ts +891 -170
  183. package/src/api/cloudPlatform.ts +667 -298
  184. package/src/api/cloudPlatformHorizon.ts +412 -9
  185. package/src/api/codeShift.ts +2088 -97
  186. package/src/api/dataIntegration.ts +635 -1
  187. package/src/api/discover.ts +180 -14
  188. package/src/api/edpBfa.ts +472 -0
  189. package/src/api/genAiInference.ts +47 -4
  190. package/src/api/workflows.ts +100 -5
  191. package/src/api/workspace-ai.ts +83 -0
  192. package/src/api/workspaceManager.ts +25 -10
  193. package/src/api-addresses.ts +113 -38
  194. package/src/apis-itau.json +241 -0
  195. package/src/apis.json +17 -1
  196. package/src/client/account-asset-manager.ts +100 -0
  197. package/src/client/account.ts +71 -40
  198. package/src/client/agent-tools.ts +111 -18
  199. package/src/client/ai.ts +237 -24
  200. package/src/client/api-management.ts +7 -2
  201. package/src/client/cloud-platform-horizon.ts +12 -4
  202. package/src/client/cloud-platform.ts +101 -27
  203. package/src/client/code-shift.ts +196 -8
  204. package/src/client/data-integration.ts +28 -1
  205. package/src/client/discover.ts +238 -5
  206. package/src/client/edp-bfa.ts +24 -0
  207. package/src/client/notification.ts +6 -1
  208. package/src/client/secrets.ts +1 -1
  209. package/src/client/types.ts +55 -9
  210. package/src/client/workspace-ai.ts +37 -26
  211. package/src/client/workspace-manager.ts +31 -2
  212. package/src/error/DefaultAPIError.ts +5 -5
  213. package/src/error/StackspotAPIError.ts +4 -4
  214. package/src/error/dictionary/accountAssetManager.ts +12 -0
  215. package/src/error/dictionary/cloud-platform.ts +80 -12
  216. package/src/error/dictionary/workspace-ai.ts +10 -0
  217. package/src/index.ts +6 -3
  218. package/src/network/NetworkClient.ts +18 -6
  219. package/src/network/types.ts +3 -0
  220. package/src/utils/StreamedJson.tsx +19 -4
package/src/client/ai.ts CHANGED
@@ -7,26 +7,33 @@ import {
7
7
  calculateNextStepV1QuickCommandsSlugStepsStepSlugCalculateNextStepPost,
8
8
  callbackV1QuickCommandsCallbackExecutionIdGet,
9
9
  conversationHistoryV1ConversationsConversationIdGet,
10
+ createAnswerForReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersPost,
10
11
  createExecutionV1QuickCommandsCreateExecutionSlugPost,
12
+ createResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsPost,
11
13
  currentV1TokensUsageCurrentGet,
12
- currentV1TokensUsageTotalGet,
13
14
  defaults,
14
15
  deleteConversationV1ConversationsConversationIdDelete,
15
16
  deleteFavoriteV1AiStacksStackIdFavoriteDelete,
16
17
  deleteFavoriteV1QuickCommandsSlugFavoriteDelete,
17
18
  deleteKnowledgeObjectByCustomIdV1KnowledgeSourcesSlugObjectsCustomIdDelete,
19
+ deleteResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdDelete,
20
+ deleteReviewCommentV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersAnswerIdDelete,
18
21
  downloadConversationV1ConversationsConversationIdDownloadGet,
19
22
  findKnowledgeObjectByCustomIdV1KnowledgeSourcesSlugObjectsCustomIdGet,
20
23
  findKnowledgeSourceV1KnowledgeSourcesSlugGet,
21
24
  formatFetchStepV1QuickCommandsSlugStepsStepSlugFetchFormatPost,
22
25
  formatResultV1QuickCommandsSlugResultFormatPost,
23
26
  getContentDependenciesV1ContentContentTypeContentIdDependenciesGet,
27
+ getFlagsV1FlagsGet,
24
28
  getQuickCommandV1QuickCommandsSlugGet,
29
+ getReviewsByResourceV1ResourcesResourceTypeSlugResourceSlugReviewsGet,
30
+ getScriptExecutionStatusV1QuickCommandsScriptExecutionsScriptExecutionIdGet,
25
31
  getUploadFormV1FileUploadFormPost,
26
32
  HttpValidationError,
27
33
  listAiStacksV1AiStacksGet,
28
34
  listAllV1QuickCommandsAllGet,
29
35
  listAllV2QuickCommandsAllGet,
36
+ listAllV3QuickCommandsGet,
30
37
  listAssociationV1WorkspaceWorkspaceIdGet,
31
38
  listConversationsV1ConversationsGet,
32
39
  listKnowledgeSourcesV1KnowledgeSourcesGet,
@@ -38,10 +45,18 @@ import {
38
45
  resetKnowledgeObjectsV1KnowledgeSourcesSlugObjectsDelete,
39
46
  runFetchStepV1QuickCommandsSlugStepsStepSlugFetchRunPost,
40
47
  searchKnowledgeSourcesV1KnowledgeSourcesSearchPost,
48
+ startScriptStepV1QuickCommandsSlugStepsStepSlugStartScriptPost,
49
+ tokensByUserV1AnalyticsTokensByUserGet,
50
+ tokensDailyUsageV1AnalyticsTokensDailyUsageGet,
51
+ totalV1TokensUsageTotalGet,
41
52
  updateQuickCommandV1QuickCommandsSlugPatch,
53
+ updateResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdPatch,
54
+ updateReviewCommentV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersAnswerIdPatch,
42
55
  updateTitleV1ConversationsConversationIdPatch,
43
56
  vectorizeCustomKnowledgeSourceV1KnowledgeSourcesSlugCustomPost,
44
57
  } from '../api/ai'
58
+
59
+
45
60
  import { StackspotAPIError } from '../error/StackspotAPIError'
46
61
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
47
62
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
@@ -49,6 +64,7 @@ import { StreamedJson } from '../utils/StreamedJson'
49
64
  import { formatJson } from '../utils/string'
50
65
  import { agentToolsClient } from './agent-tools'
51
66
  import {
67
+ AgentInfo,
52
68
  ChatAgentTool,
53
69
  ChatResponseWithSteps,
54
70
  FixedChatRequest,
@@ -59,6 +75,8 @@ import {
59
75
  StepChatStep,
60
76
  } from './types'
61
77
 
78
+ const listQAV3WithoutAuthorization = removeAuthorizationParam(listAllV3QuickCommandsGet)
79
+
62
80
  class AIClient extends ReactQueryNetworkClient {
63
81
  constructor() {
64
82
  super(getApiAddresses().ai.url, defaults)
@@ -106,7 +124,7 @@ class AIClient extends ReactQueryNetworkClient {
106
124
  /**
107
125
  * Gets total tokens usage
108
126
  */
109
- totalTokensUsage = this.query(removeAuthorizationParam(currentV1TokensUsageTotalGet))
127
+ totalTokensUsage = this.query(removeAuthorizationParam(totalV1TokensUsageTotalGet))
110
128
  /**
111
129
  * Gets current tokens usage
112
130
  */
@@ -124,6 +142,10 @@ class AIClient extends ReactQueryNetworkClient {
124
142
  * Lists all the quick commands according to filters passed as parameter (including QC with secrets).
125
143
  */
126
144
  allQuickCommands = this.query(removeAuthorizationParam(listAllV2QuickCommandsAllGet))
145
+ /**
146
+ * Lists all the quick commands according to filters passed as parameter (including QC with secrets) with pagination.
147
+ */
148
+ allQuickCommandsV3 = this.infiniteQuery(listQAV3WithoutAuthorization, { accumulator: 'items' })
127
149
  /**
128
150
  * Gets a quick command by its slug.
129
151
  */
@@ -257,15 +279,79 @@ class AIClient extends ReactQueryNetworkClient {
257
279
  * Removes the resource of type Quick Command from the list of favorites.
258
280
  */
259
281
  removeFavoriteQuickCommand = this.mutation(removeAuthorizationParam(deleteFavoriteV1QuickCommandsSlugFavoriteDelete))
282
+ /**
283
+ * Get Tokens Daily usage
284
+ */
285
+ analyticsTokensDailyUsage = this.query(removeAuthorizationParam(tokensDailyUsageV1AnalyticsTokensDailyUsageGet))
286
+ /**
287
+ * Get Tokens By User
288
+ */
289
+ analyticsTokensByUser = this.query(removeAuthorizationParam(tokensByUserV1AnalyticsTokensByUserGet))
290
+ /*
291
+ * Lists all the feature flags for this user.
292
+ */
293
+ flags = this.query(getFlagsV1FlagsGet)
294
+ /**
295
+ * Starts the execution of a script step
296
+ */
297
+ startScriptStep = this.mutation(removeAuthorizationParam(startScriptStepV1QuickCommandsSlugStepsStepSlugStartScriptPost))
298
+ /**
299
+ * Gets the status of the execution of a script step
300
+ */
301
+ getStatusScriptStep = this.query(removeAuthorizationParam(getScriptExecutionStatusV1QuickCommandsScriptExecutionsScriptExecutionIdGet))
302
+
303
+ /**
304
+ * Get reviews by resource
305
+ */
306
+ getReviewsByResource = this.query(removeAuthorizationParam(getReviewsByResourceV1ResourcesResourceTypeSlugResourceSlugReviewsGet))
307
+
308
+ /**
309
+ * Create a resource review
310
+ */
311
+ createResourceReview = this.mutation(removeAuthorizationParam(createResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsPost))
312
+
313
+ /**
314
+ * Create an answer for a review
315
+ */
316
+ createAnswerForReview = this.mutation(
317
+ removeAuthorizationParam(createAnswerForReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersPost))
318
+
319
+ /**
320
+ * Update a resource review
321
+ */
322
+ updateResourceReview = this.mutation(
323
+ removeAuthorizationParam(updateResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdPatch))
324
+
325
+ /**
326
+ * Delete a resource review
327
+ */
328
+ deleteResourceReview = this.mutation(
329
+ removeAuthorizationParam(deleteResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdDelete))
330
+
331
+ /**
332
+ * Update a review comment (answer)
333
+ */
334
+ updateReviewComment = this.mutation(
335
+ removeAuthorizationParam(updateReviewCommentV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersAnswerIdPatch))
260
336
 
261
- private static async toolsOfAgent(agentId?: string) {
337
+ /**
338
+ * Delete a review comment (answer)
339
+ */
340
+ deleteReviewComment = this.mutation(
341
+ removeAuthorizationParam(deleteReviewCommentV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersAnswerIdDelete))
342
+
343
+ private static async toolsOfAgent(agentId?: string, agent_version_number?: number) {
262
344
  try {
263
- const agent = agentId ? await agentToolsClient.agent.query({ agentId }) : undefined
345
+ const agent = agentId ? await agentToolsClient.agentV2.query({
346
+ agentCoreId: agentId, versionNumber: agent_version_number }) : undefined
264
347
  if (!agent) return []
265
348
  const tools: (Omit<ChatAgentTool, 'duration' | 'prompt' | 'output'>)[] = []
266
- agent.toolkits?.builtin_toolkits?.forEach(kit => kit.tools?.forEach(({ id, name, description }) => {
349
+ agent.version?.toolkits?.builtin_toolkits?.forEach(kit => kit.tools?.forEach(({ id, name, description }) => {
267
350
  if (id) tools.push({ image: kit.image_url, id, name: name || id, description })
268
351
  }))
352
+ agent.version?.toolkits?.custom_toolkits?.forEach(kit => kit.tools?.forEach(({ id, name, description }) => {
353
+ if (id) tools.push({ image: kit.avatar ?? undefined, id, name: name || id, description })
354
+ }))
269
355
  return tools
270
356
  } catch {
271
357
  return []
@@ -283,6 +369,10 @@ class AIClient extends ReactQueryNetworkClient {
283
369
  { method: 'post', body: JSON.stringify(request), headers, signal: abortController.signal },
284
370
  )
285
371
 
372
+ const DYNAMIC_TOOL_ID = 'dynamic'
373
+ function isDynamicTool(info: AgentInfo) {
374
+ return info.type === 'tool' && info.id === DYNAMIC_TOOL_ID
375
+ }
286
376
  /**
287
377
  * This function treats events in the streaming that deals with the execution of tools. Since these events are not concatenated like
288
378
  * normal streamings of data, we need this separate function to deal with them. It transforms the internal data model of the
@@ -291,9 +381,9 @@ class AIClient extends ReactQueryNetworkClient {
291
381
  async function transform(event: Partial<FixedChatResponse>, data: Partial<ChatResponseWithSteps>) {
292
382
  const info = event.agent_info
293
383
  if (!info) return
294
- const tools = await AIClient.toolsOfAgent(request.context?.agent_id)
384
+ const tools = await AIClient.toolsOfAgent(request.context?.agent_id, request.agent_version_number ?? undefined)
295
385
  data.steps = data.steps ? [...data.steps] : []
296
-
386
+
297
387
  if (info.type === 'planning' && info.action === 'end') {
298
388
  data.steps.push({
299
389
  id: 'planning',
@@ -303,6 +393,33 @@ class AIClient extends ReactQueryNetworkClient {
303
393
  steps: info.data?.steps?.map(s => s.goal) ?? [],
304
394
  goal: info.data?.plan_goal ?? '',
305
395
  })
396
+
397
+ info.data?.steps.forEach(s => data.steps?.push({
398
+ id: s.id,
399
+ type: 'step',
400
+ status: 'pending',
401
+ input: s.goal,
402
+ attempts: [{
403
+ tools: s.tools?.map(t => ({
404
+ ...(tools.find(({ id }) => id === t.tool_id) ?? { id: t.tool_id, name: t.tool_id }),
405
+ executionId: t.tool_execution_id,
406
+ goal: t.goal,
407
+ })),
408
+ }],
409
+ }))
410
+ data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
411
+ }
412
+
413
+ if (info.type === 'planning' && info.action === 'awaiting_approval') {
414
+ data.steps.push({
415
+ id: 'planning',
416
+ type: 'planning',
417
+ status: 'awaiting_approval',
418
+ user_question: info.data?.user_question,
419
+ duration: info.duration || 0,
420
+ steps: info.data?.steps?.map(s => s.goal) ?? [],
421
+ goal: info.data?.plan_goal ?? '',
422
+ })
306
423
  info.data?.steps.forEach(s => data.steps?.push({
307
424
  id: s.id,
308
425
  type: 'step',
@@ -312,6 +429,7 @@ class AIClient extends ReactQueryNetworkClient {
312
429
  tools: s.tools?.map(t => ({
313
430
  ...(tools.find(({ id }) => id === t.tool_id) ?? { id: t.tool_id, name: t.tool_id }),
314
431
  executionId: t.tool_execution_id,
432
+ goal: t.goal,
315
433
  })),
316
434
  }],
317
435
  }))
@@ -334,30 +452,121 @@ class AIClient extends ReactQueryNetworkClient {
334
452
  }
335
453
  }
336
454
 
455
+ if (info.type === 'tool_calls' && info.action === 'start') {
456
+ const hasPlanning = data.steps.find(s => s.type === 'planning')
457
+ // On the first tool_calls:start, create the synthetic planning ("dynamic") step.
458
+ if (!hasPlanning) {
459
+ const userPrompt = request.user_prompt === 'string' ? request.user_prompt : JSON.stringify(request.user_prompt)
460
+ data.steps.push({
461
+ id: 'dynamic',
462
+ type: 'planning',
463
+ status: 'success',
464
+ steps: [],
465
+ goal: userPrompt,
466
+ user_question: userPrompt,
467
+ })
468
+ }
469
+ const toolsStepId = data.steps.filter(s => s.id === 'tools' || s.id.startsWith('tools-')).length + 1
470
+ data.steps.push({
471
+ id: `tools-${toolsStepId.toString()}`,
472
+ type: 'step',
473
+ status: 'running',
474
+ attempts: [{ tools: [] }],
475
+ } as StepChatStep)
476
+ }
477
+
478
+ if (info.type === 'tool_calls' && info.action === 'end') {
479
+ const lastStep = findLast(data.steps, s => s.id === 'tools' || s.id.startsWith('tools-')) as StepChatStep
480
+ if (lastStep) {
481
+ lastStep.status = 'success'
482
+ lastStep.duration = info.duration
483
+ const lastAttemptOfLastTool = last(lastStep.attempts.map(a => a.tools).flat())
484
+ lastStep.output = lastAttemptOfLastTool?.output
485
+ }
486
+ }
487
+
488
+ if (info.type === 'tool' && info.action === 'awaiting_approval') {
489
+ const tool = tools.find(({ id }) => id === info.data?.tool_id)
490
+ data.steps.push({
491
+ id: info.id,
492
+ type: 'tool',
493
+ status: 'awaiting_approval',
494
+ duration: info.duration || 0,
495
+ input: info.data?.input,
496
+ user_question: info.data?.user_question,
497
+ attempts: [{
498
+ tools: [{
499
+ executionId: info.id,
500
+ id: info.data?.tool_id ?? '',
501
+ name: tool?.name ?? '',
502
+ goal: tool?.goal,
503
+ ...tool,
504
+ }],
505
+ }],
506
+ })
507
+ data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
508
+ }
509
+
337
510
  if (info.type === 'tool' && info.action === 'start') {
338
- const currentStep = data.steps.find(s => s.status === 'running') as StepChatStep
339
- if (!currentStep || !info.data || !currentStep.attempts[0].tools) return
340
- const toolInFirstAttempt = currentStep.attempts[0].tools.find(t => t.executionId === info.id)
341
- if (!toolInFirstAttempt) return
511
+ if (!info.data) return
342
512
  const input = formatJson(info.data.input)
343
- if (info.data.attempt === 0) {
344
- toolInFirstAttempt.input = input
345
- } else {
346
- currentStep.attempts[info.data.attempt] ??= { tools: [] }
347
- currentStep.attempts[info.data.attempt].tools?.push({
348
- ...toolInFirstAttempt,
349
- input,
513
+ const tool = findLast(tools, ({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
514
+
515
+ const currentStep = findLast(data.steps, s => s.status === 'running') as StepChatStep
516
+
517
+ //There might be a tool with status awaiting_approval, so we want to inform tool has already started
518
+ if (!currentStep || !currentStep?.attempts?.[0]?.tools) {
519
+ data.steps.push({
520
+ id: info.id,
521
+ type: 'tool',
522
+ status: 'running',
523
+ duration: info.duration || 0,
524
+ input: info.data?.input,
525
+ user_question: info.data?.user_question,
526
+ attempts: [{
527
+ tools: [{ ...tool, executionId: info.id, input }],
528
+ }],
350
529
  })
530
+ } else {
531
+ const toolInFirstAttempt = findLast(currentStep?.attempts?.[0]?.tools, t => t.executionId === info.id)
532
+ //One step might have multiple tools. When in an approval mode, we might not have all the tools in the array yet.
533
+ //For dynamic tools (id === 'dynamic'), we always push a new tool, since dynamic executions can trigger
534
+ //multiple tool runs in the same step and do not follow the planned tool structure.
535
+ //So we make sure to add any tools that are not in there, or always add for dynamic tools.
536
+ if (!toolInFirstAttempt || isDynamicTool(info)) {
537
+ currentStep.attempts?.[0].tools?.push({
538
+ ...tool,
539
+ executionId: info.id,
540
+ input,
541
+ status: 'running',
542
+ })
543
+ } else {
544
+ const input = formatJson(info.data.input)
545
+ if (info.data.attempt === 1) {
546
+ toolInFirstAttempt.input = input
547
+ } else {
548
+ currentStep.attempts[info.data.attempt - 1] ??= { tools: [] }
549
+ currentStep.attempts[info.data.attempt - 1].tools?.push({
550
+ ...tool,
551
+ executionId: info.id,
552
+ input,
553
+ })
554
+ }
555
+ }
351
556
  }
352
557
  }
353
558
 
354
559
  if (info.type === 'tool' && info.action === 'end') {
355
560
  const currentStep = data.steps.find(s => s.status === 'running') as StepChatStep
356
561
  if (!currentStep || !info.data) return
357
- const tool = currentStep.attempts[info.data.attempt]?.tools?.find(t => t.executionId === info.id)
562
+
563
+ // attempt index for tool execution starts at 0 for dynamically executed tools,while for planned tools it starts at 1
564
+ const attempt = isDynamicTool(info) ? info.data.attempt : info.data.attempt - 1
565
+ const tool = last(currentStep?.attempts?.[attempt]?.tools)
358
566
  if (tool) {
359
567
  tool.output = formatJson(info.data.output)
360
568
  tool.duration = info.duration
569
+ tool.status = 'success'
361
570
  }
362
571
  }
363
572
 
@@ -366,11 +575,14 @@ class AIClient extends ReactQueryNetworkClient {
366
575
  if (answerStep) answerStep.status = 'running'
367
576
  }
368
577
 
369
- if (info.type === 'final_answer' && info.action === 'end') {
370
- const answerStep = last(data.steps)
371
- if (answerStep) {
372
- answerStep.status = 'success'
373
- answerStep.duration = info.duration
578
+
579
+ if (info.type === 'chat' && info.action === 'end') {
580
+ const lastStep = last(data.steps)
581
+ if (lastStep?.type === 'answer') {
582
+ lastStep.status = 'success'
583
+ lastStep.duration = info.duration
584
+ } else {
585
+ data.steps.push({ id: 'answer', type: 'answer', status: 'success' })
374
586
  }
375
587
  }
376
588
  }
@@ -381,6 +593,7 @@ class AIClient extends ReactQueryNetworkClient {
381
593
  minChangeIntervalMS,
382
594
  ignoreKeys: ['agent_info'],
383
595
  transform,
596
+ textFromErrorEvent: data => data.answer ?? 'Unknown error',
384
597
  })
385
598
  }
386
599
 
@@ -1,10 +1,10 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import { defaults, getEntries, getEntryById, getSubEntries } from '../api/apiManagement'
2
+ import { getApiAddresses } from '../api-addresses'
3
+ import { defaults, downloadObjectArtifacts, getEntries, getEntryById, getSubEntries } from '../api/apiManagement'
3
4
  import { DefaultAPIError } from '../error/DefaultAPIError'
4
5
  import { actionDictionary } from '../error/dictionary/action'
5
6
  import { StackspotAPIError } from '../error/StackspotAPIError'
6
7
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
7
- import { getApiAddresses } from '../api-addresses'
8
8
 
9
9
  class ApiManagementClient extends ReactQueryNetworkClient {
10
10
  constructor() {
@@ -30,6 +30,11 @@ class ApiManagementClient extends ReactQueryNetworkClient {
30
30
  */
31
31
  getApiVersions = this.query(getSubEntries)
32
32
 
33
+ /**
34
+ * Gets the openAPI of one version
35
+ */
36
+ getApiVersionDocs = this.query(downloadObjectArtifacts)
37
+
33
38
  }
34
39
 
35
40
  export const apiManagementClient = new ApiManagementClient()
@@ -4,7 +4,7 @@ import { DefaultAPIError } from '../error/DefaultAPIError'
4
4
  import { StackspotAPIError } from '../error/StackspotAPIError'
5
5
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
6
6
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
7
- import { associateWithWorkspaceEnvironment, createAddon, createDeployTemplate, createOrganization, createRuntime1, createTenant1, defaults, deploy, findApplicationDeploymentById, getApplicationDeploymentHealth, getApplicationDeploymentLogs, getAssociationWorkspaceEnvironmentByRuntimeId, getOrganizationById, getOrganizations, getRuntime1, getTenant1, listAddon, listApplicationDeployments, listAssociations, listDeployTemplate, listRuntimes, listRuntimes1, listTenants, listTenants1 } from '../api/cloudPlatformHorizon'
7
+ import { associateWithWorkspaceEnvironment, createAddon, createDeployTemplate, createOrganization, createRuntime1, createTenant1, defaults, deploy, findApplicationDeploymentById, getApplicationDeploymentHealth, getApplicationDeploymentLogs, getAssociationWorkspaceEnvironmentByRuntimeId, getOrganizationById, getOrganizations, getRuntime1, getTenant1, listAddon, listApplicationDeploymentRollouts, listApplicationDeployments, listAssociations, listDeployTemplate, listRuntimes, listRuntimes1, listTenants, listTenants1, postApplicationDeploymentRolloutAction } from '../api/cloudPlatformHorizon'
8
8
  import { baseDictionary } from '../error/dictionary/base'
9
9
  import { getApiAddresses } from '../api-addresses'
10
10
 
@@ -19,7 +19,7 @@ class CloudPlatformHorizonClient extends ReactQueryNetworkClient {
19
19
  /**
20
20
  * Get a list of organizations
21
21
  */
22
- listOrganizations= this.query(removeAuthorizationParam(getOrganizations))
22
+ listOrganizations = this.query(removeAuthorizationParam(getOrganizations))
23
23
  /**
24
24
  * Get organization by id
25
25
  */
@@ -27,11 +27,11 @@ class CloudPlatformHorizonClient extends ReactQueryNetworkClient {
27
27
  /**
28
28
  * Get details of an tenant
29
29
  */
30
- getTenantById= this.query(removeAuthorizationParam(getTenant1))
30
+ getTenantById = this.query(removeAuthorizationParam(getTenant1))
31
31
  /**
32
32
  * Get details of an runtime
33
33
  */
34
- getRuntimeById= this.query(removeAuthorizationParam(getRuntime1))
34
+ getRuntimeById = this.query(removeAuthorizationParam(getRuntime1))
35
35
  /**
36
36
  * Create an tenant
37
37
  */
@@ -108,6 +108,14 @@ class CloudPlatformHorizonClient extends ReactQueryNetworkClient {
108
108
  * List runtime associations to workspace's environment
109
109
  */
110
110
  listRuntimeAssociationsToEnv = this.query(removeAuthorizationParam(listAssociations))
111
+ /**
112
+ * List of application deployments rollout
113
+ */
114
+ listApplicationDeploymentRollouts = this.query(removeAuthorizationParam(listApplicationDeploymentRollouts))
115
+ /**
116
+ * Set an action to application deployment rollout
117
+ */
118
+ deployApplicationRolloutAction = this.mutation(removeAuthorizationParam(postApplicationDeploymentRolloutAction))
111
119
  }
112
120
 
113
121
  export const cloudPlatformHorizonClient = new CloudPlatformHorizonClient()
@@ -1,21 +1,28 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import
3
- {
4
- acceptNetworkConnection,
2
+ import {
5
3
  createCertificate,
6
4
  createCidr,
7
5
  createDnsRecord,
8
6
  createDnsZone,
9
7
  createFolder,
10
8
  createFoundation,
11
- createInbound,
12
9
  createNetwork,
13
- createNetworkConnection,
14
10
  createProject,
11
+ createRuntime,
12
+ createTenant,
15
13
  createVpn,
16
14
  defaults,
15
+ deleteCertificate,
16
+ deleteCidr,
17
+ deleteDnsRecord,
18
+ deleteDnsZone,
19
+ deleteFolder,
20
+ deleteNetwork,
21
+ deleteProject,
22
+ deleteVpn,
17
23
  getCertificate,
18
24
  getFolder,
25
+ getFolderTags,
19
26
  getFoundation,
20
27
  getNetwork,
21
28
  getProject,
@@ -25,11 +32,18 @@ import
25
32
  listDnsRecord,
26
33
  listDnsZone,
27
34
  listFoundations,
28
- listInbound,
29
35
  listNetwork,
30
- listNetworkConnection,
36
+ listRuntime,
37
+ listTenant,
31
38
  listVpns,
32
39
  providers,
40
+ putCertificateTags,
41
+ putCidrTags,
42
+ putDnsZoneTags,
43
+ putFolderTags,
44
+ putNetworkTags,
45
+ putProjectTags,
46
+ putVpnTags,
33
47
  } from '../api/cloudPlatform'
34
48
  import { DefaultAPIError } from '../error/DefaultAPIError'
35
49
  import { StackspotAPIError } from '../error/StackspotAPIError'
@@ -122,26 +136,6 @@ class CloudPlatformClient extends ReactQueryNetworkClient {
122
136
  * Create a network
123
137
  */
124
138
  createNetwork = this.mutation(removeAuthorizationParam(createNetwork))
125
- /**
126
- * Get a list of inbounds
127
- */
128
- listInbounds = this.query(removeAuthorizationParam(listInbound))
129
- /**
130
- * Create a inbound
131
- */
132
- createInbound = this.mutation(removeAuthorizationParam(createInbound))
133
- /**
134
- * Add a network connection
135
- */
136
- addNetworkConnection = this.mutation(removeAuthorizationParam(createNetworkConnection))
137
- /**
138
- * Get a network connection request
139
- */
140
- getNetworkConnections = this.query(removeAuthorizationParam(listNetworkConnection))
141
- /**
142
- * Accept a network connection
143
- */
144
- acceptNetworkConnection = this.mutation(removeAuthorizationParam(acceptNetworkConnection))
145
139
  /**
146
140
  * Get a list of vpn's
147
141
  */
@@ -158,6 +152,86 @@ class CloudPlatformClient extends ReactQueryNetworkClient {
158
152
  * Get a network details
159
153
  */
160
154
  getNetworkById = this.query(removeAuthorizationParam(getNetwork))
155
+ /**
156
+ * Get a list of tenants
157
+ */
158
+ listTenants = this.query(removeAuthorizationParam(listTenant))
159
+ /**
160
+ * Create a tenant
161
+ */
162
+ createTenant = this.mutation(removeAuthorizationParam(createTenant))
163
+ /**
164
+ * Get a list of runtimes
165
+ */
166
+ listRuntimes = this.query(removeAuthorizationParam(listRuntime))
167
+ /**
168
+ * Create a runtime
169
+ */
170
+ createRuntime = this.mutation(removeAuthorizationParam(createRuntime))
171
+ /**
172
+ * Get a list of tags in folder
173
+ */
174
+ getFolderTags = this.query(removeAuthorizationParam(getFolderTags))
175
+ /**
176
+ * Update folder tags
177
+ */
178
+ updateFolderTags = this.mutation(removeAuthorizationParam(putFolderTags))
179
+ /**
180
+ * Update project tags
181
+ */
182
+ updateProjectTags = this.mutation(removeAuthorizationParam(putProjectTags))
183
+ /**
184
+ * Update network tags
185
+ */
186
+ updateNetworkTags = this.mutation(removeAuthorizationParam(putNetworkTags))
187
+ /**
188
+ * Update cidr tags
189
+ */
190
+ updateCidrTags = this.mutation(removeAuthorizationParam(putCidrTags))
191
+ /**
192
+ * Update dns zone tags
193
+ */
194
+ updateDnsZoneTags = this.mutation(removeAuthorizationParam(putDnsZoneTags))
195
+ /**
196
+ * Update certificate tags
197
+ */
198
+ updateCertificateTags = this.mutation(removeAuthorizationParam(putCertificateTags))
199
+ /**
200
+ * Update vpn tags
201
+ */
202
+ updateVpnTags = this.mutation(removeAuthorizationParam(putVpnTags))
203
+ /**
204
+ * Delete a folder
205
+ */
206
+ deleteFolder = this.mutation(removeAuthorizationParam(deleteFolder))
207
+ /**
208
+ * Delete a project
209
+ */
210
+ deleteProject = this.mutation(removeAuthorizationParam(deleteProject))
211
+ /**
212
+ * Delete a network
213
+ */
214
+ deleteNetwork = this.mutation(removeAuthorizationParam(deleteNetwork))
215
+ /**
216
+ * Delete a certificate
217
+ */
218
+ deleteCertificate = this.mutation(removeAuthorizationParam(deleteCertificate))
219
+ /**
220
+ * Delete a dns zone
221
+ */
222
+ deleteDnsZone = this.mutation(removeAuthorizationParam(deleteDnsZone))
223
+ /**
224
+ * Delete a dns record
225
+ */
226
+ deleteDnsRecord = this.mutation(removeAuthorizationParam(deleteDnsRecord))
227
+ /**
228
+ * Delete a VPN
229
+ */
230
+ deleteVPN = this.mutation(removeAuthorizationParam(deleteVpn))
231
+ /**
232
+ * Delete a CIDR
233
+ */
234
+ deleteCidr = this.mutation(removeAuthorizationParam(deleteCidr))
161
235
  }
162
236
 
163
237
  export const cloudPlatformClient = new CloudPlatformClient()