@builder.io/ai-utils 0.0.73 → 0.0.75
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/package.json +1 -1
- package/src/codegen.d.ts +63 -0
- package/src/codegen.js +1 -0
- package/src/events.d.ts +10 -1
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/src/mapping.d.ts +77 -0
- package/src/mapping.js +1 -0
- package/src/messages.d.ts +5 -3
- package/src/messages.js +8 -0
- package/src/vcp.d.ts +32 -0
- package/src/vcp.js +1 -0
package/package.json
CHANGED
package/src/codegen.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { UserMessageParam } from "./messages";
|
|
2
|
+
import type { BuilderContent } from "./completion";
|
|
3
|
+
import type { Options as PrettierOptions } from "prettier";
|
|
4
|
+
import type { UserContext } from "./mapping";
|
|
5
|
+
import type { AssistantMessageParam } from "./messages";
|
|
6
|
+
export type ImportType = "named" | "default";
|
|
7
|
+
export interface ESMImport {
|
|
8
|
+
importName: string;
|
|
9
|
+
importPath: string;
|
|
10
|
+
importType: ImportType;
|
|
11
|
+
}
|
|
12
|
+
export interface ProjectFile {
|
|
13
|
+
filePath: string;
|
|
14
|
+
content?: string;
|
|
15
|
+
importance?: number;
|
|
16
|
+
dropReason?: string;
|
|
17
|
+
wasIncluded?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface CustomInstruction {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
content: string;
|
|
23
|
+
}
|
|
24
|
+
export type CodeGenFramework = "react" | "html" | "mitosis" | "react-native" | "angular" | "vue" | "svelte" | "qwik" | "solid" | "marko" | "swiftui" | "jetpack-compose" | "flutter";
|
|
25
|
+
export type CodeGenStyleLibrary = "tailwind" | "tailwind-precise" | "emotion" | "styled-components" | "styled-jsx" | "react-native" | undefined;
|
|
26
|
+
export type CodeGenStopReason = "error" | "max_tokens" | "end" | "limit";
|
|
27
|
+
export type CodeGenMode = "exact" | "precise" | "precise_vision" | "creative" | "creative_vision" | "creative_only_vision";
|
|
28
|
+
export interface CodeGenInputOptions {
|
|
29
|
+
position: string;
|
|
30
|
+
eventName?: string;
|
|
31
|
+
sessionId: string;
|
|
32
|
+
codeGenMode?: "fast" | "quality-v2";
|
|
33
|
+
url?: string;
|
|
34
|
+
diffActions?: boolean;
|
|
35
|
+
planningPrompt?: boolean;
|
|
36
|
+
customInstructions?: CustomInstruction[];
|
|
37
|
+
userPrompt?: string;
|
|
38
|
+
files?: ProjectFile[];
|
|
39
|
+
rerankFiles?: number;
|
|
40
|
+
builderContent?: BuilderContent;
|
|
41
|
+
framework?: CodeGenFramework;
|
|
42
|
+
styleLibrary?: CodeGenStyleLibrary;
|
|
43
|
+
typescript?: boolean;
|
|
44
|
+
userContext?: UserContext;
|
|
45
|
+
maxTokens?: number;
|
|
46
|
+
maxPages?: number;
|
|
47
|
+
autoContinue?: number;
|
|
48
|
+
promptCaching?: boolean;
|
|
49
|
+
isAutoContinue?: boolean;
|
|
50
|
+
llmSuggestions?: boolean;
|
|
51
|
+
requestActions?: boolean;
|
|
52
|
+
conclusionText?: boolean;
|
|
53
|
+
searchResponse?: any | null;
|
|
54
|
+
prettierConfig?: PrettierOptions;
|
|
55
|
+
/** @deprecated */
|
|
56
|
+
history?: (UserMessageParam | AssistantMessageParam)[];
|
|
57
|
+
/** @deprecated */
|
|
58
|
+
prevId?: string;
|
|
59
|
+
/** @deprecated */
|
|
60
|
+
nextPage?: boolean;
|
|
61
|
+
/** @deprecated */
|
|
62
|
+
vcpId?: string;
|
|
63
|
+
}
|
package/src/codegen.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/events.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { BuilderContent, BuilderElement } from "@builder.io/sdk";
|
|
|
2
2
|
import type { AssistantMessage } from "./messages.js";
|
|
3
3
|
import type { AssistantSettings } from "./settings.js";
|
|
4
4
|
export type BuilderAssistantEventHandler = (ev: BuilderAssistantEvent) => void;
|
|
5
|
-
export type BuilderAssistantEvent = AssistantCompletionResultEvent | AssistantErrorEvent | AssistantStreamErrorEvent | AppCloseEvent | AppMessagesClickEvent | AppMessagesGenerationEvent | AppMessageEditCustomInstructionsEvent | AppPromptAbortEvent | AppPromptFocusEvent | AppPromptTextEvent | AppReadyEvent | AppSettingsResetEvent | AppSettingsSetEvent | AppThreadNewEvent | AssistantStatsEvent | BuilderEditorAuthEvent | BuilderEditorStateEvent | ContentUpdateEvent | ContentApplySnapshotEvent | ModelCreateEvent | ModelUpdateEvent | ModelUndoEvent | ModelRedoEvent | ResultEvent | ThreadCreatedEvent | ThreadMessageCompletedEvent | ThreadMessageCreatedEvent | ThreadMessageDeltaEvent | ThreadMessageFeedbackEvent | ThreadRunRequiresActionEvent | ThreadRunStepCreatedEvent | ThreadRunStepDeltaEvent | AppAcceptChangeEvent | AppAcceptRejectEvent | AssistantTrackEvent | AssistantEditorAuthMessage | AppAttachmentTemplateEvent;
|
|
5
|
+
export type BuilderAssistantEvent = AssistantCompletionResultEvent | AssistantErrorEvent | AssistantStreamErrorEvent | AppCloseEvent | AppMessagesClickEvent | AppMessagesGenerationEvent | AppMessageEditCustomInstructionsEvent | AppPromptAbortEvent | AppPromptFocusEvent | AppPromptTextEvent | AppReadyEvent | AppSettingsResetEvent | AppSettingsSetEvent | AppThreadNewEvent | AssistantStatsEvent | AssistantThemeEvent | BuilderEditorAuthEvent | BuilderEditorStateEvent | ContentUpdateEvent | ContentApplySnapshotEvent | ModelCreateEvent | ModelUpdateEvent | ModelUndoEvent | ModelRedoEvent | ResultEvent | ThreadCreatedEvent | ThreadMessageCompletedEvent | ThreadMessageCreatedEvent | ThreadMessageDeltaEvent | ThreadMessageFeedbackEvent | ThreadRunRequiresActionEvent | ThreadRunStepCreatedEvent | ThreadRunStepDeltaEvent | AppAcceptChangeEvent | AppAcceptRejectEvent | AssistantTrackEvent | AssistantEditorAuthMessage | AppAttachmentTemplateEvent | ThreadMessageRetryEvent;
|
|
6
6
|
export interface AssistantCompletionResultEvent {
|
|
7
7
|
type: "assistant.result";
|
|
8
8
|
data: {
|
|
@@ -30,6 +30,12 @@ export interface AssistantTrackEvent {
|
|
|
30
30
|
properties: Record<string, any>;
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
export interface AssistantThemeEvent {
|
|
34
|
+
type: "assistant.app.theme.update";
|
|
35
|
+
data: {
|
|
36
|
+
theme: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
33
39
|
export interface AppCloseEvent {
|
|
34
40
|
type: "assistant.app.close";
|
|
35
41
|
}
|
|
@@ -369,6 +375,9 @@ export interface ThreadMessageCompletedEvent {
|
|
|
369
375
|
type: "assistant.thread.message.completed";
|
|
370
376
|
data: ThreadMessageCompleted;
|
|
371
377
|
}
|
|
378
|
+
export interface ThreadMessageRetryEvent {
|
|
379
|
+
type: "assistant.thread.message.retry";
|
|
380
|
+
}
|
|
372
381
|
export interface ThreadMessageCompleted extends AssistantMessage {
|
|
373
382
|
platformId: string;
|
|
374
383
|
threadId: string;
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/mapping.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ESMImport } from "./codegen";
|
|
2
|
+
export interface UserContext {
|
|
3
|
+
client: string;
|
|
4
|
+
clientVersion: string;
|
|
5
|
+
nodeVersion: string;
|
|
6
|
+
systemPlatform: string;
|
|
7
|
+
frameworks: string[];
|
|
8
|
+
systemEOL: string;
|
|
9
|
+
systemArch: string;
|
|
10
|
+
systemShell?: string;
|
|
11
|
+
inGitRepo?: boolean;
|
|
12
|
+
[key: string]: string | string[] | boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
export type ExportType = "default" | "named";
|
|
15
|
+
/**
|
|
16
|
+
* Gets the latest component mappings for a space
|
|
17
|
+
*/
|
|
18
|
+
export interface FigmaMappingsData {
|
|
19
|
+
id: string;
|
|
20
|
+
figmaBuilderLinks: FigmaBuilderLink[];
|
|
21
|
+
version?: number;
|
|
22
|
+
createdDate?: string;
|
|
23
|
+
local: boolean;
|
|
24
|
+
userEmail?: string;
|
|
25
|
+
remoteUrl?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface FigmaBuilderLink {
|
|
28
|
+
builderName: string;
|
|
29
|
+
figmaName: string;
|
|
30
|
+
figmaKey: string;
|
|
31
|
+
figmaUrl?: string;
|
|
32
|
+
inputMapper?: string;
|
|
33
|
+
originalInputMapper?: string;
|
|
34
|
+
exportType?: ExportType;
|
|
35
|
+
importName?: string;
|
|
36
|
+
importPath?: string;
|
|
37
|
+
source: string;
|
|
38
|
+
loc?: string;
|
|
39
|
+
imports?: ESMImport[];
|
|
40
|
+
}
|
|
41
|
+
export interface FigmaMapperFile {
|
|
42
|
+
filePath: string;
|
|
43
|
+
content: string;
|
|
44
|
+
}
|
|
45
|
+
export interface PublishedMapping {
|
|
46
|
+
figmaBuilderLinks: FigmaBuilderLink[];
|
|
47
|
+
mapperFiles: FigmaMapperFile[];
|
|
48
|
+
remoteUrl?: string;
|
|
49
|
+
defaultBranch?: string;
|
|
50
|
+
currentBranch?: string;
|
|
51
|
+
commit?: string;
|
|
52
|
+
spaceKind?: string;
|
|
53
|
+
userContext?: UserContext;
|
|
54
|
+
}
|
|
55
|
+
export interface FigmaComponentInfo {
|
|
56
|
+
documentName: string;
|
|
57
|
+
key: string;
|
|
58
|
+
tree?: string;
|
|
59
|
+
jsx?: string;
|
|
60
|
+
type: string;
|
|
61
|
+
name: string;
|
|
62
|
+
exportJson?: any;
|
|
63
|
+
inputs: FigmaComponentInput[];
|
|
64
|
+
description: string;
|
|
65
|
+
documentationLinks: string[];
|
|
66
|
+
instanceId: string;
|
|
67
|
+
}
|
|
68
|
+
export interface FigmaComponentInput {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
value?: any;
|
|
72
|
+
type: string;
|
|
73
|
+
baseType: "text" | "variant" | "boolean" | "slot";
|
|
74
|
+
variantOptions?: string[];
|
|
75
|
+
isDefault: boolean;
|
|
76
|
+
ref?: string;
|
|
77
|
+
}
|
package/src/mapping.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/messages.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export interface AssistantMessageParam {
|
|
|
64
64
|
/**
|
|
65
65
|
* The contents of the assistant message.
|
|
66
66
|
*/
|
|
67
|
-
content: string |
|
|
67
|
+
content: string | ContentMessageItem[];
|
|
68
68
|
/**
|
|
69
69
|
* The role of the messages author, in this case `assistant`.
|
|
70
70
|
*/
|
|
@@ -115,13 +115,15 @@ export interface AssistantActionMessage {
|
|
|
115
115
|
export type Message = SystemMessage | UserMessage | AssistantMessage;
|
|
116
116
|
export type GeneratingMessage = null | Partial<AssistantActionMessage | AssistantMessage>;
|
|
117
117
|
export declare function getContentText(message: string | ContentMessage): string;
|
|
118
|
+
export declare function getContentAttachments(message: string | ContentMessage): ImageSource[];
|
|
118
119
|
export type Attachment = FileUpload | Template;
|
|
119
120
|
export interface FileUpload {
|
|
120
|
-
type:
|
|
121
|
+
type: "upload";
|
|
122
|
+
contentType: string;
|
|
121
123
|
name: string;
|
|
122
124
|
dataUrl: string;
|
|
123
125
|
size: number;
|
|
124
|
-
id:
|
|
126
|
+
id: string;
|
|
125
127
|
}
|
|
126
128
|
export interface Template {
|
|
127
129
|
type: "template";
|
package/src/messages.js
CHANGED
|
@@ -6,3 +6,11 @@ export function getContentText(message) {
|
|
|
6
6
|
.map((item) => (item.type === "text" ? item.text : ""))
|
|
7
7
|
.join("");
|
|
8
8
|
}
|
|
9
|
+
export function getContentAttachments(message) {
|
|
10
|
+
if (typeof message === "string") {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
return message
|
|
14
|
+
.filter((item) => item.type === "image")
|
|
15
|
+
.map((item) => item.source);
|
|
16
|
+
}
|
package/src/vcp.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ESMImport } from "./codegen";
|
|
2
|
+
export interface BuilderComponentInfo {
|
|
3
|
+
name: string;
|
|
4
|
+
inputs?: BuilderComponentInput[];
|
|
5
|
+
path: string;
|
|
6
|
+
imports: {
|
|
7
|
+
[key: string]: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
esmImports?: ESMImport[];
|
|
10
|
+
options?: any;
|
|
11
|
+
}
|
|
12
|
+
export interface BuilderComponentInput {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
value: any;
|
|
16
|
+
}
|
|
17
|
+
export interface BuilderComponentSlot {
|
|
18
|
+
figmaId: string;
|
|
19
|
+
builderName: string;
|
|
20
|
+
}
|
|
21
|
+
export interface JSXNode {
|
|
22
|
+
"@type": "jsx";
|
|
23
|
+
name: string;
|
|
24
|
+
props: Record<string, any>;
|
|
25
|
+
tagName?: string;
|
|
26
|
+
includeAirLayoutStyles?: boolean;
|
|
27
|
+
path?: string;
|
|
28
|
+
imports?: {
|
|
29
|
+
[key: string]: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
esmImports?: ESMImport[];
|
|
32
|
+
}
|
package/src/vcp.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|