builder.io 1.6.56 → 1.6.58

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -31,9 +31,24 @@ export interface ToolContext extends Partial<FusionContext> {
31
31
  files: ProjectFile[];
32
32
  emitter: EventEmitter<{
33
33
  step: [GenerateCompletionStep];
34
+ idle: [];
34
35
  }>;
35
36
  signal: AbortSignal | undefined;
36
37
  workingDirectory: string;
38
+ resolveWorkspacePath: (path: string) => string;
39
+ workspaceFolders: Array<{
40
+ path: string;
41
+ name?: string;
42
+ }>;
43
+ readFile: (filePath: string) => Promise<string | null>;
44
+ writeFile: (filePath: string, content: string | Uint8Array) => Promise<boolean>;
45
+ deleteFile: (filePath: string) => Promise<boolean>;
46
+ fileExists: (filePath: string) => Promise<boolean>;
47
+ listDir: (dirPath: string) => Promise<string[]>;
48
+ stat: (filePath: string) => Promise<{
49
+ isDirectory: () => boolean;
50
+ isFile: () => boolean;
51
+ } | null>;
37
52
  }
38
53
  export declare function resolveToolCalls(toolContext: ToolContext, toolCalls: LLMToolCalls[]): Promise<ContentMessageItemToolResult[]>;
39
54
  interface RipgrepMatch {
@@ -31,6 +31,13 @@ export interface SessionContext {
31
31
  createdUnixTime: number;
32
32
  updatedUnixTime: number;
33
33
  }
34
+ export interface WorkspaceFolder {
35
+ path: string;
36
+ name?: string;
37
+ }
38
+ export interface WorkspaceConfiguration {
39
+ folders: WorkspaceFolder[];
40
+ }
34
41
  export interface CodeGenSessionOptionsBase {
35
42
  sys: DevToolsSys;
36
43
  credentials: Credentials;
@@ -40,6 +47,7 @@ export interface CodeGenSessionOptionsBase {
40
47
  builtInCustomInstructions?: CustomInstruction[];
41
48
  fusionContext?: FusionContext;
42
49
  workingDirectory?: string;
50
+ workspace?: WorkspaceConfiguration;
43
51
  }
44
52
  export interface CodeGenSessionOptionsSession extends CodeGenSessionOptionsBase {
45
53
  sessionOrCompletionId?: string;
@@ -134,16 +142,20 @@ export declare class CodeGenSession {
134
142
  getCurrentState(): GenerateCompletionState;
135
143
  getLastTurn(): CodegenTurn | undefined;
136
144
  getNextUrl(): string | undefined;
137
- getNextMessage(): Promise<GenerateUserMessage>;
145
+ getNextMessage(): {
146
+ shouldWait: boolean;
147
+ promise: Promise<GenerateUserMessage | undefined>;
148
+ };
138
149
  sendFeedback(feedback: Partial<CodegenFeedback>): Promise<void>;
139
150
  lastTurnHasChanges(): Promise<boolean>;
140
151
  sendMessage(message: GenerateUserMessage, immediate?: boolean): Promise<void>;
141
152
  getTurns(): CodegenTurn[];
142
153
  getSessionContext(): SessionContext;
143
- abort(): Promise<boolean>;
154
+ abort(cleanCurrentMessage?: boolean): Promise<boolean>;
144
155
  stopEventLoop(): Promise<void>;
145
156
  close(): Promise<void>;
146
- connectToEventLoop(shouldReplay: boolean, onStep: (step: GenerateCompletionStep) => void): Promise<() => void>;
157
+ connectToEventLoop(shouldReplay: boolean, onStep: (step: GenerateCompletionStep) => void): () => void;
158
+ waitUntilIdle(): Promise<void>;
147
159
  waitForEventLoop(): Promise<void>;
148
160
  agentCompletion(userMessage: GenerateUserMessage, signal: AbortSignal | undefined, onStep: (step: GenerateCompletionStep) => void): Promise<void>;
149
161
  commitWorkInProgress(lastTurn: CodegenTurn): Promise<string | undefined>;
@@ -152,8 +164,80 @@ export declare class CodeGenSession {
152
164
  */
153
165
  hasChanges(): boolean;
154
166
  isCleanWorkTree(): Promise<boolean>;
167
+ /**
168
+ * Resolves a workspace file path to its actual file system path
169
+ * @param filePath A file path that may include a workspace prefix (e.g., "workspace1/path/to/file.js")
170
+ * @returns The actual file system path and the workspace folder it belongs to
171
+ */
172
+ resolveWorkspacePath(filePath: string): {
173
+ resolvedPath: string;
174
+ workspaceFolder?: WorkspaceFolder;
175
+ };
176
+ /**
177
+ * Converts an absolute path back to a workspace-relative path if applicable
178
+ * @param absolutePath An absolute file system path
179
+ * @returns The workspace-relative path with appropriate prefix
180
+ */
181
+ toWorkspaceRelativePath(absolutePath: string): string;
182
+ /**
183
+ * Reads a file from the workspace
184
+ * @param filePath A file path that may include a workspace prefix
185
+ * @returns The file content or null if the file doesn't exist
186
+ */
187
+ readFile(filePath: string): Promise<string | null>;
188
+ /**
189
+ * Reads a file from the workspace synchronously
190
+ * @param filePath A file path that may include a workspace prefix
191
+ * @returns The file content or null if the file doesn't exist
192
+ */
193
+ readFileSync(filePath: string): string | null;
194
+ /**
195
+ * Writes content to a file in the workspace
196
+ * @param filePath A file path that may include a workspace prefix
197
+ * @param content The content to write
198
+ * @returns True if the write was successful, false otherwise
199
+ */
200
+ writeFile(filePath: string, content: string | Uint8Array): Promise<boolean>;
201
+ /**
202
+ * Checks if a file exists in the workspace
203
+ * @param filePath A file path that may include a workspace prefix
204
+ * @returns True if the file exists, false otherwise
205
+ */
206
+ fileExists(filePath: string): Promise<boolean>;
207
+ /**
208
+ * Lists files in a directory in the workspace
209
+ * @param dirPath A directory path that may include a workspace prefix
210
+ * @returns Array of file names in the directory or empty array if directory doesn't exist
211
+ */
212
+ listDir(dirPath: string): Promise<string[]>;
213
+ /**
214
+ * Get stats for a file in the workspace
215
+ * @param filePath A file path that may include a workspace prefix
216
+ * @returns The file stats or null if the file doesn't exist
217
+ */
218
+ stat(filePath: string): Promise<{
219
+ isDirectory: () => boolean;
220
+ isFile: () => boolean;
221
+ } | null>;
222
+ /**
223
+ * Deletes a file from the workspace
224
+ * @param filePath A file path that may include a workspace prefix
225
+ * @returns True if the delete was successful, false otherwise
226
+ */
227
+ deleteFile(filePath: string): Promise<boolean>;
155
228
  }
156
229
  export declare function transformStream(body: ReadableStream<Uint8Array> | null): AsyncGenerator<string, void, unknown>;
157
230
  export declare function getUserContext(sys: DevToolsSys): Promise<UserContext>;
158
231
  export declare function makeAsyncIterator<T>(): readonly [AsyncGenerator<T, void, void>, (event: T) => void, () => void];
159
232
  export declare function isServerResponding(url: string, maxRetries?: number, retryDelay?: number): Promise<boolean>;
233
+ /**
234
+ * Loads a workspace configuration from a JSON file
235
+ * @param sys DevToolsSys instance
236
+ * @param workspaceFile Path to the workspace JSON file
237
+ * @returns The workspace configuration and working directory
238
+ */
239
+ export declare function loadWorkspace(sys: DevToolsSys, workspaceFile: string): Promise<{
240
+ workspace: WorkspaceConfiguration;
241
+ workingDirectory: string;
242
+ }>;
243
+ export declare function keepAlive(): () => void;
@@ -45,4 +45,6 @@ export interface CLIArgs {
45
45
  builderPublicKey?: string;
46
46
  /** Builder user ID, used for authentication. */
47
47
  builderUserId?: string;
48
+ /** Path to workspace configuration file */
49
+ workspace?: string;
48
50
  }
@@ -34,6 +34,7 @@ export type LaunchStatus = {
34
34
  error?: string | undefined;
35
35
  current?: string | undefined;
36
36
  expected?: string | undefined;
37
+ elapsedTime?: number;
37
38
  };
38
39
  gitUser?: {
39
40
  configured?: boolean;
@@ -1,5 +1,6 @@
1
1
  import type { DevToolsSys } from "@builder.io/dev-tools/core";
2
2
  import type { CLIArgs } from "./index";
3
+ import { type WorkspaceConfiguration } from "./codegen";
3
4
  import { type CommitMode } from "./code-tools";
4
5
  /**
5
6
  * Large random-ish port number that is unlikely to be used
@@ -48,6 +49,7 @@ export interface FusionConfig {
48
49
  projectId?: string;
49
50
  checkCommand?: string;
50
51
  workingDirectory: string;
52
+ workspace?: WorkspaceConfiguration | string;
51
53
  authenticateProxy: boolean;
52
54
  allowedCommands: string[];
53
55
  commitMode: CommitMode;