@supernova-studio/supernova-sdk-beta 2.1.1 → 2.1.2

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.
@@ -25,6 +25,7 @@ import { DataBridgeRequestHook } from "./data/SDKDataBridge";
25
25
  export declare class Supernova {
26
26
  private apiKey;
27
27
  private apiUrl;
28
+ private aiApiUrl;
28
29
  private apiVersion;
29
30
  private requestHook;
30
31
  private dataCore;
@@ -78,12 +79,15 @@ export declare class Supernova {
78
79
  * @param options Options for SDK
79
80
  * @param options.url URL of the Supernova.io instance to connect to. Defaults to production environment
80
81
  * @param options.requestHook Hook for observing requests
81
- * @param options.bypassEnvFetch When enabled, internal node-fetch lib will be used in environments when fetch is not available. Defaults to false
82
+ * @param options.customFetchLib When provided, network requests will run through custom provided, fetch-like. Use in environments where fetch is not available or you want to provide your own implementation.
83
+ * @param options.customProxyLib When provided, proxy will be used to route network requests.
82
84
  */
83
85
  constructor(apiKey: string, options?: {
84
86
  apiUrl?: string;
87
+ aiApiUrl?: string;
85
88
  requestHook?: DataBridgeRequestHook;
86
- bypassEnvFetch?: boolean;
89
+ customFetchLib?: any;
90
+ customProxyLib?: any;
87
91
  proxyUrl?: string;
88
92
  isPreview?: boolean;
89
93
  jobId?: string;
@@ -1,34 +1,58 @@
1
1
  import { DataCore } from "../data/SDKDataCore";
2
- import { RemoteVersionIdentifier, RemoteWorkspaceVersionIdentifier } from "./SDKRemoteIdentifiers";
2
+ import { RemoteWorkspaceVersionIdentifier } from "./SDKRemoteIdentifiers";
3
3
  export declare class AreaAI {
4
4
  /** Internal: Engine */
5
5
  private dataCore;
6
6
  constructor(dataCore: DataCore);
7
- /** Generates code for the associated design system components for provided user prompt
8
- * @param from - Design system to use
9
- * @param prompt - Prompt to generate code for
10
- * @param components - Components to generate code for
11
- * @returns Forged component code
7
+ /** Summarizes a prompt into a title. Response is not streamed.
8
+ * @param from - Version identifier
9
+ * @param text - Text to summarize
10
+ * @param options - Summarization options
11
+ * @returns Summarized title
12
+ * @disclaimer This method will throw if the user is not authorized to use AI features (if you are reading this, you are not authorized).
12
13
  */
13
- forgeCode(from: RemoteVersionIdentifier, prompt: string, components: Array<any>): Promise<string>;
14
- /** Reforges code for the associated design system components for provided user prompt, taking into account existing code
15
- * @param from - Design system to use
16
- * @param prompt - Prompt to generate code for
17
- * @param components - Components to generate code for
18
- * @param existingCode - Existing code to reforge
19
- * @returns Reforged component code
14
+ summarizeIntoTitle(from: RemoteWorkspaceVersionIdentifier, text: string, options?: {
15
+ maxWordCount: number;
16
+ strategy: "noun" | "verb";
17
+ }): Promise<string>;
18
+ /** Autocompletes a prompt into a full text. Response is not streamed.
19
+ * @param from - Version identifier
20
+ * @param text - Text to autocomplete
21
+ * @param options - Autocomplete options
22
+ * @returns Autocompleted text
23
+ * @disclaimer This method will throw if the user is not authorized to use AI features (if you are reading this, you are not authorized).
20
24
  */
21
- reforgeCode(from: RemoteVersionIdentifier, prompt: string, components: Array<any>, existingCode: string): Promise<string>;
22
- /** Reforges code for the associated design system components for provided user prompt, taking into account existing code
23
- * @param from - Design system to use
24
- * @param prompt - Prompt to generate code for
25
- * @param components - Components to generate code for
26
- * @param existingCode - Existing code to reforge
27
- * @returns Reforged component code
25
+ autocompleteText(from: RemoteWorkspaceVersionIdentifier, text: string, options?: {
26
+ maximumLength: number;
27
+ }): Promise<string>;
28
+ /** Answers question based on the data of design system in natural language. This method is non-streaming.
29
+ * @param from - Version identifier
30
+ * @param prompt - Question to answer
31
+ * @param options - Answering options
32
+ * @returns Answer to the question
33
+ * @disclaimer This method will throw if the user is not authorized to use AI features (if you are reading this, you are not authorized).
28
34
  */
29
- proposeTitle(from: RemoteVersionIdentifier, firstForgeQuery: string): Promise<string>;
30
- /** Answers question based on the data of design system in natural language */
31
- answerQuestion(from: RemoteWorkspaceVersionIdentifier, persona: "designer" | "developer" | "code", askQuery: string): Promise<string>;
32
- /** Indexes a design system so it can be asked in natural language */
33
- indexDS(from: RemoteWorkspaceVersionIdentifier): Promise<string>;
35
+ answer(from: RemoteWorkspaceVersionIdentifier, prompt: string, options?: {
36
+ persona: "designer" | "developer";
37
+ scope: "all" | "tokens" | "components" | "assets" | "docs";
38
+ density: "compact" | "full";
39
+ }): Promise<string>;
40
+ /** Answers question based on the data of design system in natural language. This method streams answer.
41
+ * @param from - Version identifier
42
+ * @param prompt - Question to answer
43
+ * @param options - Answering options
44
+ * @returns Answer to the question
45
+ * @disclaimer This method will throw if the user is not authorized to use AI features (if you are reading this, you are not authorized).
46
+ */
47
+ answerAsStream(from: RemoteWorkspaceVersionIdentifier, prompt: string, options?: {
48
+ persona: "designer" | "developer";
49
+ scope: "all" | "tokens" | "components" | "assets" | "docs";
50
+ density: "compact" | "full";
51
+ }): Promise<ReadableStream<Uint8Array>>;
52
+ /** Indexes or reindexes a design system to prepare it for QA engine
53
+ * @param from - Version identifier
54
+ * @returns Indexing status
55
+ * @disclaimer This method will throw if the user is not authorized to use AI features (if you are reading this, you are not authorized).
56
+ */
57
+ rebuildAnswerIndex(from: RemoteWorkspaceVersionIdentifier): Promise<string>;
34
58
  }
@@ -1,6 +1,8 @@
1
1
  export declare class Configuration {
2
2
  /** Retrieve API URL for default target */
3
3
  static apiUrlForDefaultEnvironment(): string;
4
+ /** Retrieve API URL for default AI target */
5
+ static aiApiUrlForDefaultEnvironment(): string;
4
6
  /** Retrieve API version for the specific environment accesse */
5
7
  static apiVersionForDefaultEnvironment(): string;
6
8
  }
@@ -15,26 +15,28 @@ export type DebugRequestObserver = (info: {
15
15
  }) => void;
16
16
  export type DataBridgeConfiguration = {
17
17
  apiUrl: string;
18
+ aiApiUrl: string;
18
19
  apiVersion: string;
19
20
  accessToken: string;
20
21
  target: string | null;
21
- bypassEnvFetch: boolean;
22
+ customFetchLib: any | null;
23
+ customProxyLib: any | null;
22
24
  requestHook: DataBridgeRequestHook | null;
23
25
  debugRequestObserver?: DebugRequestObserver | null;
24
26
  debugResponseObserver?: DebugResponseObserver | null;
25
- proxyUrl?: string | null;
26
27
  jobId?: string | null;
27
28
  isPreview?: boolean;
28
29
  };
29
30
  export declare class DataBridge {
30
31
  authToken: string;
31
32
  apiUrl: string;
33
+ aiApiUrl: string;
32
34
  apiVersion: string;
33
35
  target: string | null;
34
- bypassEnvFetch: boolean;
36
+ customFetchLib: any | null;
37
+ customProxyLib: any | null;
35
38
  isPreview: boolean;
36
39
  jobId: string | null;
37
- proxyUrl: string | undefined;
38
40
  requestHook: DataBridgeRequestHook | null;
39
41
  debugRequestObserver: DebugRequestObserver | null;
40
42
  debugResponseObserver: DebugResponseObserver | null;
@@ -50,6 +52,7 @@ export declare class DataBridge {
50
52
  private buildRequestConfig;
51
53
  private getProxyAgent;
52
54
  private getFetchInvoker;
55
+ getApiEndpoint(fragment: string | null): string;
53
56
  getBaseEndpoint(fragment: string | null): string;
54
57
  getPublicEndpoint(fragment: string): string;
55
58
  getAclEndpoint(resource?: string): string;
@@ -96,16 +96,29 @@ export declare class DataCore {
96
96
  multiplayerToken(room: string | undefined): Promise<{
97
97
  token: string;
98
98
  }>;
99
- /** Remote: Forges code based on user prompt */
100
- forgeCode(designSystemId: string, versionId: string, prompt: string, components: Array<any>): Promise<string>;
101
- /** Remote: Reforges code based on user prompt */
102
- reforgeCode(designSystemId: string, versionId: string, prompt: string, components: Array<any>, existingCode: string): Promise<string>;
103
- /** Remote: Proposes title for generated code */
104
- proposeTitle(designSystemId: string, versionId: string, firstForgeQuery: string): Promise<string>;
105
- /** Remote: Answers question based on the data of design system in natural language */
106
- answerQuestion(workspaceId: string, designSystemId: string, versionId: string, persona: "designer" | "developer" | "code", askQuery: string): Promise<string>;
107
- /** Remote: Index a design system so it can be asked in natural language */
108
- indexDS(workspaceId: string, designSystemId: string, versionId: string): Promise<string>;
99
+ /** Remote: Summarizes a prompt into a title. Response is not streamed */
100
+ aiSummarizeIntoTitle(workspaceId: string, designSystemId: string, versionId: string, text: string, options: {
101
+ maxWordCount: number;
102
+ strategy: "noun" | "verb";
103
+ }): Promise<string>;
104
+ /** Remote: Autocompletes a prompt into a full text. Response is not streamed. */
105
+ aiAutocompleteText(workspaceId: string, designSystemId: string, versionId: string, text: string, options: {
106
+ maximumLength: number;
107
+ }): Promise<string>;
108
+ /** Remote: Answers question based on the data of design system in natural language. This method is non-streaming. */
109
+ aiAnswer(workspaceId: string, designSystemId: string, versionId: string, prompt: string, options: {
110
+ persona: "designer" | "developer";
111
+ scope: "all" | "tokens" | "components" | "assets" | "docs";
112
+ density: "compact" | "full";
113
+ }): Promise<string>;
114
+ /** Remote: Answers question based on the data of design system in natural language. This method streams answer. */
115
+ aiAnswerAsStream(workspaceId: string, designSystemId: string, versionId: string, prompt: string, options: {
116
+ persona: "designer" | "developer";
117
+ scope: "all" | "tokens" | "components" | "assets" | "docs";
118
+ density: "compact" | "full";
119
+ }): Promise<ReadableStream<Uint8Array>>;
120
+ /** Indexes or reindexes a design system to prepare it for QA engine */
121
+ aiRebuildAnswerIndex(workspaceId: string, designSystemId: string, versionId: string): Promise<string>;
109
122
  /** Remote: Get information about currently logged in user */
110
123
  currentUser(): Promise<User>;
111
124
  /** Remote: Get information about a specific user */
@@ -2,14 +2,27 @@ import { DataBridge } from "../SDKDataBridge";
2
2
  export declare class DataCoreAIRequests {
3
3
  private bridge;
4
4
  constructor(bridge: DataBridge);
5
- /** Remote: Forges code based on user prompt */
6
- forgeCode(designSystemId: string, versionId: string, prompt: string, components: Array<any>): Promise<string>;
7
- /** Remote: Reforges code based on user prompt */
8
- reforgeCode(designSystemId: string, versionId: string, prompt: string, components: Array<any>, existingCode: string): Promise<string>;
9
- /** Remote: Proposes title for the forged code */
10
- proposeTitle(designSystemId: string, versionId: string, firstForgeQuery: string): Promise<string>;
11
- /** Remote: Answers question based on the data of design system in natural language */
12
- answerQuestion(workspaceId: string, designSystemId: string, versionId: string, persona: "designer" | "developer" | "code", askQuery: string): Promise<string>;
13
- /** Remote: Index a design system so it can be asked in natural language */
14
- indexDS(workspaceId: string, designSystemId: string, versionId: string): Promise<string>;
5
+ /** Remote: Summarizes a prompt into a title. Response is not streamed */
6
+ summarizeIntoTitle(workspaceId: string, designSystemId: string, versionId: string, text: string, options: {
7
+ maxWordCount: number;
8
+ strategy: "noun" | "verb";
9
+ }): Promise<string>;
10
+ /** Remote: Autocompletes a prompt into a full text. Response is not streamed. */
11
+ autocompleteText(workspaceId: string, designSystemId: string, versionId: string, text: string, options: {
12
+ maximumLength: number;
13
+ }): Promise<string>;
14
+ /** Remote: Answers question based on the data of design system in natural language. This method is non-streaming. */
15
+ answer(workspaceId: string, designSystemId: string, versionId: string, question: string, options: {
16
+ persona: "designer" | "developer";
17
+ scope: "all" | "tokens" | "components" | "assets" | "docs";
18
+ density: "compact" | "full";
19
+ }): Promise<string>;
20
+ /** Remote: Answers question based on the data of design system in natural language. This method streams answer. */
21
+ answerAsStream(workspaceId: string, designSystemId: string, versionId: string, question: string, options: {
22
+ persona: "designer" | "developer";
23
+ scope: "all" | "tokens" | "components" | "assets" | "docs";
24
+ density: "compact" | "full";
25
+ }): Promise<ReadableStream<Uint8Array>>;
26
+ /** Indexes or reindexes a design system to prepare it for QA engine */
27
+ rebuildAnswerIndex(workspaceId: string, designSystemId: string, versionId: string): Promise<string>;
15
28
  }