@builder.io/ai-utils 0.87.1 → 0.89.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.87.1",
3
+ "version": "0.89.0",
4
4
  "description": "Builder.io AI utils",
5
5
  "files": [
6
6
  "src"
@@ -34,6 +34,22 @@ export declare const BuilderConfigHostingSchema: z.ZodObject<{
34
34
  }, z.core.$strip>>>;
35
35
  }, z.core.$strip>;
36
36
  export type BuilderConfigHosting = z.infer<typeof BuilderConfigHostingSchema>;
37
+ /**
38
+ * `realtime` block in `builder.config.json` — selects the change-notification
39
+ * delivery transport. `"local"` (default) keeps sync on the app's own
40
+ * `/_agent-native/poll` + `/_agent-native/events`; `"hosted"` routes clients to
41
+ * the Builder Realtime Gateway. Read by the backend provisioning path only —
42
+ * it is never shipped to the browser (the client learns transport via the
43
+ * impersonal `window.__AGENT_NATIVE_CONFIG__` script). See the Agent-Native
44
+ * Realtime Sync spec.
45
+ */
46
+ export declare const BuilderConfigRealtimeSchema: z.ZodObject<{
47
+ transport: z.ZodEnum<{
48
+ hosted: "hosted";
49
+ local: "local";
50
+ }>;
51
+ }, z.core.$strip>;
52
+ export type BuilderConfigRealtime = z.infer<typeof BuilderConfigRealtimeSchema>;
37
53
  export declare const BuilderConfigSchema: z.ZodObject<{
38
54
  database: z.ZodOptional<z.ZodObject<{
39
55
  kind: z.ZodLiteral<"postgres">;
@@ -49,5 +65,11 @@ export declare const BuilderConfigSchema: z.ZodObject<{
49
65
  prod: z.ZodCatch<z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodString>>>>;
50
66
  }, z.core.$strip>>>;
51
67
  }, z.core.$strip>>;
68
+ realtime: z.ZodCatch<z.ZodOptional<z.ZodObject<{
69
+ transport: z.ZodEnum<{
70
+ hosted: "hosted";
71
+ local: "local";
72
+ }>;
73
+ }, z.core.$strip>>>;
52
74
  }, z.core.$strip>;
53
75
  export type BuilderConfig = z.infer<typeof BuilderConfigSchema>;
@@ -57,7 +57,23 @@ export const BuilderConfigHostingSchema = z.object({
57
57
  buildOutputDir: z.string().optional().catch(undefined),
58
58
  environment: BuilderConfigHostingEnvironmentSchema.optional().catch(undefined),
59
59
  });
60
+ /**
61
+ * `realtime` block in `builder.config.json` — selects the change-notification
62
+ * delivery transport. `"local"` (default) keeps sync on the app's own
63
+ * `/_agent-native/poll` + `/_agent-native/events`; `"hosted"` routes clients to
64
+ * the Builder Realtime Gateway. Read by the backend provisioning path only —
65
+ * it is never shipped to the browser (the client learns transport via the
66
+ * impersonal `window.__AGENT_NATIVE_CONFIG__` script). See the Agent-Native
67
+ * Realtime Sync spec.
68
+ */
69
+ export const BuilderConfigRealtimeSchema = z.object({
70
+ transport: z.enum(["local", "hosted"]),
71
+ });
60
72
  export const BuilderConfigSchema = z.object({
61
73
  database: BuilderConfigDatabaseSchema.optional(),
62
74
  hosting: BuilderConfigHostingSchema.optional(),
75
+ // `.catch(undefined)` (like the `hosting` fields): a malformed `realtime`
76
+ // block degrades to "no realtime" rather than failing the whole parse and
77
+ // discarding a valid `database` block.
78
+ realtime: BuilderConfigRealtimeSchema.optional().catch(undefined),
63
79
  });
package/src/codegen.d.ts CHANGED
@@ -2433,8 +2433,6 @@ export declare const CodeGenInputOptionsSchema: z.ZodObject<{
2433
2433
  planning: "planning";
2434
2434
  }>>;
2435
2435
  url: z.ZodOptional<z.ZodString>;
2436
- diffActions: z.ZodOptional<z.ZodBoolean>;
2437
- planningPrompt: z.ZodOptional<z.ZodBoolean>;
2438
2436
  customInstructions: z.ZodOptional<z.ZodArray<z.ZodObject<{
2439
2437
  id: z.ZodString;
2440
2438
  name: z.ZodString;
@@ -2485,7 +2483,6 @@ export declare const CodeGenInputOptionsSchema: z.ZodObject<{
2485
2483
  wasIncluded: z.ZodOptional<z.ZodBoolean>;
2486
2484
  virtual: z.ZodOptional<z.ZodBoolean>;
2487
2485
  }, z.core.$strip>>>;
2488
- rerankFiles: z.ZodOptional<z.ZodNumber>;
2489
2486
  toolResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
2490
2487
  type: z.ZodLiteral<"tool_result">;
2491
2488
  tool_use_id: z.ZodString;
@@ -2767,18 +2764,13 @@ export declare const CodeGenInputOptionsSchema: z.ZodObject<{
2767
2764
  maxAgentLoops: z.ZodOptional<z.ZodNumber>;
2768
2765
  maxAgentTiming: z.ZodOptional<z.ZodNumber>;
2769
2766
  maxTokens: z.ZodOptional<z.ZodNumber>;
2770
- maxPages: z.ZodOptional<z.ZodNumber>;
2771
- autoContinue: z.ZodOptional<z.ZodNumber>;
2772
2767
  isManualContinue: z.ZodOptional<z.ZodBoolean>;
2773
- llmSuggestions: z.ZodOptional<z.ZodBoolean>;
2774
- conclusionText: z.ZodOptional<z.ZodBoolean>;
2775
2768
  mcpServers: z.ZodOptional<z.ZodBoolean>;
2776
2769
  pingEvents: z.ZodOptional<z.ZodBoolean>;
2777
2770
  forceCompact: z.ZodOptional<z.ZodBoolean>;
2778
2771
  hadPagination: z.ZodOptional<z.ZodBoolean>;
2779
2772
  category: z.ZodOptional<z.ZodUnion<readonly [z.ZodTemplateLiteral<`repair-${string}`>, z.ZodLiteral<"user-normal">, z.ZodLiteral<"user-figma">, z.ZodLiteral<"user-pdf">, z.ZodLiteral<"user-image">, z.ZodLiteral<"setup-agent">, z.ZodTemplateLiteral<`background-${string}`>, z.ZodTemplateLiteral<`indexing-${string}`>]>>;
2780
2773
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2781
- searchResponse: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
2782
2774
  prettierConfig: z.ZodOptional<z.ZodCustom<PrettierOptions, PrettierOptions>>;
2783
2775
  role: z.ZodOptional<z.ZodEnum<{
2784
2776
  agent: "agent";
@@ -2874,6 +2866,8 @@ export declare const CodeGenInputOptionsSchema: z.ZodObject<{
2874
2866
  export type CodeGenInputOptions = z.infer<typeof CodeGenInputOptionsSchema> & {
2875
2867
  /** @internal Derived from BuilderEditorState.components for editor AI. */
2876
2868
  _allowedComponentNames?: string[];
2869
+ /** @internal Derived from BuilderEditorState.components for editor AI. */
2870
+ _fieldShapeChecks?: FieldShapeCheck[];
2877
2871
  /**
2878
2872
  * Optional factory function to wrap the MCP client with custom behavior
2879
2873
  * Used by Editor AI to add permission checks for model operations
@@ -2883,6 +2877,11 @@ export type CodeGenInputOptions = z.infer<typeof CodeGenInputOptionsSchema> & {
2883
2877
  */
2884
2878
  _mcpClientWrapperFactory?: (realClient: any) => any;
2885
2879
  };
2880
+ export interface FieldShapeCheck {
2881
+ component: string;
2882
+ input: string;
2883
+ subField: string;
2884
+ }
2886
2885
  export type CodeGenErrorCodes = "credits-limit-daily" | "credits-limit-monthly" | "credits-limit-user" | "credits-limit-other" | "cli-genetic-error" | "git-update-error" | "prompt-too-long" | "context-too-long" | "abrupt-end" | "unknown" | "failed-recover-state" | "completion-expired" | "ask-to-continue" | "bad-initial-url" | "bad-smart-export-payload" | "invalid-last-message" | "corrupted-session" | "privacy-mode-key-required" | "privacy-mode-key-invalid" | "privacy-mode-key-mismatch" | "privacy-mode-validation-unavailable" | "cli-network-error" | "invalid-credentials" | "model-restricted-too-large" | "org-no-models-enabled" | "assertion" | "rate-limit" | "unknown-design-system";
2887
2886
  export interface CodegenUsage {
2888
2887
  total: number;
@@ -2915,38 +2914,6 @@ export interface ActionItem {
2915
2914
  suggestions?: PromptSuggestion[];
2916
2915
  errors?: string[];
2917
2916
  }
2918
- export interface RepoInfo {
2919
- remoteUrl: string;
2920
- defaultBranch: string;
2921
- currentBranch: string;
2922
- commit: string;
2923
- }
2924
- export interface CodebaseSearchOptions {
2925
- repoInfo?: RepoInfo;
2926
- query: string;
2927
- selectedFiles?: string[];
2928
- sessionId: string;
2929
- files?: string[];
2930
- packageJson?: string;
2931
- limit?: number;
2932
- includeContent?: boolean;
2933
- }
2934
- export interface CodebaseSearchResponse {
2935
- id: string;
2936
- relevantPaths: string[];
2937
- grepQueries: string[];
2938
- streamMeta: any;
2939
- ranked: RankedResult[];
2940
- }
2941
- export interface RankedResult {
2942
- index: number;
2943
- filePath: string;
2944
- startIndex: number;
2945
- endIndex: number;
2946
- score: number;
2947
- id: string;
2948
- content?: string;
2949
- }
2950
2917
  export interface GenerateCompletionStepThinking {
2951
2918
  type: "thinking";
2952
2919
  content: string;
@@ -3768,9 +3735,6 @@ export interface UserInput {
3768
3735
  systemReminders: SystemReminder[];
3769
3736
  attachments: Attachment[];
3770
3737
  files: ProjectFile[];
3771
- searchResponse: CodebaseSearchResponse | null;
3772
- rerankFiles?: number;
3773
- mostRelevantFile: string | null;
3774
3738
  toolResults: ContentMessageItemToolResult[];
3775
3739
  user: UserSource;
3776
3740
  patchFusionConfig?: Partial<FusionConfig> | undefined;
@@ -4575,20 +4539,6 @@ export interface LaunchServerStatus {
4575
4539
  memoryUsage?: number;
4576
4540
  sessionId?: string;
4577
4541
  }
4578
- /**
4579
- * VS Code Tunnel status information
4580
- */
4581
- export interface TunnelStatusInfo {
4582
- enabled: boolean;
4583
- status: "stopped" | "starting" | "running" | "error";
4584
- name: string | null;
4585
- url: string | null;
4586
- vscodeUri: string | null;
4587
- cursorUri: string | null;
4588
- webUrl: string | null;
4589
- error: string | null;
4590
- workspacePath: string;
4591
- }
4592
4542
  export interface FusionStatus {
4593
4543
  status: "ok";
4594
4544
  state: LaunchServerState;
@@ -4617,8 +4567,6 @@ export interface FusionStatus {
4617
4567
  containerStateTimestamp?: number;
4618
4568
  wsClients: number;
4619
4569
  httpClients: number;
4620
- /** VS Code Tunnel status for remote editor connections */
4621
- tunnel?: TunnelStatusInfo;
4622
4570
  /** Event loop delays collected every 5 seconds (in milliseconds) for percentile calculation */
4623
4571
  eventLoopDelays?: number[];
4624
4572
  /** Max memory pressure observed in the reporting period (0-1, where 1 is near OOM) */
package/src/codegen.js CHANGED
@@ -1616,6 +1616,11 @@ export const SessionModeSchema = z
1616
1616
  .meta({ title: "SessionMode" });
1617
1617
  export const CodeGenModeSchema = z
1618
1618
  .enum([
1619
+ /**
1620
+ * @deprecated The legacy quality-v2 pipeline has been removed. Old
1621
+ * dev-tools clients that still request this mode are served `quality-v4`.
1622
+ * New code should not produce this value.
1623
+ */
1619
1624
  "quality",
1620
1625
  "quality-v4",
1621
1626
  /**
@@ -1909,8 +1914,6 @@ export const CodeGenInputOptionsSchema = z
1909
1914
  codeGenMode: CodeGenModeSchema.optional(),
1910
1915
  sessionMode: SessionModeSchema.optional(),
1911
1916
  url: z.string().optional(),
1912
- diffActions: z.boolean().optional(),
1913
- planningPrompt: z.boolean().optional(),
1914
1917
  customInstructions: z.array(CustomInstructionSchema).optional(),
1915
1918
  customAgents: z.array(CustomAgentInfoSchema).optional(),
1916
1919
  systemPromptOverride: z.union([z.string(), z.array(z.string())]).optional(),
@@ -1920,7 +1923,6 @@ export const CodeGenInputOptionsSchema = z
1920
1923
  uiContextPrompt: z.string().optional(),
1921
1924
  displayUserPrompt: z.string().optional(),
1922
1925
  files: z.array(ProjectFileSchema).optional(),
1923
- rerankFiles: z.number().optional(),
1924
1926
  toolResults: z.array(ContentMessageItemToolResultSchema).optional(),
1925
1927
  attachments: z.array(AttachmentSchema).optional(),
1926
1928
  beforeCommit: GitSnapshotSchema.optional(),
@@ -1965,18 +1967,13 @@ export const CodeGenInputOptionsSchema = z
1965
1967
  maxTokens: z.number().optional().meta({
1966
1968
  description: "Maximum output tokens allowed in the LLM response. This will set the maximum token output for the LLM.",
1967
1969
  }),
1968
- maxPages: z.number().optional(),
1969
- autoContinue: z.number().optional(),
1970
1970
  isManualContinue: z.boolean().optional(),
1971
- llmSuggestions: z.boolean().optional(),
1972
- conclusionText: z.boolean().optional(),
1973
1971
  mcpServers: z.boolean().optional(),
1974
1972
  pingEvents: z.boolean().optional(),
1975
1973
  forceCompact: z.boolean().optional(),
1976
1974
  hadPagination: z.boolean().optional(),
1977
1975
  category: CodeGenCategorySchema.optional(),
1978
1976
  metadata: z.record(z.string(), z.any()).optional(),
1979
- searchResponse: z.any().nullish(),
1980
1977
  prettierConfig: z.custom().optional(),
1981
1978
  // Role
1982
1979
  role: z.enum(["user", "agent"]).optional(),
package/src/events.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { AssistantMessage, AssistantMessageAction } from "./messages.js";
3
3
  import type { AssistantSettings } from "./settings.js";
4
4
  import type { ExitState, UserSource, CodeGenPosition, ReviewSeverity, ReviewVerdict } from "./codegen.js";
5
5
  import type { FileUpload } from "./messages.js";
6
+ import type { BuilderConfigRealtime } from "./builder-config.js";
6
7
  export type BuilderAssistantEventHandler = (ev: BuilderAssistantEvent) => void;
7
8
  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 | ModelPermissionRequiredEvent | ModelPermissionResponseEvent;
8
9
  export interface AssistantCompletionResultEvent {
@@ -1271,6 +1272,15 @@ export type ClientDevtoolsBuildUploadedV1 = FusionEventVariant<"client.devtools.
1271
1272
  * directly in the handler and is not sent through the event.
1272
1273
  */
1273
1274
  prodEnvFromBuilderConfig?: Record<string, string>;
1275
+ /**
1276
+ * `realtime.transport` from the same `builder.config.json` read. Sent from
1277
+ * the pod because the tree it built is the authoritative revision — the
1278
+ * service would otherwise have to re-resolve the deployed commit through
1279
+ * the git provider, which for template-backed projects can resolve against
1280
+ * a different repo. Absent from pods predating this field; the handler
1281
+ * falls back to reading the repo at the deployed commit.
1282
+ */
1283
+ realtimeTransport?: BuilderConfigRealtime["transport"];
1274
1284
  }, {
1275
1285
  projectId: string;
1276
1286
  deployId: string;
package/src/index.d.ts CHANGED
@@ -13,7 +13,6 @@ export * from "./fusion-environment.js";
13
13
  export * from "./repo-indexing.js";
14
14
  export * from "./organization.js";
15
15
  export * from "./features.js";
16
- export * from "./vscode-tunnel.js";
17
16
  export * from "./claw.js";
18
17
  export * from "./kube-error.js";
19
18
  export * from "./connectivity/types.js";
package/src/index.js CHANGED
@@ -13,7 +13,6 @@ export * from "./fusion-environment.js";
13
13
  export * from "./repo-indexing.js";
14
14
  export * from "./organization.js";
15
15
  export * from "./features.js";
16
- export * from "./vscode-tunnel.js";
17
16
  export * from "./claw.js";
18
17
  export * from "./kube-error.js";
19
18
  export * from "./connectivity/types.js";
@@ -1,4 +1,4 @@
1
- import type { PrivacyMode, ReviewEffort } from "./codegen";
1
+ import type { PrivacyMode, ReasoningEffort, ReviewEffort } from "./codegen";
2
2
  import type { EnvironmentVariable } from "./common-schemas";
3
3
  export interface GitlabEnterpriseSetupValue {
4
4
  host: string;
@@ -103,6 +103,8 @@ interface OrganizationSettings {
103
103
  fusionPrQuietMode?: boolean;
104
104
  runInPty?: boolean;
105
105
  maxAgentCompletions?: number;
106
+ defaultBackgroundAgentModel?: string;
107
+ defaultBackgroundAgentEffort?: ReasoningEffort;
106
108
  privacyMode?: Pick<PrivacyMode, "mcpServers" | "redactUserMessages" | "redactLLMMessages"> & {
107
109
  enabled?: boolean;
108
110
  };
@@ -328,6 +330,7 @@ export interface FeatureMap {
328
330
  agentCreditsRollover?: boolean;
329
331
  selfHostedGitProviders?: boolean;
330
332
  reviewAgent?: boolean;
333
+ hosting?: boolean;
331
334
  }
332
335
  export interface SubscriptionInfo {
333
336
  price?: number;
@@ -420,6 +423,7 @@ export interface SubscriptionInfoMap {
420
423
  "vcp:v1:level1": SubscriptionInfo;
421
424
  "vcp:v1:level2": SubscriptionInfo;
422
425
  "vcp:v1:enterprise": SubscriptionInfo;
426
+ "vcp:v2:enterprise": SubscriptionInfo;
423
427
  "vcp:v2:level1": SubscriptionInfo;
424
428
  "vcp:v2:level2": SubscriptionInfo;
425
429
  "vcp:v3:level1": SubscriptionInfo;
package/src/projects.d.ts CHANGED
@@ -616,9 +616,6 @@ export interface BranchSharedData {
616
616
  checkoutCommit?: string | null;
617
617
  /** Whether this branch is for a fork PR - affects git operations (read-only, can't push) */
618
618
  isFork?: boolean | null;
619
- vscodeTunnelUrl?: string | null;
620
- vscodeTunnelName?: string | null;
621
- vscodeTunnelExpiresAt?: string | null;
622
619
  commitMode?: CommitMode;
623
620
  /** @internal When false, merging this branch's PR does not archive it. Seeded from project.settings at creation. */
624
621
  autoCloseBranchOnMerge?: boolean;
@@ -1610,6 +1607,15 @@ export interface ProjectDatabase {
1610
1607
  role: string;
1611
1608
  /** @internal Plaintext credential — Firestore IAM enforces access. Never serialize to client responses. */
1612
1609
  password: string;
1610
+ /**
1611
+ * @internal Per-project HMAC secret for signing/verifying Realtime Gateway
1612
+ * subscribe tokens. Plaintext like `password`; Firestore IAM enforces access.
1613
+ * Never serialize to client responses. Absent on projects provisioned before
1614
+ * the Realtime Sync Gateway shipped — there is no backfill by design; such a
1615
+ * project gets its secret on its next deploy. See the Agent-Native Realtime
1616
+ * Sync spec.
1617
+ */
1618
+ realtimeHmacSecret?: string;
1613
1619
  /** Database name (white-labeled to "main"); needed to build connection URIs. */
1614
1620
  database: string;
1615
1621
  region: string;
@@ -1,89 +0,0 @@
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;
@@ -1,109 +0,0 @@
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
- }