@stack-spot/portal-network 1.0.0-dev.1769117840606 → 1.0.0-dev.1769783915267

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/api/accountAssetManager.d.ts +1 -0
  3. package/dist/api/accountAssetManager.d.ts.map +1 -1
  4. package/dist/api/accountAssetManager.js.map +1 -1
  5. package/dist/api/cloudPlatform.d.ts +79 -33
  6. package/dist/api/cloudPlatform.d.ts.map +1 -1
  7. package/dist/api/cloudPlatform.js +86 -76
  8. package/dist/api/cloudPlatform.js.map +1 -1
  9. package/dist/api/codeShift.d.ts +7 -3
  10. package/dist/api/codeShift.d.ts.map +1 -1
  11. package/dist/api/codeShift.js +3 -2
  12. package/dist/api/codeShift.js.map +1 -1
  13. package/dist/api/genAiInference.d.ts +49 -2
  14. package/dist/api/genAiInference.d.ts.map +1 -1
  15. package/dist/api/genAiInference.js +55 -2
  16. package/dist/api/genAiInference.js.map +1 -1
  17. package/dist/apis.json +3 -3
  18. package/dist/client/account.d.ts +16 -0
  19. package/dist/client/account.d.ts.map +1 -1
  20. package/dist/client/account.js +9 -0
  21. package/dist/client/account.js.map +1 -1
  22. package/dist/client/ai.d.ts +1 -3
  23. package/dist/client/ai.d.ts.map +1 -1
  24. package/dist/client/ai.js +1 -251
  25. package/dist/client/ai.js.map +1 -1
  26. package/dist/client/cloud-platform.d.ts +4 -12
  27. package/dist/client/cloud-platform.d.ts.map +1 -1
  28. package/dist/client/cloud-platform.js +5 -14
  29. package/dist/client/cloud-platform.js.map +1 -1
  30. package/dist/client/code-shift.d.ts +2 -1
  31. package/dist/client/code-shift.d.ts.map +1 -1
  32. package/dist/client/discover.d.ts +11 -4
  33. package/dist/client/discover.d.ts.map +1 -1
  34. package/dist/client/discover.js +140 -136
  35. package/dist/client/discover.js.map +1 -1
  36. package/dist/client/gen-ai-inference.d.ts +4 -0
  37. package/dist/client/gen-ai-inference.d.ts.map +1 -1
  38. package/dist/client/gen-ai-inference.js +267 -0
  39. package/dist/client/gen-ai-inference.js.map +1 -1
  40. package/dist/client/types.d.ts +35 -14
  41. package/dist/client/types.d.ts.map +1 -1
  42. package/dist/utils/StreamedJson.d.ts +7 -1
  43. package/dist/utils/StreamedJson.d.ts.map +1 -1
  44. package/dist/utils/StreamedJson.js +10 -2
  45. package/dist/utils/StreamedJson.js.map +1 -1
  46. package/dist/utils/string.d.ts +6 -0
  47. package/dist/utils/string.d.ts.map +1 -1
  48. package/dist/utils/string.js +10 -0
  49. package/dist/utils/string.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/api/accountAssetManager.ts +1 -0
  52. package/src/api/cloudPlatform.ts +170 -111
  53. package/src/api/codeShift.ts +9 -4
  54. package/src/api/genAiInference.ts +119 -3
  55. package/src/apis.json +8 -8
  56. package/src/client/account.ts +4 -0
  57. package/src/client/ai.ts +2 -266
  58. package/src/client/cloud-platform.ts +4 -9
  59. package/src/client/discover.ts +151 -137
  60. package/src/client/gen-ai-inference.ts +281 -0
  61. package/src/client/types.ts +42 -14
  62. package/src/utils/StreamedJson.tsx +11 -2
  63. package/src/utils/string.ts +12 -0
@@ -1,7 +1,7 @@
1
1
  import { RequestOpts } from '@oazapfts/runtime'
2
2
  import { AccountScmInfoSaveRequest, AccountScmInfoUpdateRequest, AccountScmStatusResponse, GroupsFromResourceResponse, MembersFromResourceResponse } from '../api/account'
3
3
  import { AgentVisibilityLevelEnum, HttpMethod, ListAgentResponse, VisibilityLevelEnum } from '../api/agent-tools'
4
- import { ChatRequest, ChatResponse3, ContentDependencyResponse, ConversationHistoryResponse, ConversationResponse, DependencyResponse } from '../api/ai'
4
+ import { ChatRequest, ChatResponse3, ContentDependencyResponse, ConversationHistoryResponse, ConversationResponse, DependencyResponse, QuickCommandResponse, QuickCommandStepResult, SourceKnowledgeSource, SourceProjectFile3, SourceStackAi } from '../api/ai'
5
5
  import { ConnectAccountRequestV2, ManagedAccountProvisionRequest } from '../api/cloudAccount'
6
6
  import { AllocationCostRequest, AllocationCostResponse, ChargePeriod, getAllocationCostFilters, ManagedService, ServiceResource } from '../api/cloudServices'
7
7
  import { Action } from '../api/workspace-ai'
@@ -172,20 +172,11 @@ export interface FixedPaginatedActivityResponse extends Omit<PaginatedActivityRe
172
172
 
173
173
  export interface FixedChatRequest extends ChatRequest {
174
174
  context?: {
175
- workspace?: string,
176
- conversation_id?: string,
177
- stack_id?: string,
178
- language?: string,
179
- project_recent_files?: string,
180
- knowledge_sources?: string[],
181
- agent_id?: string,
182
- agent_built_in?: boolean,
183
175
  platform?: string,
184
176
  platform_version?: string,
185
177
  stackspot_ai_version?: string,
186
178
  os?: string,
187
- upload_ids?: string[],
188
- selected_model_id?: string,
179
+ agent_id?: string,
189
180
  },
190
181
  }
191
182
 
@@ -366,9 +357,17 @@ export interface ToolCallsAgentInfo extends BaseAgentInfo {
366
357
 
367
358
  export type AgentInfo = GenericAgentInfo | PlanningAgentInfo | StepAgentInfo | ToolAgentInfo | ToolCallsAgentInfo
368
359
 
369
- export interface FixedChatResponse extends ChatResponse3 {
370
- agent_info: AgentInfo,
371
- tools?: string[],
360
+ export type ChatResponse = {
361
+ message: string,
362
+ cross_account_source: SourceKnowledgeSource[],
363
+ source: (SourceStackAi | SourceKnowledgeSource | SourceProjectFile3)[],
364
+ message_id: string | null,
365
+ stop_reason: 'stop',
366
+ };
367
+
368
+ export interface FixedChatResponse extends ChatResponse {
369
+ agent_info: AgentInfo[],
370
+ tools_id?: string[],
372
371
  }
373
372
  export interface OpportunitiesPMAgent {
374
373
  title: string,
@@ -421,3 +420,32 @@ export interface AgentToolsOpenAPIPreview {
421
420
  parameters?: Record<string, any>,
422
421
  request_body?: Record<string, any>,
423
422
  }
423
+
424
+ type SlugExecution = Record<string, QuickCommandStepResult>
425
+
426
+
427
+ interface BaseQCContext {
428
+ context: Required<FixedChatRequest>['context'],
429
+ resultMap: SlugExecution,
430
+ customInputs: Record<string, string>,
431
+ code?: string,
432
+ executionId: string,
433
+ signal: AbortSignal,
434
+ isRemote?: boolean,
435
+ headers?: Record<string, string>,
436
+ conversation_id?: string,
437
+ }
438
+
439
+ export interface QCContext extends BaseQCContext {
440
+ slug: string,
441
+ }
442
+
443
+ export interface QCContextExecution extends BaseQCContext {
444
+ qc: QuickCommandResponse,
445
+ }
446
+
447
+ export interface QCProgressProps{
448
+ update?: (index: number) => void,
449
+ remove?: () => void,
450
+ onStepChange?: (stepResult: any) => void,
451
+ }
@@ -21,6 +21,11 @@ interface ConstructorParams<T> {
21
21
  * @default 50
22
22
  */
23
23
  minChangeIntervalMS?: number,
24
+ /**
25
+ * Allows overriding the minimum interval by event.
26
+ * Useful when some events must flush immediately (agent_info events).
27
+ */
28
+ minChangeIntervalMSFromEvent?: (event: Partial<T>, data: Partial<T>) => number | undefined,
24
29
  /**
25
30
  * Optional. If set, this function will be called with every streaming event and must transform the current data object according to the
26
31
  * message received.
@@ -45,16 +50,18 @@ export class StreamedJson<T> {
45
50
  private abortController: AbortController | undefined
46
51
  private transform?: (event: Partial<T>, data: Partial<T>) => void | Promise<void>
47
52
  private ignoreKeys?: (keyof T)[]
53
+ private minChangeIntervalMSFromEvent?: (event: Partial<T>, data: Partial<T>) => number | undefined
48
54
  private textFromErrorEvent: (data: Partial<T>) => string
49
55
 
50
56
  /**
51
57
  * @param response the fetch response.
52
58
  * @param minChangeIntervalMS a stream can be too fast. This sets a minimum interval between running the listeners. The default is 50ms.
53
59
  */
54
- constructor({ eventsPromise, abortController, minChangeIntervalMS = 50, transform, ignoreKeys, textFromErrorEvent }: ConstructorParams<T>) {
60
+ constructor({ eventsPromise, abortController, minChangeIntervalMS = 50, minChangeIntervalMSFromEvent, transform, ignoreKeys, textFromErrorEvent }: ConstructorParams<T>) {
55
61
  this.abortController = abortController
56
62
  this.transform = transform
57
63
  this.ignoreKeys = ignoreKeys
64
+ this.minChangeIntervalMSFromEvent = minChangeIntervalMSFromEvent
58
65
  this.run(eventsPromise, minChangeIntervalMS)
59
66
  this.textFromErrorEvent = textFromErrorEvent ?? ((data) => JSON.stringify(data))
60
67
  }
@@ -77,7 +84,9 @@ export class StreamedJson<T> {
77
84
  }
78
85
  await this.transform?.(json, this.data)
79
86
  this.merge(json, this.data)
80
- if (event.event !== 'error' && new Date().getTime() - lastChangeCall >= minChangeIntervalMS) {
87
+
88
+ const intervalMS = this.minChangeIntervalMSFromEvent?.(json, this.data) ?? minChangeIntervalMS
89
+ if (event.event !== 'error' && new Date().getTime() - lastChangeCall >= intervalMS) {
81
90
  this.onChangeListeners.forEach(l => l(this.data))
82
91
  lastChangeCall = new Date().getTime()
83
92
  flushed = true
@@ -17,3 +17,15 @@ export function formatJson(data: any): string {
17
17
  }
18
18
  return JSON.stringify(data, null, 2)
19
19
  }
20
+
21
+
22
+ /**
23
+ * Gets the size of a string removing control characters and spaces
24
+ * @param str the string to count.
25
+ * @returns the count value.
26
+ */
27
+ export function getSizeOfString(str: string): number {
28
+ // eslint-disable-next-line no-control-regex
29
+ const withoutSpacesAndControls = str.replace(/[\u0000-\u001F\u007F-\u009F\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069\s]/g, '')
30
+ return withoutSpacesAndControls.length
31
+ }