@stack-spot/portal-network 0.149.0-beta.2 → 0.150.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 +14 -0
- package/dist/api/agent.d.ts +30 -16
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/agent.js +0 -18
- package/dist/api/agent.js.map +1 -1
- package/dist/api/discovery.d.ts +162 -106
- package/dist/api/discovery.d.ts.map +1 -1
- package/dist/api/discovery.js +23 -3
- package/dist/api/discovery.js.map +1 -1
- package/dist/client/agent-tools.d.ts +21 -92
- package/dist/client/agent-tools.d.ts.map +1 -1
- package/dist/client/agent-tools.js +21 -149
- package/dist/client/agent-tools.js.map +1 -1
- package/dist/client/agent.d.ts +50 -9
- package/dist/client/agent.d.ts.map +1 -1
- package/dist/client/agent.js +65 -10
- package/dist/client/agent.js.map +1 -1
- package/dist/client/ai.d.ts +6 -13
- package/dist/client/ai.d.ts.map +1 -1
- package/dist/client/ai.js +7 -16
- package/dist/client/ai.js.map +1 -1
- package/dist/client/discovery.d.ts +10 -1
- package/dist/client/discovery.d.ts.map +1 -1
- package/dist/client/discovery.js +10 -1
- package/dist/client/discovery.js.map +1 -1
- package/dist/client/secrets.d.ts +2 -2
- package/dist/client/secrets.d.ts.map +1 -1
- package/dist/client/secrets.js +2 -2
- package/dist/client/secrets.js.map +1 -1
- package/dist/client/types.d.ts +4 -5
- package/dist/client/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/StreamedArray.d.ts +66 -0
- package/dist/utils/StreamedArray.d.ts.map +1 -0
- package/dist/utils/StreamedArray.js +148 -0
- package/dist/utils/StreamedArray.js.map +1 -0
- package/dist/utils/StreamedJson.d.ts +1 -1
- package/dist/utils/StreamedJson.d.ts.map +1 -1
- package/dist/utils/use-streamed-array.d.ts +4 -0
- package/dist/utils/use-streamed-array.d.ts.map +1 -0
- package/dist/utils/use-streamed-array.js +15 -0
- package/dist/utils/use-streamed-array.js.map +1 -0
- package/package.json +1 -1
- package/src/api/agent.ts +30 -84
- package/src/api/discovery.ts +192 -107
- package/src/client/agent-tools.ts +17 -117
- package/src/client/agent.ts +72 -6
- package/src/client/ai.ts +6 -11
- package/src/client/discovery.ts +5 -1
- package/src/client/secrets.ts +2 -2
- package/src/client/types.ts +5 -7
- package/src/index.ts +3 -1
- package/src/types.ts +1 -0
- package/src/utils/StreamedArray.tsx +146 -0
- package/src/utils/StreamedJson.tsx +1 -1
- package/src/utils/use-streamed-array.ts +17 -0
package/src/api/discovery.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const servers = {
|
|
|
15
15
|
generatedServerUrl: "https://discover-discover-core.dev.stackspot.com"
|
|
16
16
|
};
|
|
17
17
|
export type OpportunityResponse = {
|
|
18
|
-
id
|
|
18
|
+
id: string;
|
|
19
19
|
name?: string;
|
|
20
20
|
"number"?: string;
|
|
21
21
|
createdAt?: string;
|
|
@@ -25,14 +25,14 @@ export type OpportunityResponse = {
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
export type HypothesisResponse = {
|
|
28
|
-
id
|
|
29
|
-
opportunity
|
|
30
|
-
name
|
|
28
|
+
id: string;
|
|
29
|
+
opportunity: OpportunityResponse;
|
|
30
|
+
name: string;
|
|
31
31
|
description?: string;
|
|
32
|
-
"number"
|
|
33
|
-
status
|
|
32
|
+
"number": string;
|
|
33
|
+
status: "TO_DO" | "PRIORITIZED" | "IN_EXPERIMENTATION" | "VALIDATED" | "DISCARDED" | "CANCELED";
|
|
34
34
|
createdAt?: string;
|
|
35
|
-
createdBy
|
|
35
|
+
createdBy: string;
|
|
36
36
|
updatedAt?: string;
|
|
37
37
|
updatedBy?: string;
|
|
38
38
|
};
|
|
@@ -43,144 +43,188 @@ export type HypothesisUpdateRequest = {
|
|
|
43
43
|
status?: string;
|
|
44
44
|
};
|
|
45
45
|
export type SortResponse = {
|
|
46
|
-
direction
|
|
47
|
-
nullHandling
|
|
48
|
-
ascending
|
|
49
|
-
property
|
|
50
|
-
ignoreCase
|
|
46
|
+
direction: string;
|
|
47
|
+
nullHandling: string;
|
|
48
|
+
ascending: boolean;
|
|
49
|
+
property: string;
|
|
50
|
+
ignoreCase: boolean;
|
|
51
51
|
};
|
|
52
52
|
export type PageableResponse = {
|
|
53
|
-
offset
|
|
54
|
-
sort
|
|
55
|
-
paged
|
|
56
|
-
pageSize
|
|
57
|
-
pageNumber
|
|
58
|
-
unpaged
|
|
53
|
+
offset: number;
|
|
54
|
+
sort: SortResponse[];
|
|
55
|
+
paged: boolean;
|
|
56
|
+
pageSize: number;
|
|
57
|
+
pageNumber: number;
|
|
58
|
+
unpaged: boolean;
|
|
59
59
|
};
|
|
60
60
|
export type PageResponseHypothesisResponse = {
|
|
61
|
-
totalElements
|
|
62
|
-
totalPages
|
|
63
|
-
first
|
|
64
|
-
last
|
|
65
|
-
size
|
|
66
|
-
content
|
|
67
|
-
"number"
|
|
68
|
-
sort
|
|
69
|
-
numberOfElements
|
|
70
|
-
pageable
|
|
71
|
-
empty
|
|
61
|
+
totalElements: number;
|
|
62
|
+
totalPages: number;
|
|
63
|
+
first: boolean;
|
|
64
|
+
last: boolean;
|
|
65
|
+
size: number;
|
|
66
|
+
content: HypothesisResponse[];
|
|
67
|
+
"number": number;
|
|
68
|
+
sort: SortResponse[];
|
|
69
|
+
numberOfElements: number;
|
|
70
|
+
pageable: PageableResponse;
|
|
71
|
+
empty: boolean;
|
|
72
72
|
};
|
|
73
73
|
export type HypothesisCreateRequest = {
|
|
74
|
-
name
|
|
75
|
-
description
|
|
76
|
-
opportunityId
|
|
74
|
+
name: string;
|
|
75
|
+
description: string;
|
|
76
|
+
opportunityId: string;
|
|
77
77
|
};
|
|
78
78
|
export type DocumentUploadRequest = {
|
|
79
|
-
file
|
|
80
|
-
description
|
|
81
|
-
name
|
|
82
|
-
typeId
|
|
83
|
-
origin
|
|
84
|
-
};
|
|
85
|
-
export type DocumentAttachRequest = {
|
|
86
|
-
documentIds?: string[];
|
|
79
|
+
file: Blob;
|
|
80
|
+
description: string;
|
|
81
|
+
name: string;
|
|
82
|
+
typeId: string;
|
|
83
|
+
origin: "AI" | "UPLOAD";
|
|
87
84
|
};
|
|
88
85
|
export type AgentResponse = {
|
|
89
|
-
id
|
|
90
|
-
label
|
|
86
|
+
id: string;
|
|
87
|
+
label: string;
|
|
91
88
|
image?: string;
|
|
92
|
-
builtIn
|
|
93
|
-
slug
|
|
89
|
+
builtIn: boolean;
|
|
90
|
+
slug: string;
|
|
94
91
|
createdAt?: string;
|
|
95
92
|
};
|
|
96
93
|
export type DocumentTypeResponse = {
|
|
97
|
-
id
|
|
98
|
-
typeName
|
|
94
|
+
id: string;
|
|
95
|
+
typeName: "PRESS_RELEASE" | "PRODUCT_VISION" | "PRODUCT_REQUIREMENTS" | "MARKET_COMPARISON";
|
|
99
96
|
agent?: AgentResponse;
|
|
100
|
-
description
|
|
97
|
+
description: string;
|
|
98
|
+
createdAt?: string;
|
|
99
|
+
};
|
|
100
|
+
export type DocumentVersionSummaryResponse = {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string;
|
|
101
103
|
createdAt?: string;
|
|
104
|
+
createdBy?: string;
|
|
105
|
+
};
|
|
106
|
+
export type DocumentUploadResponse = {
|
|
107
|
+
id: string;
|
|
108
|
+
name: string;
|
|
109
|
+
description: string;
|
|
110
|
+
"type": DocumentTypeResponse;
|
|
111
|
+
origin: "AI" | "UPLOAD";
|
|
112
|
+
createdAt?: string;
|
|
113
|
+
createdBy: string;
|
|
114
|
+
version: DocumentVersionSummaryResponse;
|
|
115
|
+
};
|
|
116
|
+
export type DocumentAttachRequest = {
|
|
117
|
+
documentIds: string[];
|
|
102
118
|
};
|
|
103
119
|
export type DocumentDetailContent = {
|
|
104
|
-
hasPreview
|
|
120
|
+
hasPreview: boolean;
|
|
105
121
|
content?: string;
|
|
106
122
|
};
|
|
107
|
-
export type
|
|
108
|
-
id
|
|
109
|
-
name
|
|
110
|
-
description?: string;
|
|
111
|
-
"type"?: DocumentTypeResponse;
|
|
112
|
-
origin?: "AI" | "UPLOAD";
|
|
123
|
+
export type DocumentVersion = {
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
113
126
|
createdAt?: string;
|
|
114
127
|
createdBy?: string;
|
|
115
|
-
|
|
128
|
+
};
|
|
129
|
+
export type DocumentDetailResponse = {
|
|
130
|
+
id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
description: string;
|
|
133
|
+
"type": DocumentTypeResponse;
|
|
134
|
+
origin: "AI" | "UPLOAD";
|
|
135
|
+
createdAt?: string;
|
|
136
|
+
createdBy: string;
|
|
137
|
+
details: DocumentDetailContent;
|
|
138
|
+
version: DocumentVersion;
|
|
116
139
|
};
|
|
117
140
|
export type DocumentPatchRequest = {
|
|
118
|
-
file
|
|
141
|
+
file: Blob;
|
|
119
142
|
description?: string;
|
|
120
143
|
name?: string;
|
|
121
144
|
};
|
|
122
145
|
export type PageResponseOpportunityResponse = {
|
|
123
|
-
totalElements
|
|
124
|
-
totalPages
|
|
125
|
-
first
|
|
126
|
-
last
|
|
127
|
-
size
|
|
128
|
-
content
|
|
129
|
-
"number"
|
|
130
|
-
sort
|
|
131
|
-
numberOfElements
|
|
132
|
-
pageable
|
|
133
|
-
empty
|
|
146
|
+
totalElements: number;
|
|
147
|
+
totalPages: number;
|
|
148
|
+
first: boolean;
|
|
149
|
+
last: boolean;
|
|
150
|
+
size: number;
|
|
151
|
+
content: OpportunityResponse[];
|
|
152
|
+
"number": number;
|
|
153
|
+
sort: SortResponse[];
|
|
154
|
+
numberOfElements: number;
|
|
155
|
+
pageable: PageableResponse;
|
|
156
|
+
empty: boolean;
|
|
134
157
|
};
|
|
135
158
|
export type HypothesisSummaryResponse = {
|
|
136
|
-
id
|
|
137
|
-
name
|
|
138
|
-
"number"
|
|
139
|
-
status
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
"number": string;
|
|
162
|
+
status: "TO_DO" | "PRIORITIZED" | "IN_EXPERIMENTATION" | "VALIDATED" | "DISCARDED" | "CANCELED";
|
|
140
163
|
};
|
|
141
164
|
export type DocumentWithHypothesesResponse = {
|
|
142
|
-
id
|
|
143
|
-
name
|
|
165
|
+
id: string;
|
|
166
|
+
name: string;
|
|
144
167
|
description?: string;
|
|
145
|
-
origin
|
|
146
|
-
hypotheses
|
|
168
|
+
origin: "AI" | "UPLOAD";
|
|
169
|
+
hypotheses: HypothesisSummaryResponse[];
|
|
147
170
|
createdAt?: string;
|
|
148
|
-
createdBy
|
|
171
|
+
createdBy: string;
|
|
149
172
|
};
|
|
150
173
|
export type PageResponseDocumentWithHypothesesResponse = {
|
|
151
|
-
totalElements
|
|
152
|
-
totalPages
|
|
153
|
-
first
|
|
154
|
-
last
|
|
155
|
-
size
|
|
156
|
-
content
|
|
157
|
-
"number"
|
|
158
|
-
sort
|
|
159
|
-
numberOfElements
|
|
160
|
-
pageable
|
|
161
|
-
empty
|
|
174
|
+
totalElements: number;
|
|
175
|
+
totalPages: number;
|
|
176
|
+
first: boolean;
|
|
177
|
+
last: boolean;
|
|
178
|
+
size: number;
|
|
179
|
+
content: DocumentWithHypothesesResponse[];
|
|
180
|
+
"number": number;
|
|
181
|
+
sort: SortResponse[];
|
|
182
|
+
numberOfElements: number;
|
|
183
|
+
pageable: PageableResponse;
|
|
184
|
+
empty: boolean;
|
|
162
185
|
};
|
|
163
|
-
export type
|
|
164
|
-
id
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
hasMultipleHypotheses?: boolean;
|
|
186
|
+
export type DocumentVersionResponse = {
|
|
187
|
+
id: string;
|
|
188
|
+
documentId: string;
|
|
189
|
+
versionName: string;
|
|
190
|
+
s3VersionId: string;
|
|
169
191
|
createdAt?: string;
|
|
170
192
|
createdBy?: string;
|
|
171
193
|
};
|
|
194
|
+
export type PageResponseDocumentVersionResponse = {
|
|
195
|
+
totalElements: number;
|
|
196
|
+
totalPages: number;
|
|
197
|
+
first: boolean;
|
|
198
|
+
last: boolean;
|
|
199
|
+
size: number;
|
|
200
|
+
content: DocumentVersionResponse[];
|
|
201
|
+
"number": number;
|
|
202
|
+
sort: SortResponse[];
|
|
203
|
+
numberOfElements: number;
|
|
204
|
+
pageable: PageableResponse;
|
|
205
|
+
empty: boolean;
|
|
206
|
+
};
|
|
207
|
+
export type DocumentSummaryResponse = {
|
|
208
|
+
id: string;
|
|
209
|
+
name: string;
|
|
210
|
+
description: string;
|
|
211
|
+
origin: "AI" | "UPLOAD";
|
|
212
|
+
hasMultipleHypotheses: boolean;
|
|
213
|
+
createdAt?: string;
|
|
214
|
+
createdBy: string;
|
|
215
|
+
};
|
|
172
216
|
export type PageResponseDocumentSummaryResponse = {
|
|
173
|
-
totalElements
|
|
174
|
-
totalPages
|
|
175
|
-
first
|
|
176
|
-
last
|
|
177
|
-
size
|
|
178
|
-
content
|
|
179
|
-
"number"
|
|
180
|
-
sort
|
|
181
|
-
numberOfElements
|
|
182
|
-
pageable
|
|
183
|
-
empty
|
|
217
|
+
totalElements: number;
|
|
218
|
+
totalPages: number;
|
|
219
|
+
first: boolean;
|
|
220
|
+
last: boolean;
|
|
221
|
+
size: number;
|
|
222
|
+
content: DocumentSummaryResponse[];
|
|
223
|
+
"number": number;
|
|
224
|
+
sort: SortResponse[];
|
|
225
|
+
numberOfElements: number;
|
|
226
|
+
pageable: PageableResponse;
|
|
227
|
+
empty: boolean;
|
|
184
228
|
};
|
|
185
229
|
export function findHypothesisById({ hypothesisId }: {
|
|
186
230
|
hypothesisId: string;
|
|
@@ -248,7 +292,10 @@ export function upload({ hypothesisId, documentUploadRequest }: {
|
|
|
248
292
|
hypothesisId: string;
|
|
249
293
|
documentUploadRequest?: DocumentUploadRequest;
|
|
250
294
|
}, opts?: Oazapfts.RequestOpts) {
|
|
251
|
-
return oazapfts.ok(oazapfts.
|
|
295
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
296
|
+
status: 200;
|
|
297
|
+
data: DocumentUploadResponse;
|
|
298
|
+
}>(`/v1/documents/hypotheses/${encodeURIComponent(hypothesisId)}/upload`, oazapfts.multipart({
|
|
252
299
|
...opts,
|
|
253
300
|
method: "POST",
|
|
254
301
|
body: documentUploadRequest
|
|
@@ -264,13 +311,16 @@ export function attach({ hypothesisId, documentAttachRequest }: {
|
|
|
264
311
|
body: documentAttachRequest
|
|
265
312
|
})));
|
|
266
313
|
}
|
|
267
|
-
export function getById({ documentId }: {
|
|
314
|
+
export function getById({ documentId, versionId }: {
|
|
268
315
|
documentId: string;
|
|
316
|
+
versionId?: string;
|
|
269
317
|
}, opts?: Oazapfts.RequestOpts) {
|
|
270
318
|
return oazapfts.ok(oazapfts.fetchJson<{
|
|
271
319
|
status: 200;
|
|
272
320
|
data: DocumentDetailResponse;
|
|
273
|
-
}>(`/v1/documents/${encodeURIComponent(documentId)}
|
|
321
|
+
}>(`/v1/documents/${encodeURIComponent(documentId)}${QS.query(QS.explode({
|
|
322
|
+
versionId
|
|
323
|
+
}))}`, {
|
|
274
324
|
...opts
|
|
275
325
|
}));
|
|
276
326
|
}
|
|
@@ -334,6 +384,21 @@ export function listAllDocumentsWithHypotheses({ filter, page, size, sort, direc
|
|
|
334
384
|
...opts
|
|
335
385
|
}));
|
|
336
386
|
}
|
|
387
|
+
export function listVersions({ documentId, page, size }: {
|
|
388
|
+
documentId: string;
|
|
389
|
+
page?: number;
|
|
390
|
+
size?: number;
|
|
391
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
392
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
393
|
+
status: 200;
|
|
394
|
+
data: PageResponseDocumentVersionResponse;
|
|
395
|
+
}>(`/v1/documents/${encodeURIComponent(documentId)}/versions${QS.query(QS.explode({
|
|
396
|
+
page,
|
|
397
|
+
size
|
|
398
|
+
}))}`, {
|
|
399
|
+
...opts
|
|
400
|
+
}));
|
|
401
|
+
}
|
|
337
402
|
export function download({ documentId }: {
|
|
338
403
|
documentId: string;
|
|
339
404
|
}, opts?: Oazapfts.RequestOpts) {
|
|
@@ -373,6 +438,26 @@ export function getAll(opts?: Oazapfts.RequestOpts) {
|
|
|
373
438
|
...opts
|
|
374
439
|
}));
|
|
375
440
|
}
|
|
441
|
+
export function systemHealth(opts?: Oazapfts.RequestOpts) {
|
|
442
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
443
|
+
status: 200;
|
|
444
|
+
data: {
|
|
445
|
+
[key: string]: object;
|
|
446
|
+
};
|
|
447
|
+
}>("/system/health", {
|
|
448
|
+
...opts
|
|
449
|
+
}));
|
|
450
|
+
}
|
|
451
|
+
export function health(opts?: Oazapfts.RequestOpts) {
|
|
452
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
453
|
+
status: 200;
|
|
454
|
+
data: {
|
|
455
|
+
[key: string]: string;
|
|
456
|
+
};
|
|
457
|
+
}>("/orchestrator/health", {
|
|
458
|
+
...opts
|
|
459
|
+
}));
|
|
460
|
+
}
|
|
376
461
|
export function deleteV1DocumentsByDocumentIdHypothesesAndHypothesisId({ hypothesisId, documentId }: {
|
|
377
462
|
hypothesisId: string;
|
|
378
463
|
documentId: string;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
-
import {
|
|
2
|
+
import { createToolkitToolsV1ToolkitsToolkitIdToolsPost, createToolkitV1ToolkitsPost, defaults, deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete, deleteToolkitV1ToolkitsToolkitIdDelete, editToolkitToolV1ToolkitsToolkitIdToolsToolIdPut, 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
|
+
import { FetchEventStream } from '../network/types'
|
|
6
7
|
import { removeAuthorizationParam } from '../utils/remove-authorization-param'
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
const AGENT_DEFAULT_SLUG = 'stk_code_buddy'
|
|
8
|
+
import { StreamedArray } from '../utils/StreamedArray'
|
|
9
|
+
import { AgentToolsOpenAPIPreview } from './types'
|
|
11
10
|
|
|
12
11
|
class AgentToolsClient extends ReactQueryNetworkClient {
|
|
13
12
|
constructor() {
|
|
@@ -27,104 +26,8 @@ class AgentToolsClient extends ReactQueryNetworkClient {
|
|
|
27
26
|
tools = this.query(removeAuthorizationParam(getPublicToolKitsV1BuiltinToolkitGet))
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
createAgent = this.mutation(removeAuthorizationParam(createAgentV1AgentsPost))
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Delete agent
|
|
36
|
-
*/
|
|
37
|
-
deleteAgent = this.mutation(deleteAgentV1AgentsAgentIdDelete)
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Updates an agent
|
|
41
|
-
*/
|
|
42
|
-
updateAgent = this.mutation(updateAgentV1AgentsAgentIdPut)
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Favorite an agent
|
|
46
|
-
*/
|
|
47
|
-
favoriteAgent = this.mutation(addFavoriteV1AgentsAgentIdFavoritePost)
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Publish an agent
|
|
51
|
-
*/
|
|
52
|
-
publishAgent = this.mutation(publishAgentV1AgentsAgentIdPublishPost)
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* List agents
|
|
56
|
-
*/
|
|
57
|
-
agents = this.infiniteQuery(removeAuthorizationParam(listAgentsV1AgentsGet))
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Gets agent by id
|
|
61
|
-
*/
|
|
62
|
-
agent = this.query(removeAuthorizationParam(getAgentV1AgentsAgentIdGet))
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Gets agents by ids
|
|
66
|
-
*/
|
|
67
|
-
agentsByIds = this.query(removeAuthorizationParam(searchAgentsV1AgentsSearchPost))
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Gets the default agent slug
|
|
71
|
-
*/
|
|
72
|
-
agentDefaultSlug = AGENT_DEFAULT_SLUG
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Gets the default agent
|
|
29
|
+
* Get list of Toolkits
|
|
76
30
|
*/
|
|
77
|
-
agentDefault = this.query({
|
|
78
|
-
name: 'agentDefault',
|
|
79
|
-
request: async (signal) => {
|
|
80
|
-
const agentDefault = await listAgentsV1AgentsGet(
|
|
81
|
-
{ visibility: 'built_in', slug: this.agentDefaultSlug, authorization: '' }, { signal },
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
const agentId = agentDefault.at(0)?.id
|
|
85
|
-
const agent = agentId ? await this.agent.query({ agentId }) : undefined
|
|
86
|
-
return agent
|
|
87
|
-
},
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* List agents filtered by visibility.
|
|
92
|
-
*/
|
|
93
|
-
allAgents = this.query({
|
|
94
|
-
name: 'allAgents',
|
|
95
|
-
request: async (signal, variables: { visibilities: (AgentVisibilityLevel | 'all')[] }) => {
|
|
96
|
-
const allVisibilities = ['account', 'built_in', 'favorite', 'personal', 'shared', 'workspace'] as const
|
|
97
|
-
const visibilities = variables.visibilities.includes('all')
|
|
98
|
-
? allVisibilities
|
|
99
|
-
: variables.visibilities as Array<AgentVisibilityLevelEnum | VisibilityLevelEnum>
|
|
100
|
-
|
|
101
|
-
const shouldFetchWorkspaceAgents = visibilities.includes('workspace')
|
|
102
|
-
|
|
103
|
-
const workspaceAgentsPromise = shouldFetchWorkspaceAgents
|
|
104
|
-
? workspaceAiClient.workspacesContentsByType.query({ contentType: 'agent' })
|
|
105
|
-
: Promise.resolve([])
|
|
106
|
-
|
|
107
|
-
const [workspaceAgents, ...agentsByVisibility] = await Promise.all([
|
|
108
|
-
workspaceAgentsPromise,
|
|
109
|
-
...visibilities.map((visibility) => listAgentsV1AgentsGet({ visibility, authorization: '' }, { signal })),
|
|
110
|
-
])
|
|
111
|
-
|
|
112
|
-
const workspaceAgentsWithSpaceName = workspaceAgents.flatMap(({ agents, space_name }) =>
|
|
113
|
-
agents?.map((agent) => ({ ...agent, spaceName: space_name, builtIn: false }))) as AgentResponseWithBuiltIn[]
|
|
114
|
-
|
|
115
|
-
const allAgents: AgentResponseWithBuiltIn[] = workspaceAgentsWithSpaceName ?? []
|
|
116
|
-
|
|
117
|
-
agentsByVisibility.forEach(agents => allAgents.push(...agents.map(agent => ({
|
|
118
|
-
...agent,
|
|
119
|
-
builtIn: agent?.visibility_level === 'built_in',
|
|
120
|
-
}))))
|
|
121
|
-
|
|
122
|
-
return allAgents
|
|
123
|
-
},
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
/* Get list of Toolkits
|
|
127
|
-
*/
|
|
128
31
|
toolkits = this.query(removeAuthorizationParam(listToolkitsV1ToolkitsGet))
|
|
129
32
|
/**
|
|
130
33
|
* Get a toolkit by Id
|
|
@@ -159,22 +62,19 @@ class AgentToolsClient extends ReactQueryNetworkClient {
|
|
|
159
62
|
*/
|
|
160
63
|
deleteToolFromToolkit = this.mutation(removeAuthorizationParam(deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete))
|
|
161
64
|
/**
|
|
162
|
-
* Previews an uploaded open api file.
|
|
65
|
+
* Previews an uploaded open api file as a stream where each array item is an OpenAPI operation.
|
|
66
|
+
*/
|
|
67
|
+
streamUploadedAPIs = ({ fileUploadIds, signal }: { fileUploadIds: string[], signal?: AbortSignal }) => {
|
|
68
|
+
const promises: Promise<FetchEventStream>[] = fileUploadIds.map((id) => {
|
|
69
|
+
const url = `/v1/toolkits/tools/preview/${encodeURIComponent(id)}`
|
|
70
|
+
return this.stream(url, { signal })
|
|
71
|
+
})
|
|
72
|
+
return new StreamedArray<AgentToolsOpenAPIPreview>({ eventsPromises: promises, signal })
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Lists the agents using the tools passed as parameter.
|
|
163
76
|
*/
|
|
164
|
-
|
|
165
|
-
name: 'previewUploadedAPI',
|
|
166
|
-
request: async (signal, params: { fileUploadId: string }) => {
|
|
167
|
-
const url = `/v1/toolkits/tools/preview/${encodeURIComponent(params.fileUploadId)}`
|
|
168
|
-
const events = await this.stream(url, { signal })
|
|
169
|
-
const result: AgentToolsOpenAPIPreview[] = []
|
|
170
|
-
for await (const event of events) {
|
|
171
|
-
if (event.data) {
|
|
172
|
-
result.push(JSON.parse(event.data))
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return result
|
|
176
|
-
},
|
|
177
|
-
})
|
|
77
|
+
agentsUsingTools = this.query(removeAuthorizationParam(listAgentsUsingToolsV1ToolkitsToolkitIdToolsAgentsPost))
|
|
178
78
|
}
|
|
179
79
|
|
|
180
80
|
export const agentToolsClient = new AgentToolsClient()
|
package/src/client/agent.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
defaults, deleteV1AgentByAgentIdFavorite, getV1AgentByAgentId, getV1Agents, getV1PublicAgentByAgentId, getV1PublicAgents,
|
|
4
|
+
postV1AgentByAgentIdFavorite, putV1AgentByAgentId,
|
|
5
|
+
VisibilityLevel,
|
|
6
|
+
} from '../api/agent'
|
|
3
7
|
import apis from '../apis.json'
|
|
4
8
|
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
5
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'
|
|
6
14
|
|
|
7
15
|
interface AgentError {
|
|
8
16
|
code?: string,
|
|
@@ -28,6 +36,57 @@ class AgentClient extends ReactQueryNetworkClient {
|
|
|
28
36
|
})
|
|
29
37
|
}
|
|
30
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
|
+
|
|
31
90
|
/**
|
|
32
91
|
* Gets an agent by id
|
|
33
92
|
*/
|
|
@@ -38,6 +97,18 @@ class AgentClient extends ReactQueryNetworkClient {
|
|
|
38
97
|
: getV1AgentByAgentId({ ...variables }, { signal }),
|
|
39
98
|
})
|
|
40
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
|
+
|
|
41
112
|
/**
|
|
42
113
|
* List commons agents
|
|
43
114
|
*/
|
|
@@ -67,11 +138,6 @@ class AgentClient extends ReactQueryNetworkClient {
|
|
|
67
138
|
* Removes the resource of type Agent from the list of favorites.
|
|
68
139
|
*/
|
|
69
140
|
removeFavoriteAgent = this.mutation(deleteV1AgentByAgentIdFavorite)
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Create a test agent if it does not exist
|
|
73
|
-
*/
|
|
74
|
-
createTrialAgents = this.mutation(postV1AgentsTrial)
|
|
75
141
|
/**
|
|
76
142
|
* Updates an agent
|
|
77
143
|
*/
|