Skip to content

Commit 56a26f9

Browse files
authored
chore: Mark legacy tunnel methods deprecated (#706)
1 parent d510b53 commit 56a26f9

4 files changed

Lines changed: 45 additions & 19 deletions

File tree

src/resources/devboxes/devboxes.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,13 @@ export class Devboxes extends APIResource {
189189
}
190190

191191
/**
192-
* [Deprecated] Use POST /v1/devboxes/{id}/enable_tunnel instead. This endpoint
193-
* creates a legacy tunnel. The new enable_tunnel endpoint provides improved tunnel
194-
* functionality with authentication options.
192+
* @deprecated Use {@link enableTunnel} instead for V2 tunnels with better URL format.
195193
*
196-
* @deprecated
194+
* Creates a legacy tunnel to expose a specific port on the devbox.
195+
* The legacy tunnel URL format is: `https://{devbox_id}-{port}.tunnel.runloop.ai`
196+
*
197+
* V2 tunnels (via enableTunnel) provide encrypted URL-based access with the format:
198+
* `https://{port}-{tunnel_key}.tunnel.runloop.ai`
197199
*/
198200
createTunnel(
199201
id: string,

src/sdk/devbox.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,24 @@ export class DevboxNetOps {
102102
}
103103

104104
/**
105-
* [Deprecated] Use enableTunnel instead. This method creates a legacy tunnel.
105+
* @deprecated Use {@link enableTunnel} instead for V2 tunnels with better URL format.
106106
*
107-
* Open a port on the devbox to be accessible from the internet.
107+
* Creates a legacy tunnel to expose a specific port on the devbox.
108+
* The legacy tunnel URL format is: `https://{devbox_id}-{port}.tunnel.runloop.ai`
109+
*
110+
* V2 tunnels (via enableTunnel) provide encrypted URL-based access with the format:
111+
* `https://{port}-{tunnel_key}.tunnel.runloop.ai`
108112
*
109113
* @example
110114
* ```typescript
115+
* // Deprecated - use enableTunnel instead
111116
* const tunnel = await devbox.net.createTunnel({ port: 8080 });
117+
* console.log(tunnel.url); // Legacy URL format
112118
* ```
113119
*
114-
* @param {DevboxCreateTunnelParams} params - Tunnel creation parameters
120+
* @param {DevboxCreateTunnelParams} params - Tunnel creation parameters including port
115121
* @param {Core.RequestOptions} [options] - Request options
116-
* @returns {Promise<DevboxTunnelView>} Tunnel creation result
117-
* @deprecated Use enableTunnel instead for V2 tunnels
122+
* @returns {Promise<DevboxTunnelView>} Legacy tunnel view with devbox_id, port, and url
118123
*/
119124
async createTunnel(params: DevboxCreateTunnelParams, options?: Core.RequestOptions) {
120125
return this.client.devboxes.createTunnel(this.devboxId, params, options);

tests/objects/devbox.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,13 @@ describe('Devbox (New API)', () => {
331331
expect(result).toEqual(mockSSHKey);
332332
});
333333

334-
it('should create legacy tunnel', async () => {
335-
const mockTunnel = { devbox_id: 'devbox-123', port: 8080 };
334+
it('should create legacy tunnel (deprecated) and return old URL format', async () => {
335+
// Legacy tunnel response includes the old URL format: https://{devbox_id}-{port}.tunnel.runloop.ai
336+
const mockTunnel = {
337+
devbox_id: 'devbox-123',
338+
port: 8080,
339+
url: 'https://devbox-123-8080.tunnel.runloop.ai',
340+
};
336341
mockClient.devboxes.createTunnel.mockResolvedValue(mockTunnel);
337342

338343
const result = await devbox.net.createTunnel({ port: 8080 });
@@ -343,6 +348,10 @@ describe('Devbox (New API)', () => {
343348
undefined,
344349
);
345350
expect(result).toEqual(mockTunnel);
351+
expect(result.devbox_id).toBe('devbox-123');
352+
expect(result.port).toBe(8080);
353+
// Verify the legacy URL format contains devbox_id and port
354+
expect(result.url).toBe('https://devbox-123-8080.tunnel.runloop.ai');
346355
});
347356

348357
it('should enable V2 tunnel with params', async () => {

tests/smoketests/object-oriented/devbox.test.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,21 +263,31 @@ describe('smoketest: object-oriented devbox', () => {
263263
await devbox.shutdown();
264264
});
265265

266-
test('create and remove tunnel', async () => {
266+
test('create and remove legacy tunnel (deprecated)', async () => {
267267
const devbox = await sdk.devbox.create({
268268
name: uniqueName('sdk-devbox-tunnel'),
269269
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
270270
});
271271

272-
// Create tunnel
273-
const tunnel = await devbox.net.createTunnel({ port: 8080 });
274-
expect(tunnel).toBeDefined();
272+
try {
273+
// Create legacy tunnel using deprecated createTunnel method
274+
const tunnel = await devbox.net.createTunnel({ port: 8080 });
275275

276-
// Remove tunnel
277-
await devbox.net.removeTunnel({ port: 8080 });
276+
// Verify the legacy tunnel response structure
277+
expect(tunnel).toBeDefined();
278+
expect(tunnel.devbox_id).toBe(devbox.id);
279+
expect(tunnel.port).toBe(8080);
280+
expect(tunnel.url).toBeDefined();
278281

279-
// Clean up
280-
await devbox.shutdown();
282+
// Verify the legacy tunnel URL format: https://{devbox_id}-{port}.tunnel.runloop.ai
283+
const expectedUrlPattern = new RegExp(`^https://${devbox.id}-8080\\.tunnel\\.runloop\\.ai$`);
284+
expect(tunnel.url).toMatch(expectedUrlPattern);
285+
286+
// Remove legacy tunnel
287+
await devbox.net.removeTunnel({ port: 8080 });
288+
} finally {
289+
await devbox.shutdown();
290+
}
281291
});
282292

283293
test('enable V2 tunnel (open)', async () => {

0 commit comments

Comments
 (0)