@builder.io/ai-utils 0.25.3 → 0.26.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/ai-utils",
3
- "version": "0.25.3",
3
+ "version": "0.26.0",
4
4
  "description": "Builder.io AI utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/codegen.d.ts CHANGED
@@ -276,17 +276,24 @@ export interface ProposeConfigToolInput {
276
276
  config: SetupAnalysisValues;
277
277
  message?: string;
278
278
  }
279
- export type SetupValueField = "installCommand" | "devServer" | "validationScript";
279
+ export type SetupValueField = "installCommand" | "devServer" | "validationScript" | "environmentVariables";
280
280
  export interface UpdateSetupValueToolInput {
281
281
  field: SetupValueField;
282
282
  value: {
283
- command: string;
283
+ command?: string;
284
284
  url?: string;
285
285
  port?: number;
286
+ environmentVariables?: Array<{
287
+ key: string;
288
+ description?: string;
289
+ isRequired?: boolean;
290
+ isSecret?: boolean;
291
+ defaultValue?: string | null;
292
+ }>;
286
293
  };
287
294
  reason: string;
288
295
  }
289
- export type ExitState = "verified" | "more-disk" | "more-memory" | "user-question" | "other";
296
+ export type ExitState = "verified" | "more-disk" | "more-memory" | "user-question" | "other" | "started";
290
297
  export interface ExitToolInput {
291
298
  state: ExitState;
292
299
  summary: string;
@@ -967,6 +974,7 @@ export interface GenerateCompletionStepGit {
967
974
  hasGeneratingPlaceholder: boolean;
968
975
  remoteBranchExists: boolean;
969
976
  remoteBranchHasChanges: boolean;
977
+ hasStagedChanges: boolean;
970
978
  canPush: boolean;
971
979
  canPull: boolean;
972
980
  canSync: boolean;
@@ -1054,30 +1062,22 @@ export interface GenerateCompletionStepUpdateSetupValue {
1054
1062
  type: "update_setup_value";
1055
1063
  field: SetupValueField;
1056
1064
  value: {
1057
- command: string;
1065
+ command?: string;
1058
1066
  url?: string;
1059
1067
  port?: number;
1068
+ environmentVariables?: Array<{
1069
+ key: string;
1070
+ description?: string;
1071
+ isRequired?: boolean;
1072
+ isSecret?: boolean;
1073
+ defaultValue?: string | null;
1074
+ }>;
1060
1075
  };
1061
1076
  reason: string;
1062
1077
  }
1063
- export interface GenerateCompletionStepExit {
1064
- type: "exit";
1065
- state: ExitState;
1066
- summary: string;
1067
- questions: Array<{
1068
- question: string;
1069
- context: string;
1070
- header?: string;
1071
- options?: Array<{
1072
- label: string;
1073
- description: string;
1074
- }>;
1075
- multiSelect?: boolean;
1076
- }>;
1077
- }
1078
1078
  export type GenerateCompletionStep = {
1079
1079
  timestamp?: number;
1080
- } & (GenerateCompletionStepPlanning | GenerateCompletionStepStart | GenerateCompletionStepDelta | GenerateCompletionStepUser | GenerateCompletionStepFile | GenerateCompletionStepDiff | GenerateCompletionStepTool | GenerateCompletionStepError | GenerateCompletionStepContinue | GenerateCompletionStepWaitForInput | GenerateCompletionStepAbort | GenerateCompletionStepDone | GenerateCompletionStepUserInput | GenerateCompletionStepText | GenerateCompletionStepRestore | GenerateCompletionStepState | GenerateCompletionStepStdio | GenerateCompletionStepSession | GenerateCompletionStepServerToolResult | GenerateCompletionStepGit | GenerateCompletionStepBuilderAction | GenerateCompletionStepToolResult | GenerateCompletionStepFusionConfigPatch | GenerateCompletionStepToolCallRequest | GenerateCodeEventMCPStatus | GenerateCodeEventMCPAuthRequired | GenerateCompletionStepDevServerState | GenerateCompletionStepAgent | GenerateCompletionStepBatch | GenerateCompletionStepTerminals | GenerateCompletionStepMetadata | GenerateCompletionStepMessageQueue | GenerateCompletionStepProposeConfig | GenerateCompletionStepUpdateSetupValue | GenerateCompletionStepExit);
1080
+ } & (GenerateCompletionStepPlanning | GenerateCompletionStepStart | GenerateCompletionStepDelta | GenerateCompletionStepUser | GenerateCompletionStepFile | GenerateCompletionStepDiff | GenerateCompletionStepTool | GenerateCompletionStepError | GenerateCompletionStepContinue | GenerateCompletionStepWaitForInput | GenerateCompletionStepAbort | GenerateCompletionStepDone | GenerateCompletionStepUserInput | GenerateCompletionStepText | GenerateCompletionStepRestore | GenerateCompletionStepState | GenerateCompletionStepStdio | GenerateCompletionStepSession | GenerateCompletionStepServerToolResult | GenerateCompletionStepGit | GenerateCompletionStepBuilderAction | GenerateCompletionStepToolResult | GenerateCompletionStepFusionConfigPatch | GenerateCompletionStepToolCallRequest | GenerateCodeEventMCPStatus | GenerateCodeEventMCPAuthRequired | GenerateCompletionStepDevServerState | GenerateCompletionStepAgent | GenerateCompletionStepBatch | GenerateCompletionStepTerminals | GenerateCompletionStepMetadata | GenerateCompletionStepMessageQueue | GenerateCompletionStepProposeConfig | GenerateCompletionStepUpdateSetupValue);
1081
1081
  export interface ApplyActionsResult {
1082
1082
  filePath: string;
1083
1083
  addedLines: number;
@@ -1117,6 +1117,7 @@ export interface UserSourceAgent extends UserSourceBase {
1117
1117
  source: "agent";
1118
1118
  }
1119
1119
  export type UserSource = UserSourceOther | UserSourceBuilder | UserSourceAgent;
1120
+ export type AutoPushMode = "force-push" | "merge-push" | "ff-push" | "safe-push" | "none";
1120
1121
  export interface GenerateUserMessage {
1121
1122
  idempotencyKey?: string;
1122
1123
  user?: UserSource;
@@ -1137,7 +1138,7 @@ export interface GenerateUserMessage {
1137
1138
  includeRelevantMemories?: boolean;
1138
1139
  category?: CodeGenCategory;
1139
1140
  metadata?: Record<string, any>;
1140
- autoPush?: "force-push" | "merge-push" | "ff-push" | "safe-push" | "none";
1141
+ autoPush?: AutoPushMode;
1141
1142
  syncChanges?: SyncChangesFromRemote;
1142
1143
  enabledMCPs?: string[];
1143
1144
  sessionMode?: SessionMode;
@@ -1516,6 +1517,7 @@ export interface FusionConfig {
1516
1517
  setupCommand?: string;
1517
1518
  validateCommand?: string;
1518
1519
  fusionServerPort?: number;
1520
+ autoPush?: AutoPushMode;
1519
1521
  lockFile?: {
1520
1522
  filePath: string;
1521
1523
  conflictBehavior: "replace" | "exit" | "kill";
@@ -1,8 +1,9 @@
1
- import type { CheckResult, Source, TestId } from "../types.js";
1
+ import type { CheckResult, Source, TestId, ConnectivityFetchFn } from "../types.js";
2
2
  export interface HttpCheckOptions {
3
3
  target: string;
4
4
  source: Source;
5
5
  testId: TestId;
6
6
  timeout?: number;
7
+ fetchFn?: ConnectivityFetchFn;
7
8
  }
8
9
  export declare function httpCheck(options: HttpCheckOptions): Promise<CheckResult>;
@@ -2,12 +2,12 @@ import { mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, } from "../e
2
2
  const DEFAULT_TIMEOUT_MS = 30000;
3
3
  const LATENCY_THRESHOLD_MS = 5000;
4
4
  export async function httpCheck(options) {
5
- const { target, source, testId, timeout = DEFAULT_TIMEOUT_MS } = options;
5
+ const { target, source, testId, timeout = DEFAULT_TIMEOUT_MS, fetchFn = fetch, } = options;
6
6
  const startTime = Date.now();
7
7
  const controller = new AbortController();
8
8
  const timeoutId = setTimeout(() => controller.abort(), timeout);
9
9
  try {
10
- const response = await fetch(target, {
10
+ const response = await fetchFn(target, {
11
11
  method: "HEAD",
12
12
  signal: controller.signal,
13
13
  redirect: "follow",
@@ -1,4 +1,4 @@
1
- export type { Source, TestId, Test, RunChecksInput, ProgressEvent, CheckResult, CheckReport, ConnectivityErrorCode, CheckType, Recommendation, LikelyCause, ConnectivityStatus, AnalysisResult, AnalyzeConnectivityInput, } from "./types.js";
1
+ export type { Source, TestId, Test, RunChecksInput, ProgressEvent, CheckResult, CheckReport, ConnectivityErrorCode, CheckType, Recommendation, LikelyCause, ConnectivityStatus, AnalysisResult, AnalyzeConnectivityInput, ConnectivityFetchFn, } from "./types.js";
2
2
  export { runChecks } from "./run-checks.js";
3
3
  export { mapNodeErrorToConnectivityCode, mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, SELF_SIGNED_CERT_ERRORS, CERT_EXPIRED_ERRORS, CERT_NOT_YET_VALID_ERRORS, CERT_INVALID_ERRORS, CERT_HOSTNAME_MISMATCH_ERRORS, SSL_PROTOCOL_ERRORS, SSL_HANDSHAKE_ERRORS, NETWORK_UNREACHABLE_ERRORS, TIMEOUT_ERRORS, PROXY_ERRORS, DNS_ERRORS, } from "./error-codes.js";
4
4
  export { BUILDER_TARGETS, DEFAULT_PORTS, resolveTarget, extractHostname, extractPort, } from "./targets.js";
@@ -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 } = input;
9
+ const { tests, gitHost, onProgress, fetchFn } = 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);
20
+ const result = await runSingleCheck(test, gitHost, fetchFn);
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) {
39
+ async function runSingleCheck(test, gitHost, fetchFn) {
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) {
80
80
  }
81
81
  switch (checkType) {
82
82
  case "http":
83
- return httpCheck({ target, source, testId });
83
+ return httpCheck({ target, source, testId, fetchFn });
84
84
  case "dns":
85
85
  return dnsCheck({
86
86
  hostname: extractHostname(target),
@@ -4,10 +4,21 @@ export interface Test {
4
4
  source: Source;
5
5
  testId: TestId;
6
6
  }
7
+ export type ConnectivityFetchFn = (input: string | URL, init?: {
8
+ method?: string;
9
+ signal?: AbortSignal;
10
+ redirect?: "follow" | "error" | "manual";
11
+ }) => Promise<Pick<Response, "ok" | "status" | "statusText">>;
7
12
  export interface RunChecksInput {
8
13
  tests: Test[];
9
14
  gitHost?: string;
10
15
  onProgress?: (event: ProgressEvent) => void;
16
+ /**
17
+ * Use this to pass a proxy-aware fetch function. Typically
18
+ * only necessary when running connectivity checks from Node
19
+ * environments.
20
+ */
21
+ fetchFn?: ConnectivityFetchFn;
11
22
  }
12
23
  export type ProgressEvent = {
13
24
  type: "test:start";
package/src/events.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { BuilderContent, BuilderElement } from "@builder.io/sdk";
2
2
  import type { AssistantMessage, AssistantMessageAction } from "./messages.js";
3
3
  import type { AssistantSettings } from "./settings.js";
4
+ import type { ExitState } from "./codegen.js";
4
5
  export type BuilderAssistantEventHandler = (ev: BuilderAssistantEvent) => void;
5
6
  export type BuilderAssistantEvent = AssistantCompletionResultEvent | AssistantErrorEvent | AssistantStreamErrorEvent | AppCloseEvent | AppMessagesClickEvent | AppMessagesGenerationEvent | AppMessageEditCustomInstructionsEvent | AppPromptAbortEvent | AppPromptFocusEvent | AppPromptSubmitEvent | AppReadyEvent | AppSettingsSetEvent | AppThreadNewEvent | AssistantStatsEvent | AssistantThemeEvent | BuilderEditorAuthEvent | BuilderEditorStateEvent | ContentUpdateEvent | ContentApplySnapshotEvent | ModelUndoEvent | ModelRedoEvent | ResultEvent | ThreadCreatedEvent | ThreadMessageCompletedEvent | ThreadMessageCreatedEvent | ThreadMessageDeltaEvent | ThreadMessageFeedbackEvent | ThreadRunStepCreatedEvent | ThreadRunStepDeltaEvent | AppAcceptChangeEvent | AppAcceptRejectEvent | AssistantTrackEvent | AssistantEditorAuthMessage | AppAttachmentTemplateEvent | AppPasteSmartExportEvent | ThreadMessageRetryEvent | AppFigmaImportEvent | AppWebImportEvent | AppMcpServersEvent | AssistantContentInitialEvent | ThreadMessageSummaryEvent | ThreadMessageSummaryCodegenDeltaEvent | ThreadMessageThinkingDeltaEvent | AssistantHeartbeatEvent | ShowUpgradeDialogEvent | AssistantFusionSuggestionEvent | AppNavigateToFusionEvent;
6
7
  export interface AssistantCompletionResultEvent {
@@ -488,7 +489,8 @@ export declare const ClientDevtoolsSessionStartedEvent: {
488
489
  version: "1";
489
490
  };
490
491
  export type FusionProjectCreatedV1 = FusionEventVariant<"fusion.project.created", {
491
- projectId?: string;
492
+ projectId: string;
493
+ branchName?: string;
492
494
  branchId?: string;
493
495
  }, {}, 1>;
494
496
  export declare const FusionProjectCreatedV1: {
@@ -496,8 +498,11 @@ export declare const FusionProjectCreatedV1: {
496
498
  version: "1";
497
499
  };
498
500
  export type SetupAgentCompletedV1 = FusionEventVariant<"fusion.setup.completed", {
499
- projectId?: string;
501
+ proposedConfigId: string;
502
+ projectId: string;
503
+ branchName: string;
500
504
  branchId?: string;
505
+ state: ExitState;
501
506
  }, {}, 1>;
502
507
  export declare const SetupAgentCompletedV1: {
503
508
  eventName: "fusion.setup.completed";
package/src/projects.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ConnectivityErrorCode, CheckType, LikelyCause } from "./connectivity/types.js";
2
- import type { FileOverride, EnvironmentVariable, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode, CustomInstruction, CustomAgentDefinition, GitSnapshot } from "./codegen";
2
+ import type { FileOverride, EnvironmentVariable, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode, CustomInstruction, CustomAgentDefinition, GitSnapshot, AutoPushMode } from "./codegen";
3
3
  import type { FallbackTokensPrivate } from "./organization";
4
4
  /**
5
5
  * Temporary type for date fields during migration.
@@ -234,12 +234,16 @@ export interface GitBackupUploadUrlOptions {
234
234
  size: number;
235
235
  partial: boolean;
236
236
  contentMd5: string;
237
+ folderName?: string;
238
+ repoUrl?: string;
237
239
  }
238
240
  export interface GitBackupDownloadUrlOptions {
239
241
  ownerId: string;
240
242
  projectId: string;
241
243
  branchName: string;
242
244
  partial: boolean;
245
+ folderName?: string;
246
+ repoUrl?: string;
243
247
  }
244
248
  export type ForcedBackup = "offline-full" | "offline" | undefined;
245
249
  export interface GitBackupRecordOptions {
@@ -258,6 +262,7 @@ export interface GitBackupRecordOptions {
258
262
  version: "v1" | "v2";
259
263
  forced: ForcedBackup;
260
264
  metadata?: Record<string, string | string[] | undefined>;
265
+ folderName?: string;
261
266
  }
262
267
  export interface RecordScreenshotOptions {
263
268
  projectId: string;
@@ -267,6 +272,9 @@ export interface RecordScreenshotOptions {
267
272
  href?: string;
268
273
  meta?: Record<string, any>;
269
274
  }
275
+ export type GitBackupRecordBody = GitBackupRecordOptions | {
276
+ backups: GitBackupRecordOptions[];
277
+ };
270
278
  export interface GitBackupRecordResult {
271
279
  success: boolean;
272
280
  }
@@ -336,6 +344,7 @@ export interface PartialBranchData {
336
344
  lockedFusionEnvironment?: FusionExecutionEnvironment;
337
345
  metadata?: BranchMetadata;
338
346
  backup?: BranchBackup;
347
+ backups?: Record<string, BranchBackup>;
339
348
  hidden?: boolean;
340
349
  gitAiBranch?: string | null;
341
350
  lastCommitHash?: GitSnapshot | null;
@@ -394,7 +403,7 @@ export interface BranchReview {
394
403
  updatedAt: number;
395
404
  }
396
405
  export type BranchType = "code-review" | "setup-project";
397
- interface BranchSharedData {
406
+ export interface BranchSharedData {
398
407
  appName?: string | null;
399
408
  prNumber?: number | null;
400
409
  prUrl?: string | null;
@@ -430,6 +439,7 @@ interface BranchSharedData {
430
439
  allocated: boolean | null;
431
440
  } | null;
432
441
  backup?: BranchBackup;
442
+ backups?: Record<string, BranchBackup>;
433
443
  metadata?: BranchMetadata;
434
444
  memoriesExtracted?: boolean;
435
445
  needsCleanup?: boolean;
@@ -541,6 +551,7 @@ export interface Project {
541
551
  pinned?: boolean;
542
552
  archived?: boolean;
543
553
  createdBy: string;
554
+ lastUpdateBy?: string;
544
555
  checkRunCounts?: Record<string, number>;
545
556
  repoAddedBy?: string;
546
557
  pipelineCounts?: Record<string, number>;
@@ -561,6 +572,7 @@ export interface Project {
561
572
  validateCommand?: string;
562
573
  proxyOrigin?: string;
563
574
  proxyDefaultOrigin?: string;
575
+ defaultAutoPush?: AutoPushMode;
564
576
  gitBranchNamingStrategy?: "ai-session" | "branch-name" | "custom";
565
577
  setupDependencies?: SetupDependency[];
566
578
  gitBranchNamingCustom?: string;