@gitterm/sdk 0.0.1 → 0.0.4
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 +177 -14
- package/dist/client.d.ts +56 -0
- package/dist/config.d.ts +11 -0
- package/dist/device-login.d.ts +15 -0
- package/dist/errors.d.ts +15 -0
- package/dist/index.d.ts +9 -213
- package/dist/index.js +177 -11
- package/dist/transport.d.ts +2 -0
- package/dist/types.d.ts +297 -0
- package/dist/workspace-client.d.ts +44 -0
- package/package.json +5 -7
- package/src/index.d.ts +0 -213
package/README.md
CHANGED
|
@@ -12,33 +12,93 @@ bun add @gitterm/sdk
|
|
|
12
12
|
npm install @gitterm/sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Switching servers (hosted vs self-hosted)
|
|
16
|
+
|
|
17
|
+
The default API is the hosted service at `https://api.gitterm.dev`. Self-hosted
|
|
18
|
+
instances use the same SDK — pass your instance’s base URL as `serverUrl`.
|
|
19
|
+
|
|
20
|
+
| Deployment | Example `serverUrl` |
|
|
21
|
+
| ----------- | ----------------------------- |
|
|
22
|
+
| Hosted | `https://api.gitterm.dev` |
|
|
23
|
+
| Self-hosted | `https://gitterm.example.com` |
|
|
24
|
+
| Local dev | `http://localhost:3000` |
|
|
25
|
+
|
|
26
|
+
### Explicit client (recommended for apps)
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { createGittermClient } from "@gitterm/sdk";
|
|
30
|
+
|
|
31
|
+
// Hosted
|
|
32
|
+
const hosted = createGittermClient({
|
|
33
|
+
serverUrl: "https://api.gitterm.dev",
|
|
34
|
+
token: process.env.GITTERM_API_TOKEN,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Self-hosted / local
|
|
38
|
+
const selfHosted = createGittermClient({
|
|
39
|
+
serverUrl: "https://gitterm.example.com", // or http://localhost:3000
|
|
40
|
+
token: process.env.GITTERM_API_TOKEN,
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Environment variables
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
export GITTERM_SERVER_URL=https://gitterm.example.com
|
|
48
|
+
export GITTERM_API_TOKEN=gt_...
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// Picks up GITTERM_SERVER_URL + GITTERM_API_TOKEN
|
|
53
|
+
const client = createGittermClient();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### CLI saved login
|
|
57
|
+
|
|
58
|
+
If you omit both options, the SDK also reads `~/.config/gitterm/cli.json` written by
|
|
59
|
+
`gitterm login` / `gitterm login --server <url>`.
|
|
60
|
+
|
|
61
|
+
**Resolution order:** constructor options → `GITTERM_SERVER_URL` / `GITTERM_API_TOKEN` → CLI config file.
|
|
62
|
+
|
|
63
|
+
Create tokens in the dashboard under **Settings → Account → API tokens**, or via
|
|
64
|
+
`gitterm login` (device-code flow). Tokens are the same `gt_...` shape on hosted and
|
|
65
|
+
self-hosted.
|
|
66
|
+
|
|
15
67
|
## Usage
|
|
16
68
|
|
|
17
69
|
### With an explicit API token
|
|
18
70
|
|
|
19
|
-
Create a token in the GitTerm dashboard under **Settings → Account → API tokens**
|
|
20
|
-
(revocable, optional expiry), or obtain one via `gitterm login`.
|
|
21
|
-
|
|
22
71
|
```ts
|
|
23
72
|
import { createGittermClient } from "@gitterm/sdk";
|
|
24
73
|
|
|
25
74
|
const client = createGittermClient({
|
|
26
|
-
serverUrl: "https://api.gitterm.dev",
|
|
27
75
|
token: process.env.GITTERM_API_TOKEN,
|
|
28
76
|
});
|
|
29
77
|
|
|
30
78
|
const { workspaces } = await client.workspaces.list();
|
|
31
79
|
```
|
|
32
80
|
|
|
33
|
-
|
|
81
|
+
The SDK deliberately exposes two clients. `createGittermClient()` uses a user API token and
|
|
82
|
+
can manage the user's workspaces. `createGittermWorkspaceClient()` uses the scoped identity
|
|
83
|
+
injected into a GitTerm workspace and can inspect only that workspace and its ports:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { createGittermWorkspaceClient } from "@gitterm/sdk";
|
|
87
|
+
|
|
88
|
+
const workspace = createGittermWorkspaceClient();
|
|
89
|
+
const self = await workspace.self.get();
|
|
90
|
+
const preview = await workspace.ports.open(3000, { name: "app" });
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The workspace client never reads the CLI's saved account login and has no create, list,
|
|
94
|
+
pause, restart, or terminate operations.
|
|
34
95
|
|
|
35
|
-
|
|
36
|
-
(`~/.config/gitterm/cli.json`), falling back to the `GITTERM_SERVER_URL` and
|
|
37
|
-
`GITTERM_API_TOKEN` environment variables.
|
|
96
|
+
### With the CLI's saved login
|
|
38
97
|
|
|
39
98
|
```ts
|
|
40
99
|
const client = createGittermClient();
|
|
41
100
|
const status = await client.auth.status();
|
|
101
|
+
// status + client.serverUrl show which account and server you hit
|
|
42
102
|
```
|
|
43
103
|
|
|
44
104
|
### API
|
|
@@ -47,14 +107,106 @@ const status = await client.auth.status();
|
|
|
47
107
|
client.auth.status(); // -> { userId, email, name, plan, authMethod }
|
|
48
108
|
client.workspaces.list(options?); // -> { workspaces, pagination }
|
|
49
109
|
client.workspaces.get(workspaceId);
|
|
110
|
+
client.workspaces.getRuntimeAccess(workspaceId); // read-only; never resumes compute
|
|
111
|
+
client.workspaces.ensureRunning(workspaceId, options?);
|
|
50
112
|
client.workspaces.pause(workspaceId);
|
|
51
113
|
client.workspaces.restart(workspaceId);
|
|
52
114
|
client.workspaces.terminate(workspaceId);
|
|
53
|
-
client.workspaces.create(
|
|
115
|
+
client.workspaces.create({
|
|
116
|
+
repo: "https://github.com/acme/product",
|
|
117
|
+
});
|
|
54
118
|
client.catalog.agentTypes();
|
|
55
119
|
client.catalog.cloudProviders();
|
|
120
|
+
client.catalog.workspaceOptions();
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The server defaults the agent to `opencode`, selects the user's preferred provider,
|
|
124
|
+
uses that provider's default machine profile, and applies the provider's persistence policy.
|
|
125
|
+
Override only the placement decisions your integration cares about:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
await client.workspaces.create({
|
|
129
|
+
repo: "https://github.com/acme/product",
|
|
130
|
+
agent: "opencode",
|
|
131
|
+
setupCommands: ["npm install", "npm run generate"],
|
|
132
|
+
opencode: {
|
|
133
|
+
skills: [
|
|
134
|
+
{
|
|
135
|
+
name: "release-demo",
|
|
136
|
+
content: `---
|
|
137
|
+
name: release-demo
|
|
138
|
+
description: Record and publish a product release demo.
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
Follow the repository's release-demo workflow.`,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
plugins: ["@acme/opencode-browser@1.2.3"],
|
|
145
|
+
},
|
|
146
|
+
provider: {
|
|
147
|
+
type: "exedev",
|
|
148
|
+
machine: { type: "profile", key: "content-rendering" },
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Setup commands run in order from the checked-out repository after the agent server is
|
|
154
|
+
ready. They do not delay workspace creation or stop the agent if they fail. Provider and
|
|
155
|
+
agent defaults configured by an administrator run first. Use
|
|
156
|
+
`client.workspaces.setupStatus(workspaceId)` or `waitForSetup(workspaceId)` to inspect them.
|
|
157
|
+
GitTerm persists the reported state and bounded log; a recovery copy also lives in the
|
|
158
|
+
repository's git-excluded `.gitterm/setup/` directory.
|
|
159
|
+
|
|
160
|
+
`provider` is a discriminated union, so TypeScript only offers `region` for providers
|
|
161
|
+
where GitTerm supports caller-selected placement. Machine keys are configured by admins
|
|
162
|
+
and returned by `client.catalog.workspaceOptions()`; raw CPU, memory, credentials, and
|
|
163
|
+
provider account configuration are never supplied by SDK callers.
|
|
164
|
+
|
|
165
|
+
This makes release automation a normal workspace task: create an OpenCode workspace,
|
|
166
|
+
run UI review or browser capture tools in the sandbox, upload the resulting media, update
|
|
167
|
+
the changelog in the checked-out repository, then terminate the workspace. Use an
|
|
168
|
+
`idempotencyKey` based on the release SHA when the workflow may be retried.
|
|
169
|
+
|
|
170
|
+
### Agent runs
|
|
171
|
+
|
|
172
|
+
Runs use durable GitTerm IDs backed by the workspace's native OpenCode session. Reusing an
|
|
173
|
+
idempotency key with the same input returns the original run, and terminal results remain
|
|
174
|
+
available after the workspace is paused. Completion means the native session became idle;
|
|
175
|
+
it does not claim that a pull request, upload, or other product outcome succeeded.
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
const { workspace } = await client.workspaces.create({
|
|
179
|
+
repo: "https://github.com/acme/product",
|
|
180
|
+
setupCommands: ["npm install", "npm run db:seed"],
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const run = await client.runs.create({
|
|
184
|
+
workspaceId: workspace.id,
|
|
185
|
+
idempotencyKey: "onboarding-v2",
|
|
186
|
+
waitForSetup: true,
|
|
187
|
+
prompt: "Record the new onboarding flow and open a pull request adding it to the changelog.",
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const completed = await client.runs.wait(workspace.id, run.id);
|
|
191
|
+
const messages = await client.runs.messages(workspace.id, run.id);
|
|
56
192
|
```
|
|
57
193
|
|
|
194
|
+
Runs are isolated by default and can execute in parallel. To preserve conversational context,
|
|
195
|
+
continue a terminal run; continued runs sharing context must remain sequential:
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
const next = await client.runs.create({
|
|
199
|
+
workspaceId: workspace.id,
|
|
200
|
+
idempotencyKey: "onboarding-tests-v1",
|
|
201
|
+
prompt: "Now add tests for that change.",
|
|
202
|
+
context: { type: "continue", runId: completed.id },
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Use `client.runs.cancel(workspaceId, runId)` to abort the current run. GitTerm keeps the
|
|
207
|
+
underlying OpenCode session private. For native session control, use
|
|
208
|
+
`workspaces.getRuntimeAccess()` and connect with the official OpenCode SDK.
|
|
209
|
+
|
|
58
210
|
### Errors
|
|
59
211
|
|
|
60
212
|
Every method throws `GittermError` with a stable `code`:
|
|
@@ -71,24 +223,35 @@ try {
|
|
|
71
223
|
}
|
|
72
224
|
```
|
|
73
225
|
|
|
74
|
-
|
|
75
|
-
`
|
|
226
|
+
Workspace lifecycle failures are also exposed as `WorkspaceLifecycleError`, with stable
|
|
227
|
+
`WORKSPACE_TERMINATED`, `WORKSPACE_NON_RECOVERABLE`, `WORKSPACE_START_TIMEOUT`, and
|
|
228
|
+
`WORKSPACE_RESTART_FAILED` codes. General codes are
|
|
229
|
+
`NOT_LOGGED_IN`, `UNAUTHORIZED`, `NOT_FOUND`, `FORBIDDEN`, `BAD_REQUEST`, `CONFLICT`,
|
|
230
|
+
`SERVER_ERROR`, and `NETWORK`.
|
|
231
|
+
|
|
232
|
+
The package ships self-contained declarations from `dist`; TypeScript consumers do not
|
|
233
|
+
need GitTerm's API package or tRPC server types.
|
|
76
234
|
|
|
77
235
|
### Obtaining a token programmatically
|
|
78
236
|
|
|
79
|
-
The device-code flow used by `gitterm login` is exposed for integrations
|
|
237
|
+
The device-code flow used by `gitterm login` is exposed for integrations. Pass the
|
|
238
|
+
server URL of the instance you want to log into:
|
|
80
239
|
|
|
81
240
|
```ts
|
|
82
241
|
import { loginWithDeviceCode, saveConfig, DEFAULT_GITTERM_SERVER_URL } from "@gitterm/sdk";
|
|
83
242
|
|
|
84
|
-
|
|
243
|
+
// Hosted: DEFAULT_GITTERM_SERVER_URL ("https://api.gitterm.dev")
|
|
244
|
+
// Self-hosted: "https://gitterm.example.com" or "http://localhost:3000"
|
|
245
|
+
const serverUrl = process.env.GITTERM_SERVER_URL ?? DEFAULT_GITTERM_SERVER_URL;
|
|
246
|
+
|
|
247
|
+
const { token } = await loginWithDeviceCode(serverUrl, {
|
|
85
248
|
onCode: ({ verificationUri, userCode }) => {
|
|
86
249
|
console.log(`Visit ${verificationUri} and enter ${userCode}`);
|
|
87
250
|
},
|
|
88
251
|
});
|
|
89
252
|
|
|
90
253
|
await saveConfig({
|
|
91
|
-
serverUrl
|
|
254
|
+
serverUrl,
|
|
92
255
|
token,
|
|
93
256
|
createdAt: Date.now(),
|
|
94
257
|
});
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { AgentType, AgentRun, AgentRunCreateInput, AgentRunMessage, AuthStatus, CloudProvider, Workspace, WorkspaceCreateInput, WorkspaceCreateResult, WorkspaceEnsureRunningResult, WorkspaceListOptions, WorkspaceListResult, WorkspaceRestartResult, WorkspaceRuntimeAccess, WorkspacePauseResult, WorkspaceTerminateResult, WorkspaceCatalog, WorkspaceSetupStatus } from "./types.js";
|
|
2
|
+
export type GittermClientOptions = {
|
|
3
|
+
serverUrl?: string;
|
|
4
|
+
token?: string;
|
|
5
|
+
configPath?: string;
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
};
|
|
8
|
+
export type GittermClient = {
|
|
9
|
+
serverUrl: string;
|
|
10
|
+
auth: {
|
|
11
|
+
status(): Promise<AuthStatus>;
|
|
12
|
+
};
|
|
13
|
+
workspaces: {
|
|
14
|
+
list(input?: WorkspaceListOptions): Promise<WorkspaceListResult>;
|
|
15
|
+
get(workspaceId: string): Promise<Workspace>;
|
|
16
|
+
getRuntimeAccess(workspaceId: string): Promise<WorkspaceRuntimeAccess>;
|
|
17
|
+
ensureRunning(workspaceId: string, options?: {
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
pollIntervalMs?: number;
|
|
20
|
+
}): Promise<WorkspaceEnsureRunningResult>;
|
|
21
|
+
pause(workspaceId: string): Promise<WorkspacePauseResult>;
|
|
22
|
+
restart(workspaceId: string): Promise<WorkspaceRestartResult>;
|
|
23
|
+
terminate(workspaceId: string): Promise<WorkspaceTerminateResult>;
|
|
24
|
+
create(input: WorkspaceCreateInput): Promise<WorkspaceCreateResult>;
|
|
25
|
+
setupStatus(workspaceId: string): Promise<WorkspaceSetupStatus>;
|
|
26
|
+
waitForSetup(workspaceId: string, options?: {
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
pollIntervalMs?: number;
|
|
29
|
+
}): Promise<WorkspaceSetupStatus>;
|
|
30
|
+
};
|
|
31
|
+
runs: {
|
|
32
|
+
create(input: AgentRunCreateInput): Promise<AgentRun>;
|
|
33
|
+
get(workspaceId: string, runId: string): Promise<AgentRun>;
|
|
34
|
+
messages(workspaceId: string, runId: string): Promise<AgentRunMessage[]>;
|
|
35
|
+
cancel(workspaceId: string, runId: string): Promise<{
|
|
36
|
+
cancelled: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
wait(workspaceId: string, runId: string, options?: {
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
pollIntervalMs?: number;
|
|
41
|
+
}): Promise<AgentRun>;
|
|
42
|
+
};
|
|
43
|
+
catalog: {
|
|
44
|
+
agentTypes(input?: {
|
|
45
|
+
serverOnly?: boolean;
|
|
46
|
+
}): Promise<AgentType[]>;
|
|
47
|
+
cloudProviders(input?: {
|
|
48
|
+
localOnly?: boolean;
|
|
49
|
+
cloudOnly?: boolean;
|
|
50
|
+
sandboxOnly?: boolean;
|
|
51
|
+
nonSandboxOnly?: boolean;
|
|
52
|
+
}): Promise<CloudProvider[]>;
|
|
53
|
+
workspaceOptions(): Promise<WorkspaceCatalog>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export declare function createGittermClient(options?: GittermClientOptions): GittermClient;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const DEFAULT_GITTERM_SERVER_URL = "https://api.gitterm.dev";
|
|
2
|
+
export type CliConfig = {
|
|
3
|
+
serverUrl: string;
|
|
4
|
+
token: string;
|
|
5
|
+
createdAt: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function getConfigPath(configPath?: string): string;
|
|
8
|
+
export declare function loadConfig(configPath?: string): Promise<CliConfig | null>;
|
|
9
|
+
export declare function loadConfigSync(configPath?: string): CliConfig | null;
|
|
10
|
+
export declare function saveConfig(config: CliConfig, configPath?: string): Promise<void>;
|
|
11
|
+
export declare function deleteConfig(configPath?: string): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type DeviceCodeInfo = {
|
|
2
|
+
deviceCode: string;
|
|
3
|
+
userCode: string;
|
|
4
|
+
verificationUri: string;
|
|
5
|
+
intervalSeconds: number;
|
|
6
|
+
expiresInSeconds: number;
|
|
7
|
+
};
|
|
8
|
+
export type LoginWithDeviceCodeOptions = {
|
|
9
|
+
clientName?: string;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
onCode?: (code: Omit<DeviceCodeInfo, "deviceCode">) => void | Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export declare function loginWithDeviceCode(serverUrl: string, options?: LoginWithDeviceCodeOptions): Promise<{
|
|
14
|
+
token: string;
|
|
15
|
+
}>;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type GittermErrorCode = "NOT_LOGGED_IN" | "UNAUTHORIZED" | "NOT_FOUND" | "FORBIDDEN" | "BAD_REQUEST" | "CONFLICT" | "SERVER_ERROR" | "NETWORK" | WorkspaceLifecycleErrorCode;
|
|
2
|
+
export type WorkspaceLifecycleErrorCode = "WORKSPACE_TERMINATED" | "WORKSPACE_NON_RECOVERABLE" | "WORKSPACE_START_TIMEOUT" | "WORKSPACE_RESTART_FAILED";
|
|
3
|
+
export declare class GittermError extends Error {
|
|
4
|
+
readonly code: GittermErrorCode;
|
|
5
|
+
readonly cause?: unknown;
|
|
6
|
+
constructor(code: GittermErrorCode, message: string, options?: {
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export declare class WorkspaceLifecycleError extends GittermError {
|
|
11
|
+
readonly code: WorkspaceLifecycleErrorCode;
|
|
12
|
+
constructor(code: WorkspaceLifecycleErrorCode, message: string, options?: {
|
|
13
|
+
cause?: unknown;
|
|
14
|
+
});
|
|
15
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,213 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export const DEFAULT_GITTERM_SERVER_URL: string;
|
|
13
|
-
|
|
14
|
-
export type CliConfig = {
|
|
15
|
-
serverUrl: string;
|
|
16
|
-
token: string;
|
|
17
|
-
createdAt: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type GittermErrorCode =
|
|
21
|
-
| "NOT_LOGGED_IN"
|
|
22
|
-
| "UNAUTHORIZED"
|
|
23
|
-
| "NOT_FOUND"
|
|
24
|
-
| "FORBIDDEN"
|
|
25
|
-
| "BAD_REQUEST"
|
|
26
|
-
| "SERVER_ERROR"
|
|
27
|
-
| "NETWORK";
|
|
28
|
-
|
|
29
|
-
export class GittermError extends Error {
|
|
30
|
-
readonly code: GittermErrorCode;
|
|
31
|
-
readonly cause?: unknown;
|
|
32
|
-
constructor(code: GittermErrorCode, message: string, options?: { cause?: unknown });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type GittermClientOptions = {
|
|
36
|
-
serverUrl?: string;
|
|
37
|
-
token?: string;
|
|
38
|
-
configPath?: string;
|
|
39
|
-
fetch?: typeof fetch;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type AuthStatus = {
|
|
43
|
-
loggedIn: true;
|
|
44
|
-
userId: string;
|
|
45
|
-
email: string;
|
|
46
|
-
name: string;
|
|
47
|
-
plan: string;
|
|
48
|
-
authMethod: "session" | "apiToken";
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export type WorkspaceStatus = "pending" | "running" | "paused" | "terminated";
|
|
52
|
-
export type WorkspaceHostingType = "cloud" | "local";
|
|
53
|
-
|
|
54
|
-
export type Workspace = {
|
|
55
|
-
id: string;
|
|
56
|
-
name: string | null;
|
|
57
|
-
status: WorkspaceStatus;
|
|
58
|
-
repositoryUrl: string | null;
|
|
59
|
-
repositoryBranch: string | null;
|
|
60
|
-
baseCommit: string | null;
|
|
61
|
-
checkoutRef: string | null;
|
|
62
|
-
domain: string;
|
|
63
|
-
subdomain: string | null;
|
|
64
|
-
persistent: boolean;
|
|
65
|
-
hostingType: WorkspaceHostingType;
|
|
66
|
-
serverOnly: boolean;
|
|
67
|
-
workspaceProfile: string;
|
|
68
|
-
cloudProviderId: string;
|
|
69
|
-
agentType: { id: string; name: string; description: string | null } | null;
|
|
70
|
-
image: { id: string; name: string; imageId: string } | null;
|
|
71
|
-
startedAt: string | null;
|
|
72
|
-
stoppedAt: string | null;
|
|
73
|
-
terminatedAt: string | null;
|
|
74
|
-
lastActiveAt: string | null;
|
|
75
|
-
updatedAt: string | null;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export type WorkspaceRuntimeAccess = {
|
|
79
|
-
workspaceId: string;
|
|
80
|
-
status: WorkspaceStatus;
|
|
81
|
-
url: string | null;
|
|
82
|
-
headers?: Record<string, string>;
|
|
83
|
-
password?: string;
|
|
84
|
-
directory: string;
|
|
85
|
-
repo: string | null;
|
|
86
|
-
branch: string | null;
|
|
87
|
-
baseCommit: string | null;
|
|
88
|
-
checkoutRef: string | null;
|
|
89
|
-
persistent: boolean;
|
|
90
|
-
recoverable: boolean;
|
|
91
|
-
providerKey: string | null;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export type WorkspaceCreateResult = {
|
|
95
|
-
workspace: Workspace;
|
|
96
|
-
runtime: WorkspaceRuntimeAccess;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export type WorkspaceListOptions = {
|
|
100
|
-
limit?: number;
|
|
101
|
-
offset?: number;
|
|
102
|
-
status?: "all" | "active" | "terminated";
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export type WorkspaceListResult = {
|
|
106
|
-
workspaces: Workspace[];
|
|
107
|
-
pagination: {
|
|
108
|
-
total: number;
|
|
109
|
-
limit: number;
|
|
110
|
-
offset: number;
|
|
111
|
-
hasMore: boolean;
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export type WorkspaceCreateInput = {
|
|
116
|
-
name?: string;
|
|
117
|
-
repo?: string;
|
|
118
|
-
branch?: string;
|
|
119
|
-
baseCommit?: string;
|
|
120
|
-
checkoutRef?: string;
|
|
121
|
-
subdomain?: string;
|
|
122
|
-
agentTypeId: string;
|
|
123
|
-
cloudProviderId: string;
|
|
124
|
-
regionId?: string;
|
|
125
|
-
gitIntegrationId?: string;
|
|
126
|
-
persistent: boolean;
|
|
127
|
-
workspaceProfile?: "standard" | "ssh-enabled";
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export type WorkspaceStopResult = { durationMinutes: number };
|
|
131
|
-
export type WorkspacePauseResult = WorkspaceStopResult;
|
|
132
|
-
export type WorkspaceRestartResult = { status: WorkspaceStatus };
|
|
133
|
-
export type WorkspaceTerminateResult = {
|
|
134
|
-
workspace: Workspace | null;
|
|
135
|
-
cleanupInBackground: boolean;
|
|
136
|
-
};
|
|
137
|
-
export type WorkspaceEnsureRunningResult = {
|
|
138
|
-
workspace: Workspace;
|
|
139
|
-
runtime: WorkspaceRuntimeAccess;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export type AgentType = {
|
|
143
|
-
id: string;
|
|
144
|
-
name: string;
|
|
145
|
-
description: string | null;
|
|
146
|
-
serverOnly: boolean;
|
|
147
|
-
isEnabled: boolean;
|
|
148
|
-
createdAt: Date | string;
|
|
149
|
-
updatedAt: Date | string;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export type CloudProvider = Record<string, unknown> & {
|
|
153
|
-
id: string;
|
|
154
|
-
name: string;
|
|
155
|
-
providerKey: string;
|
|
156
|
-
regions?: Array<Record<string, unknown>>;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export type GittermClient = {
|
|
160
|
-
serverUrl: string;
|
|
161
|
-
auth: {
|
|
162
|
-
status(): Promise<AuthStatus>;
|
|
163
|
-
};
|
|
164
|
-
workspaces: {
|
|
165
|
-
list(input?: WorkspaceListOptions): Promise<WorkspaceListResult>;
|
|
166
|
-
get(workspaceId: string): Promise<Workspace>;
|
|
167
|
-
getRuntimeAccess(workspaceId: string): Promise<WorkspaceRuntimeAccess>;
|
|
168
|
-
ensureRunning(
|
|
169
|
-
workspaceId: string,
|
|
170
|
-
options?: { timeoutMs?: number; pollIntervalMs?: number },
|
|
171
|
-
): Promise<WorkspaceEnsureRunningResult>;
|
|
172
|
-
pause(workspaceId: string): Promise<WorkspacePauseResult>;
|
|
173
|
-
restart(workspaceId: string): Promise<WorkspaceRestartResult>;
|
|
174
|
-
terminate(workspaceId: string): Promise<WorkspaceTerminateResult>;
|
|
175
|
-
create(input: WorkspaceCreateInput): Promise<WorkspaceCreateResult>;
|
|
176
|
-
createSandbox(input: WorkspaceCreateInput): Promise<WorkspaceCreateResult>;
|
|
177
|
-
};
|
|
178
|
-
catalog: {
|
|
179
|
-
agentTypes(input?: { serverOnly?: boolean }): Promise<AgentType[]>;
|
|
180
|
-
cloudProviders(input?: {
|
|
181
|
-
localOnly?: boolean;
|
|
182
|
-
cloudOnly?: boolean;
|
|
183
|
-
sandboxOnly?: boolean;
|
|
184
|
-
nonSandboxOnly?: boolean;
|
|
185
|
-
}): Promise<CloudProvider[]>;
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export function createGittermClient(options?: GittermClientOptions): GittermClient;
|
|
190
|
-
export function getConfigPath(configPath?: string): string;
|
|
191
|
-
export function loadConfig(configPath?: string): Promise<CliConfig | null>;
|
|
192
|
-
export function loadConfigSync(configPath?: string): CliConfig | null;
|
|
193
|
-
export function saveConfig(config: CliConfig, configPath?: string): Promise<void>;
|
|
194
|
-
export function deleteConfig(configPath?: string): Promise<void>;
|
|
195
|
-
|
|
196
|
-
export type DeviceCodeInfo = {
|
|
197
|
-
deviceCode: string;
|
|
198
|
-
userCode: string;
|
|
199
|
-
verificationUri: string;
|
|
200
|
-
intervalSeconds: number;
|
|
201
|
-
expiresInSeconds: number;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export type LoginWithDeviceCodeOptions = {
|
|
205
|
-
clientName?: string;
|
|
206
|
-
fetch?: typeof fetch;
|
|
207
|
-
onCode?: (code: Omit<DeviceCodeInfo, "deviceCode">) => void | Promise<void>;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
export function loginWithDeviceCode(
|
|
211
|
-
serverUrl: string,
|
|
212
|
-
options?: LoginWithDeviceCodeOptions,
|
|
213
|
-
): Promise<{ token: string }>;
|
|
1
|
+
export { createGittermClient, type GittermClient, type GittermClientOptions } from "./client.js";
|
|
2
|
+
export { DEFAULT_GITTERM_SERVER_URL, getConfigPath, loadConfig, loadConfigSync, saveConfig, deleteConfig, } from "./config.js";
|
|
3
|
+
export type { CliConfig } from "./config.js";
|
|
4
|
+
export { loginWithDeviceCode } from "./device-login.js";
|
|
5
|
+
export type { DeviceCodeInfo, LoginWithDeviceCodeOptions } from "./device-login.js";
|
|
6
|
+
export { GittermError, WorkspaceLifecycleError } from "./errors.js";
|
|
7
|
+
export { createGittermWorkspaceClient, getWorkspaceEnvironment, type GittermWorkspaceClient, type WorkspaceClientOptions, type WorkspaceEnvironment, type WorkspacePort, type WorkspaceSelf, } from "./workspace-client.js";
|
|
8
|
+
export type { GittermErrorCode, WorkspaceLifecycleErrorCode } from "./errors.js";
|
|
9
|
+
export type { AgentRun, AgentRunCreateInput, AgentRunMessage, AgentRunStatus, AgentType, AgentKey, AuthStatus, BuiltInAgentKey, CloudProvider, ProviderKey, Workspace, WorkspaceCreateInput, WorkspaceCreateResult, WorkspaceCatalog, WorkspaceEnsureRunningResult, WorkspaceHostingType, WorkspaceListOptions, WorkspaceListResult, WorkspaceRestartResult, WorkspaceRuntimeAccess, WorkspaceStatus, WorkspaceSetupStatus, WorkspacePauseResult, WorkspaceTerminateResult, WorkspaceProviderSelection, } from "./types.js";
|