@builder.io/ai-utils 0.29.0 → 0.30.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 +9 -8
- package/src/connectivity/checks/http-check.js +2 -1
- package/src/projects.d.ts +54 -0
- package/src/projects.js +68 -0
package/package.json
CHANGED
package/src/codegen.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export interface CustomInstruction {
|
|
|
32
32
|
allowedTools?: string[];
|
|
33
33
|
hideUI?: boolean;
|
|
34
34
|
isSkill?: boolean;
|
|
35
|
+
disableModelInvocation?: boolean;
|
|
36
|
+
userInvocable?: boolean;
|
|
35
37
|
}
|
|
36
38
|
export interface CustomAgentInfo {
|
|
37
39
|
name: string;
|
|
@@ -486,18 +488,15 @@ export interface SendMessageToolInput {
|
|
|
486
488
|
channelId: string;
|
|
487
489
|
markdown: string;
|
|
488
490
|
status: "starting" | "question" | "will-follow-up" | "done:success" | "done:error";
|
|
491
|
+
loadingMessage?: string;
|
|
489
492
|
}
|
|
490
493
|
export interface SpawnBranchToolInput {
|
|
491
494
|
projectId: string;
|
|
492
495
|
message: string;
|
|
493
496
|
builderUserId?: string;
|
|
494
497
|
hidden?: boolean;
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
projectId: string;
|
|
498
|
-
branchName: string;
|
|
499
|
-
message: string;
|
|
500
|
-
builderUserId?: string;
|
|
498
|
+
sourceChannelId?: string;
|
|
499
|
+
sourceDmId?: string;
|
|
501
500
|
}
|
|
502
501
|
export interface ReadBranchToolInput {
|
|
503
502
|
projectId: string;
|
|
@@ -606,7 +605,6 @@ export interface CodeGenToolMap {
|
|
|
606
605
|
SetEnvVariable: SetEnvVariableToolInput;
|
|
607
606
|
SendMessage: SendMessageToolInput;
|
|
608
607
|
SpawnBranch: SpawnBranchToolInput;
|
|
609
|
-
SendMessageToBranch: SendMessageToBranchToolInput;
|
|
610
608
|
ReadBranch: ReadBranchToolInput;
|
|
611
609
|
RunningAgents: RunningAgentsToolInput;
|
|
612
610
|
}
|
|
@@ -1174,6 +1172,9 @@ export interface UserSourceBuilder extends UserSourceBase {
|
|
|
1174
1172
|
}
|
|
1175
1173
|
export interface UserSourceAgent extends UserSourceBase {
|
|
1176
1174
|
source: "agent";
|
|
1175
|
+
userId?: string;
|
|
1176
|
+
userName?: string;
|
|
1177
|
+
userEmail?: string;
|
|
1177
1178
|
}
|
|
1178
1179
|
export type UserSource = UserSourceOther | UserSourceBuilder | UserSourceAgent;
|
|
1179
1180
|
export type AutoPushMode = "force-push" | "merge-push" | "ff-push" | "safe-push" | "none";
|
|
@@ -2127,7 +2128,7 @@ export interface RepoMetrics {
|
|
|
2127
2128
|
languages: LanguageInfo[];
|
|
2128
2129
|
isEmpty: boolean;
|
|
2129
2130
|
isMonorepo: boolean;
|
|
2130
|
-
monorepoType?: "npm-workspaces" | "yarn-workspaces" | "pnpm-workspaces" | "lerna" | "nx" | "turborepo" | "cargo-workspaces" | "other";
|
|
2131
|
+
monorepoType?: "npm-workspaces" | "yarn-workspaces" | "pnpm-workspaces" | "bun-workspaces" | "lerna" | "nx" | "turborepo" | "rush" | "moon" | "cargo-workspaces" | "go-workspaces" | "other";
|
|
2131
2132
|
frameworks: FrameworkInfo[];
|
|
2132
2133
|
setupRequirements: SetupRequirement[];
|
|
2133
2134
|
packageManagers: string[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, } from "../error-codes.js";
|
|
2
|
+
import { isBrowser } from "../environment.js";
|
|
2
3
|
const DEFAULT_TIMEOUT_MS = 30000;
|
|
3
4
|
const LATENCY_THRESHOLD_MS = 5000;
|
|
4
5
|
export async function httpCheck(options) {
|
|
@@ -10,7 +11,7 @@ export async function httpCheck(options) {
|
|
|
10
11
|
const response = await fetchFn(target, {
|
|
11
12
|
method: "HEAD",
|
|
12
13
|
signal: controller.signal,
|
|
13
|
-
redirect: "follow",
|
|
14
|
+
redirect: isBrowser() ? "follow" : "manual",
|
|
14
15
|
});
|
|
15
16
|
clearTimeout(timeoutId);
|
|
16
17
|
const durationMs = Date.now() - startTime;
|
package/src/projects.d.ts
CHANGED
|
@@ -374,6 +374,7 @@ export interface PrInfo {
|
|
|
374
374
|
prNumber: number;
|
|
375
375
|
prUrl: string;
|
|
376
376
|
status: PRStatus;
|
|
377
|
+
updatedAt: number;
|
|
377
378
|
}
|
|
378
379
|
/**
|
|
379
380
|
* Metadata stored in branches for integration tracking and PR description generation.
|
|
@@ -423,6 +424,7 @@ export interface BranchSharedData {
|
|
|
423
424
|
prUrl?: string | null;
|
|
424
425
|
prInfoByFolder?: Record<string, PrInfo> | null;
|
|
425
426
|
prStatus?: PRStatus;
|
|
427
|
+
prStatusUpdatedAt?: number | null;
|
|
426
428
|
machineId?: string | null;
|
|
427
429
|
lastMachineIdRemovedAt?: number | null;
|
|
428
430
|
volumeId?: string | null;
|
|
@@ -925,4 +927,56 @@ export interface MemorySummary extends Pick<MemoryData, (typeof MEMORY_SUMMARY_F
|
|
|
925
927
|
export interface GetProjectMemoriesResult {
|
|
926
928
|
memories: MemorySummary[];
|
|
927
929
|
}
|
|
930
|
+
interface BaseSendMessageMessage {
|
|
931
|
+
}
|
|
932
|
+
export interface ValidatingBranchMessage extends BaseSendMessageMessage {
|
|
933
|
+
type: "validating-branch";
|
|
934
|
+
message: string;
|
|
935
|
+
projectId: string;
|
|
936
|
+
branchName: string;
|
|
937
|
+
}
|
|
938
|
+
export interface SettingUpContainerMessage extends BaseSendMessageMessage {
|
|
939
|
+
type: "setting-up-container";
|
|
940
|
+
message: string;
|
|
941
|
+
projectId: string;
|
|
942
|
+
branchName: string;
|
|
943
|
+
}
|
|
944
|
+
export interface SendingMessageMessage extends BaseSendMessageMessage {
|
|
945
|
+
type: "sending-message";
|
|
946
|
+
message: string;
|
|
947
|
+
projectId: string;
|
|
948
|
+
branchName: string;
|
|
949
|
+
}
|
|
950
|
+
export interface MessageSentMessage extends BaseSendMessageMessage {
|
|
951
|
+
type: "message-sent";
|
|
952
|
+
message: string;
|
|
953
|
+
projectId: string;
|
|
954
|
+
branchName: string;
|
|
955
|
+
url: string;
|
|
956
|
+
}
|
|
957
|
+
export interface SendMessageErrorMessage extends BaseSendMessageMessage {
|
|
958
|
+
type: "error";
|
|
959
|
+
message: string;
|
|
960
|
+
error: string;
|
|
961
|
+
projectId: string;
|
|
962
|
+
branchName: string;
|
|
963
|
+
}
|
|
964
|
+
export interface EnsureContainerMessage extends BaseSendMessageMessage {
|
|
965
|
+
type: "ensure-container";
|
|
966
|
+
event: ProjectsChunkMessage;
|
|
967
|
+
}
|
|
968
|
+
export interface AiMessage extends BaseSendMessageMessage {
|
|
969
|
+
type: "ai";
|
|
970
|
+
event: GenerateCompletionStep;
|
|
971
|
+
}
|
|
972
|
+
export type SendMessageChunkMessage = ValidatingBranchMessage | SettingUpContainerMessage | SendingMessageMessage | MessageSentMessage | SendMessageErrorMessage | EnsureContainerMessage | AiMessage;
|
|
973
|
+
export interface ExitPlanModeData {
|
|
974
|
+
plan: string;
|
|
975
|
+
sessionMode?: string;
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Parses an ExitPlanMode tool result from a streaming chunk
|
|
979
|
+
* Extracts the plan content and sessionMode from the tool's structured result
|
|
980
|
+
*/
|
|
981
|
+
export declare function parseExitPlanMode(chunk: CreateBranchChunkMessage | SendMessageChunkMessage): ExitPlanModeData | null;
|
|
928
982
|
export {};
|
package/src/projects.js
CHANGED
|
@@ -92,3 +92,71 @@ export const MEMORY_SUMMARY_FIELDS = [
|
|
|
92
92
|
"glob",
|
|
93
93
|
"updatedAt",
|
|
94
94
|
];
|
|
95
|
+
/**
|
|
96
|
+
* Parses an ExitPlanMode tool result from a streaming chunk
|
|
97
|
+
* Extracts the plan content and sessionMode from the tool's structured result
|
|
98
|
+
*/
|
|
99
|
+
export function parseExitPlanMode(chunk) {
|
|
100
|
+
// Check if this is an AI chunk
|
|
101
|
+
if (chunk.type !== "ai") {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const event = chunk.event;
|
|
105
|
+
// Look for tool_result events for ExitPlanMode
|
|
106
|
+
if (event.type === "tool_result") {
|
|
107
|
+
const result = event.result;
|
|
108
|
+
// Check if this is the ExitPlanMode tool
|
|
109
|
+
if (result.tool_name === "ExitPlanMode") {
|
|
110
|
+
let plan;
|
|
111
|
+
let sessionMode;
|
|
112
|
+
// The content should be a JSON string with the structured result
|
|
113
|
+
if (typeof result.tool_input === "string") {
|
|
114
|
+
try {
|
|
115
|
+
const parsed = JSON.parse(result.tool_input);
|
|
116
|
+
if (parsed && typeof parsed.plan === "string" && !plan) {
|
|
117
|
+
plan = parsed.plan;
|
|
118
|
+
}
|
|
119
|
+
if (parsed &&
|
|
120
|
+
typeof parsed.sessionMode === "string" &&
|
|
121
|
+
!sessionMode) {
|
|
122
|
+
sessionMode = parsed.sessionMode;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (_a) {
|
|
126
|
+
// If parsing fails, ignore and return null
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (typeof result.content === "string") {
|
|
130
|
+
try {
|
|
131
|
+
const parsed = JSON.parse(result.content);
|
|
132
|
+
if (parsed && typeof parsed.plan === "string" && !plan) {
|
|
133
|
+
plan = parsed.plan;
|
|
134
|
+
}
|
|
135
|
+
if (parsed &&
|
|
136
|
+
typeof parsed.sessionMode === "string" &&
|
|
137
|
+
!sessionMode) {
|
|
138
|
+
sessionMode = parsed.sessionMode;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (_b) {
|
|
142
|
+
// If parsing fails, ignore and return null
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Also check structured_result directly (fallback)
|
|
146
|
+
if (result.structured_result &&
|
|
147
|
+
typeof result.structured_result.plan === "string" &&
|
|
148
|
+
!plan) {
|
|
149
|
+
plan = result.structured_result.plan;
|
|
150
|
+
}
|
|
151
|
+
if (result.structured_result &&
|
|
152
|
+
typeof result.structured_result.sessionMode === "string" &&
|
|
153
|
+
!sessionMode) {
|
|
154
|
+
sessionMode = result.structured_result.sessionMode;
|
|
155
|
+
}
|
|
156
|
+
if (plan) {
|
|
157
|
+
return { plan, sessionMode };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}
|