@gitterm/sdk 0.11.0 → 0.12.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/README.md CHANGED
@@ -676,8 +676,9 @@ duplicate and blank labels are dropped. Hosted users need the API redeployed for
676
676
 
677
677
  The quick start above shows a complete relay. Rejecting a permission or dismissing a question
678
678
  ends the turn: OpenCode records a failed tool call and the run finishes. A run left
679
- `awaiting_input` does not keep its workspace awake; if nobody answers before the workspace's
680
- idle timeout pauses it, the run is cancelled with `"Workspace paused while waiting for input"`.
679
+ `awaiting_input` keeps its workspace awake until the run's execution deadline, when it is
680
+ cancelled. If the workspace stops anyway (paused or deleted), the run is cancelled with
681
+ `"Workspace paused while waiting for input"`.
681
682
  To avoid prompts entirely in headless runs, allow the relevant tools in
682
683
  `opencode.config.permission` when creating the workspace.
683
684
 
@@ -853,6 +854,39 @@ await saveConfig({
853
854
  Device-code logins produce the same revocable `gt_...` API token as the dashboard;
854
855
  they appear under **API tokens** in the dashboard and can be revoked there.
855
856
 
857
+ ## Sandboxes
858
+
859
+ `@gitterm/sdk/sandbox` runs commands in a plain remote sandbox, with no coding agent
860
+ inside, on behalf of a local agent or script. The same client works against your
861
+ Gitterm plan (`managed`) or your own provider account (`direct`, no Gitterm login needed).
862
+ Direct mode supports E2B, Daytona, Vercel, Boat, exe.dev, and Railway; managed mode also AWS:
863
+
864
+ ```ts
865
+ import { captureSource, createSandboxBackend, createSandboxClient } from "@gitterm/sdk/sandbox";
866
+
867
+ const settings = {
868
+ account: "e2b",
869
+ accounts: {
870
+ e2b: { mode: "direct" as const, provider: "e2b" as const, apiKeyEnv: "E2B_API_KEY" },
871
+ },
872
+ };
873
+ const sandboxes = createSandboxClient({ backend: createSandboxBackend(settings) });
874
+
875
+ const sandbox = await sandboxes.create({ name: "ci", lifetimeMinutes: 30 });
876
+ await sandboxes.sync(sandbox, await captureSource(process.cwd())); // includes uncommitted changes
877
+ const run = await sandboxes.exec(sandbox, { command: "npm test", waitMs: 300_000 });
878
+ console.log(run.state.status, run.state.exitCode, run.job.snapshotDigest);
879
+ console.log(run.log.text); // last 8 KiB; page with sandboxes.job(sandbox, run.job.id, { offset })
880
+ await sandboxes.destroy(sandbox);
881
+ ```
882
+
883
+ Jobs are durable: their state lives in the sandbox, so another process can reattach with
884
+ `sandboxes.job()` or stop the whole process group with `sandboxes.cancel()`. A non-zero
885
+ exit is a `failed` job; a provider failure throws `SandboxProviderError`. Managed
886
+ primitives are also available directly as `client.sandboxes.*`. See
887
+ [Agent sandboxes](../../docs/agent-sandboxes.md) for modes, credentials, charges, and
888
+ cleanup.
889
+
856
890
  ## Direct provider mode
857
891
 
858
892
  Direct mode runs an agent using your cloud-provider account without a Gitterm server. It intentionally omits managed billing, proxying, policy, durable run history, and automatic cleanup; your application owns workspace state and lifecycle.
@@ -864,7 +898,7 @@ All built-in compute providers use the same provisioning plan and workspace/run
864
898
  | E2B | OpenCode-compatible template | Yes | Yes |
865
899
  | Daytona | Public Gitterm OpenCode server image by default | Yes | Yes |
866
900
  | Vercel | Vercel Sandbox project | Yes | Yes |
867
- | boat | boat API key (provider type `ascii`) | Yes | Yes |
901
+ | Boat | Boat API key (provider type `boat`) | Yes | Yes |
868
902
  | exe.dev | Lifecycle token, or an existing VM with `ls,ssh,share,ssh-key` | Yes | No |
869
903
  | Railway | Project/environment and public service domains | With a volume | No |
870
904
 
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AgentType, AgentRun, AgentRunCreateInput, AgentRunListOptions, AgentRunListResult, AgentRunMessage, AgentRunReply, AuthStatus, CloudProvider, RunRef, RunWaitOptions, RunWatchOptions, WaitOptions, Workspace, WorkspaceCreateInput, WorkspaceCreateResult, WorkspaceEnsureRunningResult, WorkspaceListOptions, WorkspaceListResult, WorkspaceRef, WorkspaceRestartResult, WorkspaceRuntimeAccess, WorkspacePauseResult, WorkspaceTerminateResult, WorkspaceCatalog, WorkspaceSetupStatus, ModelCredential, ModelProviderInfo, Integration, IntegrationKey, Connection, SavedBot, ConnectionKind, CreateConnectionInput, CreateConnectionResult, GitHubRepository, GitHubBranch, GoogleSetup, McpConnectionTestResult, UpdateMcpConnectionInput } from "./types.js";
1
+ import type { AgentType, AgentRun, AgentRunCreateInput, AgentRunListOptions, AgentRunListResult, AgentRunMessage, AgentRunReply, AuthStatus, CloudProvider, RunRef, RunWaitOptions, RunWatchOptions, WaitOptions, Workspace, WorkspaceCreateInput, WorkspaceCreateResult, WorkspaceEnsureRunningResult, WorkspaceListOptions, WorkspaceListResult, WorkspaceRef, WorkspaceRestartResult, WorkspaceRuntimeAccess, WorkspacePauseResult, WorkspaceTerminateResult, WorkspaceCatalog, WorkspaceSetupStatus, ModelCredential, ModelProviderInfo, Integration, IntegrationKey, Connection, SavedBot, ConnectionKind, CreateConnectionInput, CreateConnectionResult, GitHubRepository, GitHubBranch, GoogleSetup, McpConnectionTestResult, UpdateMcpConnectionInput, ManagedSandbox, ManagedSandboxCreateInput, ManagedSandboxSnapshot, SandboxJobFinished } from "./types.js";
2
2
  import type { AgentRunEvent, AgentRunResult, RunResultOptions, WorkspaceModelAccess } from "./types.js";
3
3
  export type GittermClientOptions = {
4
4
  serverUrl?: string;
@@ -53,6 +53,54 @@ export type GittermClient = {
53
53
  events(run: RunRef, options?: RunWatchOptions): AsyncIterable<AgentRunEvent>;
54
54
  result(run: RunRef, options?: RunResultOptions): Promise<AgentRunResult>;
55
55
  };
56
+ /** Plain command sandboxes billed to this account. Higher-level jobs live in `@gitterm/sdk/sandbox`. */
57
+ sandboxes: {
58
+ create(input: ManagedSandboxCreateInput): Promise<ManagedSandbox>;
59
+ list(input?: {
60
+ includeTerminated?: boolean;
61
+ }): Promise<ManagedSandbox[]>;
62
+ get(sandboxId: string): Promise<ManagedSandbox>;
63
+ /** A non-zero exit is returned, not thrown. At most two minutes; use jobs for longer work. */
64
+ run(sandboxId: string, command: string, options?: {
65
+ cwd?: string;
66
+ timeoutMs?: number;
67
+ env?: Record<string, string>;
68
+ }): Promise<{
69
+ exitCode: number;
70
+ stdout: string;
71
+ stderr: string;
72
+ }>;
73
+ writeFile(sandboxId: string, path: string, data: Uint8Array): Promise<void>;
74
+ readFile(sandboxId: string, path: string): Promise<Uint8Array>;
75
+ /**
76
+ * `headers` holds a sandbox-scoped access value for private previews. `gittermUrl`, when
77
+ * set, is served by Gitterm: open to anyone if `public`, else only to you signed in.
78
+ */
79
+ preview(sandboxId: string, port: number, options?: {
80
+ public?: boolean;
81
+ }): Promise<{
82
+ url: string;
83
+ headers: Record<string, string>;
84
+ gittermUrl?: string;
85
+ }>;
86
+ /** Resume a sandbox paused for inactivity. Subject to the same quota checks as creation. */
87
+ resume(sandboxId: string): Promise<void>;
88
+ terminate(sandboxId: string): Promise<void>;
89
+ /**
90
+ * Save a running sandbox as a snapshot new sandboxes can start from (`snapshotId` on
91
+ * create). Counts against your plan's snapshot limit until deleted. On Vercel, saving
92
+ * stops the sandbox.
93
+ */
94
+ saveSnapshot(sandboxId: string, label: string): Promise<ManagedSandboxSnapshot>;
95
+ listSnapshots(): Promise<ManagedSandboxSnapshot[]>;
96
+ deleteSnapshot(snapshotId: string): Promise<void>;
97
+ /**
98
+ * Calls `listener` as jobs in your sandboxes finish. Only Gitterm sandboxes on gitterm.dev
99
+ * report jobs; elsewhere nothing arrives, so keep a slower check as well. Returns a stop
100
+ * function. The connection reconnects by itself.
101
+ */
102
+ onJobFinished(listener: (event: SandboxJobFinished) => void): () => void;
103
+ };
56
104
  catalog: {
57
105
  agentTypes(input?: {
58
106
  serverOnly?: boolean;
@@ -0,0 +1,2 @@
1
+ import type { BoatDirectProviderConfig, DirectProviderAdapter } from "./types.js";
2
+ export declare function createBoatDirectProvider(config: BoatDirectProviderConfig): DirectProviderAdapter;
@@ -1,8 +1,8 @@
1
1
  export { createDirectGittermClient, type DirectGittermClient, type DirectGittermClientOptions, } from "./client.js";
2
2
  export { createE2BDirectProvider } from "./e2b.js";
3
- export { createAsciiDirectProvider } from "./ascii.js";
3
+ export { createBoatDirectProvider } from "./boat.js";
4
4
  export { createDaytonaDirectProvider } from "./daytona.js";
5
5
  export { createExeDevDirectProvider } from "./exedev.js";
6
6
  export { createRailwayDirectProvider } from "./railway.js";
7
7
  export { createVercelDirectProvider } from "./vercel.js";
8
- export type { AsciiDirectProviderConfig, DirectAuthAttempt, DirectAuthAttemptStatus, DirectAuthIntegration, DirectAuthMethod, DirectAuthPrompt, DirectAuthWaitOptions, DirectApiModelCredential, DaytonaDirectProviderConfig, DirectModelCredential, DirectOAuthModelCredential, DirectProviderAdapter, DirectProviderCapabilities, DirectProviderConfig, DirectProviderWorkspaceInput, DirectRun, DirectRunCreateInput, DirectRunMessage, DirectRunWaitOptions, DirectSecretFile, DirectWorkspace, DirectWorkspaceCreateInput, DirectWorkspaceLifecycle, DirectWorkspaceRuntime, DirectWorkspaceSetup, DirectWorkspaceSetupStatus, DirectWorkspaceSetupWaitOptions, E2BDirectProviderConfig, ExeDevDirectProviderConfig, RailwayDirectProviderConfig, VercelDirectProviderConfig, } from "./types.js";
8
+ export type { BoatDirectProviderConfig, DirectAuthAttempt, DirectAuthAttemptStatus, DirectAuthIntegration, DirectAuthMethod, DirectAuthPrompt, DirectAuthWaitOptions, DirectApiModelCredential, DaytonaDirectProviderConfig, DirectModelCredential, DirectOAuthModelCredential, DirectProviderAdapter, DirectProviderCapabilities, DirectProviderConfig, DirectProviderWorkspaceInput, DirectRun, DirectRunCreateInput, DirectRunMessage, DirectRunWaitOptions, DirectSecretFile, DirectWorkspace, DirectWorkspaceCreateInput, DirectWorkspaceLifecycle, DirectWorkspaceRuntime, DirectWorkspaceSetup, DirectWorkspaceSetupStatus, DirectWorkspaceSetupWaitOptions, E2BDirectProviderConfig, ExeDevDirectProviderConfig, RailwayDirectProviderConfig, VercelDirectProviderConfig, } from "./types.js";