@builder.io/ai-utils 0.13.4 → 0.14.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 +1 -1
- package/src/codegen.d.ts +16 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/organization.d.ts +8 -1
- package/src/projects.d.ts +5 -2
- package/src/vscode-tunnel.d.ts +89 -0
- package/src/vscode-tunnel.js +109 -0
package/package.json
CHANGED
package/src/codegen.d.ts
CHANGED
|
@@ -1271,6 +1271,20 @@ export interface LaunchServerStatus {
|
|
|
1271
1271
|
fusionConfig?: FusionConfig;
|
|
1272
1272
|
fusionEnvironment: "cloud" | "cloud-v2" | "unknown";
|
|
1273
1273
|
}
|
|
1274
|
+
/**
|
|
1275
|
+
* VS Code Tunnel status information
|
|
1276
|
+
*/
|
|
1277
|
+
export interface TunnelStatusInfo {
|
|
1278
|
+
enabled: boolean;
|
|
1279
|
+
status: "stopped" | "starting" | "running" | "error";
|
|
1280
|
+
name: string | null;
|
|
1281
|
+
url: string | null;
|
|
1282
|
+
vscodeUri: string | null;
|
|
1283
|
+
cursorUri: string | null;
|
|
1284
|
+
webUrl: string | null;
|
|
1285
|
+
error: string | null;
|
|
1286
|
+
workspacePath: string;
|
|
1287
|
+
}
|
|
1274
1288
|
export interface FusionStatus {
|
|
1275
1289
|
status: "ok";
|
|
1276
1290
|
state: LaunchServerState;
|
|
@@ -1291,6 +1305,8 @@ export interface FusionStatus {
|
|
|
1291
1305
|
fusionEnvironment: "cloud" | "cloud-v2" | "unknown";
|
|
1292
1306
|
wsClients: number;
|
|
1293
1307
|
httpClients: number;
|
|
1308
|
+
/** VS Code Tunnel status for remote editor connections */
|
|
1309
|
+
tunnel?: TunnelStatusInfo;
|
|
1294
1310
|
}
|
|
1295
1311
|
export interface FusionMetrics {
|
|
1296
1312
|
counters: {
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/organization.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ export interface GitlabEnterprisePATValue {
|
|
|
19
19
|
botUsername: string;
|
|
20
20
|
secondaryHost?: string;
|
|
21
21
|
}
|
|
22
|
+
export interface GitlabCloudFallbackToken {
|
|
23
|
+
token: string;
|
|
24
|
+
createdBy: string;
|
|
25
|
+
createdAt: number;
|
|
26
|
+
}
|
|
22
27
|
interface OrganizationSettings {
|
|
23
28
|
attribution?: string[];
|
|
24
29
|
visualEditorAiStyleInspirationURL?: string;
|
|
@@ -33,6 +38,7 @@ interface OrganizationSettings {
|
|
|
33
38
|
shopify?: boolean;
|
|
34
39
|
githubEnterpriseSetupValue?: GithubEnterpriseSetupValue;
|
|
35
40
|
gitlabEnterprisePAT?: GitlabEnterprisePATValue;
|
|
41
|
+
gitlabCloudFallbackToken?: GitlabCloudFallbackToken;
|
|
36
42
|
bitbucketEnterprisePAT?: BitbucketEnterprisePAT;
|
|
37
43
|
useProxy?: boolean;
|
|
38
44
|
fusionShareableUrlSuffix?: string;
|
|
@@ -44,7 +50,7 @@ interface OrganizationSettings {
|
|
|
44
50
|
privacyMode?: Pick<PrivacyMode, "mcpServers" | "redactUserMessages" | "redactLLMMessages"> & {
|
|
45
51
|
enabled?: boolean;
|
|
46
52
|
};
|
|
47
|
-
|
|
53
|
+
disableFigmaImageUpload?: boolean;
|
|
48
54
|
}
|
|
49
55
|
interface RoleOptions {
|
|
50
56
|
read?: boolean;
|
|
@@ -372,5 +378,6 @@ export interface Organization {
|
|
|
372
378
|
enterpriseTrialEndDate?: number;
|
|
373
379
|
fusionReferrals?: string;
|
|
374
380
|
githubInstallationIds?: number[];
|
|
381
|
+
disableFigmaImageUpload?: boolean;
|
|
375
382
|
}
|
|
376
383
|
export {};
|
package/src/projects.d.ts
CHANGED
|
@@ -136,7 +136,7 @@ export interface ReadyMessage extends BaseMessage {
|
|
|
136
136
|
export type MachineState = "unknown" | "created" | "starting" | "started" | "stopping" | "stopped" | "suspending" | "suspended" | "replacing" | "destroying" | "destroyed" | "not-found" | "running" | "failed";
|
|
137
137
|
export type FlyVolumeState = "unknown" | "creating" | "created" | "extending" | "restoring" | "enabling_remote_export" | "hydrating" | "recovering" | "scheduling_destroy" | "pending_destroy" | "failed";
|
|
138
138
|
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";
|
|
139
|
-
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" | "timeout" | "fatal:zod-validation-error" | `fatal:${string}`;
|
|
139
|
+
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}`;
|
|
140
140
|
export interface ErrorStateMessage extends BaseMessage {
|
|
141
141
|
state: "error";
|
|
142
142
|
message: string;
|
|
@@ -319,6 +319,9 @@ interface BranchSharedData {
|
|
|
319
319
|
kubePvcName?: string | null;
|
|
320
320
|
kubeHostname?: string | null;
|
|
321
321
|
checkoutBranch?: string | null;
|
|
322
|
+
vscodeTunnelUrl?: string | null;
|
|
323
|
+
vscodeTunnelName?: string | null;
|
|
324
|
+
vscodeTunnelExpiresAt?: string | null;
|
|
322
325
|
}
|
|
323
326
|
/**
|
|
324
327
|
* fields that are required in the new branch format, but optional in the legacy branch format.
|
|
@@ -520,7 +523,7 @@ export interface OrganizationPrivate {
|
|
|
520
523
|
updatedAt: number;
|
|
521
524
|
}
|
|
522
525
|
export interface CreateProjectOptions {
|
|
523
|
-
name
|
|
526
|
+
name?: string;
|
|
524
527
|
repoFullName: string;
|
|
525
528
|
repoProvider: string;
|
|
526
529
|
repoProtocol?: string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VS Code Tunnel Deep Link Utilities
|
|
3
|
+
*
|
|
4
|
+
* Generates deep links for opening VS Code, Cursor, or web editor
|
|
5
|
+
* connected to a VS Code tunnel.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default workspace path inside the container
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_WORKSPACE_PATH = "/root/app/code";
|
|
11
|
+
/**
|
|
12
|
+
* Generate a VS Code deep link for a tunnel
|
|
13
|
+
*
|
|
14
|
+
* @param tunnelName - The name of the VS Code tunnel
|
|
15
|
+
* @param workspacePath - The path to open in the editor (defaults to /root/app/code)
|
|
16
|
+
* @returns A vscode:// URI that opens VS Code connected to the tunnel
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* generateVSCodeDeepLink("my-project-main")
|
|
20
|
+
* // Returns: "vscode://vscode-remote/tunnel+my-project-main/root/app/code"
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateVSCodeDeepLink(tunnelName: string, workspacePath?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a Cursor deep link for a tunnel
|
|
25
|
+
*
|
|
26
|
+
* @param tunnelName - The name of the VS Code tunnel
|
|
27
|
+
* @param workspacePath - The path to open in the editor (defaults to /root/app/code)
|
|
28
|
+
* @returns A cursor:// URI that opens Cursor connected to the tunnel
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* generateCursorDeepLink("my-project-main")
|
|
32
|
+
* // Returns: "cursor://cursor-remote/tunnel+my-project-main/root/app/code"
|
|
33
|
+
*/
|
|
34
|
+
export declare function generateCursorDeepLink(tunnelName: string, workspacePath?: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Generate a web editor (vscode.dev) link for a tunnel
|
|
37
|
+
*
|
|
38
|
+
* @param tunnelName - The name of the VS Code tunnel
|
|
39
|
+
* @param workspacePath - The path to open in the editor (defaults to /root/app/code)
|
|
40
|
+
* @returns A https://vscode.dev URL that opens the web editor connected to the tunnel
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* generateWebEditorLink("my-project-main")
|
|
44
|
+
* // Returns: "https://vscode.dev/tunnel/my-project-main/root/app/code"
|
|
45
|
+
*/
|
|
46
|
+
export declare function generateWebEditorLink(tunnelName: string, workspacePath?: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Generate all deep links for a tunnel
|
|
49
|
+
*
|
|
50
|
+
* @param tunnelName - The name of the VS Code tunnel
|
|
51
|
+
* @param workspacePath - The path to open in the editor (defaults to /root/app/code)
|
|
52
|
+
* @returns An object containing all deep link variants
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* generateAllEditorLinks("my-project-main")
|
|
56
|
+
* // Returns: {
|
|
57
|
+
* // vscode: "vscode://vscode-remote/tunnel+my-project-main/root/app/code",
|
|
58
|
+
* // cursor: "cursor://cursor-remote/tunnel+my-project-main/root/app/code",
|
|
59
|
+
* // web: "https://vscode.dev/tunnel/my-project-main/root/app/code"
|
|
60
|
+
* // }
|
|
61
|
+
*/
|
|
62
|
+
export declare function generateAllEditorLinks(tunnelName: string, workspacePath?: string): {
|
|
63
|
+
vscode: string;
|
|
64
|
+
cursor: string;
|
|
65
|
+
web: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Generate a sanitized tunnel name from project and branch identifiers
|
|
69
|
+
*
|
|
70
|
+
* @param projectId - The project ID
|
|
71
|
+
* @param branchName - The branch name
|
|
72
|
+
* @returns A DNS-compatible tunnel name (max 63 chars, lowercase alphanumeric and hyphens)
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* generateTunnelName("abc123", "feature/my-branch")
|
|
76
|
+
* // Returns: "abc123-feature-my-branch"
|
|
77
|
+
*/
|
|
78
|
+
export declare function generateTunnelName(projectId: string, branchName: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Parse a tunnel URL to extract the tunnel name
|
|
81
|
+
*
|
|
82
|
+
* @param tunnelUrl - A vscode.dev tunnel URL
|
|
83
|
+
* @returns The tunnel name, or null if the URL is invalid
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* parseTunnelUrl("https://vscode.dev/tunnel/my-project-main/root/app/code")
|
|
87
|
+
* // Returns: "my-project-main"
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseTunnelUrl(tunnelUrl: string): string | null;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VS Code Tunnel Deep Link Utilities
|
|
3
|
+
*
|
|
4
|
+
* Generates deep links for opening VS Code, Cursor, or web editor
|
|
5
|
+
* connected to a VS Code tunnel.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default workspace path inside the container
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_WORKSPACE_PATH = "/root/app/code";
|
|
11
|
+
/**
|
|
12
|
+
* Generate a VS Code deep link for a tunnel
|
|
13
|
+
*
|
|
14
|
+
* @param tunnelName - The name of the VS Code tunnel
|
|
15
|
+
* @param workspacePath - The path to open in the editor (defaults to /root/app/code)
|
|
16
|
+
* @returns A vscode:// URI that opens VS Code connected to the tunnel
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* generateVSCodeDeepLink("my-project-main")
|
|
20
|
+
* // Returns: "vscode://vscode-remote/tunnel+my-project-main/root/app/code"
|
|
21
|
+
*/
|
|
22
|
+
export function generateVSCodeDeepLink(tunnelName, workspacePath = DEFAULT_WORKSPACE_PATH) {
|
|
23
|
+
return `vscode://vscode-remote/tunnel+${tunnelName}${workspacePath}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generate a Cursor deep link for a tunnel
|
|
27
|
+
*
|
|
28
|
+
* @param tunnelName - The name of the VS Code tunnel
|
|
29
|
+
* @param workspacePath - The path to open in the editor (defaults to /root/app/code)
|
|
30
|
+
* @returns A cursor:// URI that opens Cursor connected to the tunnel
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* generateCursorDeepLink("my-project-main")
|
|
34
|
+
* // Returns: "cursor://cursor-remote/tunnel+my-project-main/root/app/code"
|
|
35
|
+
*/
|
|
36
|
+
export function generateCursorDeepLink(tunnelName, workspacePath = DEFAULT_WORKSPACE_PATH) {
|
|
37
|
+
return `cursor://cursor-remote/tunnel+${tunnelName}${workspacePath}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generate a web editor (vscode.dev) link for a tunnel
|
|
41
|
+
*
|
|
42
|
+
* @param tunnelName - The name of the VS Code tunnel
|
|
43
|
+
* @param workspacePath - The path to open in the editor (defaults to /root/app/code)
|
|
44
|
+
* @returns A https://vscode.dev URL that opens the web editor connected to the tunnel
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* generateWebEditorLink("my-project-main")
|
|
48
|
+
* // Returns: "https://vscode.dev/tunnel/my-project-main/root/app/code"
|
|
49
|
+
*/
|
|
50
|
+
export function generateWebEditorLink(tunnelName, workspacePath = DEFAULT_WORKSPACE_PATH) {
|
|
51
|
+
return `https://vscode.dev/tunnel/${tunnelName}${workspacePath}`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Generate all deep links for a tunnel
|
|
55
|
+
*
|
|
56
|
+
* @param tunnelName - The name of the VS Code tunnel
|
|
57
|
+
* @param workspacePath - The path to open in the editor (defaults to /root/app/code)
|
|
58
|
+
* @returns An object containing all deep link variants
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* generateAllEditorLinks("my-project-main")
|
|
62
|
+
* // Returns: {
|
|
63
|
+
* // vscode: "vscode://vscode-remote/tunnel+my-project-main/root/app/code",
|
|
64
|
+
* // cursor: "cursor://cursor-remote/tunnel+my-project-main/root/app/code",
|
|
65
|
+
* // web: "https://vscode.dev/tunnel/my-project-main/root/app/code"
|
|
66
|
+
* // }
|
|
67
|
+
*/
|
|
68
|
+
export function generateAllEditorLinks(tunnelName, workspacePath = DEFAULT_WORKSPACE_PATH) {
|
|
69
|
+
return {
|
|
70
|
+
vscode: generateVSCodeDeepLink(tunnelName, workspacePath),
|
|
71
|
+
cursor: generateCursorDeepLink(tunnelName, workspacePath),
|
|
72
|
+
web: generateWebEditorLink(tunnelName, workspacePath),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Generate a sanitized tunnel name from project and branch identifiers
|
|
77
|
+
*
|
|
78
|
+
* @param projectId - The project ID
|
|
79
|
+
* @param branchName - The branch name
|
|
80
|
+
* @returns A DNS-compatible tunnel name (max 63 chars, lowercase alphanumeric and hyphens)
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* generateTunnelName("abc123", "feature/my-branch")
|
|
84
|
+
* // Returns: "abc123-feature-my-branch"
|
|
85
|
+
*/
|
|
86
|
+
export function generateTunnelName(projectId, branchName) {
|
|
87
|
+
const combined = `${projectId}-${branchName}`;
|
|
88
|
+
const sanitized = combined
|
|
89
|
+
.toLowerCase()
|
|
90
|
+
.replace(/[^a-z0-9-]/g, "-")
|
|
91
|
+
.replace(/-+/g, "-")
|
|
92
|
+
.replace(/^-|-$/g, "")
|
|
93
|
+
.substring(0, 63);
|
|
94
|
+
return sanitized || "builder-tunnel";
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parse a tunnel URL to extract the tunnel name
|
|
98
|
+
*
|
|
99
|
+
* @param tunnelUrl - A vscode.dev tunnel URL
|
|
100
|
+
* @returns The tunnel name, or null if the URL is invalid
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* parseTunnelUrl("https://vscode.dev/tunnel/my-project-main/root/app/code")
|
|
104
|
+
* // Returns: "my-project-main"
|
|
105
|
+
*/
|
|
106
|
+
export function parseTunnelUrl(tunnelUrl) {
|
|
107
|
+
const match = tunnelUrl.match(/(?:vscode\.dev\/tunnel\/|tunnel\+)([a-zA-Z0-9_-]+)/);
|
|
108
|
+
return match ? match[1] : null;
|
|
109
|
+
}
|