@builder.io/ai-utils 0.97.0 → 0.98.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 +1 -1
- package/src/codegen.d.ts +12 -0
- package/src/codegen.js +3 -1
- package/src/completion.d.ts +14 -1
- package/src/events.d.ts +14 -2
- package/src/publish-agent.d.ts +4 -77
- package/src/publish-agent.js +3 -30
package/package.json
CHANGED
package/src/codegen.d.ts
CHANGED
|
@@ -2169,6 +2169,17 @@ export type CodeGenPosition = z.infer<typeof CodeGenPositionSchema>;
|
|
|
2169
2169
|
export declare const PublishAgentMessageRequestSchema: z.ZodObject<{
|
|
2170
2170
|
message: z.ZodOptional<z.ZodString>;
|
|
2171
2171
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
2172
|
+
modelOverride: z.ZodOptional<z.ZodString>;
|
|
2173
|
+
reasoning: z.ZodOptional<z.ZodEnum<{
|
|
2174
|
+
auto: "auto";
|
|
2175
|
+
high: "high";
|
|
2176
|
+
low: "low";
|
|
2177
|
+
max: "max";
|
|
2178
|
+
medium: "medium";
|
|
2179
|
+
minimal: "minimal";
|
|
2180
|
+
none: "none";
|
|
2181
|
+
xhigh: "xhigh";
|
|
2182
|
+
}>>;
|
|
2172
2183
|
toolResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2173
2184
|
type: z.ZodLiteral<"tool_result">;
|
|
2174
2185
|
tool_use_id: z.ZodString;
|
|
@@ -3988,6 +3999,7 @@ export interface GenerateCodeEventDone {
|
|
|
3988
3999
|
nextUrl: string;
|
|
3989
4000
|
autoContinue: boolean;
|
|
3990
4001
|
model: string;
|
|
4002
|
+
modelOverride?: string;
|
|
3991
4003
|
promptVersion: string | undefined;
|
|
3992
4004
|
/** True when this turn was a compaction pass run on an internal model. */
|
|
3993
4005
|
compact: boolean;
|
package/src/codegen.js
CHANGED
|
@@ -1781,6 +1781,8 @@ export const PublishAgentMessageRequestSchema = z
|
|
|
1781
1781
|
.object({
|
|
1782
1782
|
message: z.string().max(100000).optional(),
|
|
1783
1783
|
sessionId: z.string().min(1).max(256).optional(),
|
|
1784
|
+
modelOverride: z.string().min(1).max(256).optional(),
|
|
1785
|
+
reasoning: ReasoningEffortSchema.optional(),
|
|
1784
1786
|
toolResults: z.array(ContentMessageItemToolResultSchema).optional(),
|
|
1785
1787
|
confirmation: z
|
|
1786
1788
|
.object({
|
|
@@ -1793,7 +1795,7 @@ export const PublishAgentMessageRequestSchema = z
|
|
|
1793
1795
|
path: ["message"],
|
|
1794
1796
|
message: "A message or at least one tool result is required.",
|
|
1795
1797
|
})
|
|
1796
|
-
.refine(({
|
|
1798
|
+
.refine(({ toolResults, sessionId }) => !(toolResults === null || toolResults === void 0 ? void 0 : toolResults.length) || Boolean(sessionId), {
|
|
1797
1799
|
path: ["sessionId"],
|
|
1798
1800
|
message: "A session ID is required when continuing with tool results.",
|
|
1799
1801
|
})
|
package/src/completion.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BuilderContent, BuilderElement, Component } from "@builder.io/sdk";
|
|
2
|
-
import type { Message, MessageParam, Attachment } from "./messages.js";
|
|
2
|
+
import type { Message, MessageParam, Attachment, ContentMessageItemToolResult } from "./messages.js";
|
|
3
3
|
import type { BuilderModel } from "./events.js";
|
|
4
|
+
import type { ReasoningEffort } from "./codegen.js";
|
|
4
5
|
export type { BuilderContent, BuilderElement, Component };
|
|
5
6
|
export interface CompletionOptions {
|
|
6
7
|
/**
|
|
@@ -14,6 +15,11 @@ export interface CompletionOptions {
|
|
|
14
15
|
* Note: This is not the Builder.io data model.
|
|
15
16
|
*/
|
|
16
17
|
modelId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Reasoning effort for the selected LLM.
|
|
20
|
+
* Defaults according to the session mode, typically to medium.
|
|
21
|
+
*/
|
|
22
|
+
reasoning?: ReasoningEffort;
|
|
17
23
|
/**
|
|
18
24
|
* The unique LOCAL identifier of the thread to submit the user message to.
|
|
19
25
|
* This is used to identify the thread with our own id (openai assistant id is different)
|
|
@@ -84,6 +90,13 @@ export interface CompletionOptions {
|
|
|
84
90
|
*/
|
|
85
91
|
thread?: "persist" | "ephemeral";
|
|
86
92
|
attachments?: Attachment[];
|
|
93
|
+
/**
|
|
94
|
+
* Answers to a prior `AskUserQuestion` tool call, sent on the follow-up
|
|
95
|
+
* request that resumes the paused turn. Each entry's `tool_use_id` must match
|
|
96
|
+
* the `id` from the `assistant.model.question.required` event, so the resumed
|
|
97
|
+
* codegen session pairs the answer with its pending tool_use.
|
|
98
|
+
*/
|
|
99
|
+
toolResults?: ContentMessageItemToolResult[];
|
|
87
100
|
}
|
|
88
101
|
export interface BuilderEditorState {
|
|
89
102
|
/**
|
package/src/events.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { BuilderContent, BuilderElement } from "@builder.io/sdk";
|
|
2
2
|
import type { AssistantMessage, AssistantMessageAction } from "./messages.js";
|
|
3
3
|
import type { AssistantSettings } from "./settings.js";
|
|
4
|
-
import type { ExitState, UserSource, CodeGenPosition, ReviewSeverity, ReviewVerdict } from "./codegen.js";
|
|
4
|
+
import type { ExitState, UserSource, CodeGenPosition, ReviewSeverity, ReviewVerdict, AskUserQuestion } from "./codegen.js";
|
|
5
5
|
import type { FileUpload } from "./messages.js";
|
|
6
6
|
import type { BuilderConfigRealtime } from "./builder-config.js";
|
|
7
7
|
import type { DeployFailureReport } from "./projects.js";
|
|
8
8
|
export type BuilderAssistantEventHandler = (ev: BuilderAssistantEvent) => void;
|
|
9
|
-
export type BuilderAssistantEvent = AssistantCompletionResultEvent | AssistantErrorEvent | AssistantStreamErrorEvent | AppCloseEvent | AppMessagesClickEvent | AppMessagesGenerationEvent | AppMessageEditCustomInstructionsEvent | AppPromptAbortEvent | AppPromptFocusEvent | AppPromptSubmitEvent | AppReadyEvent | AppSettingsSetEvent | AppThreadNewEvent | AssistantStatsEvent | AssistantThemeEvent | BuilderEditorAuthEvent | BuilderEditorStateEvent | ContentUpdateEvent | ContentApplySnapshotEvent | ModelUndoEvent | ModelRedoEvent | ResultEvent | ThreadCreatedEvent | ThreadMessageCompletedEvent | ThreadMessageCreatedEvent | ThreadMessageDeltaEvent | ThreadMessageFeedbackEvent | ThreadRunStepCreatedEvent | ThreadRunStepDeltaEvent | AppAcceptChangeEvent | AppAcceptRejectEvent | AssistantTrackEvent | AssistantEditorAuthMessage | AppAttachmentTemplateEvent | AppPasteSmartExportEvent | ThreadMessageRetryEvent | AppFigmaImportEvent | AppWebImportEvent | AppMcpServersEvent | AssistantContentInitialEvent | ThreadMessageSummaryEvent | ThreadMessageSummaryCodegenDeltaEvent | ThreadMessageThinkingDeltaEvent | AssistantHeartbeatEvent | ShowUpgradeDialogEvent | AssistantFusionSuggestionEvent | AppNavigateToFusionEvent | ModelPermissionRequiredEvent | ModelPermissionResponseEvent;
|
|
9
|
+
export type BuilderAssistantEvent = AssistantCompletionResultEvent | AssistantErrorEvent | AssistantStreamErrorEvent | AppCloseEvent | AppMessagesClickEvent | AppMessagesGenerationEvent | AppMessageEditCustomInstructionsEvent | AppPromptAbortEvent | AppPromptFocusEvent | AppPromptSubmitEvent | AppReadyEvent | AppSettingsSetEvent | AppThreadNewEvent | AssistantStatsEvent | AssistantThemeEvent | BuilderEditorAuthEvent | BuilderEditorStateEvent | ContentUpdateEvent | ContentApplySnapshotEvent | ModelUndoEvent | ModelRedoEvent | ResultEvent | ThreadCreatedEvent | ThreadMessageCompletedEvent | ThreadMessageCreatedEvent | ThreadMessageDeltaEvent | ThreadMessageFeedbackEvent | ThreadRunStepCreatedEvent | ThreadRunStepDeltaEvent | AppAcceptChangeEvent | AppAcceptRejectEvent | AssistantTrackEvent | AssistantEditorAuthMessage | AppAttachmentTemplateEvent | AppPasteSmartExportEvent | ThreadMessageRetryEvent | AppFigmaImportEvent | AppWebImportEvent | AppMcpServersEvent | AssistantContentInitialEvent | ThreadMessageSummaryEvent | ThreadMessageSummaryCodegenDeltaEvent | ThreadMessageThinkingDeltaEvent | AssistantHeartbeatEvent | ShowUpgradeDialogEvent | AssistantFusionSuggestionEvent | AppNavigateToFusionEvent | ModelPermissionRequiredEvent | ModelPermissionResponseEvent | AssistantQuestionRequiredEvent;
|
|
10
10
|
export interface AssistantCompletionResultEvent {
|
|
11
11
|
type: "assistant.result";
|
|
12
12
|
data: {
|
|
@@ -1400,4 +1400,16 @@ export interface ModelPermissionResponseEvent extends AwaitResultEvent {
|
|
|
1400
1400
|
reason?: string;
|
|
1401
1401
|
};
|
|
1402
1402
|
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Emitted when the model calls `AskUserQuestion`. The turn pauses; the client
|
|
1405
|
+
* renders the questions and resumes by sending a new completion whose
|
|
1406
|
+
* `toolResults` carries a result with `tool_use_id === data.id`.
|
|
1407
|
+
*/
|
|
1408
|
+
export interface AssistantQuestionRequiredEvent {
|
|
1409
|
+
type: "assistant.model.question.required";
|
|
1410
|
+
data: {
|
|
1411
|
+
id: string;
|
|
1412
|
+
questions: AskUserQuestion[];
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1403
1415
|
export {};
|
package/src/publish-agent.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GenerateCompletionStep } from "./codegen.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
export declare const PublishAgentSessionCursorSchema: z.ZodObject<{
|
|
3
4
|
updatedAt: z.ZodNumber;
|
|
@@ -23,52 +24,6 @@ export declare const PublishAgentSessionUpdateRequestSchema: z.ZodObject<{
|
|
|
23
24
|
archived: z.ZodOptional<z.ZodBoolean>;
|
|
24
25
|
}, z.core.$strip>;
|
|
25
26
|
export type PublishAgentSessionUpdateRequest = z.infer<typeof PublishAgentSessionUpdateRequestSchema>;
|
|
26
|
-
export declare const PublishAgentAttachmentReferenceSchema: z.ZodObject<{
|
|
27
|
-
id: z.ZodOptional<z.ZodString>;
|
|
28
|
-
type: z.ZodString;
|
|
29
|
-
name: z.ZodOptional<z.ZodString>;
|
|
30
|
-
size: z.ZodOptional<z.ZodNumber>;
|
|
31
|
-
}, z.core.$strip>;
|
|
32
|
-
export type PublishAgentAttachmentReference = z.infer<typeof PublishAgentAttachmentReferenceSchema>;
|
|
33
|
-
export declare const PublishAgentToolReferenceSchema: z.ZodObject<{
|
|
34
|
-
id: z.ZodOptional<z.ZodString>;
|
|
35
|
-
name: z.ZodString;
|
|
36
|
-
status: z.ZodEnum<{
|
|
37
|
-
completed: "completed";
|
|
38
|
-
requested: "requested";
|
|
39
|
-
}>;
|
|
40
|
-
}, z.core.$strip>;
|
|
41
|
-
export type PublishAgentToolReference = z.infer<typeof PublishAgentToolReferenceSchema>;
|
|
42
|
-
export declare const PublishAgentSessionMessageSchema: z.ZodObject<{
|
|
43
|
-
id: z.ZodString;
|
|
44
|
-
role: z.ZodEnum<{
|
|
45
|
-
assistant: "assistant";
|
|
46
|
-
user: "user";
|
|
47
|
-
}>;
|
|
48
|
-
senderId: z.ZodOptional<z.ZodString>;
|
|
49
|
-
content: z.ZodOptional<z.ZodString>;
|
|
50
|
-
createdAt: z.ZodNumber;
|
|
51
|
-
status: z.ZodEnum<{
|
|
52
|
-
completed: "completed";
|
|
53
|
-
error: "error";
|
|
54
|
-
running: "running";
|
|
55
|
-
}>;
|
|
56
|
-
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
57
|
-
id: z.ZodOptional<z.ZodString>;
|
|
58
|
-
type: z.ZodString;
|
|
59
|
-
name: z.ZodOptional<z.ZodString>;
|
|
60
|
-
size: z.ZodOptional<z.ZodNumber>;
|
|
61
|
-
}, z.core.$strip>>>;
|
|
62
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
63
|
-
id: z.ZodOptional<z.ZodString>;
|
|
64
|
-
name: z.ZodString;
|
|
65
|
-
status: z.ZodEnum<{
|
|
66
|
-
completed: "completed";
|
|
67
|
-
requested: "requested";
|
|
68
|
-
}>;
|
|
69
|
-
}, z.core.$strip>>>;
|
|
70
|
-
}, z.core.$strip>;
|
|
71
|
-
export type PublishAgentSessionMessage = z.infer<typeof PublishAgentSessionMessageSchema>;
|
|
72
27
|
export declare const PublishAgentSessionSummarySchema: z.ZodObject<{
|
|
73
28
|
id: z.ZodString;
|
|
74
29
|
spaceId: z.ZodString;
|
|
@@ -114,36 +69,8 @@ export declare const PublishAgentSessionDetailResponseSchema: z.ZodObject<{
|
|
|
114
69
|
totalCompletions: z.ZodNumber;
|
|
115
70
|
numUserMessages: z.ZodNumber;
|
|
116
71
|
}, z.core.$strip>;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
assistant: "assistant";
|
|
121
|
-
user: "user";
|
|
122
|
-
}>;
|
|
123
|
-
senderId: z.ZodOptional<z.ZodString>;
|
|
124
|
-
content: z.ZodOptional<z.ZodString>;
|
|
125
|
-
createdAt: z.ZodNumber;
|
|
126
|
-
status: z.ZodEnum<{
|
|
127
|
-
completed: "completed";
|
|
128
|
-
error: "error";
|
|
129
|
-
running: "running";
|
|
130
|
-
}>;
|
|
131
|
-
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
132
|
-
id: z.ZodOptional<z.ZodString>;
|
|
133
|
-
type: z.ZodString;
|
|
134
|
-
name: z.ZodOptional<z.ZodString>;
|
|
135
|
-
size: z.ZodOptional<z.ZodNumber>;
|
|
136
|
-
}, z.core.$strip>>>;
|
|
137
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
138
|
-
id: z.ZodOptional<z.ZodString>;
|
|
139
|
-
name: z.ZodString;
|
|
140
|
-
status: z.ZodEnum<{
|
|
141
|
-
completed: "completed";
|
|
142
|
-
requested: "requested";
|
|
143
|
-
}>;
|
|
144
|
-
}, z.core.$strip>>>;
|
|
145
|
-
}, z.core.$strip>>;
|
|
146
|
-
messagesCanLoadMore: z.ZodBoolean;
|
|
147
|
-
messagesNextCursor: z.ZodNullable<z.ZodString>;
|
|
72
|
+
steps: z.ZodArray<z.ZodCustom<GenerateCompletionStep, GenerateCompletionStep>>;
|
|
73
|
+
canLoadMore: z.ZodBoolean;
|
|
74
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
148
75
|
}, z.core.$strip>;
|
|
149
76
|
export type PublishAgentSessionDetailResponse = z.infer<typeof PublishAgentSessionDetailResponseSchema>;
|
package/src/publish-agent.js
CHANGED
|
@@ -30,33 +30,6 @@ export const PublishAgentSessionUpdateRequestSchema = z
|
|
|
30
30
|
message: "Provide title, archived, or both.",
|
|
31
31
|
})
|
|
32
32
|
.meta({ title: "PublishAgentSessionUpdateRequest" });
|
|
33
|
-
export const PublishAgentAttachmentReferenceSchema = z
|
|
34
|
-
.object({
|
|
35
|
-
id: z.string().optional(),
|
|
36
|
-
type: z.string(),
|
|
37
|
-
name: z.string().optional(),
|
|
38
|
-
size: z.number().optional(),
|
|
39
|
-
})
|
|
40
|
-
.meta({ title: "PublishAgentAttachmentReference" });
|
|
41
|
-
export const PublishAgentToolReferenceSchema = z
|
|
42
|
-
.object({
|
|
43
|
-
id: z.string().optional(),
|
|
44
|
-
name: z.string(),
|
|
45
|
-
status: z.enum(["requested", "completed"]),
|
|
46
|
-
})
|
|
47
|
-
.meta({ title: "PublishAgentToolReference" });
|
|
48
|
-
export const PublishAgentSessionMessageSchema = z
|
|
49
|
-
.object({
|
|
50
|
-
id: z.string(),
|
|
51
|
-
role: z.enum(["user", "assistant"]),
|
|
52
|
-
senderId: z.string().optional(),
|
|
53
|
-
content: z.string().optional(),
|
|
54
|
-
createdAt: z.number(),
|
|
55
|
-
status: z.enum(["completed", "running", "error"]),
|
|
56
|
-
attachments: z.array(PublishAgentAttachmentReferenceSchema).optional(),
|
|
57
|
-
tools: z.array(PublishAgentToolReferenceSchema).optional(),
|
|
58
|
-
})
|
|
59
|
-
.meta({ title: "PublishAgentSessionMessage" });
|
|
60
33
|
export const PublishAgentSessionSummarySchema = z
|
|
61
34
|
.object({
|
|
62
35
|
id: z.string(),
|
|
@@ -81,8 +54,8 @@ export const PublishAgentSessionListResponseSchema = z
|
|
|
81
54
|
export const PublishAgentSessionDetailResponseSchema = z
|
|
82
55
|
.object({
|
|
83
56
|
session: PublishAgentSessionSummarySchema,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
57
|
+
steps: z.array(z.custom()),
|
|
58
|
+
canLoadMore: z.boolean(),
|
|
59
|
+
nextCursor: z.string().nullable(),
|
|
87
60
|
})
|
|
88
61
|
.meta({ title: "PublishAgentSessionDetailResponse" });
|