@stack-spot/portal-network 0.186.1-beta.1 → 0.187.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/src/client/ai.ts CHANGED
@@ -266,9 +266,6 @@ class AIClient extends ReactQueryNetworkClient {
266
266
  agent.toolkits?.builtin_toolkits?.forEach(kit => kit.tools?.forEach(({ id, name, description }) => {
267
267
  if (id) tools.push({ image: kit.image_url, id, name: name || id, description })
268
268
  }))
269
- agent.toolkits?.custom_toolkits?.forEach(kit => kit.tools?.forEach(({ id, name, description }) => {
270
- if (id) tools.push({ image: kit.avatar ?? undefined, id, name: name || id, description })
271
- }))
272
269
  return tools
273
270
  } catch {
274
271
  return []
@@ -306,33 +303,6 @@ class AIClient extends ReactQueryNetworkClient {
306
303
  steps: info.data?.steps?.map(s => s.goal) ?? [],
307
304
  goal: info.data?.plan_goal ?? '',
308
305
  })
309
-
310
- info.data?.steps.forEach(s => data.steps?.push({
311
- id: s.id,
312
- type: 'step',
313
- status: 'pending',
314
- input: s.goal,
315
- attempts: [{
316
- tools: s.tools?.map(t => ({
317
- ...(tools.find(({ id }) => id === t.tool_id) ?? { id: t.tool_id, name: t.tool_id }),
318
- executionId: t.tool_execution_id,
319
- goal: t.goal,
320
- })),
321
- }],
322
- }))
323
- data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
324
- }
325
-
326
- if (info.type === 'planning' && info.action === 'awaiting_approval') {
327
- data.steps.push({
328
- id: 'planning',
329
- type: 'planning',
330
- status: 'awaiting_approval',
331
- user_question: info.data?.user_question,
332
- duration: info.duration || 0,
333
- steps: info.data?.steps?.map(s => s.goal) ?? [],
334
- goal: info.data?.plan_goal ?? '',
335
- })
336
306
  info.data?.steps.forEach(s => data.steps?.push({
337
307
  id: s.id,
338
308
  type: 'step',
@@ -342,7 +312,6 @@ class AIClient extends ReactQueryNetworkClient {
342
312
  tools: s.tools?.map(t => ({
343
313
  ...(tools.find(({ id }) => id === t.tool_id) ?? { id: t.tool_id, name: t.tool_id }),
344
314
  executionId: t.tool_execution_id,
345
- goal: t.goal,
346
315
  })),
347
316
  }],
348
317
  }))
@@ -365,78 +334,27 @@ class AIClient extends ReactQueryNetworkClient {
365
334
  }
366
335
  }
367
336
 
368
- if (info.type === 'tool' && info.action === 'awaiting_approval') {
369
- const tool = tools.find(({ id }) => id === info.data?.tool_id)
370
- data.steps.push({
371
- id: info.id,
372
- type: 'tool',
373
- status: 'awaiting_approval',
374
- duration: info.duration || 0,
375
- input: info.data?.input,
376
- user_question: info.data?.user_question,
377
- attempts: [{
378
- tools: [{
379
- executionId: info.id,
380
- id: info.data?.tool_id ?? '',
381
- name: tool?.name ?? '',
382
- goal: tool?.goal,
383
- ...tool,
384
- }],
385
- }],
386
- })
387
- data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
388
- }
389
-
390
337
  if (info.type === 'tool' && info.action === 'start') {
391
338
  const currentStep = data.steps.find(s => s.status === 'running') as StepChatStep
392
- if (!info.data) return
393
-
394
- //There might be a tool with status awaiting_approval, so we want to inform tool has already started
395
- if (!currentStep || !currentStep.attempts[0].tools) {
396
- const input = formatJson(info.data.input)
397
- const tool = tools.find(({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
398
- data.steps.push({
399
- id: info.id,
400
- type: 'tool',
401
- status: 'running',
402
- duration: info.duration || 0,
403
- input: info.data?.input,
404
- user_question: info.data?.user_question,
405
- attempts: [{
406
- tools:[{ ...tool, executionId: info.id, input }],
407
- }],
408
- })
339
+ if (!currentStep || !info.data || !currentStep.attempts[0].tools) return
340
+ const toolInFirstAttempt = currentStep.attempts[0].tools.find(t => t.executionId === info.id)
341
+ if (!toolInFirstAttempt) return
342
+ const input = formatJson(info.data.input)
343
+ if (info.data.attempt === 0) {
344
+ toolInFirstAttempt.input = input
409
345
  } else {
410
- const toolInFirstAttempt = currentStep.attempts[0].tools?.find(t => t.executionId === info.id)
411
- //One step might have multiple tools. When in an approval mode, we might not have all the tools in the array yet.
412
- //So we make sure to add any tools that are not in there.
413
- if (!toolInFirstAttempt) {
414
- const input = formatJson(info.data.input)
415
- const tool = tools?.find(({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
416
- currentStep.attempts[info.data.attempt-1].tools?.push({
417
- ...tool,
418
- input,
419
- })
420
- } else {
421
- const input = formatJson(info.data.input)
422
- if (info.data.attempt === 1) {
423
- toolInFirstAttempt.input = input
424
- } else {
425
- const tool = tools.find(({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
426
- currentStep.attempts[info.data.attempt-1] ??= { tools: [] }
427
- currentStep.attempts[info.data.attempt-1].tools?.push({
428
- ...tool,
429
- input,
430
- })
431
- }
432
- }
346
+ currentStep.attempts[info.data.attempt] ??= { tools: [] }
347
+ currentStep.attempts[info.data.attempt].tools?.push({
348
+ ...toolInFirstAttempt,
349
+ input,
350
+ })
433
351
  }
434
352
  }
435
353
 
436
354
  if (info.type === 'tool' && info.action === 'end') {
437
355
  const currentStep = data.steps.find(s => s.status === 'running') as StepChatStep
438
356
  if (!currentStep || !info.data) return
439
- const tool = currentStep.attempts[info.data.attempt-1]?.tools?.find(t => t.executionId === info.id)
357
+ const tool = currentStep.attempts[info.data.attempt]?.tools?.find(t => t.executionId === info.id)
440
358
  if (tool) {
441
359
  tool.output = formatJson(info.data.output)
442
360
  tool.duration = info.duration
@@ -475,4 +393,3 @@ class AIClient extends ReactQueryNetworkClient {
475
393
  }
476
394
 
477
395
  export const aiClient = new AIClient()
478
-
@@ -58,7 +58,6 @@ import {
58
58
  getModuleV1ModulesModuleIdGet,
59
59
  analyticsProgramGroupsTargetDetailsV1AnalyticsProgramGroupsTargetDetailsGet,
60
60
  analyticsProgramGroupsTargetDetailsDownloadV1AnalyticsProgramGroupsTargetDetailsDownloadGet,
61
- putCustomerRatingReportV1ReportsReportIdCustomerRatingPut,
62
61
  searchReposScmServiceV2ReposSearchScmPost,
63
62
  importReposWithTagsScmServiceV2ReposSearchScmSearchIdPost,
64
63
  searchReposScmV2V2ReposSearchScmSearchIdGet,
@@ -145,12 +144,6 @@ class CodeShift extends ReactQueryNetworkClient {
145
144
  * Downloads a report as a csv file.
146
145
  */
147
146
  downloadReport = this.query(removeAuthorizationParam(downloadReportV1ReportsReportIdDownloadGet))
148
- /**
149
- * Put Customer Rating Report
150
- */
151
- updateReportRating = this.mutation(
152
- removeAuthorizationParam(putCustomerRatingReportV1ReportsReportIdCustomerRatingPut),
153
- )
154
147
  /**
155
148
  * Gets code shift settings
156
149
  */
@@ -245,7 +245,6 @@ export interface ChatAgentTool {
245
245
  image?: string,
246
246
  input?: string,
247
247
  output?: string,
248
- goal?: string,
249
248
  }
250
249
 
251
250
  export interface ChatStepAttempt {
@@ -257,8 +256,8 @@ export interface ChatStepAttempt {
257
256
 
258
257
  export interface BaseChatStep {
259
258
  id: string,
260
- type: 'planning' | 'step' | 'answer' | 'tool',
261
- status: 'pending' | 'running' | 'success' | 'error' | 'awaiting_approval',
259
+ type: 'planning' | 'step' | 'answer',
260
+ status: 'pending' | 'running' | 'success' | 'error',
262
261
  /**
263
262
  * Duration in seconds.
264
263
  */
@@ -267,24 +266,9 @@ export interface BaseChatStep {
267
266
 
268
267
  export interface PlanningChatStep extends BaseChatStep {
269
268
  type: 'planning',
270
- status: 'success' | 'awaiting_approval',
269
+ status: 'success',
271
270
  steps: string[],
272
271
  goal: string,
273
- user_question?: string,
274
- }
275
-
276
- export interface ToolChatStep extends BaseChatStep {
277
- type: 'tool',
278
- status: 'running' | 'success' | 'error' | 'awaiting_approval',
279
- /**
280
- * Each step might attempt to run for multiple times, with different inputs and outputs. If first attempt succeeds, this array will have
281
- * only one element.
282
- *
283
- * This array never has less than one element, despite the step's status.
284
- */
285
- attempts: ChatStepAttempt[],
286
- input?: Record<string, any>,
287
- user_question?: string,
288
272
  }
289
273
 
290
274
  export interface StepChatStep extends BaseChatStep {
@@ -304,19 +288,17 @@ export interface AnswerChatStep extends BaseChatStep {
304
288
  type: 'answer',
305
289
  }
306
290
 
307
- export type ChatStep = PlanningChatStep | StepChatStep | AnswerChatStep | ToolChatStep
291
+ export type ChatStep = PlanningChatStep | StepChatStep | AnswerChatStep
308
292
 
309
293
  export interface BaseAgentInfo {
310
294
  type: 'chat' | 'planning' | 'step' | 'tool' | 'final_answer',
311
- action: 'start' | 'end' | 'awaiting_approval',
295
+ action: 'start' | 'end',
312
296
  duration?: number,
313
- id: string,
314
297
  }
315
298
 
316
299
  export interface AgentTool {
317
300
  tool_id: string,
318
301
  tool_execution_id: string,
319
- goal: string,
320
302
  }
321
303
 
322
304
  export interface PlanningAgentInfo extends BaseAgentInfo {
@@ -329,7 +311,6 @@ export interface PlanningAgentInfo extends BaseAgentInfo {
329
311
  goal: string,
330
312
  tools?: AgentTool[],
331
313
  }[],
332
- user_question?: string,
333
314
  },
334
315
  }
335
316
 
@@ -345,8 +326,6 @@ export interface ToolAgentInfo extends BaseAgentInfo {
345
326
  input?: any,
346
327
  attempt: number,
347
328
  output?: string,
348
- user_question?: string,
349
- tool_id: string,
350
329
  },
351
330
  }
352
331