@stack-spot/portal-network 0.194.2 → 0.195.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.
- package/CHANGELOG.md +174 -0
- package/dist/api/agent-tools.d.ts +6 -0
- package/dist/api/agent-tools.d.ts.map +1 -1
- package/dist/api/agent-tools.js.map +1 -1
- package/dist/api/agent.d.ts +55 -55
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/ai.d.ts +189 -86
- package/dist/api/ai.d.ts.map +1 -1
- package/dist/api/ai.js +238 -142
- package/dist/api/ai.js.map +1 -1
- package/dist/api/cloudPlatform.d.ts +70 -129
- package/dist/api/cloudPlatform.d.ts.map +1 -1
- package/dist/api/cloudPlatform.js +79 -72
- package/dist/api/cloudPlatform.js.map +1 -1
- package/dist/api/codeShift.d.ts +315 -62
- package/dist/api/codeShift.d.ts.map +1 -1
- package/dist/api/codeShift.js +153 -12
- package/dist/api/codeShift.js.map +1 -1
- package/dist/api/discover.d.ts +23 -12
- package/dist/api/discover.d.ts.map +1 -1
- package/dist/api/discover.js +10 -0
- package/dist/api/discover.js.map +1 -1
- package/dist/api-addresses.d.ts.map +1 -1
- package/dist/client/account.d.ts +233 -233
- package/dist/client/account.d.ts.map +1 -1
- package/dist/client/agent-tools.d.ts +124 -124
- package/dist/client/agent-tools.d.ts.map +1 -1
- package/dist/client/agent-tools.js +10 -1
- package/dist/client/agent-tools.js.map +1 -1
- package/dist/client/agent.d.ts +46 -46
- package/dist/client/agent.d.ts.map +1 -1
- package/dist/client/ai.d.ts +123 -77
- package/dist/client/ai.d.ts.map +1 -1
- package/dist/client/ai.js +44 -1
- package/dist/client/ai.js.map +1 -1
- package/dist/client/api-management.d.ts +2 -2
- package/dist/client/cloud-account.d.ts +13 -13
- package/dist/client/cloud-platform-horizon.d.ts +19 -19
- package/dist/client/cloud-platform.d.ts +114 -89
- package/dist/client/cloud-platform.d.ts.map +1 -1
- package/dist/client/cloud-platform.js +73 -46
- package/dist/client/cloud-platform.js.map +1 -1
- package/dist/client/cloud-runtimes.d.ts +4 -4
- package/dist/client/cloud-services.d.ts +17 -17
- package/dist/client/cloud-services.d.ts.map +1 -1
- package/dist/client/code-shift.d.ts +356 -258
- package/dist/client/code-shift.d.ts.map +1 -1
- package/dist/client/code-shift.js +91 -1
- package/dist/client/code-shift.js.map +1 -1
- package/dist/client/content.d.ts +127 -132
- package/dist/client/content.d.ts.map +1 -1
- package/dist/client/data-integration.d.ts +55 -55
- package/dist/client/data-integration.d.ts.map +1 -1
- package/dist/client/discover.d.ts +15 -9
- package/dist/client/discover.d.ts.map +1 -1
- package/dist/client/discover.js +208 -0
- package/dist/client/discover.js.map +1 -1
- package/dist/client/event-bus.d.ts.map +1 -1
- package/dist/client/gen-ai-inference.d.ts +20 -20
- package/dist/client/insights.d.ts +7 -7
- package/dist/client/notification.d.ts +10 -10
- package/dist/client/runtime-manager.d.ts +8 -8
- package/dist/client/types.d.ts +14 -0
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/workflow.d.ts +10 -10
- package/dist/client/workspace-ai.d.ts +48 -48
- package/dist/client/workspace-manager.d.ts +77 -77
- package/dist/client/workspace-search.d.ts +2 -2
- package/dist/client/workspace.d.ts +58 -105
- package/dist/client/workspace.d.ts.map +1 -1
- package/dist/error/dictionary/cloud-platform.d.ts +6 -0
- package/dist/error/dictionary/cloud-platform.d.ts.map +1 -1
- package/dist/error/dictionary/cloud-platform.js +6 -0
- package/dist/error/dictionary/cloud-platform.js.map +1 -1
- package/dist/utils/StreamedJson.d.ts.map +1 -1
- package/dist/utils/StreamedJson.js +9 -1
- package/dist/utils/StreamedJson.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +2 -1
- package/src/api/account.ts +1 -0
- package/src/api/agent-tools.ts +9 -0
- package/src/api/agent.ts +2 -0
- package/src/api/ai.ts +364 -157
- package/src/api/cloudPlatform.ts +142 -216
- package/src/api/codeShift.ts +607 -69
- package/src/api/discover.ts +35 -12
- package/src/api/notification.ts +2 -0
- package/src/client/agent-tools.ts +10 -1
- package/src/client/ai.ts +37 -0
- package/src/client/cloud-platform.ts +40 -25
- package/src/client/code-shift.ts +54 -1
- package/src/client/discover.ts +220 -3
- package/src/client/types.ts +17 -2
- package/src/error/dictionary/cloud-platform.ts +6 -0
- package/src/utils/StreamedJson.tsx +9 -2
package/src/api/discover.ts
CHANGED
|
@@ -28,7 +28,7 @@ export type GetOpportunityResponse = {
|
|
|
28
28
|
hypotheses: GetOpportunityResponseHypothesisResponse[];
|
|
29
29
|
updatedBy?: string;
|
|
30
30
|
updatedAt?: string;
|
|
31
|
-
chatId
|
|
31
|
+
chatId: string;
|
|
32
32
|
};
|
|
33
33
|
export type UpdateOpportunityRequest = {
|
|
34
34
|
title?: string;
|
|
@@ -42,7 +42,7 @@ export type UpdateOpportunityResponse = {
|
|
|
42
42
|
createdAt?: string;
|
|
43
43
|
updatedBy?: string;
|
|
44
44
|
updatedAt?: string;
|
|
45
|
-
chatId
|
|
45
|
+
chatId: string;
|
|
46
46
|
};
|
|
47
47
|
export type GetHypothesisResponseDocumentResponse = {
|
|
48
48
|
id: string;
|
|
@@ -59,7 +59,7 @@ export type GetHypothesisResponse = {
|
|
|
59
59
|
createdAt?: string;
|
|
60
60
|
updatedBy?: string;
|
|
61
61
|
updatedAt?: string;
|
|
62
|
-
chatId
|
|
62
|
+
chatId: string;
|
|
63
63
|
};
|
|
64
64
|
export type UpdateHypothesisRequest = {
|
|
65
65
|
title?: string;
|
|
@@ -74,7 +74,7 @@ export type UpdateHypothesisResponse = {
|
|
|
74
74
|
createdAt?: string;
|
|
75
75
|
updatedBy?: string;
|
|
76
76
|
updatedAt?: string;
|
|
77
|
-
chatId
|
|
77
|
+
chatId: string;
|
|
78
78
|
};
|
|
79
79
|
export type GetDocumentResponse = {
|
|
80
80
|
id: string;
|
|
@@ -85,7 +85,7 @@ export type GetDocumentResponse = {
|
|
|
85
85
|
createdAt?: string;
|
|
86
86
|
updatedBy?: string;
|
|
87
87
|
updatedAt?: string;
|
|
88
|
-
chatId
|
|
88
|
+
chatId: string;
|
|
89
89
|
};
|
|
90
90
|
export type UpdateDocumentRequest = {
|
|
91
91
|
title?: string;
|
|
@@ -101,7 +101,7 @@ export type UpdateDocumentResponse = {
|
|
|
101
101
|
createdAt?: string;
|
|
102
102
|
updatedBy?: string;
|
|
103
103
|
updatedAt?: string;
|
|
104
|
-
chatId
|
|
104
|
+
chatId: string;
|
|
105
105
|
};
|
|
106
106
|
export type SortResponse = {
|
|
107
107
|
direction: string;
|
|
@@ -134,7 +134,7 @@ export type PageResponseGetOpportunityResponse = {
|
|
|
134
134
|
export type CreateOpportunityRequest = {
|
|
135
135
|
title?: string;
|
|
136
136
|
description?: string;
|
|
137
|
-
chatId
|
|
137
|
+
chatId: string;
|
|
138
138
|
};
|
|
139
139
|
export type CreateOpportunityResponse = {
|
|
140
140
|
id: string;
|
|
@@ -144,13 +144,13 @@ export type CreateOpportunityResponse = {
|
|
|
144
144
|
createdAt?: string;
|
|
145
145
|
updatedBy?: string;
|
|
146
146
|
updatedAt?: string;
|
|
147
|
-
chatId
|
|
147
|
+
chatId: string;
|
|
148
148
|
};
|
|
149
149
|
export type CreateHypothesisRequest = {
|
|
150
150
|
opportunityId?: string;
|
|
151
151
|
title?: string;
|
|
152
152
|
description?: string;
|
|
153
|
-
chatId
|
|
153
|
+
chatId: string;
|
|
154
154
|
};
|
|
155
155
|
export type CreateHypothesisResponse = {
|
|
156
156
|
id: string;
|
|
@@ -161,14 +161,14 @@ export type CreateHypothesisResponse = {
|
|
|
161
161
|
createdAt?: string;
|
|
162
162
|
updatedBy?: string;
|
|
163
163
|
updatedAt?: string;
|
|
164
|
-
chatId
|
|
164
|
+
chatId: string;
|
|
165
165
|
};
|
|
166
166
|
export type CreateDocumentRequest = {
|
|
167
167
|
hypothesisId?: string;
|
|
168
168
|
title?: string;
|
|
169
169
|
description?: string;
|
|
170
170
|
content?: string;
|
|
171
|
-
chatId
|
|
171
|
+
chatId: string;
|
|
172
172
|
};
|
|
173
173
|
export type CreateDocumentResponse = {
|
|
174
174
|
id: string;
|
|
@@ -179,7 +179,14 @@ export type CreateDocumentResponse = {
|
|
|
179
179
|
createdAt?: string;
|
|
180
180
|
updatedBy?: string;
|
|
181
181
|
updatedAt?: string;
|
|
182
|
-
chatId
|
|
182
|
+
chatId: string;
|
|
183
|
+
};
|
|
184
|
+
export type MessageRequest = {
|
|
185
|
+
prompt: string;
|
|
186
|
+
conversationId: string;
|
|
187
|
+
};
|
|
188
|
+
export type SseEmitter = {
|
|
189
|
+
timeout?: number;
|
|
183
190
|
};
|
|
184
191
|
export type GetArtifactResponse = {
|
|
185
192
|
"type": "OPPORTUNITY" | "HYPOTHESIS" | "DOCUMENT";
|
|
@@ -405,6 +412,22 @@ export function create2({ createDocumentRequest }: {
|
|
|
405
412
|
body: createDocumentRequest
|
|
406
413
|
})));
|
|
407
414
|
}
|
|
415
|
+
export function chat({ authorization, messageRequest }: {
|
|
416
|
+
authorization: string;
|
|
417
|
+
messageRequest: MessageRequest;
|
|
418
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
419
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
420
|
+
status: 200;
|
|
421
|
+
data: SseEmitter;
|
|
422
|
+
}>("/v2/ai/chat", oazapfts.json({
|
|
423
|
+
...opts,
|
|
424
|
+
method: "POST",
|
|
425
|
+
body: messageRequest,
|
|
426
|
+
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
427
|
+
Authorization: authorization
|
|
428
|
+
})
|
|
429
|
+
})));
|
|
430
|
+
}
|
|
408
431
|
/**
|
|
409
432
|
* Get specific Document content
|
|
410
433
|
*/
|
package/src/api/notification.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { AgentResponseWithBuiltIn, AgentToolsOpenAPIPreview, AgentVisibilityLeve
|
|
|
12
12
|
import { workspaceAiClient } from './workspace-ai'
|
|
13
13
|
|
|
14
14
|
const AGENT_DEFAULT_SLUG = 'stk_flex'
|
|
15
|
+
const listAgentsV3AgentsWithoutAuthorization = removeAuthorizationParam(listAgentsV3AgentsGet)
|
|
15
16
|
|
|
16
17
|
class AgentToolsClient extends ReactQueryNetworkClient {
|
|
17
18
|
constructor() {
|
|
@@ -57,7 +58,15 @@ class AgentToolsClient extends ReactQueryNetworkClient {
|
|
|
57
58
|
/**
|
|
58
59
|
* List agents with support for multiple filters
|
|
59
60
|
*/
|
|
60
|
-
agentsMultipleFilters = this.infiniteQuery(
|
|
61
|
+
agentsMultipleFilters = this.infiniteQuery(listAgentsV3AgentsWithoutAuthorization, {
|
|
62
|
+
pageParamName: 'filters.page',
|
|
63
|
+
accumulator: 'items',
|
|
64
|
+
getNextPageParam: ({ variables, lastPage, lastPageParam }) => {
|
|
65
|
+
const size = variables.filters.size ?? 1
|
|
66
|
+
const parsedLastPageParam = (lastPageParam as number) ?? variables.filters.page ?? 1
|
|
67
|
+
return lastPage.items && lastPage.items.length < size ? undefined : parsedLastPageParam + 1
|
|
68
|
+
},
|
|
69
|
+
})
|
|
61
70
|
|
|
62
71
|
/**
|
|
63
72
|
* List agents available to be added to other agents
|
package/src/client/ai.ts
CHANGED
|
@@ -38,6 +38,8 @@ import {
|
|
|
38
38
|
resetKnowledgeObjectsV1KnowledgeSourcesSlugObjectsDelete,
|
|
39
39
|
runFetchStepV1QuickCommandsSlugStepsStepSlugFetchRunPost,
|
|
40
40
|
searchKnowledgeSourcesV1KnowledgeSourcesSearchPost,
|
|
41
|
+
tokensByUserV1AnalyticsTokensByUserGet,
|
|
42
|
+
tokensDailyUsageV1AnalyticsTokensDailyUsageGet,
|
|
41
43
|
updateQuickCommandV1QuickCommandsSlugPatch,
|
|
42
44
|
updateTitleV1ConversationsConversationIdPatch,
|
|
43
45
|
vectorizeCustomKnowledgeSourceV1KnowledgeSourcesSlugCustomPost,
|
|
@@ -257,6 +259,14 @@ class AIClient extends ReactQueryNetworkClient {
|
|
|
257
259
|
* Removes the resource of type Quick Command from the list of favorites.
|
|
258
260
|
*/
|
|
259
261
|
removeFavoriteQuickCommand = this.mutation(removeAuthorizationParam(deleteFavoriteV1QuickCommandsSlugFavoriteDelete))
|
|
262
|
+
/**
|
|
263
|
+
* Get Tokens Daily usage
|
|
264
|
+
*/
|
|
265
|
+
analyticsTokensDailyUsage = this.query(removeAuthorizationParam(tokensDailyUsageV1AnalyticsTokensDailyUsageGet))
|
|
266
|
+
/**
|
|
267
|
+
* Get Tokens By User
|
|
268
|
+
*/
|
|
269
|
+
analyticsTokensByUser = this.query(tokensByUserV1AnalyticsTokensByUserGet)
|
|
260
270
|
|
|
261
271
|
private static async toolsOfAgent(agentId?: string) {
|
|
262
272
|
try {
|
|
@@ -351,6 +361,32 @@ class AIClient extends ReactQueryNetworkClient {
|
|
|
351
361
|
data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
|
|
352
362
|
}
|
|
353
363
|
|
|
364
|
+
if (info.type === 'planning' && info.action === 'awaiting_approval') {
|
|
365
|
+
data.steps.push({
|
|
366
|
+
id: 'planning',
|
|
367
|
+
type: 'planning',
|
|
368
|
+
status: 'awaiting_approval',
|
|
369
|
+
user_question: info.data?.user_question,
|
|
370
|
+
duration: info.duration || 0,
|
|
371
|
+
steps: info.data?.steps?.map(s => s.goal) ?? [],
|
|
372
|
+
goal: info.data?.plan_goal ?? '',
|
|
373
|
+
})
|
|
374
|
+
info.data?.steps.forEach(s => data.steps?.push({
|
|
375
|
+
id: s.id,
|
|
376
|
+
type: 'step',
|
|
377
|
+
status: 'pending',
|
|
378
|
+
input: s.goal,
|
|
379
|
+
attempts: [{
|
|
380
|
+
tools: s.tools?.map(t => ({
|
|
381
|
+
...(tools.find(({ id }) => id === t.tool_id) ?? { id: t.tool_id, name: t.tool_id }),
|
|
382
|
+
executionId: t.tool_execution_id,
|
|
383
|
+
goal: t.goal,
|
|
384
|
+
})),
|
|
385
|
+
}],
|
|
386
|
+
}))
|
|
387
|
+
data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
|
|
388
|
+
}
|
|
389
|
+
|
|
354
390
|
if (info.type === 'step' && info.action === 'start') {
|
|
355
391
|
const step = data.steps.find(s => s.id === info.id)
|
|
356
392
|
if (step) step.status = 'running'
|
|
@@ -479,3 +515,4 @@ class AIClient extends ReactQueryNetworkClient {
|
|
|
479
515
|
}
|
|
480
516
|
|
|
481
517
|
export const aiClient = new AIClient()
|
|
518
|
+
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { HttpError } from '@oazapfts/runtime'
|
|
2
2
|
import {
|
|
3
|
-
acceptNetworkConnection,
|
|
4
3
|
createCertificate,
|
|
5
4
|
createCidr,
|
|
6
5
|
createDnsRecord,
|
|
7
6
|
createDnsZone,
|
|
8
7
|
createFolder,
|
|
9
8
|
createFoundation,
|
|
10
|
-
createInbound,
|
|
11
9
|
createNetwork,
|
|
12
|
-
createNetworkConnection,
|
|
13
10
|
createProject,
|
|
14
11
|
createRuntime,
|
|
15
12
|
createTenant,
|
|
16
13
|
createVpn,
|
|
17
14
|
defaults,
|
|
15
|
+
deleteCertificate,
|
|
16
|
+
deleteCidr,
|
|
17
|
+
deleteDnsRecord,
|
|
18
|
+
deleteDnsZone,
|
|
19
|
+
deleteFolder,
|
|
20
|
+
deleteNetwork,
|
|
21
|
+
deleteProject,
|
|
22
|
+
deleteVpn,
|
|
18
23
|
getCertificate,
|
|
19
24
|
getFolder,
|
|
20
25
|
getFolderTags,
|
|
@@ -27,9 +32,7 @@ import {
|
|
|
27
32
|
listDnsRecord,
|
|
28
33
|
listDnsZone,
|
|
29
34
|
listFoundations,
|
|
30
|
-
listInbound,
|
|
31
35
|
listNetwork,
|
|
32
|
-
listNetworkConnection,
|
|
33
36
|
listRuntime,
|
|
34
37
|
listTenant,
|
|
35
38
|
listVpns,
|
|
@@ -133,26 +136,6 @@ class CloudPlatformClient extends ReactQueryNetworkClient {
|
|
|
133
136
|
* Create a network
|
|
134
137
|
*/
|
|
135
138
|
createNetwork = this.mutation(removeAuthorizationParam(createNetwork))
|
|
136
|
-
/**
|
|
137
|
-
* Get a list of inbounds
|
|
138
|
-
*/
|
|
139
|
-
listInbounds = this.query(removeAuthorizationParam(listInbound))
|
|
140
|
-
/**
|
|
141
|
-
* Create a inbound
|
|
142
|
-
*/
|
|
143
|
-
createInbound = this.mutation(removeAuthorizationParam(createInbound))
|
|
144
|
-
/**
|
|
145
|
-
* Add a network connection
|
|
146
|
-
*/
|
|
147
|
-
addNetworkConnection = this.mutation(removeAuthorizationParam(createNetworkConnection))
|
|
148
|
-
/**
|
|
149
|
-
* Get a network connection request
|
|
150
|
-
*/
|
|
151
|
-
getNetworkConnections = this.query(removeAuthorizationParam(listNetworkConnection))
|
|
152
|
-
/**
|
|
153
|
-
* Accept a network connection
|
|
154
|
-
*/
|
|
155
|
-
acceptNetworkConnection = this.mutation(removeAuthorizationParam(acceptNetworkConnection))
|
|
156
139
|
/**
|
|
157
140
|
* Get a list of vpn's
|
|
158
141
|
*/
|
|
@@ -217,6 +200,38 @@ class CloudPlatformClient extends ReactQueryNetworkClient {
|
|
|
217
200
|
* Update vpn tags
|
|
218
201
|
*/
|
|
219
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))
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
export const cloudPlatformClient = new CloudPlatformClient()
|
package/src/client/code-shift.ts
CHANGED
|
@@ -58,14 +58,23 @@ import {
|
|
|
58
58
|
getModuleV1ModulesModuleIdGet,
|
|
59
59
|
analyticsProgramGroupsTargetDetailsV1AnalyticsProgramGroupsTargetDetailsGet,
|
|
60
60
|
analyticsProgramGroupsTargetDetailsDownloadV1AnalyticsProgramGroupsTargetDetailsDownloadGet,
|
|
61
|
+
putCustomerRatingReportV1ReportsReportIdCustomerRatingPut,
|
|
61
62
|
searchReposScmServiceV2ReposSearchScmPost,
|
|
62
63
|
importReposWithTagsScmServiceV2ReposSearchScmSearchIdPost,
|
|
63
64
|
searchReposScmV2V2ReposSearchScmSearchIdGet,
|
|
64
65
|
analyticsRepositoryTargetDetailsV1AnalyticsRepositoriesTargetDetailsGet,
|
|
65
66
|
analyticsRepositoryTargetDetailsDownloadV1AnalyticsRepositoriesTargetDetailsDownloadGet,
|
|
66
|
-
putCustomerRatingReportV1ReportsReportIdCustomerRatingPut,
|
|
67
67
|
updateModuleServiceV1ModulesModuleIdPut,
|
|
68
68
|
downloadSearchReposScmV2V2ReposSearchScmSearchIdDownloadGet,
|
|
69
|
+
moduleFavoriteServiceAddV1ModulesModuleIdFavoritesPost,
|
|
70
|
+
moduleFavoriteServiceDeleteV1ModulesModuleIdFavoritesDelete,
|
|
71
|
+
patHealthCheckV1ScmPatHealthCheckGet,
|
|
72
|
+
createReposBatchServiceV2ReposBatchPost,
|
|
73
|
+
getImportResultV2ReposBatchImportIdGet,
|
|
74
|
+
getModuleDocsV1ModulesModuleIdDocsGet,
|
|
75
|
+
downloadImportResultV2ReposBatchImportIdDownloadGet,
|
|
76
|
+
analyticsModuleExecutionTimesReportV1AnalyticsModulesExecutionTimesGet,
|
|
77
|
+
analyticsModuleExecutionTimesDownloadV1AnalyticsModulesExecutionTimesDownloadGet,
|
|
69
78
|
} from '../api/codeShift'
|
|
70
79
|
import { DefaultAPIError } from '../error/DefaultAPIError'
|
|
71
80
|
import { codeShiftDictionary } from '../error/dictionary/code-shift'
|
|
@@ -91,6 +100,18 @@ class CodeShift extends ReactQueryNetworkClient {
|
|
|
91
100
|
* Creates repositories in batch.
|
|
92
101
|
*/
|
|
93
102
|
createRepositoriesBatch = this.mutation(removeAuthorizationParam(createReposBatchServiceV1ReposBatchPost))
|
|
103
|
+
/**
|
|
104
|
+
* Imports repositories in batch.
|
|
105
|
+
*/
|
|
106
|
+
createRepositoriesBatchV2 = this.mutation(removeAuthorizationParam(createReposBatchServiceV2ReposBatchPost))
|
|
107
|
+
/**
|
|
108
|
+
* Gets the status of a batch import.
|
|
109
|
+
*/
|
|
110
|
+
getImportBatchResultsV2 = this.query(removeAuthorizationParam(getImportResultV2ReposBatchImportIdGet))
|
|
111
|
+
/**
|
|
112
|
+
* Downloads the import result for a batch.
|
|
113
|
+
*/
|
|
114
|
+
downloadImportBatchResultsV2 = this.query(removeAuthorizationParam(downloadImportResultV2ReposBatchImportIdDownloadGet))
|
|
94
115
|
/**
|
|
95
116
|
* Gets list of repositories.
|
|
96
117
|
*/
|
|
@@ -123,6 +144,14 @@ class CodeShift extends ReactQueryNetworkClient {
|
|
|
123
144
|
* Gets module by id.
|
|
124
145
|
*/
|
|
125
146
|
module = this.query(removeAuthorizationParam(getModuleV1ModulesModuleIdGet))
|
|
147
|
+
/**
|
|
148
|
+
* Add a module in favorites.
|
|
149
|
+
*/
|
|
150
|
+
addFavoriteModule = this.mutation(removeAuthorizationParam(moduleFavoriteServiceAddV1ModulesModuleIdFavoritesPost))
|
|
151
|
+
/**
|
|
152
|
+
* Remove a module from favorites.
|
|
153
|
+
*/
|
|
154
|
+
removeFavoriteModule = this.mutation(removeAuthorizationParam(moduleFavoriteServiceDeleteV1ModulesModuleIdFavoritesDelete))
|
|
126
155
|
/**
|
|
127
156
|
* Gets module inputs.
|
|
128
157
|
*/
|
|
@@ -135,10 +164,18 @@ class CodeShift extends ReactQueryNetworkClient {
|
|
|
135
164
|
* Updates a module.
|
|
136
165
|
*/
|
|
137
166
|
updateModule = this.mutation(removeAuthorizationParam(updateModuleServiceV1ModulesModuleIdPut))
|
|
167
|
+
/**
|
|
168
|
+
* Adds a module to favorites.
|
|
169
|
+
*/
|
|
170
|
+
addModuleToFavorites = this.mutation(removeAuthorizationParam(moduleFavoriteServiceAddV1ModulesModuleIdFavoritesPost))
|
|
138
171
|
/**
|
|
139
172
|
* Generates a report.
|
|
140
173
|
*/
|
|
141
174
|
generateReport = this.mutation(removeAuthorizationParam(dispatchModuleServiceV1ModulesDispatchesPost))
|
|
175
|
+
/**
|
|
176
|
+
* Gets module docs.
|
|
177
|
+
*/
|
|
178
|
+
moduleDocs = this.query(removeAuthorizationParam(getModuleDocsV1ModulesModuleIdDocsGet))
|
|
142
179
|
/**
|
|
143
180
|
* Gets repository reports.
|
|
144
181
|
*/
|
|
@@ -263,6 +300,10 @@ class CodeShift extends ReactQueryNetworkClient {
|
|
|
263
300
|
* Validates a SCM URL.
|
|
264
301
|
*/
|
|
265
302
|
validateSCMUrl = this.mutation(removeAuthorizationParam(validateScmUrlServiceV1ReposValidateScmUrlPost))
|
|
303
|
+
/**
|
|
304
|
+
* PAT Health Check
|
|
305
|
+
*/
|
|
306
|
+
checkScmPatHealth = this.query(removeAuthorizationParam(patHealthCheckV1ScmPatHealthCheckGet))
|
|
266
307
|
/**
|
|
267
308
|
* Get Branches for a Repository
|
|
268
309
|
*/
|
|
@@ -379,6 +420,18 @@ class CodeShift extends ReactQueryNetworkClient {
|
|
|
379
420
|
analyticsRepositoryTargetDetailsDownload = this.query(
|
|
380
421
|
removeAuthorizationParam(analyticsRepositoryTargetDetailsDownloadV1AnalyticsRepositoriesTargetDetailsDownloadGet),
|
|
381
422
|
)
|
|
423
|
+
/**
|
|
424
|
+
* Analytics Modules Execution Times
|
|
425
|
+
*/
|
|
426
|
+
analyticsModulesExecutionTimes = this.query(
|
|
427
|
+
removeAuthorizationParam(analyticsModuleExecutionTimesReportV1AnalyticsModulesExecutionTimesGet),
|
|
428
|
+
)
|
|
429
|
+
/**
|
|
430
|
+
* Analytics Modules Execution Times Download
|
|
431
|
+
*/
|
|
432
|
+
analyticsModulesExecutionTimesDownload = this.query(
|
|
433
|
+
removeAuthorizationParam(analyticsModuleExecutionTimesDownloadV1AnalyticsModulesExecutionTimesDownloadGet),
|
|
434
|
+
)
|
|
382
435
|
}
|
|
383
436
|
|
|
384
437
|
export const codeShiftClient = new CodeShift()
|
package/src/client/discover.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
+
import { findLast, last } from 'lodash'
|
|
2
3
|
import { getApiAddresses } from '../api-addresses'
|
|
3
4
|
import { ConversationResponse } from '../api/ai'
|
|
4
|
-
import { create, create1, create2, defaults, deleteById, deleteById1, deleteById2, getAll, getAll1, getAll2, getAllByHypothesis, getById, getById1, getById2, GetOpportunityResponse } from '../api/discover'
|
|
5
|
+
import { create, create1, create2, defaults, deleteById, deleteById1, deleteById2, getAll, getAll1, getAll2, getAllByHypothesis, getById, getById1, getById2, GetOpportunityResponse, MessageRequest } from '../api/discover'
|
|
5
6
|
import { DefaultAPIError } from '../error/DefaultAPIError'
|
|
6
7
|
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
8
|
+
import { StreamedJson } from '../utils/StreamedJson'
|
|
7
9
|
import { baseDictionary } from '../error/dictionary/base'
|
|
10
|
+
import { formatJson } from '../utils/string'
|
|
8
11
|
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
9
12
|
import { aiClient } from './ai'
|
|
13
|
+
import { ChatAgentTool, ChatResponseWithSteps, FixedChatResponse, StepChatStep } from './types'
|
|
14
|
+
import { agentToolsClient } from './agent-tools'
|
|
10
15
|
|
|
11
16
|
export interface ChatConversionDetails extends ConversationResponse {
|
|
12
17
|
opportunityName?: string,
|
|
@@ -67,8 +72,8 @@ class DiscoverClient extends ReactQueryNetworkClient {
|
|
|
67
72
|
{ ...variables, page: variables.page, size: variables.size ?? 40 },
|
|
68
73
|
)
|
|
69
74
|
|
|
70
|
-
const filteredItems = variables.filter
|
|
71
|
-
? chatsHistory.filter((chat) => chat.title.toLowerCase().includes(variables.filter!.toLowerCase()))
|
|
75
|
+
const filteredItems = variables.filter
|
|
76
|
+
? chatsHistory.filter((chat) => chat.title.toLowerCase().includes(variables.filter!.toLowerCase()))
|
|
72
77
|
: chatsHistory
|
|
73
78
|
|
|
74
79
|
const enrichedChats = filteredItems?.map(chat => {
|
|
@@ -84,6 +89,218 @@ class DiscoverClient extends ReactQueryNetworkClient {
|
|
|
84
89
|
return enrichedChats as ChatConversionDetails[]
|
|
85
90
|
},
|
|
86
91
|
})
|
|
92
|
+
|
|
93
|
+
private static async toolsOfAgent(agentId?: string) {
|
|
94
|
+
try {
|
|
95
|
+
const agent = agentId ? await agentToolsClient.agent.query({ agentId }) : undefined
|
|
96
|
+
if (!agent) return []
|
|
97
|
+
const tools: (Omit<ChatAgentTool, 'duration' | 'prompt' | 'output'>)[] = []
|
|
98
|
+
agent.toolkits?.builtin_toolkits?.forEach(kit => kit.tools?.forEach(({ id, name, description }) => {
|
|
99
|
+
if (id) tools.push({ image: kit.image_url, id, name: name || id, description })
|
|
100
|
+
}))
|
|
101
|
+
agent.toolkits?.custom_toolkits?.forEach(kit => kit.tools?.forEach(({ id, name, description }) => {
|
|
102
|
+
if (id) tools.push({ image: kit.avatar ?? undefined, id, name: name || id, description })
|
|
103
|
+
}))
|
|
104
|
+
return tools
|
|
105
|
+
} catch {
|
|
106
|
+
return []
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
sendChatMessage(request: MessageRequest & { agentId: string }, minChangeIntervalMS?: number): StreamedJson<ChatResponseWithSteps> {
|
|
112
|
+
const abortController = new AbortController()
|
|
113
|
+
const headers = {
|
|
114
|
+
'Content-Type': 'application/json',
|
|
115
|
+
'Accept': 'text/event-stream',
|
|
116
|
+
}
|
|
117
|
+
const events = this.stream(
|
|
118
|
+
this.resolveURL('/v2/ai/chat'),
|
|
119
|
+
{ method: 'post', body: JSON.stringify(request), headers, signal: abortController.signal },
|
|
120
|
+
)
|
|
121
|
+
/**
|
|
122
|
+
* This function treats events in the streaming that deals with the execution of tools. Since these events are not concatenated like
|
|
123
|
+
* normal streamings of data, we need this separate function to deal with them. It transforms the internal data model of the
|
|
124
|
+
* StreamedJson object whenever an event is triggered.
|
|
125
|
+
*/
|
|
126
|
+
async function transform(event: Partial<FixedChatResponse>, data: Partial<ChatResponseWithSteps>) {
|
|
127
|
+
const info = event.agent_info
|
|
128
|
+
|
|
129
|
+
if (!info) return
|
|
130
|
+
|
|
131
|
+
const tools = await DiscoverClient.toolsOfAgent(request.agentId)
|
|
132
|
+
data.steps = data.steps ? [...data.steps] : []
|
|
133
|
+
|
|
134
|
+
if (info.type === 'planning' && info.action === 'end') {
|
|
135
|
+
data.steps.push({
|
|
136
|
+
id: 'planning',
|
|
137
|
+
type: 'planning',
|
|
138
|
+
status: 'success',
|
|
139
|
+
duration: info.duration || 0,
|
|
140
|
+
steps: info.data?.steps?.map(s => s.goal) ?? [],
|
|
141
|
+
goal: info.data?.plan_goal ?? '',
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
info.data?.steps.forEach(s => data.steps?.push({
|
|
145
|
+
id: s.id,
|
|
146
|
+
type: 'step',
|
|
147
|
+
status: 'pending',
|
|
148
|
+
input: s.goal,
|
|
149
|
+
attempts: [{
|
|
150
|
+
tools: s.tools?.map(t => ({
|
|
151
|
+
...(tools.find(({ id }) => id === t.tool_id) ?? { id: t.tool_id, name: t.tool_id }),
|
|
152
|
+
executionId: t.tool_execution_id,
|
|
153
|
+
goal: t.goal,
|
|
154
|
+
})),
|
|
155
|
+
}],
|
|
156
|
+
}))
|
|
157
|
+
data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (info.type === 'planning' && info.action === 'awaiting_approval') {
|
|
161
|
+
data.steps.push({
|
|
162
|
+
id: 'planning',
|
|
163
|
+
type: 'planning',
|
|
164
|
+
status: 'awaiting_approval',
|
|
165
|
+
user_question: info.data?.user_question,
|
|
166
|
+
duration: info.duration || 0,
|
|
167
|
+
steps: info.data?.steps?.map(s => s.goal) ?? [],
|
|
168
|
+
goal: info.data?.plan_goal ?? '',
|
|
169
|
+
})
|
|
170
|
+
info.data?.steps.forEach(s => data.steps?.push({
|
|
171
|
+
id: s.id,
|
|
172
|
+
type: 'step',
|
|
173
|
+
status: 'pending',
|
|
174
|
+
input: s.goal,
|
|
175
|
+
attempts: [{
|
|
176
|
+
tools: s.tools?.map(t => ({
|
|
177
|
+
...(tools.find(({ id }) => id === t.tool_id) ?? { id: t.tool_id, name: t.tool_id }),
|
|
178
|
+
executionId: t.tool_execution_id,
|
|
179
|
+
goal: t.goal,
|
|
180
|
+
})),
|
|
181
|
+
}],
|
|
182
|
+
}))
|
|
183
|
+
data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (info.type === 'step' && info.action === 'start') {
|
|
187
|
+
const step = data.steps.find(s => s.id === info.id)
|
|
188
|
+
if (step) step.status = 'running'
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (info.type === 'step' && info.action === 'end') {
|
|
192
|
+
const step = data.steps.find(s => s.id === info.id) as StepChatStep
|
|
193
|
+
if (step) {
|
|
194
|
+
step.status = 'success'
|
|
195
|
+
step.duration = info.duration
|
|
196
|
+
const lastToolId = last(step.attempts[0].tools)?.id
|
|
197
|
+
const lastAttemptOfLastTool = findLast(step.attempts.map(a => a.tools).flat(), t => t?.id === lastToolId)
|
|
198
|
+
step.output = lastAttemptOfLastTool?.output
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (info.type === 'tool' && info.action === 'awaiting_approval') {
|
|
203
|
+
const tool = tools.find(({ id }) => id === info.data?.tool_id)
|
|
204
|
+
data.steps.push({
|
|
205
|
+
id: info.id,
|
|
206
|
+
type: 'tool',
|
|
207
|
+
status: 'awaiting_approval',
|
|
208
|
+
duration: info.duration || 0,
|
|
209
|
+
input: info.data?.input,
|
|
210
|
+
user_question: info.data?.user_question,
|
|
211
|
+
attempts: [{
|
|
212
|
+
tools: [{
|
|
213
|
+
executionId: info.id,
|
|
214
|
+
id: info.data?.tool_id ?? '',
|
|
215
|
+
name: tool?.name ?? '',
|
|
216
|
+
goal: tool?.goal,
|
|
217
|
+
...tool,
|
|
218
|
+
}],
|
|
219
|
+
}],
|
|
220
|
+
})
|
|
221
|
+
data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (info.type === 'tool' && info.action === 'start') {
|
|
225
|
+
const currentStep = data.steps.find(s => s.status === 'running') as StepChatStep
|
|
226
|
+
if (!info.data) return
|
|
227
|
+
|
|
228
|
+
//There might be a tool with status awaiting_approval, so we want to inform tool has already started
|
|
229
|
+
if (!currentStep || !currentStep.attempts[0].tools) {
|
|
230
|
+
const input = formatJson(info.data.input)
|
|
231
|
+
const tool = tools.find(({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
|
|
232
|
+
data.steps.push({
|
|
233
|
+
id: info.id,
|
|
234
|
+
type: 'tool',
|
|
235
|
+
status: 'running',
|
|
236
|
+
duration: info.duration || 0,
|
|
237
|
+
input: info.data?.input,
|
|
238
|
+
user_question: info.data?.user_question,
|
|
239
|
+
attempts: [{
|
|
240
|
+
tools: [{ ...tool, executionId: info.id, input }],
|
|
241
|
+
}],
|
|
242
|
+
})
|
|
243
|
+
} else {
|
|
244
|
+
const toolInFirstAttempt = currentStep.attempts[0].tools?.find(t => t.executionId === info.id)
|
|
245
|
+
//One step might have multiple tools. When in an approval mode, we might not have all the tools in the array yet.
|
|
246
|
+
//So we make sure to add any tools that are not in there.
|
|
247
|
+
if (!toolInFirstAttempt) {
|
|
248
|
+
const input = formatJson(info.data.input)
|
|
249
|
+
const tool = tools?.find(({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
|
|
250
|
+
currentStep.attempts[info.data.attempt - 1].tools?.push({
|
|
251
|
+
...tool,
|
|
252
|
+
executionId: info.id,
|
|
253
|
+
input,
|
|
254
|
+
})
|
|
255
|
+
} else {
|
|
256
|
+
const input = formatJson(info.data.input)
|
|
257
|
+
if (info.data.attempt === 1) {
|
|
258
|
+
toolInFirstAttempt.input = input
|
|
259
|
+
} else {
|
|
260
|
+
const tool = tools.find(({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
|
|
261
|
+
currentStep.attempts[info.data.attempt - 1] ??= { tools: [] }
|
|
262
|
+
currentStep.attempts[info.data.attempt - 1].tools?.push({
|
|
263
|
+
...tool,
|
|
264
|
+
executionId: info.id,
|
|
265
|
+
input,
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (info.type === 'tool' && info.action === 'end') {
|
|
273
|
+
const currentStep = data.steps.find(s => s.status === 'running') as StepChatStep
|
|
274
|
+
if (!currentStep || !info.data) return
|
|
275
|
+
const tool = currentStep.attempts[info.data.attempt - 1]?.tools?.find(t => t.executionId === info.id)
|
|
276
|
+
if (tool) {
|
|
277
|
+
tool.output = formatJson(info.data.output)
|
|
278
|
+
tool.duration = info.duration
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (info.type === 'final_answer' && info.action === 'start') {
|
|
283
|
+
const answerStep = last(data.steps)
|
|
284
|
+
if (answerStep) answerStep.status = 'running'
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (info.type === 'chat' && info.action === 'end') {
|
|
288
|
+
const answerStep = last(data.steps)
|
|
289
|
+
if (answerStep) {
|
|
290
|
+
answerStep.status = 'success'
|
|
291
|
+
answerStep.duration = info.duration
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return new StreamedJson({
|
|
297
|
+
eventsPromise: events,
|
|
298
|
+
abortController,
|
|
299
|
+
minChangeIntervalMS,
|
|
300
|
+
ignoreKeys: ['agent_info'],
|
|
301
|
+
transform,
|
|
302
|
+
})
|
|
303
|
+
}
|
|
87
304
|
}
|
|
88
305
|
|
|
89
306
|
export const discoverClient = new DiscoverClient()
|