@builder.io/ai-utils 0.22.2 → 0.23.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.22.2",
3
+ "version": "0.23.0",
4
4
  "description": "Builder.io AI utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/codegen.d.ts CHANGED
@@ -2,9 +2,10 @@ import type { Attachment, ContentMessageItemToolResult } from "./messages";
2
2
  import type { BuilderContent } from "./completion";
3
3
  import type { Options as PrettierOptions } from "prettier";
4
4
  import type { UserContext } from "./mapping";
5
- import type { ForcedBackup, SetupDependency } from "./projects";
5
+ import type { ForcedBackup, SetupDependency, GitDiagnostics } from "./projects";
6
6
  import type { Feature } from "./features";
7
7
  import type { CpuKind } from "./projects";
8
+ export type GitSnapshot = unknown;
8
9
  export type ImportType = "named" | "default";
9
10
  export interface ESMImport {
10
11
  importName: string;
@@ -192,7 +193,7 @@ export interface BuilderEditToolInput {
192
193
  new_str: string;
193
194
  }
194
195
  export interface GetScreenshotToolInput {
195
- href: string;
196
+ href?: string;
196
197
  url?: string;
197
198
  selector?: string;
198
199
  width?: number;
@@ -425,7 +426,7 @@ export interface CodeGenInputOptions {
425
426
  rerankFiles?: number;
426
427
  toolResults?: ContentMessageItemToolResult[];
427
428
  attachments?: Attachment[];
428
- beforeCommit?: string;
429
+ beforeCommit?: GitSnapshot;
429
430
  workingDirectory?: string;
430
431
  includeRelevantMemories?: boolean;
431
432
  encryptKey?: string;
@@ -840,7 +841,7 @@ export interface CustomInstructionDefinition {
840
841
  export interface GenerateCompletionStepSession {
841
842
  type: "session";
842
843
  title: string | undefined;
843
- beforeCommit: string | undefined;
844
+ beforeCommit: GitSnapshot | undefined;
844
845
  createdUnixTime: number;
845
846
  updatedUnixTime: number;
846
847
  id: string;
@@ -914,13 +915,18 @@ export interface UserSourceBase {
914
915
  jobs?: string[];
915
916
  permissions?: UserSourcePermission[];
916
917
  }
918
+ /** All integration sources: Slack, Teams, Jira, Linear, and git providers (GitHub, GitLab, Azure, Bitbucket). */
917
919
  export interface UserSourceOther extends UserSourceBase {
918
- source: "slack" | "teams" | "jira" | "linear";
919
- /** User ID from the external platform (Slack user ID, Jira account ID, etc.) */
920
+ source: "slack" | "teams" | "jira" | "linear" | "github" | "gitlab" | "azure" | "bitbucket";
921
+ /** User ID from the external platform (Slack user ID, GitHub user id, etc.) */
920
922
  userId?: string;
921
923
  userName?: string;
922
924
  userEmail?: string;
923
925
  photoURL?: string;
926
+ /** Resolved Builder user ID for attribution/credits */
927
+ builderUserId?: string;
928
+ /** Optional link (e.g. comment/PR URL) for git provider sources */
929
+ link?: string;
924
930
  }
925
931
  export interface UserSourceBuilder extends UserSourceBase {
926
932
  source: "builder.io";
@@ -929,31 +935,10 @@ export interface UserSourceBuilder extends UserSourceBase {
929
935
  userEmail?: string;
930
936
  photoURL?: string;
931
937
  }
932
- export interface UserSourceGithub extends UserSourceBase {
933
- source: "github";
934
- userName: string;
935
- userEmail?: string;
936
- link?: string;
937
- }
938
- export interface UserSourceGitlab extends UserSourceBase {
939
- source: "gitlab";
940
- userName: string;
941
- link?: string;
942
- }
943
- export interface UserSourceAzure extends UserSourceBase {
944
- source: "azure";
945
- userName: string;
946
- link?: string;
947
- }
948
- export interface UserSourceBitbucket extends UserSourceBase {
949
- source: "bitbucket";
950
- userName: string;
951
- link?: string;
952
- }
953
938
  export interface UserSourceAgent extends UserSourceBase {
954
939
  source: "agent";
955
940
  }
956
- export type UserSource = UserSourceOther | UserSourceBuilder | UserSourceGithub | UserSourceGitlab | UserSourceAzure | UserSourceBitbucket | UserSourceAgent;
941
+ export type UserSource = UserSourceOther | UserSourceBuilder | UserSourceAgent;
957
942
  export interface GenerateUserMessage {
958
943
  idempotencyKey?: string;
959
944
  user?: UserSource;
@@ -1016,9 +1001,9 @@ export interface CodegenTurn {
1016
1001
  sentiment: "positive" | "negative" | "undo" | undefined;
1017
1002
  applyResults: ApplyActionsResult[];
1018
1003
  userMessage: GenerateUserMessage | undefined;
1019
- beforeCommit: string | undefined;
1020
- afterCommit: string | undefined;
1021
- lastCommit: string | undefined;
1004
+ beforeCommit: GitSnapshot | undefined;
1005
+ afterCommit: GitSnapshot | undefined;
1006
+ lastCommit: GitSnapshot | undefined;
1022
1007
  cachedToolResults?: ContentMessageItemToolResult[];
1023
1008
  autoContinue: boolean;
1024
1009
  }
@@ -1028,7 +1013,7 @@ export interface GetSessionTurnsResult {
1028
1013
  lastCompletionId: string | undefined;
1029
1014
  sessionId: string;
1030
1015
  initialUrl: string | undefined;
1031
- beforeCommit: string | undefined;
1016
+ beforeCommit: GitSnapshot | undefined;
1032
1017
  title: string | undefined;
1033
1018
  createdUnixTime: number | undefined;
1034
1019
  updatedUnixTime: number | undefined;
@@ -1042,8 +1027,8 @@ export interface CodegenFeedback {
1042
1027
  feedbackSentiment?: string;
1043
1028
  framework?: string;
1044
1029
  acceptedLines?: number;
1045
- beforeCommit?: string;
1046
- afterCommit?: string;
1030
+ beforeCommit?: GitSnapshot;
1031
+ afterCommit?: GitSnapshot;
1047
1032
  linesOfCodeAdded?: number;
1048
1033
  linesOfCodeRemoved?: number;
1049
1034
  commitFailed?: boolean;
@@ -1055,9 +1040,9 @@ export interface CodegenFinalize {
1055
1040
  projectId?: string;
1056
1041
  branchName?: string;
1057
1042
  userCompletionId?: string;
1058
- beforeCommit?: string;
1059
- afterCommit?: string;
1060
- lastCommit?: string;
1043
+ beforeCommit?: GitSnapshot;
1044
+ afterCommit?: GitSnapshot;
1045
+ lastCommit?: GitSnapshot;
1061
1046
  commitFailed?: boolean;
1062
1047
  metadata?: Record<string, any>;
1063
1048
  }
@@ -1467,6 +1452,11 @@ export interface FusionConfig {
1467
1452
  * Errors matching these patterns will not show the error popup.
1468
1453
  */
1469
1454
  errorIgnorePatterns?: string[];
1455
+ /**
1456
+ * Maximum number of agent completions before pausing to ask the user to continue.
1457
+ * Read from project settings, with fallback to organization/space settings.
1458
+ */
1459
+ maxAgentCompletions?: number;
1470
1460
  /** @deprecated use devCommand */
1471
1461
  command?: string;
1472
1462
  }
@@ -1482,7 +1472,7 @@ export interface LoadWholeSessionOptions {
1482
1472
  export interface LoadWholeSessionResult {
1483
1473
  sessionId: string;
1484
1474
  title: string | undefined;
1485
- beforeCommit: string | undefined;
1475
+ beforeCommit: GitSnapshot | undefined;
1486
1476
  createdUnixTime: number;
1487
1477
  updatedUnixTime: number;
1488
1478
  addedTurns: number;
@@ -1491,7 +1481,7 @@ export interface LoadWholeSessionResult {
1491
1481
  export interface LoadHistoryResult {
1492
1482
  sessionId: string;
1493
1483
  title: string | undefined;
1494
- beforeCommit: string | undefined;
1484
+ beforeCommit: GitSnapshot | undefined;
1495
1485
  createdUnixTime: number;
1496
1486
  updatedUnixTime: number;
1497
1487
  turns: CodegenTurn[];
@@ -1512,6 +1502,7 @@ export interface InitState {
1512
1502
  success: boolean;
1513
1503
  currentStep: InitStateStep;
1514
1504
  error: string | undefined;
1505
+ gitDiagnostics?: GitDiagnostics;
1515
1506
  repos: {
1516
1507
  repoName: string;
1517
1508
  enabledGit: boolean;
@@ -1,6 +1,6 @@
1
1
  export type { Source, TestId, Test, RunChecksInput, ProgressEvent, CheckResult, CheckReport, ConnectivityErrorCode, CheckType, Recommendation, LikelyCause, ConnectivityStatus, AnalysisResult, AnalyzeConnectivityInput, } from "./types.js";
2
2
  export { runChecks } from "./run-checks.browser.js";
3
- export { mapNodeErrorToConnectivityCode, mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, 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";
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";
5
5
  export { isBrowser, isNode, getCheckTypeForTestId, isCheckAvailable, getUnavailabilityReason, } from "./environment.js";
6
6
  export { httpCheck } from "./checks/http-check.js";
@@ -1,5 +1,5 @@
1
1
  export { runChecks } from "./run-checks.browser.js";
2
- export { mapNodeErrorToConnectivityCode, mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, 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";
2
+ 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";
3
3
  export { BUILDER_TARGETS, DEFAULT_PORTS, resolveTarget, extractHostname, extractPort, } from "./targets.js";
4
4
  export { isBrowser, isNode, getCheckTypeForTestId, isCheckAvailable, getUnavailabilityReason, } from "./environment.js";
5
5
  export { httpCheck } from "./checks/http-check.js";
@@ -1,4 +1,4 @@
1
- import type { ConnectivityErrorCode } from "./types.js";
1
+ import type { ConnectivityErrorCode, CheckType, LikelyCause } from "./types.js";
2
2
  export declare const SELF_SIGNED_CERT_ERRORS: Set<string>;
3
3
  export declare const CERT_EXPIRED_ERRORS: Set<string>;
4
4
  export declare const CERT_NOT_YET_VALID_ERRORS: Set<string>;
@@ -19,3 +19,18 @@ export declare function mapFetchErrorToConnectivityCode(error: Error & {
19
19
  code?: string;
20
20
  };
21
21
  }): ConnectivityErrorCode;
22
+ /**
23
+ * Map a connectivity error code to a likely cause for recommendations.
24
+ * Shared by the connectivity analyzer and git error diagnostics so both
25
+ * show consistent likely-cause messaging.
26
+ */
27
+ export declare function connectivityErrorCodeToLikelyCause(errorCode: ConnectivityErrorCode | undefined): LikelyCause | undefined;
28
+ /**
29
+ * Map a connectivity error message string (e.g. from a simple DNS/TCP check)
30
+ * to a connectivity error code and check type. Used when building GitDiagnostics
31
+ * from checks that don't use the full runChecks/CheckResult pipeline.
32
+ */
33
+ export declare function mapConnectivityErrorMessage(errorMessage: string): {
34
+ connectivityErrorCode: ConnectivityErrorCode;
35
+ checkType: CheckType;
36
+ } | null;
@@ -165,3 +165,104 @@ export function mapFetchErrorToConnectivityCode(error) {
165
165
  }
166
166
  return "unknown_error";
167
167
  }
168
+ /**
169
+ * Map a connectivity error code to a likely cause for recommendations.
170
+ * Shared by the connectivity analyzer and git error diagnostics so both
171
+ * show consistent likely-cause messaging.
172
+ */
173
+ export function connectivityErrorCodeToLikelyCause(errorCode) {
174
+ if (!errorCode)
175
+ return undefined;
176
+ const timeoutCodes = [
177
+ "tcp_connection_timeout",
178
+ "tcp_host_unreachable",
179
+ "tcp_network_unreachable",
180
+ ];
181
+ if (timeoutCodes.includes(errorCode))
182
+ return "ip_whitelisting_required";
183
+ const dnsCodes = [
184
+ "dns_resolution_failed",
185
+ "dns_timeout",
186
+ "dns_wrong_ip",
187
+ ];
188
+ if (dnsCodes.includes(errorCode))
189
+ return "dns_misconfiguration";
190
+ const tlsCodes = [
191
+ "tls_self_signed_cert",
192
+ "tls_cert_expired",
193
+ "tls_cert_not_yet_valid",
194
+ "tls_cert_invalid",
195
+ "tls_cert_hostname_mismatch",
196
+ "tls_handshake_failed",
197
+ "tls_protocol_error",
198
+ ];
199
+ if (tlsCodes.includes(errorCode))
200
+ return "self_signed_certificate";
201
+ const firewallCodes = [
202
+ "tcp_connection_refused",
203
+ "tcp_connection_reset",
204
+ ];
205
+ if (firewallCodes.includes(errorCode))
206
+ return "firewall_blocking";
207
+ const proxyCodes = [
208
+ "proxy_auth_required",
209
+ "proxy_connection_failed",
210
+ "proxy_tunnel_failed",
211
+ ];
212
+ if (proxyCodes.includes(errorCode))
213
+ return "corporate_proxy_required";
214
+ if (errorCode === "http_service_unavailable" ||
215
+ errorCode === "http_server_error") {
216
+ return "server_unavailable";
217
+ }
218
+ return undefined;
219
+ }
220
+ /**
221
+ * Map a connectivity error message string (e.g. from a simple DNS/TCP check)
222
+ * to a connectivity error code and check type. Used when building GitDiagnostics
223
+ * from checks that don't use the full runChecks/CheckResult pipeline.
224
+ */
225
+ export function mapConnectivityErrorMessage(errorMessage) {
226
+ const lower = errorMessage.toLowerCase();
227
+ if (lower.includes("dns resolution failed") ||
228
+ lower.includes("dns resolution") ||
229
+ lower.includes("no addresses found")) {
230
+ return {
231
+ connectivityErrorCode: "dns_resolution_failed",
232
+ checkType: "dns",
233
+ };
234
+ }
235
+ if (lower.includes("connection attempt failed") ||
236
+ lower.includes("connection timed out") ||
237
+ lower.includes("connection timeout") ||
238
+ lower.includes("etimedout") ||
239
+ lower.includes("timed out")) {
240
+ return {
241
+ connectivityErrorCode: "tcp_connection_timeout",
242
+ checkType: "tcp",
243
+ };
244
+ }
245
+ if (lower.includes("econnrefused") || lower.includes("connection refused")) {
246
+ return {
247
+ connectivityErrorCode: "tcp_connection_refused",
248
+ checkType: "tcp",
249
+ };
250
+ }
251
+ // ENOTFOUND, getaddrinfo, EAI_AGAIN, ENODATA are DNS resolution errors (aligned with DNS_ERRORS and mapNodeErrorToConnectivityCode)
252
+ if (lower.includes("enotfound") ||
253
+ lower.includes("getaddrinfo") ||
254
+ lower.includes("eai_again") ||
255
+ lower.includes("enodata")) {
256
+ return {
257
+ connectivityErrorCode: "dns_resolution_failed",
258
+ checkType: "dns",
259
+ };
260
+ }
261
+ if (lower.includes("network unreachable")) {
262
+ return {
263
+ connectivityErrorCode: "tcp_network_unreachable",
264
+ checkType: "tcp",
265
+ };
266
+ }
267
+ return null;
268
+ }
@@ -1,6 +1,6 @@
1
1
  export type { Source, TestId, Test, RunChecksInput, ProgressEvent, CheckResult, CheckReport, ConnectivityErrorCode, CheckType, Recommendation, LikelyCause, ConnectivityStatus, AnalysisResult, AnalyzeConnectivityInput, } from "./types.js";
2
2
  export { runChecks } from "./run-checks.js";
3
- export { mapNodeErrorToConnectivityCode, mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, 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";
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";
5
5
  export { isBrowser, isNode, getCheckTypeForTestId, isCheckAvailable, getUnavailabilityReason, } from "./environment.js";
6
6
  export { httpCheck } from "./checks/http-check.js";
@@ -1,5 +1,5 @@
1
1
  export { runChecks } from "./run-checks.js";
2
- export { mapNodeErrorToConnectivityCode, mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, 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";
2
+ 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";
3
3
  export { BUILDER_TARGETS, DEFAULT_PORTS, resolveTarget, extractHostname, extractPort, } from "./targets.js";
4
4
  export { isBrowser, isNode, getCheckTypeForTestId, isCheckAvailable, getUnavailabilityReason, } from "./environment.js";
5
5
  export { httpCheck } from "./checks/http-check.js";
package/src/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from "./organization.js";
10
10
  export * from "./features.js";
11
11
  export * from "./vscode-tunnel.js";
12
12
  export * from "./connectivity/types.js";
13
+ export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
package/src/index.js CHANGED
@@ -10,3 +10,4 @@ export * from "./organization.js";
10
10
  export * from "./features.js";
11
11
  export * from "./vscode-tunnel.js";
12
12
  export * from "./connectivity/types.js";
13
+ export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
@@ -79,6 +79,7 @@ interface OrganizationSettings {
79
79
  fusionPrLabel?: string;
80
80
  fusionPrQuietMode?: boolean;
81
81
  runInPty?: boolean;
82
+ maxAgentCompletions?: number;
82
83
  privacyMode?: Pick<PrivacyMode, "mcpServers" | "redactUserMessages" | "redactLLMMessages"> & {
83
84
  enabled?: boolean;
84
85
  };
package/src/projects.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { FileOverride, EnvironmentVariable, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode, CustomInstruction, CustomAgentDefinition } from "./codegen";
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
3
  import type { FallbackTokensPrivate } from "./organization";
3
4
  /**
4
5
  * Temporary type for date fields during migration.
@@ -148,6 +149,54 @@ export interface ReadyMessage extends BaseMessage {
148
149
  export type MachineState = "unknown" | "created" | "starting" | "started" | "stopping" | "stopped" | "suspending" | "suspended" | "replacing" | "destroying" | "destroyed" | "not-found" | "running" | "failed";
149
150
  export type FlyVolumeState = "unknown" | "creating" | "created" | "extending" | "restoring" | "enabling_remote_export" | "hydrating" | "recovering" | "scheduling_destroy" | "pending_destroy" | "failed";
150
151
  export type GitAuthErrorCode = "git-auth-failed" | "git-auth-failed-root-repo" | "git-auth-failed-folder-added-by" | "git-auth-failed-folder-created-by" | "git-auth-failed-repo-not-found" | "git-auth-failed-repo-renamed" | "git-auth-failed-folder-server-token" | "git-auth-failed-root-repo-server-token" | "git-auth-failed-ghes-unreachable";
152
+ /**
153
+ * Git provider types for diagnostics.
154
+ */
155
+ export type GitDiagnosticsProvider = "github" | "bitbucket" | "gitlab" | "azure" | "unknown";
156
+ /**
157
+ * Detect git provider from a repository URL (HTTPS or SSH).
158
+ * Used by both error diagnostics and connectivity checks for consistent provider labeling.
159
+ */
160
+ export declare function getGitProviderFromUrl(url: string): GitDiagnosticsProvider;
161
+ /**
162
+ * Issue classification for git-related errors.
163
+ * - access: Repository access issues (404, repo doesn't exist, insufficient permissions)
164
+ * - auth: Authentication issues (token expired, invalid credentials)
165
+ * - network: Network issues (timeouts, connection failures, unreachable hosts)
166
+ * - unknown: Should be avoided - not helpful for debugging
167
+ */
168
+ export type GitDiagnosticsIssue = "access" | "auth" | "network" | "unknown";
169
+ /**
170
+ * Diagnostic information for git-related errors.
171
+ * Helps frontend display actionable error messages.
172
+ * Optional connectivity fields align with the connectivity check feature so that
173
+ * when a git error is due to network/connectivity, we can pass through granular
174
+ * error codes and likely causes for better UX and recommendations.
175
+ */
176
+ export interface GitDiagnostics {
177
+ provider: GitDiagnosticsProvider;
178
+ hostname: string;
179
+ /**
180
+ * Source IP for debugging network issues: when using an HTTP proxy for outbound
181
+ * git requests, use the proxy host/IP; otherwise the egress IP of the running machine if known.
182
+ */
183
+ sourceIp: string;
184
+ repoName: string;
185
+ issue: GitDiagnosticsIssue;
186
+ /**
187
+ * When issue is "network" (or from a connectivity check), the specific
188
+ * connectivity error code from the check result, if available.
189
+ */
190
+ connectivityErrorCode?: ConnectivityErrorCode;
191
+ /**
192
+ * Which kind of check failed (dns, tcp, tls, http, ssh). Omitted when not from a connectivity check.
193
+ */
194
+ checkType?: CheckType;
195
+ /**
196
+ * Suggested likely cause for the failure; can drive recommendations (e.g. whitelist IP, fix DNS).
197
+ */
198
+ likelyCause?: LikelyCause;
199
+ }
151
200
  export type EnsureContainerErrorCode = "FAILED_TO_START_MACHINE_ERROR" | "FLY_APP_CHECK_ERROR" | "FLY_CAPACITY_ERROR" | "FLY_PERMISSIONS_TOKEN_ERROR" | "FLY_VOLUME_CREATE_ERROR" | "FLY_VOLUME_FORK_ERROR" | "FLY_VOLUME_DELETE_RECENTLY_FORKED_ERROR" | "FLY_MACHINE_CREATE_ERROR" | "FLY_VOLUME_CHECK_ERROR" | "FLY_NON_MOUNTABLE_VOLUME_ERROR" | "FLY_DEPRECATED_REGION_ERROR" | "FLY_VOLUME_NOT_FOUND" | "FLY_MACHINE_LIMIT_ERROR" | "KUBE_CAPACITY_ERROR" | "KUBE_PERMISSIONS_ERROR" | "KUBE_POD_LIMIT_ERROR" | "KUBE_RESOURCE_QUOTA_ERROR" | "KUBE_NAMESPACE_CHECK_ERROR" | "KUBE_PVC_CREATE_ERROR" | "KUBE_PVC_CHECK_ERROR" | "KUBE_POD_CREATE_ERROR" | "KUBE_SERVICE_CREATE_ERROR" | "KUBE_INGRESS_CREATE_ERROR" | "KUBE_POD_FAILED_TO_START_ERROR" | "ensure-checking-existing-machines" | "found-multiple-failed-machine" | "maximun-retries-machine-creation" | GitAuthErrorCode | "unknown" | "project-bad-state" | "project-not-found" | "project-deleted" | "project-branch-not-found" | "project-branch-deleted" | "project-branch-no-session-id" | "project-repo-full-name-not-found" | "project-org-not-found" | "invalid-project-repo-url-already-in-use" | "no-available-regions" | "invalid-backup-without-volume-id" | "missing-app-with-machine-or-volume" | "update-branch-info-in-firebase" | "update-branch-app-name-in-firebase" | `machine-status-polling-${MachineState}` | `machine-image-exited-immediately` | `volume-not-found-${FlyVolumeState}` | "trying-to-remove-used-volume" | "missing-container-url" | "timeout" | "fatal:zod-validation-error" | `fatal:${string}`;
152
201
  export interface ErrorStateMessage extends BaseMessage {
153
202
  state: "error";
@@ -210,19 +259,27 @@ export interface GitBackupRecordOptions {
210
259
  forced: ForcedBackup;
211
260
  metadata?: Record<string, string | string[] | undefined>;
212
261
  }
262
+ export interface RecordScreenshotOptions {
263
+ projectId: string;
264
+ branchName: string;
265
+ completionId?: string;
266
+ screenshotUrl: string;
267
+ href?: string;
268
+ meta?: Record<string, any>;
269
+ }
213
270
  export interface GitBackupRecordResult {
214
271
  success: boolean;
215
272
  }
216
273
  export interface CodegenSetLastCommit {
217
274
  projectId: string;
218
275
  branchName: string;
219
- lastCommitHash: string;
276
+ lastCommitHash: GitSnapshot;
220
277
  clearSecondaryVolumeId: boolean;
221
278
  }
222
279
  export interface CodegenRuntimeStatus {
223
280
  projectId: string;
224
281
  branchName: string;
225
- lastCommitHash?: string;
282
+ lastCommitHash?: GitSnapshot;
226
283
  clearSecondaryVolumeId?: boolean;
227
284
  lastServerState?: LaunchServerState;
228
285
  lastServerVersion?: string;
@@ -279,7 +336,7 @@ export interface PartialBranchData {
279
336
  metadata?: BranchMetadata;
280
337
  backup?: BranchBackup;
281
338
  gitAiBranch?: string | null;
282
- lastCommitHash?: string | null;
339
+ lastCommitHash?: GitSnapshot | null;
283
340
  lastCommitDate?: number | null;
284
341
  commitMode?: CommitMode;
285
342
  useHomeDir?: boolean;
@@ -298,6 +355,7 @@ export type EntityState = "active" | "deleted" | "archived";
298
355
  export interface PrInfo {
299
356
  prNumber: number;
300
357
  prUrl: string;
358
+ status: PRStatus;
301
359
  }
302
360
  /**
303
361
  * Metadata stored in branches for integration tracking and PR description generation.
@@ -342,7 +400,7 @@ interface BranchSharedData {
342
400
  secondaryVolumeId?: string | null;
343
401
  volumeName?: string | null;
344
402
  gitAiBranch?: string | null;
345
- lastCommitHash?: string | null;
403
+ lastCommitHash?: GitSnapshot | null;
346
404
  lastCommitDate?: number | null;
347
405
  lastServerState?: LaunchServerState | null;
348
406
  lastServerStateDate?: number | null;
@@ -391,6 +449,9 @@ interface BranchSharedData {
391
449
  lastActivityAt?: number;
392
450
  /** Whether the branch has unpushed changes (ahead > 0 or dirty working directory) */
393
451
  hasUnpushedChanges?: boolean;
452
+ screenshot?: string | null;
453
+ /** Screenshots indexed by normalized href (without query params, fragments, protocol) */
454
+ screenshots?: Record<string, string>;
394
455
  }
395
456
  /**
396
457
  * fields that are required in the new branch format, but optional in the legacy branch format.
@@ -500,7 +561,7 @@ export interface Project {
500
561
  autoStop?: MachineAutoStop;
501
562
  mainBranchName?: string;
502
563
  minMachinesRunning?: number;
503
- volumeSize?: 5 | 10 | 12 | 15 | 20;
564
+ volumeSize?: 5 | 10 | 12 | 15 | 20 | 25 | 30 | 50;
504
565
  includePath?: string;
505
566
  includePatterns?: string[];
506
567
  environmentVariables?: EnvironmentVariable[];
@@ -541,6 +602,7 @@ export interface Project {
541
602
  };
542
603
  postMergeMemories?: boolean;
543
604
  commitInstructions?: string;
605
+ maxAgentCompletions?: number;
544
606
  httpsServerKeyPath?: string;
545
607
  httpsServerCertPath?: string;
546
608
  httpsServerCaPath?: string;
package/src/projects.js CHANGED
@@ -1,3 +1,25 @@
1
+ /**
2
+ * Detect git provider from a repository URL (HTTPS or SSH).
3
+ * Used by both error diagnostics and connectivity checks for consistent provider labeling.
4
+ */
5
+ export function getGitProviderFromUrl(url) {
6
+ try {
7
+ const lower = url.toLowerCase();
8
+ // Prefer canonical hostnames to avoid false positives (e.g. custom host with "github" in name)
9
+ if (lower.includes("github.com"))
10
+ return "github";
11
+ if (lower.includes("gitlab.com"))
12
+ return "gitlab";
13
+ if (lower.includes("bitbucket.org"))
14
+ return "bitbucket";
15
+ if (lower.includes("dev.azure.com"))
16
+ return "azure";
17
+ return "unknown";
18
+ }
19
+ catch (_a) {
20
+ return "unknown";
21
+ }
22
+ }
1
23
  export const EXAMPLE_REPOS = [
2
24
  "steve8708/mui-vite",
3
25
  "steve8708/carbon-vite",