@builder.io/ai-utils 0.29.1 → 0.31.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 -2
- package/src/connectivity/checks/http-check.d.ts +2 -0
- package/src/connectivity/checks/http-check.js +17 -6
- package/src/connectivity/run-checks.js +4 -4
- package/src/connectivity/types.d.ts +6 -0
- package/src/projects.d.ts +55 -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;
|
|
@@ -203,7 +205,6 @@ export interface BuilderEditToolInput {
|
|
|
203
205
|
}
|
|
204
206
|
export interface GetScreenshotToolInput {
|
|
205
207
|
href?: string;
|
|
206
|
-
url?: string;
|
|
207
208
|
selector?: string;
|
|
208
209
|
width?: number;
|
|
209
210
|
height?: number;
|
|
@@ -325,6 +326,7 @@ export interface ExitToolInput {
|
|
|
325
326
|
isMicrofrontend?: boolean;
|
|
326
327
|
setupNeedsCredentials?: boolean;
|
|
327
328
|
devServerNeedsCredentials?: boolean;
|
|
329
|
+
needsVPN?: boolean;
|
|
328
330
|
/** A human-readable description of what the project is about (not tech specs), used by fusion to route requests to the right project */
|
|
329
331
|
projectDescription?: string;
|
|
330
332
|
}
|
|
@@ -417,6 +419,7 @@ export interface ProposedConfig {
|
|
|
417
419
|
projectDescription?: string;
|
|
418
420
|
cost?: number;
|
|
419
421
|
durationMs?: number;
|
|
422
|
+
needsVPN?: boolean;
|
|
420
423
|
}
|
|
421
424
|
/**
|
|
422
425
|
* Parameters for proposing a configuration to the backend
|
|
@@ -448,6 +451,7 @@ export interface ProposeConfigParams {
|
|
|
448
451
|
setupNeedsCredentials?: boolean;
|
|
449
452
|
devServerNeedsCredentials?: boolean;
|
|
450
453
|
projectDescription?: string;
|
|
454
|
+
needsVPN?: boolean;
|
|
451
455
|
}
|
|
452
456
|
export interface VerifySetupCommandToolInput {
|
|
453
457
|
command: string;
|
|
@@ -486,12 +490,15 @@ export interface SendMessageToolInput {
|
|
|
486
490
|
channelId: string;
|
|
487
491
|
markdown: string;
|
|
488
492
|
status: "starting" | "question" | "will-follow-up" | "done:success" | "done:error";
|
|
493
|
+
loadingMessage?: string;
|
|
489
494
|
}
|
|
490
495
|
export interface SpawnBranchToolInput {
|
|
491
496
|
projectId: string;
|
|
492
497
|
message: string;
|
|
493
498
|
builderUserId?: string;
|
|
494
499
|
hidden?: boolean;
|
|
500
|
+
sourceChannelId?: string;
|
|
501
|
+
sourceDmId?: string;
|
|
495
502
|
}
|
|
496
503
|
export interface ReadBranchToolInput {
|
|
497
504
|
projectId: string;
|
|
@@ -1817,6 +1824,7 @@ export interface LaunchServerStatus {
|
|
|
1817
1824
|
activeOperations: number;
|
|
1818
1825
|
diskUsage?: number;
|
|
1819
1826
|
memoryUsage?: number;
|
|
1827
|
+
sessionId?: string;
|
|
1820
1828
|
}
|
|
1821
1829
|
/**
|
|
1822
1830
|
* VS Code Tunnel status information
|
|
@@ -1864,6 +1872,8 @@ export interface FusionStatus {
|
|
|
1864
1872
|
diskUsage?: number;
|
|
1865
1873
|
/** Current memory usage as a ratio (0-1, where 1 is fully used) */
|
|
1866
1874
|
memoryUsage?: number;
|
|
1875
|
+
/** Session ID of the active codegen session */
|
|
1876
|
+
sessionId?: string;
|
|
1867
1877
|
}
|
|
1868
1878
|
export interface FusionMetrics {
|
|
1869
1879
|
counters?: {
|
|
@@ -2123,7 +2133,7 @@ export interface RepoMetrics {
|
|
|
2123
2133
|
languages: LanguageInfo[];
|
|
2124
2134
|
isEmpty: boolean;
|
|
2125
2135
|
isMonorepo: boolean;
|
|
2126
|
-
monorepoType?: "npm-workspaces" | "yarn-workspaces" | "pnpm-workspaces" | "lerna" | "nx" | "turborepo" | "cargo-workspaces" | "other";
|
|
2136
|
+
monorepoType?: "npm-workspaces" | "yarn-workspaces" | "pnpm-workspaces" | "bun-workspaces" | "lerna" | "nx" | "turborepo" | "rush" | "moon" | "cargo-workspaces" | "go-workspaces" | "other";
|
|
2127
2137
|
frameworks: FrameworkInfo[];
|
|
2128
2138
|
setupRequirements: SetupRequirement[];
|
|
2129
2139
|
packageManagers: string[];
|
|
@@ -5,5 +5,7 @@ export interface HttpCheckOptions {
|
|
|
5
5
|
testId: TestId;
|
|
6
6
|
timeout?: number;
|
|
7
7
|
fetchFn?: ConnectivityFetchFn;
|
|
8
|
+
/** Fetch dispatcher for proxy routing (e.g. undici ProxyAgent). */
|
|
9
|
+
dispatcher?: object;
|
|
8
10
|
}
|
|
9
11
|
export declare function httpCheck(options: HttpCheckOptions): Promise<CheckResult>;
|
|
@@ -1,17 +1,28 @@
|
|
|
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) {
|
|
5
|
-
const { target, source, testId, timeout = DEFAULT_TIMEOUT_MS, fetchFn = fetch, } = options;
|
|
6
|
+
const { target, source, testId, timeout = DEFAULT_TIMEOUT_MS, fetchFn = fetch, dispatcher, } = options;
|
|
6
7
|
const startTime = Date.now();
|
|
7
8
|
const controller = new AbortController();
|
|
8
9
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
9
10
|
try {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const method = "HEAD";
|
|
12
|
+
const redirect = isBrowser() ? "follow" : "manual";
|
|
13
|
+
const signal = controller.signal;
|
|
14
|
+
/**
|
|
15
|
+
* The custom fetch fn used in dev tools has proxy handling built-in, so no need
|
|
16
|
+
* for a custom dispatcher.
|
|
17
|
+
*/
|
|
18
|
+
const response = dispatcher
|
|
19
|
+
? await fetch(target, {
|
|
20
|
+
method,
|
|
21
|
+
signal,
|
|
22
|
+
redirect,
|
|
23
|
+
dispatcher,
|
|
24
|
+
})
|
|
25
|
+
: await fetchFn(target, { method, signal, redirect });
|
|
15
26
|
clearTimeout(timeoutId);
|
|
16
27
|
const durationMs = Date.now() - startTime;
|
|
17
28
|
const errorCode = mapHttpStatusToErrorCode(response.status);
|
|
@@ -6,7 +6,7 @@ import { tcpCheck } from "./checks/tcp-check.js";
|
|
|
6
6
|
import { tlsCheck } from "./checks/tls-check.js";
|
|
7
7
|
import { sshCheck } from "./checks/ssh-check.js";
|
|
8
8
|
export async function runChecks(input) {
|
|
9
|
-
const { tests, gitHost, onProgress, fetchFn } = input;
|
|
9
|
+
const { tests, gitHost, onProgress, fetchFn, dispatcher } = input;
|
|
10
10
|
const results = [];
|
|
11
11
|
const total = tests.length;
|
|
12
12
|
for (let index = 0; index < tests.length; index++) {
|
|
@@ -17,7 +17,7 @@ export async function runChecks(input) {
|
|
|
17
17
|
index,
|
|
18
18
|
total,
|
|
19
19
|
});
|
|
20
|
-
const result = await runSingleCheck(test, gitHost, fetchFn);
|
|
20
|
+
const result = await runSingleCheck(test, gitHost, fetchFn, dispatcher);
|
|
21
21
|
results.push(result);
|
|
22
22
|
emitProgress(onProgress, {
|
|
23
23
|
type: "test:complete",
|
|
@@ -36,7 +36,7 @@ export async function runChecks(input) {
|
|
|
36
36
|
results,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
async function runSingleCheck(test, gitHost, fetchFn) {
|
|
39
|
+
async function runSingleCheck(test, gitHost, fetchFn, dispatcher) {
|
|
40
40
|
const { source, testId } = test;
|
|
41
41
|
const checkType = getCheckTypeForTestId(testId);
|
|
42
42
|
if (!isCheckAvailable(checkType)) {
|
|
@@ -80,7 +80,7 @@ async function runSingleCheck(test, gitHost, fetchFn) {
|
|
|
80
80
|
}
|
|
81
81
|
switch (checkType) {
|
|
82
82
|
case "http":
|
|
83
|
-
return httpCheck({ target, source, testId, fetchFn });
|
|
83
|
+
return httpCheck({ target, source, testId, fetchFn, dispatcher });
|
|
84
84
|
case "dns":
|
|
85
85
|
return dnsCheck({
|
|
86
86
|
hostname: extractHostname(target),
|
|
@@ -19,6 +19,12 @@ export interface RunChecksInput {
|
|
|
19
19
|
* environments.
|
|
20
20
|
*/
|
|
21
21
|
fetchFn?: ConnectivityFetchFn;
|
|
22
|
+
/**
|
|
23
|
+
* Fetch dispatcher for proxy routing (e.g. undici ProxyAgent).
|
|
24
|
+
* Passed through to the `dispatcher` option of fetch for HTTP checks.
|
|
25
|
+
* Typically only needed server-side for static IP routing.
|
|
26
|
+
*/
|
|
27
|
+
dispatcher?: object;
|
|
22
28
|
}
|
|
23
29
|
export type ProgressEvent = {
|
|
24
30
|
type: "test:start";
|
package/src/projects.d.ts
CHANGED
|
@@ -343,6 +343,7 @@ export interface PartialBranchData {
|
|
|
343
343
|
name?: string;
|
|
344
344
|
createdBy: string;
|
|
345
345
|
friendlyName?: string;
|
|
346
|
+
description?: string;
|
|
346
347
|
isDefault: boolean;
|
|
347
348
|
isPublic: boolean;
|
|
348
349
|
lockedFusionEnvironment?: FusionExecutionEnvironment;
|
|
@@ -357,6 +358,7 @@ export interface PartialBranchData {
|
|
|
357
358
|
useHomeDir?: boolean;
|
|
358
359
|
agentType?: AgentType;
|
|
359
360
|
checkoutBranch?: string | null;
|
|
361
|
+
prNumber?: number;
|
|
360
362
|
/** Whether this branch is for a fork PR - affects git operations (read-only, can't push) */
|
|
361
363
|
isFork?: boolean | null;
|
|
362
364
|
/** Whether this branch is for a code review - affects enabled agents and tools*/
|
|
@@ -442,6 +444,7 @@ export interface BranchSharedData {
|
|
|
442
444
|
isPublic?: boolean;
|
|
443
445
|
isDefault?: boolean;
|
|
444
446
|
friendlyName?: string;
|
|
447
|
+
description?: string;
|
|
445
448
|
useHomeDir?: boolean;
|
|
446
449
|
useCloudHomeDir?: boolean;
|
|
447
450
|
reviewers?: string[] | null;
|
|
@@ -927,4 +930,56 @@ export interface MemorySummary extends Pick<MemoryData, (typeof MEMORY_SUMMARY_F
|
|
|
927
930
|
export interface GetProjectMemoriesResult {
|
|
928
931
|
memories: MemorySummary[];
|
|
929
932
|
}
|
|
933
|
+
interface BaseSendMessageMessage {
|
|
934
|
+
}
|
|
935
|
+
export interface ValidatingBranchMessage extends BaseSendMessageMessage {
|
|
936
|
+
type: "validating-branch";
|
|
937
|
+
message: string;
|
|
938
|
+
projectId: string;
|
|
939
|
+
branchName: string;
|
|
940
|
+
}
|
|
941
|
+
export interface SettingUpContainerMessage extends BaseSendMessageMessage {
|
|
942
|
+
type: "setting-up-container";
|
|
943
|
+
message: string;
|
|
944
|
+
projectId: string;
|
|
945
|
+
branchName: string;
|
|
946
|
+
}
|
|
947
|
+
export interface SendingMessageMessage extends BaseSendMessageMessage {
|
|
948
|
+
type: "sending-message";
|
|
949
|
+
message: string;
|
|
950
|
+
projectId: string;
|
|
951
|
+
branchName: string;
|
|
952
|
+
}
|
|
953
|
+
export interface MessageSentMessage extends BaseSendMessageMessage {
|
|
954
|
+
type: "message-sent";
|
|
955
|
+
message: string;
|
|
956
|
+
projectId: string;
|
|
957
|
+
branchName: string;
|
|
958
|
+
url: string;
|
|
959
|
+
}
|
|
960
|
+
export interface SendMessageErrorMessage extends BaseSendMessageMessage {
|
|
961
|
+
type: "error";
|
|
962
|
+
message: string;
|
|
963
|
+
error: string;
|
|
964
|
+
projectId: string;
|
|
965
|
+
branchName: string;
|
|
966
|
+
}
|
|
967
|
+
export interface EnsureContainerMessage extends BaseSendMessageMessage {
|
|
968
|
+
type: "ensure-container";
|
|
969
|
+
event: ProjectsChunkMessage;
|
|
970
|
+
}
|
|
971
|
+
export interface AiMessage extends BaseSendMessageMessage {
|
|
972
|
+
type: "ai";
|
|
973
|
+
event: GenerateCompletionStep;
|
|
974
|
+
}
|
|
975
|
+
export type SendMessageChunkMessage = ValidatingBranchMessage | SettingUpContainerMessage | SendingMessageMessage | MessageSentMessage | SendMessageErrorMessage | EnsureContainerMessage | AiMessage;
|
|
976
|
+
export interface ExitPlanModeData {
|
|
977
|
+
plan: string;
|
|
978
|
+
sessionMode?: string;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Parses an ExitPlanMode tool result from a streaming chunk
|
|
982
|
+
* Extracts the plan content and sessionMode from the tool's structured result
|
|
983
|
+
*/
|
|
984
|
+
export declare function parseExitPlanMode(chunk: CreateBranchChunkMessage | SendMessageChunkMessage): ExitPlanModeData | null;
|
|
930
985
|
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
|
+
}
|