Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,17 @@ import {
DevboxWaitForCommandParams,
DevboxWriteFileContentsParams,
Devboxes,
PtyTunnelView,
TunnelView,
} from './resources/devboxes/devboxes';
import {
Pty,
PtyConnectParams,
PtyConnectView,
PtyControlAction,
PtyControlParams,
PtyControlResultView,
} from './resources/pty';
import {
InputContext,
InputContextUpdate,
Expand Down Expand Up @@ -374,6 +383,7 @@ export class Runloop extends Core.APIClient {
axons: API.Axons = new API.Axons(this);
blueprints: API.Blueprints = new API.Blueprints(this);
devboxes: API.Devboxes = new API.Devboxes(this);
pty: API.Pty = new API.Pty(this);
scenarios: API.Scenarios = new API.Scenarios(this);
objects: API.Objects = new API.Objects(this);
secrets: API.Secrets = new API.Secrets(this);
Expand Down Expand Up @@ -440,6 +450,7 @@ Runloop.BlueprintViewsBlueprintsCursorIDPage = BlueprintViewsBlueprintsCursorIDP
Runloop.Devboxes = Devboxes;
Runloop.DevboxViewsDevboxesCursorIDPage = DevboxViewsDevboxesCursorIDPage;
Runloop.DevboxSnapshotViewsDiskSnapshotsCursorIDPage = DevboxSnapshotViewsDiskSnapshotsCursorIDPage;
Runloop.Pty = Pty;
Runloop.Scenarios = Scenarios;
Runloop.ScenarioViewsScenariosCursorIDPage = ScenarioViewsScenariosCursorIDPage;
Runloop.Objects = Objects;
Expand Down Expand Up @@ -635,6 +646,7 @@ export declare namespace Runloop {
type DevboxSnapshotListView as DevboxSnapshotListView,
type DevboxSnapshotView as DevboxSnapshotView,
type DevboxView as DevboxView,
type PtyTunnelView as PtyTunnelView,
type TunnelView as TunnelView,
type DevboxCreateSSHKeyResponse as DevboxCreateSSHKeyResponse,
type DevboxDeleteDiskSnapshotResponse as DevboxDeleteDiskSnapshotResponse,
Expand Down Expand Up @@ -662,6 +674,15 @@ export declare namespace Runloop {
type DevboxWriteFileContentsParams as DevboxWriteFileContentsParams,
};

export {
Pty as Pty,
type PtyConnectView as PtyConnectView,
type PtyControlAction as PtyControlAction,
type PtyControlParams as PtyControlParams,
type PtyControlResultView as PtyControlResultView,
type PtyConnectParams as PtyConnectParams,
};

export {
Scenarios as Scenarios,
type InputContext as InputContext,
Expand Down
22 changes: 22 additions & 0 deletions src/resources/devboxes/devboxes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ export class Devboxes extends APIResource {
return this._client.post(`/v1/devboxes/${id}/create_ssh_key`, options);
}

/**
* Create an ephemeral PTY tunnel for a running Devbox.
*/
createPtyTunnel(id: string, options?: Core.RequestOptions): Core.APIPromise<PtyTunnelView> {
return this._client.post(`/v1/devboxes/${id}/create_pty_tunnel`, options);
}

/**
* Delete a previously taken disk snapshot of a Devbox.
*/
Expand Down Expand Up @@ -1008,6 +1015,21 @@ export interface TunnelView {
auth_token?: string | null;
}

/**
* An ephemeral PTY tunnel providing authenticated terminal access to a Devbox.
*/
export interface PtyTunnelView {
/**
* Bearer token for tunnel authentication. Always required for PTY tunnels.
*/
auth_token: string;

/**
* The encrypted tunnel key used to construct the tunnel URL.
*/
tunnel_key: string;
}

export interface DevboxCreateSSHKeyResponse {
/**
* The ID of the Devbox.
Expand Down
1 change: 1 addition & 0 deletions src/resources/devboxes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
type DevboxSnapshotListView,
type DevboxSnapshotView,
type DevboxView,
type PtyTunnelView,
type TunnelView,
type DevboxCreateSSHKeyResponse,
type DevboxDeleteDiskSnapshotResponse,
Expand Down
9 changes: 9 additions & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export {
type DevboxSnapshotListView,
type DevboxSnapshotView,
type DevboxView,
type PtyTunnelView,
type TunnelView,
type DevboxCreateSSHKeyResponse,
type DevboxDeleteDiskSnapshotResponse,
Expand All @@ -121,6 +122,14 @@ export {
type DevboxWaitForCommandParams,
type DevboxWriteFileContentsParams,
} from './devboxes/devboxes';
export {
Pty,
type PtyConnectView,
type PtyControlAction,
type PtyControlParams,
type PtyControlResultView,
type PtyConnectParams,
} from './pty';
export {
GatewayConfigViewsGatewayConfigsCursorIDPage,
GatewayConfigs,
Expand Down
83 changes: 83 additions & 0 deletions src/resources/pty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../resource';
import { isRequestOptions } from '../core';
import * as Core from '../core';

export class Pty extends APIResource {
/**
* Create or reconnect to a PTY session.
*/
connect(
sessionName: string,
query?: PtyConnectParams,
options?: Core.RequestOptions,
): Core.APIPromise<PtyConnectView>;
connect(sessionName: string, options?: Core.RequestOptions): Core.APIPromise<PtyConnectView>;
connect(
sessionName: string,
query: PtyConnectParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<PtyConnectView> {
if (isRequestOptions(query)) {
return this.connect(sessionName, {}, query);
}
return this._client.get(`/pty/${sessionName}`, { query, ...options });
}

/**
* Send a control command to a PTY session.
*/
control(
sessionName: string,
body: PtyControlParams,
options?: Core.RequestOptions,
): Core.APIPromise<PtyControlResultView> {
return this._client.post(`/pty/${sessionName}/control`, { body, ...options });
}
}

export interface PtyConnectView {
attached: boolean;

created: boolean;

cols?: number;

connect_url?: string;

idle_ttl_seconds?: number;

protocol_version?: string;

rows?: number;

session_name?: string;

status?: string;
}

export type PtyControlAction = 'resize' | 'signal' | 'close';

export type PtyControlParams =
| { action: 'resize'; cols: number; rows: number }
| { action: 'signal'; signal: string }
| { action: 'close' };

export interface PtyControlResultView {
session_name?: string;

status?: string;
}

export interface PtyConnectParams {
/**
* Optional initial terminal width in character cells.
*/
cols?: number | string;

/**
* Optional initial terminal height in character cells.
*/
rows?: number | string;
}
9 changes: 9 additions & 0 deletions src/sdk/devbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ import { LongPollRequestOptions, PollingOptions } from '../lib/polling';
import { Snapshot } from './snapshot';
import { Execution } from './execution';
import { ExecutionResult } from './execution-result';
import { DevboxPtyOps } from './pty';
import { uuidv7 } from 'uuidv7';

// Re-export Execution and ExecutionResult for Devbox namespace
export { Execution } from './execution';
export { ExecutionResult } from './execution-result';
export { DevboxPtyOps, DevboxPtyProcess, DevboxPtySession, PtyOutput } from './pty';

/**
* Streaming callbacks for real-time log processing.
Expand Down Expand Up @@ -506,6 +508,7 @@ export class DevboxFileOps {
* - {@link DevboxNetOps net} - Network operations
* - {@link DevboxCmdOps cmd} - Command execution operations
* - {@link DevboxFileOps file} - File operations
* - {@link DevboxPtyOps pty} - PTY terminal operations
*
* ## Quickstart
*
Expand Down Expand Up @@ -538,12 +541,18 @@ export class Devbox {
*/
public readonly file: DevboxFileOps;

/**
* PTY terminal operations on the devbox.
*/
public readonly pty: DevboxPtyOps;

private constructor(client: Runloop, id: string) {
this.client = client;
this._id = id;
this.net = new DevboxNetOps(this.client, this._id);
this.cmd = new DevboxCmdOps(this.client, this._id, this.startStreamingWithCallbacks.bind(this));
this.file = new DevboxFileOps(this.client, this._id);
this.pty = new DevboxPtyOps(this.client, this._id);
}

/**
Expand Down
12 changes: 11 additions & 1 deletion src/sdk/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
export { Devbox, DevboxCmdOps, DevboxFileOps, DevboxNetOps, type ExecuteStreamingCallbacks } from './devbox';
export {
Devbox,
DevboxCmdOps,
DevboxFileOps,
DevboxNetOps,
DevboxPtyOps,
DevboxPtyProcess,
DevboxPtySession,
PtyOutput,
type ExecuteStreamingCallbacks,
} from './devbox';
export { Blueprint } from './blueprint';
export { Snapshot } from './snapshot';
export { StorageObject } from './storage-object';
Expand Down
Loading
Loading