@stack-spot/portal-network 0.203.1-beta.1 → 0.204.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/codeShift.d.ts +13 -1
  3. package/dist/api/codeShift.d.ts.map +1 -1
  4. package/dist/api/codeShift.js.map +1 -1
  5. package/dist/api/genAiInference.d.ts +49 -2
  6. package/dist/api/genAiInference.d.ts.map +1 -1
  7. package/dist/api/genAiInference.js +55 -2
  8. package/dist/api/genAiInference.js.map +1 -1
  9. package/dist/client/ai.d.ts +1 -3
  10. package/dist/client/ai.d.ts.map +1 -1
  11. package/dist/client/ai.js +2 -249
  12. package/dist/client/ai.js.map +1 -1
  13. package/dist/client/discover.d.ts +2 -2
  14. package/dist/client/discover.d.ts.map +1 -1
  15. package/dist/client/discover.js +4 -3
  16. package/dist/client/discover.js.map +1 -1
  17. package/dist/client/gen-ai-inference.d.ts +4 -0
  18. package/dist/client/gen-ai-inference.d.ts.map +1 -1
  19. package/dist/client/gen-ai-inference.js +267 -0
  20. package/dist/client/gen-ai-inference.js.map +1 -1
  21. package/dist/client/types.d.ts +13 -14
  22. package/dist/client/types.d.ts.map +1 -1
  23. package/dist/client/workspace-manager.d.ts +9 -0
  24. package/dist/client/workspace-manager.d.ts.map +1 -1
  25. package/dist/client/workspace-manager.js +10 -1
  26. package/dist/client/workspace-manager.js.map +1 -1
  27. package/dist/utils/StreamedJson.d.ts +9 -1
  28. package/dist/utils/StreamedJson.d.ts.map +1 -1
  29. package/dist/utils/StreamedJson.js +22 -2
  30. package/dist/utils/StreamedJson.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/api/codeShift.ts +13 -1
  33. package/src/api/genAiInference.ts +119 -3
  34. package/src/client/ai.ts +2 -265
  35. package/src/client/discover.ts +7 -6
  36. package/src/client/gen-ai-inference.ts +281 -0
  37. package/src/client/types.ts +14 -14
  38. package/src/client/workspace-manager.ts +5 -0
  39. package/src/utils/StreamedJson.tsx +19 -2
@@ -21,6 +21,7 @@ import {
21
21
  applicationControllergetApplicationLinks,
22
22
  applicationControllergetApplications,
23
23
  applicationControllerregistryAppDestroy,
24
+ availableConnectionInterfaceControllergetAvailableConnectionInterfaces,
24
25
  contentWorkflowControllercreateApplicationThroughWorkflow,
25
26
  contentWorkflowControllercreateSharedInfraThroughWorkflow,
26
27
  contextActionControllergetStackActionInputsInAccountContext,
@@ -572,6 +573,10 @@ class WorkspaceManagerClient extends ReactQueryNetworkClient {
572
573
  * Receives a list of workspace id's and returns that workspaces detailed
573
574
  */
574
575
  workspacesFilterById = this.mutation(workspaceControllergetWorkspacesSummary)
576
+ /**
577
+ * Gets available connection interfaces from a workspace
578
+ */
579
+ availableConnectionInterfaces = this.query(availableConnectionInterfaceControllergetAvailableConnectionInterfaces)
575
580
  }
576
581
 
577
582
  export const workspaceManagerClient = new WorkspaceManagerClient()
@@ -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.
@@ -31,6 +36,7 @@ interface ConstructorParams<T> {
31
36
  * of merged.
32
37
  */
33
38
  ignoreKeys?: (keyof T)[],
39
+ textFromErrorEvent?: (data: Partial<T>) => string,
34
40
  }
35
41
 
36
42
  /**
@@ -44,16 +50,20 @@ export class StreamedJson<T> {
44
50
  private abortController: AbortController | undefined
45
51
  private transform?: (event: Partial<T>, data: Partial<T>) => void | Promise<void>
46
52
  private ignoreKeys?: (keyof T)[]
53
+ private minChangeIntervalMSFromEvent?: (event: Partial<T>, data: Partial<T>) => number | undefined
54
+ private textFromErrorEvent: (data: Partial<T>) => string
47
55
 
48
56
  /**
49
57
  * @param response the fetch response.
50
58
  * @param minChangeIntervalMS a stream can be too fast. This sets a minimum interval between running the listeners. The default is 50ms.
51
59
  */
52
- constructor({ eventsPromise, abortController, minChangeIntervalMS = 50, transform, ignoreKeys }: ConstructorParams<T>) {
60
+ constructor({ eventsPromise, abortController, minChangeIntervalMS = 50, minChangeIntervalMSFromEvent, transform, ignoreKeys, textFromErrorEvent }: ConstructorParams<T>) {
53
61
  this.abortController = abortController
54
62
  this.transform = transform
55
63
  this.ignoreKeys = ignoreKeys
64
+ this.minChangeIntervalMSFromEvent = minChangeIntervalMSFromEvent
56
65
  this.run(eventsPromise, minChangeIntervalMS)
66
+ this.textFromErrorEvent = textFromErrorEvent ?? ((data) => JSON.stringify(data))
57
67
  }
58
68
 
59
69
  private async run(eventsPromise: Promise<FetchEventStream>, minChangeIntervalMS: number) {
@@ -74,7 +84,9 @@ export class StreamedJson<T> {
74
84
  }
75
85
  await this.transform?.(json, this.data)
76
86
  this.merge(json, this.data)
77
- if (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) {
78
90
  this.onChangeListeners.forEach(l => l(this.data))
79
91
  lastChangeCall = new Date().getTime()
80
92
  flushed = true
@@ -82,6 +94,11 @@ export class StreamedJson<T> {
82
94
  flushed = false
83
95
  }
84
96
  }
97
+ if (event.event === 'error') {
98
+ const error = new Error(this.textFromErrorEvent(this.data))
99
+ this.data = {}
100
+ throw error
101
+ }
85
102
  }
86
103
  if (!flushed) this.onChangeListeners.forEach(l => l(this.data))
87
104
  } catch (error: any) {