builder.io 1.6.29 → 1.6.31

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.
@@ -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 declare function resolveToolCalls(sys: DevToolsSys, toolCalls: LLMToolCalls[]): Promise<{
14
- toolResults: ContentMessageItemToolResult[];
15
- projectFiles: ProjectFile[];
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;
@@ -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
- type State = "unknown" | "initial-with-url" | "initial-without-url" | "generating" | "success" | "abort" | "error";
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,11 @@ export interface SessionContext {
11
22
  customInstructions: CustomInstruction[];
12
23
  userContext: UserContext;
13
24
  prettierConfig: prettier.Config | null;
14
- state: State;
25
+ state: GenerateCompletionState;
26
+ title: string | undefined;
27
+ beforeCommit: string | undefined;
28
+ createdUnixTime: number;
29
+ updatedUnixTime: number;
15
30
  }
16
31
  export interface CodeGenSessionOptionsBase {
17
32
  sys: DevToolsSys;
@@ -23,6 +38,7 @@ export interface CodeGenSessionOptionsBase {
23
38
  fusionRemote?: string;
24
39
  fusionAutoInitGit?: boolean;
25
40
  featureBranch?: string;
41
+ providedToolContext?: ProvidedToolContext;
26
42
  }
27
43
  export interface CodeGenSessionOptionsSession extends CodeGenSessionOptionsBase {
28
44
  sessionOrCompletionId?: string;
@@ -78,23 +94,28 @@ export declare class CodeGenSession {
78
94
  */
79
95
  undoLastUserMessage(dryRun?: boolean): Promise<string[] | null>;
80
96
  getLastCompletionId(): string | undefined;
81
- getCurrentState(): State;
97
+ getCurrentState(): GenerateCompletionState;
82
98
  getLastTurn(): CodegenTurn | undefined;
83
99
  getNextUrl(): string | undefined;
84
100
  getNextMessage(): Promise<GenerateUserMessage>;
85
101
  sendFeedback(sentiment: "positive" | "negative" | "undo", message?: string, lastCompletionId?: string | undefined): Promise<void>;
86
- hasUndoChanges(): Promise<boolean>;
87
- isBusy(): boolean;
102
+ lastTurnHasChanges(): Promise<boolean>;
88
103
  sendMessage(message: GenerateUserMessage): void;
89
104
  getTurns(): CodegenTurn[];
90
105
  getSessionContext(): SessionContext;
91
106
  abort(): void;
92
107
  stopEventLoop(): Promise<void>;
108
+ close(): Promise<void>;
93
109
  connectToEventLoop(shouldReplay: boolean, onStep: (step: GenerateCompletionStep) => void): () => void;
94
110
  waitForEventLoop(): Promise<void>;
95
- agentCompletion(userMessage: GenerateUserMessage, signal: AbortSignal | undefined, onStep: (step: GenerateCompletionStep) => Promise<void> | void): Promise<void>;
111
+ agentCompletion(userMessage: GenerateUserMessage, signal: AbortSignal | undefined, onStep: (step: GenerateCompletionStep) => void): Promise<void>;
112
+ commitWorkInProgress(lastTurn: CodegenTurn): Promise<string | undefined>;
113
+ /**
114
+ * Returns true if the last turn's afterCommit (or beforeCommit) is different from the session's beforeCommit.
115
+ */
116
+ hasChanges(): boolean;
117
+ isCleanWorkTree(): Promise<boolean>;
96
118
  }
97
119
  export declare function transformStream(body: ReadableStream<Uint8Array> | null): AsyncGenerator<string, void, unknown>;
98
120
  export declare function getUserContext(sys: DevToolsSys): Promise<UserContext>;
99
121
  export declare function makeAsyncIterator<T>(): readonly [AsyncGenerator<T, void, void>, (event: T) => void, () => void];
100
- export {};
@@ -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,62 @@
1
+ import type { EnsureConfigResult } from "types";
2
+ export declare const GIT_APP_FOLDER = "code";
3
+ export declare const LOGS_FILE_PATH: string;
4
+ export declare const STATUS_FILE_PATH: string;
5
+ export declare const transformVolumePath: (volumePath?: string) => string;
6
+ export declare const navigateToVolumePath: (volumePath: string) => void;
7
+ export declare const navigateToGitAppFolder: () => void;
8
+ export type InstallOutcome = EnsureConfigResult["outcome"] | "install-failed";
9
+ export type InstallStatus = {
10
+ timestamp: string;
11
+ outcome: InstallOutcome;
12
+ packageManager: string;
13
+ buildTool: string;
14
+ rootDir: string;
15
+ error: string | undefined;
16
+ };
17
+ export type LaunchStatus = {
18
+ jsxPlugin?: Partial<InstallStatus>;
19
+ devTools?: {
20
+ version?: string;
21
+ };
22
+ stash?: {
23
+ completed?: boolean;
24
+ };
25
+ dependencies?: {
26
+ installed?: boolean;
27
+ error?: string | undefined;
28
+ };
29
+ gitRepo?: {
30
+ exists?: boolean;
31
+ configured?: boolean;
32
+ repo?: string | undefined;
33
+ branch?: string;
34
+ error?: string | undefined;
35
+ current?: string | undefined;
36
+ expected?: string | undefined;
37
+ };
38
+ gitUser?: {
39
+ configured?: boolean;
40
+ };
41
+ gitDirectory?: {
42
+ exists?: boolean;
43
+ creating?: boolean;
44
+ };
45
+ volumeDirectory?: {
46
+ exists?: boolean;
47
+ };
48
+ args?: {
49
+ repoFullName?: string;
50
+ branchName?: string;
51
+ volumePath?: string;
52
+ };
53
+ initialization?: {
54
+ started?: boolean;
55
+ timestamp?: string;
56
+ completed?: boolean;
57
+ success?: boolean;
58
+ error?: string;
59
+ };
60
+ };
61
+ export declare const updateStatus: <T extends keyof LaunchStatus>(key: T, value: Partial<LaunchStatus[T]>) => void;
62
+ export declare const getConfigStatus: () => LaunchStatus;
@@ -1,7 +1,7 @@
1
1
  import type { DevToolsSys } from "@builder.io/dev-tools/core";
2
- import type { CLIArgs } from "../index";
3
- import type { EnsureConfigResult } from "types";
4
- export type InstallOutcome = EnsureConfigResult["outcome"] | "install-failed";
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,43 @@
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(): void;
6
+ /**
7
+ * Reset console methods to their original state
8
+ */
9
+ export declare function resetLogging(): void;
10
+ /**
11
+ * Capture and log child process output
12
+ */
13
+ export declare function setupChildProcessLogging(childProcess: ChildProcessWithoutNullStreams, prefix: string): void;
14
+ /**
15
+ * Display intro message with logging
16
+ */
17
+ export declare const intro: (message: string) => void;
18
+ /**
19
+ * Wrapped clack logging methods with file logging
20
+ */
21
+ export declare const log: {
22
+ info: (message: string) => void;
23
+ success: (message: string) => void;
24
+ error: (message: string) => void;
25
+ warn: (message: string) => void;
26
+ step: (message: string) => void;
27
+ message: (message?: string, { symbol }?: import("@clack/prompts").LogMessageOptions) => void;
28
+ warning: (message: string) => void;
29
+ };
30
+ /**
31
+ * Display outro message with logging
32
+ */
33
+ export declare const outro: (message: string) => void;
34
+ /**
35
+ * Reads logs with pagination
36
+ * @param nextToken Line number to start reading from (0-indexed)
37
+ * @param limit Number of lines to read
38
+ * @returns Object containing logs array and next token
39
+ */
40
+ export declare const readLogs: (nextToken?: number, limit?: number) => {
41
+ logs: string[];
42
+ nextToken: number | null;
43
+ };
@@ -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>;
@@ -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: CLIArgs;
7
- }): Promise<number>;
35
+ args: LaunchArgs;
36
+ }): Promise<undefined>;
@@ -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 Server(opts: ServerOptions): {
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>;