@stack-spot/portal-network 0.202.0 → 0.203.0-beta.1

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 (132) hide show
  1. package/CHANGELOG.md +254 -0
  2. package/dist/api/account.d.ts +344 -91
  3. package/dist/api/account.d.ts.map +1 -1
  4. package/dist/api/account.js +203 -46
  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 +623 -141
  11. package/dist/api/agent-tools.d.ts.map +1 -1
  12. package/dist/api/agent-tools.js +168 -45
  13. package/dist/api/agent-tools.js.map +1 -1
  14. package/dist/api/ai.d.ts +135 -24
  15. package/dist/api/ai.d.ts.map +1 -1
  16. package/dist/api/ai.js +79 -26
  17. package/dist/api/ai.js.map +1 -1
  18. package/dist/api/codeShift.d.ts +127 -9
  19. package/dist/api/codeShift.d.ts.map +1 -1
  20. package/dist/api/codeShift.js +73 -6
  21. package/dist/api/codeShift.js.map +1 -1
  22. package/dist/api/dataIntegration.d.ts +291 -1
  23. package/dist/api/dataIntegration.d.ts.map +1 -1
  24. package/dist/api/dataIntegration.js +254 -0
  25. package/dist/api/dataIntegration.js.map +1 -1
  26. package/dist/api/discover.d.ts +79 -4
  27. package/dist/api/discover.d.ts.map +1 -1
  28. package/dist/api/discover.js +73 -7
  29. package/dist/api/discover.js.map +1 -1
  30. package/dist/api/edpBfa.d.ts +215 -0
  31. package/dist/api/edpBfa.d.ts.map +1 -0
  32. package/dist/api/edpBfa.js +87 -0
  33. package/dist/api/edpBfa.js.map +1 -0
  34. package/dist/api/workspace-ai.d.ts +41 -0
  35. package/dist/api/workspace-ai.d.ts.map +1 -1
  36. package/dist/api/workspace-ai.js +34 -0
  37. package/dist/api/workspace-ai.js.map +1 -1
  38. package/dist/api-addresses.d.ts +13 -20
  39. package/dist/api-addresses.d.ts.map +1 -1
  40. package/dist/api-addresses.js +60 -17
  41. package/dist/api-addresses.js.map +1 -1
  42. package/dist/apis-itau.json +16 -0
  43. package/dist/apis.json +16 -0
  44. package/dist/client/account-asset-manager.d.ts +112 -0
  45. package/dist/client/account-asset-manager.d.ts.map +1 -0
  46. package/dist/client/account-asset-manager.js +160 -0
  47. package/dist/client/account-asset-manager.js.map +1 -0
  48. package/dist/client/account.d.ts +11 -9
  49. package/dist/client/account.d.ts.map +1 -1
  50. package/dist/client/account.js +11 -8
  51. package/dist/client/account.js.map +1 -1
  52. package/dist/client/agent-tools.d.ts +108 -3
  53. package/dist/client/agent-tools.d.ts.map +1 -1
  54. package/dist/client/agent-tools.js +95 -10
  55. package/dist/client/agent-tools.js.map +1 -1
  56. package/dist/client/ai.d.ts +148 -1
  57. package/dist/client/ai.d.ts.map +1 -1
  58. package/dist/client/ai.js +149 -17
  59. package/dist/client/ai.js.map +1 -1
  60. package/dist/client/code-shift.d.ts +54 -3
  61. package/dist/client/code-shift.d.ts.map +1 -1
  62. package/dist/client/code-shift.js +46 -1
  63. package/dist/client/code-shift.js.map +1 -1
  64. package/dist/client/data-integration.d.ts +30 -0
  65. package/dist/client/data-integration.d.ts.map +1 -1
  66. package/dist/client/data-integration.js +29 -2
  67. package/dist/client/data-integration.js.map +1 -1
  68. package/dist/client/discover.d.ts +16 -2
  69. package/dist/client/discover.d.ts.map +1 -1
  70. package/dist/client/discover.js +28 -1
  71. package/dist/client/discover.js.map +1 -1
  72. package/dist/client/edp-bfa.d.ts +16 -0
  73. package/dist/client/edp-bfa.d.ts.map +1 -0
  74. package/dist/client/edp-bfa.js +24 -0
  75. package/dist/client/edp-bfa.js.map +1 -0
  76. package/dist/client/notification.d.ts +7 -0
  77. package/dist/client/notification.d.ts.map +1 -1
  78. package/dist/client/notification.js +10 -1
  79. package/dist/client/notification.js.map +1 -1
  80. package/dist/client/types.d.ts +11 -3
  81. package/dist/client/types.d.ts.map +1 -1
  82. package/dist/client/workspace-ai.d.ts +13 -3
  83. package/dist/client/workspace-ai.d.ts.map +1 -1
  84. package/dist/client/workspace-ai.js +17 -3
  85. package/dist/client/workspace-ai.js.map +1 -1
  86. package/dist/client/workspace-manager.d.ts +15 -0
  87. package/dist/client/workspace-manager.d.ts.map +1 -1
  88. package/dist/client/workspace-manager.js +19 -1
  89. package/dist/client/workspace-manager.js.map +1 -1
  90. package/dist/error/dictionary/accountAssetManager.d.ts +11 -0
  91. package/dist/error/dictionary/accountAssetManager.d.ts.map +1 -0
  92. package/dist/error/dictionary/accountAssetManager.js +11 -0
  93. package/dist/error/dictionary/accountAssetManager.js.map +1 -0
  94. package/dist/index.d.ts +3 -1
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +3 -1
  97. package/dist/index.js.map +1 -1
  98. package/dist/network/NetworkClient.d.ts.map +1 -1
  99. package/dist/network/NetworkClient.js +12 -2
  100. package/dist/network/NetworkClient.js.map +1 -1
  101. package/dist/network/types.d.ts +1 -0
  102. package/dist/network/types.d.ts.map +1 -1
  103. package/package.json +2 -2
  104. package/readme.md +39 -1
  105. package/src/api/account.ts +592 -165
  106. package/src/api/accountAssetManager.ts +771 -0
  107. package/src/api/agent-tools.ts +824 -188
  108. package/src/api/ai.ts +206 -38
  109. package/src/api/codeShift.ts +233 -12
  110. package/src/api/dataIntegration.ts +635 -1
  111. package/src/api/discover.ts +153 -10
  112. package/src/api/edpBfa.ts +472 -0
  113. package/src/api/workspace-ai.ts +83 -0
  114. package/src/api-addresses.ts +93 -37
  115. package/src/apis-itau.json +16 -0
  116. package/src/apis.json +16 -0
  117. package/src/client/account-asset-manager.ts +100 -0
  118. package/src/client/account.ts +11 -7
  119. package/src/client/agent-tools.ts +64 -16
  120. package/src/client/ai.ts +129 -19
  121. package/src/client/code-shift.ts +29 -0
  122. package/src/client/data-integration.ts +23 -2
  123. package/src/client/discover.ts +15 -2
  124. package/src/client/edp-bfa.ts +24 -0
  125. package/src/client/notification.ts +6 -1
  126. package/src/client/types.ts +12 -3
  127. package/src/client/workspace-ai.ts +21 -6
  128. package/src/client/workspace-manager.ts +13 -0
  129. package/src/error/dictionary/accountAssetManager.ts +12 -0
  130. package/src/index.ts +4 -1
  131. package/src/network/NetworkClient.ts +13 -4
  132. package/src/network/types.ts +1 -0
package/src/client/ai.ts CHANGED
@@ -7,13 +7,17 @@ import {
7
7
  calculateNextStepV1QuickCommandsSlugStepsStepSlugCalculateNextStepPost,
8
8
  callbackV1QuickCommandsCallbackExecutionIdGet,
9
9
  conversationHistoryV1ConversationsConversationIdGet,
10
+ createAnswerForReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersPost,
10
11
  createExecutionV1QuickCommandsCreateExecutionSlugPost,
12
+ createResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsPost,
11
13
  currentV1TokensUsageCurrentGet,
12
14
  defaults,
13
15
  deleteConversationV1ConversationsConversationIdDelete,
14
16
  deleteFavoriteV1AiStacksStackIdFavoriteDelete,
15
17
  deleteFavoriteV1QuickCommandsSlugFavoriteDelete,
16
18
  deleteKnowledgeObjectByCustomIdV1KnowledgeSourcesSlugObjectsCustomIdDelete,
19
+ deleteResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdDelete,
20
+ deleteReviewCommentV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersAnswerIdDelete,
17
21
  downloadConversationV1ConversationsConversationIdDownloadGet,
18
22
  findKnowledgeObjectByCustomIdV1KnowledgeSourcesSlugObjectsCustomIdGet,
19
23
  findKnowledgeSourceV1KnowledgeSourcesSlugGet,
@@ -22,12 +26,14 @@ import {
22
26
  getContentDependenciesV1ContentContentTypeContentIdDependenciesGet,
23
27
  getFlagsV1FlagsGet,
24
28
  getQuickCommandV1QuickCommandsSlugGet,
29
+ getReviewsByResourceV1ResourcesResourceTypeSlugResourceSlugReviewsGet,
25
30
  getScriptExecutionStatusV1QuickCommandsScriptExecutionsScriptExecutionIdGet,
26
31
  getUploadFormV1FileUploadFormPost,
27
32
  HttpValidationError,
28
33
  listAiStacksV1AiStacksGet,
29
34
  listAllV1QuickCommandsAllGet,
30
35
  listAllV2QuickCommandsAllGet,
36
+ listAllV3QuickCommandsGet,
31
37
  listAssociationV1WorkspaceWorkspaceIdGet,
32
38
  listConversationsV1ConversationsGet,
33
39
  listKnowledgeSourcesV1KnowledgeSourcesGet,
@@ -39,12 +45,18 @@ import {
39
45
  resetKnowledgeObjectsV1KnowledgeSourcesSlugObjectsDelete,
40
46
  runFetchStepV1QuickCommandsSlugStepsStepSlugFetchRunPost,
41
47
  searchKnowledgeSourcesV1KnowledgeSourcesSearchPost,
48
+ tokensByUserV1AnalyticsTokensByUserGet,
49
+ tokensDailyUsageV1AnalyticsTokensDailyUsageGet,
42
50
  startScriptStepV1QuickCommandsSlugStepsStepSlugStartScriptPost,
43
51
  totalV1TokensUsageTotalGet,
44
52
  updateQuickCommandV1QuickCommandsSlugPatch,
53
+ updateResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdPatch,
54
+ updateReviewCommentV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersAnswerIdPatch,
45
55
  updateTitleV1ConversationsConversationIdPatch,
46
56
  vectorizeCustomKnowledgeSourceV1KnowledgeSourcesSlugCustomPost,
47
57
  } from '../api/ai'
58
+
59
+
48
60
  import { StackspotAPIError } from '../error/StackspotAPIError'
49
61
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
50
62
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
@@ -52,6 +64,7 @@ import { StreamedJson } from '../utils/StreamedJson'
52
64
  import { formatJson } from '../utils/string'
53
65
  import { agentToolsClient } from './agent-tools'
54
66
  import {
67
+ AgentInfo,
55
68
  ChatAgentTool,
56
69
  ChatResponseWithSteps,
57
70
  FixedChatRequest,
@@ -62,6 +75,8 @@ import {
62
75
  StepChatStep,
63
76
  } from './types'
64
77
 
78
+ const listQAV3WithoutAuthorization = removeAuthorizationParam(listAllV3QuickCommandsGet)
79
+
65
80
  class AIClient extends ReactQueryNetworkClient {
66
81
  constructor() {
67
82
  super(getApiAddresses().ai.url, defaults)
@@ -127,6 +142,10 @@ class AIClient extends ReactQueryNetworkClient {
127
142
  * Lists all the quick commands according to filters passed as parameter (including QC with secrets).
128
143
  */
129
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' })
130
149
  /**
131
150
  * Gets a quick command by its slug.
132
151
  */
@@ -261,6 +280,14 @@ class AIClient extends ReactQueryNetworkClient {
261
280
  */
262
281
  removeFavoriteQuickCommand = this.mutation(removeAuthorizationParam(deleteFavoriteV1QuickCommandsSlugFavoriteDelete))
263
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
+ /*
264
291
  * Lists all the feature flags for this user.
265
292
  */
266
293
  flags = this.query(getFlagsV1FlagsGet)
@@ -273,6 +300,46 @@ class AIClient extends ReactQueryNetworkClient {
273
300
  */
274
301
  getStatusScriptStep = this.query(removeAuthorizationParam(getScriptExecutionStatusV1QuickCommandsScriptExecutionsScriptExecutionIdGet))
275
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))
336
+
337
+ /**
338
+ * Delete a review comment (answer)
339
+ */
340
+ deleteReviewComment = this.mutation(
341
+ removeAuthorizationParam(deleteReviewCommentV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersAnswerIdDelete))
342
+
276
343
  private static async toolsOfAgent(agentId?: string) {
277
344
  try {
278
345
  const agent = agentId ? await agentToolsClient.agent.query({ agentId }) : undefined
@@ -301,6 +368,10 @@ class AIClient extends ReactQueryNetworkClient {
301
368
  { method: 'post', body: JSON.stringify(request), headers, signal: abortController.signal },
302
369
  )
303
370
 
371
+ const DYNAMIC_TOOL_ID = 'dynamic'
372
+ function isDynamicTool(info: AgentInfo) {
373
+ return info.type === 'tool' && info.id === DYNAMIC_TOOL_ID
374
+ }
304
375
  /**
305
376
  * This function treats events in the streaming that deals with the execution of tools. Since these events are not concatenated like
306
377
  * normal streamings of data, we need this separate function to deal with them. It transforms the internal data model of the
@@ -308,12 +379,10 @@ class AIClient extends ReactQueryNetworkClient {
308
379
  */
309
380
  async function transform(event: Partial<FixedChatResponse>, data: Partial<ChatResponseWithSteps>) {
310
381
  const info = event.agent_info
311
-
312
382
  if (!info) return
313
-
314
383
  const tools = await AIClient.toolsOfAgent(request.context?.agent_id)
315
384
  data.steps = data.steps ? [...data.steps] : []
316
-
385
+
317
386
  if (info.type === 'planning' && info.action === 'end') {
318
387
  data.steps.push({
319
388
  id: 'planning',
@@ -382,6 +451,39 @@ class AIClient extends ReactQueryNetworkClient {
382
451
  }
383
452
  }
384
453
 
454
+ if (info.type === 'tool_calls' && info.action === 'start') {
455
+ const hasPlanning = data.steps.find(s => s.type === 'planning')
456
+ // On the first tool_calls:start, create the synthetic planning ("dynamic") step.
457
+ if (!hasPlanning) {
458
+ const userPrompt = request.user_prompt === 'string' ? request.user_prompt : JSON.stringify(request.user_prompt)
459
+ data.steps.push({
460
+ id: 'dynamic',
461
+ type: 'planning',
462
+ status: 'success',
463
+ steps: [],
464
+ goal: userPrompt,
465
+ user_question: userPrompt,
466
+ })
467
+ }
468
+ const toolsStepId = data.steps.filter(s => s.id === 'tools' || s.id.startsWith('tools-')).length + 1
469
+ data.steps.push({
470
+ id: `tools-${toolsStepId.toString()}`,
471
+ type: 'step',
472
+ status: 'running',
473
+ attempts: [{ tools: [] }],
474
+ } as StepChatStep)
475
+ }
476
+
477
+ if (info.type === 'tool_calls' && info.action === 'end') {
478
+ const lastStep = findLast(data.steps, s => s.id === 'tools' || s.id.startsWith('tools-')) as StepChatStep
479
+ if (lastStep) {
480
+ lastStep.status = 'success'
481
+ lastStep.duration = info.duration
482
+ const lastAttemptOfLastTool = last(lastStep.attempts.map(a => a.tools).flat())
483
+ lastStep.output = lastAttemptOfLastTool?.output
484
+ }
485
+ }
486
+
385
487
  if (info.type === 'tool' && info.action === 'awaiting_approval') {
386
488
  const tool = tools.find(({ id }) => id === info.data?.tool_id)
387
489
  data.steps.push({
@@ -405,13 +507,14 @@ class AIClient extends ReactQueryNetworkClient {
405
507
  }
406
508
 
407
509
  if (info.type === 'tool' && info.action === 'start') {
408
- const currentStep = data.steps.find(s => s.status === 'running') as StepChatStep
409
510
  if (!info.data) return
511
+ const input = formatJson(info.data.input)
512
+ const tool = findLast(tools, ({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
513
+
514
+ const currentStep = findLast(data.steps, s => s.status === 'running') as StepChatStep
410
515
 
411
516
  //There might be a tool with status awaiting_approval, so we want to inform tool has already started
412
- if (!currentStep || !currentStep.attempts[0].tools) {
413
- const input = formatJson(info.data.input)
414
- const tool = tools.find(({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
517
+ if (!currentStep || !currentStep?.attempts?.[0]?.tools) {
415
518
  data.steps.push({
416
519
  id: info.id,
417
520
  type: 'tool',
@@ -424,23 +527,23 @@ class AIClient extends ReactQueryNetworkClient {
424
527
  }],
425
528
  })
426
529
  } else {
427
- const toolInFirstAttempt = currentStep.attempts[0].tools?.find(t => t.executionId === info.id)
530
+ const toolInFirstAttempt = findLast(currentStep?.attempts?.[0]?.tools, t => t.executionId === info.id)
428
531
  //One step might have multiple tools. When in an approval mode, we might not have all the tools in the array yet.
429
- //So we make sure to add any tools that are not in there.
430
- if (!toolInFirstAttempt) {
431
- const input = formatJson(info.data.input)
432
- const tool = tools?.find(({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
433
- currentStep.attempts[info.data.attempt - 1].tools?.push({
532
+ //For dynamic tools (id === 'dynamic'), we always push a new tool, since dynamic executions can trigger
533
+ //multiple tool runs in the same step and do not follow the planned tool structure.
534
+ //So we make sure to add any tools that are not in there, or always add for dynamic tools.
535
+ if (!toolInFirstAttempt || isDynamicTool(info)) {
536
+ currentStep.attempts?.[0].tools?.push({
434
537
  ...tool,
435
538
  executionId: info.id,
436
539
  input,
540
+ status: 'running',
437
541
  })
438
542
  } else {
439
543
  const input = formatJson(info.data.input)
440
544
  if (info.data.attempt === 1) {
441
545
  toolInFirstAttempt.input = input
442
546
  } else {
443
- const tool = tools.find(({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
444
547
  currentStep.attempts[info.data.attempt - 1] ??= { tools: [] }
445
548
  currentStep.attempts[info.data.attempt - 1].tools?.push({
446
549
  ...tool,
@@ -455,10 +558,14 @@ class AIClient extends ReactQueryNetworkClient {
455
558
  if (info.type === 'tool' && info.action === 'end') {
456
559
  const currentStep = data.steps.find(s => s.status === 'running') as StepChatStep
457
560
  if (!currentStep || !info.data) return
458
- const tool = currentStep.attempts[info.data.attempt - 1]?.tools?.find(t => t.executionId === info.id)
561
+
562
+ // attempt index for tool execution starts at 0 for dynamically executed tools,while for planned tools it starts at 1
563
+ const attempt = isDynamicTool(info) ? info.data.attempt : info.data.attempt - 1
564
+ const tool = last(currentStep?.attempts?.[attempt]?.tools)
459
565
  if (tool) {
460
566
  tool.output = formatJson(info.data.output)
461
567
  tool.duration = info.duration
568
+ tool.status = 'success'
462
569
  }
463
570
  }
464
571
 
@@ -467,11 +574,14 @@ class AIClient extends ReactQueryNetworkClient {
467
574
  if (answerStep) answerStep.status = 'running'
468
575
  }
469
576
 
577
+
470
578
  if (info.type === 'chat' && info.action === 'end') {
471
- const answerStep = last(data.steps)
472
- if (answerStep) {
473
- answerStep.status = 'success'
474
- answerStep.duration = info.duration
579
+ const lastStep = last(data.steps)
580
+ if (lastStep?.type === 'answer') {
581
+ lastStep.status = 'success'
582
+ lastStep.duration = info.duration
583
+ } else {
584
+ data.steps.push({ id: 'answer', type: 'answer', status: 'success' })
475
585
  }
476
586
  }
477
587
  }
@@ -75,6 +75,11 @@ import {
75
75
  createReposBatchServiceV2ReposBatchPost,
76
76
  getImportResultV2ReposBatchImportIdGet,
77
77
  downloadImportResultV2ReposBatchImportIdDownloadGet,
78
+ deleteModuleServiceV1ModulesModuleIdDelete,
79
+ createRepositoryServiceV2ReposPost,
80
+ listRepositoryServiceV2ReposGet,
81
+ listModuleExecutionBatchActivitiesV1ActivitiesModuleExecutionBatchGet,
82
+ getModuleExecutionBatchActivitiesByIdV1ActivitiesModuleExecutionBatchModuleExecutionBatchIdGet,
78
83
  } from '../api/codeShift'
79
84
  import { DefaultAPIError } from '../error/DefaultAPIError'
80
85
  import { codeShiftDictionary } from '../error/dictionary/code-shift'
@@ -96,6 +101,10 @@ class CodeShift extends ReactQueryNetworkClient {
96
101
  * Creates a repository.
97
102
  */
98
103
  createRepository = this.mutation(removeAuthorizationParam(createRepositoryServiceV1ReposPost))
104
+ /**
105
+ * Creates a repository (v2).
106
+ */
107
+ createRepositoryV2 = this.mutation(removeAuthorizationParam(createRepositoryServiceV2ReposPost))
99
108
  /**
100
109
  * Creates repositories in batch.
101
110
  */
@@ -116,6 +125,10 @@ class CodeShift extends ReactQueryNetworkClient {
116
125
  * Gets list of repositories.
117
126
  */
118
127
  repositories = this.query(removeAuthorizationParam(listRepositoryServiceV1ReposGet))
128
+ /**
129
+ * Gets list of repositories (v2).
130
+ */
131
+ repositoriesV2 = this.query(removeAuthorizationParam(listRepositoryServiceV2ReposGet))
119
132
  /**
120
133
  * Gets a repository
121
134
  */
@@ -144,6 +157,10 @@ class CodeShift extends ReactQueryNetworkClient {
144
157
  * Gets module by id.
145
158
  */
146
159
  module = this.query(removeAuthorizationParam(getModuleV1ModulesModuleIdGet))
160
+ /**
161
+ * Deletes a module by id.
162
+ */
163
+ deleteModule = this.mutation(removeAuthorizationParam(deleteModuleServiceV1ModulesModuleIdDelete))
147
164
  /**
148
165
  * Add a module in favorites.
149
166
  */
@@ -428,6 +445,18 @@ class CodeShift extends ReactQueryNetworkClient {
428
445
  analyticsModulesExecutionTimesDownload = this.query(
429
446
  removeAuthorizationParam(analyticsModuleExecutionTimesDownloadV1AnalyticsModulesExecutionTimesDownloadGet),
430
447
  )
448
+ /**
449
+ * List Module Execution Batch Activities
450
+ */
451
+ activitiesModuleExecutionBatch = this.query(
452
+ removeAuthorizationParam(listModuleExecutionBatchActivitiesV1ActivitiesModuleExecutionBatchGet),
453
+ )
454
+ /**
455
+ * Get Module Execution Batch Activity by ID
456
+ */
457
+ activityModuleExecutionBatch = this.query(
458
+ removeAuthorizationParam(getModuleExecutionBatchActivitiesByIdV1ActivitiesModuleExecutionBatchModuleExecutionBatchIdGet),
459
+ )
431
460
  }
432
461
 
433
462
  export const codeShiftClient = new CodeShift()
@@ -1,4 +1,5 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
+ import { getApiAddresses } from '../api-addresses'
2
3
  import {
3
4
  addFavoriteV1KnowledgeSourcesSlugFavoritePost,
4
5
  createKsV1KnowledgeSourcesPost,
@@ -14,7 +15,9 @@ import {
14
15
  getUploadFormV1FileUploadFormPost,
15
16
  getUploadFormV2V2FileUploadFormPost,
16
17
  listKosV1KnowledgeSourcesKsSlugObjectsGet,
18
+ listKosV2KnowledgeSourcesKsSlugObjectsGet,
17
19
  listKsV1KnowledgeSourcesGet,
20
+ listKsV2KnowledgeSourcesGet,
18
21
  publishKsV1KnowledgeSourcesSlugPublishPost,
19
22
  resetKosV1KnowledgeSourcesKsSlugObjectsDelete,
20
23
  saveChunkedFilesDeprecatedV1FileUploadFileUploadIdPost,
@@ -32,7 +35,10 @@ import { FileUploadError } from '../error/FileUploadError'
32
35
  import { StackspotAPIError } from '../error/StackspotAPIError'
33
36
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
34
37
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
35
- import { getApiAddresses } from '../api-addresses'
38
+
39
+ const listKSV2WithoutAuthorization = removeAuthorizationParam(listKsV2KnowledgeSourcesGet)
40
+ const listKOV2WithoutAuthorization = removeAuthorizationParam(listKosV2KnowledgeSourcesKsSlugObjectsGet)
41
+
36
42
 
37
43
  class DataIntegrationClient extends ReactQueryNetworkClient {
38
44
  constructor() {
@@ -90,6 +96,17 @@ class DataIntegrationClient extends ReactQueryNetworkClient {
90
96
  * List of knowledge sources
91
97
  */
92
98
  knowledgeSources = this.query(removeAuthorizationParam(listKsV1KnowledgeSourcesGet))
99
+ /**
100
+ * List of knowledge sources with pagination
101
+ */
102
+ knowledgeSourcesV2 = this.infiniteQuery(listKSV2WithoutAuthorization, {
103
+ accumulator: 'items',
104
+ getNextPageParam: ({ variables, lastPage, lastPageParam }) => {
105
+ const size = variables.size ?? 1
106
+ const parsedLastPageParam = (lastPageParam as number) ?? variables.page ?? 1
107
+ return lastPage.items && lastPage.items.length < size ? undefined : parsedLastPageParam + 1
108
+ },
109
+ })
93
110
  /**
94
111
  * Adds the resource of type Knowledge Source to the list of favorites.
95
112
  */
@@ -102,6 +119,10 @@ class DataIntegrationClient extends ReactQueryNetworkClient {
102
119
  * List knowledge objects from a knowledge source
103
120
  */
104
121
  listKnowledgeObjects = this.query(removeAuthorizationParam(listKosV1KnowledgeSourcesKsSlugObjectsGet))
122
+ /**
123
+ * List knowledge objects from a knowledge source with pagination
124
+ */
125
+ listKnowledgeObjectsV2 = this.infiniteQuery(listKOV2WithoutAuthorization, { accumulator: 'items' })
105
126
  /**
106
127
  * Get a knowledge object by id
107
128
  */
@@ -185,7 +206,7 @@ class DataIntegrationClient extends ReactQueryNetworkClient {
185
206
  * Get Indexed Files
186
207
  */
187
208
  listIndexedProjectFiles = this.query(removeAuthorizationParam(getIndexedFilesV1KnowledgeSourcesKsSlugFilesGet))
188
-
209
+
189
210
  }
190
211
 
191
212
  export const dataIntegrationClient = new DataIntegrationClient()
@@ -2,7 +2,7 @@ import { HttpError } from '@oazapfts/runtime'
2
2
  import { findLast, last } from 'lodash'
3
3
  import { getApiAddresses } from '../api-addresses'
4
4
  import { ConversationResponse } from '../api/ai'
5
- import { create, create1, create2, defaults, deleteById, deleteById1, deleteById2, getAll, getAll1, getAll2, getAllByHypothesis, getById, getById1, getById2, GetOpportunityResponse, MessageRequest } from '../api/discover'
5
+ import { create, create1, create2, defaults, deleteById, deleteById1, deleteById2, fetchInsights, getAll, getAll1, getAll2, getAllByHypothesis, getById, getById1, getById2, getInsightById, GetOpportunityResponse, AiChatRequest, refreshInsights } from '../api/discover'
6
6
  import { DefaultAPIError } from '../error/DefaultAPIError'
7
7
  import { StackspotAPIError } from '../error/StackspotAPIError'
8
8
  import { StreamedJson } from '../utils/StreamedJson'
@@ -53,6 +53,19 @@ class DiscoverClient extends ReactQueryNetworkClient {
53
53
 
54
54
  deleteDocument = this.mutation(deleteById2)
55
55
 
56
+ /**
57
+ * Fetch insights
58
+ */
59
+ insights = this.query(fetchInsights)
60
+ /**
61
+ * Refresh insights
62
+ */
63
+ refreshInsights = this.mutation(refreshInsights)
64
+ /**
65
+ * Get Insight by Id
66
+ */
67
+ insightById = this.query(getInsightById)
68
+
56
69
  chats = this.query({
57
70
  name: 'chats',
58
71
  request: async (_signal, variables: { filter?: string, page?: number, size?: number }) => {
@@ -108,7 +121,7 @@ class DiscoverClient extends ReactQueryNetworkClient {
108
121
  }
109
122
 
110
123
 
111
- sendChatMessage(request: MessageRequest & { agentId: string }, minChangeIntervalMS?: number): StreamedJson<ChatResponseWithSteps> {
124
+ sendChatMessage(request: AiChatRequest & { agentId: string }, minChangeIntervalMS?: number): StreamedJson<ChatResponseWithSteps> {
112
125
  const abortController = new AbortController()
113
126
  const headers = {
114
127
  'Content-Type': 'application/json',
@@ -0,0 +1,24 @@
1
+ import { HttpError } from '@oazapfts/runtime'
2
+ import { getApiAddresses } from '../api-addresses'
3
+ import { defaults, executeCodeWorkflow } from '../api/edpBfa'
4
+ import { DefaultAPIError } from '../error/DefaultAPIError'
5
+ import { baseDictionary } from '../error/dictionary/base'
6
+ import { StackspotAPIError } from '../error/StackspotAPIError'
7
+ import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
8
+
9
+ class EdpBfaClient extends ReactQueryNetworkClient {
10
+ constructor() {
11
+ super(getApiAddresses().edpBfa.url, defaults)
12
+ }
13
+
14
+ protected buildStackSpotError(error: HttpError): StackspotAPIError {
15
+ return new DefaultAPIError(error.data, error.status, baseDictionary, error.headers)
16
+ }
17
+
18
+ /**
19
+ * Triggers an workflow to generate code.
20
+ */
21
+ generateCode = this.mutation(executeCodeWorkflow)
22
+ }
23
+
24
+ export const edpBfaClient = new EdpBfaClient()
@@ -1,5 +1,5 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import { commit, committedNotifications, defaults, findAll } from '../api/notification'
2
+ import { commit, committedNotifications, defaults, findAll, uncommit } from '../api/notification'
3
3
  import { DefaultAPIError } from '../error/DefaultAPIError'
4
4
  import { baseDictionary } from '../error/dictionary/base'
5
5
  import { StackspotAPIError } from '../error/StackspotAPIError'
@@ -27,6 +27,11 @@ class NotificationClient extends ReactQueryNetworkClient {
27
27
  * Mark a notification as committed (mark as read)
28
28
  */
29
29
  commit = this.mutation(commit)
30
+ /**
31
+ * Mark a notification as uncommitted (mark as unread)
32
+ */
33
+ uncommit = this.mutation(uncommit)
34
+
30
35
  }
31
36
 
32
37
  export const notificationClient = new NotificationClient()
@@ -247,6 +247,7 @@ export interface ChatAgentTool {
247
247
  input?: string,
248
248
  output?: string,
249
249
  goal?: string,
250
+ status?: 'running' | 'success' | 'error',
250
251
  }
251
252
 
252
253
  export interface ChatStepAttempt {
@@ -308,10 +309,10 @@ export interface AnswerChatStep extends BaseChatStep {
308
309
  export type ChatStep = PlanningChatStep | StepChatStep | AnswerChatStep | ToolChatStep
309
310
 
310
311
  export interface BaseAgentInfo {
311
- type: 'chat' | 'planning' | 'step' | 'tool' | 'final_answer',
312
+ type: 'chat' | 'planning' | 'step' | 'tool' | 'final_answer' | 'tool_calls',
312
313
  action: 'start' | 'end' | 'awaiting_approval',
313
314
  duration?: number,
314
- id: string,
315
+ id?: string,
315
316
  }
316
317
 
317
318
  export interface AgentTool {
@@ -355,7 +356,15 @@ export interface GenericAgentInfo extends BaseAgentInfo {
355
356
  type: 'chat' | 'final_answer',
356
357
  }
357
358
 
358
- export type AgentInfo = GenericAgentInfo | PlanningAgentInfo | StepAgentInfo | ToolAgentInfo
359
+ export interface ToolCallsAgentInfo extends BaseAgentInfo {
360
+ type: 'tool_calls',
361
+ data?: {
362
+ tools?: string[],
363
+ duration?: number,
364
+ },
365
+ }
366
+
367
+ export type AgentInfo = GenericAgentInfo | PlanningAgentInfo | StepAgentInfo | ToolAgentInfo | ToolCallsAgentInfo
359
368
 
360
369
  export interface FixedChatResponse extends ChatResponse3 {
361
370
  agent_info: AgentInfo,
@@ -1,9 +1,10 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import { AgentResponse } from '../api/agent'
2
+ import { getApiAddresses } from '../api-addresses'
3
3
  import { CustomToolkitResponse } from '../api/agent-tools'
4
4
  import { GetAiStackResponse, KnowledgeSourceItemResponse, QuickCommandResponse } from '../api/ai'
5
5
  import {
6
6
  addContentV1WorkspacesWorkspaceIdContentTypePost,
7
+ addContentV2WorkspacesWorkspaceIdContentTypePost,
7
8
  addFavoriteV1WorkspacesWorkspaceIdFavoritePost,
8
9
  addPermissionV1ResourceTypeResourceTypeResourcesResourceIdentifierPatch,
9
10
  addPermissionV1WorkspacesWorkspaceIdPermissionsPatch,
@@ -24,13 +25,12 @@ import {
24
25
  updateWorkspaceV1WorkspacesWorkspaceIdPatch,
25
26
  useShareableLinkV1ShareShareIdPatch,
26
27
  } from '../api/workspace-ai'
28
+ import { DefaultAPIError } from '../error/DefaultAPIError'
29
+ import { wksAiDictionary } from '../error/dictionary/workspace-ai'
27
30
  import { StackspotAPIError } from '../error/StackspotAPIError'
28
31
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
29
32
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
30
- import { getApiAddresses } from '../api-addresses'
31
- import { DefaultAPIError } from '../error/DefaultAPIError'
32
- import { wksAiDictionary } from '../error/dictionary/workspace-ai'
33
- import { FixedAddResourceToWorkspaceAi, FixedWorkspaceAiPermissions, ReplaceResult } from './types'
33
+ import { AgentResponseWithBuiltIn, FixedAddResourceToWorkspaceAi, FixedWorkspaceAiPermissions, ReplaceResult } from './types'
34
34
 
35
35
  class WorkspaceAiClient extends ReactQueryNetworkClient {
36
36
  constructor() {
@@ -48,6 +48,7 @@ class WorkspaceAiClient extends ReactQueryNetworkClient {
48
48
  deleteWorkspaceAi = this.mutation(removeAuthorizationParam(deleteWorkspaceV1WorkspacesWorkspaceIdDelete))
49
49
 
50
50
  /**
51
+ * @deprecated
51
52
  * Adds a resource to the Spot.
52
53
  */
53
54
  addResourceTypeToWorkspaceAi = this.mutation({
@@ -61,6 +62,20 @@ class WorkspaceAiClient extends ReactQueryNetworkClient {
61
62
  permission: this.createPermissionFunctionFor(addContentV1WorkspacesWorkspaceIdContentTypePost),
62
63
  })
63
64
 
65
+ /**
66
+ * V2 for adding a resource to the Spot.
67
+ */
68
+ addResourceTypeV2ToSpot = this.mutation({
69
+ name: 'addResourceTypeToWorkspaceAi',
70
+ request: (
71
+ signal,
72
+ variables: Omit<Parameters<typeof addContentV2WorkspacesWorkspaceIdContentTypePost>[0], 'authorization'>,
73
+ ) =>
74
+ addContentV2WorkspacesWorkspaceIdContentTypePost({ ...variables, authorization: '' },
75
+ { signal }) as unknown as Promise<FixedAddResourceToWorkspaceAi>,
76
+ permission: this.createPermissionFunctionFor(addContentV2WorkspacesWorkspaceIdContentTypePost),
77
+ })
78
+
64
79
  /**
65
80
  * Lists all the knowledge sources in a Spot.
66
81
  */
@@ -117,7 +132,7 @@ class WorkspaceAiClient extends ReactQueryNetworkClient {
117
132
  'authorization' | 'contentType'>,
118
133
  ) =>
119
134
  listAllByContentTypeV1WorkspacesWorkspaceIdContentTypeGet({ ...variables, contentType: 'agent', authorization: '' },
120
- { signal }) as unknown as Promise<AgentResponse[]>,
135
+ { signal }) as unknown as Promise<AgentResponseWithBuiltIn[]>,
121
136
  permission: this.createPermissionFunctionFor(listAllByContentTypeV1WorkspacesWorkspaceIdContentTypeGet),
122
137
  })
123
138
 
@@ -29,6 +29,8 @@ import {
29
29
  contextControllerclearActionContextInWorkspace,
30
30
  contextControllerclearPluginContextInAccount,
31
31
  contextControllerclearPluginContextInWorkspace,
32
+ contextControllerclearWorkflowContextInAccount,
33
+ contextControllerclearWorkflowContextInWorkspace,
32
34
  contextControllerimportContextInAccount,
33
35
  contextControllerimportContextInWorkspace,
34
36
  contextControllerupsertAccountActionsInputContext,
@@ -539,6 +541,17 @@ class WorkspaceManagerClient extends ReactQueryNetworkClient {
539
541
  permission: async ({ stackVersionId, workflowVersionId }: Parameters<typeof contextControllerupsertWorkflowAccountContext>[0]) =>
540
542
  workspaceClient.saveContextInAccount.isAllowed({ $type: 'workflow', stackVersionId, externalId: workflowVersionId }),
541
543
  })
544
+
545
+ /**
546
+ * Clear stack workflow context in account
547
+ */
548
+ clearInputContextWorkflowAccount = this.mutation(contextControllerclearWorkflowContextInAccount)
549
+
550
+ /**
551
+ * Clear stack workflow context in workspace
552
+ */
553
+ clearInputContextWorkflowWorkspace = this.mutation(contextControllerclearWorkflowContextInWorkspace)
554
+
542
555
  /**
543
556
  * Get Stacks with context
544
557
  */
@@ -0,0 +1,12 @@
1
+ import { Dictionary } from '@stack-spot/portal-translate'
2
+
3
+ export const accountAssetManagerDictionary = {
4
+ en: {
5
+ FOLDER_BAD_REQUEST_ERROR: 'The provided data is invalid or inconsistent.',
6
+ FOLDER_ALREADY_EXISTS: 'A folder with this name already exists.',
7
+ },
8
+ pt: {
9
+ FOLDER_BAD_REQUEST_ERROR: 'Os dados informados estão inválidos ou inconsistentes.',
10
+ FOLDER_ALREADY_EXISTS: 'Já existe uma pasta com esse nome.',
11
+ },
12
+ } satisfies Dictionary
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { CancelledError } from '@tanstack/react-query'
2
- export { apiAddresses, getApiAddresses, getApisByTenant, getBaseUrlByTenantWithOverride, setApisOverride } from './api-addresses'
2
+ export { apiAddresses, getApiAddresses, getApisBaseUrlConfig, getBaseUrlByTenantWithOverride } from './api-addresses'
3
3
  export { accountClient } from './client/account'
4
+ export { accountAssetManagerClient } from './client/account-asset-manager'
4
5
  export { agentClient } from './client/agent'
5
6
  export { agentToolsClient } from './client/agent-tools'
6
7
  export { aiClient } from './client/ai'
@@ -15,6 +16,7 @@ export { contentClient } from './client/content'
15
16
  export { dataIntegrationClient } from './client/data-integration'
16
17
  export * from './client/discover'
17
18
  export { discoverClient } from './client/discover'
19
+ export { edpBfaClient } from './client/edp-bfa'
18
20
  export { eventBusClient } from './client/event-bus'
19
21
  export { genAiInferenceClient } from './client/gen-ai-inference'
20
22
  export { insightsClient } from './client/insights'
@@ -41,3 +43,4 @@ export { StreamedArray } from './utils/StreamedArray'
41
43
  export { StreamedJson } from './utils/StreamedJson'
42
44
  export { useExtendedList } from './utils/use-extended-list'
43
45
  export { useStreamedArray } from './utils/use-streamed-array'
46
+