@stack-spot/portal-network 0.184.0 → 0.185.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.
- package/CHANGELOG.md +2419 -2412
- package/dist/api/account.js +1 -1
- package/dist/api/agent-tools.js +1 -1
- package/dist/api/agent.js +1 -1
- package/dist/api/ai.js +1 -1
- package/dist/api/apiManagement.js +1 -1
- package/dist/api/apiRuntime.js +1 -1
- package/dist/api/cloudAccount.js +1 -1
- package/dist/api/cloudPlatform.js +1 -1
- package/dist/api/cloudPlatformHorizon.js +1 -1
- package/dist/api/cloudRuntimes.js +1 -1
- package/dist/api/cloudServices.js +1 -1
- package/dist/api/codeShift.d.ts +63 -4
- package/dist/api/codeShift.d.ts.map +1 -1
- package/dist/api/codeShift.js +14 -1
- package/dist/api/codeShift.js.map +1 -1
- package/dist/api/content.js +1 -1
- package/dist/api/dataIntegration.js +1 -1
- package/dist/api/discover.js +1 -1
- package/dist/api/genAiInference.js +1 -1
- package/dist/api/insights.js +1 -1
- package/dist/api/notification.js +1 -1
- package/dist/api/secrets.js +1 -1
- package/dist/api/serviceCatalog.js +1 -1
- package/dist/api/workspace-ai.js +1 -1
- package/dist/api/workspace.js +1 -1
- package/dist/api/workspaceManager.js +1 -1
- package/dist/api/workspaceSearchEngine.js +1 -1
- package/dist/client/code-shift.d.ts +22 -0
- package/dist/client/code-shift.d.ts.map +1 -1
- package/dist/client/code-shift.js +28 -1
- package/dist/client/code-shift.js.map +1 -1
- package/package.json +6 -6
- package/scripts/generate-apis.ts +134 -134
- package/src/api/account.ts +8367 -8367
- package/src/api/agent-tools.ts +2169 -2169
- package/src/api/agent.ts +1083 -1083
- package/src/api/ai.ts +3388 -3388
- package/src/api/apiManagement.ts +570 -570
- package/src/api/apiRuntime.ts +2103 -2103
- package/src/api/cloudAccount.ts +1239 -1239
- package/src/api/cloudPlatform.ts +927 -927
- package/src/api/cloudPlatformHorizon.ts +2655 -2655
- package/src/api/cloudRuntimes.ts +2043 -2043
- package/src/api/cloudServices.ts +1445 -1445
- package/src/api/codeShift.ts +3567 -3481
- package/src/api/content.ts +9785 -9785
- package/src/api/dataIntegration.ts +1657 -1657
- package/src/api/discover.ts +435 -435
- package/src/api/eventBus.ts +171 -171
- package/src/api/genAiInference.ts +603 -603
- package/src/api/insights.ts +310 -310
- package/src/api/notification.ts +334 -334
- package/src/api/secrets.ts +342 -342
- package/src/api/serviceCatalog.ts +2908 -2908
- package/src/api/workflows.ts +1669 -1669
- package/src/api/workspace-ai.ts +677 -677
- package/src/api/workspace.ts +5889 -5889
- package/src/api/workspaceManager.ts +2951 -2951
- package/src/api/workspaceSearchEngine.ts +153 -153
- package/src/api-addresses.ts +120 -120
- package/src/apis-itau.json +225 -225
- package/src/apis.json +225 -225
- package/src/client/account.ts +902 -902
- package/src/client/agent-tools.ts +210 -210
- package/src/client/agent.ts +81 -81
- package/src/client/ai.ts +395 -395
- package/src/client/api-management.ts +40 -40
- package/src/client/cloud-account.ts +70 -70
- package/src/client/cloud-platform-horizon.ts +113 -113
- package/src/client/cloud-platform.ts +163 -163
- package/src/client/cloud-runtimes.ts +129 -129
- package/src/client/cloud-services.ts +94 -94
- package/src/client/code-shift.ts +364 -349
- package/src/client/content.ts +538 -538
- package/src/client/data-integration.ts +191 -191
- package/src/client/discover.ts +89 -89
- package/src/client/event-bus.ts +84 -84
- package/src/client/gen-ai-inference.ts +65 -65
- package/src/client/insights.ts +28 -28
- package/src/client/notification.ts +32 -32
- package/src/client/runtime-manager.ts +76 -76
- package/src/client/secrets.ts +60 -60
- package/src/client/types.ts +377 -377
- package/src/client/workflow.ts +83 -83
- package/src/client/workspace-ai.ts +191 -191
- package/src/client/workspace-manager.ts +564 -564
- package/src/client/workspace-search.ts +39 -39
- package/src/client/workspace.ts +480 -480
- package/src/error/DefaultAPIError.ts +151 -151
- package/src/error/FileUploadError.ts +18 -18
- package/src/error/IgnoredErrorCodes.ts +3 -3
- package/src/error/StackspotAPIError.ts +101 -101
- package/src/error/StreamCanceledError.ts +10 -10
- package/src/error/StreamError.ts +7 -7
- package/src/error/StreamJsonError.ts +10 -10
- package/src/error/dictionary/account.ts +58 -58
- package/src/error/dictionary/action-details.ts +20 -20
- package/src/error/dictionary/action.ts +211 -211
- package/src/error/dictionary/agent-tools.ts +75 -75
- package/src/error/dictionary/ai-inference.ts +28 -28
- package/src/error/dictionary/base.ts +22 -22
- package/src/error/dictionary/cloud-platform.ts +82 -82
- package/src/error/dictionary/cnt-fields.ts +14 -14
- package/src/error/dictionary/cnt.ts +103 -103
- package/src/error/dictionary/code-shift.ts +12 -12
- package/src/error/dictionary/rte.ts +24 -24
- package/src/error/dictionary/rtm.ts +10 -10
- package/src/error/dictionary/secrets.ts +14 -14
- package/src/error/dictionary/workspace-ai.ts +10 -10
- package/src/error/dictionary/workspace-details.ts +15 -15
- package/src/error/dictionary/workspace-fields.ts +10 -10
- package/src/error/dictionary/workspace.ts +209 -209
- package/src/error/types.ts +21 -21
- package/src/index.ts +43 -43
- package/src/network/AutoInfiniteQuery.ts +115 -115
- package/src/network/AutoMutation.ts +27 -27
- package/src/network/AutoOperation.ts +73 -73
- package/src/network/AutoQuery.ts +75 -75
- package/src/network/ManualInfiniteQuery.ts +95 -95
- package/src/network/ManualMutation.ts +40 -40
- package/src/network/ManualOperation.ts +52 -52
- package/src/network/ManualQuery.ts +82 -82
- package/src/network/NetworkClient.ts +167 -167
- package/src/network/ReactQueryNetworkClient.ts +312 -312
- package/src/network/react-query-client.ts +14 -14
- package/src/network/types.ts +294 -294
- package/src/types.ts +1 -1
- package/src/utils/StreamedArray.tsx +146 -146
- package/src/utils/StreamedJson.tsx +166 -166
- package/src/utils/remove-authorization-param.ts +6 -6
- package/src/utils/string.ts +19 -19
- package/src/utils/use-extended-list.ts +80 -80
- package/src/utils/use-streamed-array.ts +17 -17
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +10 -10
|
@@ -1,210 +1,210 @@
|
|
|
1
|
-
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
-
import { getApiAddresses } from '../api-addresses'
|
|
3
|
-
import { addFavoriteV1AgentsAgentIdFavoritePost, AgentVisibilityLevelEnum, createAgentV1AgentsPost, createToolkitToolsV1ToolkitsToolkitIdToolsPost, createToolkitV1ToolkitsPost, defaults, deleteAgentV1AgentsAgentIdDelete, deleteFavoriteV1AgentsAgentIdFavoriteDelete, deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete, deleteToolkitV1ToolkitsToolkitIdDelete, editToolkitToolV1ToolkitsToolkitIdToolsToolIdPut, forkAgentV1AgentsAgentIdForkPost, forkToolkitV1ToolkitsToolkitIdForkPost, getAgentV1AgentsAgentIdGet, getPublicToolKitsV1BuiltinToolkitGet, getToolkitToolV1ToolkitsToolkitIdToolsToolIdGet, getToolkitV1ToolkitsToolkitIdGet, listAgentsUsingToolsV1ToolkitsToolkitIdToolsAgentsPost, listAgentsV1AgentsGet, listAgentsV3AgentsGet, listMultiAgentsV1AgentsMultiAgentsGet, listToolkitsV1ToolkitsGet, publishAgentV1AgentsAgentIdPublishPost, searchAgentsV1AgentsSearchPost, shareV1AgentsAgentIdSharePost, updateAgentV1AgentsAgentIdPatch, updateToolkitV1ToolkitsToolkitIdPatch, VisibilityLevelEnum } from '../api/agent-tools'
|
|
4
|
-
import { DefaultAPIError } from '../error/DefaultAPIError'
|
|
5
|
-
import { agentToolsDictionary } from '../error/dictionary/agent-tools'
|
|
6
|
-
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
7
|
-
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
8
|
-
import { FetchEventStream } from '../network/types'
|
|
9
|
-
import { removeAuthorizationParam } from '../utils/remove-authorization-param'
|
|
10
|
-
import { StreamedArray } from '../utils/StreamedArray'
|
|
11
|
-
import { AgentResponseWithBuiltIn, AgentToolsOpenAPIPreview, AgentVisibilityLevel } from './types'
|
|
12
|
-
import { workspaceAiClient } from './workspace-ai'
|
|
13
|
-
|
|
14
|
-
const AGENT_DEFAULT_SLUG = 'stk_flex'
|
|
15
|
-
|
|
16
|
-
class AgentToolsClient extends ReactQueryNetworkClient {
|
|
17
|
-
constructor() {
|
|
18
|
-
super(getApiAddresses()['agent-tools'].url, defaults)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
protected buildStackSpotError(error: HttpError): StackspotAPIError {
|
|
22
|
-
return new DefaultAPIError(error.data, error.status, agentToolsDictionary, error.headers)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
tools = this.query(removeAuthorizationParam(getPublicToolKitsV1BuiltinToolkitGet))
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Create agent
|
|
29
|
-
*/
|
|
30
|
-
createAgent = this.mutation(removeAuthorizationParam(createAgentV1AgentsPost))
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Delete agent
|
|
34
|
-
*/
|
|
35
|
-
deleteAgent = this.mutation(removeAuthorizationParam(deleteAgentV1AgentsAgentIdDelete))
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Updates an agent
|
|
39
|
-
*/
|
|
40
|
-
updateAgent = this.mutation(removeAuthorizationParam(updateAgentV1AgentsAgentIdPatch))
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Favorite an agent
|
|
44
|
-
*/
|
|
45
|
-
favoriteAgent = this.mutation(removeAuthorizationParam(addFavoriteV1AgentsAgentIdFavoritePost))
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Publish an agent
|
|
49
|
-
*/
|
|
50
|
-
publishAgent = this.mutation(removeAuthorizationParam(publishAgentV1AgentsAgentIdPublishPost))
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* List agents
|
|
54
|
-
*/
|
|
55
|
-
agents = this.infiniteQuery(removeAuthorizationParam(listAgentsV1AgentsGet))
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* List agents with support for multiple filters
|
|
59
|
-
*/
|
|
60
|
-
agentsMultipleFilters = this.infiniteQuery(removeAuthorizationParam(listAgentsV3AgentsGet), { pageParamName: 'filters.page' })
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* List agents available to be added to other agents
|
|
64
|
-
*/
|
|
65
|
-
availableAgentsForMultiAgentAddition = this.query(removeAuthorizationParam(listMultiAgentsV1AgentsMultiAgentsGet))
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Gets agent by id
|
|
69
|
-
*/
|
|
70
|
-
agent = this.query(removeAuthorizationParam(getAgentV1AgentsAgentIdGet))
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Gets agents by ids
|
|
74
|
-
*/
|
|
75
|
-
agentsByIds = this.query(removeAuthorizationParam(searchAgentsV1AgentsSearchPost))
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Gets the default agent slug
|
|
79
|
-
*/
|
|
80
|
-
agentDefaultSlug = AGENT_DEFAULT_SLUG
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Gets the default agent
|
|
84
|
-
*/
|
|
85
|
-
agentDefault = this.query({
|
|
86
|
-
name: 'agentDefault',
|
|
87
|
-
request: async (signal) => {
|
|
88
|
-
const agentDefault = await listAgentsV1AgentsGet(
|
|
89
|
-
{ visibility: 'built_in', slug: this.agentDefaultSlug, authorization: '' }, { signal },
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
const agentId = agentDefault?.find((agent) => agent.slug === this.agentDefaultSlug)?.id
|
|
93
|
-
const agent = agentId ? await this.agent.query({ agentId }) : undefined
|
|
94
|
-
return agent
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* List agents filtered by visibility.
|
|
100
|
-
*/
|
|
101
|
-
allAgents = this.query({
|
|
102
|
-
name: 'allAgents',
|
|
103
|
-
request: async (signal, variables: { visibilities: (AgentVisibilityLevel | 'all')[] }) => {
|
|
104
|
-
const allVisibilities = ['account', 'built_in', 'recently_used', 'favorite', 'personal', 'shared', 'workspace'] as const
|
|
105
|
-
const visibilities = variables.visibilities.includes('all')
|
|
106
|
-
? allVisibilities
|
|
107
|
-
: variables.visibilities as Array<AgentVisibilityLevelEnum | VisibilityLevelEnum>
|
|
108
|
-
|
|
109
|
-
const shouldFetchWorkspaceAgents = visibilities.includes('workspace')
|
|
110
|
-
|
|
111
|
-
const workspaceAgentsPromise = shouldFetchWorkspaceAgents
|
|
112
|
-
? workspaceAiClient.workspacesContentsByType.query({ contentType: 'agent' })
|
|
113
|
-
: Promise.resolve([])
|
|
114
|
-
|
|
115
|
-
const [workspaceAgents, ...agentsByVisibility] = await Promise.all([
|
|
116
|
-
workspaceAgentsPromise,
|
|
117
|
-
...visibilities.map((visibility) => listAgentsV1AgentsGet({ visibility, authorization: '' }, { signal })),
|
|
118
|
-
])
|
|
119
|
-
|
|
120
|
-
const workspaceAgentsWithSpaceName = workspaceAgents.flatMap(({ agents, space_name }) =>
|
|
121
|
-
agents?.map((agent) => ({ ...agent, spaceName: space_name, builtIn: false }))) as AgentResponseWithBuiltIn[]
|
|
122
|
-
|
|
123
|
-
const allAgents: AgentResponseWithBuiltIn[] = workspaceAgentsWithSpaceName ?? []
|
|
124
|
-
|
|
125
|
-
agentsByVisibility.forEach(agents => allAgents.push(...agents.map(agent => ({
|
|
126
|
-
...agent,
|
|
127
|
-
builtIn: agent?.visibility_level === 'built_in',
|
|
128
|
-
}))))
|
|
129
|
-
|
|
130
|
-
return allAgents
|
|
131
|
-
},
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
/* Get list of Toolkits
|
|
135
|
-
*/
|
|
136
|
-
toolkits = this.query(removeAuthorizationParam(listToolkitsV1ToolkitsGet))
|
|
137
|
-
/**
|
|
138
|
-
* Get a toolkit by Id
|
|
139
|
-
*/
|
|
140
|
-
toolkitById = this.query(removeAuthorizationParam(getToolkitV1ToolkitsToolkitIdGet))
|
|
141
|
-
/**
|
|
142
|
-
* Create a toolkit
|
|
143
|
-
*/
|
|
144
|
-
createToolkit = this.mutation(removeAuthorizationParam(createToolkitV1ToolkitsPost))
|
|
145
|
-
/**
|
|
146
|
-
* Update a toolkit
|
|
147
|
-
*/
|
|
148
|
-
updateToolkit = this.mutation(removeAuthorizationParam(updateToolkitV1ToolkitsToolkitIdPatch))
|
|
149
|
-
/**
|
|
150
|
-
* Delete a toolkit
|
|
151
|
-
*/
|
|
152
|
-
deleteToolkit = this.mutation(removeAuthorizationParam(deleteToolkitV1ToolkitsToolkitIdDelete))
|
|
153
|
-
/**
|
|
154
|
-
* Get Tool from Toolkit
|
|
155
|
-
*/
|
|
156
|
-
toolFromToolkit = this.query(removeAuthorizationParam(getToolkitToolV1ToolkitsToolkitIdToolsToolIdGet))
|
|
157
|
-
/**
|
|
158
|
-
* Add tool on Toolkit
|
|
159
|
-
*/
|
|
160
|
-
addToolOnToolkit = this.mutation(removeAuthorizationParam(createToolkitToolsV1ToolkitsToolkitIdToolsPost))
|
|
161
|
-
/**
|
|
162
|
-
* Edit tool on Toolkit
|
|
163
|
-
*/
|
|
164
|
-
editToolOnToolkit = this.mutation(removeAuthorizationParam(editToolkitToolV1ToolkitsToolkitIdToolsToolIdPut))
|
|
165
|
-
/**
|
|
166
|
-
* Delete tool from Toolkit
|
|
167
|
-
*/
|
|
168
|
-
deleteToolFromToolkit = this.mutation(removeAuthorizationParam(deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete))
|
|
169
|
-
/**
|
|
170
|
-
* Previews an uploaded open api file as a stream where each array item is an OpenAPI operation.
|
|
171
|
-
*/
|
|
172
|
-
streamUploadedAPIs = ({ fileUploadIds, signal }: { fileUploadIds: string[], signal?: AbortSignal }) => {
|
|
173
|
-
const promises: Promise<FetchEventStream>[] = fileUploadIds.map((id) => {
|
|
174
|
-
const url = `/v1/toolkits/tools/preview/${encodeURIComponent(id)}`
|
|
175
|
-
return this.stream(url, { signal })
|
|
176
|
-
})
|
|
177
|
-
return new StreamedArray<AgentToolsOpenAPIPreview>({ eventsPromises: promises, signal })
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Lists the agents using the tools passed as parameter.
|
|
181
|
-
*/
|
|
182
|
-
agentsUsingTools = this.query(removeAuthorizationParam(listAgentsUsingToolsV1ToolkitsToolkitIdToolsAgentsPost))
|
|
183
|
-
/**
|
|
184
|
-
* Forks the toolkit.
|
|
185
|
-
*/
|
|
186
|
-
fork = this.mutation(removeAuthorizationParam(forkToolkitV1ToolkitsToolkitIdForkPost))
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Share Agent
|
|
190
|
-
*/
|
|
191
|
-
shareAgent = this.mutation(removeAuthorizationParam(shareV1AgentsAgentIdSharePost))
|
|
192
|
-
/**
|
|
193
|
-
* Fork Agent
|
|
194
|
-
*/
|
|
195
|
-
forkAgent = this.mutation(removeAuthorizationParam(forkAgentV1AgentsAgentIdForkPost))
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Add and agent to favorites
|
|
199
|
-
*/
|
|
200
|
-
addFavorite = this.mutation(removeAuthorizationParam(addFavoriteV1AgentsAgentIdFavoritePost))
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* remove an agent from favorites
|
|
204
|
-
*/
|
|
205
|
-
removeFavorite = this.mutation(removeAuthorizationParam(deleteFavoriteV1AgentsAgentIdFavoriteDelete))
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export const agentToolsClient = new AgentToolsClient()
|
|
209
|
-
|
|
210
|
-
|
|
1
|
+
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
+
import { getApiAddresses } from '../api-addresses'
|
|
3
|
+
import { addFavoriteV1AgentsAgentIdFavoritePost, AgentVisibilityLevelEnum, createAgentV1AgentsPost, createToolkitToolsV1ToolkitsToolkitIdToolsPost, createToolkitV1ToolkitsPost, defaults, deleteAgentV1AgentsAgentIdDelete, deleteFavoriteV1AgentsAgentIdFavoriteDelete, deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete, deleteToolkitV1ToolkitsToolkitIdDelete, editToolkitToolV1ToolkitsToolkitIdToolsToolIdPut, forkAgentV1AgentsAgentIdForkPost, forkToolkitV1ToolkitsToolkitIdForkPost, getAgentV1AgentsAgentIdGet, getPublicToolKitsV1BuiltinToolkitGet, getToolkitToolV1ToolkitsToolkitIdToolsToolIdGet, getToolkitV1ToolkitsToolkitIdGet, listAgentsUsingToolsV1ToolkitsToolkitIdToolsAgentsPost, listAgentsV1AgentsGet, listAgentsV3AgentsGet, listMultiAgentsV1AgentsMultiAgentsGet, listToolkitsV1ToolkitsGet, publishAgentV1AgentsAgentIdPublishPost, searchAgentsV1AgentsSearchPost, shareV1AgentsAgentIdSharePost, updateAgentV1AgentsAgentIdPatch, updateToolkitV1ToolkitsToolkitIdPatch, VisibilityLevelEnum } from '../api/agent-tools'
|
|
4
|
+
import { DefaultAPIError } from '../error/DefaultAPIError'
|
|
5
|
+
import { agentToolsDictionary } from '../error/dictionary/agent-tools'
|
|
6
|
+
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
7
|
+
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
8
|
+
import { FetchEventStream } from '../network/types'
|
|
9
|
+
import { removeAuthorizationParam } from '../utils/remove-authorization-param'
|
|
10
|
+
import { StreamedArray } from '../utils/StreamedArray'
|
|
11
|
+
import { AgentResponseWithBuiltIn, AgentToolsOpenAPIPreview, AgentVisibilityLevel } from './types'
|
|
12
|
+
import { workspaceAiClient } from './workspace-ai'
|
|
13
|
+
|
|
14
|
+
const AGENT_DEFAULT_SLUG = 'stk_flex'
|
|
15
|
+
|
|
16
|
+
class AgentToolsClient extends ReactQueryNetworkClient {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(getApiAddresses()['agent-tools'].url, defaults)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
protected buildStackSpotError(error: HttpError): StackspotAPIError {
|
|
22
|
+
return new DefaultAPIError(error.data, error.status, agentToolsDictionary, error.headers)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
tools = this.query(removeAuthorizationParam(getPublicToolKitsV1BuiltinToolkitGet))
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create agent
|
|
29
|
+
*/
|
|
30
|
+
createAgent = this.mutation(removeAuthorizationParam(createAgentV1AgentsPost))
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Delete agent
|
|
34
|
+
*/
|
|
35
|
+
deleteAgent = this.mutation(removeAuthorizationParam(deleteAgentV1AgentsAgentIdDelete))
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Updates an agent
|
|
39
|
+
*/
|
|
40
|
+
updateAgent = this.mutation(removeAuthorizationParam(updateAgentV1AgentsAgentIdPatch))
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Favorite an agent
|
|
44
|
+
*/
|
|
45
|
+
favoriteAgent = this.mutation(removeAuthorizationParam(addFavoriteV1AgentsAgentIdFavoritePost))
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Publish an agent
|
|
49
|
+
*/
|
|
50
|
+
publishAgent = this.mutation(removeAuthorizationParam(publishAgentV1AgentsAgentIdPublishPost))
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* List agents
|
|
54
|
+
*/
|
|
55
|
+
agents = this.infiniteQuery(removeAuthorizationParam(listAgentsV1AgentsGet))
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* List agents with support for multiple filters
|
|
59
|
+
*/
|
|
60
|
+
agentsMultipleFilters = this.infiniteQuery(removeAuthorizationParam(listAgentsV3AgentsGet), { pageParamName: 'filters.page' })
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* List agents available to be added to other agents
|
|
64
|
+
*/
|
|
65
|
+
availableAgentsForMultiAgentAddition = this.query(removeAuthorizationParam(listMultiAgentsV1AgentsMultiAgentsGet))
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Gets agent by id
|
|
69
|
+
*/
|
|
70
|
+
agent = this.query(removeAuthorizationParam(getAgentV1AgentsAgentIdGet))
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets agents by ids
|
|
74
|
+
*/
|
|
75
|
+
agentsByIds = this.query(removeAuthorizationParam(searchAgentsV1AgentsSearchPost))
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Gets the default agent slug
|
|
79
|
+
*/
|
|
80
|
+
agentDefaultSlug = AGENT_DEFAULT_SLUG
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Gets the default agent
|
|
84
|
+
*/
|
|
85
|
+
agentDefault = this.query({
|
|
86
|
+
name: 'agentDefault',
|
|
87
|
+
request: async (signal) => {
|
|
88
|
+
const agentDefault = await listAgentsV1AgentsGet(
|
|
89
|
+
{ visibility: 'built_in', slug: this.agentDefaultSlug, authorization: '' }, { signal },
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
const agentId = agentDefault?.find((agent) => agent.slug === this.agentDefaultSlug)?.id
|
|
93
|
+
const agent = agentId ? await this.agent.query({ agentId }) : undefined
|
|
94
|
+
return agent
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* List agents filtered by visibility.
|
|
100
|
+
*/
|
|
101
|
+
allAgents = this.query({
|
|
102
|
+
name: 'allAgents',
|
|
103
|
+
request: async (signal, variables: { visibilities: (AgentVisibilityLevel | 'all')[] }) => {
|
|
104
|
+
const allVisibilities = ['account', 'built_in', 'recently_used', 'favorite', 'personal', 'shared', 'workspace'] as const
|
|
105
|
+
const visibilities = variables.visibilities.includes('all')
|
|
106
|
+
? allVisibilities
|
|
107
|
+
: variables.visibilities as Array<AgentVisibilityLevelEnum | VisibilityLevelEnum>
|
|
108
|
+
|
|
109
|
+
const shouldFetchWorkspaceAgents = visibilities.includes('workspace')
|
|
110
|
+
|
|
111
|
+
const workspaceAgentsPromise = shouldFetchWorkspaceAgents
|
|
112
|
+
? workspaceAiClient.workspacesContentsByType.query({ contentType: 'agent' })
|
|
113
|
+
: Promise.resolve([])
|
|
114
|
+
|
|
115
|
+
const [workspaceAgents, ...agentsByVisibility] = await Promise.all([
|
|
116
|
+
workspaceAgentsPromise,
|
|
117
|
+
...visibilities.map((visibility) => listAgentsV1AgentsGet({ visibility, authorization: '' }, { signal })),
|
|
118
|
+
])
|
|
119
|
+
|
|
120
|
+
const workspaceAgentsWithSpaceName = workspaceAgents.flatMap(({ agents, space_name }) =>
|
|
121
|
+
agents?.map((agent) => ({ ...agent, spaceName: space_name, builtIn: false }))) as AgentResponseWithBuiltIn[]
|
|
122
|
+
|
|
123
|
+
const allAgents: AgentResponseWithBuiltIn[] = workspaceAgentsWithSpaceName ?? []
|
|
124
|
+
|
|
125
|
+
agentsByVisibility.forEach(agents => allAgents.push(...agents.map(agent => ({
|
|
126
|
+
...agent,
|
|
127
|
+
builtIn: agent?.visibility_level === 'built_in',
|
|
128
|
+
}))))
|
|
129
|
+
|
|
130
|
+
return allAgents
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
/* Get list of Toolkits
|
|
135
|
+
*/
|
|
136
|
+
toolkits = this.query(removeAuthorizationParam(listToolkitsV1ToolkitsGet))
|
|
137
|
+
/**
|
|
138
|
+
* Get a toolkit by Id
|
|
139
|
+
*/
|
|
140
|
+
toolkitById = this.query(removeAuthorizationParam(getToolkitV1ToolkitsToolkitIdGet))
|
|
141
|
+
/**
|
|
142
|
+
* Create a toolkit
|
|
143
|
+
*/
|
|
144
|
+
createToolkit = this.mutation(removeAuthorizationParam(createToolkitV1ToolkitsPost))
|
|
145
|
+
/**
|
|
146
|
+
* Update a toolkit
|
|
147
|
+
*/
|
|
148
|
+
updateToolkit = this.mutation(removeAuthorizationParam(updateToolkitV1ToolkitsToolkitIdPatch))
|
|
149
|
+
/**
|
|
150
|
+
* Delete a toolkit
|
|
151
|
+
*/
|
|
152
|
+
deleteToolkit = this.mutation(removeAuthorizationParam(deleteToolkitV1ToolkitsToolkitIdDelete))
|
|
153
|
+
/**
|
|
154
|
+
* Get Tool from Toolkit
|
|
155
|
+
*/
|
|
156
|
+
toolFromToolkit = this.query(removeAuthorizationParam(getToolkitToolV1ToolkitsToolkitIdToolsToolIdGet))
|
|
157
|
+
/**
|
|
158
|
+
* Add tool on Toolkit
|
|
159
|
+
*/
|
|
160
|
+
addToolOnToolkit = this.mutation(removeAuthorizationParam(createToolkitToolsV1ToolkitsToolkitIdToolsPost))
|
|
161
|
+
/**
|
|
162
|
+
* Edit tool on Toolkit
|
|
163
|
+
*/
|
|
164
|
+
editToolOnToolkit = this.mutation(removeAuthorizationParam(editToolkitToolV1ToolkitsToolkitIdToolsToolIdPut))
|
|
165
|
+
/**
|
|
166
|
+
* Delete tool from Toolkit
|
|
167
|
+
*/
|
|
168
|
+
deleteToolFromToolkit = this.mutation(removeAuthorizationParam(deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete))
|
|
169
|
+
/**
|
|
170
|
+
* Previews an uploaded open api file as a stream where each array item is an OpenAPI operation.
|
|
171
|
+
*/
|
|
172
|
+
streamUploadedAPIs = ({ fileUploadIds, signal }: { fileUploadIds: string[], signal?: AbortSignal }) => {
|
|
173
|
+
const promises: Promise<FetchEventStream>[] = fileUploadIds.map((id) => {
|
|
174
|
+
const url = `/v1/toolkits/tools/preview/${encodeURIComponent(id)}`
|
|
175
|
+
return this.stream(url, { signal })
|
|
176
|
+
})
|
|
177
|
+
return new StreamedArray<AgentToolsOpenAPIPreview>({ eventsPromises: promises, signal })
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Lists the agents using the tools passed as parameter.
|
|
181
|
+
*/
|
|
182
|
+
agentsUsingTools = this.query(removeAuthorizationParam(listAgentsUsingToolsV1ToolkitsToolkitIdToolsAgentsPost))
|
|
183
|
+
/**
|
|
184
|
+
* Forks the toolkit.
|
|
185
|
+
*/
|
|
186
|
+
fork = this.mutation(removeAuthorizationParam(forkToolkitV1ToolkitsToolkitIdForkPost))
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Share Agent
|
|
190
|
+
*/
|
|
191
|
+
shareAgent = this.mutation(removeAuthorizationParam(shareV1AgentsAgentIdSharePost))
|
|
192
|
+
/**
|
|
193
|
+
* Fork Agent
|
|
194
|
+
*/
|
|
195
|
+
forkAgent = this.mutation(removeAuthorizationParam(forkAgentV1AgentsAgentIdForkPost))
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Add and agent to favorites
|
|
199
|
+
*/
|
|
200
|
+
addFavorite = this.mutation(removeAuthorizationParam(addFavoriteV1AgentsAgentIdFavoritePost))
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* remove an agent from favorites
|
|
204
|
+
*/
|
|
205
|
+
removeFavorite = this.mutation(removeAuthorizationParam(deleteFavoriteV1AgentsAgentIdFavoriteDelete))
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export const agentToolsClient = new AgentToolsClient()
|
|
209
|
+
|
|
210
|
+
|
package/src/client/agent.ts
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
-
import {
|
|
3
|
-
defaults, deleteV1AgentByAgentIdFavorite, getV1AgentByAgentId, getV1Agents, getV1PublicAgentByAgentId, getV1PublicAgents,
|
|
4
|
-
postV1AgentByAgentIdFavorite, putV1AgentByAgentId,
|
|
5
|
-
} from '../api/agent'
|
|
6
|
-
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
7
|
-
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
8
|
-
import { getApiAddresses } from '../api-addresses'
|
|
9
|
-
|
|
10
|
-
export const isAgentDefault = (agentSlug?: string) => agentSlug === 'stk_code_buddy'
|
|
11
|
-
|
|
12
|
-
interface AgentError {
|
|
13
|
-
code?: string,
|
|
14
|
-
details?: string,
|
|
15
|
-
additionalInformation?: Record<string, any>,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
class AgentClient extends ReactQueryNetworkClient {
|
|
19
|
-
constructor() {
|
|
20
|
-
super(getApiAddresses().agent.url, defaults)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
protected buildStackSpotError(error: HttpError): StackspotAPIError {
|
|
24
|
-
const errorData = error.data as AgentError | undefined
|
|
25
|
-
const message = [errorData?.details]
|
|
26
|
-
Object.keys(errorData?.additionalInformation ?? {}).forEach(k => message.push(` - ${k}: ${errorData?.additionalInformation?.[k]}`))
|
|
27
|
-
return new StackspotAPIError({
|
|
28
|
-
status: error.status,
|
|
29
|
-
headers: error.headers,
|
|
30
|
-
stack: error.stack,
|
|
31
|
-
code: error.data?.code,
|
|
32
|
-
message: message.join('\n'),
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Gets an agent by id
|
|
38
|
-
*/
|
|
39
|
-
agentById = this.query({
|
|
40
|
-
name: 'agentById',
|
|
41
|
-
request: (signal, variables: { agentId: string, builtIn: boolean }) => variables.builtIn
|
|
42
|
-
? getV1PublicAgentByAgentId({ ...variables }, { signal })
|
|
43
|
-
: getV1AgentByAgentId({ ...variables }, { signal }),
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* List commons agents
|
|
48
|
-
*/
|
|
49
|
-
agents = this.query(getV1Agents)
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Gets a common agent by id
|
|
53
|
-
*/
|
|
54
|
-
agent = this.query(getV1AgentByAgentId)
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* List all public agents (built-in)
|
|
58
|
-
*/
|
|
59
|
-
publicAgents = this.query(getV1PublicAgents)
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Gets a public agent by id (built-in)
|
|
63
|
-
*/
|
|
64
|
-
publicAgent = this.query(getV1PublicAgentByAgentId)
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Adds the resource of type Agent to the list of favorites.
|
|
68
|
-
*/
|
|
69
|
-
addFavoriteAgent = this.mutation(postV1AgentByAgentIdFavorite)
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Removes the resource of type Agent from the list of favorites.
|
|
73
|
-
*/
|
|
74
|
-
removeFavoriteAgent = this.mutation(deleteV1AgentByAgentIdFavorite)
|
|
75
|
-
/**
|
|
76
|
-
* Updates an agent
|
|
77
|
-
*/
|
|
78
|
-
updateAgent = this.mutation(putV1AgentByAgentId)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const agentClient = new AgentClient()
|
|
1
|
+
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
+
import {
|
|
3
|
+
defaults, deleteV1AgentByAgentIdFavorite, getV1AgentByAgentId, getV1Agents, getV1PublicAgentByAgentId, getV1PublicAgents,
|
|
4
|
+
postV1AgentByAgentIdFavorite, putV1AgentByAgentId,
|
|
5
|
+
} from '../api/agent'
|
|
6
|
+
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
7
|
+
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
8
|
+
import { getApiAddresses } from '../api-addresses'
|
|
9
|
+
|
|
10
|
+
export const isAgentDefault = (agentSlug?: string) => agentSlug === 'stk_code_buddy'
|
|
11
|
+
|
|
12
|
+
interface AgentError {
|
|
13
|
+
code?: string,
|
|
14
|
+
details?: string,
|
|
15
|
+
additionalInformation?: Record<string, any>,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class AgentClient extends ReactQueryNetworkClient {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(getApiAddresses().agent.url, defaults)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected buildStackSpotError(error: HttpError): StackspotAPIError {
|
|
24
|
+
const errorData = error.data as AgentError | undefined
|
|
25
|
+
const message = [errorData?.details]
|
|
26
|
+
Object.keys(errorData?.additionalInformation ?? {}).forEach(k => message.push(` - ${k}: ${errorData?.additionalInformation?.[k]}`))
|
|
27
|
+
return new StackspotAPIError({
|
|
28
|
+
status: error.status,
|
|
29
|
+
headers: error.headers,
|
|
30
|
+
stack: error.stack,
|
|
31
|
+
code: error.data?.code,
|
|
32
|
+
message: message.join('\n'),
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Gets an agent by id
|
|
38
|
+
*/
|
|
39
|
+
agentById = this.query({
|
|
40
|
+
name: 'agentById',
|
|
41
|
+
request: (signal, variables: { agentId: string, builtIn: boolean }) => variables.builtIn
|
|
42
|
+
? getV1PublicAgentByAgentId({ ...variables }, { signal })
|
|
43
|
+
: getV1AgentByAgentId({ ...variables }, { signal }),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* List commons agents
|
|
48
|
+
*/
|
|
49
|
+
agents = this.query(getV1Agents)
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Gets a common agent by id
|
|
53
|
+
*/
|
|
54
|
+
agent = this.query(getV1AgentByAgentId)
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* List all public agents (built-in)
|
|
58
|
+
*/
|
|
59
|
+
publicAgents = this.query(getV1PublicAgents)
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Gets a public agent by id (built-in)
|
|
63
|
+
*/
|
|
64
|
+
publicAgent = this.query(getV1PublicAgentByAgentId)
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Adds the resource of type Agent to the list of favorites.
|
|
68
|
+
*/
|
|
69
|
+
addFavoriteAgent = this.mutation(postV1AgentByAgentIdFavorite)
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Removes the resource of type Agent from the list of favorites.
|
|
73
|
+
*/
|
|
74
|
+
removeFavoriteAgent = this.mutation(deleteV1AgentByAgentIdFavorite)
|
|
75
|
+
/**
|
|
76
|
+
* Updates an agent
|
|
77
|
+
*/
|
|
78
|
+
updateAgent = this.mutation(putV1AgentByAgentId)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const agentClient = new AgentClient()
|