@stack-spot/portal-network 0.157.0-beta.0 → 0.157.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 (42) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/api/discovery.d.ts +222 -33
  3. package/dist/api/discovery.d.ts.map +1 -1
  4. package/dist/api/discovery.js +78 -27
  5. package/dist/api/discovery.js.map +1 -1
  6. package/dist/api/workspaceManager.d.ts +380 -48
  7. package/dist/api/workspaceManager.d.ts.map +1 -1
  8. package/dist/api/workspaceManager.js +334 -2
  9. package/dist/api/workspaceManager.js.map +1 -1
  10. package/dist/apis.json +1 -1
  11. package/dist/client/agent-tools.d.ts +3 -89
  12. package/dist/client/agent-tools.d.ts.map +1 -1
  13. package/dist/client/agent-tools.js +2 -133
  14. package/dist/client/agent-tools.js.map +1 -1
  15. package/dist/client/agent.d.ts +50 -5
  16. package/dist/client/agent.d.ts.map +1 -1
  17. package/dist/client/agent.js +64 -0
  18. package/dist/client/agent.js.map +1 -1
  19. package/dist/client/ai.d.ts +0 -7
  20. package/dist/client/ai.d.ts.map +1 -1
  21. package/dist/client/ai.js +1 -10
  22. package/dist/client/ai.js.map +1 -1
  23. package/dist/client/discovery.d.ts +6 -12
  24. package/dist/client/discovery.d.ts.map +1 -1
  25. package/dist/client/discovery.js +5 -14
  26. package/dist/client/discovery.js.map +1 -1
  27. package/dist/client/types.d.ts +4 -5
  28. package/dist/client/types.d.ts.map +1 -1
  29. package/dist/client/workspace-manager.d.ts +6 -0
  30. package/dist/client/workspace-manager.d.ts.map +1 -1
  31. package/dist/client/workspace-manager.js +10 -1
  32. package/dist/client/workspace-manager.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/api/discovery.ts +309 -49
  35. package/src/api/workspaceManager.ts +402 -50
  36. package/src/apis.json +1 -1
  37. package/src/client/agent-tools.ts +3 -102
  38. package/src/client/agent.ts +68 -0
  39. package/src/client/ai.ts +0 -5
  40. package/src/client/discovery.ts +5 -9
  41. package/src/client/types.ts +5 -7
  42. package/src/client/workspace-manager.ts +5 -0
package/src/apis.json CHANGED
@@ -218,7 +218,7 @@
218
218
  "url": {
219
219
  "dev": "https://discover-discover-core.dev.stackspot.com",
220
220
  "stg": "https://discover-discover-core.stg.stackspot.com",
221
- "prd": "https://discover-discover-core.prd.stackspot.com"
221
+ "prd": "https://discover-discover-core.stackspot.com"
222
222
  },
223
223
  "docs": "/v3/api-docs"
224
224
  }
@@ -1,15 +1,12 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import { addFavoriteV1AgentsAgentIdFavoritePost, AgentVisibilityLevelEnum, createAgentV1AgentsPost, createToolkitToolsV1ToolkitsToolkitIdToolsPost, createToolkitV1ToolkitsPost, defaults, deleteAgentV1AgentsAgentIdDelete, deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete, deleteToolkitV1ToolkitsToolkitIdDelete, editToolkitToolV1ToolkitsToolkitIdToolsToolIdPut, forkToolkitV1ToolkitsToolkitIdForkPost, getAgentV1AgentsAgentIdGet, getPublicToolKitsV1BuiltinToolkitGet, getToolkitToolV1ToolkitsToolkitIdToolsToolIdGet, getToolkitV1ToolkitsToolkitIdGet, HttpValidationError, listAgentsUsingToolsV1ToolkitsToolkitIdToolsAgentsPost, listAgentsV1AgentsGet, listToolkitsV1ToolkitsGet, publishAgentV1AgentsAgentIdPublishPost, searchAgentsV1AgentsSearchPost, updateAgentV1AgentsAgentIdPut, updateToolkitV1ToolkitsToolkitIdPatch, VisibilityLevelEnum } from '../api/agent-tools'
2
+ import { createToolkitToolsV1ToolkitsToolkitIdToolsPost, createToolkitV1ToolkitsPost, defaults, deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete, deleteToolkitV1ToolkitsToolkitIdDelete, editToolkitToolV1ToolkitsToolkitIdToolsToolIdPut, forkToolkitV1ToolkitsToolkitIdForkPost, getPublicToolKitsV1BuiltinToolkitGet, getToolkitToolV1ToolkitsToolkitIdToolsToolIdGet, getToolkitV1ToolkitsToolkitIdGet, HttpValidationError, listAgentsUsingToolsV1ToolkitsToolkitIdToolsAgentsPost, listToolkitsV1ToolkitsGet, updateToolkitV1ToolkitsToolkitIdPatch } from '../api/agent-tools'
3
3
  import apis from '../apis.json'
4
4
  import { StackspotAPIError } from '../error/StackspotAPIError'
5
5
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
6
6
  import { FetchEventStream } from '../network/types'
7
7
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
8
8
  import { StreamedArray } from '../utils/StreamedArray'
9
- import { AgentResponseWithBuiltIn, AgentToolsOpenAPIPreview, AgentVisibilityLevel } from './types'
10
- import { workspaceAiClient } from './workspace-ai'
11
-
12
- const AGENT_DEFAULT_SLUG = 'stk_code_buddy'
9
+ import { AgentToolsOpenAPIPreview } from './types'
13
10
 
14
11
  class AgentToolsClient extends ReactQueryNetworkClient {
15
12
  constructor() {
@@ -29,104 +26,8 @@ class AgentToolsClient extends ReactQueryNetworkClient {
29
26
  tools = this.query(removeAuthorizationParam(getPublicToolKitsV1BuiltinToolkitGet))
30
27
 
31
28
  /**
32
- * Create agent
33
- */
34
- createAgent = this.mutation(removeAuthorizationParam(createAgentV1AgentsPost))
35
-
36
- /**
37
- * Delete agent
38
- */
39
- deleteAgent = this.mutation(deleteAgentV1AgentsAgentIdDelete)
40
-
41
- /**
42
- * Updates an agent
43
- */
44
- updateAgent = this.mutation(updateAgentV1AgentsAgentIdPut)
45
-
46
- /**
47
- * Favorite an agent
48
- */
49
- favoriteAgent = this.mutation(addFavoriteV1AgentsAgentIdFavoritePost)
50
-
51
- /**
52
- * Publish an agent
53
- */
54
- publishAgent = this.mutation(publishAgentV1AgentsAgentIdPublishPost)
55
-
56
- /**
57
- * List agents
58
- */
59
- agents = this.infiniteQuery(removeAuthorizationParam(listAgentsV1AgentsGet))
60
-
61
- /**
62
- * Gets agent by id
63
- */
64
- agent = this.query(removeAuthorizationParam(getAgentV1AgentsAgentIdGet))
65
-
66
- /**
67
- * Gets agents by ids
68
- */
69
- agentsByIds = this.query(removeAuthorizationParam(searchAgentsV1AgentsSearchPost))
70
-
71
- /**
72
- * Gets the default agent slug
73
- */
74
- agentDefaultSlug = AGENT_DEFAULT_SLUG
75
-
76
- /**
77
- * Gets the default agent
78
- */
79
- agentDefault = this.query({
80
- name: 'agentDefault',
81
- request: async (signal) => {
82
- const agentDefault = await listAgentsV1AgentsGet(
83
- { visibility: 'built_in', slug: this.agentDefaultSlug, authorization: '' }, { signal },
84
- )
85
-
86
- const agentId = agentDefault.at(0)?.id
87
- const agent = agentId ? await this.agent.query({ agentId }) : undefined
88
- return agent
89
- },
90
- })
91
-
92
- /**
93
- * List agents filtered by visibility.
29
+ * Get list of Toolkits
94
30
  */
95
- allAgents = this.query({
96
- name: 'allAgents',
97
- request: async (signal, variables: { visibilities: (AgentVisibilityLevel | 'all')[] }) => {
98
- const allVisibilities = ['account', 'built_in', 'favorite', 'personal', 'shared', 'workspace'] as const
99
- const visibilities = variables.visibilities.includes('all')
100
- ? allVisibilities
101
- : variables.visibilities as Array<AgentVisibilityLevelEnum | VisibilityLevelEnum>
102
-
103
- const shouldFetchWorkspaceAgents = visibilities.includes('workspace')
104
-
105
- const workspaceAgentsPromise = shouldFetchWorkspaceAgents
106
- ? workspaceAiClient.workspacesContentsByType.query({ contentType: 'agent' })
107
- : Promise.resolve([])
108
-
109
- const [workspaceAgents, ...agentsByVisibility] = await Promise.all([
110
- workspaceAgentsPromise,
111
- ...visibilities.map((visibility) => listAgentsV1AgentsGet({ visibility, authorization: '' }, { signal })),
112
- ])
113
-
114
- const workspaceAgentsWithSpaceName = workspaceAgents.flatMap(({ agents, space_name }) =>
115
- agents?.map((agent) => ({ ...agent, spaceName: space_name, builtIn: false }))) as AgentResponseWithBuiltIn[]
116
-
117
- const allAgents: AgentResponseWithBuiltIn[] = workspaceAgentsWithSpaceName ?? []
118
-
119
- agentsByVisibility.forEach(agents => allAgents.push(...agents.map(agent => ({
120
- ...agent,
121
- builtIn: agent?.visibility_level === 'built_in',
122
- }))))
123
-
124
- return allAgents
125
- },
126
- })
127
-
128
- /* Get list of Toolkits
129
- */
130
31
  toolkits = this.query(removeAuthorizationParam(listToolkitsV1ToolkitsGet))
131
32
  /**
132
33
  * Get a toolkit by Id
@@ -2,10 +2,15 @@ import { HttpError } from '@oazapfts/runtime'
2
2
  import {
3
3
  defaults, deleteV1AgentByAgentIdFavorite, getV1AgentByAgentId, getV1Agents, getV1PublicAgentByAgentId, getV1PublicAgents,
4
4
  postV1AgentByAgentIdFavorite, putV1AgentByAgentId,
5
+ VisibilityLevel,
5
6
  } from '../api/agent'
6
7
  import apis from '../apis.json'
7
8
  import { StackspotAPIError } from '../error/StackspotAPIError'
8
9
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
10
+ import { AgentResponseWithBuiltIn, AgentVisibilityLevel } from './types'
11
+ import { workspaceAiClient } from './workspace-ai'
12
+
13
+ export const isAgentDefault = (agentSlug?: string) => agentSlug === 'stk_code_buddy'
9
14
 
10
15
  interface AgentError {
11
16
  code?: string,
@@ -31,6 +36,57 @@ class AgentClient extends ReactQueryNetworkClient {
31
36
  })
32
37
  }
33
38
 
39
+ /**
40
+ * List agents filtered by visibility.
41
+ */
42
+ allAgents = this.query({
43
+ name: 'allAgents',
44
+ request: async (signal, variables: { visibilities: AgentVisibilityLevel[] }) => {
45
+ const visibilities: VisibilityLevel[] = variables.visibilities.includes('ALL')
46
+ ? ['PERSONAL', 'SHARED', 'WORKSPACE', 'ACCOUNT', 'FAVORITE']
47
+ : variables.visibilities.filter((visibility) => visibility !== 'BUILT-IN' && visibility !== 'ALL') as VisibilityLevel[]
48
+
49
+ const shouldIncludeBuiltInAgent = variables.visibilities.includes('ALL') || variables.visibilities.includes('BUILT-IN')
50
+ const shouldFetchBuiltInAgent = shouldIncludeBuiltInAgent || variables.visibilities.includes('FAVORITE')
51
+ const shouldFetchWorkspaceAgents = variables.visibilities.includes('ALL') || variables.visibilities.includes('WORKSPACE')
52
+
53
+ const publicAgentsPromise = shouldFetchBuiltInAgent ? getV1PublicAgents({}, { signal }) : Promise.resolve([])
54
+ const workspaceAgentsPromise = shouldFetchWorkspaceAgents
55
+ ? workspaceAiClient.workspacesContentsByType.query({ contentType: 'agent' })
56
+ : Promise.resolve([])
57
+
58
+ const [publicAgents, workspaceAgents, ...agentsByVisibility] = await Promise.all([
59
+ publicAgentsPromise,
60
+ workspaceAgentsPromise,
61
+ ...visibilities.map((visibility) => getV1Agents({ visibility }, { signal })),
62
+ ])
63
+
64
+ const workspaceAgentsWithSpaceName = workspaceAgents?.flatMap(({ agents, space_name }) =>
65
+ agents?.map((agent) => ({
66
+ ...agent,
67
+ spaceName: space_name,
68
+ builtIn: publicAgents?.some(publicAgent => publicAgent.id === agent.id),
69
+ }))) as AgentResponseWithBuiltIn[]
70
+
71
+ const allAgents: AgentResponseWithBuiltIn[] = workspaceAgentsWithSpaceName || []
72
+
73
+ if (shouldIncludeBuiltInAgent) {
74
+ const builtInsAgents = publicAgents?.map((agent) => ({ ...agent, builtIn: true, visibility_level: 'BUILT-IN' }))
75
+ // @ts-ignore fixme: above, BUILT-IN is not a valid value for the enum VisibilityLevel.
76
+ allAgents.push(...builtInsAgents)
77
+ }
78
+
79
+ agentsByVisibility.forEach(agents => {
80
+ allAgents.push(...agents.map(agent => ({
81
+ ...agent,
82
+ builtIn: publicAgents?.some(publicAgent => publicAgent.id === agent.id),
83
+ })))
84
+ })
85
+
86
+ return allAgents
87
+ },
88
+ })
89
+
34
90
  /**
35
91
  * Gets an agent by id
36
92
  */
@@ -41,6 +97,18 @@ class AgentClient extends ReactQueryNetworkClient {
41
97
  : getV1AgentByAgentId({ ...variables }, { signal }),
42
98
  })
43
99
 
100
+ /**
101
+ * Gets the default agent
102
+ */
103
+ agentDefault = this.query({
104
+ name: 'agentDefault',
105
+ request: async (signal) => {
106
+ const publicAgents = await getV1PublicAgents({}, { signal })
107
+ const agentDefault = publicAgents.find((agent) => isAgentDefault(agent.slug))
108
+ return agentDefault ? { ...agentDefault, builtIn: true } : undefined
109
+ },
110
+ })
111
+
44
112
  /**
45
113
  * List commons agents
46
114
  */
package/src/client/ai.ts CHANGED
@@ -34,7 +34,6 @@ import {
34
34
  quickCommandsRunV2V2QuickCommandsSlugStepsStepSlugRunPost,
35
35
  resetKnowledgeObjectsV1KnowledgeSourcesSlugObjectsDelete,
36
36
  runFetchStepV1QuickCommandsSlugStepsStepSlugFetchRunPost,
37
- searchKnowledgeSourcesV1KnowledgeSourcesSearchPost,
38
37
  updateQuickCommandV1QuickCommandsSlugPatch,
39
38
  updateTitleV1ConversationsConversationIdPatch,
40
39
  vectorizeCustomKnowledgeSourceV1KnowledgeSourcesSlugCustomPost,
@@ -136,10 +135,6 @@ class AIClient extends ReactQueryNetworkClient {
136
135
  * Gets a knowledge source document by the slug of the parent knowledge source and the document id.
137
136
  */
138
137
  knowledgeSourceDocument = this.query(removeAuthorizationParam(findKnowledgeObjectByCustomIdV1KnowledgeSourcesSlugObjectsCustomIdGet))
139
- /**
140
- * Lists knowledge sources matching the provided IDs.
141
- */
142
- searchKnowledgeSources = this.query(removeAuthorizationParam(searchKnowledgeSourcesV1KnowledgeSourcesSearchPost))
143
138
  /**
144
139
  * Gets the chat history. This is a paginated resource.
145
140
  */
@@ -1,5 +1,5 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import { attach, createHypothesis, defaults, deleteHypothesisById, deleteV1DocumentsByDocumentIdHypothesesAndHypothesisId, download, findHypothesisById, getAll, getById, list, list1, listAllDocumentsWithHypotheses, listHypothesis, listVersions, upload } from '../api/discovery'
2
+ import { attach, createHypothesis, defaults, deleteV1DocumentsByDocumentIdHypothesesAndHypothesisNumber, download, findHypothesisByNumber, getAll, getById, list1, list2, listAllDocumentsWithHypotheses, listHypothesis, listVersions, upload } from '../api/discovery'
3
3
  import apis from '../apis.json'
4
4
  import { DefaultAPIError } from '../error/DefaultAPIError'
5
5
  import { baseDictionary } from '../error/dictionary/base'
@@ -23,11 +23,11 @@ class DiscoveryClient extends ReactQueryNetworkClient {
23
23
  /**
24
24
  * Get details of an hypothesis by id
25
25
  */
26
- getHypothesisById = this.query(findHypothesisById)
26
+ getHypothesisById = this.query(findHypothesisByNumber)
27
27
  /**
28
28
  * Get list of hypothesis documents
29
29
  */
30
- listDocumentsByHypothesis = this.query(list1)
30
+ listDocumentsByHypothesis = this.query(list2)
31
31
  /**
32
32
  * Get list of all documents
33
33
  */
@@ -39,7 +39,7 @@ class DiscoveryClient extends ReactQueryNetworkClient {
39
39
  /**
40
40
  * Get list of opportunities
41
41
  */
42
- listOpportunities = this.query(list)
42
+ listOpportunities = this.query(list1)
43
43
  /**
44
44
  * Get list of document types
45
45
  */
@@ -56,14 +56,10 @@ class DiscoveryClient extends ReactQueryNetworkClient {
56
56
  * Attach a existing document in an hypothesis
57
57
  */
58
58
  attachExistingDocument = this.mutation(removeAuthorizationParam(attach))
59
- /**
60
- * Delete an hypothesis
61
- */
62
- deleteHypothesis = this.mutation(removeAuthorizationParam(deleteHypothesisById))
63
59
  /**
64
60
  * Delete an document
65
61
  */
66
- deleteDocument = this.mutation(removeAuthorizationParam(deleteV1DocumentsByDocumentIdHypothesesAndHypothesisId))
62
+ deleteDocument = this.mutation(removeAuthorizationParam(deleteV1DocumentsByDocumentIdHypothesesAndHypothesisNumber))
67
63
  /**
68
64
  * Download an document
69
65
  */
@@ -1,6 +1,7 @@
1
1
  import { RequestOpts } from '@oazapfts/runtime'
2
2
  import { AccountScmInfoSaveRequest, AccountScmInfoUpdateRequest, AccountScmStatusResponse, GroupsFromResourceResponse, MembersFromResourceResponse } from '../api/account'
3
- import { AgentVisibilityLevelEnum, HttpMethod, ListAgentResponse, VisibilityLevelEnum } from '../api/agent-tools'
3
+ import { AgentResponse, VisibilityLevel } from '../api/agent'
4
+ import { HttpMethod } from '../api/agent-tools'
4
5
  import { ChatRequest, ChatResponse3, ContentDependencyResponse, ConversationHistoryResponse, ConversationResponse, DependencyResponse } from '../api/ai'
5
6
  import { ConnectAccountRequestV2, ManagedAccountProvisionRequest } from '../api/cloudAccount'
6
7
  import { AllocationCostRequest, AllocationCostResponse, ChargePeriod, getAllocationCostFilters, ManagedService, ServiceResource } from '../api/cloudServices'
@@ -219,7 +220,6 @@ export interface WorkspaceAiMembersPermissions {
219
220
  totalPages: number,
220
221
  }
221
222
 
222
-
223
223
  export interface WorkspaceAiGroupsPermissions extends GroupsFromResourceResponse {
224
224
  actions: Action[],
225
225
  }
@@ -358,14 +358,12 @@ export type FixVariables<
358
358
 
359
359
  export type ReplaceResult<T extends (...args: any[]) => Promise<any>, Fix> = (...args: Parameters<T>) => Promise<Fix>
360
360
 
361
- export interface AgentResponseWithBuiltIn extends Omit<ListAgentResponse, 'conversation_starter' | 'avatar'> {
361
+ export interface AgentResponseWithBuiltIn extends AgentResponse {
362
362
  builtIn?: boolean,
363
363
  spaceName?: string,
364
- conversation_starter?: string[] | null,
365
- avatar?: string | null | undefined,
366
- }
364
+ }
367
365
 
368
- export type AgentVisibilityLevel = AgentVisibilityLevelEnum | VisibilityLevelEnum
366
+ export type AgentVisibilityLevel = VisibilityLevel | 'BUILT-IN' | 'ALL'
369
367
 
370
368
  export interface AgentToolsOpenAPIPreview {
371
369
  name: string,
@@ -42,6 +42,7 @@ import {
42
42
  contextgetConsolidatedPluginInputs,
43
43
  contextgetConsolidatedPluginInputsWithConnectionInterfaces,
44
44
  defaults,
45
+ environmentControllergetEnvironments,
45
46
  managerRunControllerdeleteApplication,
46
47
  managerRunControllerdeleteSharedInfra,
47
48
  sharedInfraControllerV2GetSharedInfraActivities,
@@ -225,6 +226,10 @@ class WorkspaceManagerClient extends ReactQueryNetworkClient {
225
226
  * Gets applied plugins in shared infra
226
227
  */
227
228
  appliedPluginsSharedInfra = this.query(sharedInfraControllerV2GetSharedInfraAppliedPlugins)
229
+ /**
230
+ * List all environments from account
231
+ */
232
+ listEnvironments = this.query(environmentControllergetEnvironments)
228
233
  /**
229
234
  * Gets applied plugins in application
230
235
  */