@builder.io/ai-utils 0.17.2 → 0.18.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/ai-utils",
3
- "version": "0.17.2",
3
+ "version": "0.18.0",
4
4
  "description": "Builder.io AI utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/codegen.d.ts CHANGED
@@ -44,6 +44,7 @@ export interface CustomAgentDefinition {
44
44
  needDevServer?: boolean;
45
45
  needValidation?: boolean;
46
46
  includeMemories?: boolean;
47
+ resetAfterRun?: boolean;
47
48
  }
48
49
  export type CodeGenFramework = "react" | "html" | "mitosis" | "react-native" | "angular" | "vue" | "svelte" | "qwik" | "solid" | "marko" | "swiftui" | "jetpack-compose" | "flutter";
49
50
  export type CodeGenStyleLibrary = "tailwind" | "tailwind-precise" | "emotion" | "styled-components" | "styled-jsx" | "react-native" | undefined;
@@ -349,7 +350,7 @@ export interface CodeGenInputOptions {
349
350
  /** @deprecated */
350
351
  systemReminderPrompt?: string;
351
352
  }
352
- export type CodeGenErrorCodes = "credits-limit-daily" | "credits-limit-monthly" | "credits-limit-other" | "cli-genetic-error" | "git-update-error" | "prompt-too-long" | "context-too-long" | "abrupt-end" | "unknown" | "failed-recover-state" | "completion-expired" | "ask-to-continue" | "bad-initial-url" | "invalid-last-message" | "corrupted-session" | "privacy-mode-key-required" | "privacy-mode-key-invalid" | "cli-network-error" | "assertion" | "rate-limit" | "unknown-design-system";
353
+ export type CodeGenErrorCodes = "credits-limit-daily" | "credits-limit-monthly" | "credits-limit-other" | "cli-genetic-error" | "git-update-error" | "prompt-too-long" | "context-too-long" | "abrupt-end" | "unknown" | "failed-recover-state" | "completion-expired" | "ask-to-continue" | "bad-initial-url" | "bad-smart-export-payload" | "invalid-last-message" | "corrupted-session" | "privacy-mode-key-required" | "privacy-mode-key-invalid" | "cli-network-error" | "assertion" | "rate-limit" | "unknown-design-system";
353
354
  export interface CodegenUsage {
354
355
  total: number;
355
356
  fast: number;
@@ -750,6 +751,7 @@ export type UserSourcePermission = "editCode" | "modifyMcpServers" | "modifyProj
750
751
  export interface UserSourceBase {
751
752
  role: "user" | "agent";
752
753
  principals?: string[];
754
+ jobs?: string[];
753
755
  permissions?: UserSourcePermission[];
754
756
  }
755
757
  export interface UserSourceOther extends UserSourceBase {
@@ -1,154 +1,158 @@
1
- import type { BuilderContent, BuilderElement, Component } from "@builder.io/sdk";
1
+ import type {
2
+ BuilderContent,
3
+ BuilderElement,
4
+ Component,
5
+ } from "@builder.io/sdk";
2
6
  import type { Message, MessageParam, Attachment } from "./messages.js";
3
7
  import type { BuilderModel } from "./events.js";
4
8
  export type { BuilderContent, BuilderElement, Component };
5
9
  export interface CompletionOptions {
6
- /**
7
- * How this assistant is being used. For example, "content-editor"
8
- * is used when the assistant is being used in the Builder.io content editor.
9
- */
10
- assistantType?: string;
11
- /**
12
- * LLM Model identifier to lookup which sdk and model to use.
13
- * If not provided the default model will be used.
14
- * Note: This is not the Builder.io data model.
15
- */
16
- modelId?: string;
17
- /**
18
- * The unique LOCAL identifier of the thread to submit the user message to.
19
- * This is used to identify the thread with our own id (openai assistant id is different)
20
- */
21
- id: string;
22
- /**
23
- * The unique OPENAI assistant id of the thread to submit the user message to.
24
- * If the assistantThreadId is not provided, a new thread will be created.
25
- */
26
- assistantThreadId?: string;
27
- /**
28
- * The message history of the conversation, user prompt then assistant response.
29
- * The messages are ordered from oldest to newest. The last message in the array
30
- * is the message that the user has just sent.
31
- */
32
- messages: (MessageParam | Message)[];
33
- /**
34
- * Which platform (framework) the the user has choosen to get help with.
35
- */
36
- platformId?: string;
37
- /**
38
- * The user id of the user sending the message.
39
- * This is used to track the user's progress in the conversation.
40
- * User id is stored in localStorage for this domain, its not the builder user id.
41
- */
42
- userId: string;
43
- /**
44
- * The state of the builder editor.
45
- */
46
- builderState?: BuilderEditorState;
47
- /**
48
- * Additional console logs
49
- */
50
- debug?: boolean;
51
- /**
52
- * Date.now() timestamp of when the assistant was started.
53
- * This is used to calculate the time taken between all events.
54
- */
55
- startMs?: number;
56
- /**
57
- * If events should be streamed back throughout the process.
58
- *
59
- * Setting to `false` will skip any intermediate processing and emitting
60
- * events while collecting LLM deltas, but will only emit the final result.
61
- *
62
- * Defaults to `true`.
63
- */
64
- stream?: boolean;
65
- /**
66
- * Provide a system prompt id to lookup a pre-defined system prompt
67
- * text sent to the LLM. Must be a pre-defined system prompt id!
68
- */
69
- systemPromptIds?: {
70
- "content-edit"?: string;
71
- };
72
- /**
73
- * Option on how this call should handle the conversation thread.
74
- *
75
- * `persist`:
76
- * - When there is no CompletionOptions `id`, it'll create a new thread id
77
- * - When given an existing `id`, it'll look up the past thread messages and prefix the messages
78
- *
79
- * `ephemeral`:
80
- * - Creates a new conversation each time, ignoring any existing thread history
81
- * - Will not save the conversation for future use
82
- *
83
- * Defaults to `persist`
84
- */
85
- thread?: "persist" | "ephemeral";
86
- attachments?: Attachment[];
10
+ /**
11
+ * How this assistant is being used. For example, "content-editor"
12
+ * is used when the assistant is being used in the Builder.io content editor.
13
+ */
14
+ assistantType?: string;
15
+ /**
16
+ * LLM Model identifier to lookup which sdk and model to use.
17
+ * If not provided the default model will be used.
18
+ * Note: This is not the Builder.io data model.
19
+ */
20
+ modelId?: string;
21
+ /**
22
+ * The unique LOCAL identifier of the thread to submit the user message to.
23
+ * This is used to identify the thread with our own id (openai assistant id is different)
24
+ */
25
+ id: string;
26
+ /**
27
+ * The unique OPENAI assistant id of the thread to submit the user message to.
28
+ * If the assistantThreadId is not provided, a new thread will be created.
29
+ */
30
+ assistantThreadId?: string;
31
+ /**
32
+ * The message history of the conversation, user prompt then assistant response.
33
+ * The messages are ordered from oldest to newest. The last message in the array
34
+ * is the message that the user has just sent.
35
+ */
36
+ messages: (MessageParam | Message)[];
37
+ /**
38
+ * Which platform (framework) the the user has choosen to get help with.
39
+ */
40
+ platformId?: string;
41
+ /**
42
+ * The user id of the user sending the message.
43
+ * This is used to track the user's progress in the conversation.
44
+ * User id is stored in localStorage for this domain, its not the builder user id.
45
+ */
46
+ userId: string;
47
+ /**
48
+ * The state of the builder editor.
49
+ */
50
+ builderState?: BuilderEditorState;
51
+ /**
52
+ * Additional console logs
53
+ */
54
+ debug?: boolean;
55
+ /**
56
+ * Date.now() timestamp of when the assistant was started.
57
+ * This is used to calculate the time taken between all events.
58
+ */
59
+ startMs?: number;
60
+ /**
61
+ * If events should be streamed back throughout the process.
62
+ *
63
+ * Setting to `false` will skip any intermediate processing and emitting
64
+ * events while collecting LLM deltas, but will only emit the final result.
65
+ *
66
+ * Defaults to `true`.
67
+ */
68
+ stream?: boolean;
69
+ /**
70
+ * Provide a system prompt id to lookup a pre-defined system prompt
71
+ * text sent to the LLM. Must be a pre-defined system prompt id!
72
+ */
73
+ systemPromptIds?: {
74
+ "content-edit"?: string;
75
+ };
76
+ /**
77
+ * Option on how this call should handle the conversation thread.
78
+ *
79
+ * `persist`:
80
+ * - When there is no CompletionOptions `id`, it'll create a new thread id
81
+ * - When given an existing `id`, it'll look up the past thread messages and prefix the messages
82
+ *
83
+ * `ephemeral`:
84
+ * - Creates a new conversation each time, ignoring any existing thread history
85
+ * - Will not save the conversation for future use
86
+ *
87
+ * Defaults to `persist`
88
+ */
89
+ thread?: "persist" | "ephemeral";
90
+ attachments?: Attachment[];
87
91
  }
88
92
  export interface BuilderEditorState {
89
- /**
90
- * The active locale of the builder editor.
91
- */
92
- activeLocale?: string;
93
- /**
94
- * The locale of the provided builder content.
95
- */
96
- contentLocale?: string;
97
- /**
98
- * Top level Builder content. The data.blocks array contains the BuilderElement.
99
- */
100
- content?: BuilderContent;
101
- /**
102
- * Builder custom components.
103
- */
104
- components?: Component[];
105
- /**
106
- * Builder design tokens.
107
- */
108
- designTokens?: Record<string, string>;
109
- /**
110
- * Builder model. (not the LLM model)
111
- */
112
- model?: BuilderModel;
113
- /**
114
- * Other models in the Builder account
115
- */
116
- otherModels?: BuilderModel[];
117
- /**
118
- * The URL that the Builder content preview is pointing to.
119
- */
120
- previewUrl?: string;
121
- /**
122
- * Selected ids in the builder.
123
- */
124
- selectedIds?: string[];
125
- /**
126
- * Builder space id.
127
- */
128
- spaceId?: string;
129
- /**
130
- * Builder user id.
131
- */
132
- userId?: string;
133
- /**
134
- * Email of the user in the builder.
135
- */
136
- userEmail?: string;
137
- /**
138
- * User's jobs
139
- */
140
- userJobs?: string[];
141
- /**
142
- * Builder session id.
143
- */
144
- sessionId?: string;
145
- /**
146
- * Custom instructions that could be add into the prompt.
147
- */
148
- customInstructions?: Record<string, string>;
149
- styleInspirationURL?: string;
150
- /**
151
- * All targeting attributes of the content.
152
- */
153
- allTargetingAttributes?: Record<string, any>;
93
+ /**
94
+ * The active locale of the builder editor.
95
+ */
96
+ activeLocale?: string;
97
+ /**
98
+ * The locale of the provided builder content.
99
+ */
100
+ contentLocale?: string;
101
+ /**
102
+ * Top level Builder content. The data.blocks array contains the BuilderElement.
103
+ */
104
+ content?: BuilderContent;
105
+ /**
106
+ * Builder custom components.
107
+ */
108
+ components?: Component[];
109
+ /**
110
+ * Builder design tokens.
111
+ */
112
+ designTokens?: Record<string, string>;
113
+ /**
114
+ * Builder model. (not the LLM model)
115
+ */
116
+ model?: BuilderModel;
117
+ /**
118
+ * Other models in the Builder account
119
+ */
120
+ otherModels?: BuilderModel[];
121
+ /**
122
+ * The URL that the Builder content preview is pointing to.
123
+ */
124
+ previewUrl?: string;
125
+ /**
126
+ * Selected ids in the builder.
127
+ */
128
+ selectedIds?: string[];
129
+ /**
130
+ * Builder space id.
131
+ */
132
+ spaceId?: string;
133
+ /**
134
+ * Builder user id.
135
+ */
136
+ userId?: string;
137
+ /**
138
+ * Email of the user in the builder.
139
+ */
140
+ userEmail?: string;
141
+ /**
142
+ * User's jobs
143
+ */
144
+ userJobs?: string[];
145
+ /**
146
+ * Builder session id.
147
+ */
148
+ sessionId?: string;
149
+ /**
150
+ * Custom instructions that could be add into the prompt.
151
+ */
152
+ customInstructions?: Record<string, string>;
153
+ styleInspirationURL?: string;
154
+ /**
155
+ * All targeting attributes of the content.
156
+ */
157
+ allTargetingAttributes?: Record<string, any>;
154
158
  }