builder.io 1.6.29 → 1.6.30
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/cli/index.cjs +467 -467
- package/cli/index.cjs.map +4 -4
- package/core/index.cjs +1 -1
- package/core/index.mjs +1 -1
- package/node/index.cjs +1 -1
- package/node/index.mjs +1 -1
- package/package.json +1 -1
- package/server/index.cjs +120 -109
- package/server/index.mjs +120 -109
- package/types/cli/code-tools.d.ts +11 -4
- package/types/cli/codegen.d.ts +17 -6
- package/types/cli/index.d.ts +0 -30
- package/types/cli/launch/helpers.d.ts +65 -0
- package/types/cli/launch/install-jsx-plugin.d.ts +4 -4
- package/types/cli/launch/logger.d.ts +45 -0
- package/types/cli/launch/server.d.ts +9 -0
- package/types/cli/launch-init.d.ts +13 -0
- package/types/cli/launch.d.ts +31 -2
- package/types/cli/server-ws.d.ts +1 -7
- package/types/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CodeGenTools, ContentMessageItemToolResult, ProjectFile } from "$/ai-utils";
|
|
2
2
|
import type { DevToolsSys } from "../core";
|
|
3
|
+
import type { RunCommandCtx } from "./codegen";
|
|
3
4
|
export interface LLMToolCalls {
|
|
4
5
|
name: CodeGenTools;
|
|
5
6
|
input: Record<string, any>;
|
|
@@ -10,10 +11,16 @@ export interface ToolResolution {
|
|
|
10
11
|
isError: boolean;
|
|
11
12
|
title?: string;
|
|
12
13
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
14
|
+
export interface ProvidedToolContext {
|
|
15
|
+
commandCtx?: RunCommandCtx;
|
|
16
|
+
allowedCommands?: RegExp[];
|
|
17
|
+
}
|
|
18
|
+
export interface ToolContext extends ProvidedToolContext {
|
|
19
|
+
sys: DevToolsSys;
|
|
20
|
+
files: ProjectFile[];
|
|
21
|
+
signal: AbortSignal | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare function resolveToolCalls(toolContext: ToolContext, toolCalls: LLMToolCalls[]): Promise<ContentMessageItemToolResult[]>;
|
|
17
24
|
interface RipgrepMatch {
|
|
18
25
|
path: string;
|
|
19
26
|
lineNumber: number;
|
package/types/cli/codegen.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { DevToolsSys } from "../types";
|
|
2
2
|
import type { CLIArgs } from "./index";
|
|
3
3
|
import { type Credentials } from "./credentials";
|
|
4
|
-
import type { CodegenTurn, CustomInstruction, GenerateCompletionStep, GenerateUserMessage, UserContext } from "$/ai-utils";
|
|
4
|
+
import type { CodegenTurn, CustomInstruction, GenerateCompletionState, GenerateCompletionStep, GenerateUserMessage, UserContext } from "$/ai-utils";
|
|
5
5
|
import prettier from "prettier";
|
|
6
|
-
|
|
6
|
+
import { type ProvidedToolContext } from "./code-tools";
|
|
7
|
+
import type { ChildProcessWithoutNullStreams } from "child_process";
|
|
8
|
+
export interface RunCommandCtx {
|
|
9
|
+
command: string;
|
|
10
|
+
getAllStdout: () => string;
|
|
11
|
+
getAllStderr: () => string;
|
|
12
|
+
getOutput: () => string;
|
|
13
|
+
pid: number | undefined;
|
|
14
|
+
process: ChildProcessWithoutNullStreams;
|
|
15
|
+
onStdout: (callback: (data: string) => void) => void;
|
|
16
|
+
onStderr: (callback: (data: string) => void) => void;
|
|
17
|
+
}
|
|
7
18
|
export interface SessionContext {
|
|
8
19
|
sessionId: string;
|
|
9
20
|
turns: CodegenTurn[];
|
|
@@ -11,7 +22,7 @@ export interface SessionContext {
|
|
|
11
22
|
customInstructions: CustomInstruction[];
|
|
12
23
|
userContext: UserContext;
|
|
13
24
|
prettierConfig: prettier.Config | null;
|
|
14
|
-
state:
|
|
25
|
+
state: GenerateCompletionState;
|
|
15
26
|
}
|
|
16
27
|
export interface CodeGenSessionOptionsBase {
|
|
17
28
|
sys: DevToolsSys;
|
|
@@ -23,6 +34,7 @@ export interface CodeGenSessionOptionsBase {
|
|
|
23
34
|
fusionRemote?: string;
|
|
24
35
|
fusionAutoInitGit?: boolean;
|
|
25
36
|
featureBranch?: string;
|
|
37
|
+
providedToolContext?: ProvidedToolContext;
|
|
26
38
|
}
|
|
27
39
|
export interface CodeGenSessionOptionsSession extends CodeGenSessionOptionsBase {
|
|
28
40
|
sessionOrCompletionId?: string;
|
|
@@ -78,18 +90,18 @@ export declare class CodeGenSession {
|
|
|
78
90
|
*/
|
|
79
91
|
undoLastUserMessage(dryRun?: boolean): Promise<string[] | null>;
|
|
80
92
|
getLastCompletionId(): string | undefined;
|
|
81
|
-
getCurrentState():
|
|
93
|
+
getCurrentState(): GenerateCompletionState;
|
|
82
94
|
getLastTurn(): CodegenTurn | undefined;
|
|
83
95
|
getNextUrl(): string | undefined;
|
|
84
96
|
getNextMessage(): Promise<GenerateUserMessage>;
|
|
85
97
|
sendFeedback(sentiment: "positive" | "negative" | "undo", message?: string, lastCompletionId?: string | undefined): Promise<void>;
|
|
86
98
|
hasUndoChanges(): Promise<boolean>;
|
|
87
|
-
isBusy(): boolean;
|
|
88
99
|
sendMessage(message: GenerateUserMessage): void;
|
|
89
100
|
getTurns(): CodegenTurn[];
|
|
90
101
|
getSessionContext(): SessionContext;
|
|
91
102
|
abort(): void;
|
|
92
103
|
stopEventLoop(): Promise<void>;
|
|
104
|
+
close(): Promise<void>;
|
|
93
105
|
connectToEventLoop(shouldReplay: boolean, onStep: (step: GenerateCompletionStep) => void): () => void;
|
|
94
106
|
waitForEventLoop(): Promise<void>;
|
|
95
107
|
agentCompletion(userMessage: GenerateUserMessage, signal: AbortSignal | undefined, onStep: (step: GenerateCompletionStep) => Promise<void> | void): Promise<void>;
|
|
@@ -97,4 +109,3 @@ export declare class CodeGenSession {
|
|
|
97
109
|
export declare function transformStream(body: ReadableStream<Uint8Array> | null): AsyncGenerator<string, void, unknown>;
|
|
98
110
|
export declare function getUserContext(sys: DevToolsSys): Promise<UserContext>;
|
|
99
111
|
export declare function makeAsyncIterator<T>(): readonly [AsyncGenerator<T, void, void>, (event: T) => void, () => void];
|
|
100
|
-
export {};
|
package/types/cli/index.d.ts
CHANGED
|
@@ -37,38 +37,8 @@ export interface CLIArgs {
|
|
|
37
37
|
cwd?: string;
|
|
38
38
|
/** Debug mode */
|
|
39
39
|
debug?: boolean;
|
|
40
|
-
/** Port number for the dev server */
|
|
41
|
-
port?: number;
|
|
42
|
-
/** Port number for the dev server (shorthand) */
|
|
43
|
-
p?: number;
|
|
44
|
-
/** Dev server command to execute */
|
|
45
|
-
command?: string;
|
|
46
|
-
/** Dev server command to execute (shorthand) */
|
|
47
|
-
c?: string;
|
|
48
|
-
/** Skip authentication for testing purposes */
|
|
49
|
-
noAuth?: boolean;
|
|
50
|
-
/** Skip authentication for testing purposes (flag form) */
|
|
51
|
-
auth?: boolean;
|
|
52
|
-
/** Use development server instead of production for launch command */
|
|
53
|
-
dev?: boolean;
|
|
54
|
-
/** Skip browser auto-open */
|
|
55
|
-
noOpen?: boolean;
|
|
56
|
-
/** Skip browser auto-open (flag form) */
|
|
57
|
-
open?: boolean;
|
|
58
40
|
/** Raw command line arguments */
|
|
59
41
|
_: string[];
|
|
60
|
-
/** Silent mode for launch command */
|
|
61
|
-
silent?: boolean;
|
|
62
|
-
/** Fusion project ID */
|
|
63
|
-
projectId?: string;
|
|
64
|
-
/** Enable Fusion side-car branch workflow */
|
|
65
|
-
fusion?: boolean;
|
|
66
|
-
/** Remote URL for Fusion side-car branch storage */
|
|
67
|
-
fusionRemote?: string;
|
|
68
|
-
/** Auto-commit changes when session ends (for Fusion) */
|
|
69
|
-
fusionAutoCommit?: boolean;
|
|
70
42
|
/** Auto-initialize a git repository if none exists (for Fusion) */
|
|
71
43
|
fusionAutoInitGit?: boolean;
|
|
72
|
-
/** Push changes to origin after squash merge (for Fusion) */
|
|
73
|
-
fusionPushToOrigin?: boolean;
|
|
74
44
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { EnsureConfigResult } from "types";
|
|
2
|
+
export declare const GIT_APP_FOLDER = "code";
|
|
3
|
+
export declare const transformVolumePath: (volumePath?: string) => string;
|
|
4
|
+
export declare const navigateToVolumePath: (volumePath: string) => void;
|
|
5
|
+
export declare const navigateToGitAppFolder: () => void;
|
|
6
|
+
export type InstallOutcome = EnsureConfigResult["outcome"] | "install-failed";
|
|
7
|
+
export type InstallStatus = {
|
|
8
|
+
timestamp: string;
|
|
9
|
+
outcome: InstallOutcome;
|
|
10
|
+
packageManager: string;
|
|
11
|
+
buildTool: string;
|
|
12
|
+
rootDir: string;
|
|
13
|
+
error: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type LaunchStatus = {
|
|
16
|
+
jsxPlugin?: Partial<InstallStatus>;
|
|
17
|
+
devTools?: {
|
|
18
|
+
version?: string;
|
|
19
|
+
};
|
|
20
|
+
stash?: {
|
|
21
|
+
completed?: boolean;
|
|
22
|
+
};
|
|
23
|
+
dependencies?: {
|
|
24
|
+
installed?: boolean;
|
|
25
|
+
error?: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
gitRepo?: {
|
|
28
|
+
exists?: boolean;
|
|
29
|
+
configured?: boolean;
|
|
30
|
+
repo?: string | undefined;
|
|
31
|
+
branch?: string;
|
|
32
|
+
error?: string | undefined;
|
|
33
|
+
current?: string | undefined;
|
|
34
|
+
expected?: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
gitUser?: {
|
|
37
|
+
configured?: boolean;
|
|
38
|
+
};
|
|
39
|
+
gitDirectory?: {
|
|
40
|
+
exists?: boolean;
|
|
41
|
+
creating?: boolean;
|
|
42
|
+
};
|
|
43
|
+
volumeDirectory?: {
|
|
44
|
+
exists?: boolean;
|
|
45
|
+
};
|
|
46
|
+
args?: {
|
|
47
|
+
repoFullName?: string;
|
|
48
|
+
branchName?: string;
|
|
49
|
+
volumePath?: string;
|
|
50
|
+
};
|
|
51
|
+
initialization?: {
|
|
52
|
+
started?: boolean;
|
|
53
|
+
timestamp?: string;
|
|
54
|
+
completed?: boolean;
|
|
55
|
+
success?: boolean;
|
|
56
|
+
error?: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export declare const updateStatus: <T extends keyof LaunchStatus>(key: T, value: Partial<LaunchStatus[T]>) => void;
|
|
60
|
+
/**
|
|
61
|
+
* This path is derived from the logs file path, which is set by `initializeLogging`.
|
|
62
|
+
* Therefore make sure that `initializeLogging` has been called before calling this function.
|
|
63
|
+
*/
|
|
64
|
+
export declare const getBuilderStatusFilePath: () => string;
|
|
65
|
+
export declare const getConfigStatus: () => LaunchStatus;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DevToolsSys } from "@builder.io/dev-tools/core";
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare const installJsxPlugin: (sys: DevToolsSys, args: CLIArgs) => Promise<{
|
|
2
|
+
import { type InstallOutcome } from "./helpers";
|
|
3
|
+
export declare const installJsxPlugin: (sys: DevToolsSys) => Promise<{
|
|
4
|
+
timestamp: string;
|
|
6
5
|
installOutcome: InstallOutcome;
|
|
6
|
+
error: string | undefined;
|
|
7
7
|
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from "child_process";
|
|
2
|
+
/**
|
|
3
|
+
* Initialize logging by wrapping all console methods to write to logs file
|
|
4
|
+
*/
|
|
5
|
+
export declare function initializeLogging({ goToParentTimes, }?: {
|
|
6
|
+
goToParentTimes?: number;
|
|
7
|
+
}): void;
|
|
8
|
+
/**
|
|
9
|
+
* Reset console methods to their original state
|
|
10
|
+
*/
|
|
11
|
+
export declare function resetLogging(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Capture and log child process output
|
|
14
|
+
*/
|
|
15
|
+
export declare function setupChildProcessLogging(childProcess: ChildProcessWithoutNullStreams, prefix: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Display intro message with logging
|
|
18
|
+
*/
|
|
19
|
+
export declare const intro: (message: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Wrapped clack logging methods with file logging
|
|
22
|
+
*/
|
|
23
|
+
export declare const log: {
|
|
24
|
+
info: (message: string) => void;
|
|
25
|
+
success: (message: string) => void;
|
|
26
|
+
error: (message: string) => void;
|
|
27
|
+
warn: (message: string) => void;
|
|
28
|
+
step: (message: string) => void;
|
|
29
|
+
message: (message?: string, { symbol }?: import("@clack/prompts").LogMessageOptions) => void;
|
|
30
|
+
warning: (message: string) => void;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Display outro message with logging
|
|
34
|
+
*/
|
|
35
|
+
export declare const outro: (message: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Reads logs with pagination
|
|
38
|
+
* @param nextToken Line number to start reading from (0-indexed)
|
|
39
|
+
* @param limit Number of lines to read
|
|
40
|
+
* @returns Object containing logs array and next token
|
|
41
|
+
*/
|
|
42
|
+
export declare const readLogs: (nextToken?: number, limit?: number) => {
|
|
43
|
+
logs: string[];
|
|
44
|
+
nextToken: number | null;
|
|
45
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Express, type RequestHandler } from "express";
|
|
2
|
+
export declare const BUILDER_ENDPOINT_PREFIX = "/_builder.io";
|
|
3
|
+
export declare const BUILDER_API_ENDPOINT_PREFIX: string;
|
|
4
|
+
export declare const configureServer: (app: Express) => void;
|
|
5
|
+
export declare const serverAuthMiddleware: ({ validBuilderPrivateKey, authenticateProxy, }: {
|
|
6
|
+
validBuilderPrivateKey: string | undefined;
|
|
7
|
+
authenticateProxy: boolean;
|
|
8
|
+
}) => RequestHandler;
|
|
9
|
+
export declare const createLogAndConfigEndpoints: (app: Express) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DevToolsSys } from "@builder.io/dev-tools/core";
|
|
2
|
+
import type { CLIArgs } from "./index";
|
|
3
|
+
export interface InitArgs extends CLIArgs {
|
|
4
|
+
repoFullName?: string;
|
|
5
|
+
branchName?: string;
|
|
6
|
+
githubToken?: string;
|
|
7
|
+
installCommand?: string;
|
|
8
|
+
volumePath?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function runLaunchInitCommand({ args, sys, }: {
|
|
11
|
+
sys: DevToolsSys;
|
|
12
|
+
args: InitArgs;
|
|
13
|
+
}): Promise<number>;
|
package/types/cli/launch.d.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import type { DevToolsSys } from "@builder.io/dev-tools/core";
|
|
2
2
|
import type { CLIArgs } from "./index";
|
|
3
|
+
/**
|
|
4
|
+
* Large random-ish port number that is unlikely to be used
|
|
5
|
+
*/
|
|
3
6
|
export declare const PROXY_PORT = 48752;
|
|
7
|
+
export interface LaunchArgs extends CLIArgs {
|
|
8
|
+
volumePath?: string;
|
|
9
|
+
/** Fusion project ID */
|
|
10
|
+
projectId?: string;
|
|
11
|
+
/** Silent mode for launch command */
|
|
12
|
+
silent?: boolean;
|
|
13
|
+
/** Port number for the dev server */
|
|
14
|
+
port?: number;
|
|
15
|
+
/** Port number for the dev server (shorthand) */
|
|
16
|
+
p?: number;
|
|
17
|
+
/** Dev server command to execute */
|
|
18
|
+
command?: string;
|
|
19
|
+
/** Dev server command to execute (shorthand) */
|
|
20
|
+
c?: string;
|
|
21
|
+
/** Use development server instead of production for launch command */
|
|
22
|
+
dev?: boolean;
|
|
23
|
+
/** Skip browser auto-open (flag form) */
|
|
24
|
+
open?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Decides whether to skip authentication for the user's proxy server.
|
|
27
|
+
* Our own _builder.io/ endpoitns are always authenticated.
|
|
28
|
+
*
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
authenticateProxy?: boolean;
|
|
32
|
+
}
|
|
4
33
|
export declare function runLaunchCommand({ sys, args, }: {
|
|
5
34
|
sys: DevToolsSys;
|
|
6
|
-
args:
|
|
7
|
-
}): Promise<
|
|
35
|
+
args: LaunchArgs;
|
|
36
|
+
}): Promise<undefined>;
|
package/types/cli/server-ws.d.ts
CHANGED
|
@@ -37,14 +37,8 @@ type SocketEvents = {
|
|
|
37
37
|
"socket-error": (socketId: string, error: Error) => Promise<void> | void;
|
|
38
38
|
close: () => Promise<void> | void;
|
|
39
39
|
};
|
|
40
|
-
export declare function
|
|
40
|
+
export declare function RPCWebSocketServer(opts: ServerOptions): {
|
|
41
41
|
on: <EventKey extends keyof SocketEvents>(event: EventKey, cb: SocketEvents[EventKey]) => void;
|
|
42
|
-
of: (ns: string) => {
|
|
43
|
-
emit: (name: string, ...params: any[]) => void;
|
|
44
|
-
clients: () => Map<string, WebSocket>;
|
|
45
|
-
register: <T = any>(method: string, fn: RegisterFn<T>) => void;
|
|
46
|
-
event: (name: string) => void;
|
|
47
|
-
};
|
|
48
42
|
event: (e: string) => void;
|
|
49
43
|
handleUpgrade: (req: IncomingMessage, socket: Duplex, upgradeHead: Buffer, callback?: (client: WebSocket, request: IncomingMessage) => void) => Promise<void>;
|
|
50
44
|
clients: () => Map<string, WebSocket>;
|