@builder.io/ai-utils 0.3.10 → 0.3.12

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.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Builder.io AI utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/codegen.ts CHANGED
@@ -70,11 +70,13 @@ export type CompletionStopReason =
70
70
  | "content_filter"
71
71
  | "error"
72
72
  | "aborted"
73
+ | "pause_turn"
74
+ | "refusal"
73
75
  | null;
74
76
 
75
77
  export interface ViewPathToolInput {
76
- filePath: string;
77
- viewRange?: [number, number];
78
+ file_path: string;
79
+ view_range?: [number, number];
78
80
  }
79
81
 
80
82
  export interface GlobSearchToolInput {
@@ -83,8 +85,8 @@ export interface GlobSearchToolInput {
83
85
 
84
86
  export interface GrepSearchToolInput {
85
87
  query: string;
86
- includeGlob?: string;
87
- excludeGlob?: string;
88
+ include_glob?: string;
89
+ exclude_glob?: string;
88
90
  }
89
91
 
90
92
  export interface GetRuleToolInput {
@@ -98,7 +100,7 @@ export interface GetStyleInspirationToolInput {
98
100
  export interface GetBuildOutputToolInput {}
99
101
  export interface DevServerControlInput {
100
102
  restart?: boolean;
101
- getLogs?: boolean;
103
+ get_logs?: boolean;
102
104
  }
103
105
 
104
106
  export interface BashToolInput {
@@ -110,6 +112,19 @@ export interface WebSearchToolInput {
110
112
  query: string;
111
113
  }
112
114
 
115
+ export interface WriteFileInput {
116
+ title: string;
117
+ file_path: string;
118
+ content: string;
119
+ }
120
+
121
+ export interface SearchReplaceInput {
122
+ title: string;
123
+ file_path: string;
124
+ old_str: string;
125
+ new_str: string;
126
+ }
127
+
113
128
  export interface CodeGenToolMap {
114
129
  view_path: ViewPathToolInput;
115
130
  glob_search: GlobSearchToolInput;
@@ -120,10 +135,17 @@ export interface CodeGenToolMap {
120
135
  dev_server_control: DevServerControlInput;
121
136
  bash: BashToolInput;
122
137
  web_search: WebSearchToolInput;
138
+ write_file: WriteFileInput;
139
+ search_replace_file: SearchReplaceInput;
123
140
  }
124
141
 
125
142
  export type CodeGenTools = keyof CodeGenToolMap;
126
143
 
144
+ export type AllCodeGenTools =
145
+ | CodeGenTools
146
+ | "str_replace_editor"
147
+ | "web_search";
148
+
127
149
  export type CodeGenMode =
128
150
  | "exact" // @deprecated
129
151
  | "precise" // tries to match the design as close
@@ -166,7 +188,6 @@ export interface CodeGenInputOptions {
166
188
  maxPages?: number;
167
189
  autoContinue?: number;
168
190
  promptCaching?: boolean;
169
- isAutoContinue?: boolean;
170
191
  llmSuggestions?: boolean;
171
192
  conclusionText?: boolean;
172
193
 
@@ -175,6 +196,10 @@ export interface CodeGenInputOptions {
175
196
  // Prettier options
176
197
  prettierConfig?: PrettierOptions;
177
198
 
199
+ // Role
200
+ role?: "user" | "agent";
201
+ user?: UserSource;
202
+
178
203
  /** @deprecated */
179
204
  history?: (UserMessageParam | AssistantMessageParam)[];
180
205
  /** @deprecated */
@@ -223,7 +248,8 @@ export interface ActionItem {
223
248
  | "thinking"
224
249
  | "tool"
225
250
  | "suggestion"
226
- | "tool_result";
251
+ | "tool_result"
252
+ | "server_tool_result";
227
253
  id?: string;
228
254
  content: string;
229
255
  filePath?: string;
@@ -349,6 +375,7 @@ export interface GenerateCompletionStepStart {
349
375
  id: string | undefined;
350
376
  title: string;
351
377
  content: string;
378
+ filePath?: string;
352
379
  }
353
380
 
354
381
  export interface GenerateCompletionStepDelta {
@@ -455,6 +482,13 @@ export interface GenerateCompletionStepSession {
455
482
  hasChanges: boolean;
456
483
  }
457
484
 
485
+ export interface GenerateCompletionStepServerToolResult {
486
+ type: "server_tool_result";
487
+ content: any;
488
+ title: string;
489
+ id: string;
490
+ }
491
+
458
492
  export type GenerateCompletionStep = { timestamp?: number } & (
459
493
  | GenerateCompletionStepPlanning
460
494
  | GenerateCompletionStepStart
@@ -474,6 +508,7 @@ export type GenerateCompletionStep = { timestamp?: number } & (
474
508
  | GenerateCompletionStepState
475
509
  | GenerateCompletionStepStdio
476
510
  | GenerateCompletionStepSession
511
+ | GenerateCompletionStepServerToolResult
477
512
  | GenerateCompletionStepToolResult
478
513
  );
479
514
 
@@ -486,7 +521,30 @@ export interface ApplyActionsResult {
486
521
  oldContent?: string;
487
522
  }
488
523
 
524
+ export interface UserSourceBuilder {
525
+ source: "builder.io";
526
+ userId?: string;
527
+ userName?: string;
528
+ userEmail?: string;
529
+ role: "user";
530
+ }
531
+
532
+ export interface UserSourceGithub {
533
+ source: "github";
534
+ userName: string;
535
+ link?: string;
536
+ role: "user" | "agent";
537
+ }
538
+
539
+ export interface UserSourceAgent {
540
+ source: "agent";
541
+ role: "agent";
542
+ }
543
+
544
+ export type UserSource = UserSourceBuilder | UserSourceGithub | UserSourceAgent;
545
+
489
546
  export interface GenerateUserMessage {
547
+ user?: UserSource;
490
548
  userPrompt: string;
491
549
  ephemeralUserPrompt?: string;
492
550
  displayPrompt?: string;
@@ -594,6 +652,8 @@ export interface GenerateCodeEventUser {
594
652
  type: "user";
595
653
  id: string;
596
654
  displayPrompt: string | undefined;
655
+ user: UserSource;
656
+ /** @deprecated */
597
657
  role: "user" | "agent";
598
658
  }
599
659
 
package/src/events.ts CHANGED
@@ -245,6 +245,15 @@ interface ContentPatchBase {
245
245
  * If there was an error applying the patch, this will contain the error message.
246
246
  */
247
247
  error?: string;
248
+
249
+ /**
250
+ * If `true`, Editor AI attempted to process this patch. It could be that the patch
251
+ * had invalid syntax or that the LLM made its changes incorrectly. This can be used
252
+ * to differentiate between a patch that is actively being streamed in, as indicated by
253
+ * the "incomplete" property, and a patch that is has finished streaming and is being
254
+ * processed.
255
+ */
256
+ attemptedProcess?: boolean;
248
257
  }
249
258
 
250
259
  export interface ContentTsUpdateComponentPatch extends ContentPatchBase {
package/src/messages.ts CHANGED
@@ -13,6 +13,7 @@ export interface ContentMessageItemText {
13
13
  type: "text";
14
14
  text: string;
15
15
  cache?: boolean;
16
+ citations?: TextCitationParam[] | null;
16
17
  ephemeral?: boolean;
17
18
  }
18
19
 
@@ -48,7 +49,7 @@ export interface ContentMessageItemToolResult {
48
49
  tool_input?: string;
49
50
  title?: string;
50
51
  content: string;
51
- is_error: boolean;
52
+ is_error?: boolean;
52
53
  cache?: boolean;
53
54
  ephemeral?: boolean;
54
55
  }
@@ -83,6 +84,104 @@ export interface ContentMessageItemToolUse {
83
84
  name: string;
84
85
  }
85
86
 
87
+ export interface CitationCharLocationParam {
88
+ cited_text: string;
89
+
90
+ document_index: number;
91
+
92
+ document_title: string | null;
93
+
94
+ end_char_index: number;
95
+
96
+ start_char_index: number;
97
+
98
+ type: "char_location";
99
+ }
100
+
101
+ export interface CitationContentBlockLocationParam {
102
+ cited_text: string;
103
+
104
+ document_index: number;
105
+
106
+ document_title: string | null;
107
+
108
+ end_block_index: number;
109
+
110
+ start_block_index: number;
111
+
112
+ type: "content_block_location";
113
+ }
114
+
115
+ export interface CitationPageLocationParam {
116
+ cited_text: string;
117
+
118
+ document_index: number;
119
+
120
+ document_title: string | null;
121
+
122
+ end_page_number: number;
123
+
124
+ start_page_number: number;
125
+
126
+ type: "page_location";
127
+ }
128
+
129
+ export interface CitationWebSearchResultLocationParam {
130
+ cited_text: string;
131
+
132
+ encrypted_index: string;
133
+
134
+ title: string | null;
135
+
136
+ type: "web_search_result_location";
137
+
138
+ url: string;
139
+ }
140
+
141
+ export type TextCitationParam =
142
+ | CitationCharLocationParam
143
+ | CitationPageLocationParam
144
+ | CitationContentBlockLocationParam
145
+ | CitationWebSearchResultLocationParam;
146
+
147
+ export interface ServerToolUseContent {
148
+ type: "web_search_result";
149
+ title: string;
150
+ url: string;
151
+ page_age: string | null;
152
+ encrypted_content: string;
153
+ }
154
+
155
+ export interface ServerToolUseContentError {
156
+ error_code:
157
+ | "invalid_tool_input"
158
+ | "unavailable"
159
+ | "max_uses_exceeded"
160
+ | "too_many_requests"
161
+ | "query_too_long";
162
+
163
+ type: "web_search_tool_result_error";
164
+ }
165
+
166
+ export type ServerToolUseContentUnion =
167
+ | ServerToolUseContent[]
168
+ | ServerToolUseContentError;
169
+
170
+ export interface ContentMessageItemServerToolUse {
171
+ type: "server_tool_use";
172
+ id: string;
173
+ name: "web_search";
174
+ input: unknown;
175
+ completion?: string;
176
+ content?: ServerToolUseContentUnion;
177
+ }
178
+
179
+ export interface ContentMessageItemWebSearchToolResult {
180
+ content: ServerToolUseContent[] | ServerToolUseContentError;
181
+ tool_use_id: string;
182
+ type: "web_search_tool_result";
183
+ }
184
+
86
185
  export type ContentMessageItem =
87
186
  | ContentMessageItemText
88
187
  | ContentMessageItemImage
@@ -90,7 +189,9 @@ export type ContentMessageItem =
90
189
  | ContentMessageItemThinking
91
190
  | ContentMessageItemRedactedThinking
92
191
  | ContentMessageItemToolUse
93
- | ContentMessageItemToolResult;
192
+ | ContentMessageItemToolResult
193
+ | ContentMessageItemWebSearchToolResult
194
+ | ContentMessageItemServerToolUse;
94
195
 
95
196
  export type ContentMessage = ContentMessageItem[];
96
197