computer-agents 1.0.2 → 1.0.3

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.
Files changed (47) hide show
  1. package/README.md +399 -170
  2. package/dist/index.d.ts +5 -28
  3. package/dist/index.js +194 -51
  4. package/dist/index.js.map +1 -1
  5. package/dist/metadata.d.ts +8 -0
  6. package/dist/metadata.js +13 -0
  7. package/dist/metadata.js.map +1 -0
  8. package/package.json +25 -23
  9. package/dist/ComputerAgentsClient.d.ts +0 -357
  10. package/dist/ComputerAgentsClient.js +0 -359
  11. package/dist/ComputerAgentsClient.js.map +0 -1
  12. package/dist/cloud/ApiClient.d.ts +0 -62
  13. package/dist/cloud/ApiClient.js +0 -150
  14. package/dist/cloud/ApiClient.js.map +0 -1
  15. package/dist/cloud/resources/AgentsResource.d.ts +0 -39
  16. package/dist/cloud/resources/AgentsResource.js +0 -58
  17. package/dist/cloud/resources/AgentsResource.js.map +0 -1
  18. package/dist/cloud/resources/BudgetResource.d.ts +0 -167
  19. package/dist/cloud/resources/BudgetResource.js +0 -179
  20. package/dist/cloud/resources/BudgetResource.js.map +0 -1
  21. package/dist/cloud/resources/EnvironmentsResource.d.ts +0 -78
  22. package/dist/cloud/resources/EnvironmentsResource.js +0 -118
  23. package/dist/cloud/resources/EnvironmentsResource.js.map +0 -1
  24. package/dist/cloud/resources/FilesResource.d.ts +0 -173
  25. package/dist/cloud/resources/FilesResource.js +0 -180
  26. package/dist/cloud/resources/FilesResource.js.map +0 -1
  27. package/dist/cloud/resources/GitResource.d.ts +0 -28
  28. package/dist/cloud/resources/GitResource.js +0 -45
  29. package/dist/cloud/resources/GitResource.js.map +0 -1
  30. package/dist/cloud/resources/ProjectsResource.d.ts +0 -78
  31. package/dist/cloud/resources/ProjectsResource.js +0 -117
  32. package/dist/cloud/resources/ProjectsResource.js.map +0 -1
  33. package/dist/cloud/resources/RunsResource.d.ts +0 -61
  34. package/dist/cloud/resources/RunsResource.js +0 -84
  35. package/dist/cloud/resources/RunsResource.js.map +0 -1
  36. package/dist/cloud/resources/SchedulesResource.d.ts +0 -58
  37. package/dist/cloud/resources/SchedulesResource.js +0 -82
  38. package/dist/cloud/resources/SchedulesResource.js.map +0 -1
  39. package/dist/cloud/resources/ThreadsResource.d.ts +0 -124
  40. package/dist/cloud/resources/ThreadsResource.js +0 -178
  41. package/dist/cloud/resources/ThreadsResource.js.map +0 -1
  42. package/dist/cloud/resources/index.d.ts +0 -16
  43. package/dist/cloud/resources/index.js +0 -28
  44. package/dist/cloud/resources/index.js.map +0 -1
  45. package/dist/cloud/types.d.ts +0 -573
  46. package/dist/cloud/types.js +0 -9
  47. package/dist/cloud/types.js.map +0 -1
@@ -1,78 +0,0 @@
1
- /**
2
- * Environments Resource Manager
3
- *
4
- * Handles environment management including CRUD operations,
5
- * container lifecycle, and configuration management.
6
- *
7
- * Note: projectId is now embedded in the API key, so routes use
8
- * simplified paths without /projects/:projectId prefix.
9
- */
10
- import type { ApiClient } from '../ApiClient';
11
- import type { Environment, CreateEnvironmentParams, UpdateEnvironmentParams, ContainerStatus, BuildResult, StartContainerParams, StartContainerResult } from '../types';
12
- export declare class EnvironmentsResource {
13
- private readonly client;
14
- constructor(client: ApiClient);
15
- /**
16
- * Create a new environment
17
- *
18
- * Project is determined automatically from the API key.
19
- */
20
- create(params: CreateEnvironmentParams): Promise<Environment>;
21
- /**
22
- * List all environments
23
- *
24
- * Project is determined automatically from the API key.
25
- */
26
- list(): Promise<Environment[]>;
27
- /**
28
- * Get an environment by ID
29
- */
30
- get(environmentId: string): Promise<Environment>;
31
- /**
32
- * Update an environment
33
- */
34
- update(environmentId: string, params: UpdateEnvironmentParams): Promise<Environment>;
35
- /**
36
- * Delete an environment
37
- */
38
- delete(environmentId: string, hard?: boolean): Promise<void>;
39
- /**
40
- * Build the container image for an environment
41
- */
42
- build(environmentId: string, force?: boolean): Promise<BuildResult>;
43
- /**
44
- * Start the environment's container
45
- */
46
- start(environmentId: string, params?: StartContainerParams): Promise<StartContainerResult>;
47
- /**
48
- * Stop the environment's container(s)
49
- */
50
- stop(environmentId: string, options?: {
51
- containerId?: string;
52
- all?: boolean;
53
- }): Promise<{
54
- success: boolean;
55
- stopped: number;
56
- containers: string[];
57
- }>;
58
- /**
59
- * Get container status for an environment
60
- */
61
- getStatus(environmentId: string): Promise<ContainerStatus>;
62
- /**
63
- * Get the Dockerfile for an environment
64
- */
65
- getDockerfile(environmentId: string): Promise<string>;
66
- /**
67
- * Update the Dockerfile for an environment
68
- */
69
- updateDockerfile(environmentId: string, dockerfile: string): Promise<void>;
70
- /**
71
- * Get the Codex configuration for an environment
72
- */
73
- getConfig(environmentId: string): Promise<string>;
74
- /**
75
- * Update the Codex configuration for an environment
76
- */
77
- updateConfig(environmentId: string, config: string): Promise<void>;
78
- }
@@ -1,118 +0,0 @@
1
- "use strict";
2
- /**
3
- * Environments Resource Manager
4
- *
5
- * Handles environment management including CRUD operations,
6
- * container lifecycle, and configuration management.
7
- *
8
- * Note: projectId is now embedded in the API key, so routes use
9
- * simplified paths without /projects/:projectId prefix.
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.EnvironmentsResource = void 0;
13
- class EnvironmentsResource {
14
- client;
15
- constructor(client) {
16
- this.client = client;
17
- }
18
- /**
19
- * Create a new environment
20
- *
21
- * Project is determined automatically from the API key.
22
- */
23
- async create(params) {
24
- const response = await this.client.post(`/environments`, params);
25
- return response.environment;
26
- }
27
- /**
28
- * List all environments
29
- *
30
- * Project is determined automatically from the API key.
31
- */
32
- async list() {
33
- const response = await this.client.get(`/environments`);
34
- return response.data;
35
- }
36
- /**
37
- * Get an environment by ID
38
- */
39
- async get(environmentId) {
40
- const response = await this.client.get(`/environments/${environmentId}`);
41
- return response.environment;
42
- }
43
- /**
44
- * Update an environment
45
- */
46
- async update(environmentId, params) {
47
- const response = await this.client.put(`/environments/${environmentId}`, params);
48
- return response.environment;
49
- }
50
- /**
51
- * Delete an environment
52
- */
53
- async delete(environmentId, hard = false) {
54
- await this.client.delete(`/environments/${environmentId}${hard ? '?hard=true' : ''}`);
55
- }
56
- // =========================================================================
57
- // Container Lifecycle
58
- // =========================================================================
59
- /**
60
- * Build the container image for an environment
61
- */
62
- async build(environmentId, force = false) {
63
- const response = await this.client.post(`/environments/${environmentId}/build`, { force });
64
- return response;
65
- }
66
- /**
67
- * Start the environment's container
68
- */
69
- async start(environmentId, params = {}) {
70
- const response = await this.client.post(`/environments/${environmentId}/start`, params);
71
- return response;
72
- }
73
- /**
74
- * Stop the environment's container(s)
75
- */
76
- async stop(environmentId, options) {
77
- const response = await this.client.post(`/environments/${environmentId}/stop`, options);
78
- return response;
79
- }
80
- /**
81
- * Get container status for an environment
82
- */
83
- async getStatus(environmentId) {
84
- const response = await this.client.get(`/environments/${environmentId}/status`);
85
- return response;
86
- }
87
- // =========================================================================
88
- // Configuration Management
89
- // =========================================================================
90
- /**
91
- * Get the Dockerfile for an environment
92
- */
93
- async getDockerfile(environmentId) {
94
- const response = await this.client.get(`/environments/${environmentId}/dockerfile`);
95
- return response.dockerfile;
96
- }
97
- /**
98
- * Update the Dockerfile for an environment
99
- */
100
- async updateDockerfile(environmentId, dockerfile) {
101
- await this.client.put(`/environments/${environmentId}/dockerfile`, { dockerfile });
102
- }
103
- /**
104
- * Get the Codex configuration for an environment
105
- */
106
- async getConfig(environmentId) {
107
- const response = await this.client.get(`/environments/${environmentId}/config`);
108
- return response.config;
109
- }
110
- /**
111
- * Update the Codex configuration for an environment
112
- */
113
- async updateConfig(environmentId, config) {
114
- await this.client.put(`/environments/${environmentId}/config`, { config });
115
- }
116
- }
117
- exports.EnvironmentsResource = EnvironmentsResource;
118
- //# sourceMappingURL=EnvironmentsResource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnvironmentsResource.js","sourceRoot":"","sources":["../../../src/cloud/resources/EnvironmentsResource.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAaH,MAAa,oBAAoB;IACF;IAA7B,YA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AAM,CAAC,GAAG,CACpC,iBAAiB,aAAa,SAAS,CACxC,CAAC;QACF,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAChB,aAAqB,EACrB,MAAc;QAEd,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACnB,iBAAiB,aAAa,SAAS,EACvC,EAAE,MAAM,EAAE,CACX,CAAC;IACJ,CAAC;CACF;AA1KD,oDA0KC"}
@@ -1,173 +0,0 @@
1
- /**
2
- * Files Resource Manager
3
- *
4
- * Handles file operations within environment workspaces.
5
- * Files are scoped to environments - each environment has its own isolated workspace.
6
- *
7
- * API Endpoints (matching server.ts):
8
- * - GET /environments/:environmentId/files - List files
9
- * - POST /environments/:environmentId/files/upload - Upload file (multipart)
10
- * - GET /environments/:environmentId/files/download/* - Download file
11
- * - DELETE /environments/:environmentId/files/* - Delete file
12
- * - POST /environments/:environmentId/files/move - Move/rename file
13
- */
14
- import type { ApiClient } from '../ApiClient';
15
- /**
16
- * File entry returned by the API
17
- */
18
- export interface EnvironmentFile {
19
- /** Full path relative to workspace root */
20
- path: string;
21
- /** Type of entry */
22
- type: 'file' | 'directory';
23
- /** File size in bytes (0 for directories) */
24
- size: number;
25
- /** Last modification time (ISO 8601 string) */
26
- lastModified: string;
27
- }
28
- /**
29
- * Result from listing files
30
- */
31
- export interface ListFilesResult {
32
- environmentId: string;
33
- files: EnvironmentFile[];
34
- }
35
- /**
36
- * Parameters for uploading a file
37
- */
38
- export interface UploadFileParams {
39
- environmentId: string;
40
- /** Relative path within the environment (e.g., 'src/app.py') */
41
- path?: string;
42
- /** File content as string or Buffer */
43
- content: string | Buffer;
44
- /** Original filename */
45
- filename: string;
46
- /** Content type (optional) */
47
- contentType?: string;
48
- }
49
- /**
50
- * Result from uploading a file
51
- */
52
- export interface UploadFileResult {
53
- success: boolean;
54
- environmentId: string;
55
- filename: string;
56
- path: string;
57
- size: number;
58
- }
59
- /**
60
- * Parameters for moving a file
61
- */
62
- export interface MoveFileParams {
63
- environmentId: string;
64
- sourcePath: string;
65
- destPath: string;
66
- }
67
- /**
68
- * Result from moving a file
69
- */
70
- export interface MoveFileResult {
71
- success: boolean;
72
- environmentId: string;
73
- sourcePath: string;
74
- destPath: string;
75
- }
76
- /**
77
- * Result from deleting a file
78
- */
79
- export interface DeleteFileResult {
80
- success: boolean;
81
- environmentId: string;
82
- filePath: string;
83
- }
84
- export declare class FilesResource {
85
- private readonly client;
86
- constructor(client: ApiClient);
87
- /**
88
- * List all files in an environment workspace
89
- *
90
- * @param environmentId - The environment ID
91
- * @returns List of files with metadata
92
- *
93
- * @example
94
- * ```typescript
95
- * const result = await client.files.list('env_xxx');
96
- * console.log(result.files);
97
- * ```
98
- */
99
- list(environmentId: string): Promise<ListFilesResult>;
100
- /**
101
- * Alias for list() - for backward compatibility
102
- */
103
- listFiles(environmentId: string): Promise<EnvironmentFile[]>;
104
- /**
105
- * Download a file from an environment workspace
106
- *
107
- * @param environmentId - The environment ID
108
- * @param filePath - Path to the file (e.g., 'src/app.py')
109
- * @returns File content as string
110
- *
111
- * @example
112
- * ```typescript
113
- * const content = await client.files.getFile('env_xxx', 'src/app.py');
114
- * console.log(content);
115
- * ```
116
- */
117
- getFile(environmentId: string, filePath: string): Promise<string>;
118
- /**
119
- * Download a file as a Buffer
120
- *
121
- * @param environmentId - The environment ID
122
- * @param filePath - Path to the file
123
- * @returns File content as Buffer
124
- */
125
- downloadFile(environmentId: string, filePath: string): Promise<Buffer>;
126
- /**
127
- * Upload a file to an environment workspace
128
- *
129
- * Uses multipart form data to match the server.ts upload handler.
130
- *
131
- * @param params - Upload parameters
132
- * @returns Upload result with file path
133
- *
134
- * @example
135
- * ```typescript
136
- * const result = await client.files.uploadFile({
137
- * environmentId: 'env_xxx',
138
- * filename: 'app.py',
139
- * path: 'src', // Optional: subdirectory
140
- * content: 'print("Hello, world!")'
141
- * });
142
- * ```
143
- */
144
- uploadFile(params: UploadFileParams): Promise<UploadFileResult>;
145
- /**
146
- * Delete a file from an environment workspace
147
- *
148
- * @param environmentId - The environment ID
149
- * @param filePath - Path to the file to delete
150
- *
151
- * @example
152
- * ```typescript
153
- * await client.files.deleteFile('env_xxx', 'src/old-file.py');
154
- * ```
155
- */
156
- deleteFile(environmentId: string, filePath: string): Promise<DeleteFileResult>;
157
- /**
158
- * Move or rename a file within an environment workspace
159
- *
160
- * @param params - Move parameters (environmentId, sourcePath, destPath)
161
- * @returns Move result
162
- *
163
- * @example
164
- * ```typescript
165
- * await client.files.moveFile({
166
- * environmentId: 'env_xxx',
167
- * sourcePath: 'old-name.py',
168
- * destPath: 'new-name.py'
169
- * });
170
- * ```
171
- */
172
- moveFile(params: MoveFileParams): Promise<MoveFileResult>;
173
- }
@@ -1,180 +0,0 @@
1
- "use strict";
2
- /**
3
- * Files Resource Manager
4
- *
5
- * Handles file operations within environment workspaces.
6
- * Files are scoped to environments - each environment has its own isolated workspace.
7
- *
8
- * API Endpoints (matching server.ts):
9
- * - GET /environments/:environmentId/files - List files
10
- * - POST /environments/:environmentId/files/upload - Upload file (multipart)
11
- * - GET /environments/:environmentId/files/download/* - Download file
12
- * - DELETE /environments/:environmentId/files/* - Delete file
13
- * - POST /environments/:environmentId/files/move - Move/rename file
14
- */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.FilesResource = void 0;
17
- const ApiClient_1 = require("../ApiClient");
18
- class FilesResource {
19
- client;
20
- constructor(client) {
21
- this.client = client;
22
- }
23
- /**
24
- * List all files in an environment workspace
25
- *
26
- * @param environmentId - The environment ID
27
- * @returns List of files with metadata
28
- *
29
- * @example
30
- * ```typescript
31
- * const result = await client.files.list('env_xxx');
32
- * console.log(result.files);
33
- * ```
34
- */
35
- async list(environmentId) {
36
- const response = await this.client.get(`/environments/${environmentId}/files`);
37
- return {
38
- environmentId,
39
- files: response.data,
40
- };
41
- }
42
- /**
43
- * Alias for list() - for backward compatibility
44
- */
45
- async listFiles(environmentId) {
46
- const response = await this.client.get(`/environments/${environmentId}/files`);
47
- return response.data;
48
- }
49
- /**
50
- * Download a file from an environment workspace
51
- *
52
- * @param environmentId - The environment ID
53
- * @param filePath - Path to the file (e.g., 'src/app.py')
54
- * @returns File content as string
55
- *
56
- * @example
57
- * ```typescript
58
- * const content = await client.files.getFile('env_xxx', 'src/app.py');
59
- * console.log(content);
60
- * ```
61
- */
62
- async getFile(environmentId, filePath) {
63
- // Remove leading slash if present
64
- const normalizedPath = filePath.replace(/^\/+/, '');
65
- const encodedPath = normalizedPath
66
- .split('/')
67
- .map(encodeURIComponent)
68
- .join('/');
69
- const response = await this.client.request('GET', `/environments/${environmentId}/files/${encodedPath}`, { stream: true });
70
- return response.text();
71
- }
72
- /**
73
- * Download a file as a Buffer
74
- *
75
- * @param environmentId - The environment ID
76
- * @param filePath - Path to the file
77
- * @returns File content as Buffer
78
- */
79
- async downloadFile(environmentId, filePath) {
80
- const normalizedPath = filePath.replace(/^\/+/, '');
81
- const encodedPath = normalizedPath
82
- .split('/')
83
- .map(encodeURIComponent)
84
- .join('/');
85
- const response = await this.client.request('GET', `/environments/${environmentId}/files/${encodedPath}`, { stream: true });
86
- const arrayBuffer = await response.arrayBuffer();
87
- return Buffer.from(arrayBuffer);
88
- }
89
- /**
90
- * Upload a file to an environment workspace
91
- *
92
- * Uses multipart form data to match the server.ts upload handler.
93
- *
94
- * @param params - Upload parameters
95
- * @returns Upload result with file path
96
- *
97
- * @example
98
- * ```typescript
99
- * const result = await client.files.uploadFile({
100
- * environmentId: 'env_xxx',
101
- * filename: 'app.py',
102
- * path: 'src', // Optional: subdirectory
103
- * content: 'print("Hello, world!")'
104
- * });
105
- * ```
106
- */
107
- async uploadFile(params) {
108
- const { environmentId, path: relativePath, content, filename, contentType } = params;
109
- if (!environmentId) {
110
- throw new Error('environmentId is required for file upload');
111
- }
112
- // Create FormData for multipart upload
113
- const formData = new FormData();
114
- // Convert content to Blob
115
- const contentBuffer = typeof content === 'string'
116
- ? new TextEncoder().encode(content)
117
- : content;
118
- const blob = new Blob([contentBuffer], {
119
- type: contentType || 'application/octet-stream'
120
- });
121
- formData.append('file', blob, filename);
122
- if (relativePath) {
123
- formData.append('path', relativePath);
124
- }
125
- // Make request with FormData (not JSON)
126
- const url = `${this.client.getBaseUrl()}/environments/${environmentId}/files/upload`;
127
- const response = await fetch(url, {
128
- method: 'POST',
129
- headers: {
130
- 'Authorization': `Bearer ${this.client.getApiKey()}`,
131
- },
132
- body: formData,
133
- });
134
- if (!response.ok) {
135
- const errorData = await response.json().catch(() => ({ error: response.statusText }));
136
- throw new ApiClient_1.ApiClientError(errorData.message || errorData.error || 'Upload failed', response.status, errorData.code);
137
- }
138
- return response.json();
139
- }
140
- /**
141
- * Delete a file from an environment workspace
142
- *
143
- * @param environmentId - The environment ID
144
- * @param filePath - Path to the file to delete
145
- *
146
- * @example
147
- * ```typescript
148
- * await client.files.deleteFile('env_xxx', 'src/old-file.py');
149
- * ```
150
- */
151
- async deleteFile(environmentId, filePath) {
152
- const normalizedPath = filePath.replace(/^\/+/, '');
153
- const encodedPath = normalizedPath
154
- .split('/')
155
- .map(encodeURIComponent)
156
- .join('/');
157
- return this.client.delete(`/environments/${environmentId}/files/${encodedPath}`);
158
- }
159
- /**
160
- * Move or rename a file within an environment workspace
161
- *
162
- * @param params - Move parameters (environmentId, sourcePath, destPath)
163
- * @returns Move result
164
- *
165
- * @example
166
- * ```typescript
167
- * await client.files.moveFile({
168
- * environmentId: 'env_xxx',
169
- * sourcePath: 'old-name.py',
170
- * destPath: 'new-name.py'
171
- * });
172
- * ```
173
- */
174
- async moveFile(params) {
175
- const { environmentId, sourcePath, destPath } = params;
176
- return this.client.post(`/environments/${environmentId}/files/move`, { sourcePath, destPath });
177
- }
178
- }
179
- exports.FilesResource = FilesResource;
180
- //# sourceMappingURL=FilesResource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilesResource.js","sourceRoot":"","sources":["../../../src/cloud/resources/FilesResource.ts"],"names":[],"mappings":";AAA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,MAAM,CAAC;QAEvD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,iBAAiB,aAAa,aAAa,EAC3C,EAAE,UAAU,EAAE,QAAQ,EAAE,CACzB,CAAC;IACJ,CAAC;CACF;AAvND,sCAuNC"}
@@ -1,28 +0,0 @@
1
- /**
2
- * Git Resource Manager
3
- *
4
- * Handles git operations on cloud workspaces including
5
- * diff, commit, and push.
6
- */
7
- import type { ApiClient } from '../ApiClient';
8
- import type { GitDiffResult, GitCommitParams, GitCommitResult, GitPushParams, GitPushResult } from '../types';
9
- export declare class GitResource {
10
- private readonly client;
11
- constructor(client: ApiClient);
12
- /**
13
- * Get uncommitted changes in a workspace
14
- */
15
- diff(workspaceId: string): Promise<GitDiffResult>;
16
- /**
17
- * Create a git commit
18
- */
19
- commit(workspaceId: string, params: GitCommitParams): Promise<GitCommitResult>;
20
- /**
21
- * Push commits to remote
22
- */
23
- push(workspaceId: string, params?: GitPushParams): Promise<GitPushResult>;
24
- /**
25
- * Get diff for a specific commit
26
- */
27
- getCommitDiff(workspaceId: string, commitSha: string): Promise<GitDiffResult>;
28
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- /**
3
- * Git Resource Manager
4
- *
5
- * Handles git operations on cloud workspaces including
6
- * diff, commit, and push.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.GitResource = void 0;
10
- class GitResource {
11
- client;
12
- constructor(client) {
13
- this.client = client;
14
- }
15
- /**
16
- * Get uncommitted changes in a workspace
17
- */
18
- async diff(workspaceId) {
19
- const response = await this.client.get(`/git/${workspaceId}/diff`);
20
- return response;
21
- }
22
- /**
23
- * Create a git commit
24
- */
25
- async commit(workspaceId, params) {
26
- const response = await this.client.post(`/git/${workspaceId}/commit`, params);
27
- return response;
28
- }
29
- /**
30
- * Push commits to remote
31
- */
32
- async push(workspaceId, params = {}) {
33
- const response = await this.client.post(`/git/${workspaceId}/push`, params);
34
- return response;
35
- }
36
- /**
37
- * Get diff for a specific commit
38
- */
39
- async getCommitDiff(workspaceId, commitSha) {
40
- const response = await this.client.get(`/git/${workspaceId}/commits/${commitSha}/diff`);
41
- return response;
42
- }
43
- }
44
- exports.GitResource = GitResource;
45
- //# sourceMappingURL=GitResource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GitResource.js","sourceRoot":"","sources":["../../../src/cloud/resources/GitResource.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAWH,MAAa,WAAW;IACO;IAA7B,YAA6B,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAElD;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,WAAmB;QAC5B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACpC,QAAQ,WAAW,OAAO,CAC3B,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,WAAmB,EACnB,MAAuB;QAEvB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,QAAQ,WAAW,SAAS,EAC5B,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CACR,WAAmB,EACnB,SAAwB,EAAE;QAE1B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,QAAQ,WAAW,OAAO,EAC1B,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB,EAAE,SAAiB;QACxD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACpC,QAAQ,WAAW,YAAY,SAAS,OAAO,CAChD,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlDD,kCAkDC"}