@builder.io/ai-utils 0.0.58 → 0.0.60
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/dist/events.d.ts +12 -1
- package/dist/fetch.js +25 -3
- package/dist/messages.d.ts +1 -0
- package/package.json +1 -1
package/dist/events.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Thread } from "./thread";
|
|
|
3
3
|
import type { AssistantMessage } from "./messages";
|
|
4
4
|
import { AssistantSettings } from "./settings";
|
|
5
5
|
export type BuilderAssistantEventHandler = (ev: BuilderAssistantEvent) => void;
|
|
6
|
-
export type BuilderAssistantEvent = AssistantErrorEvent | AssistantStreamErrorEvent | AppCloseEvent | AppMessagesClickEvent | AppMessagesGenerationEvent | 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;
|
|
6
|
+
export type BuilderAssistantEvent = 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;
|
|
7
7
|
export interface AssistantError {
|
|
8
8
|
message: string;
|
|
9
9
|
status?: number;
|
|
@@ -23,6 +23,9 @@ export interface AppCloseEvent {
|
|
|
23
23
|
export interface AppMessagesClickEvent {
|
|
24
24
|
type: "assistant.app.messages.click";
|
|
25
25
|
}
|
|
26
|
+
export interface AppMessageEditCustomInstructionsEvent {
|
|
27
|
+
type: "assistant.app.messages.editCustomInstructions";
|
|
28
|
+
}
|
|
26
29
|
export interface AppMessagesGenerationEvent {
|
|
27
30
|
type: "assistant.app.messages.generation";
|
|
28
31
|
data: {
|
|
@@ -127,6 +130,10 @@ interface ContentPatchBase {
|
|
|
127
130
|
* A change value is considered incomplete until we also parsed it's closing xml tag.
|
|
128
131
|
*/
|
|
129
132
|
incomplete?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* If there was an error applying the patch, this will contain the error message.
|
|
135
|
+
*/
|
|
136
|
+
error?: string;
|
|
130
137
|
}
|
|
131
138
|
export interface ContentTsCodePatch extends ContentPatchBase {
|
|
132
139
|
type: "ts_code";
|
|
@@ -295,6 +302,10 @@ export interface ThreadMessageFeedback {
|
|
|
295
302
|
messageId: string;
|
|
296
303
|
userId: string;
|
|
297
304
|
commitId?: string;
|
|
305
|
+
frontendDomain: string | undefined;
|
|
306
|
+
frontendCommitId: string | undefined;
|
|
307
|
+
backendDomain?: string;
|
|
308
|
+
backendCommitId: string | undefined;
|
|
298
309
|
feedbackText: string;
|
|
299
310
|
thread: Thread;
|
|
300
311
|
platformId: string;
|
package/dist/fetch.js
CHANGED
|
@@ -9,13 +9,23 @@ export async function fetchJsonl(input, init, onData) {
|
|
|
9
9
|
...init.headers,
|
|
10
10
|
},
|
|
11
11
|
};
|
|
12
|
-
const rsp = await
|
|
12
|
+
const rsp = await (async () => {
|
|
13
|
+
try {
|
|
14
|
+
return await fetch(input, init);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
reject(new NetworkError(`${input}, status: network failure`));
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
if (!rsp) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
13
23
|
if (!rsp.ok) {
|
|
14
|
-
reject(new
|
|
24
|
+
reject(new APIError(`${input}, status: ${rsp.status}`));
|
|
15
25
|
return;
|
|
16
26
|
}
|
|
17
27
|
if (!rsp.body) {
|
|
18
|
-
reject(new
|
|
28
|
+
reject(new APIError(`${input}, missing body`));
|
|
19
29
|
return;
|
|
20
30
|
}
|
|
21
31
|
const reader = rsp.body.getReader();
|
|
@@ -59,3 +69,15 @@ export async function fetchJsonl(input, init, onData) {
|
|
|
59
69
|
}
|
|
60
70
|
});
|
|
61
71
|
}
|
|
72
|
+
class NetworkError extends Error {
|
|
73
|
+
constructor(message) {
|
|
74
|
+
super(message);
|
|
75
|
+
this.name = "NetworkError";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
class APIError extends Error {
|
|
79
|
+
constructor(message) {
|
|
80
|
+
super(message);
|
|
81
|
+
this.name = "APIError";
|
|
82
|
+
}
|
|
83
|
+
}
|
package/dist/messages.d.ts
CHANGED