computer-agents 1.0.3 → 2.0.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.
Files changed (47) hide show
  1. package/README.md +253 -385
  2. package/dist/ComputerAgentsClient.d.ts +358 -0
  3. package/dist/ComputerAgentsClient.js +360 -0
  4. package/dist/ComputerAgentsClient.js.map +1 -0
  5. package/dist/cloud/ApiClient.d.ts +62 -0
  6. package/dist/cloud/ApiClient.js +150 -0
  7. package/dist/cloud/ApiClient.js.map +1 -0
  8. package/dist/cloud/resources/AgentsResource.d.ts +39 -0
  9. package/dist/cloud/resources/AgentsResource.js +58 -0
  10. package/dist/cloud/resources/AgentsResource.js.map +1 -0
  11. package/dist/cloud/resources/BudgetResource.d.ts +167 -0
  12. package/dist/cloud/resources/BudgetResource.js +179 -0
  13. package/dist/cloud/resources/BudgetResource.js.map +1 -0
  14. package/dist/cloud/resources/EnvironmentsResource.d.ts +167 -0
  15. package/dist/cloud/resources/EnvironmentsResource.js +256 -0
  16. package/dist/cloud/resources/EnvironmentsResource.js.map +1 -0
  17. package/dist/cloud/resources/FilesResource.d.ts +201 -0
  18. package/dist/cloud/resources/FilesResource.js +204 -0
  19. package/dist/cloud/resources/FilesResource.js.map +1 -0
  20. package/dist/cloud/resources/GitResource.d.ts +28 -0
  21. package/dist/cloud/resources/GitResource.js +45 -0
  22. package/dist/cloud/resources/GitResource.js.map +1 -0
  23. package/dist/cloud/resources/ProjectsResource.d.ts +78 -0
  24. package/dist/cloud/resources/ProjectsResource.js +117 -0
  25. package/dist/cloud/resources/ProjectsResource.js.map +1 -0
  26. package/dist/cloud/resources/RunsResource.d.ts +61 -0
  27. package/dist/cloud/resources/RunsResource.js +84 -0
  28. package/dist/cloud/resources/RunsResource.js.map +1 -0
  29. package/dist/cloud/resources/SchedulesResource.d.ts +58 -0
  30. package/dist/cloud/resources/SchedulesResource.js +82 -0
  31. package/dist/cloud/resources/SchedulesResource.js.map +1 -0
  32. package/dist/cloud/resources/ThreadsResource.d.ts +124 -0
  33. package/dist/cloud/resources/ThreadsResource.js +178 -0
  34. package/dist/cloud/resources/ThreadsResource.js.map +1 -0
  35. package/dist/cloud/resources/index.d.ts +17 -0
  36. package/dist/cloud/resources/index.js +28 -0
  37. package/dist/cloud/resources/index.js.map +1 -0
  38. package/dist/cloud/types.d.ts +676 -0
  39. package/dist/cloud/types.js +9 -0
  40. package/dist/cloud/types.js.map +1 -0
  41. package/dist/index.d.ts +28 -5
  42. package/dist/index.js +51 -194
  43. package/dist/index.js.map +1 -1
  44. package/package.json +25 -24
  45. package/dist/metadata.d.ts +0 -8
  46. package/dist/metadata.js +0 -13
  47. package/dist/metadata.js.map +0 -1
@@ -0,0 +1,204 @@
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
+ * - POST /environments/:environmentId/files/mkdir - Create directory
12
+ * - GET /environments/:environmentId/files/download/* - Download file
13
+ * - DELETE /environments/:environmentId/files/* - Delete file
14
+ * - POST /environments/:environmentId/files/move - Move/rename file
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.FilesResource = void 0;
18
+ const ApiClient_1 = require("../ApiClient");
19
+ class FilesResource {
20
+ client;
21
+ constructor(client) {
22
+ this.client = client;
23
+ }
24
+ /**
25
+ * List all files in an environment workspace
26
+ *
27
+ * @param environmentId - The environment ID
28
+ * @returns List of files with metadata
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const result = await client.files.list('env_xxx');
33
+ * console.log(result.files);
34
+ * ```
35
+ */
36
+ async list(environmentId) {
37
+ const response = await this.client.get(`/environments/${environmentId}/files`);
38
+ return {
39
+ environmentId,
40
+ files: response.data,
41
+ };
42
+ }
43
+ /**
44
+ * Alias for list() - for backward compatibility
45
+ */
46
+ async listFiles(environmentId) {
47
+ const response = await this.client.get(`/environments/${environmentId}/files`);
48
+ return response.data;
49
+ }
50
+ /**
51
+ * Download a file from an environment workspace
52
+ *
53
+ * @param environmentId - The environment ID
54
+ * @param filePath - Path to the file (e.g., 'src/app.py')
55
+ * @returns File content as string
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const content = await client.files.getFile('env_xxx', 'src/app.py');
60
+ * console.log(content);
61
+ * ```
62
+ */
63
+ async getFile(environmentId, filePath) {
64
+ // Remove leading slash if present
65
+ const normalizedPath = filePath.replace(/^\/+/, '');
66
+ const encodedPath = normalizedPath
67
+ .split('/')
68
+ .map(encodeURIComponent)
69
+ .join('/');
70
+ const response = await this.client.request('GET', `/environments/${environmentId}/files/${encodedPath}`, { stream: true });
71
+ return response.text();
72
+ }
73
+ /**
74
+ * Download a file as a Buffer
75
+ *
76
+ * @param environmentId - The environment ID
77
+ * @param filePath - Path to the file
78
+ * @returns File content as Buffer
79
+ */
80
+ async downloadFile(environmentId, filePath) {
81
+ const normalizedPath = filePath.replace(/^\/+/, '');
82
+ const encodedPath = normalizedPath
83
+ .split('/')
84
+ .map(encodeURIComponent)
85
+ .join('/');
86
+ const response = await this.client.request('GET', `/environments/${environmentId}/files/${encodedPath}`, { stream: true });
87
+ const arrayBuffer = await response.arrayBuffer();
88
+ return Buffer.from(arrayBuffer);
89
+ }
90
+ /**
91
+ * Upload a file to an environment workspace
92
+ *
93
+ * Uses multipart form data to match the server.ts upload handler.
94
+ *
95
+ * @param params - Upload parameters
96
+ * @returns Upload result with file path
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const result = await client.files.uploadFile({
101
+ * environmentId: 'env_xxx',
102
+ * filename: 'app.py',
103
+ * path: 'src', // Optional: subdirectory
104
+ * content: 'print("Hello, world!")'
105
+ * });
106
+ * ```
107
+ */
108
+ async uploadFile(params) {
109
+ const { environmentId, path: relativePath, content, filename, contentType } = params;
110
+ if (!environmentId) {
111
+ throw new Error('environmentId is required for file upload');
112
+ }
113
+ // Create FormData for multipart upload
114
+ const formData = new FormData();
115
+ // Convert content to Blob
116
+ const contentBuffer = typeof content === 'string'
117
+ ? new TextEncoder().encode(content)
118
+ : content;
119
+ const blob = new Blob([contentBuffer], {
120
+ type: contentType || 'application/octet-stream'
121
+ });
122
+ formData.append('file', blob, filename);
123
+ if (relativePath) {
124
+ formData.append('path', relativePath);
125
+ }
126
+ // Make request with FormData (not JSON)
127
+ const url = `${this.client.getBaseUrl()}/environments/${environmentId}/files/upload`;
128
+ const response = await fetch(url, {
129
+ method: 'POST',
130
+ headers: {
131
+ 'Authorization': `Bearer ${this.client.getApiKey()}`,
132
+ },
133
+ body: formData,
134
+ });
135
+ if (!response.ok) {
136
+ const errorData = await response.json().catch(() => ({ error: response.statusText }));
137
+ throw new ApiClient_1.ApiClientError(errorData.message || errorData.error || 'Upload failed', response.status, errorData.code);
138
+ }
139
+ return response.json();
140
+ }
141
+ /**
142
+ * Delete a file from an environment workspace
143
+ *
144
+ * @param environmentId - The environment ID
145
+ * @param filePath - Path to the file to delete
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * await client.files.deleteFile('env_xxx', 'src/old-file.py');
150
+ * ```
151
+ */
152
+ async deleteFile(environmentId, filePath) {
153
+ const normalizedPath = filePath.replace(/^\/+/, '');
154
+ const encodedPath = normalizedPath
155
+ .split('/')
156
+ .map(encodeURIComponent)
157
+ .join('/');
158
+ return this.client.delete(`/environments/${environmentId}/files/${encodedPath}`);
159
+ }
160
+ /**
161
+ * Move or rename a file within an environment workspace
162
+ *
163
+ * @param params - Move parameters (environmentId, sourcePath, destPath)
164
+ * @returns Move result
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * await client.files.moveFile({
169
+ * environmentId: 'env_xxx',
170
+ * sourcePath: 'old-name.py',
171
+ * destPath: 'new-name.py'
172
+ * });
173
+ * ```
174
+ */
175
+ async moveFile(params) {
176
+ const { environmentId, sourcePath, destPath } = params;
177
+ return this.client.post(`/environments/${environmentId}/files/move`, { sourcePath, destPath });
178
+ }
179
+ /**
180
+ * Create a directory in an environment workspace
181
+ *
182
+ * Parent directories are created automatically if they don't exist.
183
+ *
184
+ * @param environmentId - The environment ID
185
+ * @param path - Directory path to create (relative to workspace root)
186
+ * @returns Create directory result
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * // Create a simple directory
191
+ * await client.files.createDirectory('env_xxx', 'src/components');
192
+ *
193
+ * // Create nested directories (parents created automatically)
194
+ * await client.files.createDirectory('env_xxx', 'src/components/ui/buttons');
195
+ * ```
196
+ */
197
+ async createDirectory(environmentId, path) {
198
+ // Normalize path - remove leading slash if present
199
+ const normalizedPath = path.replace(/^\/+/, '');
200
+ return this.client.post(`/environments/${environmentId}/files/mkdir`, { path: normalizedPath });
201
+ }
202
+ }
203
+ exports.FilesResource = FilesResource;
204
+ //# sourceMappingURL=FilesResource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilesResource.js","sourceRoot":"","sources":["../../../src/cloud/resources/FilesResource.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAGH,4CAA8C;AAuF9C,MAAa,aAAa;IACK;IAA7B,YAA6B,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAElD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,IAAI,CAAC,aAAqB;QAC9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAMnC,iBAAiB,aAAa,QAAQ,CAAC,CAAC;QAE3C,OAAO;YACL,aAAa;YACb,KAAK,EAAE,QAAQ,CAAC,IAAI;SACrB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,aAAqB;QACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAMnC,iBAAiB,aAAa,QAAQ,CAAC,CAAC;QAE3C,OAAO,QAAQ,CAAC,IAAI,C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, 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
+ }
@@ -0,0 +1,45 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Projects Resource Manager
3
+ *
4
+ * Handles project-related API operations including file management.
5
+ *
6
+ * Note: With the simplified API, each API key is bound to exactly one project.
7
+ * The project is determined automatically from the API key, so no projectId
8
+ * parameter is needed in method calls.
9
+ */
10
+ import type { ApiClient } from '../ApiClient';
11
+ import type { Project, UpdateProjectParams, ProjectStats, FileEntry, ListFilesParams, UploadFileParams, CreateDirectoryParams } from '../types';
12
+ export declare class ProjectsResource {
13
+ private readonly client;
14
+ constructor(client: ApiClient);
15
+ /**
16
+ * Get the current project (bound to this API key)
17
+ *
18
+ * Project is determined automatically from the API key.
19
+ */
20
+ get(): Promise<Project & {
21
+ stats?: ProjectStats;
22
+ }>;
23
+ /**
24
+ * Update the current project
25
+ *
26
+ * Project is determined automatically from the API key.
27
+ */
28
+ update(params: UpdateProjectParams): Promise<Project>;
29
+ /**
30
+ * Sync project with cloud storage
31
+ *
32
+ * Project is determined automatically from the API key.
33
+ */
34
+ sync(changes?: {
35
+ added?: string[];
36
+ modified?: string[];
37
+ deleted?: string[];
38
+ }): Promise<{
39
+ synced: boolean;
40
+ fileCount: number;
41
+ }>;
42
+ /**
43
+ * List files in the project
44
+ *
45
+ * Project is determined automatically from the API key.
46
+ */
47
+ listFiles(params?: ListFilesParams): Promise<FileEntry[]>;
48
+ /**
49
+ * Get a file's content
50
+ *
51
+ * Project is determined automatically from the API key.
52
+ */
53
+ getFile(filePath: string, environmentId?: string): Promise<string>;
54
+ /**
55
+ * Upload a file
56
+ *
57
+ * Project is determined automatically from the API key.
58
+ */
59
+ uploadFile(params: UploadFileParams): Promise<FileEntry>;
60
+ /**
61
+ * Delete a file or directory
62
+ *
63
+ * Project is determined automatically from the API key.
64
+ */
65
+ deleteFile(filePath: string, recursive?: boolean): Promise<void>;
66
+ /**
67
+ * Move or rename a file
68
+ *
69
+ * Project is determined automatically from the API key.
70
+ */
71
+ moveFile(sourcePath: string, destinationPath: string): Promise<FileEntry>;
72
+ /**
73
+ * Create a directory
74
+ *
75
+ * Project is determined automatically from the API key.
76
+ */
77
+ createDirectory(params: CreateDirectoryParams): Promise<FileEntry>;
78
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ /**
3
+ * Projects Resource Manager
4
+ *
5
+ * Handles project-related API operations including file management.
6
+ *
7
+ * Note: With the simplified API, each API key is bound to exactly one project.
8
+ * The project is determined automatically from the API key, so no projectId
9
+ * parameter is needed in method calls.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ProjectsResource = void 0;
13
+ class ProjectsResource {
14
+ client;
15
+ constructor(client) {
16
+ this.client = client;
17
+ }
18
+ /**
19
+ * Get the current project (bound to this API key)
20
+ *
21
+ * Project is determined automatically from the API key.
22
+ */
23
+ async get() {
24
+ const response = await this.client.get(`/project`);
25
+ return response.project;
26
+ }
27
+ /**
28
+ * Update the current project
29
+ *
30
+ * Project is determined automatically from the API key.
31
+ */
32
+ async update(params) {
33
+ const response = await this.client.patch(`/project`, params);
34
+ return response.project;
35
+ }
36
+ /**
37
+ * Sync project with cloud storage
38
+ *
39
+ * Project is determined automatically from the API key.
40
+ */
41
+ async sync(changes) {
42
+ const response = await this.client.post(`/project/sync`, { changes });
43
+ return response;
44
+ }
45
+ // =========================================================================
46
+ // File Operations
47
+ // =========================================================================
48
+ /**
49
+ * List files in the project
50
+ *
51
+ * Project is determined automatically from the API key.
52
+ */
53
+ async listFiles(params = {}) {
54
+ const response = await this.client.get(`/files`, {
55
+ path: params.path,
56
+ environmentId: params.environmentId,
57
+ recursive: params.recursive,
58
+ });
59
+ return response.files;
60
+ }
61
+ /**
62
+ * Get a file's content
63
+ *
64
+ * Project is determined automatically from the API key.
65
+ */
66
+ async getFile(filePath, environmentId) {
67
+ const encodedPath = encodeURIComponent(filePath);
68
+ const response = await this.client.get(`/files/${encodedPath}`, { environmentId });
69
+ return response;
70
+ }
71
+ /**
72
+ * Upload a file
73
+ *
74
+ * Project is determined automatically from the API key.
75
+ */
76
+ async uploadFile(params) {
77
+ // For single file upload, we use the PUT endpoint
78
+ const encodedPath = encodeURIComponent(params.path);
79
+ const response = await this.client.put(`/files/${encodedPath}`, {
80
+ content: typeof params.content === 'string'
81
+ ? params.content
82
+ : params.content.toString('base64'),
83
+ contentType: params.contentType,
84
+ environmentId: params.environmentId,
85
+ });
86
+ return response.file;
87
+ }
88
+ /**
89
+ * Delete a file or directory
90
+ *
91
+ * Project is determined automatically from the API key.
92
+ */
93
+ async deleteFile(filePath, recursive = false) {
94
+ const encodedPath = encodeURIComponent(filePath);
95
+ await this.client.delete(`/files/${encodedPath}${recursive ? '?recursive=true' : ''}`);
96
+ }
97
+ /**
98
+ * Move or rename a file
99
+ *
100
+ * Project is determined automatically from the API key.
101
+ */
102
+ async moveFile(sourcePath, destinationPath) {
103
+ const response = await this.client.post(`/files/move`, { source: sourcePath, destination: destinationPath });
104
+ return response.file;
105
+ }
106
+ /**
107
+ * Create a directory
108
+ *
109
+ * Project is determined automatically from the API key.
110
+ */
111
+ async createDirectory(params) {
112
+ const response = await this.client.post(`/directories`, params);
113
+ return response.directory;
114
+ }
115
+ }
116
+ exports.ProjectsResource = ProjectsResource;
117
+ //# sourceMappingURL=ProjectsResource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectsResource.js","sourceRoot":"","sources":["../../../src/cloud/resources/ProjectsResource.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAaH,MAAa,gBAAgB;IACE;IAA7B,YAA6B,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAElD;;;;OAIG;IACH,KAAK,CAAC,GAAG;QACP,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACpC,UAAU,CACX,CAAC;QACF,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,MAA2B;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CACtC,UAAU,EACV,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CACR,OAIC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAA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IAAI,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CACd,QAAgB,EAChB,YAAqB,KAAK;QAE1B,MAAM,WAAW,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACjD,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CACtB,UAAU,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CAC7D,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CACZ,UAAkB,EAClB,eAAuB;QAEvB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,aAAa,EACb,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,CACrD,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,eAAe,CACnB,MAA6B;QAE7B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,cAAc,EACd,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC,SAAS,CAAC;IAC5B,CAAC;CACF;AAzJD,4CAyJC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Runs Resource Manager
3
+ *
4
+ * Handles execution tracking including CRUD operations,
5
+ * logs retrieval, and file diffs.
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 { Run, CreateRunParams, UpdateRunParams, ListRunsParams, RunLogEntry, RunDiff } from '../types';
12
+ export declare class RunsResource {
13
+ private readonly client;
14
+ constructor(client: ApiClient);
15
+ /**
16
+ * Create a new run
17
+ *
18
+ * Project is determined automatically from the API key.
19
+ */
20
+ create(params: CreateRunParams): Promise<Run>;
21
+ /**
22
+ * List runs
23
+ *
24
+ * Project is determined automatically from the API key.
25
+ */
26
+ list(params?: ListRunsParams): Promise<{
27
+ runs: Run[];
28
+ pagination: {
29
+ total: number;
30
+ limit: number;
31
+ offset: number;
32
+ };
33
+ }>;
34
+ /**
35
+ * Get a run by ID
36
+ */
37
+ get(runId: string): Promise<Run>;
38
+ /**
39
+ * Update a run
40
+ */
41
+ update(runId: string, params: UpdateRunParams): Promise<Run>;
42
+ /**
43
+ * Delete a run
44
+ */
45
+ delete(runId: string): Promise<void>;
46
+ /**
47
+ * Get logs for a run
48
+ */
49
+ getLogs(runId: string, options?: {
50
+ level?: 'all' | 'info' | 'error';
51
+ format?: 'json' | 'text';
52
+ }): Promise<RunLogEntry[]>;
53
+ /**
54
+ * Append a log entry to a run
55
+ */
56
+ appendLog(runId: string, entry: Omit<RunLogEntry, 'timestamp'>): Promise<void>;
57
+ /**
58
+ * Get file diffs for a run
59
+ */
60
+ getDiffs(runId: string): Promise<RunDiff[]>;
61
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ /**
3
+ * Runs Resource Manager
4
+ *
5
+ * Handles execution tracking including CRUD operations,
6
+ * logs retrieval, and file diffs.
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.RunsResource = void 0;
13
+ class RunsResource {
14
+ client;
15
+ constructor(client) {
16
+ this.client = client;
17
+ }
18
+ /**
19
+ * Create a new run
20
+ *
21
+ * Project is determined automatically from the API key.
22
+ */
23
+ async create(params) {
24
+ const response = await this.client.post(`/runs`, params);
25
+ return response.run;
26
+ }
27
+ /**
28
+ * List runs
29
+ *
30
+ * Project is determined automatically from the API key.
31
+ */
32
+ async list(params = {}) {
33
+ const response = await this.client.get(`/runs`, {
34
+ limit: params.limit,
35
+ offset: params.offset,
36
+ threadId: params.threadId,
37
+ status: params.status,
38
+ since: params.since,
39
+ });
40
+ return response;
41
+ }
42
+ /**
43
+ * Get a run by ID
44
+ */
45
+ async get(runId) {
46
+ const response = await this.client.get(`/runs/${runId}`);
47
+ return response.run;
48
+ }
49
+ /**
50
+ * Update a run
51
+ */
52
+ async update(runId, params) {
53
+ const response = await this.client.patch(`/runs/${runId}`, params);
54
+ return response.run;
55
+ }
56
+ /**
57
+ * Delete a run
58
+ */
59
+ async delete(runId) {
60
+ await this.client.delete(`/runs/${runId}`);
61
+ }
62
+ /**
63
+ * Get logs for a run
64
+ */
65
+ async getLogs(runId, options) {
66
+ const response = await this.client.get(`/runs/${runId}/logs`, options);
67
+ return response.logs;
68
+ }
69
+ /**
70
+ * Append a log entry to a run
71
+ */
72
+ async appendLog(runId, entry) {
73
+ await this.client.post(`/runs/${runId}/logs`, entry);
74
+ }
75
+ /**
76
+ * Get file diffs for a run
77
+ */
78
+ async getDiffs(runId) {
79
+ const response = await this.client.get(`/threads/${runId}/diffs`);
80
+ return response.diffs;
81
+ }
82
+ }
83
+ exports.RunsResource = RunsResource;
84
+ //# sourceMappingURL=RunsResource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RunsResource.js","sourceRoot":"","sources":["../../../src/cloud/resources/RunsResource.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAYH,MAAa,YAAY;IACM;IAA7B,YAA6B,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAElD;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,MAAuB;QAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,OAAO,EACP,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC,GAAG,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,SAAyB,EAAE;QAIpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAGnC,OAAO,EAAE;YACV,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,MA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