@stack-spot/portal-network 0.139.0 → 0.139.1-beta.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/dist/api/agent-tools.d.ts +178 -4
- package/dist/api/agent-tools.d.ts.map +1 -1
- package/dist/api/agent-tools.js +98 -2
- package/dist/api/agent-tools.js.map +1 -1
- package/dist/client/agent-tools.d.ts +77 -0
- package/dist/client/agent-tools.d.ts.map +1 -1
- package/dist/client/agent-tools.js +134 -1
- package/dist/client/agent-tools.js.map +1 -1
- package/dist/client/agent.d.ts +2 -49
- package/dist/client/agent.d.ts.map +1 -1
- package/dist/client/agent.js +0 -63
- package/dist/client/agent.js.map +1 -1
- package/dist/client/ai.d.ts +7 -0
- package/dist/client/ai.d.ts.map +1 -1
- package/dist/client/ai.js +10 -1
- package/dist/client/ai.js.map +1 -1
- package/dist/client/types.d.ts +5 -3
- package/dist/client/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/agent-tools.ts +306 -4
- package/src/client/agent-tools.ts +103 -1
- package/src/client/agent.ts +1 -67
- package/src/client/ai.ts +5 -0
- package/src/client/types.ts +7 -4
package/src/api/agent-tools.ts
CHANGED
|
@@ -45,7 +45,9 @@ export type FunctionParameter = {
|
|
|
45
45
|
/** A list of possible values for the parameter (optional) */
|
|
46
46
|
"enum"?: string[] | null;
|
|
47
47
|
/** A dictionary of properties for the parameter (optional) */
|
|
48
|
-
properties?:
|
|
48
|
+
properties?: {
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
} | null;
|
|
49
51
|
/** A list of required parameters (optional) */
|
|
50
52
|
required?: string[] | null;
|
|
51
53
|
/** Allow arbitrary data of specific typed */
|
|
@@ -73,6 +75,115 @@ export type ExecuteAgentToolRequest = {
|
|
|
73
75
|
export type AgentToolExecutionResponse = {
|
|
74
76
|
result: string;
|
|
75
77
|
};
|
|
78
|
+
export type AgentVisibilityLevelEnum = "built_in";
|
|
79
|
+
export type VisibilityLevelEnum = "account" | "personal" | "shared" | "workspace" | "favorite";
|
|
80
|
+
export type ListAgentResponse = {
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
slug: string;
|
|
84
|
+
created_by: string | null;
|
|
85
|
+
visibility_level: string;
|
|
86
|
+
avatar: string | null;
|
|
87
|
+
conversation_starter: string[] | null;
|
|
88
|
+
};
|
|
89
|
+
export type AgentType = "CONVERSATIONAL" | "SINGLE_ANSWER";
|
|
90
|
+
export type SimilarityFunctionEnum = "cosine" | "euclidean" | "dot_product";
|
|
91
|
+
export type KnowledgeSourcesConfigRequest = {
|
|
92
|
+
similarity_function?: SimilarityFunctionEnum | null;
|
|
93
|
+
post_processing?: boolean | null;
|
|
94
|
+
max_number_of_kos?: number | null;
|
|
95
|
+
relevancy_threshold?: number | null;
|
|
96
|
+
knowledge_sources?: string[] | null;
|
|
97
|
+
sealed?: boolean | null;
|
|
98
|
+
};
|
|
99
|
+
export type NewAgentRequest = {
|
|
100
|
+
/** LLM model name */
|
|
101
|
+
model_name?: string | null;
|
|
102
|
+
/** LLM model id */
|
|
103
|
+
model_id?: string | null;
|
|
104
|
+
/** Agent name */
|
|
105
|
+
name: string;
|
|
106
|
+
/** Agent unique slug */
|
|
107
|
+
slug: string;
|
|
108
|
+
/** Agent description */
|
|
109
|
+
description?: string | null;
|
|
110
|
+
/** Agent avatar image */
|
|
111
|
+
avatar?: string | null;
|
|
112
|
+
/** Agent suggested prompt */
|
|
113
|
+
suggested_prompts?: string[];
|
|
114
|
+
/** System prompt */
|
|
115
|
+
system_prompt?: string | null;
|
|
116
|
+
/** Agent type */
|
|
117
|
+
"type": AgentType;
|
|
118
|
+
knowledge_sources_config?: KnowledgeSourcesConfigRequest | null;
|
|
119
|
+
builtin_tools_ids?: string[];
|
|
120
|
+
detail_mode?: boolean;
|
|
121
|
+
structured_output?: string | null;
|
|
122
|
+
llm_settings?: {
|
|
123
|
+
[key: string]: any;
|
|
124
|
+
} | null;
|
|
125
|
+
};
|
|
126
|
+
export type NewAgentResponse = {
|
|
127
|
+
id: string;
|
|
128
|
+
};
|
|
129
|
+
export type SearchAgentsRequest = {
|
|
130
|
+
/** Agent ids to filter for */
|
|
131
|
+
ids: string[];
|
|
132
|
+
};
|
|
133
|
+
export type KnowledgeSourceConfigModel = {
|
|
134
|
+
similarity_function: SimilarityFunctionEnum;
|
|
135
|
+
max_number_of_kos: number;
|
|
136
|
+
relevancy_threshold: number;
|
|
137
|
+
post_processing: boolean;
|
|
138
|
+
knowledge_sources: string[];
|
|
139
|
+
sealed: boolean;
|
|
140
|
+
created_by?: string | null;
|
|
141
|
+
created_at?: string | null;
|
|
142
|
+
updated_by?: string | null;
|
|
143
|
+
updated_at?: string | null;
|
|
144
|
+
};
|
|
145
|
+
export type AgentToolModel = {
|
|
146
|
+
agent_id: string;
|
|
147
|
+
builtin_tool_id: string;
|
|
148
|
+
builtin_toolkit_id?: string | null;
|
|
149
|
+
created_by?: string | null;
|
|
150
|
+
created_at?: string | null;
|
|
151
|
+
updated_by?: string | null;
|
|
152
|
+
updated_at?: string | null;
|
|
153
|
+
};
|
|
154
|
+
export type LlmSettingsModel = {
|
|
155
|
+
property_key?: string | null;
|
|
156
|
+
property_value?: string | null;
|
|
157
|
+
property_type?: string | null;
|
|
158
|
+
agent_id: string;
|
|
159
|
+
created_by?: string | null;
|
|
160
|
+
created_at?: string | null;
|
|
161
|
+
updated_by?: string | null;
|
|
162
|
+
updated_at?: string | null;
|
|
163
|
+
};
|
|
164
|
+
export type AgentModel = {
|
|
165
|
+
id: string;
|
|
166
|
+
name: string;
|
|
167
|
+
slug: string;
|
|
168
|
+
description?: string | null;
|
|
169
|
+
system_prompt: string;
|
|
170
|
+
visibility_level: string;
|
|
171
|
+
avatar?: string | null;
|
|
172
|
+
"type": string;
|
|
173
|
+
conversation_starter?: string[] | null;
|
|
174
|
+
use_only: boolean;
|
|
175
|
+
detail_mode: boolean;
|
|
176
|
+
structured_output?: string | null;
|
|
177
|
+
model_id?: string | null;
|
|
178
|
+
model_name?: string | null;
|
|
179
|
+
knowledge_source_config?: KnowledgeSourceConfigModel | null;
|
|
180
|
+
tools?: AgentToolModel[];
|
|
181
|
+
settings?: LlmSettingsModel[];
|
|
182
|
+
created_by?: string | null;
|
|
183
|
+
created_at?: string | null;
|
|
184
|
+
updated_by?: string | null;
|
|
185
|
+
updated_at?: string | null;
|
|
186
|
+
};
|
|
76
187
|
/**
|
|
77
188
|
* Health Check
|
|
78
189
|
*/
|
|
@@ -87,9 +198,9 @@ export function healthCheckHealthzGet(opts?: Oazapfts.RequestOpts) {
|
|
|
87
198
|
}));
|
|
88
199
|
}
|
|
89
200
|
/**
|
|
90
|
-
*
|
|
201
|
+
* Readyz
|
|
91
202
|
*/
|
|
92
|
-
export function
|
|
203
|
+
export function readyzReadyzGet(opts?: Oazapfts.RequestOpts) {
|
|
93
204
|
return oazapfts.ok(oazapfts.fetchJson<{
|
|
94
205
|
status: 200;
|
|
95
206
|
data: any;
|
|
@@ -207,7 +318,9 @@ export function listToolsByAgentForSchemaV1AgentsAgentIdToolsSchemaSchemaGet({ a
|
|
|
207
318
|
}, opts?: Oazapfts.RequestOpts) {
|
|
208
319
|
return oazapfts.ok(oazapfts.fetchJson<{
|
|
209
320
|
status: 200;
|
|
210
|
-
data: (OpenAiTool |
|
|
321
|
+
data: (OpenAiTool | {
|
|
322
|
+
[key: string]: any;
|
|
323
|
+
})[];
|
|
211
324
|
} | {
|
|
212
325
|
status: 404;
|
|
213
326
|
} | {
|
|
@@ -253,3 +366,192 @@ export function executeToolV1AgentsToolsAgentToolIdExecutePost({ agentToolId, is
|
|
|
253
366
|
})
|
|
254
367
|
})));
|
|
255
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* List Agents
|
|
371
|
+
*/
|
|
372
|
+
export function listAgentsV1AgentsGet({ name, slug, visibility, size, page, xAccountId, authorization }: {
|
|
373
|
+
name?: string | null;
|
|
374
|
+
slug?: string | null;
|
|
375
|
+
visibility?: AgentVisibilityLevelEnum | VisibilityLevelEnum;
|
|
376
|
+
size?: number;
|
|
377
|
+
page?: number;
|
|
378
|
+
xAccountId?: string | null;
|
|
379
|
+
authorization: string;
|
|
380
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
381
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
382
|
+
status: 200;
|
|
383
|
+
data: ListAgentResponse[];
|
|
384
|
+
} | {
|
|
385
|
+
status: 404;
|
|
386
|
+
} | {
|
|
387
|
+
status: 422;
|
|
388
|
+
data: HttpValidationError;
|
|
389
|
+
}>(`/v1/agents${QS.query(QS.explode({
|
|
390
|
+
name,
|
|
391
|
+
slug,
|
|
392
|
+
visibility,
|
|
393
|
+
size,
|
|
394
|
+
page
|
|
395
|
+
}))}`, {
|
|
396
|
+
...opts,
|
|
397
|
+
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
398
|
+
"x-account-id": xAccountId,
|
|
399
|
+
authorization
|
|
400
|
+
})
|
|
401
|
+
}));
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Create Agent
|
|
405
|
+
*/
|
|
406
|
+
export function createAgentV1AgentsPost({ isPublic, xAccountId, authorization, newAgentRequest }: {
|
|
407
|
+
isPublic?: boolean;
|
|
408
|
+
xAccountId?: string | null;
|
|
409
|
+
authorization: string;
|
|
410
|
+
newAgentRequest: NewAgentRequest;
|
|
411
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
412
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
413
|
+
status: 201;
|
|
414
|
+
data: NewAgentResponse;
|
|
415
|
+
} | {
|
|
416
|
+
status: 404;
|
|
417
|
+
} | {
|
|
418
|
+
status: 422;
|
|
419
|
+
data: HttpValidationError;
|
|
420
|
+
}>(`/v1/agents${QS.query(QS.explode({
|
|
421
|
+
is_public: isPublic
|
|
422
|
+
}))}`, oazapfts.json({
|
|
423
|
+
...opts,
|
|
424
|
+
method: "POST",
|
|
425
|
+
body: newAgentRequest,
|
|
426
|
+
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
427
|
+
"x-account-id": xAccountId,
|
|
428
|
+
authorization
|
|
429
|
+
})
|
|
430
|
+
})));
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Search Agents
|
|
434
|
+
*/
|
|
435
|
+
export function searchAgentsV1AgentsSearchPost({ xAccountId, authorization, searchAgentsRequest }: {
|
|
436
|
+
xAccountId?: string | null;
|
|
437
|
+
authorization: string;
|
|
438
|
+
searchAgentsRequest: SearchAgentsRequest;
|
|
439
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
440
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
441
|
+
status: 200;
|
|
442
|
+
data: ListAgentResponse[];
|
|
443
|
+
} | {
|
|
444
|
+
status: 404;
|
|
445
|
+
} | {
|
|
446
|
+
status: 422;
|
|
447
|
+
data: HttpValidationError;
|
|
448
|
+
}>("/v1/agents/search", oazapfts.json({
|
|
449
|
+
...opts,
|
|
450
|
+
method: "POST",
|
|
451
|
+
body: searchAgentsRequest,
|
|
452
|
+
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
453
|
+
"x-account-id": xAccountId,
|
|
454
|
+
authorization
|
|
455
|
+
})
|
|
456
|
+
})));
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Get Agent
|
|
460
|
+
*/
|
|
461
|
+
export function getAgentV1AgentsAgentIdGet({ agentId, xAccountId, authorization }: {
|
|
462
|
+
agentId: string;
|
|
463
|
+
xAccountId?: string | null;
|
|
464
|
+
authorization: string;
|
|
465
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
466
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
467
|
+
status: 200;
|
|
468
|
+
data: AgentModel;
|
|
469
|
+
} | {
|
|
470
|
+
status: 404;
|
|
471
|
+
} | {
|
|
472
|
+
status: 422;
|
|
473
|
+
data: HttpValidationError;
|
|
474
|
+
}>(`/v1/agents/${encodeURIComponent(agentId)}`, {
|
|
475
|
+
...opts,
|
|
476
|
+
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
477
|
+
"x-account-id": xAccountId,
|
|
478
|
+
authorization
|
|
479
|
+
})
|
|
480
|
+
}));
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Update Agent
|
|
484
|
+
*/
|
|
485
|
+
export function updateAgentV1AgentsAgentIdPut({ agentId }: {
|
|
486
|
+
agentId: string;
|
|
487
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
488
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
489
|
+
status: 200;
|
|
490
|
+
data: any;
|
|
491
|
+
} | {
|
|
492
|
+
status: 404;
|
|
493
|
+
} | {
|
|
494
|
+
status: 422;
|
|
495
|
+
data: HttpValidationError;
|
|
496
|
+
}>(`/v1/agents/${encodeURIComponent(agentId)}`, {
|
|
497
|
+
...opts,
|
|
498
|
+
method: "PUT"
|
|
499
|
+
}));
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Delete Agent
|
|
503
|
+
*/
|
|
504
|
+
export function deleteAgentV1AgentsAgentIdDelete({ agentId }: {
|
|
505
|
+
agentId: string;
|
|
506
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
507
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
508
|
+
status: 200;
|
|
509
|
+
data: any;
|
|
510
|
+
} | {
|
|
511
|
+
status: 404;
|
|
512
|
+
} | {
|
|
513
|
+
status: 422;
|
|
514
|
+
data: HttpValidationError;
|
|
515
|
+
}>(`/v1/agents/${encodeURIComponent(agentId)}`, {
|
|
516
|
+
...opts,
|
|
517
|
+
method: "DELETE"
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Add Favorite
|
|
522
|
+
*/
|
|
523
|
+
export function addFavoriteV1AgentsAgentIdFavoritePost({ agentId }: {
|
|
524
|
+
agentId: string;
|
|
525
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
526
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
527
|
+
status: 200;
|
|
528
|
+
data: any;
|
|
529
|
+
} | {
|
|
530
|
+
status: 404;
|
|
531
|
+
} | {
|
|
532
|
+
status: 422;
|
|
533
|
+
data: HttpValidationError;
|
|
534
|
+
}>(`/v1/agents/${encodeURIComponent(agentId)}/favorite`, {
|
|
535
|
+
...opts,
|
|
536
|
+
method: "POST"
|
|
537
|
+
}));
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Publish Agent
|
|
541
|
+
*/
|
|
542
|
+
export function publishAgentV1AgentsAgentIdPublishPost({ agentId }: {
|
|
543
|
+
agentId: string;
|
|
544
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
545
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
546
|
+
status: 200;
|
|
547
|
+
data: any;
|
|
548
|
+
} | {
|
|
549
|
+
status: 404;
|
|
550
|
+
} | {
|
|
551
|
+
status: 422;
|
|
552
|
+
data: HttpValidationError;
|
|
553
|
+
}>(`/v1/agents/${encodeURIComponent(agentId)}/publish`, {
|
|
554
|
+
...opts,
|
|
555
|
+
method: "POST"
|
|
556
|
+
}));
|
|
557
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
-
import { defaults, getPublicToolKitsV1BuiltinToolkitGet, HttpValidationError } from '../api/agent-tools'
|
|
2
|
+
import { addFavoriteV1AgentsAgentIdFavoritePost, AgentVisibilityLevelEnum, createAgentV1AgentsPost, defaults, deleteAgentV1AgentsAgentIdDelete, getAgentV1AgentsAgentIdGet, getPublicToolKitsV1BuiltinToolkitGet, HttpValidationError, listAgentsV1AgentsGet, publishAgentV1AgentsAgentIdPublishPost, searchAgentsV1AgentsSearchPost, updateAgentV1AgentsAgentIdPut, VisibilityLevelEnum } 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 { removeAuthorizationParam } from '../utils/remove-authorization-param'
|
|
7
|
+
import { AgentResponseWithBuiltIn, AgentVisibilityLevel } from './types'
|
|
8
|
+
import { workspaceAiClient } from './workspace-ai'
|
|
9
|
+
|
|
10
|
+
const AGENT_DEFAULT_SLUG = 'stk_code_buddy'
|
|
6
11
|
|
|
7
12
|
class AgentToolsClient extends ReactQueryNetworkClient {
|
|
8
13
|
constructor() {
|
|
@@ -19,6 +24,103 @@ class AgentToolsClient extends ReactQueryNetworkClient {
|
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
tools = this.query(getPublicToolKitsV1BuiltinToolkitGet)
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Create agent
|
|
30
|
+
*/
|
|
31
|
+
createAgent = this.mutation(removeAuthorizationParam(createAgentV1AgentsPost))
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Delete agent
|
|
35
|
+
*/
|
|
36
|
+
deleteAgent = this.mutation(deleteAgentV1AgentsAgentIdDelete)
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Updates an agent
|
|
40
|
+
*/
|
|
41
|
+
updateAgent = this.mutation(updateAgentV1AgentsAgentIdPut)
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Favorite an agent
|
|
45
|
+
*/
|
|
46
|
+
favoriteAgent = this.mutation(addFavoriteV1AgentsAgentIdFavoritePost)
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Publish an agent
|
|
50
|
+
*/
|
|
51
|
+
publishAgent = this.mutation(publishAgentV1AgentsAgentIdPublishPost)
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* List agents
|
|
55
|
+
*/
|
|
56
|
+
agents = this.infiniteQuery(removeAuthorizationParam(listAgentsV1AgentsGet))
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Gets agent by id
|
|
60
|
+
*/
|
|
61
|
+
agent = this.query(removeAuthorizationParam(getAgentV1AgentsAgentIdGet))
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Gets agents by ids
|
|
65
|
+
*/
|
|
66
|
+
agentsByIds = this.query(removeAuthorizationParam(searchAgentsV1AgentsSearchPost))
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Gets the default agent slug
|
|
70
|
+
*/
|
|
71
|
+
agentDefaultSlug = AGENT_DEFAULT_SLUG
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets the default agent
|
|
75
|
+
*/
|
|
76
|
+
agentDefault = this.query({
|
|
77
|
+
name: 'agentDefault',
|
|
78
|
+
request: async (signal) => {
|
|
79
|
+
const agentDefault = await listAgentsV1AgentsGet(
|
|
80
|
+
{ visibility: 'built_in', slug: this.agentDefaultSlug, authorization: '' }, { signal },
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
const agentId = agentDefault.at(0)?.id
|
|
84
|
+
const agent = agentId ? await this.agent.query({ agentId }) : undefined
|
|
85
|
+
return agent
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* List agents filtered by visibility.
|
|
91
|
+
*/
|
|
92
|
+
allAgents = this.query({
|
|
93
|
+
name: 'allAgents',
|
|
94
|
+
request: async (signal, variables: { visibilities: (AgentVisibilityLevel | 'all')[] }) => {
|
|
95
|
+
const allVisibilities = ['account', 'built_in', 'favorite', 'personal', 'shared', 'workspace'] as const
|
|
96
|
+
const visibilities = variables.visibilities.includes('all')
|
|
97
|
+
? allVisibilities
|
|
98
|
+
: variables.visibilities as Array<AgentVisibilityLevelEnum | VisibilityLevelEnum>
|
|
99
|
+
|
|
100
|
+
const shouldFetchWorkspaceAgents = visibilities.includes('workspace')
|
|
101
|
+
|
|
102
|
+
const workspaceAgentsPromise = shouldFetchWorkspaceAgents
|
|
103
|
+
? workspaceAiClient.workspacesContentsByType.query({ contentType: 'agent' })
|
|
104
|
+
: Promise.resolve([])
|
|
105
|
+
|
|
106
|
+
const [workspaceAgents, ...agentsByVisibility] = await Promise.all([
|
|
107
|
+
workspaceAgentsPromise,
|
|
108
|
+
...visibilities.map((visibility) => listAgentsV1AgentsGet({ visibility, authorization: '' }, { signal })),
|
|
109
|
+
])
|
|
110
|
+
|
|
111
|
+
const workspaceAgentsWithSpaceName = workspaceAgents.flatMap(({ agents, space_name }) =>
|
|
112
|
+
agents?.map((agent) => ({ ...agent, spaceName: space_name, builtIn: false }))) as AgentResponseWithBuiltIn[]
|
|
113
|
+
|
|
114
|
+
const allAgents: AgentResponseWithBuiltIn[] = workspaceAgentsWithSpaceName ?? []
|
|
115
|
+
|
|
116
|
+
agentsByVisibility.forEach(agents => allAgents.push(...agents.map(agent => ({
|
|
117
|
+
...agent,
|
|
118
|
+
builtIn: agent?.visibility_level === 'built_in',
|
|
119
|
+
}))))
|
|
120
|
+
|
|
121
|
+
return allAgents
|
|
122
|
+
},
|
|
123
|
+
})
|
|
22
124
|
}
|
|
23
125
|
|
|
24
126
|
export const agentToolsClient = new AgentToolsClient()
|
package/src/client/agent.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
-
import { defaults, deleteV1AgentByAgentIdFavorite, getV1AgentByAgentId, getV1Agents, getV1PublicAgentByAgentId, getV1PublicAgents, postV1AgentByAgentIdFavorite, postV1AgentsTrial, putV1AgentByAgentId
|
|
2
|
+
import { defaults, deleteV1AgentByAgentIdFavorite, getV1AgentByAgentId, getV1Agents, getV1PublicAgentByAgentId, getV1PublicAgents, postV1AgentByAgentIdFavorite, postV1AgentsTrial, putV1AgentByAgentId } from '../api/agent'
|
|
3
3
|
import apis from '../apis.json'
|
|
4
4
|
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
5
5
|
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
6
|
-
import { AgentResponseWithBuiltIn, AgentVisibilityLevel } from './types'
|
|
7
|
-
import { workspaceAiClient } from './workspace-ai'
|
|
8
|
-
|
|
9
|
-
export const isAgentDefault = (agentSlug?: string) => agentSlug === 'stk_code_buddy'
|
|
10
6
|
|
|
11
7
|
interface AgentError {
|
|
12
8
|
code?: string,
|
|
@@ -32,56 +28,6 @@ class AgentClient extends ReactQueryNetworkClient {
|
|
|
32
28
|
})
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
/**
|
|
36
|
-
* List agents filtered by visibility.
|
|
37
|
-
*/
|
|
38
|
-
allAgents = this.query({
|
|
39
|
-
name: 'allAgents',
|
|
40
|
-
request: async (signal, variables: { visibilities: AgentVisibilityLevel[] }) => {
|
|
41
|
-
const visibilities: VisibilityLevel[] = variables.visibilities.includes('ALL')
|
|
42
|
-
? ['PERSONAL', 'SHARED', 'WORKSPACE', 'ACCOUNT', 'FAVORITE']
|
|
43
|
-
: variables.visibilities.filter((visibility) => visibility !== 'BUILT-IN' && visibility !== 'ALL') as VisibilityLevel[]
|
|
44
|
-
|
|
45
|
-
const shouldIncludeBuiltInAgent = variables.visibilities.includes('ALL') || variables.visibilities.includes('BUILT-IN')
|
|
46
|
-
const shouldFetchBuiltInAgent = shouldIncludeBuiltInAgent || variables.visibilities.includes('FAVORITE')
|
|
47
|
-
const shouldFetchWorkspaceAgents = variables.visibilities.includes('ALL') || variables.visibilities.includes('WORKSPACE')
|
|
48
|
-
|
|
49
|
-
const publicAgentsPromise = shouldFetchBuiltInAgent ? getV1PublicAgents({}, { signal }) : Promise.resolve([])
|
|
50
|
-
const workspaceAgentsPromise = shouldFetchWorkspaceAgents
|
|
51
|
-
? workspaceAiClient.workspacesContentsByType.query({ contentType: 'agent' })
|
|
52
|
-
: Promise.resolve([])
|
|
53
|
-
|
|
54
|
-
const [publicAgents, workspaceAgents, ...agentsByVisibility] = await Promise.all([
|
|
55
|
-
publicAgentsPromise,
|
|
56
|
-
workspaceAgentsPromise,
|
|
57
|
-
...visibilities.map((visibility) => getV1Agents({ visibility }, { signal })),
|
|
58
|
-
])
|
|
59
|
-
|
|
60
|
-
const workspaceAgentsWithSpaceName = workspaceAgents?.flatMap(({ agents, space_name }) =>
|
|
61
|
-
agents?.map((agent) => ({
|
|
62
|
-
...agent,
|
|
63
|
-
spaceName: space_name,
|
|
64
|
-
builtIn: publicAgents?.some(publicAgent => publicAgent.id === agent.id),
|
|
65
|
-
}))) as AgentResponseWithBuiltIn[]
|
|
66
|
-
|
|
67
|
-
const allAgents: AgentResponseWithBuiltIn[] = workspaceAgentsWithSpaceName || []
|
|
68
|
-
|
|
69
|
-
if (shouldIncludeBuiltInAgent) {
|
|
70
|
-
const builtInsAgents = publicAgents?.map((agent) => ({ ...agent, builtIn: true, visibility_level: 'BUILT-IN' }))
|
|
71
|
-
allAgents.push(...builtInsAgents)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
agentsByVisibility.forEach(agents => {
|
|
75
|
-
allAgents.push(...agents.map(agent => ({
|
|
76
|
-
...agent,
|
|
77
|
-
builtIn: publicAgents?.some(publicAgent => publicAgent.id === agent.id),
|
|
78
|
-
})))
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
return allAgents
|
|
82
|
-
},
|
|
83
|
-
})
|
|
84
|
-
|
|
85
31
|
/**
|
|
86
32
|
* Gets an agent by id
|
|
87
33
|
*/
|
|
@@ -92,18 +38,6 @@ class AgentClient extends ReactQueryNetworkClient {
|
|
|
92
38
|
: getV1AgentByAgentId({ ...variables }, { signal }),
|
|
93
39
|
})
|
|
94
40
|
|
|
95
|
-
/**
|
|
96
|
-
* Gets the default agent
|
|
97
|
-
*/
|
|
98
|
-
agentDefault = this.query({
|
|
99
|
-
name: 'agentDefault',
|
|
100
|
-
request: async (signal) => {
|
|
101
|
-
const publicAgents = await getV1PublicAgents({}, { signal })
|
|
102
|
-
const agentDefault = publicAgents.find((agent) => isAgentDefault(agent.slug))
|
|
103
|
-
return agentDefault ? { ...agentDefault, builtIn: true } : undefined
|
|
104
|
-
},
|
|
105
|
-
})
|
|
106
|
-
|
|
107
41
|
/**
|
|
108
42
|
* List commons agents
|
|
109
43
|
*/
|
package/src/client/ai.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
QuickCommandsExecutionRequest,
|
|
32
32
|
quickCommandsRunV2V2QuickCommandsSlugStepsStepSlugRunPost,
|
|
33
33
|
resetKnowledgeObjectsV1KnowledgeSourcesSlugObjectsDelete,
|
|
34
|
+
searchKnowledgeSourcesV1KnowledgeSourcesSearchPost,
|
|
34
35
|
updateQuickCommandV1QuickCommandsSlugPatch,
|
|
35
36
|
updateTitleV1ConversationsConversationIdPatch,
|
|
36
37
|
vectorizeCustomKnowledgeSourceV1KnowledgeSourcesSlugCustomPost,
|
|
@@ -127,6 +128,10 @@ class AIClient extends ReactQueryNetworkClient {
|
|
|
127
128
|
* Gets a knowledge source document by the slug of the parent knowledge source and the document id.
|
|
128
129
|
*/
|
|
129
130
|
knowledgeSourceDocument = this.query(removeAuthorizationParam(findKnowledgeObjectByCustomIdV1KnowledgeSourcesSlugObjectsCustomIdGet))
|
|
131
|
+
/**
|
|
132
|
+
* Lists knowledge sources matching the provided IDs.
|
|
133
|
+
*/
|
|
134
|
+
searchKnowledgeSources = this.query(removeAuthorizationParam(searchKnowledgeSourcesV1KnowledgeSourcesSearchPost))
|
|
130
135
|
/**
|
|
131
136
|
* Gets the chat history. This is a paginated resource.
|
|
132
137
|
*/
|
package/src/client/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestOpts } from '@oazapfts/runtime'
|
|
2
2
|
import { AccountScmInfoSaveRequest, AccountScmInfoUpdateRequest, AccountScmStatusResponse, GroupsFromResourceResponse, MembersFromResourceResponse } from '../api/account'
|
|
3
|
-
import {
|
|
3
|
+
import { AgentVisibilityLevelEnum, ListAgentResponse, VisibilityLevelEnum } from '../api/agent-tools'
|
|
4
4
|
import { ChatRequest, ChatResponse3, ContentDependencyResponse, ConversationHistoryResponse, ConversationResponse, DependencyResponse } from '../api/ai'
|
|
5
5
|
import { ConnectAccountRequestV2, ManagedAccountProvisionRequest } from '../api/cloudAccount'
|
|
6
6
|
import { AllocationCostRequest, AllocationCostResponse, ChargePeriod, getAllocationCostFilters, ManagedService, ServiceResource } from '../api/cloudServices'
|
|
@@ -219,6 +219,7 @@ export interface WorkspaceAiMembersPermissions {
|
|
|
219
219
|
totalPages: number,
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
|
|
222
223
|
export interface WorkspaceAiGroupsPermissions extends GroupsFromResourceResponse {
|
|
223
224
|
actions: Action[],
|
|
224
225
|
}
|
|
@@ -357,9 +358,11 @@ export type FixVariables<
|
|
|
357
358
|
|
|
358
359
|
export type ReplaceResult<T extends (...args: any[]) => Promise<any>, Fix> = (...args: Parameters<T>) => Promise<Fix>
|
|
359
360
|
|
|
360
|
-
export interface AgentResponseWithBuiltIn extends
|
|
361
|
+
export interface AgentResponseWithBuiltIn extends Omit<ListAgentResponse, 'conversation_starter' | 'avatar'> {
|
|
361
362
|
builtIn?: boolean,
|
|
362
363
|
spaceName?: string,
|
|
363
|
-
|
|
364
|
+
conversation_starter?: string[] | null,
|
|
365
|
+
avatar?: string | null | undefined,
|
|
366
|
+
}
|
|
364
367
|
|
|
365
|
-
export type AgentVisibilityLevel =
|
|
368
|
+
export type AgentVisibilityLevel = AgentVisibilityLevelEnum | VisibilityLevelEnum
|